linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] x86/vdso: Remove remnants of the fake section table
@ 2018-12-04 21:25 Sean Christopherson
  2018-12-04 21:25 ` [PATCH v2 1/4] x86/vdso: Remove obsolete "fake section table" reservation Sean Christopherson
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Sean Christopherson @ 2018-12-04 21:25 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86
  Cc: H. Peter Anvin, linux-kernel, Andy Lutomirski

Remove pieces of the vDSO's fake section table mechanism that were left
behind when the vDSO build process reverted to using "objdump -S" to
strip the userspace image.

One of the removed pieces is a 0x340 byte reservation (for 64-bit) in
the .rodata section.  Trimming that fat drops the current image's size
to under 4k, i.e. reduces the effective size of the userspace vDSO
mapping by a full page.

v1->v2:
  - Remove the definition of sym_VDSO_FAKE_SECTION_TABLE_*
  - Add patches 3/4 and 4/4 for additional cleanup

Sean Christopherson (4):
  x86/vdso: Remove obsolete "fake section table" reservation
  x86/vdso: Remove a stale/misleading comment from the linker script
  x86/vdso: Remove struct vdso_sym and its associated export option
  x86/vdso: Rename "required_syms" to "requested_syms"

 arch/x86/entry/vdso/vdso-layout.lds.S | 27 -------------------
 arch/x86/entry/vdso/vdso2c.c          | 37 +++++++++------------------
 arch/x86/entry/vdso/vdso2c.h          | 15 +++++------
 3 files changed, 19 insertions(+), 60 deletions(-)

-- 
2.19.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/4] x86/vdso: Remove obsolete "fake section table" reservation
  2018-12-04 21:25 [PATCH v2 0/4] x86/vdso: Remove remnants of the fake section table Sean Christopherson
@ 2018-12-04 21:25 ` Sean Christopherson
  2018-12-04 22:48   ` Andy Lutomirski
  2018-12-05 18:03   ` [tip:x86/asm] " tip-bot for Sean Christopherson
  2018-12-04 21:25 ` [PATCH v2 2/4] x86/vdso: Remove a stale/misleading comment from the linker script Sean Christopherson
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 9+ messages in thread
From: Sean Christopherson @ 2018-12-04 21:25 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86
  Cc: H. Peter Anvin, linux-kernel, Andy Lutomirski

At one point the vDSO image was manually stripped down by vdso2c in an
attempt to minimize the size of the image mapped into userspace.  Part
of that stripping process involved building a fake section table so as
not to break userspace processes that parse the section table.  Memory
for the fake section table was reserved in the .rodata section so that
vdso2c could simply copy the entire PT_LOAD segment into the userspace
image after building the fake table.

Eventually, the entire fake section table approach was dropped in favor
of stripping the vdso "the old fashioned way", i.e. via objdump -S.
But, the reservation in .rodata for the fake table was left behind.
Remove the reserveration along with a few other related defines and
section entries.

Removing the fake section table placeholder zaps a whopping 0x340 bytes
from the 64-bit vDSO image, which drops the current image's size to
under 4k, i.e. reduces the effective size of the userspace vDSO mapping
by a full page.

Fixes: da861e18eccc ("x86, vdso: Get rid of the fake section mechanism")
Cc: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 arch/x86/entry/vdso/vdso-layout.lds.S | 22 ----------------------
 arch/x86/entry/vdso/vdso2c.c          |  8 --------
 2 files changed, 30 deletions(-)

diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/vdso-layout.lds.S
index acfd5ba7d943..0cedc905c8d6 100644
--- a/arch/x86/entry/vdso/vdso-layout.lds.S
+++ b/arch/x86/entry/vdso/vdso-layout.lds.S
@@ -7,16 +7,6 @@
  * This script controls its layout.
  */
 
-#if defined(BUILD_VDSO64)
-# define SHDR_SIZE 64
-#elif defined(BUILD_VDSO32) || defined(BUILD_VDSOX32)
-# define SHDR_SIZE 40
-#else
-# error unknown VDSO target
-#endif
-
-#define NUM_FAKE_SHDRS 13
-
 SECTIONS
 {
 	/*
@@ -60,20 +50,8 @@ SECTIONS
 		*(.bss*)
 		*(.dynbss*)
 		*(.gnu.linkonce.b.*)
-
-		/*
-		 * Ideally this would live in a C file, but that won't
-		 * work cleanly for x32 until we start building the x32
-		 * C code using an x32 toolchain.
-		 */
-		VDSO_FAKE_SECTION_TABLE_START = .;
-		. = . + NUM_FAKE_SHDRS * SHDR_SIZE;
-		VDSO_FAKE_SECTION_TABLE_END = .;
 	}						:text
 
-	.fake_shstrtab	: { *(.fake_shstrtab) }		:text
-
-
 	.note		: { *(.note.*) }		:text	:note
 
 	.eh_frame_hdr	: { *(.eh_frame_hdr) }		:text	:eh_frame_hdr
diff --git a/arch/x86/entry/vdso/vdso2c.c b/arch/x86/entry/vdso/vdso2c.c
index 4674f58581a1..8e470b018512 100644
--- a/arch/x86/entry/vdso/vdso2c.c
+++ b/arch/x86/entry/vdso/vdso2c.c
@@ -76,8 +76,6 @@ enum {
 	sym_hpet_page,
 	sym_pvclock_page,
 	sym_hvclock_page,
-	sym_VDSO_FAKE_SECTION_TABLE_START,
-	sym_VDSO_FAKE_SECTION_TABLE_END,
 };
 
 const int special_pages[] = {
@@ -98,12 +96,6 @@ struct vdso_sym required_syms[] = {
 	[sym_hpet_page] = {"hpet_page", true},
 	[sym_pvclock_page] = {"pvclock_page", true},
 	[sym_hvclock_page] = {"hvclock_page", true},
-	[sym_VDSO_FAKE_SECTION_TABLE_START] = {
-		"VDSO_FAKE_SECTION_TABLE_START", false
-	},
-	[sym_VDSO_FAKE_SECTION_TABLE_END] = {
-		"VDSO_FAKE_SECTION_TABLE_END", false
-	},
 	{"VDSO32_NOTE_MASK", true},
 	{"__kernel_vsyscall", true},
 	{"__kernel_sigreturn", true},
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/4] x86/vdso: Remove a stale/misleading comment from the linker script
  2018-12-04 21:25 [PATCH v2 0/4] x86/vdso: Remove remnants of the fake section table Sean Christopherson
  2018-12-04 21:25 ` [PATCH v2 1/4] x86/vdso: Remove obsolete "fake section table" reservation Sean Christopherson
@ 2018-12-04 21:25 ` Sean Christopherson
  2018-12-04 22:49   ` Andy Lutomirski
  2018-12-05 18:04   ` [tip:x86/asm] " tip-bot for Sean Christopherson
  2018-12-04 21:25 ` [PATCH v2 3/4] x86/vdso: Remove struct vdso_sym and its associated export option Sean Christopherson
  2018-12-04 21:26 ` [PATCH v2 4/4] x86/vdso: Rename "required_syms" to "requested_syms" Sean Christopherson
  3 siblings, 2 replies; 9+ messages in thread
From: Sean Christopherson @ 2018-12-04 21:25 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86
  Cc: H. Peter Anvin, linux-kernel, Andy Lutomirski

Once upon a time, vdso2c aggressively stripped data from the vDSO
image when generating the final userspace image.  This included
stripping the .altinstructions and .altinstr_replacement sections.
Eventually, the stripping process reverted to "objdump -S" and no
longer removed the aforementioned sections, but the comment remained.

Keeping the .alt* sections at the end of the PT_LOAD segment is no
longer necessary, but there's no harm in doing so and it's a helpful
reminder that they don't need to be included in the final vDSO image,
i.e. someone may want to take another stab at zapping/stripping the
unneeded sections.

Fixes: da861e18eccc ("x86, vdso: Get rid of the fake section mechanism")
Cc: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Acked-by: Andy Lutomirski <luto@kernel.org>
---
 arch/x86/entry/vdso/vdso-layout.lds.S | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/vdso-layout.lds.S
index 0cedc905c8d6..93c6dc7812d0 100644
--- a/arch/x86/entry/vdso/vdso-layout.lds.S
+++ b/arch/x86/entry/vdso/vdso-layout.lds.S
@@ -65,11 +65,6 @@ SECTIONS
 
 	.text		: { *(.text*) }			:text	=0x90909090,
 
-	/*
-	 * At the end so that eu-elflint stays happy when vdso2c strips
-	 * these.  A better implementation would avoid allocating space
-	 * for these.
-	 */
 	.altinstructions	: { *(.altinstructions) }	:text
 	.altinstr_replacement	: { *(.altinstr_replacement) }	:text
 
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 3/4] x86/vdso: Remove struct vdso_sym and its associated export option
  2018-12-04 21:25 [PATCH v2 0/4] x86/vdso: Remove remnants of the fake section table Sean Christopherson
  2018-12-04 21:25 ` [PATCH v2 1/4] x86/vdso: Remove obsolete "fake section table" reservation Sean Christopherson
  2018-12-04 21:25 ` [PATCH v2 2/4] x86/vdso: Remove a stale/misleading comment from the linker script Sean Christopherson
@ 2018-12-04 21:25 ` Sean Christopherson
  2018-12-04 21:26 ` [PATCH v2 4/4] x86/vdso: Rename "required_syms" to "requested_syms" Sean Christopherson
  3 siblings, 0 replies; 9+ messages in thread
From: Sean Christopherson @ 2018-12-04 21:25 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86
  Cc: H. Peter Anvin, linux-kernel, Andy Lutomirski

...now that all required symbols are exported by vdso2c.

Cc: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---

Regarding Andy's concern that we might want the exported flag in the
future for exception fixup, I prototyped a few approaches and in the
end we always need to know at least the base of the original extable
so that we have an anchor point for the relative IPs.  Technically
it's possible to omit the length/end, but doing so requires making
either vdso2c or the kernel code more complex than it needs to be.
So, regardless of whether we use symbols or sections for extable, I'm
fairly confident we'll want to export the result to the .c file.

 arch/x86/entry/vdso/vdso2c.c | 27 +++++++++++----------------
 arch/x86/entry/vdso/vdso2c.h | 15 +++++++--------
 2 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/arch/x86/entry/vdso/vdso2c.c b/arch/x86/entry/vdso/vdso2c.c
index 8e470b018512..a175cd2016c9 100644
--- a/arch/x86/entry/vdso/vdso2c.c
+++ b/arch/x86/entry/vdso/vdso2c.c
@@ -85,22 +85,17 @@ const int special_pages[] = {
 	sym_hvclock_page,
 };
 
-struct vdso_sym {
-	const char *name;
-	bool export;
-};
-
-struct vdso_sym required_syms[] = {
-	[sym_vvar_start] = {"vvar_start", true},
-	[sym_vvar_page] = {"vvar_page", true},
-	[sym_hpet_page] = {"hpet_page", true},
-	[sym_pvclock_page] = {"pvclock_page", true},
-	[sym_hvclock_page] = {"hvclock_page", true},
-	{"VDSO32_NOTE_MASK", true},
-	{"__kernel_vsyscall", true},
-	{"__kernel_sigreturn", true},
-	{"__kernel_rt_sigreturn", true},
-	{"int80_landing_pad", true},
+const char *required_syms[] = {
+	[sym_vvar_start] = "vvar_start",
+	[sym_vvar_page] = "vvar_page",
+	[sym_hpet_page] = "hpet_page",
+	[sym_pvclock_page] = "pvclock_page",
+	[sym_hvclock_page] = "hvclock_page",
+	"VDSO32_NOTE_MASK",
+	"__kernel_vsyscall",
+	"__kernel_sigreturn",
+	"__kernel_rt_sigreturn",
+	"int80_landing_pad",
 };
 
 __attribute__((format(printf, 1, 2))) __attribute__((noreturn))
diff --git a/arch/x86/entry/vdso/vdso2c.h b/arch/x86/entry/vdso/vdso2c.h
index fa847a620f40..14003d311298 100644
--- a/arch/x86/entry/vdso/vdso2c.h
+++ b/arch/x86/entry/vdso/vdso2c.h
@@ -97,10 +97,10 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
 			GET_LE(&sym->st_name);
 
 		for (k = 0; k < NSYMS; k++) {
-			if (!strcmp(name, required_syms[k].name)) {
+			if (!strcmp(name, required_syms[k])) {
 				if (syms[k]) {
 					fail("duplicate symbol %s\n",
-					     required_syms[k].name);
+					     required_syms[k]);
 				}
 
 				/*
@@ -123,13 +123,12 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
 
 		if (symval % 4096)
 			fail("%s must be a multiple of 4096\n",
-			     required_syms[i].name);
+			     required_syms[i]);
 		if (symval + 4096 < syms[sym_vvar_start])
-			fail("%s underruns vvar_start\n",
-			     required_syms[i].name);
+			fail("%s underruns vvar_start\n", required_syms[i]);
 		if (symval + 4096 > 0)
 			fail("%s is on the wrong side of the vdso text\n",
-			     required_syms[i].name);
+			     required_syms[i]);
 	}
 	if (syms[sym_vvar_start] % 4096)
 		fail("vvar_begin must be a multiple of 4096\n");
@@ -167,9 +166,9 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
 			(unsigned long)GET_LE(&alt_sec->sh_size));
 	}
 	for (i = 0; i < NSYMS; i++) {
-		if (required_syms[i].export && syms[i])
+		if (syms[i])
 			fprintf(outfile, "\t.sym_%s = %" PRIi64 ",\n",
-				required_syms[i].name, (int64_t)syms[i]);
+				required_syms[i], (int64_t)syms[i]);
 	}
 	fprintf(outfile, "};\n");
 }
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 4/4] x86/vdso: Rename "required_syms" to "requested_syms"
  2018-12-04 21:25 [PATCH v2 0/4] x86/vdso: Remove remnants of the fake section table Sean Christopherson
                   ` (2 preceding siblings ...)
  2018-12-04 21:25 ` [PATCH v2 3/4] x86/vdso: Remove struct vdso_sym and its associated export option Sean Christopherson
@ 2018-12-04 21:26 ` Sean Christopherson
  3 siblings, 0 replies; 9+ messages in thread
From: Sean Christopherson @ 2018-12-04 21:26 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86
  Cc: H. Peter Anvin, linux-kernel, Andy Lutomirski

The "required" moniker implies that vdso2c will fail if one of the
defined symbols is not found, which is simply not true, e.g.
VDSO32_NOTE_MASK is quite obviously 32-bit only and not required
for the 64-bit image.

Cc: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 arch/x86/entry/vdso/vdso2c.c |  4 ++--
 arch/x86/entry/vdso/vdso2c.h | 12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/x86/entry/vdso/vdso2c.c b/arch/x86/entry/vdso/vdso2c.c
index a175cd2016c9..b2acdaffc66d 100644
--- a/arch/x86/entry/vdso/vdso2c.c
+++ b/arch/x86/entry/vdso/vdso2c.c
@@ -85,7 +85,7 @@ const int special_pages[] = {
 	sym_hvclock_page,
 };
 
-const char *required_syms[] = {
+const char *requested_syms[] = {
 	[sym_vvar_start] = "vvar_start",
 	[sym_vvar_page] = "vvar_page",
 	[sym_hpet_page] = "hpet_page",
@@ -139,7 +139,7 @@ extern void bad_put_le(void);
 	PLE(x, val, 64, PLE(x, val, 32, PLE(x, val, 16, LAST_PLE(x, val))))
 
 
-#define NSYMS ARRAY_SIZE(required_syms)
+#define NSYMS ARRAY_SIZE(requested_syms)
 
 #define BITSFUNC3(name, bits, suffix) name##bits##suffix
 #define BITSFUNC2(name, bits, suffix) BITSFUNC3(name, bits, suffix)
diff --git a/arch/x86/entry/vdso/vdso2c.h b/arch/x86/entry/vdso/vdso2c.h
index 14003d311298..6c5a290ce468 100644
--- a/arch/x86/entry/vdso/vdso2c.h
+++ b/arch/x86/entry/vdso/vdso2c.h
@@ -97,10 +97,10 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
 			GET_LE(&sym->st_name);
 
 		for (k = 0; k < NSYMS; k++) {
-			if (!strcmp(name, required_syms[k])) {
+			if (!strcmp(name, requested_syms[k])) {
 				if (syms[k]) {
 					fail("duplicate symbol %s\n",
-					     required_syms[k]);
+					     requested_syms[k]);
 				}
 
 				/*
@@ -123,12 +123,12 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
 
 		if (symval % 4096)
 			fail("%s must be a multiple of 4096\n",
-			     required_syms[i]);
+			     requested_syms[i]);
 		if (symval + 4096 < syms[sym_vvar_start])
-			fail("%s underruns vvar_start\n", required_syms[i]);
+			fail("%s underruns vvar_start\n", requested_syms[i]);
 		if (symval + 4096 > 0)
 			fail("%s is on the wrong side of the vdso text\n",
-			     required_syms[i]);
+			     requested_syms[i]);
 	}
 	if (syms[sym_vvar_start] % 4096)
 		fail("vvar_begin must be a multiple of 4096\n");
@@ -168,7 +168,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
 	for (i = 0; i < NSYMS; i++) {
 		if (syms[i])
 			fprintf(outfile, "\t.sym_%s = %" PRIi64 ",\n",
-				required_syms[i], (int64_t)syms[i]);
+				requested_syms[i], (int64_t)syms[i]);
 	}
 	fprintf(outfile, "};\n");
 }
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/4] x86/vdso: Remove obsolete "fake section table" reservation
  2018-12-04 21:25 ` [PATCH v2 1/4] x86/vdso: Remove obsolete "fake section table" reservation Sean Christopherson
@ 2018-12-04 22:48   ` Andy Lutomirski
  2018-12-05 18:03   ` [tip:x86/asm] " tip-bot for Sean Christopherson
  1 sibling, 0 replies; 9+ messages in thread
From: Andy Lutomirski @ 2018-12-04 22:48 UTC (permalink / raw)
  To: Christopherson, Sean J
  Cc: Andrew Lutomirski, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	X86 ML, H. Peter Anvin, LKML

On Tue, Dec 4, 2018 at 1:26 PM Sean Christopherson
<sean.j.christopherson@intel.com> wrote:
>
> At one point the vDSO image was manually stripped down by vdso2c in an
> attempt to minimize the size of the image mapped into userspace.  Part
> of that stripping process involved building a fake section table so as
> not to break userspace processes that parse the section table.  Memory
> for the fake section table was reserved in the .rodata section so that
> vdso2c could simply copy the entire PT_LOAD segment into the userspace
> image after building the fake table.
>
> Eventually, the entire fake section table approach was dropped in favor
> of stripping the vdso "the old fashioned way", i.e. via objdump -S.
> But, the reservation in .rodata for the fake table was left behind.
> Remove the reserveration along with a few other related defines and
> section entries.
>
> Removing the fake section table placeholder zaps a whopping 0x340 bytes
> from the 64-bit vDSO image, which drops the current image's size to
> under 4k, i.e. reduces the effective size of the userspace vDSO mapping
> by a full page.

Acked-by: Andy Lutomirski <luto@kernel.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/4] x86/vdso: Remove a stale/misleading comment from the linker script
  2018-12-04 21:25 ` [PATCH v2 2/4] x86/vdso: Remove a stale/misleading comment from the linker script Sean Christopherson
@ 2018-12-04 22:49   ` Andy Lutomirski
  2018-12-05 18:04   ` [tip:x86/asm] " tip-bot for Sean Christopherson
  1 sibling, 0 replies; 9+ messages in thread
From: Andy Lutomirski @ 2018-12-04 22:49 UTC (permalink / raw)
  To: Christopherson, Sean J
  Cc: Andrew Lutomirski, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	X86 ML, H. Peter Anvin, LKML

On Tue, Dec 4, 2018 at 1:26 PM Sean Christopherson
<sean.j.christopherson@intel.com> wrote:
>
> Once upon a time, vdso2c aggressively stripped data from the vDSO
> image when generating the final userspace image.  This included
> stripping the .altinstructions and .altinstr_replacement sections.
> Eventually, the stripping process reverted to "objdump -S" and no
> longer removed the aforementioned sections, but the comment remained.
>
> Keeping the .alt* sections at the end of the PT_LOAD segment is no
> longer necessary, but there's no harm in doing so and it's a helpful
> reminder that they don't need to be included in the final vDSO image,
> i.e. someone may want to take another stab at zapping/stripping the
> unneeded sections.

Acked-by: Andy Lutomirski <luto@kernel.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [tip:x86/asm] x86/vdso: Remove obsolete "fake section table" reservation
  2018-12-04 21:25 ` [PATCH v2 1/4] x86/vdso: Remove obsolete "fake section table" reservation Sean Christopherson
  2018-12-04 22:48   ` Andy Lutomirski
@ 2018-12-05 18:03   ` tip-bot for Sean Christopherson
  1 sibling, 0 replies; 9+ messages in thread
From: tip-bot for Sean Christopherson @ 2018-12-05 18:03 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: bp, hpa, riel, dvlasenk, sean.j.christopherson, peterz, torvalds,
	brgerst, dave.hansen, luto, tglx, linux-kernel, mingo

Commit-ID:  24b7c77bbb24f129beead93574ff248c3db1288e
Gitweb:     https://git.kernel.org/tip/24b7c77bbb24f129beead93574ff248c3db1288e
Author:     Sean Christopherson <sean.j.christopherson@intel.com>
AuthorDate: Tue, 4 Dec 2018 13:25:57 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 5 Dec 2018 08:58:11 +0100

x86/vdso: Remove obsolete "fake section table" reservation

At one point the vDSO image was manually stripped down by vdso2c in an
attempt to minimize the size of the image mapped into userspace.  Part
of that stripping process involved building a fake section table so as
not to break userspace processes that parse the section table.  Memory
for the fake section table was reserved in the .rodata section so that
vdso2c could simply copy the entire PT_LOAD segment into the userspace
image after building the fake table.

Eventually, the entire fake section table approach was dropped in favor
of stripping the vdso "the old fashioned way", i.e. via objdump -S.
But, the reservation in .rodata for the fake table was left behind.
Remove the reserveration along with a few other related defines and
section entries.

Removing the fake section table placeholder zaps a whopping 0x340 bytes
from the 64-bit vDSO image, which drops the current image's size to
under 4k, i.e. reduces the effective size of the userspace vDSO mapping
by a full page.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Acked-by: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: da861e18eccc ("x86, vdso: Get rid of the fake section mechanism")
Link: http://lkml.kernel.org/r/20181204212600.28090-2-sean.j.christopherson@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/entry/vdso/vdso-layout.lds.S | 22 ----------------------
 arch/x86/entry/vdso/vdso2c.c          |  8 --------
 2 files changed, 30 deletions(-)

diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/vdso-layout.lds.S
index acfd5ba7d943..0cedc905c8d6 100644
--- a/arch/x86/entry/vdso/vdso-layout.lds.S
+++ b/arch/x86/entry/vdso/vdso-layout.lds.S
@@ -7,16 +7,6 @@
  * This script controls its layout.
  */
 
-#if defined(BUILD_VDSO64)
-# define SHDR_SIZE 64
-#elif defined(BUILD_VDSO32) || defined(BUILD_VDSOX32)
-# define SHDR_SIZE 40
-#else
-# error unknown VDSO target
-#endif
-
-#define NUM_FAKE_SHDRS 13
-
 SECTIONS
 {
 	/*
@@ -60,20 +50,8 @@ SECTIONS
 		*(.bss*)
 		*(.dynbss*)
 		*(.gnu.linkonce.b.*)
-
-		/*
-		 * Ideally this would live in a C file, but that won't
-		 * work cleanly for x32 until we start building the x32
-		 * C code using an x32 toolchain.
-		 */
-		VDSO_FAKE_SECTION_TABLE_START = .;
-		. = . + NUM_FAKE_SHDRS * SHDR_SIZE;
-		VDSO_FAKE_SECTION_TABLE_END = .;
 	}						:text
 
-	.fake_shstrtab	: { *(.fake_shstrtab) }		:text
-
-
 	.note		: { *(.note.*) }		:text	:note
 
 	.eh_frame_hdr	: { *(.eh_frame_hdr) }		:text	:eh_frame_hdr
diff --git a/arch/x86/entry/vdso/vdso2c.c b/arch/x86/entry/vdso/vdso2c.c
index 4674f58581a1..8e470b018512 100644
--- a/arch/x86/entry/vdso/vdso2c.c
+++ b/arch/x86/entry/vdso/vdso2c.c
@@ -76,8 +76,6 @@ enum {
 	sym_hpet_page,
 	sym_pvclock_page,
 	sym_hvclock_page,
-	sym_VDSO_FAKE_SECTION_TABLE_START,
-	sym_VDSO_FAKE_SECTION_TABLE_END,
 };
 
 const int special_pages[] = {
@@ -98,12 +96,6 @@ struct vdso_sym required_syms[] = {
 	[sym_hpet_page] = {"hpet_page", true},
 	[sym_pvclock_page] = {"pvclock_page", true},
 	[sym_hvclock_page] = {"hvclock_page", true},
-	[sym_VDSO_FAKE_SECTION_TABLE_START] = {
-		"VDSO_FAKE_SECTION_TABLE_START", false
-	},
-	[sym_VDSO_FAKE_SECTION_TABLE_END] = {
-		"VDSO_FAKE_SECTION_TABLE_END", false
-	},
 	{"VDSO32_NOTE_MASK", true},
 	{"__kernel_vsyscall", true},
 	{"__kernel_sigreturn", true},

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [tip:x86/asm] x86/vdso: Remove a stale/misleading comment from the linker script
  2018-12-04 21:25 ` [PATCH v2 2/4] x86/vdso: Remove a stale/misleading comment from the linker script Sean Christopherson
  2018-12-04 22:49   ` Andy Lutomirski
@ 2018-12-05 18:04   ` tip-bot for Sean Christopherson
  1 sibling, 0 replies; 9+ messages in thread
From: tip-bot for Sean Christopherson @ 2018-12-05 18:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: luto, tglx, dave.hansen, sean.j.christopherson, peterz, bp, riel,
	dvlasenk, mingo, brgerst, hpa, linux-kernel, torvalds

Commit-ID:  29434801e7e9c6d05fbea4533b3c0bd6be612f62
Gitweb:     https://git.kernel.org/tip/29434801e7e9c6d05fbea4533b3c0bd6be612f62
Author:     Sean Christopherson <sean.j.christopherson@intel.com>
AuthorDate: Tue, 4 Dec 2018 13:25:58 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 5 Dec 2018 08:58:12 +0100

x86/vdso: Remove a stale/misleading comment from the linker script

Once upon a time, vdso2c aggressively stripped data from the vDSO
image when generating the final userspace image.  This included
stripping the .altinstructions and .altinstr_replacement sections.
Eventually, the stripping process reverted to "objdump -S" and no
longer removed the aforementioned sections, but the comment remained.

Keeping the .alt* sections at the end of the PT_LOAD segment is no
longer necessary, but there's no harm in doing so and it's a helpful
reminder that they don't need to be included in the final vDSO image,
i.e. someone may want to take another stab at zapping/stripping the
unneeded sections.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Acked-by: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: da861e18eccc ("x86, vdso: Get rid of the fake section mechanism")
Link: http://lkml.kernel.org/r/20181204212600.28090-3-sean.j.christopherson@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/entry/vdso/vdso-layout.lds.S | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/vdso-layout.lds.S
index 0cedc905c8d6..93c6dc7812d0 100644
--- a/arch/x86/entry/vdso/vdso-layout.lds.S
+++ b/arch/x86/entry/vdso/vdso-layout.lds.S
@@ -65,11 +65,6 @@ SECTIONS
 
 	.text		: { *(.text*) }			:text	=0x90909090,
 
-	/*
-	 * At the end so that eu-elflint stays happy when vdso2c strips
-	 * these.  A better implementation would avoid allocating space
-	 * for these.
-	 */
 	.altinstructions	: { *(.altinstructions) }	:text
 	.altinstr_replacement	: { *(.altinstr_replacement) }	:text
 

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-12-05 18:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-04 21:25 [PATCH v2 0/4] x86/vdso: Remove remnants of the fake section table Sean Christopherson
2018-12-04 21:25 ` [PATCH v2 1/4] x86/vdso: Remove obsolete "fake section table" reservation Sean Christopherson
2018-12-04 22:48   ` Andy Lutomirski
2018-12-05 18:03   ` [tip:x86/asm] " tip-bot for Sean Christopherson
2018-12-04 21:25 ` [PATCH v2 2/4] x86/vdso: Remove a stale/misleading comment from the linker script Sean Christopherson
2018-12-04 22:49   ` Andy Lutomirski
2018-12-05 18:04   ` [tip:x86/asm] " tip-bot for Sean Christopherson
2018-12-04 21:25 ` [PATCH v2 3/4] x86/vdso: Remove struct vdso_sym and its associated export option Sean Christopherson
2018-12-04 21:26 ` [PATCH v2 4/4] x86/vdso: Rename "required_syms" to "requested_syms" Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).