Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 37aee82

Browse files
committed
x86/efi: Drop support for fake EFI memory maps
Between kexec and confidential VM support, handling the EFI memory maps correctly on x86 is already proving to be rather difficult (as opposed to other EFI architectures which manage to never modify the EFI memory map to begin with) EFI fake memory map support is essentially a development hack (for testing new support for the 'special purpose' and 'more reliable' EFI memory attributes) that leaked into production code. The regions marked in this manner are not actually recognized as such by the firmware itself or the EFI stub (and never have), and marking memory as 'more reliable' seems rather futile if the underlying memory is just ordinary RAM. Marking memory as 'special purpose' in this way is also dubious, but may be in use in production code nonetheless. However, the same should be achievable by using the memmap= command line option with the ! operator. EFI fake memmap support is not enabled by any of the major distros (Debian, Fedora, SUSE, Ubuntu) and does not exist on other architectures, so let's drop support for it. Acked-by: Borislav Petkov (AMD) <bp@alien8.de> Acked-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent f266106 commit 37aee82

File tree

10 files changed

+11
-292
lines changed

10 files changed

+11
-292
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,27 +1450,6 @@
14501450
you are really sure that your UEFI does sane gc and
14511451
fulfills the spec otherwise your board may brick.
14521452

1453-
efi_fake_mem= nn[KMG]@ss[KMG]:aa[,nn[KMG]@ss[KMG]:aa,..] [EFI,X86,EARLY]
1454-
Add arbitrary attribute to specific memory range by
1455-
updating original EFI memory map.
1456-
Region of memory which aa attribute is added to is
1457-
from ss to ss+nn.
1458-
1459-
If efi_fake_mem=2G@4G:0x10000,2G@0x10a0000000:0x10000
1460-
is specified, EFI_MEMORY_MORE_RELIABLE(0x10000)
1461-
attribute is added to range 0x100000000-0x180000000 and
1462-
0x10a0000000-0x1120000000.
1463-
1464-
If efi_fake_mem=8G@9G:0x40000 is specified, the
1465-
EFI_MEMORY_SP(0x40000) attribute is added to
1466-
range 0x240000000-0x43fffffff.
1467-
1468-
Using this parameter you can do debugging of EFI memmap
1469-
related features. For example, you can do debugging of
1470-
Address Range Mirroring feature even if your box
1471-
doesn't support it, or mark specific memory as
1472-
"soft reserved".
1473-
14741453
efivar_ssdt= [EFI; X86] Name of an EFI variable that contains an SSDT
14751454
that is to be dynamically loaded by Linux. If there are
14761455
multiple variables with the same name but with different

arch/x86/Kconfig

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2038,26 +2038,6 @@ config EFI_MIXED
20382038

20392039
If unsure, say N.
20402040

2041-
config EFI_FAKE_MEMMAP
2042-
bool "Enable EFI fake memory map"
2043-
depends on EFI
2044-
help
2045-
Saying Y here will enable "efi_fake_mem" boot option. By specifying
2046-
this parameter, you can add arbitrary attribute to specific memory
2047-
range by updating original (firmware provided) EFI memmap. This is
2048-
useful for debugging of EFI memmap related feature, e.g., Address
2049-
Range Mirroring feature.
2050-
2051-
config EFI_MAX_FAKE_MEM
2052-
int "maximum allowable number of ranges in efi_fake_mem boot option"
2053-
depends on EFI_FAKE_MEMMAP
2054-
range 1 128
2055-
default 8
2056-
help
2057-
Maximum allowable number of ranges in efi_fake_mem boot option.
2058-
Ranges can be set up to this value using comma-separated list.
2059-
The default value is 8.
2060-
20612041
config EFI_RUNTIME_MAP
20622042
bool "Export EFI runtime maps to sysfs" if EXPERT
20632043
depends on EFI

arch/x86/boot/compressed/kaslr.c

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,8 @@ char *skip_spaces(const char *str)
119119
#include "../../../../lib/ctype.c"
120120
#include "../../../../lib/cmdline.c"
121121

122-
enum parse_mode {
123-
PARSE_MEMMAP,
124-
PARSE_EFI,
125-
};
126-
127122
static int
128-
parse_memmap(char *p, u64 *start, u64 *size, enum parse_mode mode)
123+
parse_memmap(char *p, u64 *start, u64 *size)
129124
{
130125
char *oldp;
131126

@@ -148,29 +143,11 @@ parse_memmap(char *p, u64 *start, u64 *size, enum parse_mode mode)
148143
*start = memparse(p + 1, &p);
149144
return 0;
150145
case '@':
151-
if (mode == PARSE_MEMMAP) {
152-
/*
153-
* memmap=nn@ss specifies usable region, should
154-
* be skipped
155-
*/
156-
*size = 0;
157-
} else {
158-
u64 flags;
159-
160-
/*
161-
* efi_fake_mem=nn@ss:attr the attr specifies
162-
* flags that might imply a soft-reservation.
163-
*/
164-
*start = memparse(p + 1, &p);
165-
if (p && *p == ':') {
166-
p++;
167-
if (kstrtoull(p, 0, &flags) < 0)
168-
*size = 0;
169-
else if (flags & EFI_MEMORY_SP)
170-
return 0;
171-
}
172-
*size = 0;
173-
}
146+
/*
147+
* memmap=nn@ss specifies usable region, should
148+
* be skipped
149+
*/
150+
*size = 0;
174151
fallthrough;
175152
default:
176153
/*
@@ -185,7 +162,7 @@ parse_memmap(char *p, u64 *start, u64 *size, enum parse_mode mode)
185162
return -EINVAL;
186163
}
187164

188-
static void mem_avoid_memmap(enum parse_mode mode, char *str)
165+
static void mem_avoid_memmap(char *str)
189166
{
190167
static int i;
191168

@@ -200,7 +177,7 @@ static void mem_avoid_memmap(enum parse_mode mode, char *str)
200177
if (k)
201178
*k++ = 0;
202179

203-
rc = parse_memmap(str, &start, &size, mode);
180+
rc = parse_memmap(str, &start, &size);
204181
if (rc < 0)
205182
break;
206183
str = k;
@@ -281,7 +258,7 @@ static void handle_mem_options(void)
281258
break;
282259

283260
if (!strcmp(param, "memmap")) {
284-
mem_avoid_memmap(PARSE_MEMMAP, val);
261+
mem_avoid_memmap(val);
285262
} else if (IS_ENABLED(CONFIG_X86_64) && strstr(param, "hugepages")) {
286263
parse_gb_huge_pages(param, val);
287264
} else if (!strcmp(param, "mem")) {
@@ -295,8 +272,6 @@ static void handle_mem_options(void)
295272

296273
if (mem_size < mem_limit)
297274
mem_limit = mem_size;
298-
} else if (!strcmp(param, "efi_fake_mem")) {
299-
mem_avoid_memmap(PARSE_EFI, val);
300275
}
301276
}
302277

arch/x86/include/asm/efi.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -384,23 +384,8 @@ static inline void efi_reserve_boot_services(void)
384384
}
385385
#endif /* CONFIG_EFI */
386386

387-
#ifdef CONFIG_EFI_FAKE_MEMMAP
388-
extern void __init efi_fake_memmap_early(void);
389-
extern void __init efi_fake_memmap(void);
390-
#else
391-
static inline void efi_fake_memmap_early(void)
392-
{
393-
}
394-
395-
static inline void efi_fake_memmap(void)
396-
{
397-
}
398-
#endif
399-
400387
extern int __init efi_memmap_alloc(unsigned int num_entries,
401388
struct efi_memory_map_data *data);
402-
extern void __efi_memmap_free(u64 phys, unsigned long size,
403-
unsigned long flags);
404389

405390
extern int __init efi_memmap_install(struct efi_memory_map_data *data);
406391
extern int __init efi_memmap_split_count(efi_memory_desc_t *md,

arch/x86/kernel/setup.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,6 @@ void __init setup_arch(char **cmdline_p)
995995
mem_encrypt_setup_arch();
996996
cc_random_init();
997997

998-
efi_fake_memmap();
999998
efi_find_mirror();
1000999
efi_esrt_init();
10011000
efi_mokvar_table_init();

arch/x86/platform/efi/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ GCOV_PROFILE := n
55
obj-$(CONFIG_EFI) += memmap.o quirks.o efi.o efi_$(BITS).o \
66
efi_stub_$(BITS).o
77
obj-$(CONFIG_EFI_MIXED) += efi_thunk_$(BITS).o
8-
obj-$(CONFIG_EFI_FAKE_MEMMAP) += fake_mem.o
98
obj-$(CONFIG_EFI_RUNTIME_MAP) += runtime-map.o

arch/x86/platform/efi/efi.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,6 @@ int __init efi_memblock_x86_reserve_range(void)
226226
if (add_efi_memmap || do_efi_soft_reserve())
227227
do_add_efi_memmap();
228228

229-
efi_fake_memmap_early();
230-
231229
WARN(efi.memmap.desc_version != 1,
232230
"Unexpected EFI_MEMORY_DESCRIPTOR version %ld",
233231
efi.memmap.desc_version);

arch/x86/platform/efi/fake_mem.c

Lines changed: 0 additions & 197 deletions
This file was deleted.

arch/x86/platform/efi/memmap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ static phys_addr_t __init __efi_memmap_alloc_late(unsigned long size)
3030
return PFN_PHYS(page_to_pfn(p));
3131
}
3232

33+
static
3334
void __init __efi_memmap_free(u64 phys, unsigned long size, unsigned long flags)
3435
{
3536
if (flags & EFI_MEMMAP_MEMBLOCK) {

0 commit comments

Comments
 (0)