Skip to content

Commit c7ab7b2

Browse files
committed
Merge tag 'efi-fixes-for-v6.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi
Pull EFI fixes from Ard Biesheuvel: "Take the newly introduced EFI_MEMORY_HOT_PLUGGABLE memory attribute into account when placing the kernel image in memory at boot. Otherwise, the presence of the kernel image could prevent such a memory region from being unplugged at runtime if it was 'cold plugged', i.e., already plugged in at boot time (and exposed via the EFI memory map). This should ensure that the new EFI_MEMORY_HOT_PLUGGABLE memory attribute is used consistently by Linux before it ever turns up in production, ensuring that we can make meaningful use of it without running the risk of regressing existing users" * tag 'efi-fixes-for-v6.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi: efi: Use BIT_ULL() constants for memory attributes efi: Avoid cold plugged memory for placing the kernel
2 parents 1b8c8cd + bbc4578 commit c7ab7b2

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

drivers/firmware/efi/efi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,13 +934,15 @@ char * __init efi_md_typeattr_format(char *buf, size_t size,
934934
EFI_MEMORY_WB | EFI_MEMORY_UCE | EFI_MEMORY_RO |
935935
EFI_MEMORY_WP | EFI_MEMORY_RP | EFI_MEMORY_XP |
936936
EFI_MEMORY_NV | EFI_MEMORY_SP | EFI_MEMORY_CPU_CRYPTO |
937-
EFI_MEMORY_RUNTIME | EFI_MEMORY_MORE_RELIABLE))
937+
EFI_MEMORY_MORE_RELIABLE | EFI_MEMORY_HOT_PLUGGABLE |
938+
EFI_MEMORY_RUNTIME))
938939
snprintf(pos, size, "|attr=0x%016llx]",
939940
(unsigned long long)attr);
940941
else
941942
snprintf(pos, size,
942-
"|%3s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%3s|%2s|%2s|%2s|%2s]",
943+
"|%3s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%3s|%2s|%2s|%2s|%2s]",
943944
attr & EFI_MEMORY_RUNTIME ? "RUN" : "",
945+
attr & EFI_MEMORY_HOT_PLUGGABLE ? "HP" : "",
944946
attr & EFI_MEMORY_MORE_RELIABLE ? "MR" : "",
945947
attr & EFI_MEMORY_CPU_CRYPTO ? "CC" : "",
946948
attr & EFI_MEMORY_SP ? "SP" : "",

drivers/firmware/efi/libstub/randomalloc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ static unsigned long get_entry_num_slots(efi_memory_desc_t *md,
2525
if (md->type != EFI_CONVENTIONAL_MEMORY)
2626
return 0;
2727

28+
if (md->attribute & EFI_MEMORY_HOT_PLUGGABLE)
29+
return 0;
30+
2831
if (efi_soft_reserve_enabled() &&
2932
(md->attribute & EFI_MEMORY_SP))
3033
return 0;

drivers/firmware/efi/libstub/relocate.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align,
5353
if (desc->type != EFI_CONVENTIONAL_MEMORY)
5454
continue;
5555

56+
if (desc->attribute & EFI_MEMORY_HOT_PLUGGABLE)
57+
continue;
58+
5659
if (efi_soft_reserve_enabled() &&
5760
(desc->attribute & EFI_MEMORY_SP))
5861
continue;

include/linux/efi.h

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,22 @@ typedef struct {
114114
#define EFI_MAX_MEMORY_TYPE 16
115115

116116
/* Attribute values: */
117-
#define EFI_MEMORY_UC ((u64)0x0000000000000001ULL) /* uncached */
118-
#define EFI_MEMORY_WC ((u64)0x0000000000000002ULL) /* write-coalescing */
119-
#define EFI_MEMORY_WT ((u64)0x0000000000000004ULL) /* write-through */
120-
#define EFI_MEMORY_WB ((u64)0x0000000000000008ULL) /* write-back */
121-
#define EFI_MEMORY_UCE ((u64)0x0000000000000010ULL) /* uncached, exported */
122-
#define EFI_MEMORY_WP ((u64)0x0000000000001000ULL) /* write-protect */
123-
#define EFI_MEMORY_RP ((u64)0x0000000000002000ULL) /* read-protect */
124-
#define EFI_MEMORY_XP ((u64)0x0000000000004000ULL) /* execute-protect */
125-
#define EFI_MEMORY_NV ((u64)0x0000000000008000ULL) /* non-volatile */
126-
#define EFI_MEMORY_MORE_RELIABLE \
127-
((u64)0x0000000000010000ULL) /* higher reliability */
128-
#define EFI_MEMORY_RO ((u64)0x0000000000020000ULL) /* read-only */
129-
#define EFI_MEMORY_SP ((u64)0x0000000000040000ULL) /* soft reserved */
130-
#define EFI_MEMORY_CPU_CRYPTO ((u64)0x0000000000080000ULL) /* supports encryption */
131-
#define EFI_MEMORY_RUNTIME ((u64)0x8000000000000000ULL) /* range requires runtime mapping */
117+
#define EFI_MEMORY_UC BIT_ULL(0) /* uncached */
118+
#define EFI_MEMORY_WC BIT_ULL(1) /* write-coalescing */
119+
#define EFI_MEMORY_WT BIT_ULL(2) /* write-through */
120+
#define EFI_MEMORY_WB BIT_ULL(3) /* write-back */
121+
#define EFI_MEMORY_UCE BIT_ULL(4) /* uncached, exported */
122+
#define EFI_MEMORY_WP BIT_ULL(12) /* write-protect */
123+
#define EFI_MEMORY_RP BIT_ULL(13) /* read-protect */
124+
#define EFI_MEMORY_XP BIT_ULL(14) /* execute-protect */
125+
#define EFI_MEMORY_NV BIT_ULL(15) /* non-volatile */
126+
#define EFI_MEMORY_MORE_RELIABLE BIT_ULL(16) /* higher reliability */
127+
#define EFI_MEMORY_RO BIT_ULL(17) /* read-only */
128+
#define EFI_MEMORY_SP BIT_ULL(18) /* soft reserved */
129+
#define EFI_MEMORY_CPU_CRYPTO BIT_ULL(19) /* supports encryption */
130+
#define EFI_MEMORY_HOT_PLUGGABLE BIT_ULL(20) /* supports unplugging at runtime */
131+
#define EFI_MEMORY_RUNTIME BIT_ULL(63) /* range requires runtime mapping */
132+
132133
#define EFI_MEMORY_DESCRIPTOR_VERSION 1
133134

134135
#define EFI_PAGE_SHIFT 12

0 commit comments

Comments
 (0)