From: Marc Zyngier <maz@kernel.org>
To: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Cc: Joey Gouly <joey.gouly@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Oliver Upton <oliver.upton@linux.dev>,
Zenghui Yu <yuzenghui@huawei.com>
Subject: [PATCH 0/2] KVM: arm64: nv: Fix sysreg RESx-ication
Date: Sun, 12 Jan 2025 16:50:27 +0000 [thread overview]
Message-ID: <20250112165029.1181056-1-maz@kernel.org> (raw)
Joey recently reported that some rather basic tests were failing on
NV, and managed to track it down to critical register fields (such as
HCR_EL2.E2H) not having their expect value.
Further investigation has outlined a couple of critical issues:
- Evaluating HCR_EL2.E2H must always be done with a sanitising
accessor, no ifs, no buts. Given that KVM assumes a fixed value for
this bit, we cannot leave it to the guest to mess with.
- Resetting the sysreg file must result in the RESx bits taking
effect. Otherwise, we may end-up making the wrong decision (see
above), and we definitely expose invalid values to the guest. Note
that because we compute the RESx masks very late in the VM setup, we
need to apply these masks at that particular point as well.
The two patches in this series are enough to fix the current set of
issues, but __vcpu_sys_reg() needs some extra work as it is doing the
wrong thing when used as a lvalue. I'll post a separate series for
that, as the two problems are fairly orthogonal, and this results in a
significant amount of churn.
All kudos to Joey for patiently tracking that one down. This was
hidden behind a myriad of other issues, and nailing this sucker down
is nothing short of a debugging lesson. Drinks on me next time.
Unless someone shouts, I'll take this in for 6.14.
Marc Zyngier (2):
KVM: arm64: nv: Always evaluate HCR_EL2 using sanitising accessors
KVM: arm64: nv: Apply RESx settings to sysreg reset values
arch/arm64/include/asm/kvm_emulate.h | 36 ++++++++++++----------------
arch/arm64/include/asm/kvm_nested.h | 2 +-
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 4 ++--
arch/arm64/kvm/nested.c | 9 +++++--
arch/arm64/kvm/sys_regs.c | 5 +++-
5 files changed, 29 insertions(+), 27 deletions(-)
--
2.39.2
next reply other threads:[~2025-01-12 16:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-12 16:50 Marc Zyngier [this message]
2025-01-12 16:50 ` [PATCH 1/2] KVM: arm64: nv: Always evaluate HCR_EL2 using sanitising accessors Marc Zyngier
2025-01-12 16:50 ` [PATCH 2/2] KVM: arm64: nv: Apply RESx settings to sysreg reset values Marc Zyngier
2025-01-14 11:13 ` [PATCH 0/2] KVM: arm64: nv: Fix sysreg RESx-ication Joey Gouly
2025-01-14 11:37 ` Marc Zyngier
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=20250112165029.1181056-1-maz@kernel.org \
--to=maz@kernel.org \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=oliver.upton@linux.dev \
--cc=suzuki.poulose@arm.com \
--cc=yuzenghui@huawei.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