From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: nikos.nikoleris@arm.com, alexandru.elisei@arm.com
Subject: [PATCH kvm-unit-tests 2/2] arm64: Output PC load offset on unhandled exceptions
Date: Thu, 25 Mar 2021 16:56:57 +0100 [thread overview]
Message-ID: <20210325155657.600897-3-drjones@redhat.com> (raw)
In-Reply-To: <20210325155657.600897-1-drjones@redhat.com>
Since for arm64 we can load the unit tests at different addresses,
then let's make it easier to debug by calculating the PC offset for
the user. The offset can then be directly used when looking at the
disassembly of the test's elf file.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
arm/flat.lds | 1 +
lib/arm64/processor.c | 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/arm/flat.lds b/arm/flat.lds
index 4d43cdfeab41..6ed377c0eaa0 100644
--- a/arm/flat.lds
+++ b/arm/flat.lds
@@ -1,6 +1,7 @@
SECTIONS
{
+ PROVIDE(_text = .);
.text : { *(.init) *(.text) *(.text.*) }
. = ALIGN(64K);
PROVIDE(etext = .);
diff --git a/lib/arm64/processor.c b/lib/arm64/processor.c
index ef558625e284..831207c16587 100644
--- a/lib/arm64/processor.c
+++ b/lib/arm64/processor.c
@@ -99,12 +99,19 @@ bool get_far(unsigned int esr, unsigned long *far)
return false;
}
+extern unsigned long _text;
+
static void bad_exception(enum vector v, struct pt_regs *regs,
unsigned int esr, bool esr_valid, bool bad_vector)
{
unsigned long far;
bool far_valid = get_far(esr, &far);
unsigned int ec = esr >> ESR_EL1_EC_SHIFT;
+ uintptr_t text = (uintptr_t)&_text;
+
+ printf("Load address: %" PRIxPTR "\n", text);
+ printf("PC: %" PRIxPTR " PC offset: %" PRIxPTR "\n",
+ (uintptr_t)regs->pc, (uintptr_t)regs->pc - text);
if (bad_vector) {
if (v < VECTOR_MAX)
--
2.26.3
next prev parent reply other threads:[~2021-03-25 15:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-25 15:56 [PATCH kvm-unit-tests 0/2] arm64: One fix and one improvement Andrew Jones
2021-03-25 15:56 ` [PATCH kvm-unit-tests 1/2] arm64: argc is an int Andrew Jones
2021-03-25 16:15 ` Nikos Nikoleris
2021-03-25 15:56 ` Andrew Jones [this message]
2021-03-25 16:20 ` [PATCH kvm-unit-tests 2/2] arm64: Output PC load offset on unhandled exceptions Nikos Nikoleris
2021-03-25 16:28 ` [PATCH kvm-unit-tests 0/2] arm64: One fix and one improvement 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=20210325155657.600897-3-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=alexandru.elisei@arm.com \
--cc=kvm@vger.kernel.org \
--cc=nikos.nikoleris@arm.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