efi/boot: Don't free ebmalloc area at all
PATCH v2 1/1 efi/boot: Don't free ebmalloc area at all
Freeing part of the BSS back for general use proves to be problematic. It is not accounted for in xen_in_range(), causing errors when constructing the IOMMU tables, resulting in a failure to boot.
Other smaller issues are that tboot treats the entire BSS as hypervisor data, creating and checking a MAC of it on S3, and that, by being 1MB in size, freeing it guarentees to shatter the hypervisor superpage mappings.
This is a stopgap fix to unblock master, while alternatives are discussed.
---
CC: Jan Beulich <[email protected]>
--- xen/common/efi/boot.c | 16 ---------------- 1 file changed, 16 deletions(-)
xen/common/efi/boot.c +0 -16
@@ -120,7 +120,6 @@ static CHAR16 __initdata newline[] = L"\r\n";* have to be disabled in xen/arch/arm/arm64/head.S; though BSS * should be initialized somehow before use of variables living there, * - use ebmalloc() in ARM/common EFI boot code, -* - call free_ebmalloc_unused_mem() somewhere in init code. */ #define EBMALLOC_SIZE MB(0)#else
@@ -144,19 +143,6 @@ static void __init __maybe_unused *ebmalloc(size_t size)return ptr; } -static void __init __maybe_unused free_ebmalloc_unused_mem (void ) -{ -unsigned long start, end; - - start = (unsigned long )ebmalloc_mem +PAGE_ALIGN (ebmalloc_allocated); - end = (unsigned long )ebmalloc_mem +sizeof (ebmalloc_mem); - -destroy_xen_mappings (start, end); -init_xenheap_pages (__pa (start),__pa (end)); - -printk (XENLOG_INFO "Freed %lukB unused BSS memory\n" , (end - start) >>10 ); -} -/* * Include architecture specific implementation here, which references the * static globals defined above.
@@ -1310,8 +1296,6 @@ void __init efi_init_memory(void) } *extra, *extra_head = NULL;#endif -free_ebmalloc_unused_mem (); -if ( !efi_enabled (EFI_BOOT ) )return ;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 01.03.17 at 11:28, <[email protected]> wrote:
xen/common/efi/boot.c +0
-2@@ -144,19 +143,6 @@ static void __init __maybe_unused *ebmalloc(size_t size)return ptr; } -static void __init __maybe_unused free_ebmalloc_unused_mem (void ) -{
xen/common/efi/boot.c static void __init __maybe_unused *ebmalloc(size_t size) · line 158
Quoted 10 lines
xen/common/efi/boot.c +0
-10-unsigned long start, end; - - start = (unsigned long )ebmalloc_mem +PAGE_ALIGN (ebmalloc_allocated); - end = (unsigned long )ebmalloc_mem +sizeof (ebmalloc_mem); - -destroy_xen_mappings (start, end); -init_xenheap_pages (__pa (start),__pa (end)); - -printk (XENLOG_INFO "Freed %lukB unused BSS memory\n" , (end - start) >>10 ); -}
To be honest, for a temporary workaround I'd have expected to just see the last three lines of the function put inside "#if 0". But anyway,
The one thing I don't understand here, btw, is why it is only 32-bit Dom0 that fails to boot. Do you have any explanation or theory?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 01.03.17 at 11:28, <[email protected]> wrote:
xen/common/efi/boot.c +0
-0@@ -144,19 +143,6 @@ static void __init __maybe_unused *ebmalloc(size_t size)return ptr; }
Quoted 15 lines
xen/common/efi/boot.c static void __init __maybe_unused *ebmalloc(size_t size) · line 158
Quoted 12 lines
xen/common/efi/boot.c +0
-12-static void __init __maybe_unused free_ebmalloc_unused_mem (void ) -{ -unsigned long start, end; - - start = (unsigned long )ebmalloc_mem +PAGE_ALIGN (ebmalloc_allocated); - end = (unsigned long )ebmalloc_mem +sizeof (ebmalloc_mem); - -destroy_xen_mappings (start, end); -init_xenheap_pages (__pa (start),__pa (end)); - -printk (XENLOG_INFO "Freed %lukB unused BSS memory\n" , (end - start) >>10 ); -}To be honest, for a temporary workaround I'd have expected to just see the last three lines of the function put inside "#if 0". But anyway,
I can do this if your ack still stands?
Quoted 5 lines
Acked-by Jan Beulich <[email protected]>The one thing I don't understand here, btw, is why it is only 32-bit Dom0 that fails to boot. Do you have any explanation or theory?
32bit guests are allocated from 0 upwards, while 64bit are allocated from top down, to keep as many mfns below the 128GB boundary available for 32bit guests.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 01.03.17 at 11:41, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 01.03.17 at 11:28, <[email protected]> wrote:
xen/common/efi/boot.c +0
-0@@ -144,19 +143,6 @@ static void __init __maybe_unused *ebmalloc(size_t size)return ptr; }Quoted 15 lines
xen/common/efi/boot.c static void __init __maybe_unused *ebmalloc(size_t size) · line 158
Quoted 12 lines
xen/common/efi/boot.c +0
-12-static void __init __maybe_unused free_ebmalloc_unused_mem (void ) -{ -unsigned long start, end; - - start = (unsigned long )ebmalloc_mem +PAGE_ALIGN (ebmalloc_allocated); - end = (unsigned long )ebmalloc_mem +sizeof (ebmalloc_mem); - -destroy_xen_mappings (start, end); -init_xenheap_pages (__pa (start),__pa (end)); - -printk (XENLOG_INFO "Freed %lukB unused BSS memory\n" , (end - start) >>10 ); -}To be honest, for a temporary workaround I'd have expected to just see the last three lines of the function put inside "#if 0". But anyway,
Quoted 1 line
I can do this if your ack still stands?
Sure it does.
Quoted 8 lines
Quoted 4 lines
Acked-by Jan Beulich <[email protected]>The one thing I don't understand here, btw, is why it is only 32-bit Dom0 that fails to boot. Do you have any explanation or theory?
32bit guests are allocated from 0 upwards, while 64bit are allocated from top down, to keep as many mfns below the 128GB boundary available for 32bit guests.
I have to admit that I can't even see how such a bottom-up allocation would work, considering that the generic page allocator has no control for doing so and doesn't itself use any of the is_32*() constructs. Similarly when splitting chunks it always returns the highest part and keeps lower ones. The only difference I can see (on huge systems) is that for 32-bit Dom0 we'd allocate from 128Gb down, while for 64-bit it would be from top-of-memory.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel