diff options
author | Daniel Verkamp <dverkamp@chromium.org> | 2024-05-06 15:35:05 -0700 |
---|---|---|
committer | crosvm LUCI <crosvm-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-05-07 00:19:47 +0000 |
commit | 123b6f8b8211dfb2d84f559e5fb3c097f915633b (patch) | |
tree | 706635c4fdb7eee9a42c33c79f37029a6519f64c | |
parent | de988e9eb799a5c31ab72cb900f2731e3cb57afd (diff) | |
download | crosvm-123b6f8b8211dfb2d84f559e5fb3c097f915633b.tar.gz |
x86_64: simplify e820 memory map
crosvm originally omitted the region between (just below) 640 KB and up
to the kernel load address (2 MB) from the e820 memory map provided to
the kernel. This region is traditionally used for video memory, BIOS,
and option ROMs in the PC architecture, but crosvm doesn't emulate any
of the legacy hardware that would use this region; all of the low memory
is actually just RAM.
The memory map we report is only used for the direct kernel boot case,
so it does not affect the memory layout reported when booting with a
BIOS/UEFI firmware.
Before:
[ 0.000000] BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[ 0.000000] BIOS-e820: [mem 0x0000000000200000-0x00000000cfffffff] usable
[ 0.000000] BIOS-e820: [mem 0x00000000f4000000-0x00000000f7ffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x0000000100000000-0x00000001687fffff] usable
[ 0.000000] BIOS-e820: [mem 0x0000000168800000-0x00000001707fffff] reserved
After:
[ 0.000000] BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x00000000cfffffff] usable
[ 0.000000] BIOS-e820: [mem 0x00000000f4000000-0x00000000f7ffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x0000000100000000-0x00000001687fffff] usable
[ 0.000000] BIOS-e820: [mem 0x0000000168800000-0x00000001707fffff] reserved
BUG=None
TEST=Boot x86-64 Linux kernel and OVMF
Change-Id: I11fc377e466bc3aacadc21be0aad8db06712c248
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5518127
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
-rw-r--r-- | x86_64/src/lib.rs | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/x86_64/src/lib.rs b/x86_64/src/lib.rs index 007a9f4d0..58d2e58d3 100644 --- a/x86_64/src/lib.rs +++ b/x86_64/src/lib.rs @@ -458,14 +458,12 @@ fn tss_addr_end() -> GuestAddress { fn configure_system( guest_mem: &GuestMemory, - kernel_addr: GuestAddress, cmdline_addr: GuestAddress, cmdline_size: usize, setup_data: Option<GuestAddress>, initrd: Option<(GuestAddress, usize)>, mut params: boot_params, ) -> Result<()> { - const EBDA_START: u64 = 0x0009_fc00; const KERNEL_BOOT_FLAG_MAGIC: u16 = 0xaa55; const KERNEL_HDR_MAGIC: u32 = 0x5372_6448; const KERNEL_LOADER_OTHER: u8 = 0xff; @@ -486,20 +484,11 @@ fn configure_system( params.hdr.ramdisk_size = initrd_size as u32; } - add_e820_entry( - &mut params, - AddressRange { - start: START_OF_RAM_32BITS, - end: EBDA_START - 1, - }, - E820Type::Ram, - )?; - // GuestMemory::end_addr() returns the first address past the end, so subtract 1 to get the // inclusive end. let guest_mem_end = guest_mem.end_addr().offset() - 1; let ram_below_4g = AddressRange { - start: kernel_addr.offset(), + start: START_OF_RAM_32BITS, end: guest_mem_end.min(read_pci_mmio_before_32bit().start - 1), }; let ram_above_4g = AddressRange { @@ -1713,7 +1702,6 @@ impl X8664arch { configure_system( mem, - GuestAddress(KERNEL_START_OFFSET), GuestAddress(CMDLINE_OFFSET), cmdline.to_bytes().len() + 1, setup_data, |