Skip to contentSkip to conversation

efi: Allow EFI_MEMORY_XP and EFI_MEMORY_RO both to be cleared

PATCH In review Heiner Kallweit 2 participants 2 messages Apr 30, 2021 – May 7, 2021 EFI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi: Allow EFI_MEMORY_XP and EFI_MEMORY_RO both to be cleared

UEFI spec 2.9, p.108, table 4-1 lists the scenario that both attributes are cleared with the description "No memory access protection is possible for Entry". So we can have valid entries where both attributes are cleared, so remove the check.

---
 drivers/firmware/efi/memattr.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/firmware/efi/memattr.c +0 -5
index 5737cb0fc..0a9aba5f9 100644
@@ -67,11 +67,6 @@ static bool entry_is_valid(const efi_memory_desc_t *in, efi_memory_desc_t *out)
 		return false;
 	}
 
-	if (!(in->attribute & (EFI_MEMORY_RO | EFI_MEMORY_XP))) {
-		pr_warn("Entry attributes invalid: RO and XP bits both cleared\n");
-		return false;
-	}
-
 	if (PAGE_SIZE > EFI_PAGE_SIZE &&
 	    (!PAGE_ALIGNED(in->phys_addr) ||
 	     !PAGE_ALIGNED(in->num_pages << EFI_PAGE_SHIFT))) {
Signature · 1 line
2.31.1
maintainer
#1 lore raw
Quoted 7 lines · Heiner Kallweit

UEFI spec 2.9, p.108, table 4-1 lists the scenario that both attributes are cleared with the description "No memory access protection is possible for Entry". So we can have valid entries where both attributes are cleared, so remove the check.

Thanks, I'll queue this up after the merge window.

Quoted 23 lines
---
 drivers/firmware/efi/memattr.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/firmware/efi/memattr.c +0 -6
index 5737cb0fc..0a9aba5f9 100644
@@ -67,11 +67,6 @@ static bool entry_is_valid(const efi_memory_desc_t *in, efi_memory_desc_t *out)
                return false;
        }
 
-       if (!(in->attribute & (EFI_MEMORY_RO | EFI_MEMORY_XP))) {
-               pr_warn("Entry attributes invalid: RO and XP bits both cleared\n");
-               return false;
-       }
-
        if (PAGE_SIZE > EFI_PAGE_SIZE &&
            (!PAGE_ALIGNED(in->phys_addr) ||
             !PAGE_ALIGNED(in->num_pages << EFI_PAGE_SHIFT))) {
--

2.31.1