[PATCH v2 2/4] KVM: arm64: Trap TCR2_EL1 writes when S1PIE or S1POE is hidden
Marc Zyngier
maz at kernel.org
Fri Nov 20 01:23:03 PST 2026
On Fri, 20 Nov 2026 05:33:00 +0000,
Dan Carpenter <dan at pereq.eu> wrote:
>
> [1 <text/plain; us-ascii (7bit)>]
> On Thu, Nov 19, 2026 at 04:32:00PM +0000, Marc Zyngier wrote:
> > On Thu, 19 Nov 2026 13:25:35 +0000,
> > Dan Carpenter <dan at pereq.eu> wrote:
> > >
> > > A VMM can offer FEAT_TCR2 to a guest but hide FEAT_S1PIE or FEAT_S1POE,
> > > for example this is done to keep the VM migratable. KVM then stops
> > > loading the PIR_EL1, PIRE0_EL1 and POR_EL1 registers for that guest. But
> > > the guest's writes to the TCR2_EL1 register don't trap, and the CPU still
> > > acts on its PIE, POE and E0POE bits.
> > >
> > > If a guest turned these features on, it would run with the permission
> > > settings another VM left on the CPU. Technically this is a kind of
> > > information leak and a guest could figure out another guests permission
> > > setting based on which accesses fault.
> > >
> > > For these VMs, set the TCR_EL1 bit in HFGWTR_EL2 so that writes to
> > > TCR_EL1 and TCR2_EL1 trap, and clear the hidden bits in a new
> > > access_tcr2_el1() handler.
> > >
> > > Fixes: 58627b722ee2 ("KVM: arm64: Make PIR{,E0}_EL1 UNDEF if S1PIE is not advertised to the guest")
> > > Fixes: b86c9bea6349 ("KVM: arm64: Save/restore POE registers")
> > > Cc: stable at vger.kernel.org
> > > Signed-off-by: Dan Carpenter <dan at pereq.eu>
> > > ---
> > > v2: This is a new patch
> > >
> > > This is only a partial fix, I will update nested virtualization in the
> > > next patch and the !vcpu_has_nv(vcpu) condition in __compute_hfgwtr() will
> > > go away.
> >
> > No, I really don't want to go down that road.
> >
>
> Yeah. Thanks, Marc.
>
> I'm still a KVM newbie. I'm embarrassed I sent that in retrospect.
Don't be embarrassed. There is nothing wrong with proposing a solution
and being told why it doesn't really work. If anything, you have
spotted an interesting problem that we had ignored so far, and forced
me into thinking about it. Seems like a net win to me.
> I had Claude create a checklist based on analysing your review
> comments so I can hopefully get ahead of it a bit. Attached for
> your amusement. Apparently 10% of the time your review is "Why?"
Oh man. This thing has summed me up, digested me and reduced me to a
markdown file. It's 9:15 and I feel like I need a drink...
On the other hand, some of this stuff could be used to add more
substance to Documentation/process/maintainer-kvm-arm64.rst (which is
only on our fixes branch for now, but on its way to Linus).
> Also Claude says that it could have found the Sashiko bugs by reviewing
> patches to see if any different bugs get exposed by making a fix. We
> shall see.
>
> Btw, I'm still hoping to get you that selftest but I need to send a few
> more fixes first.
Sure, no worries.
Thanks again,
M.
--
Without deviation from the norm, progress is not possible.
More information about the linux-arm-kernel
mailing list