Skip to content

Commit a2498e5

Browse files
daveyoungIngo Molnar
authored andcommitted
x86/kexec: Export e820_table_kexec[] to sysfs
Previously the e820_table_kexec[] was exported to sysfs since kexec-tools uses the memmap entries to prepare the e820 table for the new kernel. The following commit, ~8 years ago, introduced e820_table_firmware[] and changed the behavior to export the firmware table instead: 12df216 ("x86/boot/e820: Introduce the bootloader provided e820_table_firmware[] table") Originally the kexec_file_load and kexec_load syscalls both used e820_table_kexec[]. Since the sysfs exported entries are from e820_table_firmware[] people now need to tune both tables for kexec. Restore the old behavior so the kexec_load and kexec_file_load syscalls work with only one table update. The e820_table_firmware[] is used by hibernation kernel code and it works without the sysfs exporting. Also remove the SEV e820_table_firmware[] updating code. Also update the code comments here and drop the comments about setup_data reservation since it is not needed any more after this change was made a year ago: fc7f27c ("x86/kexec: Do not update E820 kexec table for setup_data") [ mingo: Tidy up the changelog and comments. ] Signed-off-by: Dave Young <dyoung@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Ashish Kalra <ashish.kalra@amd.com> Cc: Sean Christopherson <seanjc@google.com> Cc: Joerg Roedel <jroedel@suse.de> Cc: Baoquan He <bhe@redhat.com> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: Eric Biederman <ebiederm@xmission.com> Link: https://lore.kernel.org/r/Z5jcb1GKhLvH8kDc@darkstar.users.ipa.redhat.com
1 parent 5bebe2e commit a2498e5

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

arch/x86/kernel/e820.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,25 @@
2828
* the first 128 E820 memory entries in boot_params.e820_table and the remaining
2929
* (if any) entries of the SETUP_E820_EXT nodes. We use this to:
3030
*
31-
* - inform the user about the firmware's notion of memory layout
32-
* via /sys/firmware/memmap
33-
*
3431
* - the hibernation code uses it to generate a kernel-independent CRC32
3532
* checksum of the physical memory layout of a system.
3633
*
3734
* - 'e820_table_kexec': a slightly modified (by the kernel) firmware version
3835
* passed to us by the bootloader - the major difference between
39-
* e820_table_firmware[] and this one is that, the latter marks the setup_data
40-
* list created by the EFI boot stub as reserved, so that kexec can reuse the
41-
* setup_data information in the second kernel. Besides, e820_table_kexec[]
42-
* might also be modified by the kexec itself to fake a mptable.
36+
* e820_table_firmware[] and this one is that e820_table_kexec[]
37+
* might be modified by the kexec itself to fake an mptable.
4338
* We use this to:
4439
*
4540
* - kexec, which is a bootloader in disguise, uses the original E820
4641
* layout to pass to the kexec-ed kernel. This way the original kernel
4742
* can have a restricted E820 map while the kexec()-ed kexec-kernel
4843
* can have access to full memory - etc.
4944
*
45+
* Export the memory layout via /sys/firmware/memmap. kexec-tools uses
46+
* the entries to create an E820 table for the kexec kernel.
47+
*
48+
* kexec_file_load in-kernel code uses the table for the kexec kernel.
49+
*
5050
* - 'e820_table': this is the main E820 table that is massaged by the
5151
* low level x86 platform code, or modified by boot parameters, before
5252
* passed on to higher level MM layers.
@@ -1117,9 +1117,9 @@ void __init e820__reserve_resources(void)
11171117
res++;
11181118
}
11191119

1120-
/* Expose the bootloader-provided memory layout to the sysfs. */
1121-
for (i = 0; i < e820_table_firmware->nr_entries; i++) {
1122-
struct e820_entry *entry = e820_table_firmware->entries + i;
1120+
/* Expose the kexec e820 table to the sysfs. */
1121+
for (i = 0; i < e820_table_kexec->nr_entries; i++) {
1122+
struct e820_entry *entry = e820_table_kexec->entries + i;
11231123

11241124
firmware_map_add_early(entry->addr, entry->addr + entry->size, e820_type_to_string(entry));
11251125
}

arch/x86/virt/svm/sev.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ static void __init __snp_fixup_e820_tables(u64 pa)
198198
pr_info("Reserving start/end of RMP table on a 2MB boundary [0x%016llx]\n", pa);
199199
e820__range_update(pa, PMD_SIZE, E820_TYPE_RAM, E820_TYPE_RESERVED);
200200
e820__range_update_table(e820_table_kexec, pa, PMD_SIZE, E820_TYPE_RAM, E820_TYPE_RESERVED);
201-
e820__range_update_table(e820_table_firmware, pa, PMD_SIZE, E820_TYPE_RAM, E820_TYPE_RESERVED);
202201
if (!memblock_is_region_reserved(pa, PMD_SIZE))
203202
memblock_reserve(pa, PMD_SIZE);
204203
}

0 commit comments

Comments
 (0)