Commit d223246e authored by Anders Kaseorg's avatar Anders Kaseorg Committed by H. Peter Anvin

x86: fix fragile computation of vsyscall address

Previously, the address of the vsyscall page (VSYSCALL_PHYS_ADDR,
VSYSCALL_VIRT_ADDR) was computed by arithmetic on the address of the
last section.  This leads to bugs when new sections are inserted, such
as the one fixed by commit d312ceda.
Let's compute it from the current address instead.
Signed-off-by: default avatarAnders Kaseorg <andersk@ksplice.com>
Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
parent daf7b9c9
...@@ -135,24 +135,21 @@ SECTIONS ...@@ -135,24 +135,21 @@ SECTIONS
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
#define VSYSCALL_ADDR (-10*1024*1024) #define VSYSCALL_ADDR (-10*1024*1024)
#define VSYSCALL_PHYS_ADDR ((LOADADDR(.data) + SIZEOF(.data) + \
PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
#define VSYSCALL_VIRT_ADDR ((ADDR(.data) + SIZEOF(.data) + \
PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
#define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR) #define VLOAD_OFFSET (VSYSCALL_ADDR - __vsyscall_0 + LOAD_OFFSET)
#define VLOAD(x) (ADDR(x) - VLOAD_OFFSET) #define VLOAD(x) (ADDR(x) - VLOAD_OFFSET)
#define VVIRT_OFFSET (VSYSCALL_ADDR - VSYSCALL_VIRT_ADDR) #define VVIRT_OFFSET (VSYSCALL_ADDR - __vsyscall_0)
#define VVIRT(x) (ADDR(x) - VVIRT_OFFSET) #define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
. = ALIGN(4096);
__vsyscall_0 = .;
. = VSYSCALL_ADDR; . = VSYSCALL_ADDR;
.vsyscall_0 : AT(VSYSCALL_PHYS_ADDR) { .vsyscall_0 : AT(VLOAD(.vsyscall_0)) {
*(.vsyscall_0) *(.vsyscall_0)
} :user } :user
__vsyscall_0 = VSYSCALL_VIRT_ADDR;
. = ALIGN(CONFIG_X86_L1_CACHE_BYTES); . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
.vsyscall_fn : AT(VLOAD(.vsyscall_fn)) { .vsyscall_fn : AT(VLOAD(.vsyscall_fn)) {
*(.vsyscall_fn) *(.vsyscall_fn)
...@@ -192,11 +189,9 @@ SECTIONS ...@@ -192,11 +189,9 @@ SECTIONS
*(.vsyscall_3) *(.vsyscall_3)
} }
. = VSYSCALL_VIRT_ADDR + PAGE_SIZE; . = __vsyscall_0 + PAGE_SIZE;
#undef VSYSCALL_ADDR #undef VSYSCALL_ADDR
#undef VSYSCALL_PHYS_ADDR
#undef VSYSCALL_VIRT_ADDR
#undef VLOAD_OFFSET #undef VLOAD_OFFSET
#undef VLOAD #undef VLOAD
#undef VVIRT_OFFSET #undef VVIRT_OFFSET
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment