Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Dan Carpenter <dan@pereq.eu>
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 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>,
	"Jintack Lim" <jintack.lim@linaro.org>,
	linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	"Karthik Bhargavan" <karthik@pereq.eu>,
	"Clément Blaudeau" <clement@cryspen.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH v2 2/4] KVM: arm64: Trap TCR2_EL1 writes when S1PIE or S1POE is hidden
Date: Thu, 19 Nov 2026 16:32:00 +0000	[thread overview]
Message-ID: <86wlq8zssf.wl-maz@kernel.org> (raw)
In-Reply-To: <20261119-nv-tcr2-v2-2-3deb1a6cdba8@pereq.eu>

On Thu, 19 Nov 2026 13:25:35 +0000,
Dan Carpenter <dan@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@vger.kernel.org
> Signed-off-by: Dan Carpenter <dan@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.

Trapping TCR_EL1 is an absolute performance sink, and at this point it
is not worth running VMs (it puts everyone at the level of AmpereOne).
It also puts the penalty on well behaved guests which should be able
to access TCR_EL1 as much as they want without penalties.

Yes, the architecture is terrible, and we have to work around it.  I
can see two ways to address this:

- load PIR/PIRE0/POR unconditionally so that they do not contain any
  state that logically belong to another guest, preferably with values
  that prevent any access (0 is a good candidate for the permissions).
  It means that if the guest plays with us, it will lose permission to
  its own memory accesses.

- Move TCR2_EL1 to the sanitised set, and make sure that these bits are
  never evaluated by KVM, and will be cleared on each entry (we
  already do this for TCR2_EL2).

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.


  reply	other threads:[~2026-11-19 16:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 13:25 [PATCH v2 0/4] KVM: arm64: nv: Fix AT emulation for nested virtualization Dan Carpenter
2026-11-19 13:25 ` [PATCH v2 1/4] KVM: arm64: nv: Fix AT emulation for TCR2_EL1 Dan Carpenter
2026-11-19 13:25 ` [PATCH v2 2/4] KVM: arm64: Trap TCR2_EL1 writes when S1PIE or S1POE is hidden Dan Carpenter
2026-11-19 16:32   ` Marc Zyngier [this message]
2026-11-19 13:25 ` [PATCH v2 3/4] KVM: arm64: nv: Clear hidden TCR2 bits for nested guests Dan Carpenter
2026-11-19 13:25 ` [PATCH v2 4/4] KVM: arm64: nv: Update the shadow MMU's VMID for AT emulation Dan Carpenter

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=86wlq8zssf.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=clement@cryspen.com \
    --cc=dan@pereq.eu \
    --cc=fuad.tabba@linux.dev \
    --cc=jintack.lim@linaro.org \
    --cc=joey.gouly@arm.com \
    --cc=karthik@pereq.eu \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=oupton@kernel.org \
    --cc=seiden@linux.ibm.com \
    --cc=stable@vger.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