Skip to content

Commit efe659a

Browse files
rpptIngo Molnar
authored andcommitted
x86/e820: Drop obsolete E820_TYPE_RESERVED_KERN and related code
E820_TYPE_RESERVED_KERN is a relict from the ancient history that was used to early reserve setup_data, see: 28bb223 ("x86: move reserve_setup_data to setup.c") Nowadays setup_data is anyway reserved in memblock and there is no point in carrying E820_TYPE_RESERVED_KERN that behaves exactly like E820_TYPE_RAM but only complicates the code. A bonus for removing E820_TYPE_RESERVED_KERN is a small but measurable speedup of 20 microseconds in init_mem_mappings() on a VM with 32GB or RAM. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Ard Biesheuvel <ardb@kernel.org> Cc: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20250214090651.3331663-5-rppt@kernel.org
1 parent d45dd0a commit efe659a

File tree

6 files changed

+4
-83
lines changed

6 files changed

+4
-83
lines changed

arch/x86/include/asm/e820/api.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ extern unsigned long e820__end_of_low_ram_pfn(void);
2929
extern u64 e820__memblock_alloc_reserved(u64 size, u64 align);
3030
extern void e820__memblock_setup(void);
3131

32-
extern void e820__reserve_setup_data(void);
3332
extern void e820__finish_early_params(void);
3433
extern void e820__reserve_resources(void);
3534
extern void e820__reserve_resources_late(void);

arch/x86/include/asm/e820/types.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,6 @@ enum e820_type {
3535
* marking it with the IORES_DESC_SOFT_RESERVED designation.
3636
*/
3737
E820_TYPE_SOFT_RESERVED = 0xefffffff,
38-
39-
/*
40-
* Reserved RAM used by the kernel itself if
41-
* CONFIG_INTEL_TXT=y is enabled, memory of this type
42-
* will be included in the S3 integrity calculation
43-
* and so should not include any memory that the BIOS
44-
* might alter over the S3 transition:
45-
*/
46-
E820_TYPE_RESERVED_KERN = 128,
4738
};
4839

4940
/*

arch/x86/kernel/e820.c

Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ void __init e820__range_add(u64 start, u64 size, enum e820_type type)
187187
static void __init e820_print_type(enum e820_type type)
188188
{
189189
switch (type) {
190-
case E820_TYPE_RAM: /* Fall through: */
191-
case E820_TYPE_RESERVED_KERN: pr_cont("usable"); break;
190+
case E820_TYPE_RAM: pr_cont("usable"); break;
192191
case E820_TYPE_RESERVED: pr_cont("reserved"); break;
193192
case E820_TYPE_SOFT_RESERVED: pr_cont("soft reserved"); break;
194193
case E820_TYPE_ACPI: pr_cont("ACPI data"); break;
@@ -764,7 +763,7 @@ void __init e820__register_nosave_regions(unsigned long limit_pfn)
764763

765764
pfn = PFN_DOWN(entry->addr + entry->size);
766765

767-
if (entry->type != E820_TYPE_RAM && entry->type != E820_TYPE_RESERVED_KERN)
766+
if (entry->type != E820_TYPE_RAM)
768767
register_nosave_region(PFN_UP(entry->addr), pfn);
769768

770769
if (pfn >= limit_pfn)
@@ -990,60 +989,6 @@ static int __init parse_memmap_opt(char *str)
990989
}
991990
early_param("memmap", parse_memmap_opt);
992991

993-
/*
994-
* Reserve all entries from the bootloader's extensible data nodes list,
995-
* because if present we are going to use it later on to fetch e820
996-
* entries from it:
997-
*/
998-
void __init e820__reserve_setup_data(void)
999-
{
1000-
struct setup_indirect *indirect;
1001-
struct setup_data *data;
1002-
u64 pa_data, pa_next;
1003-
u32 len;
1004-
1005-
pa_data = boot_params.hdr.setup_data;
1006-
if (!pa_data)
1007-
return;
1008-
1009-
while (pa_data) {
1010-
data = early_memremap(pa_data, sizeof(*data));
1011-
if (!data) {
1012-
pr_warn("e820: failed to memremap setup_data entry\n");
1013-
return;
1014-
}
1015-
1016-
len = sizeof(*data);
1017-
pa_next = data->next;
1018-
1019-
e820__range_update(pa_data, sizeof(*data)+data->len, E820_TYPE_RAM, E820_TYPE_RESERVED_KERN);
1020-
1021-
if (data->type == SETUP_INDIRECT) {
1022-
len += data->len;
1023-
early_memunmap(data, sizeof(*data));
1024-
data = early_memremap(pa_data, len);
1025-
if (!data) {
1026-
pr_warn("e820: failed to memremap indirect setup_data\n");
1027-
return;
1028-
}
1029-
1030-
indirect = (struct setup_indirect *)data->data;
1031-
1032-
if (indirect->type != SETUP_INDIRECT)
1033-
e820__range_update(indirect->addr, indirect->len,
1034-
E820_TYPE_RAM, E820_TYPE_RESERVED_KERN);
1035-
}
1036-
1037-
pa_data = pa_next;
1038-
early_memunmap(data, len);
1039-
}
1040-
1041-
e820__update_table(e820_table);
1042-
1043-
pr_info("extended physical RAM map:\n");
1044-
e820__print_table("reserve setup_data");
1045-
}
1046-
1047992
/*
1048993
* Called after parse_early_param(), after early parameters (such as mem=)
1049994
* have been processed, in which case we already have an E820 table filled in
@@ -1063,7 +1008,6 @@ void __init e820__finish_early_params(void)
10631008
static const char *__init e820_type_to_string(struct e820_entry *entry)
10641009
{
10651010
switch (entry->type) {
1066-
case E820_TYPE_RESERVED_KERN: /* Fall-through: */
10671011
case E820_TYPE_RAM: return "System RAM";
10681012
case E820_TYPE_ACPI: return "ACPI Tables";
10691013
case E820_TYPE_NVS: return "ACPI Non-volatile Storage";
@@ -1079,7 +1023,6 @@ static const char *__init e820_type_to_string(struct e820_entry *entry)
10791023
static unsigned long __init e820_type_to_iomem_type(struct e820_entry *entry)
10801024
{
10811025
switch (entry->type) {
1082-
case E820_TYPE_RESERVED_KERN: /* Fall-through: */
10831026
case E820_TYPE_RAM: return IORESOURCE_SYSTEM_RAM;
10841027
case E820_TYPE_ACPI: /* Fall-through: */
10851028
case E820_TYPE_NVS: /* Fall-through: */
@@ -1101,7 +1044,6 @@ static unsigned long __init e820_type_to_iores_desc(struct e820_entry *entry)
11011044
case E820_TYPE_PRAM: return IORES_DESC_PERSISTENT_MEMORY_LEGACY;
11021045
case E820_TYPE_RESERVED: return IORES_DESC_RESERVED;
11031046
case E820_TYPE_SOFT_RESERVED: return IORES_DESC_SOFT_RESERVED;
1104-
case E820_TYPE_RESERVED_KERN: /* Fall-through: */
11051047
case E820_TYPE_RAM: /* Fall-through: */
11061048
case E820_TYPE_UNUSABLE: /* Fall-through: */
11071049
default: return IORES_DESC_NONE;
@@ -1124,7 +1066,6 @@ static bool __init do_mark_busy(enum e820_type type, struct resource *res)
11241066
case E820_TYPE_PRAM:
11251067
case E820_TYPE_PMEM:
11261068
return false;
1127-
case E820_TYPE_RESERVED_KERN:
11281069
case E820_TYPE_RAM:
11291070
case E820_TYPE_ACPI:
11301071
case E820_TYPE_NVS:
@@ -1353,7 +1294,7 @@ void __init e820__memblock_setup(void)
13531294
if (entry->type == E820_TYPE_SOFT_RESERVED)
13541295
memblock_reserve(entry->addr, entry->size);
13551296

1356-
if (entry->type != E820_TYPE_RAM && entry->type != E820_TYPE_RESERVED_KERN)
1297+
if (entry->type != E820_TYPE_RAM)
13571298
continue;
13581299

13591300
memblock_add(entry->addr, entry->size);

arch/x86/kernel/setup.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,6 @@ void __init setup_arch(char **cmdline_p)
895895
setup_clear_cpu_cap(X86_FEATURE_APIC);
896896
}
897897

898-
e820__reserve_setup_data();
899898
e820__finish_early_params();
900899

901900
if (efi_enabled(EFI_BOOT))

arch/x86/kernel/tboot.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ static int tboot_setup_sleep(void)
200200
tboot->num_mac_regions = 0;
201201

202202
for (i = 0; i < e820_table->nr_entries; i++) {
203-
if ((e820_table->entries[i].type != E820_TYPE_RAM)
204-
&& (e820_table->entries[i].type != E820_TYPE_RESERVED_KERN))
203+
if (e820_table->entries[i].type != E820_TYPE_RAM)
205204
continue;
206205

207206
add_mac_region(e820_table->entries[i].addr, e820_table->entries[i].size);

arch/x86/mm/init_64.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,6 @@ phys_pte_init(pte_t *pte_page, unsigned long paddr, unsigned long paddr_end,
468468
if (!after_bootmem &&
469469
!e820__mapped_any(paddr & PAGE_MASK, paddr_next,
470470
E820_TYPE_RAM) &&
471-
!e820__mapped_any(paddr & PAGE_MASK, paddr_next,
472-
E820_TYPE_RESERVED_KERN) &&
473471
!e820__mapped_any(paddr & PAGE_MASK, paddr_next,
474472
E820_TYPE_ACPI))
475473
set_pte_init(pte, __pte(0), init);
@@ -525,8 +523,6 @@ phys_pmd_init(pmd_t *pmd_page, unsigned long paddr, unsigned long paddr_end,
525523
if (!after_bootmem &&
526524
!e820__mapped_any(paddr & PMD_MASK, paddr_next,
527525
E820_TYPE_RAM) &&
528-
!e820__mapped_any(paddr & PMD_MASK, paddr_next,
529-
E820_TYPE_RESERVED_KERN) &&
530526
!e820__mapped_any(paddr & PMD_MASK, paddr_next,
531527
E820_TYPE_ACPI))
532528
set_pmd_init(pmd, __pmd(0), init);
@@ -614,8 +610,6 @@ phys_pud_init(pud_t *pud_page, unsigned long paddr, unsigned long paddr_end,
614610
if (!after_bootmem &&
615611
!e820__mapped_any(paddr & PUD_MASK, paddr_next,
616612
E820_TYPE_RAM) &&
617-
!e820__mapped_any(paddr & PUD_MASK, paddr_next,
618-
E820_TYPE_RESERVED_KERN) &&
619613
!e820__mapped_any(paddr & PUD_MASK, paddr_next,
620614
E820_TYPE_ACPI))
621615
set_pud_init(pud, __pud(0), init);
@@ -703,8 +697,6 @@ phys_p4d_init(p4d_t *p4d_page, unsigned long paddr, unsigned long paddr_end,
703697
if (!after_bootmem &&
704698
!e820__mapped_any(paddr & P4D_MASK, paddr_next,
705699
E820_TYPE_RAM) &&
706-
!e820__mapped_any(paddr & P4D_MASK, paddr_next,
707-
E820_TYPE_RESERVED_KERN) &&
708700
!e820__mapped_any(paddr & P4D_MASK, paddr_next,
709701
E820_TYPE_ACPI))
710702
set_p4d_init(p4d, __p4d(0), init);

0 commit comments

Comments
 (0)