History

efi: Common enable/disable infrastructure for EFI soft reservation

UEFI 2.8 defines an EFI_MEMORY_SP attribute bit to augment the interpretation of the EFI Memory Types as "reserved for a specific purpose". The proposed Linux behavior for specific purpose memory is that it is reserved for direct-access (device-dax) by default and not available for any kernel usage, not even as an OOM fallback. Later, through udev scripts or another init mechanism, these device-dax claimed ranges can be reconfigured and hot-added to the available System-RAM with a unique node identifier. This device-dax management scheme implements "soft" in the "soft reserved" designation by allowing some or all of the reservation to be recovered as typical memory. This policy can be disabled at compile-time with CONFIG_EFI_SOFT_RESERVE=n, or runtime with efi=nosoftreserve. As for this patch, define the common helpers to determine if the EFI_MEMORY_SP attribute should be honored. The determination needs to be made early to prevent the kernel from being loaded into soft-reserved memory, or otherwise allowing early allocations to land there. Follow-on changes are needed per architecture to leverage these helpers in their respective mem-init paths.

Dan Williams committed 7 years ago

Commit b617c521 parent 6950e315 files · +70 −1Browse files

Showing the changes to include/linux (1 of 5 files). Show all

Unified · Split

include/linux/efi.h+14−0
@@ -1202,6 +1202,7 @@ extern int __init efi_setup_pcdp_console(char *); · 1201 unmodified lines
1202#define EFI_DBG 8 /* Print additional debug info at runtime */1202#define EFI_DBG 8 /* Print additional debug info at runtime */
1203#define EFI_NX_PE_DATA 9 /* Can runtime data regions be mapped non-executable? */1203#define EFI_NX_PE_DATA 9 /* Can runtime data regions be mapped non-executable? */
1204#define EFI_MEM_ATTR 10 /* Did firmware publish an EFI_MEMORY_ATTRIBUTES table? */1204#define EFI_MEM_ATTR 10 /* Did firmware publish an EFI_MEMORY_ATTRIBUTES table? */
1205#define EFI_MEM_NO_SOFT_RESERVE 11 /* Is the kernel configured to ignore soft reservations? */
1205 1206
1206#ifdef CONFIG_EFI1207#ifdef CONFIG_EFI
1207/*1208/*
@@ -1212,6 +1213,14 @@ static inline bool efi_enabled(int feature) · 4 unmodified lines
1212 return test_bit(feature, &efi.flags) != 0;1213 return test_bit(feature, &efi.flags) != 0;
1213}1214}
1214extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused);1215extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused);
1216
1217bool __pure __efi_soft_reserve_enabled(void);
1218
1219static inline bool __pure efi_soft_reserve_enabled(void)
1220{
1221 return IS_ENABLED(CONFIG_EFI_SOFT_RESERVE)
1222 && __efi_soft_reserve_enabled();
1223}
1215#else1224#else
1216static inline bool efi_enabled(int feature)1225static inline bool efi_enabled(int feature)
1217{1226{
@@ -1225,6 +1234,11 @@ efi_capsule_pending(int *reset_type) · 7 unmodified lines
1225{1234{
1226 return false;1235 return false;
1227}1236}
1237
1238static inline bool efi_soft_reserve_enabled(void)
1239{
1240 return false;
1241}
1228#endif1242#endif
1229 1243
1230extern int efi_status_to_err(efi_status_t status);1244extern int efi_status_to_err(efi_status_t status);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t