xen/arm: during efi boot, improve the check for usable memory
PATCH 1/1 xen/arm: during efi boot, improve the check for usable memory
When booting via EFI, the EFI memory map has information about memory regions and their type. Improve the check for the type and attribute of each memory region to figure out whether it is usable memory or not. This patch brings the check on par with Linux and makes more memory reusable as normal memory by Xen.
--- xen/arch/arm/efi/efi-boot.h | 11 +++++++---- xen/include/efi/efidef.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-)
xen/arch/arm/efi/efi-boot.h +7 -4
@@ -149,10 +149,13 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *for ( Index =0 ; Index < (mmap_size / desc_size); Index++ ) { -if ( desc_ptr->Type == EfiConventionalMemory || - (!map_bs && - (desc_ptr->Type == EfiBootServicesCode || - desc_ptr->Type == EfiBootServicesData)) ) +if ( desc_ptr->Attribute &EFI_MEMORY_WB && + (desc_ptr->Type == EfiConventionalMemory || + desc_ptr->Type == EfiLoaderCode || + desc_ptr->Type == EfiLoaderData || + desc_ptr->Type == EfiPersistentMemory || + desc_ptr->Type == EfiBootServicesCode || + desc_ptr->Type == EfiBootServicesData) ) {if ( !meminfo_add_bank (&bootinfo.mem, desc_ptr) ) {
xen/include/efi/efidef.h +1 -0
@@ -147,6 +147,7 @@ typedef enum { EfiMemoryMappedIO, EfiMemoryMappedIOPortSpace, EfiPalCode, + EfiPersistentMemory, EfiMaxMemoryType }EFI_MEMORY_TYPE ;
Signature · 7 lines
2.17.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Stefano,
Quoted 5 lines · Stefano Stabellini
When booting via EFI, the EFI memory map has information about memory regions and their type. Improve the check for the type and attribute of each memory region to figure out whether it is usable memory or not. This patch brings the check on par with Linux and makes more memory reusable as normal memory by Xen.
Please mention the version of Linux used.
Furthermore, as I pointed out in the original thread, it may not be correct for Xen to use the exact same checks as Linux. More importantly any change in behavior should be explained in the commit message. For instance...
Quoted 14 lines
Reported-by Roman Shaposhnik <[email protected]>Signed-off-by Stefano Stabellini <[email protected]>CC Julien Grall <[email protected]>--- xen/arch/arm/efi/efi-boot.h | 11 +++++++---- xen/include/efi/efidef.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-)xen/arch/arm/efi/efi-boot.h +0
-0
xen/arch/arm/efi/efi-boot.h static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR * · line 153
Quoted 5 lines
xen/arch/arm/efi/efi-boot.h +0
-2@@ -149,10 +149,13 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *for ( Index =0 ; Index < (mmap_size / desc_size); Index++ ) { - if ( desc_ptr->Type == EfiConventionalMemory || - (!map_bs &&
... the behavior when the option /mapbs is given to the EFI stub will now change. Why such change?
xen/arch/arm/efi/efi-boot.h static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR * · line 156
Quoted 7 lines
xen/arch/arm/efi/efi-boot.h +5
-2- (desc_ptr->Type == EfiBootServicesCode || - desc_ptr->Type == EfiBootServicesData)) ) + if ( desc_ptr->Attribute & EFI_MEMORY_WB && + (desc_ptr->Type == EfiConventionalMemory || + desc_ptr->Type == EfiLoaderCode || + desc_ptr->Type == EfiLoaderData || + desc_ptr->Type == EfiPersistentMemory ||
I am not entirely convince this is the right thing to do. From my understanding, a region marked as EfiPersistentMemory will keep the state of memory accross power cycle.
As the memory will be given to the Xen allocator directly, this means some domains may randomly have there data placed in the NVM. Wouldn't this be considered as a leak of data?
Quoted 11 lines
xen/arch/arm/efi/efi-boot.h +2
-0+ desc_ptr->Type == EfiBootServicesCode || + desc_ptr->Type == EfiBootServicesData) ) {if ( !meminfo_add_bank (&bootinfo.mem, desc_ptr) ) {xen/include/efi/efidef.h +0
-0
xen/include/efi/efidef.h typedef enum { · line 153
Quoted 7 lines
xen/include/efi/efidef.h +1
-0@@ -147,6 +147,7 @@ typedef enum { EfiMemoryMappedIO, EfiMemoryMappedIOPortSpace, EfiPalCode, + EfiPersistentMemory, EfiMaxMemoryType }EFI_MEMORY_TYPE ;
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel