Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

efi: Enumerate EFI_MEMORY_SP

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 intent of this bit is to allow the OS to identify precious
or scarce memory resources and optionally manage it separately from
EfiConventionalMemory. As defined older OSes that do not know about this
attribute are permitted to ignore it and the memory will be handled
according to the OS default policy for the given memory type.

In other words, this "specific purpose" hint is deliberately weaker than
EfiReservedMemoryType in that the system continues to operate if the OS
takes no action on the attribute. The risk of taking no action is
potentially unwanted / unmovable kernel allocations from the designated
resource that prevent the full realization of the "specific purpose".
For example, consider a system with a high-bandwidth memory pool. Older
kernels are permitted to boot and consume that memory as conventional
"System-RAM" newer kernels may arrange for that memory to be set aside
(soft reserved) by the system administrator for a dedicated
high-bandwidth memory aware application to consume.

Specifically, this mechanism allows for the elimination of scenarios
where platform firmware tries to game OS policy by lying about ACPI SLIT
values, i.e. claiming that a precious memory resource has a high
distance to trigger the OS to avoid it by default. This reservation hint
allows platform-firmware to instead tell the truth about performance
characteristics by indicate to OS memory management to put immovable
allocations elsewhere.

Implement simple detection of the bit for EFI memory table dumps and
save the kernel policy for a follow-on change.

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Dan Williams and committed by
Rafael J. Wysocki
fe3e5e65 c710fcc5

+4 -2
+3 -2
drivers/firmware/efi/efi.c
··· 842 842 if (attr & ~(EFI_MEMORY_UC | EFI_MEMORY_WC | EFI_MEMORY_WT | 843 843 EFI_MEMORY_WB | EFI_MEMORY_UCE | EFI_MEMORY_RO | 844 844 EFI_MEMORY_WP | EFI_MEMORY_RP | EFI_MEMORY_XP | 845 - EFI_MEMORY_NV | 845 + EFI_MEMORY_NV | EFI_MEMORY_SP | 846 846 EFI_MEMORY_RUNTIME | EFI_MEMORY_MORE_RELIABLE)) 847 847 snprintf(pos, size, "|attr=0x%016llx]", 848 848 (unsigned long long)attr); 849 849 else 850 850 snprintf(pos, size, 851 - "|%3s|%2s|%2s|%2s|%2s|%2s|%2s|%3s|%2s|%2s|%2s|%2s]", 851 + "|%3s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%3s|%2s|%2s|%2s|%2s]", 852 852 attr & EFI_MEMORY_RUNTIME ? "RUN" : "", 853 853 attr & EFI_MEMORY_MORE_RELIABLE ? "MR" : "", 854 + attr & EFI_MEMORY_SP ? "SP" : "", 854 855 attr & EFI_MEMORY_NV ? "NV" : "", 855 856 attr & EFI_MEMORY_XP ? "XP" : "", 856 857 attr & EFI_MEMORY_RP ? "RP" : "",
+1
include/linux/efi.h
··· 112 112 #define EFI_MEMORY_MORE_RELIABLE \ 113 113 ((u64)0x0000000000010000ULL) /* higher reliability */ 114 114 #define EFI_MEMORY_RO ((u64)0x0000000000020000ULL) /* read-only */ 115 + #define EFI_MEMORY_SP ((u64)0x0000000000040000ULL) /* soft reserved */ 115 116 #define EFI_MEMORY_RUNTIME ((u64)0x8000000000000000ULL) /* range requires runtime mapping */ 116 117 #define EFI_MEMORY_DESCRIPTOR_VERSION 1 117 118