From: Fuad Tabba <fuad.tabba@linux.dev>
To: Marc Zyngier <maz@kernel.org>, Oliver Upton <oupton@kernel.org>
Cc: Joey Gouly <joey.gouly@arm.com>,
Steffen Eiden <seiden@linux.ibm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Vincent Donnefort <vdonnefort@google.com>,
Fuad Tabba <tabba@google.com>,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: [PATCH 0/3] KVM: arm64: Fixes for a vCPU caught in a disallowed AArch32 mode
Date: Mon, 30 Nov 2026 14:44:35 +0000 [thread overview]
Message-ID: <20261130144438.3176276-1-fuad.tabba@linux.dev> (raw)
Hi folks,
KVM marks a vCPU as uninitialized once its guest has entered a
disallowed AArch32 mode, and the VMM has to call KVM_ARM_VCPU_INIT
before it can run the vCPU again. This series fixes how
KVM_ARM_VCPU_INIT and KVM_RUN handle such a vCPU.
KVM_ARM_VCPU_INIT sets the vCPU up a second time, as if it never ran.
For a nested vCPU, this can free the VNCR page that the virtual timer
still reads, and for any vCPU it resets MPIDR_EL1 and CLIDR_EL1 a
second time. With the first patch, a vCPU that has run is only reset.
KVM_RUN checks that a vCPU is initialized only when the thread issuing
it changes, so the same thread can still run the vCPU. The second
patch makes KVM_RUN check every time. For a protected vCPU, EL2 marks
its own copy of the vCPU but never checks it. With the third patch,
EL2 doesn't run a vCPU that it has marked.
Tested on QEMU. The KASAN report in the first patch is from a host
booted with kvm-arm.mode=nested, with fault injection failing the
nested MMU allocation when the VMM calls KVM_ARM_VCPU_INIT again. With
the series, KVM_ARM_VCPU_INIT doesn't reach that allocation, MPIDR_EL1
keeps the value that the VMM wrote, and a protected guest that enters
AArch32 EL0 doesn't run again.
Based on Linux 7.4-rc3 (aebb727447640).
Cheers,
/fuad
Fuad Tabba (3):
KVM: arm64: Don't call kvm_setup_vcpu() again once a vCPU has run
KVM: arm64: Reject KVM_RUN on a vCPU that's no longer initialized
KVM: arm64: Don't run a protected vCPU that was caught in AArch32
arch/arm64/kvm/arm.c | 8 +++++++-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 4 ++++
arch/arm64/kvm/hyp/nvhe/switch.c | 7 +++----
3 files changed, 14 insertions(+), 5 deletions(-)
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
--
2.47.3
next reply other threads:[~2026-11-30 14:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 14:44 Fuad Tabba [this message]
2026-11-30 14:44 ` [PATCH 1/3] KVM: arm64: Don't call kvm_setup_vcpu() again once a vCPU has run Fuad Tabba
2026-11-30 14:44 ` [PATCH 2/3] KVM: arm64: Reject KVM_RUN on a vCPU that's no longer initialized Fuad Tabba
2026-11-30 14:44 ` [PATCH 3/3] KVM: arm64: Don't run a protected vCPU that was caught in AArch32 Fuad Tabba
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=20261130144438.3176276-1-fuad.tabba@linux.dev \
--to=fuad.tabba@linux.dev \
--cc=catalin.marinas@arm.com \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=seiden@linux.ibm.com \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.com \
--cc=vdonnefort@google.com \
--cc=will@kernel.org \
--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