Various patches to improve Secure Boot support
cover Various patches to improve Secure Boot support
These patches improve support for Secure boot.
UEFI CA memory mitigation requires memory pages to be not executable and writable at the same time. So changing permissions and splitting some section is required.
SBAT is the preferred way to revocate executables.
Remove multiboot pieces from EFI executable.
Frediano Ziglio (2):
Align all sections to 4KB
x86: Split .init section to satisfy UEFI CA memory mitigation
Gerald Elder-Vass (1):
Add SBAT section to the PE binary
Roger Pau Monné (3):
x86/efi: discard .text.header for PE binary x86/efi: discard multiboot related entry code for PE binary x86/efi: avoid a relocation in efi_arch_post_exit_boot()
xen/arch/x86/Makefile | 4 ++++ xen/arch/x86/boot/head.S | 3 ++- xen/arch/x86/efi/efi-boot.h | 7 +++++-- xen/arch/x86/xen.lds.S | 25 +++++++++++++++---------- xen/include/xen/xen.lds.h | 3 ++- 5 files changed, 28 insertions(+), 14 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/6 Add SBAT section to the PE binary
From: Gerald Elder-Vass <[email protected]>
The SBAT section provides a way for the binary to declare a generation id for its upstream source and any vendor changes applied. A compatible loader can then revoke vulnerable binaries by generation, using the binary's declared generation id(s) to determine if it is safe to load.
More information about SBAT is available here:
https://github.com/rhboot/shim/blob/main/SBAT.md
Populate the SBAT section in the Xen binary by using the information in xen/arch/x86/sbat.csv.
On XenServer, the version and release fields are populated by the spec file during the build process.
--- xen/arch/x86/Makefile | 4 ++++ xen/arch/x86/xen.lds.S | 2 ++ xen/include/xen/xen.lds.h | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-)
xen/arch/x86/Makefile +4 -0
@@ -71,6 +71,7 @@ obj-$(CONFIG_TBOOT) += tboot.o obj-y += hpet.o obj-$(CONFIG_VM_EVENT) += vm_event.o obj-y += xstate.o +obj-y += sbat_data.o ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y) obj-y += domctl.o
@@ -275,6 +276,9 @@ $(obj)/efi.lds: AFLAGS-y += -DEFI $(obj)/xen.lds $(obj)/efi.lds: $(src)/xen.lds.S FORCE $(call if_changed_dep,cpp_lds_S) +$(obj)/sbat_data.o: $(src)/sbat.csv + $(OBJCOPY) -I binary -O elf64-x86-64 --rename-section .data=.sbat,readonly,data,contents --add-section .note.GNU-stack=/dev/null $(srcdir)/sbat.csv $@ + clean-files := \ include/asm/asm-macros.* \ $(objtree)/.xen-syms.[0-9]* \
xen/arch/x86/sbat.csv new file +1 -0
@@ -0,0 +1,1 @@ +sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
xen/arch/x86/xen.lds.S +2 -0
@@ -354,6 +354,8 @@ SECTIONS PROVIDE(ALT_START = 0); VIRT_START &= 0; ALT_START &= 0; + + .sbat (NOLOAD) : { *(.sbat) } #elif defined(XEN_BUILD_EFI) /* * Due to the way EFI support is currently implemented, these two symbols
xen/include/xen/xen.lds.h +2 -1
@@ -118,7 +118,8 @@ *(.comment.*) \ *(.note.*) #else -#define DISCARD_EFI_SECTIONS +#define DISCARD_EFI_SECTIONS \ + *(.sbat)#endif /* Sections to be discarded. */
Signature · 1 line
2.43.0
Re: [PATCH 1/6] Add SBAT section to the PE binary
Quoted 16 lines · Frediano Ziglio
From: Gerald Elder-Vass <[email protected]>
The SBAT section provides a way for the binary to declare a generation id for its upstream source and any vendor changes applied. A compatible loader can then revoke vulnerable binaries by generation, using the binary's declared generation id(s) to determine if it is safe to load.
More information about SBAT is available here:
https://github.com/rhboot/shim/blob/main/SBAT.mdPopulate the SBAT section in the Xen binary by using the information in xen/arch/x86/sbat.csv.
On XenServer, the version and release fields are populated by the spec file during the build process.
Quoted 7 lines
Signed-off-by Gerald Elder-Vass <[email protected]>Signed-off-by Frediano Ziglio <[email protected]>--- xen/arch/x86/Makefile | 4 ++++ xen/arch/x86/xen.lds.S | 2 ++ xen/include/xen/xen.lds.h | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-)
This gives the impression of being an entirely new patch, when really the (standalone) patch was already at v4, and my comment there wasn't addressed (perhaps merely by extending the description some). It also feels like there were other pending comments, or else why would this not have gone in long ago? Additionally, ...
xen/arch/x86/Makefile obj-$(CONFIG_TBOOT) += tboot.o · line 74
Quoted 7 lines
xen/arch/x86/Makefile +1
-0@@ -71,6 +71,7 @@ obj-$(CONFIG_TBOOT) += tboot.o obj-y += hpet.o obj-$(CONFIG_VM_EVENT) += vm_event.o obj-y += xstate.o +obj-y += sbat_data.o
... like elsewhere: New files' names should prefer dashes over underscores. Question of course is why this isn't simply sbat.o in the first place.
xen/arch/x86/Makefile $(obj)/efi.lds: AFLAGS-y += -DEFI · line 280
Quoted 6 lines
xen/arch/x86/Makefile +2
-0@@ -275,6 +276,9 @@ $(obj)/efi.lds: AFLAGS-y += -DEFI $(obj)/xen.lds $(obj)/efi.lds: $(src)/xen.lds.S FORCE $(call if_changed_dep,cpp_lds_S) +$(obj)/sbat_data.o: $(src)/sbat.csv + $(OBJCOPY) -I binary -O elf64-x86-64 --rename-section .data=.sbat,readonly,data,contents --add-section .note.GNU-stack=/dev/null $(srcdir)/sbat.csv $@
That'll be an SHT_PROGBITS .note.GNU-stack, won't it? When it really wants to be SHT_NOTE at least for bleeding edge GNU binutils (see relatively recent changes there).
Jan
Re: [PATCH 1/6] Add SBAT section to the PE binary
Quoted 24 lines · Jan Beulich
Quoted 16 lines · Frediano Ziglio
From: Gerald Elder-Vass <[email protected]>
The SBAT section provides a way for the binary to declare a generation id for its upstream source and any vendor changes applied. A compatible loader can then revoke vulnerable binaries by generation, using the binary's declared generation id(s) to determine if it is safe to load.
More information about SBAT is available here:
https://github.com/rhboot/shim/blob/main/SBAT.mdPopulate the SBAT section in the Xen binary by using the information in xen/arch/x86/sbat.csv.
On XenServer, the version and release fields are populated by the spec file during the build process.
Quoted 7 lines
Signed-off-by Gerald Elder-Vass <[email protected]>Signed-off-by Frediano Ziglio <[email protected]>--- xen/arch/x86/Makefile | 4 ++++ xen/arch/x86/xen.lds.S | 2 ++ xen/include/xen/xen.lds.h | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-)
Quoted 5 lines
This gives the impression of being an entirely new patch, when really the (standalone) patch was already at v4, and my comment there wasn't addressed (perhaps merely by extending the description some). It also feels like there were other pending comments, or else why would this not have gone in long ago?
The content of the SBAT table is still pending the security document, and in particular the decision over whether upstream Xen maintains a global revision or not.
Although the global revision could be appended later.
Quoted 11 lines
Additionally, ...
xen/arch/x86/Makefile obj-$(CONFIG_TBOOT) += tboot.o · line 74
Quoted 7 lines
xen/arch/x86/Makefile +1
-0@@ -71,6 +71,7 @@ obj-$(CONFIG_TBOOT) += tboot.o obj-y += hpet.o obj-$(CONFIG_VM_EVENT) += vm_event.o obj-y += xstate.o +obj-y += sbat_data.o... like elsewhere: New files' names should prefer dashes over underscores. Question of course is why this isn't simply sbat.o in the first place.
Also sorted.
Quoted 10 lines
xen/arch/x86/Makefile $(obj)/efi.lds: AFLAGS-y += -DEFI · line 280
Quoted 7 lines
xen/arch/x86/Makefile +2
-0@@ -275,6 +276,9 @@ $(obj)/efi.lds: AFLAGS-y += -DEFI $(obj)/xen.lds $(obj)/efi.lds: $(src)/xen.lds.S FORCE $(call if_changed_dep,cpp_lds_S) +$(obj)/sbat_data.o: $(src)/sbat.csv + $(OBJCOPY) -I binary -O elf64-x86-64 --rename-section .data=.sbat,readonly,data,contents --add-section .note.GNU-stack=/dev/null $(srcdir)/sbat.csv $@That'll be an
SHT_PROGBITS.note.GNU-stack, won't it? When it really wants to beSHT_NOTEat least for bleeding edge GNU binutils (see relatively recent changes there).
That was my addition to prevent there being a warning about RWX stacks cascade all the way up the build.
Maybe a better option is to have sbat.S with an .incbin sbat.csv ?
~Andrew
Re: [PATCH 1/6] Add SBAT section to the PE binary
Quoted 12 lines · Andrew Cooper
Quoted 10 lines · Jan Beulich
xen/arch/x86/Makefile $(obj)/efi.lds: AFLAGS-y += -DEFI · line 280
Quoted 6 lines · Frediano Ziglio
xen/arch/x86/Makefile +2
-0@@ -275,6 +276,9 @@ $(obj)/efi.lds: AFLAGS-y += -DEFI $(obj)/xen.lds $(obj)/efi.lds: $(src)/xen.lds.S FORCE $(call if_changed_dep,cpp_lds_S) +$(obj)/sbat_data.o: $(src)/sbat.csv + $(OBJCOPY) -I binary -O elf64-x86-64 --rename-section .data=.sbat,readonly,data,contents --add-section .note.GNU-stack=/dev/null $(srcdir)/sbat.csv $@That'll be an
SHT_PROGBITS.note.GNU-stack, won't it? When it really wants to beSHT_NOTEat least for bleeding edge GNU binutils (see relatively recent changes there).
Quoted 4 lines
That was my addition to prevent there being a warning about RWX stacks cascade all the way up the build.
Maybe a better option is to have
sbat.Swith an .incbin sbat.csv ?
Yes, that'll avoid all the custom objcopy-ing.
Jan
Re: [PATCH 1/6] Add SBAT section to the PE binary
Quoted 12 lines · Jan Beulich
Quoted 11 lines · Andrew Cooper
Quoted 10 lines · Jan Beulich
xen/arch/x86/Makefile $(obj)/efi.lds: AFLAGS-y += -DEFI · line 280
Quoted 6 lines · Frediano Ziglio
xen/arch/x86/Makefile +2
-0@@ -275,6 +276,9 @@ $(obj)/efi.lds: AFLAGS-y += -DEFI $(obj)/xen.lds $(obj)/efi.lds: $(src)/xen.lds.S FORCE $(call if_changed_dep,cpp_lds_S) +$(obj)/sbat_data.o: $(src)/sbat.csv + $(OBJCOPY) -I binary -O elf64-x86-64 --rename-section .data=.sbat,readonly,data,contents --add-section .note.GNU-stack=/dev/null $(srcdir)/sbat.csv $@That'll be an
SHT_PROGBITS.note.GNU-stack, won't it? When it really wants to beSHT_NOTEat least for bleeding edge GNU binutils (see relatively recent changes there).
Quoted 5 lines
Quoted 4 lines
That was my addition to prevent there being a warning about RWX stacks cascade all the way up the build.
Maybe a better option is to have
sbat.Swith an .incbin sbat.csv ?Yes, that'll avoid all the custom objcopy-ing.
The objcopy line comes from the instructions in shim-review, not that I think they're great instructions overall.
~Andrew
PATCH 2/6 Align all sections to 4KB
In reply to Frediano ZiglioRequired by UEFI CA memory mitigation.
--- xen/arch/x86/xen.lds.S | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
xen/arch/x86/xen.lds.S +4 -2
@@ -162,8 +162,8 @@ SECTIONS __note_gnu_build_id_end = .; } PHDR(note) PHDR(text) #elif defined(BUILD_ID_EFI) - /* Workaround bug in binutils < 2.36 */ - . = ALIGN(32); + /* align to satisfy UEFI CA memory mitigation */ + . = ALIGN(PAGE_SIZE); DECL_SECTION(.buildid) { __note_gnu_build_id_start = .; *(.buildid)
@@ -330,6 +330,7 @@ SECTIONS __2M_rwdata_end = ALIGN(SECTION_ALIGN); #ifdef EFI + . = ALIGN(PAGE_SIZE); .reloc ALIGN(4) : { __base_relocs_start = .; *(.reloc)
@@ -355,6 +356,7 @@ SECTIONS VIRT_START &= 0; ALT_START &= 0; + . = ALIGN(PAGE_SIZE); .sbat (NOLOAD) : { *(.sbat) } #elif defined(XEN_BUILD_EFI) /*
Signature · 1 line
2.43.0
Re: [PATCH 2/6] Align all sections to 4KB
Quoted 1 line · Frediano Ziglio
Required by UEFI CA memory mitigation.
Imo this isn't enough for a description: At the very least you want to point at where that requirement is spelled out. Additionally: How much of an image growth is this going to be? Considering that elsewhere it was already said that xen.efi is too large for certain purposes (and hence e.g. debug info wants stripping there), size increase is a potential issue.
Quoted 22 lines
xen/arch/x86/xen.lds.S +3
-2@@ -162,8 +162,8 @@ SECTIONS __note_gnu_build_id_end = .; } PHDR(note) PHDR(text) #elif defined(BUILD_ID_EFI) - /* Workaround bug in binutils < 2.36 */ - . = ALIGN(32); + /* align to satisfy UEFI CA memory mitigation */ + . = ALIGN(PAGE_SIZE); DECL_SECTION(.buildid) { __note_gnu_build_id_start = .; *(.buildid)@@ -330,6 +330,7 @@ SECTIONS __2M_rwdata_end = ALIGN(SECTION_ALIGN); #ifdef EFI + . = ALIGN(PAGE_SIZE); .reloc ALIGN(4) : { __base_relocs_start = .; *(.reloc)
xen/arch/x86/xen.lds.S SECTIONS · line 362
Quoted 7 lines
xen/arch/x86/xen.lds.S +1
-0@@ -355,6 +356,7 @@ SECTIONS VIRT_START &= 0; ALT_START &= 0; + . = ALIGN(PAGE_SIZE); .sbat (NOLOAD) : { *(.sbat) } #elif defined(XEN_BUILD_EFI) /*
You say "all sections" in the title, yet this is not covering e.g. debug info.
Jan
Re: [PATCH 2/6] Align all sections to 4KB
Quoted 4 lines · Jan Beulich
Quoted 1 line · Frediano Ziglio
Required by UEFI CA memory mitigation.
Imo this isn't enough for a description: At the very least you want to point at where that requirement is spelled out.
It is a requirement for NX_COMPAT so the PE can be loaded with W^X perms in the pagetables.
NX_COMPAT is a requirement from shim-review,
https://github.com/rhboot/shim-review#do-you-have-the-nx-bit-set-in-your-shim-if-so-is-your-entire-boot-stack-nx-compatible-and-what-testing-have-you-done-to-ensure-such-compatibility
The discussed exception is (AFAICT) only for re-signing an previously-accepted blobs, and is not usable for new downstream products (which is what Xen is in this context).
~Andrew
Re: [PATCH 2/6] Align all sections to 4KB
In reply to Jan BeulichQuoted 11 lines · Jan Beulich
Quoted 1 line · Frediano Ziglio
Required by UEFI CA memory mitigation.
Imo this isn't enough for a description: At the very least you want to point at where that requirement is spelled out. Additionally: How much of an image growth is this going to be? Considering that elsewhere it was already said that xen.efi is too large for certain purposes (and hence e.g. debug info wants stripping there), size increase is a potential issue.
I'll integrate Andrew comment on the description.
The image will increase but if it's a problem just adding some kbytes it would be a pretty big deal.
If I remember the issue was more if the image was not stripped and in this case it was like 10 times bigger, not just a bit bigger.
Quoted 25 lines
Quoted 25 lines
xen/arch/x86/xen.lds.S +3
-2@@ -162,8 +162,8 @@ SECTIONS __note_gnu_build_id_end = .; } PHDR(note) PHDR(text) #elif defined(BUILD_ID_EFI) - /* Workaround bug in binutils < 2.36 */ - . = ALIGN(32); + /* align to satisfy UEFI CA memory mitigation */ + . = ALIGN(PAGE_SIZE); DECL_SECTION(.buildid) { __note_gnu_build_id_start = .; *(.buildid)@@ -330,6 +330,7 @@ SECTIONS __2M_rwdata_end = ALIGN(SECTION_ALIGN); #ifdef EFI + . = ALIGN(PAGE_SIZE); .reloc ALIGN(4) : { __base_relocs_start = .; *(.reloc)@@ -355,6 +356,7 @@ SECTIONS VIRT_START &= 0; ALT_START &= 0;
Quoted 8 lines
xen/arch/x86/xen.lds.S SECTIONS · line 362
Quoted 4 lines
xen/arch/x86/xen.lds.S +1
-0+ . = ALIGN(PAGE_SIZE); .sbat (NOLOAD) : { *(.sbat) } #elif defined(XEN_BUILD_EFI) /*You say "all sections" in the title, yet this is not covering e.g. debug info.
I will change to "all loadable sections". debug sections are not loadable so they don't cause an issue.
Quoted 1 line
Jan
Frediano
Re: [PATCH 2/6] Align all sections to 4KB
Quoted 35 lines · Frediano Ziglio
Quoted 26 lines · Jan Beulich
Quoted 25 lines · Frediano Ziglio
xen/arch/x86/xen.lds.S +3
-2@@ -162,8 +162,8 @@ SECTIONS __note_gnu_build_id_end = .; } PHDR(note) PHDR(text) #elif defined(BUILD_ID_EFI) - /* Workaround bug in binutils < 2.36 */ - . = ALIGN(32); + /* align to satisfy UEFI CA memory mitigation */ + . = ALIGN(PAGE_SIZE); DECL_SECTION(.buildid) { __note_gnu_build_id_start = .; *(.buildid)@@ -330,6 +330,7 @@ SECTIONS __2M_rwdata_end = ALIGN(SECTION_ALIGN); #ifdef EFI + . = ALIGN(PAGE_SIZE); .reloc ALIGN(4) : { __base_relocs_start = .; *(.reloc)@@ -355,6 +356,7 @@ SECTIONS VIRT_START &= 0; ALT_START &= 0;Quoted 7 lines
xen/arch/x86/xen.lds.S SECTIONS · line 362
Quoted 4 lines
xen/arch/x86/xen.lds.S +1
-0+ . = ALIGN(PAGE_SIZE); .sbat (NOLOAD) : { *(.sbat) } #elif defined(XEN_BUILD_EFI) /*You say "all sections" in the title, yet this is not covering e.g. debug info.
Quoted 2 lines
I will change to "all loadable sections". debug sections are not loadable so they don't cause an issue.
Please try to be precise there, as some aspects are subtle. As per my understanding, like .reloc all .debug_* are loadable (and may be loaded). The IMAGE_SCN_MEM_DISCARDABLE flag merely means they can be discarded at a certain point after image loading (for .reloc in particular: after relocations were processed).
Jan
Re: [PATCH 2/6] Align all sections to 4KB
Frediano
Quoted 40 lines · Jan Beulich
Quoted 35 lines · Frediano Ziglio
Quoted 26 lines · Jan Beulich
Quoted 25 lines · Frediano Ziglio
xen/arch/x86/xen.lds.S +3
-2@@ -162,8 +162,8 @@ SECTIONS __note_gnu_build_id_end = .; } PHDR(note) PHDR(text) #elif defined(BUILD_ID_EFI) - /* Workaround bug in binutils < 2.36 */ - . = ALIGN(32); + /* align to satisfy UEFI CA memory mitigation */ + . = ALIGN(PAGE_SIZE); DECL_SECTION(.buildid) { __note_gnu_build_id_start = .; *(.buildid)@@ -330,6 +330,7 @@ SECTIONS __2M_rwdata_end = ALIGN(SECTION_ALIGN); #ifdef EFI + . = ALIGN(PAGE_SIZE); .reloc ALIGN(4) : { __base_relocs_start = .; *(.reloc)@@ -355,6 +356,7 @@ SECTIONS VIRT_START &= 0; ALT_START &= 0;Quoted 7 lines
xen/arch/x86/xen.lds.S SECTIONS · line 362
Quoted 4 lines
xen/arch/x86/xen.lds.S +1
-0+ . = ALIGN(PAGE_SIZE); .sbat (NOLOAD) : { *(.sbat) } #elif defined(XEN_BUILD_EFI) /*You say "all sections" in the title, yet this is not covering e.g. debug info.
Quoted 2 lines
I will change to "all loadable sections". debug sections are not loadable so they don't cause an issue.
Quoted 7 lines
Please try to be precise there, as some aspects are subtle. As per my understanding, like .reloc all .debug_* are loadable (and may be loaded). The
IMAGE_SCN_MEM_DISCARDABLEflag merely means they can be discarded at a certain point after image loading (for .reloc in particular: after relocations were processed).Jan
No, debug sections are not loadable, for instance, in a random executable I found:
Sections:
Idx Name Size VMA LMA File off Algn 0 .text 0000c7f8 0000000140001000 0000000140001000 00000600 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
1 .data 00000250 000000014000e000 000000014000e000 0000ce00 2**4
CONTENTS, ALLOC, LOAD, DATA
2 .rdata 00002c70 000000014000f000 000000014000f000 0000d200 2**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .pdata 00000654 0000000140012000 0000000140012000 00010000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .xdata 00000630 0000000140013000 0000000140013000 00010800 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .bss 00001ec0 0000000140014000 0000000140014000 00000000 2**4
ALLOC
6 .idata 00000c88 0000000140016000 0000000140016000 00011000 2**2
CONTENTS, ALLOC, LOAD, DATA
7 .CRT 00000060 0000000140017000 0000000140017000 00011e00 2**2
CONTENTS, ALLOC, LOAD, DATA
8 .tls 00000010 0000000140018000 0000000140018000 00012000 2**2
CONTENTS, ALLOC, LOAD, DATA
9 .reloc 0000009c 0000000140019000 0000000140019000 00012200 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .debug_aranges 00000150 000000014001a000 000000014001a000 00012400 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_info 0000d5e4 000000014001b000 000000014001b000 00012600 2**0
CONTENTS, READONLY, DEBUGGING
12 .debug_abbrev 000014de 0000000140029000 0000000140029000 0001fc00 2**0
CONTENTS, READONLY, DEBUGGING
13 .debug_line 00001a36 000000014002b000 000000014002b000 00021200 2**0
CONTENTS, READONLY, DEBUGGING
14 .debug_frame 00000f40 000000014002d000 000000014002d000 00022e00 2**0
CONTENTS, READONLY, DEBUGGING
15 .debug_str 000003a0 000000014002e000 000000014002e000 00023e00 2**0
CONTENTS, READONLY, DEBUGGING
16 .debug_line_str 00000a76 000000014002f000 000000014002f000 00024200 2**0
CONTENTS, READONLY, DEBUGGING
17 .debug_loclists 0000174a 0000000140030000 0000000140030000 00024e00 2**0
CONTENTS, READONLY, DEBUGGING
18 .debug_rnglists 0000039c 0000000140032000 0000000140032000 00026600 2**0
CONTENTS, READONLY, DEBUGGING
Maybe "loaded" instead of "loadable" ?
Frediano
Re: [PATCH 2/6] Align all sections to 4KB
Quoted 84 lines · Frediano Ziglio
Frediano
Quoted 37 lines · Jan Beulich
Quoted 35 lines · Frediano Ziglio
Quoted 33 lines · Jan Beulich
Quoted 22 lines · Frediano Ziglio
xen/arch/x86/xen.lds.S +3
-2@@ -162,8 +162,8 @@ SECTIONS __note_gnu_build_id_end = .; } PHDR(note) PHDR(text) #elif defined(BUILD_ID_EFI) - /* Workaround bug in binutils < 2.36 */ - . = ALIGN(32); + /* align to satisfy UEFI CA memory mitigation */ + . = ALIGN(PAGE_SIZE); DECL_SECTION(.buildid) { __note_gnu_build_id_start = .; *(.buildid)@@ -330,6 +330,7 @@ SECTIONS __2M_rwdata_end = ALIGN(SECTION_ALIGN); #ifdef EFI + . = ALIGN(PAGE_SIZE); .reloc ALIGN(4) : { __base_relocs_start = .; *(.reloc)xen/arch/x86/xen.lds.S SECTIONS · line 362
Quoted 7 lines
xen/arch/x86/xen.lds.S +1
-0@@ -355,6 +356,7 @@ SECTIONS VIRT_START &= 0; ALT_START &= 0; + . = ALIGN(PAGE_SIZE); .sbat (NOLOAD) : { *(.sbat) } #elif defined(XEN_BUILD_EFI) /*You say "all sections" in the title, yet this is not covering e.g. debug info.
Quoted 8 lines
Quoted 2 lines
I will change to "all loadable sections". debug sections are not loadable so they don't cause an issue.
Please try to be precise there, as some aspects are subtle. As per my understanding, like .reloc all .debug_* are loadable (and may be loaded). The
IMAGE_SCN_MEM_DISCARDABLEflag merely means they can be discarded at a certain point after image loading (for .reloc in particular: after relocations were processed).No, debug sections are not loadable, for instance, in a random executable I found:
Sections:
Idx Name Size VMA LMA File off Algn 0 .text 0000c7f8 0000000140001000 0000000140001000 00000600 2**4CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
1 .data 00000250000000014000e000000000014000e0000000ce002**4
CONTENTS, ALLOC, LOAD, DATA
2 .rdata00002c70000000014000f000000000014000f0000000d2002**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .pdata 00000654 0000000140012000 0000000140012000 00010000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .xdata 00000630 0000000140013000 0000000140013000 00010800 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .bss00001ec00000000140014000 0000000140014000 00000000 2**4
ALLOC
6 .idata00000c880000000140016000 0000000140016000 00011000 2**2
CONTENTS, ALLOC, LOAD, DATA
7 .CRT 00000060 0000000140017000 000000014001700000011e002**2
CONTENTS, ALLOC, LOAD, DATA
8 .tls 00000010 0000000140018000 0000000140018000 00012000 2**2
CONTENTS, ALLOC, LOAD, DATA
9 .reloc0000009c0000000140019000 0000000140019000 00012200 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .debug_aranges 00000150000000014001a000000000014001a00000012400 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_info0000d5e4000000014001b000000000014001b00000012600 2**0
CONTENTS, READONLY, DEBUGGING
12 .debug_abbrev000014de0000000140029000 00000001400290000001fc002**0
CONTENTS, READONLY, DEBUGGING
13 .debug_line00001a36000000014002b000000000014002b00000021200 2**0
CONTENTS, READONLY, DEBUGGING
14 .debug_frame00000f40000000014002d000000000014002d00000022e002**0
CONTENTS, READONLY, DEBUGGING
Quoted 8 lines
15 .debug_str
000003a0000000014002e000000000014002e00000023e002**0
CONTENTS, READONLY, DEBUGGING
16 .debug_line_str00000a76000000014002f000000000014002f00000024200 2**0
CONTENTS, READONLY, DEBUGGING
17 .debug_loclists0000174a0000000140030000 000000014003000000024e002**0
CONTENTS, READONLY, DEBUGGING
18 .debug_rnglists0000039c0000000140032000 0000000140032000 00026600 2**0
CONTENTS, READONLY, DEBUGGING
That's derived from libfd's internal representation, which means nothing at all to the loader processing the image. If your objdump is suitably enabled, try using its -P option.
Jan
Re: [PATCH 2/6] Align all sections to 4KB
Quoted 95 lines · Jan Beulich
Quoted 84 lines · Frediano Ziglio
Frediano
Quoted 37 lines · Jan Beulich
Quoted 35 lines · Frediano Ziglio
Quoted 33 lines · Jan Beulich
Quoted 22 lines · Frediano Ziglio
xen/arch/x86/xen.lds.S +3
-2@@ -162,8 +162,8 @@ SECTIONS __note_gnu_build_id_end = .; } PHDR(note) PHDR(text) #elif defined(BUILD_ID_EFI) - /* Workaround bug in binutils < 2.36 */ - . = ALIGN(32); + /* align to satisfy UEFI CA memory mitigation */ + . = ALIGN(PAGE_SIZE); DECL_SECTION(.buildid) { __note_gnu_build_id_start = .; *(.buildid)@@ -330,6 +330,7 @@ SECTIONS __2M_rwdata_end = ALIGN(SECTION_ALIGN); #ifdef EFI + . = ALIGN(PAGE_SIZE); .reloc ALIGN(4) : { __base_relocs_start = .; *(.reloc)xen/arch/x86/xen.lds.S SECTIONS · line 362
Quoted 7 lines
xen/arch/x86/xen.lds.S +1
-0@@ -355,6 +356,7 @@ SECTIONS VIRT_START &= 0; ALT_START &= 0; + . = ALIGN(PAGE_SIZE); .sbat (NOLOAD) : { *(.sbat) } #elif defined(XEN_BUILD_EFI) /*You say "all sections" in the title, yet this is not covering e.g. debug info.
Quoted 8 lines
Quoted 2 lines
I will change to "all loadable sections". debug sections are not loadable so they don't cause an issue.
Please try to be precise there, as some aspects are subtle. As per my understanding, like .reloc all .debug_* are loadable (and may be loaded). The
IMAGE_SCN_MEM_DISCARDABLEflag merely means they can be discarded at a certain point after image loading (for .reloc in particular: after relocations were processed).No, debug sections are not loadable, for instance, in a random executable I found:
Sections:
Idx Name Size VMA LMA File off Algn 0 .text 0000c7f8 0000000140001000 0000000140001000 00000600 2**4CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
1 .data 00000250000000014000e000000000014000e0000000ce002**4
CONTENTS, ALLOC, LOAD, DATA
2 .rdata00002c70000000014000f000000000014000f0000000d2002**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .pdata 00000654 0000000140012000 0000000140012000 00010000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .xdata 00000630 0000000140013000 0000000140013000 00010800 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .bss00001ec00000000140014000 0000000140014000 00000000 2**4
ALLOC
6 .idata00000c880000000140016000 0000000140016000 00011000 2**2
CONTENTS, ALLOC, LOAD, DATA
7 .CRT 00000060 0000000140017000 000000014001700000011e002**2
CONTENTS, ALLOC, LOAD, DATA
8 .tls 00000010 0000000140018000 0000000140018000 00012000 2**2
CONTENTS, ALLOC, LOAD, DATA
9 .reloc0000009c0000000140019000 0000000140019000 00012200 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .debug_aranges 00000150000000014001a000000000014001a00000012400 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_info0000d5e4000000014001b000000000014001b00000012600 2**0
CONTENTS, READONLY, DEBUGGING
12 .debug_abbrev000014de0000000140029000 00000001400290000001fc002**0
CONTENTS, READONLY, DEBUGGING
13 .debug_line00001a36000000014002b000000000014002b00000021200 2**0
CONTENTS, READONLY, DEBUGGING
14 .debug_frame00000f40000000014002d000000000014002d00000022e002**0
CONTENTS, READONLY, DEBUGGINGQuoted 8 lines
15 .debug_str
000003a0000000014002e000000000014002e00000023e002**0
CONTENTS, READONLY, DEBUGGING
16 .debug_line_str00000a76000000014002f000000000014002f00000024200 2**0
CONTENTS, READONLY, DEBUGGING
17 .debug_loclists0000174a0000000140030000 000000014003000000024e002**0
CONTENTS, READONLY, DEBUGGING
18 .debug_rnglists0000039c0000000140032000 0000000140032000 00026600 2**0
CONTENTS, READONLY, DEBUGGING
Quoted 5 lines
That's derived from libfd's internal representation, which means nothing at all to the loader processing the image. If your objdump is suitably enabled, try using its -P option.
Jan
You are right, I got
Section headers (at offset 0x00000188):
# Name paddr vaddr size scnptr relptr lnnoptr nrel nlnno
1 .text 0000c7f8 00001000 0000c800 00000600 00000000 00000000 0 0
Flags: 60000060: EXECUTE,READ,CODE,INITIALIZED DATA
2 .data 00000250 0000e000 00000400 0000ce00 00000000 00000000 0 0
Flags: c0000040: READ,WRITE,INITIALIZED DATA
3 .rdata 00002c70 0000f000 00002e00 0000d200 00000000 00000000 0 0
Flags: 40000040: READ,INITIALIZED DATA
4 .pdata 00000654 00012000 00000800 00010000 00000000 00000000 0 0
Flags: 40000040: READ,INITIALIZED DATA
5 .xdata 00000630 00013000 00000800 00010800 00000000 00000000 0 0
Flags: 40000040: READ,INITIALIZED DATA 6 .bss 00001ec0 00014000 00000000 00000000 00000000 00000000 0 0
Flags: c0000080: READ,WRITE,UNINITIALIZED DATA
7 .idata 00000c88 00016000 00000e00 00011000 00000000 00000000 0 0
Flags: c0000040: READ,WRITE,INITIALIZED DATA
8 .CRT 00000060 00017000 00000200 00011e00 00000000 00000000 0 0
Flags: c0000040: READ,WRITE,INITIALIZED DATA
9 .tls 00000010 00018000 00000200 00012000 00000000 00000000 0 0
Flags: c0000040: READ,WRITE,INITIALIZED DATA
10 .reloc 0000009c 00019000 00000200 00012200 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
11 /4 00000150 0001a000 00000200 00012400 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
12 /19 0000d5e4 0001b000 0000d600 00012600 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
13 /31 000014de 00029000 00001600 0001fc00 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
14 /45 00001a36 0002b000 00001c00 00021200 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
15 /57 00000f40 0002d000 00001000 00022e00 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
16 /70 000003a0 0002e000 00000400 00023e00 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
17 /81 00000a76 0002f000 00000c00 00024200 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
18 /97 0000174a 00030000 00001800 00024e00 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
19 /113 0000039c 00032000 00000400 00026600 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
I suppose I will change to simply "Align some sections to 4KB"
Frediano
Re: [PATCH 2/6] Align all sections to 4KB
Quoted 145 lines · Frediano Ziglio
Quoted 95 lines · Jan Beulich
Quoted 84 lines · Frediano Ziglio
Frediano
Quoted 37 lines · Jan Beulich
Quoted 35 lines · Frediano Ziglio
Quoted 33 lines · Jan Beulich
Quoted 22 lines · Frediano Ziglio
xen/arch/x86/xen.lds.S +3
-2@@ -162,8 +162,8 @@ SECTIONS __note_gnu_build_id_end = .; } PHDR(note) PHDR(text) #elif defined(BUILD_ID_EFI) - /* Workaround bug in binutils < 2.36 */ - . = ALIGN(32); + /* align to satisfy UEFI CA memory mitigation */ + . = ALIGN(PAGE_SIZE); DECL_SECTION(.buildid) { __note_gnu_build_id_start = .; *(.buildid)@@ -330,6 +330,7 @@ SECTIONS __2M_rwdata_end = ALIGN(SECTION_ALIGN); #ifdef EFI + . = ALIGN(PAGE_SIZE); .reloc ALIGN(4) : { __base_relocs_start = .; *(.reloc)xen/arch/x86/xen.lds.S SECTIONS · line 362
Quoted 7 lines
xen/arch/x86/xen.lds.S +1
-0@@ -355,6 +356,7 @@ SECTIONS VIRT_START &= 0; ALT_START &= 0; + . = ALIGN(PAGE_SIZE); .sbat (NOLOAD) : { *(.sbat) } #elif defined(XEN_BUILD_EFI) /*You say "all sections" in the title, yet this is not covering e.g. debug info.
Quoted 8 lines
Quoted 2 lines
I will change to "all loadable sections". debug sections are not loadable so they don't cause an issue.
Please try to be precise there, as some aspects are subtle. As per my understanding, like .reloc all .debug_* are loadable (and may be loaded). The
IMAGE_SCN_MEM_DISCARDABLEflag merely means they can be discarded at a certain point after image loading (for .reloc in particular: after relocations were processed).No, debug sections are not loadable, for instance, in a random executable I found:
Sections:
Idx Name Size VMA LMA File off Algn 0 .text 0000c7f8 0000000140001000 0000000140001000 00000600 2**4CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
1 .data 00000250000000014000e000000000014000e0000000ce002**4
CONTENTS, ALLOC, LOAD, DATA
2 .rdata00002c70000000014000f000000000014000f0000000d2002**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .pdata 00000654 0000000140012000 0000000140012000 00010000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .xdata 00000630 0000000140013000 0000000140013000 00010800 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .bss00001ec00000000140014000 0000000140014000 00000000 2**4
ALLOC
6 .idata00000c880000000140016000 0000000140016000 00011000 2**2
CONTENTS, ALLOC, LOAD, DATA
7 .CRT 00000060 0000000140017000 000000014001700000011e002**2
CONTENTS, ALLOC, LOAD, DATA
8 .tls 00000010 0000000140018000 0000000140018000 00012000 2**2
CONTENTS, ALLOC, LOAD, DATA
9 .reloc0000009c0000000140019000 0000000140019000 00012200 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .debug_aranges 00000150000000014001a000000000014001a00000012400 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_info0000d5e4000000014001b000000000014001b00000012600 2**0
CONTENTS, READONLY, DEBUGGING
12 .debug_abbrev000014de0000000140029000 00000001400290000001fc002**0
CONTENTS, READONLY, DEBUGGING
13 .debug_line00001a36000000014002b000000000014002b00000021200 2**0
CONTENTS, READONLY, DEBUGGING
14 .debug_frame00000f40000000014002d000000000014002d00000022e002**0
CONTENTS, READONLY, DEBUGGINGQuoted 8 lines
15 .debug_str
000003a0000000014002e000000000014002e00000023e002**0
CONTENTS, READONLY, DEBUGGING
16 .debug_line_str00000a76000000014002f000000000014002f00000024200 2**0
CONTENTS, READONLY, DEBUGGING
17 .debug_loclists0000174a0000000140030000 000000014003000000024e002**0
CONTENTS, READONLY, DEBUGGING
18 .debug_rnglists0000039c0000000140032000 0000000140032000 00026600 2**0
CONTENTS, READONLY, DEBUGGINGQuoted 5 lines
That's derived from libfd's internal representation, which means nothing at all to the loader processing the image. If your objdump is suitably enabled, try using its -P option.
Jan
You are right, I got
Section headers (at offset
0x00000188):
# Name paddr vaddr size scnptr relptr lnnoptr nrel nlnno
1 .text0000c7f8000010000000c80000000600 00000000 00000000 0 0Flags: 60000060: EXECUTE,READ,CODE,INITIALIZED DATA 2 .data 00000250 0000e000 00000400 0000ce00 00000000 00000000 0 0 Flags: c0000040: READ,WRITE,INITIALIZED DATA 3 .rdata 00002c70 0000f000 00002e00 0000d200 00000000 00000000 0 0 Flags: 40000040: READ,INITIALIZED DATA 4 .pdata 00000654 00012000 00000800 00010000 00000000 00000000 0 0 Flags: 40000040: READ,INITIALIZED DATA 5 .xdata 00000630 00013000 00000800 00010800 00000000 00000000 0 0 Flags: 40000040: READ,INITIALIZED DATA6 .bss
00001ec000014000 00000000 00000000 00000000 00000000 0 0
Flags:c0000080: READ,WRITE,UNINITIALIZED DATA
7 .idata00000c880001600000000e0000011000 00000000 00000000 0 0
Flags:c0000040: READ,WRITE,INITIALIZED DATA
8 .CRT 00000060 00017000 0000020000011e0000000000 00000000 0 0
Flags:c0000040: READ,WRITE,INITIALIZED DATA
9 .tls 00000010 00018000 00000200 00012000 00000000 00000000 0 0
Flags:c0000040: READ,WRITE,INITIALIZED DATA
10 .reloc0000009c00019000 00000200 00012200 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
11 /4 000001500001a00000000200 00012400 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
12 /190000d5e40001b0000000d60000012600 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
13 /31000014de00029000 000016000001fc0000000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
14 /4500001a360002b00000001c0000021200 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
15 /5700000f400002d0000000100000022e0000000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
16 /70000003a00002e0000000040000023e0000000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
17 /8100000a760002f00000000c0000024200 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
18 /970000174a00030000 0000180000024e0000000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
19 /1130000039c00032000 00000400 00026600 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
Quoted 1 line
I suppose I will change to simply "Align some sections to 4KB"
"Some" is imo going to be too imprecise. Please qualify which sections you intend to align. If new sections need adding in the future, this then can guide people as to whether those may also need aligning.
Jan
Re: [PATCH 2/6] Align all sections to 4KB
Quoted 147 lines · Jan Beulich
Quoted 145 lines · Frediano Ziglio
Quoted 95 lines · Jan Beulich
Quoted 84 lines · Frediano Ziglio
Frediano
Quoted 37 lines · Jan Beulich
Quoted 35 lines · Frediano Ziglio
Quoted 33 lines · Jan Beulich
Quoted 22 lines · Frediano Ziglio
xen/arch/x86/xen.lds.S +3
-2@@ -162,8 +162,8 @@ SECTIONS __note_gnu_build_id_end = .; } PHDR(note) PHDR(text) #elif defined(BUILD_ID_EFI) - /* Workaround bug in binutils < 2.36 */ - . = ALIGN(32); + /* align to satisfy UEFI CA memory mitigation */ + . = ALIGN(PAGE_SIZE); DECL_SECTION(.buildid) { __note_gnu_build_id_start = .; *(.buildid)@@ -330,6 +330,7 @@ SECTIONS __2M_rwdata_end = ALIGN(SECTION_ALIGN); #ifdef EFI + . = ALIGN(PAGE_SIZE); .reloc ALIGN(4) : { __base_relocs_start = .; *(.reloc)xen/arch/x86/xen.lds.S SECTIONS · line 362
Quoted 7 lines
xen/arch/x86/xen.lds.S +1
-0@@ -355,6 +356,7 @@ SECTIONS VIRT_START &= 0; ALT_START &= 0; + . = ALIGN(PAGE_SIZE); .sbat (NOLOAD) : { *(.sbat) } #elif defined(XEN_BUILD_EFI) /*You say "all sections" in the title, yet this is not covering e.g. debug info.
Quoted 8 lines
Quoted 2 lines
I will change to "all loadable sections". debug sections are not loadable so they don't cause an issue.
Please try to be precise there, as some aspects are subtle. As per my understanding, like .reloc all .debug_* are loadable (and may be loaded). The
IMAGE_SCN_MEM_DISCARDABLEflag merely means they can be discarded at a certain point after image loading (for .reloc in particular: after relocations were processed).No, debug sections are not loadable, for instance, in a random executable I found:
Sections:
Idx Name Size VMA LMA File off Algn 0 .text 0000c7f8 0000000140001000 0000000140001000 00000600 2**4CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
1 .data 00000250000000014000e000000000014000e0000000ce002**4
CONTENTS, ALLOC, LOAD, DATA
2 .rdata00002c70000000014000f000000000014000f0000000d2002**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .pdata 00000654 0000000140012000 0000000140012000 00010000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .xdata 00000630 0000000140013000 0000000140013000 00010800 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .bss00001ec00000000140014000 0000000140014000 00000000 2**4
ALLOC
6 .idata00000c880000000140016000 0000000140016000 00011000 2**2
CONTENTS, ALLOC, LOAD, DATA
7 .CRT 00000060 0000000140017000 000000014001700000011e002**2
CONTENTS, ALLOC, LOAD, DATA
8 .tls 00000010 0000000140018000 0000000140018000 00012000 2**2
CONTENTS, ALLOC, LOAD, DATA
9 .reloc0000009c0000000140019000 0000000140019000 00012200 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .debug_aranges 00000150000000014001a000000000014001a00000012400 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_info0000d5e4000000014001b000000000014001b00000012600 2**0
CONTENTS, READONLY, DEBUGGING
12 .debug_abbrev000014de0000000140029000 00000001400290000001fc002**0
CONTENTS, READONLY, DEBUGGING
13 .debug_line00001a36000000014002b000000000014002b00000021200 2**0
CONTENTS, READONLY, DEBUGGING
14 .debug_frame00000f40000000014002d000000000014002d00000022e002**0
CONTENTS, READONLY, DEBUGGINGQuoted 8 lines
15 .debug_str
000003a0000000014002e000000000014002e00000023e002**0
CONTENTS, READONLY, DEBUGGING
16 .debug_line_str00000a76000000014002f000000000014002f00000024200 2**0
CONTENTS, READONLY, DEBUGGING
17 .debug_loclists0000174a0000000140030000 000000014003000000024e002**0
CONTENTS, READONLY, DEBUGGING
18 .debug_rnglists0000039c0000000140032000 0000000140032000 00026600 2**0
CONTENTS, READONLY, DEBUGGINGQuoted 5 lines
That's derived from libfd's internal representation, which means nothing at all to the loader processing the image. If your objdump is suitably enabled, try using its -P option.
Jan
You are right, I got
Section headers (at offset
0x00000188):
# Name paddr vaddr size scnptr relptr lnnoptr nrel nlnno
1 .text0000c7f8000010000000c80000000600 00000000 00000000 0 0Flags: 60000060: EXECUTE,READ,CODE,INITIALIZED DATA 2 .data 00000250 0000e000 00000400 0000ce00 00000000 00000000 0 0 Flags: c0000040: READ,WRITE,INITIALIZED DATA 3 .rdata 00002c70 0000f000 00002e00 0000d200 00000000 00000000 0 0 Flags: 40000040: READ,INITIALIZED DATA 4 .pdata 00000654 00012000 00000800 00010000 00000000 00000000 0 0 Flags: 40000040: READ,INITIALIZED DATA 5 .xdata 00000630 00013000 00000800 00010800 00000000 00000000 0 0 Flags: 40000040: READ,INITIALIZED DATA6 .bss
00001ec000014000 00000000 00000000 00000000 00000000 0 0
Flags:c0000080: READ,WRITE,UNINITIALIZED DATA
7 .idata00000c880001600000000e0000011000 00000000 00000000 0 0
Flags:c0000040: READ,WRITE,INITIALIZED DATA
8 .CRT 00000060 00017000 0000020000011e0000000000 00000000 0 0
Flags:c0000040: READ,WRITE,INITIALIZED DATA
9 .tls 00000010 00018000 00000200 00012000 00000000 00000000 0 0
Flags:c0000040: READ,WRITE,INITIALIZED DATA
10 .reloc0000009c00019000 00000200 00012200 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
11 /4 000001500001a00000000200 00012400 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
12 /190000d5e40001b0000000d60000012600 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
13 /31000014de00029000 000016000001fc0000000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
14 /4500001a360002b00000001c0000021200 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
15 /5700000f400002d0000000100000022e0000000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
16 /70000003a00002e0000000040000023e0000000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
17 /8100000a760002f00000000c0000024200 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
18 /970000174a00030000 0000180000024e0000000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
19 /1130000039c00032000 00000400 00026600 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
Quoted 7 lines
Quoted 1 line
I suppose I will change to simply "Align some sections to 4KB"
"Some" is imo going to be too imprecise. Please qualify which sections you intend to align. If new sections need adding in the future, this then can guide people as to whether those may also need aligning.
Jan
The main issue is that sections with different permissions must be in separate sections.
In the case of debug sections they are contiguous and have the same permissions so it's not an issue (although better to strip them off).
Any suggestions on how to describe this?
Frediano
Re: [PATCH 2/6] Align all sections to 4KB
Quoted 154 lines · Frediano Ziglio
Quoted 153 lines · Jan Beulich
Quoted 145 lines · Frediano Ziglio
Quoted 95 lines · Jan Beulich
Quoted 84 lines · Frediano Ziglio
Frediano
Quoted 37 lines · Jan Beulich
Quoted 35 lines · Frediano Ziglio
Quoted 33 lines · Jan Beulich
Quoted 22 lines · Frediano Ziglio
xen/arch/x86/xen.lds.S +3
-2@@ -162,8 +162,8 @@ SECTIONS __note_gnu_build_id_end = .; } PHDR(note) PHDR(text) #elif defined(BUILD_ID_EFI) - /* Workaround bug in binutils < 2.36 */ - . = ALIGN(32); + /* align to satisfy UEFI CA memory mitigation */ + . = ALIGN(PAGE_SIZE); DECL_SECTION(.buildid) { __note_gnu_build_id_start = .; *(.buildid)@@ -330,6 +330,7 @@ SECTIONS __2M_rwdata_end = ALIGN(SECTION_ALIGN); #ifdef EFI + . = ALIGN(PAGE_SIZE); .reloc ALIGN(4) : { __base_relocs_start = .; *(.reloc)xen/arch/x86/xen.lds.S SECTIONS · line 362
Quoted 7 lines
xen/arch/x86/xen.lds.S +1
-0@@ -355,6 +356,7 @@ SECTIONS VIRT_START &= 0; ALT_START &= 0; + . = ALIGN(PAGE_SIZE); .sbat (NOLOAD) : { *(.sbat) } #elif defined(XEN_BUILD_EFI) /*You say "all sections" in the title, yet this is not covering e.g. debug info.
Quoted 8 lines
Quoted 2 lines
I will change to "all loadable sections". debug sections are not loadable so they don't cause an issue.
Please try to be precise there, as some aspects are subtle. As per my understanding, like .reloc all .debug_* are loadable (and may be loaded). The
IMAGE_SCN_MEM_DISCARDABLEflag merely means they can be discarded at a certain point after image loading (for .reloc in particular: after relocations were processed).No, debug sections are not loadable, for instance, in a random executable I found:
Sections:
Idx Name Size VMA LMA File off Algn 0 .text 0000c7f8 0000000140001000 0000000140001000 00000600 2**4CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
1 .data 00000250000000014000e000000000014000e0000000ce002**4
CONTENTS, ALLOC, LOAD, DATA
2 .rdata00002c70000000014000f000000000014000f0000000d2002**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .pdata 00000654 0000000140012000 0000000140012000 00010000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .xdata 00000630 0000000140013000 0000000140013000 00010800 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .bss00001ec00000000140014000 0000000140014000 00000000 2**4
ALLOC
6 .idata00000c880000000140016000 0000000140016000 00011000 2**2
CONTENTS, ALLOC, LOAD, DATA
7 .CRT 00000060 0000000140017000 000000014001700000011e002**2
CONTENTS, ALLOC, LOAD, DATA
8 .tls 00000010 0000000140018000 0000000140018000 00012000 2**2
CONTENTS, ALLOC, LOAD, DATA
9 .reloc0000009c0000000140019000 0000000140019000 00012200 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .debug_aranges 00000150000000014001a000000000014001a00000012400 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_info0000d5e4000000014001b000000000014001b00000012600 2**0
CONTENTS, READONLY, DEBUGGING
12 .debug_abbrev000014de0000000140029000 00000001400290000001fc002**0
CONTENTS, READONLY, DEBUGGING
13 .debug_line00001a36000000014002b000000000014002b00000021200 2**0
CONTENTS, READONLY, DEBUGGING
14 .debug_frame00000f40000000014002d000000000014002d00000022e002**0
CONTENTS, READONLY, DEBUGGINGQuoted 8 lines
15 .debug_str
000003a0000000014002e000000000014002e00000023e002**0
CONTENTS, READONLY, DEBUGGING
16 .debug_line_str00000a76000000014002f000000000014002f00000024200 2**0
CONTENTS, READONLY, DEBUGGING
17 .debug_loclists0000174a0000000140030000 000000014003000000024e002**0
CONTENTS, READONLY, DEBUGGING
18 .debug_rnglists0000039c0000000140032000 0000000140032000 00026600 2**0
CONTENTS, READONLY, DEBUGGINGQuoted 5 lines
That's derived from libfd's internal representation, which means nothing at all to the loader processing the image. If your objdump is suitably enabled, try using its -P option.
Jan
You are right, I got
Section headers (at offset
0x00000188):
# Name paddr vaddr size scnptr relptr lnnoptr nrel nlnno
1 .text0000c7f8000010000000c80000000600 00000000 00000000 0 0Flags: 60000060: EXECUTE,READ,CODE,INITIALIZED DATA 2 .data 00000250 0000e000 00000400 0000ce00 00000000 00000000 0 0 Flags: c0000040: READ,WRITE,INITIALIZED DATA 3 .rdata 00002c70 0000f000 00002e00 0000d200 00000000 00000000 0 0 Flags: 40000040: READ,INITIALIZED DATA 4 .pdata 00000654 00012000 00000800 00010000 00000000 00000000 0 0 Flags: 40000040: READ,INITIALIZED DATA 5 .xdata 00000630 00013000 00000800 00010800 00000000 00000000 0 0 Flags: 40000040: READ,INITIALIZED DATA6 .bss
00001ec000014000 00000000 00000000 00000000 00000000 0 0
Flags:c0000080: READ,WRITE,UNINITIALIZED DATA
7 .idata00000c880001600000000e0000011000 00000000 00000000 0 0
Flags:c0000040: READ,WRITE,INITIALIZED DATA
8 .CRT 00000060 00017000 0000020000011e0000000000 00000000 0 0
Flags:c0000040: READ,WRITE,INITIALIZED DATA
9 .tls 00000010 00018000 00000200 00012000 00000000 00000000 0 0
Flags:c0000040: READ,WRITE,INITIALIZED DATA
10 .reloc0000009c00019000 00000200 00012200 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
11 /4 000001500001a00000000200 00012400 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
12 /190000d5e40001b0000000d60000012600 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
13 /31000014de00029000 000016000001fc0000000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
14 /4500001a360002b00000001c0000021200 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
15 /5700000f400002d0000000100000022e0000000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
16 /70000003a00002e0000000040000023e0000000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
17 /8100000a760002f00000000c0000024200 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
18 /970000174a00030000 0000180000024e0000000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
19 /1130000039c00032000 00000400 00026600 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATAQuoted 1 line
I suppose I will change to simply "Align some sections to 4KB"
"Some" is imo going to be too imprecise. Please qualify which sections you intend to align. If new sections need adding in the future, this then can guide people as to whether those may also need aligning.
Quoted 8 lines
Quoted 1 line
Jan
The main issue is that sections with different permissions must be in separate sections.
In the case of debug sections they are contiguous and have the same permissions so it's not an issue (although better to strip them off).Any suggestions on how to describe this?
Maybe something like "Align sections of different permissions to force them into separate pages"?
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
Re: [PATCH 2/6] Align all sections to 4KB
In reply to Frediano ZiglioQuoted 154 lines · Frediano Ziglio
Quoted 147 lines · Jan Beulich
Quoted 145 lines · Frediano Ziglio
Quoted 95 lines · Jan Beulich
Quoted 84 lines · Frediano Ziglio
Frediano
Quoted 37 lines · Jan Beulich
Quoted 35 lines · Frediano Ziglio
Quoted 33 lines · Jan Beulich
Quoted 22 lines · Frediano Ziglio
xen/arch/x86/xen.lds.S +3
-2@@ -162,8 +162,8 @@ SECTIONS __note_gnu_build_id_end = .; } PHDR(note) PHDR(text) #elif defined(BUILD_ID_EFI) - /* Workaround bug in binutils < 2.36 */ - . = ALIGN(32); + /* align to satisfy UEFI CA memory mitigation */ + . = ALIGN(PAGE_SIZE); DECL_SECTION(.buildid) { __note_gnu_build_id_start = .; *(.buildid)@@ -330,6 +330,7 @@ SECTIONS __2M_rwdata_end = ALIGN(SECTION_ALIGN); #ifdef EFI + . = ALIGN(PAGE_SIZE); .reloc ALIGN(4) : { __base_relocs_start = .; *(.reloc)xen/arch/x86/xen.lds.S SECTIONS · line 362
Quoted 7 lines
xen/arch/x86/xen.lds.S +1
-0@@ -355,6 +356,7 @@ SECTIONS VIRT_START &= 0; ALT_START &= 0; + . = ALIGN(PAGE_SIZE); .sbat (NOLOAD) : { *(.sbat) } #elif defined(XEN_BUILD_EFI) /*You say "all sections" in the title, yet this is not covering e.g. debug info.
Quoted 8 lines
Quoted 2 lines
I will change to "all loadable sections". debug sections are not loadable so they don't cause an issue.
Please try to be precise there, as some aspects are subtle. As per my understanding, like .reloc all .debug_* are loadable (and may be loaded). The
IMAGE_SCN_MEM_DISCARDABLEflag merely means they can be discarded at a certain point after image loading (for .reloc in particular: after relocations were processed).No, debug sections are not loadable, for instance, in a random executable I found:
Sections:
Idx Name Size VMA LMA File off Algn 0 .text 0000c7f8 0000000140001000 0000000140001000 00000600 2**4CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
1 .data 00000250000000014000e000000000014000e0000000ce002**4
CONTENTS, ALLOC, LOAD, DATA
2 .rdata00002c70000000014000f000000000014000f0000000d2002**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .pdata 00000654 0000000140012000 0000000140012000 00010000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .xdata 00000630 0000000140013000 0000000140013000 00010800 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .bss00001ec00000000140014000 0000000140014000 00000000 2**4
ALLOC
6 .idata00000c880000000140016000 0000000140016000 00011000 2**2
CONTENTS, ALLOC, LOAD, DATA
7 .CRT 00000060 0000000140017000 000000014001700000011e002**2
CONTENTS, ALLOC, LOAD, DATA
8 .tls 00000010 0000000140018000 0000000140018000 00012000 2**2
CONTENTS, ALLOC, LOAD, DATA
9 .reloc0000009c0000000140019000 0000000140019000 00012200 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .debug_aranges 00000150000000014001a000000000014001a00000012400 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_info0000d5e4000000014001b000000000014001b00000012600 2**0
CONTENTS, READONLY, DEBUGGING
12 .debug_abbrev000014de0000000140029000 00000001400290000001fc002**0
CONTENTS, READONLY, DEBUGGING
13 .debug_line00001a36000000014002b000000000014002b00000021200 2**0
CONTENTS, READONLY, DEBUGGING
14 .debug_frame00000f40000000014002d000000000014002d00000022e002**0
CONTENTS, READONLY, DEBUGGINGQuoted 8 lines
15 .debug_str
000003a0000000014002e000000000014002e00000023e002**0
CONTENTS, READONLY, DEBUGGING
16 .debug_line_str00000a76000000014002f000000000014002f00000024200 2**0
CONTENTS, READONLY, DEBUGGING
17 .debug_loclists0000174a0000000140030000 000000014003000000024e002**0
CONTENTS, READONLY, DEBUGGING
18 .debug_rnglists0000039c0000000140032000 0000000140032000 00026600 2**0
CONTENTS, READONLY, DEBUGGINGQuoted 5 lines
That's derived from libfd's internal representation, which means nothing at all to the loader processing the image. If your objdump is suitably enabled, try using its -P option.
Jan
You are right, I got
Section headers (at offset
0x00000188):
# Name paddr vaddr size scnptr relptr lnnoptr nrel nlnno
1 .text0000c7f8000010000000c80000000600 00000000 00000000 0 0Flags: 60000060: EXECUTE,READ,CODE,INITIALIZED DATA 2 .data 00000250 0000e000 00000400 0000ce00 00000000 00000000 0 0 Flags: c0000040: READ,WRITE,INITIALIZED DATA 3 .rdata 00002c70 0000f000 00002e00 0000d200 00000000 00000000 0 0 Flags: 40000040: READ,INITIALIZED DATA 4 .pdata 00000654 00012000 00000800 00010000 00000000 00000000 0 0 Flags: 40000040: READ,INITIALIZED DATA 5 .xdata 00000630 00013000 00000800 00010800 00000000 00000000 0 0 Flags: 40000040: READ,INITIALIZED DATA6 .bss
00001ec000014000 00000000 00000000 00000000 00000000 0 0
Flags:c0000080: READ,WRITE,UNINITIALIZED DATA
7 .idata00000c880001600000000e0000011000 00000000 00000000 0 0
Flags:c0000040: READ,WRITE,INITIALIZED DATA
8 .CRT 00000060 00017000 0000020000011e0000000000 00000000 0 0
Flags:c0000040: READ,WRITE,INITIALIZED DATA
9 .tls 00000010 00018000 00000200 00012000 00000000 00000000 0 0
Flags:c0000040: READ,WRITE,INITIALIZED DATA
10 .reloc0000009c00019000 00000200 00012200 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
11 /4 000001500001a00000000200 00012400 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
12 /190000d5e40001b0000000d60000012600 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
13 /31000014de00029000 000016000001fc0000000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
14 /4500001a360002b00000001c0000021200 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
15 /5700000f400002d0000000100000022e0000000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
16 /70000003a00002e0000000040000023e0000000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
17 /8100000a760002f00000000c0000024200 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
18 /970000174a00030000 0000180000024e0000000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATA
19 /1130000039c00032000 00000400 00026600 00000000 00000000 0 0
Flags: 42000040: DISCARDABLE,READ,INITIALIZED DATAQuoted 5 lines
Quoted 1 line
I suppose I will change to simply "Align some sections to 4KB"
"Some" is imo going to be too imprecise. Please qualify which sections you intend to align. If new sections need adding in the future, this then can guide people as to whether those may also need aligning.
Quoted 6 lines
The main issue is that sections with different permissions must be in separate sections.
In the case of debug sections they are contiguous and have the same permissions so it's not an issue (although better to strip them off).Any suggestions on how to describe this?
s/all/relevant/ (or some such) in the subject and then largely what you say above as part of the description.
Jan
PATCH 3/6 x86/efi: discard .text.header for PE binary
In reply to Frediano ZiglioFrom: Roger Pau Monné <[email protected]>
The multiboot headers are not consumed in the PE binary, hence discard them in the linker script when doing a PE build.
That removes some relocations that otherwise appear due to the usage of the start and __efi64_mb2_start symbols in the multiboot2 header.
No functional change intended.
--- xen/arch/x86/xen.lds.S | 3 +++ 1 file changed, 3 insertions(+)
xen/arch/x86/xen.lds.S +3 -0
@@ -57,6 +57,9 @@ SECTIONS __image_base__ = .; #else . = __image_base__; + /DISCARD/ : { + *(.text.header) + } #endif #if 0
Signature · 1 line
2.43.0
Re: [PATCH 3/6] x86/efi: discard .text.header for PE binary
Quoted 4 lines · Frediano Ziglio
From: Roger Pau Monné <[email protected]>
The multiboot headers are not consumed in the PE binary, hence discard them in the linker script when doing a PE build.
Yet weren't there plans to allow making use of those headers even in xen.efi?
Quoted 9 lines
That removes some relocations that otherwise appear due to the usage of the start and
__efi64_mb2_startsymbols in the multiboot2 header.No functional change intended.
Signed-off-by Roger Pau Monné <[email protected]>--- xen/arch/x86/xen.lds.S | 3 +++ 1 file changed, 3 insertions(+)
This is lacking your own S-o-b.
xen/arch/x86/xen.lds.S SECTIONS · line 63
Quoted 10 lines
xen/arch/x86/xen.lds.S +3
-0@@ -57,6 +57,9 @@ SECTIONS __image_base__ = .; #else . = __image_base__; + /DISCARD/ : { + *(.text.header) + } #endif
We already have DISCARD_SECTIONS, so I think it needs clarifying why that can't be used / extended.
Jan
Re: [PATCH 3/6] x86/efi: discard .text.header for PE binary
Quoted 9 lines · Jan Beulich
Quoted 4 lines · Frediano Ziglio
From: Roger Pau Monné <[email protected]>
The multiboot headers are not consumed in the PE binary, hence discard them in the linker script when doing a PE build.
Yet weren't there plans to allow making use of those headers even in xen.efi?
That method was replaced by different ways of loading. Using multiboot for PE would require some extensions to multiboot as the protocol is not designed to support PE format. There are already ways to use EFI and configuration files that can be used. We (as Citrix) are going (not me personally) to post changes to extend xen_hypervisor and xen_module (used currently only by ARM) to x64. These changes are much smaller, maintainable and coherent.
Quoted 12 lines
Quoted 9 lines
That removes some relocations that otherwise appear due to the usage of the start and
__efi64_mb2_startsymbols in the multiboot2 header.No functional change intended.
Signed-off-by Roger Pau Monné <[email protected]>--- xen/arch/x86/xen.lds.S | 3 +++ 1 file changed, 3 insertions(+)This is lacking your own S-o-b.
Quoted 14 lines
xen/arch/x86/xen.lds.S SECTIONS · line 63
Quoted 10 lines
xen/arch/x86/xen.lds.S +3
-0@@ -57,6 +57,9 @@ SECTIONS __image_base__ = .; #else . = __image_base__; + /DISCARD/ : { + *(.text.header) + } #endifWe already have
DISCARD_SECTIONS, so I think it needs clarifying why that can't be used / extended.
Yes, this can be done that way. Roger, do you agree on this ?
Quoted 1 line
Jan
Frediano
Re: [PATCH 3/6] x86/efi: discard .text.header for PE binary
Quoted 14 lines · Frediano Ziglio
Quoted 4 lines · Jan Beulich
Quoted 4 lines
xen/arch/x86/xen.lds.S +0
-0@@ -57,6 +57,9 @@ SECTIONS __image_base__ = .;Quoted 9 lines
xen/arch/x86/xen.lds.S SECTIONS · line 63
Quoted 6 lines
xen/arch/x86/xen.lds.S +3
-0#else . = __image_base__; + /DISCARD/ : { + *(.text.header) + } #endifWe already have
DISCARD_SECTIONS, so I think it needs clarifying why that can't be used / extended.
Quoted 1 line
Yes, this can be done that way. Roger, do you agree on this ?
You'll need to add a general ARCH_DISCARD_SECTIONS, and have x86 fill in {ELF,EFI}_DISCARD_SECTIONS conditionally.
Also you need to fold this hunk.
docs/hypervisor-guide/x86/how-xen-boots.rst +0 -0
@@ -82,12 +82,6 @@ When a PEI-capable toolchain is found, the objects are linked together and a
PE32+ binary is created. It can be run directly from the EFI shell, and has ``efi_start`` as its entry symbol.
-.. note::
-
- xen.efi does contain all MB1/MB2/PVH tags included in the rest of the - build. However, entry via anything other than the EFI64 protocol is - unsupported, and won't work.
-
Boot
----
~Andrew
Re: [PATCH 3/6] x86/efi: discard .text.header for PE binary
Quoted 16 lines · Andrew Cooper
Quoted 14 lines · Frediano Ziglio
Quoted 13 lines · Jan Beulich
xen/arch/x86/xen.lds.S SECTIONS · line 63
Quoted 10 lines
xen/arch/x86/xen.lds.S +3
-0@@ -57,6 +57,9 @@ SECTIONS __image_base__ = .; #else . = __image_base__; + /DISCARD/ : { + *(.text.header) + } #endifWe already have
DISCARD_SECTIONS, so I think it needs clarifying why that can't be used / extended.
Quoted 5 lines
Quoted 1 line
Yes, this can be done that way. Roger, do you agree on this ?
You'll need to add a general
ARCH_DISCARD_SECTIONS, and have x86 fill in {ELF,EFI}_DISCARD_SECTIONS conditionally.
I think binutils simply ignore sections not present so this is not necessary. I'll test it.
Quoted 10 lines
Also you need to fold this hunk.
docs/hypervisor-guide/x86/how-xen-boots.rst +0
-0@@ -82,12 +82,6 @@ When a PEI-capable toolchain is found, the objects are linked together and a PE32+ binary is created. It can be run directly from the EFI shell, and has ``efi_start`` as its entry symbol.
docs/hypervisor-guide/x86/how-xen-boots.rst When a PEI-capable toolchain is found, the objects are linked together and a · line 87
Quoted 10 lines
docs/hypervisor-guide/x86/how-xen-boots.rst +0
-6-.. note:: - - xen.efi does contain all MB1/MB2/PVH tags included in the rest of the - build. However, entry via anything other than the EFI64 protocol is - unsupported, and won't work. - Boot ----
Sure, thanks
Quoted 3 lines
~Andrew
Frediano
Re: [PATCH 3/6] x86/efi: discard .text.header for PE binary
Quoted 16 lines · Frediano Ziglio
Quoted 15 lines · Andrew Cooper
Quoted 14 lines · Frediano Ziglio
Quoted 13 lines · Jan Beulich
xen/arch/x86/xen.lds.S SECTIONS · line 63
Quoted 10 lines
xen/arch/x86/xen.lds.S +3
-0@@ -57,6 +57,9 @@ SECTIONS __image_base__ = .; #else . = __image_base__; + /DISCARD/ : { + *(.text.header) + } #endifWe already have
DISCARD_SECTIONS, so I think it needs clarifying why that can't be used / extended.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Yes, this can be done that way. Roger, do you agree on this ?
FTOAD: I did _not_ suggest to make use of DISCARD_SECTIONS, as that won't work. Instead I did ask that it be clarified in the description why DISCARD_SECTIONS cannot be extended for the purpose here.
Quoted 5 lines
Quoted 2 lines
You'll need to add a general
ARCH_DISCARD_SECTIONS, and have x86 fill in {ELF,EFI}_DISCARD_SECTIONS conditionally.I think binutils simply ignore sections not present so this is not necessary. I'll test it.
But you can't discard .text.header blindly everywhere. The reason it can be discarded on x86, and only for xen.efi, is very much x86-specific.
Jan
PATCH 4/6 x86/efi: discard multiboot related entry code for PE binary
In reply to Frediano ZiglioFrom: Roger Pau Monné <[email protected]>
The multiboot and PVH entry points are not used in the PE binary, hence discard them in the linker script when doing a PE build.
That removes some relocations that otherwise appear due to the entry point code in head.S not being position independent.
No functional change intended.
--- xen/arch/x86/boot/head.S | 3 ++- xen/arch/x86/xen.lds.S | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-)
xen/arch/x86/boot/head.S +2 -1
@@ -152,7 +152,7 @@ vga_text_buffer: efi_platform: .byte 0 - .section .init.text, "ax", @progbits + .section .init.multiboot, "ax", @progbits early_error: /* Here to improve the disassembly. */
@@ -710,6 +710,7 @@ trampoline_setup: /* Jump into the relocated trampoline. */ lret + .section .init.text, "ax", @progbits ENTRY(trampoline_start) #include "trampoline.S" ENTRY(trampoline_end)
xen/arch/x86/xen.lds.S +2 -0
@@ -59,6 +59,7 @@ SECTIONS . = __image_base__; /DISCARD/ : { *(.text.header) + *(.init.multiboot) } #endif
@@ -200,6 +201,7 @@ SECTIONS _sinittext = .; *(.init.text) *(.text.startup) + *(.init.multiboot) _einittext = .; /* * Here are the replacement instructions. The linker sticks them
Signature · 1 line
2.43.0
Re: [PATCH 4/6] x86/efi: discard multiboot related entry code for PE binary
Quoted 8 lines · Frediano Ziglio
From: Roger Pau Monné <[email protected]>
The multiboot and PVH entry points are not used in the PE binary, hence discard them in the linker script when doing a PE build.
That removes some relocations that otherwise appear due to the entry point code in
head.Snot being position independent.
Quoted 7 lines
No functional change intended.
Signed-off-by Roger Pau Monné <[email protected]>--- xen/arch/x86/boot/head.S | 3 ++- xen/arch/x86/xen.lds.S | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-)
S-o-b issue again.
xen/arch/x86/xen.lds.S SECTIONS · line 205
Quoted 6 lines
xen/arch/x86/xen.lds.S +1
-0@@ -200,6 +201,7 @@ SECTIONS _sinittext = .; *(.init.text) *(.text.startup) + *(.init.multiboot) _einittext = .;
Aren't you making a needlessly big change to the final image by placing this last rather than first?
Jan
Re: [PATCH 4/6] x86/efi: discard multiboot related entry code for PE binary
Quoted 12 lines · Jan Beulich
Quoted 10 lines · Frediano Ziglio
From: Roger Pau Monné <[email protected]>
The multiboot and PVH entry points are not used in the PE binary, hence discard them in the linker script when doing a PE build.
That removes some relocations that otherwise appear due to the entry point code in
head.Snot being position independent.No functional change intended.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Roger Pau Monné <[email protected]>--- xen/arch/x86/boot/head.S | 3 ++- xen/arch/x86/xen.lds.S | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-)S-o-b issue again.
Even if I didn't make any changes to the original patch ?
Quoted 10 lines
xen/arch/x86/xen.lds.S SECTIONS · line 205
Quoted 6 lines
xen/arch/x86/xen.lds.S +1
-0@@ -200,6 +201,7 @@ SECTIONS _sinittext = .; *(.init.text) *(.text.startup) + *(.init.multiboot) _einittext = .;Aren't you making a needlessly big change to the final image by placing this last rather than first?
Yes, I agree, .init.multiboot section should be even before .init.test. I'll change it.
Quoted 1 line
Jan
Frediano
Re: [PATCH 4/6] x86/efi: discard multiboot related entry code for PE binary
Quoted 12 lines · Frediano Ziglio
Quoted 11 lines · Jan Beulich
Quoted 10 lines · Frediano Ziglio
From: Roger Pau Monné <[email protected]>
The multiboot and PVH entry points are not used in the PE binary, hence discard them in the linker script when doing a PE build.
That removes some relocations that otherwise appear due to the entry point code in
head.Snot being position independent.No functional change intended.
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Signed-off-by Roger Pau Monné <[email protected]>--- xen/arch/x86/boot/head.S | 3 ++- xen/arch/x86/xen.lds.S | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-)S-o-b issue again.
Even if I didn't make any changes to the original patch ?
Yes. Everything you submit must have your SoB, per the DOC. It is a declaration that, to the best of your knowledge, the license is compatible.
Honestly, I think this patch would be better merged with the prior one. Both are taking out multiboot content.
~Andrew
PATCH 5/6 x86/efi: avoid a relocation in efi_arch_post_exit_boot()
In reply to Frediano ZiglioFrom: Roger Pau Monné <[email protected]>
Instead of using the absolute __start_xen address, calculate it as an offset from the current instruction pointer. The relocation would be problematic if the loader has acknowledged the Xen image section attributes, and mapped .init.text with just read and execute permissions.
No functional change intended.
--- xen/arch/x86/efi/efi-boot.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
xen/arch/x86/efi/efi-boot.h +5 -2
@@ -270,7 +270,9 @@ static void __init noreturn efi_arch_post_exit_boot(void)/* Jump to higher mappings. */ "mov stack_start(%%rip), %%rsp\n\t" -"movabs $__start_xen, %[rip]\n\t" +"lea __start_xen(%%rip), %[rip]\n\t" +"add %[offset], %[rip]\n\t" +"push %[cs]\n\t" "push %[rip]\n\t" "lretq"
@@ -278,7 +280,8 @@ static void __init noreturn efi_arch_post_exit_boot(void) [cr4] "+&r" (cr4) : [cr3] "r" (idle_pg_table), [cs] "i" (__HYPERVISOR_CS), - [ds] "r" (__HYPERVISOR_DS) + [ds] "r" (__HYPERVISOR_DS), + [offset] "r" (__XEN_VIRT_START - xen_phys_start) : "memory" ); unreachable(); }
Signature · 1 line
2.43.0
Re: [PATCH 5/6] x86/efi: avoid a relocation in efi_arch_post_exit_boot()
Quoted 6 lines · Frediano Ziglio
From: Roger Pau Monné <[email protected]>
Instead of using the absolute
__start_xenaddress, calculate it as an offset from the current instruction pointer. The relocation would be problematic if the loader has acknowledged the Xen image section attributes, and mapped .init.text with just read and execute permissions.
How can the loader respect what .init.text wants when it sees only .init, prior to the subsequent patch? Was the series meant to be ordered differently?
Jan
Re: [PATCH 5/6] x86/efi: avoid a relocation in efi_arch_post_exit_boot()
Quoted 10 lines · Jan Beulich
Quoted 6 lines · Frediano Ziglio
From: Roger Pau Monné <[email protected]>
Instead of using the absolute
__start_xenaddress, calculate it as an offset from the current instruction pointer. The relocation would be problematic if the loader has acknowledged the Xen image section attributes, and mapped .init.text with just read and execute permissions.How can the loader respect what .init.text wants when it sees only .init, prior to the subsequent patch? Was the series meant to be ordered differently?
No. Xen explodes if you split .init and this relocation is present.
It's the part where Xen undoes the relocation that the UEFI loader did.
Removing this relocation is necessary to make it safe to split .init.
~Andrew
Re: [PATCH 5/6] x86/efi: avoid a relocation in efi_arch_post_exit_boot()
Quoted 12 lines · Andrew Cooper
Quoted 10 lines · Jan Beulich
Quoted 6 lines · Frediano Ziglio
From: Roger Pau Monné <[email protected]>
Instead of using the absolute
__start_xenaddress, calculate it as an offset from the current instruction pointer. The relocation would be problematic if the loader has acknowledged the Xen image section attributes, and mapped .init.text with just read and execute permissions.How can the loader respect what .init.text wants when it sees only .init, prior to the subsequent patch? Was the series meant to be ordered differently?
Quoted 5 lines
No. Xen explodes if you split .init and this relocation is present.
It's the part where Xen undoes the relocation that the UEFI loader did.
Removing this relocation is necessary to make it safe to split .init.
Okay, so ordering of the series is intentional as is, but the description here is imprecise.
Jan
PATCH 6/6 x86: Split .init section to satisfy UEFI CA memory mitigation
In reply to Frediano ZiglioCurrently .init section is both writeable and executable, split data and code to have 2 sections satisfying W^X rule.
--- xen/arch/x86/xen.lds.S | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
xen/arch/x86/xen.lds.S +4 -8
@@ -193,11 +193,7 @@ SECTIONS __2M_init_start = .; /* Start of 2M superpages, mapped RWX (boot only). */ . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; -#ifdef EFI /* EFI wants to merge all of .init.* ELF doesn't. */ - DECL_SECTION(.init) { -#else DECL_SECTION(.init.text) { -#endif _sinittext = .; *(.init.text) *(.text.startup)
@@ -210,12 +206,12 @@ SECTIONS */ *(.altinstr_replacement) -#ifdef EFI /* EFI wants to merge all of .init.* ELF doesn't. */ - . = ALIGN(SMP_CACHE_BYTES); -#else } PHDR(text) - DECL_SECTION(.init.data) { +#ifdef EFI + /* align to satisfy UEFI CA memory mitigation */ + . = ALIGN(SECTION_ALIGN); #endif + DECL_SECTION(.init.data) { *(.init.bss.stack_aligned) *(.init.data.page_aligned)
Signature · 1 line
2.43.0
Re: [PATCH 6/6] x86: Split .init section to satisfy UEFI CA memory mitigation
Quoted 4 lines · Frediano Ziglio
Currently .init section is both writeable and executable, split data and code to have 2 sections satisfying W^X rule.
Signed-off-by Frediano Ziglio <[email protected]>
Like for the earlier patch: Reference please to where this requirement is stated.
Quoted 16 lines
xen/arch/x86/xen.lds.S +0
-4@@ -193,11 +193,7 @@ SECTIONS __2M_init_start = .; /* Start of 2M superpages, mapped RWX (boot only). */ . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; -#ifdef EFI /* EFI wants to merge all of .init.* ELF doesn't. */ - DECL_SECTION(.init) { -#else DECL_SECTION(.init.text) { -#endif _sinittext = .; *(.init.text) *(.text.startup)@@ -210,12 +206,12 @@ SECTIONS */
xen/arch/x86/xen.lds.S SECTIONS · line 212
Quoted 10 lines
xen/arch/x86/xen.lds.S +3
-4*(.altinstr_replacement) -#ifdef EFI /* EFI wants to merge all of .init.* ELF doesn't. */ - . = ALIGN(SMP_CACHE_BYTES); -#else } PHDR(text) - DECL_SECTION(.init.data) { +#ifdef EFI + /* align to satisfy UEFI CA memory mitigation */ + . = ALIGN(SECTION_ALIGN);
Nit (also for the earlier patch iirc): Comment style.
Jan