Skip to content

Commit 79729f2

Browse files
summaryInfoardbiesheuvel
authored andcommitted
efi/libstub: Add memory attribute protocol definitions
EFI_MEMORY_ATTRIBUTE_PROTOCOL servers as a better alternative to DXE services for setting memory attributes in EFI Boot Services environment. This protocol is better since it is a part of UEFI specification itself and not UEFI PI specification like DXE services. Add EFI_MEMORY_ATTRIBUTE_PROTOCOL definitions. Support mixed mode properly for its calls. Tested-by: Mario Limonciello <[email protected]> Signed-off-by: Evgeniy Baskov <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent 0217a40 commit 79729f2

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

arch/x86/include/asm/efi.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,13 @@ static inline u32 efi64_convert_status(efi_status_t status)
335335
#define __efi64_argmap_open_volume(prot, file) \
336336
((prot), efi64_zero_upper(file))
337337

338+
/* Memory Attribute Protocol */
339+
#define __efi64_argmap_set_memory_attributes(protocol, phys, size, flags) \
340+
((protocol), __efi64_split(phys), __efi64_split(size), __efi64_split(flags))
341+
342+
#define __efi64_argmap_clear_memory_attributes(protocol, phys, size, flags) \
343+
((protocol), __efi64_split(phys), __efi64_split(size), __efi64_split(flags))
344+
338345
/*
339346
* The macros below handle the plumbing for the argument mapping. To add a
340347
* mapping for a specific EFI method, simply define a macro

drivers/firmware/efi/libstub/efistub.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,26 @@ union efi_dxe_services_table {
442442
} mixed_mode;
443443
};
444444

445+
typedef union efi_memory_attribute_protocol efi_memory_attribute_protocol_t;
446+
447+
union efi_memory_attribute_protocol {
448+
struct {
449+
efi_status_t (__efiapi *get_memory_attributes)(
450+
efi_memory_attribute_protocol_t *, efi_physical_addr_t, u64, u64 *);
451+
452+
efi_status_t (__efiapi *set_memory_attributes)(
453+
efi_memory_attribute_protocol_t *, efi_physical_addr_t, u64, u64);
454+
455+
efi_status_t (__efiapi *clear_memory_attributes)(
456+
efi_memory_attribute_protocol_t *, efi_physical_addr_t, u64, u64);
457+
};
458+
struct {
459+
u32 get_memory_attributes;
460+
u32 set_memory_attributes;
461+
u32 clear_memory_attributes;
462+
} mixed_mode;
463+
};
464+
445465
typedef union efi_uga_draw_protocol efi_uga_draw_protocol_t;
446466

447467
union efi_uga_draw_protocol {

include/linux/efi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ void efi_native_runtime_setup(void);
391391
#define EFI_RT_PROPERTIES_TABLE_GUID EFI_GUID(0xeb66918a, 0x7eef, 0x402a, 0x84, 0x2e, 0x93, 0x1d, 0x21, 0xc3, 0x8a, 0xe9)
392392
#define EFI_DXE_SERVICES_TABLE_GUID EFI_GUID(0x05ad34ba, 0x6f02, 0x4214, 0x95, 0x2e, 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9)
393393
#define EFI_SMBIOS_PROTOCOL_GUID EFI_GUID(0x03583ff6, 0xcb36, 0x4940, 0x94, 0x7e, 0xb9, 0xb3, 0x9f, 0x4a, 0xfa, 0xf7)
394+
#define EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID EFI_GUID(0xf4560cf6, 0x40ec, 0x4b4a, 0xa1, 0x92, 0xbf, 0x1d, 0x57, 0xd0, 0xb1, 0x89)
394395

395396
#define EFI_IMAGE_SECURITY_DATABASE_GUID EFI_GUID(0xd719b2cb, 0x3d3a, 0x4596, 0xa3, 0xbc, 0xda, 0xd0, 0x0e, 0x67, 0x65, 0x6f)
396397
#define EFI_SHIM_LOCK_GUID EFI_GUID(0x605dab50, 0xe046, 0x4300, 0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23)

0 commit comments

Comments
 (0)