From: Frediano Ziglio <frediano.ziglio@cloud.com>
Currently .init section is both writeable and executable, split data and code
to have 2 sections satisfying W^X rule.
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
Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
Change since v1:
- update comment style.
Changes since v3:
- Added Acked-by.
Changes since v4:
- Added Acked-by.
---
xen/arch/x86/xen.lds.S | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 4ed1d2bec1..e26e37db13 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -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.multiboot)
*(.init.text)
@@ -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)
--
2.43.0