From bf7d3bd38f3e8dd3d27ee5184d279e7199ca9777 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 6 Jun 2022 14:19:03 -0700 Subject: [PATCH] examples/baremetal: make paddr == vaddr Fix loading of the example baremetal kernel with the fixed ELF kernel loader: - Remove the "RAM" address space so virtual and physical address match. - Remove the 0x200-byte padding now that entry point address is used. BUG=b:234155022 TEST=Run baremetal as in tools/examples/baremetal/README.md Change-Id: I61394cdf4bf71f91736da5a636b0088ecfe78c84 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3691965 Commit-Queue: Daniel Verkamp Reviewed-by: Anton Romanov Reviewed-by: Alexandre Courbot Tested-by: kokoro --- tools/examples/baremetal/layout.ld | 5 ++--- tools/examples/baremetal/src/boot.asm | 9 +++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/examples/baremetal/layout.ld b/tools/examples/baremetal/layout.ld index d9529c0e9b..7d8060d3c0 100644 --- a/tools/examples/baremetal/layout.ld +++ b/tools/examples/baremetal/layout.ld @@ -3,7 +3,6 @@ ENTRY(_start) /* Crosvm will load our code into 0x200000 + paddr */ MEMORY { VMA : ORIGIN = 0x00200000, LENGTH = 0x200000 - RAM : ORIGIN = 0x00000000, LENGTH = 0x200000 } SECTIONS { @@ -13,7 +12,7 @@ SECTIONS { { _stack_end = . ; *(.boot) - }> VMA AT>RAM + }> VMA .kernel : { @@ -22,7 +21,7 @@ SECTIONS { *(.rodata .rodata.*) *(.data .data.*) *(.bss .bss.*) - }> VMA AT>RAM + }> VMA DISCARD/ : { diff --git a/tools/examples/baremetal/src/boot.asm b/tools/examples/baremetal/src/boot.asm index d3e25922d1..861192c03a 100644 --- a/tools/examples/baremetal/src/boot.asm +++ b/tools/examples/baremetal/src/boot.asm @@ -1,12 +1,13 @@ +/* Copyright 2022 The ChromiumOS Authors. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + .section .boot, "awx" .global _start .code64 -# crosvm starts execution at 0x200 offset from the beginning -.fill 0x200 _start: lea rsp, _stack_end jmp main - -