From: Justin He <Justin.He@arm.com>
To: Marc Zyngier <maz@kernel.org>
Cc: Oliver Upton <oupton@kernel.org>,
Fuad Tabba <fuad.tabba@linux.dev>,
Joey Gouly <Joey.Gouly@arm.com>,
Steffen Eiden <seiden@linux.ibm.com>,
Suzuki 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>,
Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>,
Shuah Khan <shuah@kernel.org>,
Sascha Bischoff <Sascha.Bischoff@arm.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"kvmarm@lists.linux.dev" <kvmarm@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"linux-kselftest@vger.kernel.org"
<linux-kselftest@vger.kernel.org>
Subject: RE: [PATCH 2/3] KVM: arm64: nv: Don't request or attempt L1 VNCR mapping without vncr_tlb
Date: Tue, 24 Nov 2026 01:42:42 +0000 [thread overview]
Message-ID: <AS2PR08MB97860AD10162A11B52229A44F7442@AS2PR08MB9786.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <86cxrvzbyn.wl-maz@kernel.org>
> -----Original Message-----
[...]
> On Mon, 23 Nov 2026 15:09:16 +0000,
> Jia He <justin.he@arm.com> wrote:
> >
> > vcpu->arch.vncr_tlb is only allocated when ID_AA64MMFR4_EL1.NV_frac
> > advertises FEAT_NV2. When NV_frac is cleared to 0 (or E2H0 is selected),
> > vncr_tlb is NULL for the lifetime of the vCPU.
> >
> > Don't set KVM_REQ_MAP_L1_VNCR_EL2 in kvm_vcpu_load_hw_mmu()
> when
> > vncr_tlb is NULL. The only other place that sets this request is
> > kvm_translate_vncr(), which only runs on a FEAT_NV2 VNCR abort. Warn
> and
> > return early in kvm_map_l1_vncr() if vt is NULL before disabling
> > preemption and taking kvm->mmu_lock.
> >
> > Signed-off-by: Jia He <justin.he@arm.com>
> > ---
> > arch/arm64/kvm/nested.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c
> > index 4d83281a7a28..2f52c128f3a7 100644
> > --- a/arch/arm64/kvm/nested.c
> > +++ b/arch/arm64/kvm/nested.c
> > @@ -979,7 +979,8 @@ void kvm_vcpu_load_hw_mmu(struct kvm_vcpu
> *vcpu)
> > vcpu->arch.hw_mmu =
> get_s2_mmu_nested(vcpu);
> > }
> >
> > - if (__vcpu_sys_reg(vcpu, HCR_EL2) & HCR_EL2_NV)
> > + if (vcpu->arch.vncr_tlb &&
> > + (__vcpu_sys_reg(vcpu, HCR_EL2) & HCR_EL2_NV))
> > kvm_make_request(KVM_REQ_MAP_L1_VNCR_EL2,
> vcpu);
>
> How do we even get here? Now that you have short-circuited the vcpu
> state loading, I can't see how this code is reachable before we've
> actually initialised the relevant state.
>
> What am I missing?
>
> > }
> > }
> > @@ -1761,6 +1762,9 @@ static void kvm_map_l1_vncr(struct kvm_vcpu
> *vcpu)
> > struct vncr_tlb *vt = vcpu->arch.vncr_tlb;
> > pgprot_t prot;
> >
> > + if (WARN_ON_ONCE(!vt))
> > + return;
> > +
>
> I don't think we want this. Either the code is rock solid, and the
> warning pointless, or we have terrible problems, and I really want to
> see the kernel exploding, specially given that NV is still an
> experimental feature.
>
Agreed. I'll drop this patch in v2. Patch 2/3 was only meant as a defensive check,
and patch 1/3 should be sufficient.
Thanks,
Jia He (Justin)
next prev parent reply other threads:[~2026-11-24 1:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 15:09 [PATCH 0/3] KVM: arm64: Fix pre-first-run KVM_PRE_FAULT_MEMORY vcpu_load() issues Jia He
2026-11-23 15:09 ` [PATCH 1/3] KVM: arm64: Don't load hardware vCPU state before first run Jia He
2026-11-23 17:20 ` Marc Zyngier
2026-11-23 17:50 ` Lorenzo Stoakes (ARM)
2026-11-24 1:39 ` Justin He
2026-11-23 15:09 ` [PATCH 2/3] KVM: arm64: nv: Don't request or attempt L1 VNCR mapping without vncr_tlb Jia He
2026-11-23 17:36 ` Marc Zyngier
2026-11-24 1:42 ` Justin He [this message]
2026-11-23 15:09 ` [PATCH 3/3] KVM: selftests: arm64: Test KVM_PRE_FAULT_MEMORY before first KVM_RUN 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=AS2PR08MB97860AD10162A11B52229A44F7442@AS2PR08MB9786.eurprd08.prod.outlook.com \
--to=justin.he@arm.com \
--cc=Catalin.Marinas@arm.com \
--cc=Joey.Gouly@arm.com \
--cc=Mark.Rutland@arm.com \
--cc=Sascha.Bischoff@arm.com \
--cc=Suzuki.Poulose@arm.com \
--cc=fuad.tabba@linux.dev \
--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=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=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
all inboxes | Powered by JetHome®