From: Alexander Graf <agraf@csgraf.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-stable@nongnu.org, Cameron Esfahani <dirty@apple.com>,
qemu-devel@nongnu.org, Roman Bolshakov <r.bolshakov@yadro.com>,
qemu-arm@nongnu.org, Ivan Babrou <ivan@cloudflare.com>
Subject: [PATCH v3 2/2] hvf: arm: Handle unknown ID registers as RES0
Date: Wed, 9 Feb 2022 13:41:35 +0100 [thread overview]
Message-ID: <20220209124135.69183-2-agraf@csgraf.de> (raw)
In-Reply-To: <20220209124135.69183-1-agraf@csgraf.de>
Recent Linux versions added support to read ID_AA64ISAR2_EL1. On M1,
those reads trap into QEMU which handles them as faults.
However, AArch64 ID registers should always read as RES0. Let's
handle them accordingly.
This fixes booting Linux 5.17 guests.
Cc: qemu-stable@nongnu.org
Reported-by: Ivan Babrou <ivan@cloudflare.com>
Signed-off-by: Alexander Graf <agraf@csgraf.de>
---
v1 -> v2:
- Handle all ID registers instead of just ID_AA64ISAR2_EL1.
v2 -> v3:
- Use new sysreg parsing macros
- Remove useless check for op2
---
target/arm/hvf/hvf.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 8d0447ab01..5ca7aa2dcd 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -754,6 +754,15 @@ static bool hvf_handle_psci_call(CPUState *cpu)
return true;
}
+static bool is_id_sysreg(uint32_t reg)
+{
+ return SYSREG_OP0(reg) == 3 &&
+ SYSREG_OP1(reg) == 0 &&
+ SYSREG_CRN(reg) == 0 &&
+ SYSREG_CRM(reg) >= 1 &&
+ SYSREG_CRM(reg) < 8;
+}
+
static int hvf_sysreg_read(CPUState *cpu, uint32_t reg, uint32_t rt)
{
ARMCPU *arm_cpu = ARM_CPU(cpu);
@@ -806,6 +815,11 @@ static int hvf_sysreg_read(CPUState *cpu, uint32_t reg, uint32_t rt)
/* Dummy register */
break;
default:
+ if (is_id_sysreg(reg)) {
+ /* ID system registers read as RES0 */
+ val = 0;
+ break;
+ }
cpu_synchronize_state(cpu);
trace_hvf_unhandled_sysreg_read(env->pc, reg,
SYSREG_OP0(reg),
--
2.32.0 (Apple Git-132)
next prev parent reply other threads:[~2022-02-09 13:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-09 12:41 [PATCH v3 1/2] hvf: arm: Use macros for sysreg shift/masking Alexander Graf
2022-02-09 12:41 ` Alexander Graf [this message]
2022-02-16 17:32 ` [PATCH v3 2/2] hvf: arm: Handle unknown ID registers as RES0 Peter Maydell
2022-02-11 8:13 ` [PATCH v3 1/2] hvf: arm: Use macros for sysreg shift/masking Cameron Esfahani
2022-02-11 9:40 ` Philippe Mathieu-Daudé via
2022-02-16 17:35 ` Peter Maydell
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=20220209124135.69183-2-agraf@csgraf.de \
--to=agraf@csgraf.de \
--cc=dirty@apple.com \
--cc=ivan@cloudflare.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=r.bolshakov@yadro.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;
as well as URLs for NNTP newsgroup(s).