xen/efi: Add /mapres to map EfiReservedMemoryType for runtime services
PATCH 1/1 xen/efi: Add /mapres to map EfiReservedMemoryType for runtime services
From: Ross Lagerwall <[email protected]>
In the same vein as needing /mapbs, some EFI firmware runtime services access areas marked as EfiReservedMemoryType.
The failing firmware implementations were:
Product Name: PowerEdge R720
Vendor: Dell Inc.
Version: 2.1.2
Release Date: 09/19/2013
BIOS Revision: 2.1
Product Name: PowerEdge R320
Vendor: Dell Inc.
Version: 1.5.2
Release Date: 03/11/2013
BIOS Revision: 1.5
--- xen/common/efi/boot.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
xen/common/efi/boot.c +9 -2
@@ -88,6 +88,7 @@ static bool_t read_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name,static UINT32 __initdata mdesc_ver;static bool_t __initdata map_bs; +static bool_t __initdata map_res;static struct file __initdata cfg;static struct file __initdata kernel;
@@ -763,6 +764,8 @@ static int __init __maybe_unused set_color(u32 mask, int bpp, u8 *pos, u8 *sz) base_video =1 ; else if ( wstrcmp(ptr + 1, L"mapbs") == 0 ) map_bs =1 ; + else if ( wstrcmp(ptr + 1, L"mapres") == 0 ) + map_res =1 ; else if ( wstrncmp(ptr + 1, L"cfg=", 4) == 0 ) cfg_file_name = ptr +5 ; else if ( i + 1 < argc && wstrcmp(ptr + 1, L"cfg") == 0 )
@@ -1216,7 +1219,9 @@ void __init efi_init_memory(void) (!(desc->Attribute &EFI_MEMORY_RUNTIME ) && (!map_bs || (desc->Type != EfiBootServicesCode && - desc->Type != EfiBootServicesData))) ) + desc->Type != EfiBootServicesData)) && + (!map_res || + desc->Type != EfiReservedMemoryType)) ) continue; desc->VirtualStart =INVALID_VIRTUAL_ADDRESS ;
@@ -1311,7 +1316,9 @@ void __init efi_init_memory(void)if ( ((desc->Attribute &EFI_MEMORY_RUNTIME ) || (map_bs && (desc->Type == EfiBootServicesCode || - desc->Type == EfiBootServicesData))) && + desc->Type == EfiBootServicesData)) || + (map_res && + (desc->Type == EfiReservedMemoryType))) && desc->VirtualStart !=INVALID_VIRTUAL_ADDRESS && desc->VirtualStart != desc->PhysicalStart ) copy_mapping(PFN_DOWN(desc->PhysicalStart),
Signature · 1 line
1.7.10.4
xen/common/efi/boot.c static int __init __maybe_unused set_color(u32 mask, int bpp, u8 *pos, u8 *sz) · line 768
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 17.06.15 at 15:46, <[email protected]> wrote:
xen/common/efi/boot.c +2
-0@@ -763,6 +764,8 @@ static int __init __maybe_unused set_color(u32 mask, int bpp, u8 *pos, u8 *sz) base_video =1 ; else if ( wstrcmp(ptr + 1, L"mapbs") == 0 ) map_bs =1 ; + else if ( wstrcmp(ptr + 1, L"mapres") == 0 ) + map_res =1 ;
For one, this not being used in loader code, it should be a sub-option to the regular efi= option instead of loader one.
xen/common/efi/boot.c void __init efi_init_memory(void) · line 1227
Quoted 11 lines
xen/common/efi/boot.c +3
-1@@ -1216,7 +1219,9 @@ void __init efi_init_memory(void) (!(desc->Attribute &EFI_MEMORY_RUNTIME ) && (!map_bs || (desc->Type != EfiBootServicesCode && - desc->Type != EfiBootServicesData))) ) + desc->Type != EfiBootServicesData)) && + (!map_res || + desc->Type != EfiReservedMemoryType)) ) continue; desc->VirtualStart =INVALID_VIRTUAL_ADDRESS ;
And then I have severe reservations against adding mappings to _all_ reserved regions: What if the cachability for them is given incorrectly in the memory map, and we end up inserting a mapping that the processor can speculate into? At the very least all such mappings imo should be forced to be UC. But I think such mappings should be added in much more fine grained manner, i.e. the command line option should allow to specify page ranges (any of which not being marked EfiReservedMemoryType would be silently ignored).
Jan