Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

efi: make efi_mem_type() and efi_mem_attributes() work on Xen PV

Xen doesn't give direct access to the EFI memory map, but provides a
hypercall interface for it. efi_mem_desc_lookup() was already adjusted
in aca1d27ac38a "efi: xen: Implement memory descriptor lookup based on
hypercall" to (optionally) use it. Now make efi_mem_type() and
efi_mem_attributes() use common efi_mem_desc_lookup() too.
This also reduces code duplication a bit.
efi_mem_type() retains separate check for -ENOTSUPP error case (even
though no caller seems to rely on this currently).

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
[ardb: Drop erroneous 'const' qualifier]
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

authored by

Marek Marczykowski-Górecki and committed by
Ard Biesheuvel
80e80a70 1f318b96

+9 -18
+9 -18
drivers/firmware/efi/efi.c
··· 983 983 */ 984 984 u64 efi_mem_attributes(unsigned long phys_addr) 985 985 { 986 - efi_memory_desc_t *md; 986 + efi_memory_desc_t md; 987 987 988 - if (!efi_enabled(EFI_MEMMAP)) 988 + if (efi_mem_desc_lookup(phys_addr, &md)) 989 989 return 0; 990 990 991 - for_each_efi_memory_desc(md) { 992 - if ((md->phys_addr <= phys_addr) && 993 - (phys_addr < (md->phys_addr + 994 - (md->num_pages << EFI_PAGE_SHIFT)))) 995 - return md->attribute; 996 - } 997 - return 0; 991 + return md.attribute; 998 992 } 999 993 1000 994 /* ··· 1001 1007 */ 1002 1008 int efi_mem_type(unsigned long phys_addr) 1003 1009 { 1004 - const efi_memory_desc_t *md; 1010 + efi_memory_desc_t md; 1005 1011 1006 - if (!efi_enabled(EFI_MEMMAP)) 1012 + if (!efi_enabled(EFI_MEMMAP) && !efi_enabled(EFI_PARAVIRT)) 1007 1013 return -ENOTSUPP; 1008 1014 1009 - for_each_efi_memory_desc(md) { 1010 - if ((md->phys_addr <= phys_addr) && 1011 - (phys_addr < (md->phys_addr + 1012 - (md->num_pages << EFI_PAGE_SHIFT)))) 1013 - return md->type; 1014 - } 1015 - return -EINVAL; 1015 + if (efi_mem_desc_lookup(phys_addr, &md)) 1016 + return -EINVAL; 1017 + 1018 + return md.type; 1016 1019 } 1017 1020 1018 1021 int efi_status_to_err(efi_status_t status)