From: Andrew Jones <andrew.jones@linux.dev>
To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org
Cc: pbonzini@redhat.com, thuth@redhat.com
Subject: [kvm-unit-tests PATCH v2 02/13] riscv: show_regs: Prepare for EFI images
Date: Tue, 5 Mar 2024 18:09:01 +0100 [thread overview]
Message-ID: <20240305170858.395836-17-andrew.jones@linux.dev> (raw)
In-Reply-To: <20240305170858.395836-15-andrew.jones@linux.dev>
EFI images start with a header page and then _text, so the load
address should use 'ImageBase' instead of _text. Just add the
ImageBase symbol to the non-efi build too and then change show_regs()
to use it instead. While there, add a couple convenience calculations
for the PC and return address (pre-subtract the load address from
them) in order to make it quicker for looking them up in an objdump.
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
---
lib/riscv/processor.c | 8 ++++----
riscv/flat.lds | 1 +
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/riscv/processor.c b/lib/riscv/processor.c
index 6c868b805cf7..ece7cbffc6dd 100644
--- a/lib/riscv/processor.c
+++ b/lib/riscv/processor.c
@@ -8,20 +8,20 @@
#include <asm/processor.h>
#include <asm/setup.h>
-extern unsigned long _text;
+extern unsigned long ImageBase;
void show_regs(struct pt_regs *regs)
{
struct thread_info *info = current_thread_info();
- uintptr_t text = (uintptr_t)&_text;
+ uintptr_t loadaddr = (uintptr_t)&ImageBase;
unsigned int w = __riscv_xlen / 4;
- printf("Load address: %" PRIxPTR "\n", text);
+ printf("Load address: %" PRIxPTR "\n", loadaddr);
printf("CPU%3d : hartid=%lx\n", info->cpu, info->hartid);
printf("status : %.*lx\n", w, regs->status);
printf("cause : %.*lx\n", w, regs->cause);
printf("badaddr: %.*lx\n", w, regs->badaddr);
- printf("pc: %.*lx ra: %.*lx\n", w, regs->epc, w, regs->ra);
+ printf("pc: %.*lx (%lx) ra: %.*lx (%lx)\n", w, regs->epc, regs->epc - loadaddr, w, regs->ra, regs->ra - loadaddr);
printf("sp: %.*lx gp: %.*lx tp : %.*lx\n", w, regs->sp, w, regs->gp, w, regs->tp);
printf("a0: %.*lx a1: %.*lx a2 : %.*lx a3 : %.*lx\n", w, regs->a0, w, regs->a1, w, regs->a2, w, regs->a3);
printf("a4: %.*lx a5: %.*lx a6 : %.*lx a7 : %.*lx\n", w, regs->a4, w, regs->a5, w, regs->a6, w, regs->a7);
diff --git a/riscv/flat.lds b/riscv/flat.lds
index d4853f82ba1c..1ca501e6593b 100644
--- a/riscv/flat.lds
+++ b/riscv/flat.lds
@@ -30,6 +30,7 @@ PHDRS
SECTIONS
{
+ PROVIDE(ImageBase = .);
PROVIDE(_text = .);
.text : { *(.init) *(.text) *(.text.*) } :text
. = ALIGN(4K);
--
2.44.0
next prev parent reply other threads:[~2024-03-05 17:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-05 17:08 [kvm-unit-tests PATCH v2 00/13] Enable EFI support Andrew Jones
2024-03-05 17:09 ` [kvm-unit-tests PATCH v2 01/13] riscv: Call abort instead of assert on unhandled exceptions Andrew Jones
2024-03-05 17:09 ` Andrew Jones [this message]
2024-03-05 17:09 ` [kvm-unit-tests PATCH v2 03/13] treewide: lib/stack: Fix backtrace Andrew Jones
2024-03-05 17:09 ` [kvm-unit-tests PATCH v2 04/13] treewide: lib/stack: Make base_address arch specific Andrew Jones
2024-03-12 5:45 ` Nicholas Piggin
2024-03-05 17:09 ` [kvm-unit-tests PATCH v2 05/13] riscv: Import gnu-efi files Andrew Jones
2024-03-05 17:09 ` [kvm-unit-tests PATCH v2 06/13] riscv: Tweak the gnu-efi imported code Andrew Jones
2024-03-05 17:09 ` [kvm-unit-tests PATCH v2 07/13] riscv: Enable building for EFI Andrew Jones
2024-03-05 17:09 ` [kvm-unit-tests PATCH v2 08/13] riscv: efi: Switch stack in _start Andrew Jones
2024-03-05 17:09 ` [kvm-unit-tests PATCH v2 09/13] efi: Add support for obtaining the boot hartid Andrew Jones
2024-03-05 17:09 ` [kvm-unit-tests PATCH v2 10/13] riscv: Refactor setup code Andrew Jones
2024-03-05 17:09 ` [kvm-unit-tests PATCH v2 11/13] riscv: Enable EFI boot Andrew Jones
2024-03-05 17:09 ` [kvm-unit-tests PATCH v2 12/13] riscv: efi: Add run script Andrew Jones
2024-03-05 17:09 ` [kvm-unit-tests PATCH v2 13/13] riscv: efi: Use efi-direct by default Andrew Jones
2024-03-18 17:28 ` [kvm-unit-tests PATCH v2 00/13] Enable EFI support Andrew Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240305170858.395836-17-andrew.jones@linux.dev \
--to=andrew.jones@linux.dev \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox