efi: avoid hard-coding the various PAT constants

This makes the code much easier to understand, and avoids problems if
Xen's PAT ever changes in the future.

Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Demi Marie Obenour authored and Jan Beulich committed 2022-12-15 17:04:40 +01:00
1 parent 1ca8af08df
commit 32b61bcafc
1 file changed
+6 -6
+6 -6
View File
@@ -1724,23 +1724,23 @@ void __init efi_init_memory(void)
emfn = PFN_UP(desc->PhysicalStart + len);
if ( desc->Attribute & EFI_MEMORY_WB )
/* nothing */;
prot |= _PAGE_WB;
else if ( desc->Attribute & EFI_MEMORY_WT )
prot |= _PAGE_PWT | MAP_SMALL_PAGES;
prot |= _PAGE_WT | MAP_SMALL_PAGES;
else if ( desc->Attribute & EFI_MEMORY_WC )
prot |= _PAGE_PAT | MAP_SMALL_PAGES;
prot |= _PAGE_WC | MAP_SMALL_PAGES;
else if ( desc->Attribute & (EFI_MEMORY_UC | EFI_MEMORY_UCE) )
prot |= _PAGE_PWT | _PAGE_PCD | MAP_SMALL_PAGES;
prot |= _PAGE_UC | MAP_SMALL_PAGES;
else if ( efi_bs_revision >= EFI_REVISION(2, 5) &&
(desc->Attribute & EFI_MEMORY_WP) )
prot |= _PAGE_PAT | _PAGE_PWT | MAP_SMALL_PAGES;
prot |= _PAGE_WP | MAP_SMALL_PAGES;
else
{
printk(XENLOG_ERR "Unknown cachability for MFNs %#lx-%#lx%s\n",
smfn, emfn - 1, efi_map_uc ? ", assuming UC" : "");
if ( !efi_map_uc )
continue;
prot |= _PAGE_PWT | _PAGE_PCD | MAP_SMALL_PAGES;
prot |= _PAGE_UC | MAP_SMALL_PAGES;
}
if ( desc->Attribute & (efi_bs_revision < EFI_REVISION(2, 5)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.