From: Andrew Cooper Date: Tue, 18 Oct 2016 13:08:00 +0000 (+0000) Subject: Separate page aligned data/bss into separate sections X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=8269707ab3526ae171bfc57f65116b8c255ad96b;p=people%2Fandrewcoop%2Fxen-test-framework.git Separate page aligned data/bss into separate sections This alone drops the size of HVM tests by 8k. Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/hvm/pagetables.S b/arch/x86/hvm/pagetables.S index 61c98e8..ee9bf42 100644 --- a/arch/x86/hvm/pagetables.S +++ b/arch/x86/hvm/pagetables.S @@ -16,7 +16,7 @@ #define PAE_IDX(sym) ((. - (sym)) / PAE_PTE_SIZE) #define PSE_IDX(sym) ((. - (sym)) / PSE_PTE_SIZE) - .data + .section ".data.page_aligned", "aw" .p2align PAGE_SHIFT /* PAE mappings of first 2M of memory in 4k pages. Uses 1x 4k page. */ @@ -72,6 +72,8 @@ PAGETABLE_START(pse_l2_identmap) PAGETABLE_END(pse_l2_identmap) .Lpse_l2_identmap_end: + .data + .align 32 /* PAE l3 32bit quad. Contains 4 64bit entries. */ PAGETABLE_START(pae32_l3_identmap) .rept PAE32_L3_ENTRIES diff --git a/arch/x86/hypercall_page.S b/arch/x86/hypercall_page.S index 94a7834..4787f09 100644 --- a/arch/x86/hypercall_page.S +++ b/arch/x86/hypercall_page.S @@ -2,8 +2,9 @@ #include #include -.data -.align PAGE_SIZE + .section ".data.page_aligned", "aw" + .p2align PAGE_SHIFT + GLOBAL(hypercall_page) /* Poisoned with `ret` for safety before hypercalls are set up. */ .fill PAGE_SIZE, 1, 0xc3 diff --git a/arch/x86/link.lds.S b/arch/x86/link.lds.S index 3941858..736659a 100644 --- a/arch/x86/link.lds.S +++ b/arch/x86/link.lds.S @@ -47,6 +47,9 @@ SECTIONS .data : { *(.data) + . = ALIGN(PAGE_SIZE); + *(.data.page_aligned) + . = ALIGN(PAGE_SIZE); } .rodata : { @@ -66,6 +69,9 @@ SECTIONS .bss : { *(.bss) + . = ALIGN(PAGE_SIZE); + *(.bss.page_aligned) + . = ALIGN(PAGE_SIZE); } _end = .; diff --git a/arch/x86/setup.c b/arch/x86/setup.c index f64f22f..bd2a505 100644 --- a/arch/x86/setup.c +++ b/arch/x86/setup.c @@ -16,8 +16,9 @@ * boot_stack[page 2] Exception entrypoints * boot_stack[page 1] Top of work stack */ -uint8_t boot_stack[3 * PAGE_SIZE] __aligned(PAGE_SIZE); -uint8_t user_stack[PAGE_SIZE] __aligned(PAGE_SIZE); +uint8_t boot_stack[3 * PAGE_SIZE] __page_aligned_bss; +uint8_t user_stack[PAGE_SIZE] __page_aligned_bss; + uint32_t x86_features[FSCAPINTS]; enum x86_vendor x86_vendor; unsigned int max_leaf, max_extd_leaf; diff --git a/include/xtf/compiler.h b/include/xtf/compiler.h index 9875b50..11a516c 100644 --- a/include/xtf/compiler.h +++ b/include/xtf/compiler.h @@ -22,6 +22,8 @@ /* Convenience wrappers. */ #define __user_text __section(".text.user") +#define __page_aligned_data __section(".data.page_aligned") __aligned(4096) +#define __page_aligned_bss __section(".bss.page_aligned") __aligned(4096) #endif /* XTF_COMPILER_H */ diff --git a/tests/xsa-170/main.c b/tests/xsa-170/main.c index c8fbf18..f8b4c1b 100644 --- a/tests/xsa-170/main.c +++ b/tests/xsa-170/main.c @@ -61,9 +61,9 @@ void nop_slide(void) void test_main(void) { - static intpte_t nl2t[L2_PT_ENTRIES] __aligned(PAGE_SIZE); - static intpte_t nl1t[L1_PT_ENTRIES] __aligned(PAGE_SIZE); - static uint8_t buffer[PAGE_SIZE] __aligned(PAGE_SIZE); + static intpte_t nl2t[L2_PT_ENTRIES] __page_aligned_bss; + static intpte_t nl1t[L1_PT_ENTRIES] __page_aligned_bss; + static uint8_t buffer[PAGE_SIZE] __page_aligned_bss; printk(" Executing user wild jump\n"); exec_user_void(wild_jump); diff --git a/tests/xsa-173/main.c b/tests/xsa-173/main.c index a4bc6de..dd5a25d 100644 --- a/tests/xsa-173/main.c +++ b/tests/xsa-173/main.c @@ -29,7 +29,7 @@ const char test_title[] = "XSA-173 PoC"; /* New L2 pagetable for the test to manipulate. */ -uint64_t nl2[PAE_L2_PT_ENTRIES] __aligned(PAGE_SIZE); +uint64_t nl2[PAE_L2_PT_ENTRIES] __page_aligned_bss; static bool seen_fault; diff --git a/tests/xsa-186/main.c b/tests/xsa-186/main.c index 93a7065..894a229 100644 --- a/tests/xsa-186/main.c +++ b/tests/xsa-186/main.c @@ -97,8 +97,8 @@ void test_main(void) if ( IS_DEFINED(CONFIG_64BIT) ) { - static intpte_t nl1t[L1_PT_ENTRIES] __aligned(PAGE_SIZE); - static intpte_t nl2t[L2_PT_ENTRIES] __aligned(PAGE_SIZE); + static intpte_t nl1t[L1_PT_ENTRIES] __page_aligned_bss; + static intpte_t nl2t[L2_PT_ENTRIES] __page_aligned_bss; /* * The manuals say we can't `iretq` to a compat mode code segment with diff --git a/tests/xsa-188/main.c b/tests/xsa-188/main.c index 0fac31f..a02059a 100644 --- a/tests/xsa-188/main.c +++ b/tests/xsa-188/main.c @@ -20,7 +20,7 @@ const char test_title[] = "XSA-188 PoC"; -static uint8_t array_page[PAGE_SIZE] __aligned(PAGE_SIZE); +static uint8_t array_page[PAGE_SIZE] __page_aligned_bss; void test_main(void) { diff --git a/tests/xsa-195/main.c b/tests/xsa-195/main.c index fb90df5..945b50b 100644 --- a/tests/xsa-195/main.c +++ b/tests/xsa-195/main.c @@ -30,9 +30,9 @@ const char test_title[] = "XSA-195 PoC"; -static intpte_t nl3t[L3_PT_ENTRIES] __aligned(PAGE_SIZE); -static intpte_t nl2t[L2_PT_ENTRIES] __aligned(PAGE_SIZE); -static intpte_t nl1t[L1_PT_ENTRIES] __aligned(PAGE_SIZE); +static intpte_t nl3t[L3_PT_ENTRIES] __page_aligned_bss; +static intpte_t nl2t[L2_PT_ENTRIES] __page_aligned_bss; +static intpte_t nl1t[L1_PT_ENTRIES] __page_aligned_bss; void test_main(void) {