Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18d0a6fd authored by Andy Lutomirski's avatar Andy Lutomirski Committed by H. Peter Anvin
Browse files

x86, vdso: Move the 32-bit vdso special pages after the text



This unifies the vdso mapping code and teaches it how to map special
pages at addresses corresponding to symbols in the vdso image.  The
new code is used for all vdso variants, but so far only the 32-bit
variants use the new vvar page position.

Signed-off-by: default avatarAndy Lutomirski <luto@amacapital.net>
Link: http://lkml.kernel.org/r/b6d7858ad7b5ac3fd3c29cab6d6d769bc45d195e.1399317206.git.luto@amacapital.net


Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent 6f121e54
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -333,11 +333,9 @@ struct linux_binprm;
#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
extern int arch_setup_additional_pages(struct linux_binprm *bprm,
				       int uses_interp);
extern int x32_setup_additional_pages(struct linux_binprm *bprm,
extern int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
					      int uses_interp);

extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
#define compat_arch_setup_additional_pages	syscall32_setup_pages
#define compat_arch_setup_additional_pages compat_arch_setup_additional_pages

extern unsigned long arch_randomize_brk(struct mm_struct *mm);
#define arch_randomize_brk arch_randomize_brk
+4 −0
Original line number Diff line number Diff line
@@ -14,6 +14,10 @@ struct vdso_image {

	unsigned long alt, alt_len;

	unsigned long sym_end_mapping;  /* Total size of the mapping */

	unsigned long sym_vvar_page;
	unsigned long sym_hpet_page;
	unsigned long sym_VDSO32_NOTE_MASK;
	unsigned long sym___kernel_sigreturn;
	unsigned long sym___kernel_rt_sigreturn;

arch/x86/include/asm/vdso32.h

deleted100644 → 0
+0 −11
Original line number Diff line number Diff line
#ifndef _ASM_X86_VDSO32_H
#define _ASM_X86_VDSO32_H

#define VDSO_BASE_PAGE	0
#define VDSO_VVAR_PAGE	1
#define VDSO_HPET_PAGE	2
#define VDSO_PAGES	3
#define VDSO_PREV_PAGES	2
#define VDSO_OFFSET(x)	((x) * PAGE_SIZE)

#endif
+26 −16
Original line number Diff line number Diff line
#include <asm/vdso.h>

/*
 * Linker script for vDSO.  This is an ELF shared object prelinked to
 * its virtual address, and with only one read-only segment.
@@ -6,20 +8,6 @@

SECTIONS
{
#ifdef BUILD_VDSO32
#include <asm/vdso32.h>

	hpet_page = . - VDSO_OFFSET(VDSO_HPET_PAGE);

	vvar = . - VDSO_OFFSET(VDSO_VVAR_PAGE);

	/* Place all vvars at the offsets in asm/vvar.h. */
#define EMIT_VVAR(name, offset) vvar_ ## name = vvar + offset;
#define __VVAR_KERNEL_LDS
#include <asm/vvar.h>
#undef __VVAR_KERNEL_LDS
#undef EMIT_VVAR
#endif
	. = SIZEOF_HEADERS;

	.hash		: { *(.hash) }			:text
@@ -59,11 +47,33 @@ SECTIONS

	.text		: { *(.text*) }			:text	=0x90909090,

#ifdef BUILD_VDSO32
	/*
	 * The comma above works around a bug in gold:
	 * https://sourceware.org/bugzilla/show_bug.cgi?id=16804
	 * The remainder of the vDSO consists of special pages that are
	 * shared between the kernel and userspace.  It needs to be at the
	 * end so that it doesn't overlap the mapping of the actual
	 * vDSO image.
	 */

	. = ALIGN(PAGE_SIZE);
	vvar_page = .;

	/* Place all vvars at the offsets in asm/vvar.h. */
#define EMIT_VVAR(name, offset) vvar_ ## name = vvar_page + offset;
#define __VVAR_KERNEL_LDS
#include <asm/vvar.h>
#undef __VVAR_KERNEL_LDS
#undef EMIT_VVAR

	. = vvar_page + PAGE_SIZE;

	hpet_page = .;
	. = . + PAGE_SIZE;
#endif

	. = ALIGN(PAGE_SIZE);
	end_mapping = .;

	/DISCARD/ : {
		*(.discard)
		*(.discard.*)
+14 −0
Original line number Diff line number Diff line
@@ -15,7 +15,21 @@
#include <linux/types.h>

/* Symbols that we need in vdso2c. */
enum {
	sym_vvar_page,
	sym_hpet_page,
	sym_end_mapping,
};

const int special_pages[] = {
	sym_vvar_page,
	sym_hpet_page,
};

char const * const required_syms[] = {
	[sym_vvar_page] = "vvar_page",
	[sym_hpet_page] = "hpet_page",
	[sym_end_mapping] = "end_mapping",
	"VDSO32_NOTE_MASK",
	"VDSO32_SYSENTER_RETURN",
	"__kernel_vsyscall",
Loading