lkml.org 
[lkml]   [2022]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] efi/x86: don't set unsupported memory attributes
Date
On platforms where the firmware uses DXE, but which do not implement the
EFI Memory Attribute Protocol, we implement W^X support using DXE's
set_memory_attributes() call. This call will fail without making any
changes if an attribute is set that isn't supported on the platform.

This patch changes efi_adjust_memory_range_protection() to avoid trying
to set any attribute bits that aren't set in the memory region's
capability flags.

Signed-off-by: Peter Jones <pjones@redhat.com>
---
drivers/firmware/efi/libstub/mem.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/firmware/efi/libstub/mem.c b/drivers/firmware/efi/libstub/mem.c
index d10996e4eb0..d52841adcc2 100644
--- a/drivers/firmware/efi/libstub/mem.c
+++ b/drivers/firmware/efi/libstub/mem.c
@@ -192,6 +192,7 @@ static efi_status_t adjust_mem_attrib_dxe(efi_physical_addr_t rounded_start,

desc.attributes &= ~(EFI_MEMORY_RO | EFI_MEMORY_XP);
desc.attributes |= attributes;
+ desc.attributes &= desc.capabilities;

unprotect_start = max(rounded_start, desc.base_address);
unprotect_size = min(rounded_end, next) - unprotect_start;
--
2.38.1
\
 
 \ /
  Last update: 2022-12-13 19:06    [W:0.130 / U:0.408 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site