From: Jia He <justin.he@arm.com>
To: maz@kernel.org, oupton@kernel.org
Cc: fuad.tabba@linux.dev, joey.gouly@arm.com, seiden@linux.ibm.com,
suzuki.poulose@arm.com, yuzenghui@huawei.com,
catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com,
pbonzini@redhat.com, seanjc@google.com, shuah@kernel.org,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, Jia He <justin.he@arm.com>
Subject: [PATCH v3 0/4] KVM: arm64: nv: VNCR page mapping fixes
Date: Sat, 28 Nov 2026 01:14:43 +0000 [thread overview]
Message-ID: <20261128011447.3588988-1-justin.he@arm.com> (raw)
On a VNCR abort, KVM walks the guest hypervisor's EL2 stage-1 tables,
maps the page that VNCR_EL2 points to at a fixmap, and points the
hardware VNCR_EL2 at that fixmap. This series fixes three cases where
this goes wrong.
Patch 1 fixes the address that KVM programs into VNCR_EL2 on a host
with 16K or 64K pages. The fixmap maps the host page that contains the
VNCR page, and KVM takes the offset of the VNCR page in it from the VA.
If the guest hypervisor uses a smaller stage-1 granule, the VA and the
PA can have different offsets, and the nested context accesses another
page of the guest. Patch 1 takes the offset from the PA.
Patch 2 fixes a walk that cannot set the AF. If TCR_EL2.HA is set and
the descriptor that maps VNCR_EL2 is in a read-only memslot, the walk
returns -EPERM. kvm_handle_vncr_abort() has no case for -EPERM, so the
vCPU takes the same abort forever. Patch 2 injects the SEA that the
walk recorded.
Patch 3 adds a selftest for both. It maps the VNCR page at a VA whose
offset in a 16K or 64K page differs from that of its PA, and puts the
table that maps it in a read-only memslot.
Patch 4 allows the VNCR page in a cacheable VM_PFNMAP or VM_MIXEDMAP
VMA. The stage-2 fault path already maps such memory as cacheable, but
kvm_translate_vncr() rejects it and injects an SEA.
Patches 1 and 2 fix bugs that predate this series, and each can be
applied on its own.
Based on v7.4-rc3.
Patch numbers below are those of v3.
Changes since v2:
- New patch 1 (Sashiko).
- Patch 3: size the read-only memslot to whole host pages, and map the
VNCR page at a VA whose bits [15:12] differ from those of its PA
(Sashiko).
Changes since v1:
- New patches 2 and 3 (Sashiko).
- Patch 4: get the HVA with gfn_to_hva_memslot_prot() so that a VNCR
page in a read-only memslot is not rejected (Sashiko).
- Patch 4: limit the stage-2 comparison in the commit message to
VM_PFNMAP and VM_MIXEDMAP VMAs.
v2: https://lore.kernel.org/r/20261125024426.3464050-1-justin.he@arm.com
v1: https://lore.kernel.org/r/20261124025336.4107575-1-justin.he@arm.com
Jia He (4):
KVM: arm64: nv: Locate the VNCR page in the host page from its PA
KVM: arm64: nv: Inject an SEA when the VNCR walk cannot set the AF
KVM: arm64: selftests: Add a test for VNCR_EL2 translation faults
KVM: arm64: nv: Allow the L1 VNCR page in cacheable PFNMAP memory
arch/arm64/include/asm/kvm_mmu.h | 2 +
arch/arm64/include/asm/kvm_nested.h | 1 +
arch/arm64/kvm/hyp/vhe/switch.c | 9 +-
arch/arm64/kvm/mmu.c | 2 +-
arch/arm64/kvm/nested.c | 47 +++-
tools/testing/selftests/kvm/Makefile.kvm | 1 +
.../selftests/kvm/arm64/nv_vncr_abort.c | 221 ++++++++++++++++++
7 files changed, 273 insertions(+), 10 deletions(-)
create mode 100644 tools/testing/selftests/kvm/arm64/nv_vncr_abort.c
--
2.34.1
next reply other threads:[~2026-11-28 1:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 1:14 Jia He [this message]
2026-11-28 1:14 ` [PATCH v3 1/4] KVM: arm64: nv: Locate the VNCR page in the host page from its PA Jia He
2026-11-28 1:14 ` [PATCH v3 2/4] KVM: arm64: nv: Inject an SEA when the VNCR walk cannot set the AF Jia He
2026-11-28 1:14 ` [PATCH v3 3/4] KVM: arm64: selftests: Add a test for VNCR_EL2 translation faults Jia He
2026-11-28 1:14 ` [PATCH v3 4/4] KVM: arm64: nv: Allow the L1 VNCR page in cacheable PFNMAP memory Jia He
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=20261128011447.3588988-1-justin.he@arm.com \
--to=justin.he@arm.com \
--cc=catalin.marinas@arm.com \
--cc=fuad.tabba@linux.dev \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=seiden@linux.ibm.com \
--cc=shuah@kernel.org \
--cc=suzuki.poulose@arm.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