Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Fuad Tabba" <fuad.tabba@linux.dev>
Cc: "Marc Zyngier" <maz@kernel.org>,
	kvmarm@lists.linux.dev, "Oliver Upton" <oupton@kernel.org>
Subject: Re: [PATCH v2] KVM: arm64: Trap guest MPAM accesses whenever MPAM is implemented
Date: Tue, 08 Sep 2026 15:14:47 +0000	[thread overview]
Message-ID: <20260908151457.0A6901F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908145651.2828597-1-fuad.tabba@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Guests can bypass EL2 traps and directly access physical MPAM registers if the host has asymmetric CPUs or boots with `arm64.nompam`.
--

commit e23ed2fd702c6c43a8b21feffe356931e0f7eb5a
Author: Fuad Tabba <fuad.tabba@linux.dev>

KVM: arm64: Trap guest MPAM accesses whenever MPAM is implemented

This commit modifies the EL2 MPAM trap activation to gate on the sanitized
ID registers rather than the MPAMEN bit. This ensures that guest MPAM
accesses are trapped whenever MPAM registers are implemented, even if
firmware hasn't enabled MPAM.

> diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h
> index 1ce7130e25490..8941335724f6b 100644
> --- a/arch/arm64/kvm/hyp/include/hyp/switch.h
> +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h
[ ... ]
> @@ -298,7 +298,7 @@ static inline void  __activate_traps_mpam(struct kvm_vcpu *vcpu)
>  	u64 clr = MPAM2_EL2_EnMPAMSM;
>  	u64 set = MPAM2_EL2_TRAPMPAM0EL1 | MPAM2_EL2_TRAPMPAM1EL1;
>  
> -	if (!system_supports_mpam())
> +	if (!system_supports_mpam_sysregs())

[Severity: High]
This is a pre-existing issue, but does gating this early return on the
sanitized system-wide ID registers allow the guest direct access to
physical MPAM registers in asymmetric or overridden configurations?

During early boot, head.S (in finalise_el2_state) reads the physical
CPU ID registers and clears the EL2 MPAM traps. If the system has
asymmetric MPAM CPUs, or if the kernel is booted with arm64.nompam,
system_supports_mpam_sysregs() evaluates to false.

When that happens, __activate_traps_mpam() takes this early return and
skips setting TRAPMPAM0EL1 and TRAPMPAM1EL1. Since the hardware traps
were already cleared by head.S (or left clear by firmware), the guest's
MPAM register accesses execute natively without trapping to EL2. This
could allow an untrusted guest to manipulate host cache and memory
bandwidth partitioning.

This patch swaps one system-wide capability (ARM64_MPAM) for another
(ARM64_MPAM_SYSREGS), which inherits the exact same bypass. Should KVM
base its trap activation on the physical ID registers to safely isolate
the guest instead?

>  		return;
>  
>  	/* trap guest access to MPAMIDR_EL1 */

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260908145651.2828597-1-fuad.tabba@linux.dev?part=1

  reply	other threads:[~2026-09-08 15:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 14:56 [PATCH v2] KVM: arm64: Trap guest MPAM accesses whenever MPAM is implemented Fuad Tabba
2026-09-08 15:14 ` sashiko-bot [this message]
2026-09-10 10:40 ` Will Deacon
2026-09-11  7:01   ` Fuad Tabba
2026-09-10 11:08 ` Marc Zyngier
2026-09-11 10:43   ` Fuad Tabba

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=20260908151457.0A6901F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=fuad.tabba@linux.dev \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox