From: Dan Carpenter <dan@pereq.eu>
To: sashiko-reviews@lists.linux.dev
Cc: kvmarm@lists.linux.dev, Oliver Upton <oupton@kernel.org>,
Marc Zyngier <maz@kernel.org>
Subject: Re: [PATCH 1/2] KVM: arm64: nv: Fix AT emulation for TCR2_EL1
Date: Mon, 16 Nov 2026 12:22:13 +0300 [thread overview]
Message-ID: <avrLRfCRUcLrc9Tp@stanley.mountain> (raw)
In-Reply-To: <sashiko-outbox-216278@kernel.org>
On Mon, Nov 16, 2026 at 06:27:41AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Medium] KVM: arm64: nv: unmasked PIE/POE in SYS_TCR2 in
> __kvm_at_s1e01_fast() and __kvm_at_s1e2()
> --
>
> commit ba7c962c50af660f734650ef98aa65969755bc0a
> Author: Dan Carpenter <dan@pereq.eu>
>
> KVM: arm64: nv: Fix AT emulation for TCR2_EL1
>
> This commit sanitizes hardware SYS_TCR2 during nested AT instruction
> emulation by masking out unsupported PIE and POE bits and clearing
> SYS_TCR2 when the guest VM does not support FEAT_TCR2.
>
> > diff --git a/arch/arm64/kvm/at.c b/arch/arm64/kvm/at.c
> > index 30d8f062b2c29..06765881a4c81 100644
> > --- a/arch/arm64/kvm/at.c
> > +++ b/arch/arm64/kvm/at.c
> > @@ -1438,7 +1438,13 @@ static u64 __kvm_at_s1e01_fast(struct kvm_vcpu *vcpu, u32 op, u64 vaddr)
> > write_sysreg_el1(vcpu_read_sys_reg(vcpu, TCR_EL1), SYS_TCR);
> > write_sysreg_el1(vcpu_read_sys_reg(vcpu, MAIR_EL1), SYS_MAIR);
> > if (kvm_has_tcr2(vcpu->kvm)) {
> > - write_sysreg_el1(vcpu_read_sys_reg(vcpu, TCR2_EL1), SYS_TCR2);
> > + u64 tcr2 = effective_tcr2(vcpu, TR_EL10);
> > +
> > + if (!kvm_has_s1pie(vcpu->kvm))
> > + tcr2 &= ~TCR2_EL1_PIE;
> > + if (!kvm_has_s1poe(vcpu->kvm))
> > + tcr2 &= ~(TCR2_EL1_POE | TCR2_EL1_E0POE);
> > + write_sysreg_el1(tcr2, SYS_TCR2);
> > if (kvm_has_s1pie(vcpu->kvm)) {
> > write_sysreg_el1(vcpu_read_sys_reg(vcpu, PIR_EL1), SYS_PIR);
> > write_sysreg_el1(vcpu_read_sys_reg(vcpu, PIRE0_EL1), SYS_PIRE0);
> > @@ -1452,6 +1458,9 @@ static u64 __kvm_at_s1e01_fast(struct kvm_vcpu *vcpu, u32 op, u64 vaddr)
> > __load_stage2(mmu);
> >
> > skip_mmu_switch:
> > + if (cpus_have_final_cap(ARM64_HAS_TCR2) && !kvm_has_tcr2(vcpu->kvm))
> > + write_sysreg_el1(0, SYS_TCR2);
> > +
> > /* Temporarily switch back to guest context */
> > write_sysreg_hcr(vcpu->arch.hcr_el2);
> > isb();
> > @@ -1554,6 +1563,9 @@ int __kvm_at_s1e2(struct kvm_vcpu *vcpu, u32 op, u64 vaddr)
> > if (!vcpu_el2_e2h_is_set(vcpu))
> > val |= HCR_EL2_NV | HCR_EL2_NV1;
> >
> > + if (cpus_have_final_cap(ARM64_HAS_TCR2) && !kvm_has_tcr2(vcpu->kvm))
> > + write_sysreg_el1(0, SYS_TCR2);
>
> [Severity: Medium]
> Does hardware SYS_TCR2 still retain unmasked PIE, POE, and E0POE bits in
> __kvm_at_s1e2() and on the !mmu_cs path of __kvm_at_s1e01_fast() when
> kvm_has_tcr2(vcpu->kvm) is true?
>
Yep. Some bits are missing. I'll need to update this one.
Also sorry for sending patch 2/2 before patch 1/2. I fat fingered that.
regards,
dan carpenter
next prev parent reply other threads:[~2026-11-16 9:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 6:00 [PATCH 0/2] KVM: arm64: nv: fix a couple bugs in AT emulation Dan Carpenter
2026-11-16 6:00 ` [PATCH 2/2] KVM: arm64: nv: Update the shadow MMU's VMID for " Dan Carpenter
2026-11-16 6:00 ` [PATCH 1/2] KVM: arm64: nv: Fix AT emulation for TCR2_EL1 Dan Carpenter
2026-11-16 6:27 ` sashiko-bot
2026-11-16 9:22 ` Dan Carpenter [this message]
2026-11-16 16:01 ` 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=avrLRfCRUcLrc9Tp@stanley.mountain \
--to=dan@pereq.eu \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.