[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/4] x86/efi: Split .init section to satisfy Microsoft UEFI signing requirements



From: Frediano Ziglio <frediano.ziglio@xxxxxxxxxx>

Since 2022, Microsoft require that sections are not both writable and
executable, in order to be able to apply W^X restrictions.

Xen specifies SectionAlignment=2M, which technically requires that all
sections have such alignment.  For now, only separate code and data sections
in this way.  This is good enough to get an OVMF based StrictNX test working
in CI.

In the longterm Xen needs to be reworked to use SectionAlignment=4k, which
will allow us to become fully compliant without more than doubling the size of
Xen in memory.

Link: 
https://techcommunity.microsoft.com/blog/hardware-dev-center/updated-microsoft-uefi-signing-requirements/1062916
Signed-off-by: Frediano Ziglio <frediano.ziglio@xxxxxxxxxx>
Acked-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
CC: Anthony PERARD <anthony.perard@xxxxxxxxxx>
CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
CC: Michal Orzel <michal.orzel@xxxxxxx>
CC: Doug Goldstein <cardoe@xxxxxxxxxx>
CC: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
CC: Jan Beulich <jbeulich@xxxxxxxx>
CC: Roger Pau Monné <roger@xxxxxxxxxxxxxx>
CC: Teddy Astie <teddy.astie@xxxxxxxxxx>
CC: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>
CC: Frediano Ziglio <freddy77@xxxxxxxxx>

This reverts part of commit 1308f0170c1f ("x86/EFI: warn about r/o sections
requiring relocations"), following the work to ensure that Xen does not write
into read-only sections.
---
 xen/arch/x86/xen.lds.S | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index cef3d404a1a8..474cdd95c9e8 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -192,11 +192,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.multiboot)
        *(.init.text)
@@ -212,12 +208,19 @@ 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
+  /*
+   * Xen.efi specifies SectionAlignment=2M, allowing it to be constructed with
+   * superpages.  StrictNX requires code sections to be non-writable, so
+   * .init.data must not share the same superpage.
+   *
+   * TODO: Rework Xen to use SectionAlignment=4k.
+   */
+  . = ALIGN(SECTION_ALIGN);
 #endif
+  DECL_SECTION(.init.data) {
        *(.init.bss.stack_aligned)
        *(.init.data.page_aligned)
 
-- 
2.39.5




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.