From: sashiko-bot@kernel.org
To: "Sebastian Ene" <sebastianene@google.com>
Cc: "Marc Zyngier" <maz@kernel.org>,
kvmarm@lists.linux.dev, "Oliver Upton" <oupton@kernel.org>
Subject: Re: [PATCH v2 12/13] KVM: arm64: Prevent the host from programming new GITS_BASER tables
Date: Fri, 07 Aug 2026 17:11:32 +0000 [thread overview]
Message-ID: <20260807171133.364CC1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260807164322.2970811-14-sebastianene@google.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Critical] Sub-word (32-bit) MMIO writes to 64-bit ITS registers cause hypervisor crashes (Alignment Fault) and silent state corruption.
- [Critical] Incomplete attribute masking in baser_write and cbaser_write allows the host to alter ITS table Cacheability and Shareability.
- [Critical] The host can activate unvalidated ITS tables by toggling the GITS_BASER Valid bit (bit 63).
- [High] Incomplete physical address masking in baser_write on 52-bit PA systems (FEAT_LPA) allows physical address hijacking.
--
--- Patch [12]: [PATCH v2 12/13] KVM: arm64: Prevent the host from programming new GITS_BASER tables ---
commit ceb5f9bba1bc25bf01683842fe6461183f94c200
Author: Sebastian Ene <sebastianene@google.com>
KVM: arm64: Prevent the host from programming new GITS_BASER tables
Don't allow the host to change the layout of the tables or to modify the
address programmed in the GITS_BASER registers to point to new tables
and bypass the sanitization.
Prevent the host from updating the ITS tables while the ITS is enabled
and the tables are set to prevent undefined behavior.
> diff --git a/arch/arm64/kvm/hyp/nvhe/its_emulate.c b/arch/arm64/kvm/hyp/nvhe/its_emulate.c
> --- a/arch/arm64/kvm/hyp/nvhe/its_emulate.c
> +++ b/arch/arm64/kvm/hyp/nvhe/its_emulate.c
[ ... ]
> @@ -460,10 +465,42 @@ static void cbaser_read(struct pkvm_protected_reg *region, u64 offset, u64 *read
> *read = readq_relaxed(its->base + GITS_CBASER);
> }
>
> +static void baser_write(struct pkvm_protected_reg *region, u64 offset, u64 value)
> +{
> + struct its_priv_state *its = region->priv;
> + u32 ctlr = readl_relaxed(its->base + GITS_CTLR);
> + int baser_idx;
> + u64 baser;
> +
> + if ((ctlr & GITS_CTLR_ENABLE) || !(ctlr & GITS_CTLR_QUIESCENT))
> + return;
> +
> + baser_idx = (offset - GITS_BASER) >> 3;
> + baser = its->host_state->tables[baser_idx].val;
> +
> + /* Prevent if it tries to change from direct layout to indirect layout */
> + if ((value & GITS_BASER_INDIRECT) != (baser & GITS_BASER_INDIRECT))
> + return;
> +
> + /* Don't allow the host to point to new tables or new attributes */
> + value &= ~(GENMASK_ULL(47, 12) | GENMASK_ULL(9, 0));
> + value |= (baser & GENMASK_ULL(47, 12)) | (baser & GENMASK_ULL(9, 0));
[Severity: Critical]
Does this mask correctly restrict the cacheability and shareability attributes?
The mask only clears bits 47:12 and 9:0, which leaves Cacheability
(bits 61:53) and Shareability (bits 11:10) unmasked. This allows the host
to force the ITS hardware to bypass caches while EL2 accesses the same
memory via Cacheable mappings, potentially compromising memory coherency
and EL2 isolation.
The cbaser_write() function similarly fails to mask Cacheability and
Shareability attributes for the command queue base register.
[Severity: High]
Can this mask allow the host to hijack the physical address on 52-bit PA
systems?
For systems with FEAT_LPA, PA[51:48] are stored in bits 51:48 of GITS_BASER.
Since the mask only covers up to bit 47, the host can supply arbitrary
values in bits 51:48. This would redirect the ITS table physical address
by multiples of 256TB to untracked memory, bypassing pKVM stage-2 tracking.
[Severity: Critical]
Could this allow the host to activate unvalidated ITS tables by toggling the
Valid bit (bit 63)?
Because bit 63 is unmasked, a malicious host could boot with a fabricated PA
and VALID = 0, skipping KVM's validation and memory donation. If the host
subsequently writes to GITS_BASER with VALID = 1, this mask restores the
fabricated PA and writes VALID = 1 to the hardware, granting the ITS
hardware DMA access to arbitrary physical addresses.
> +
> + writeq_relaxed(value, its->base + offset);
[Severity: Critical]
Could a 32-bit MMIO write to a 64-bit ITS register cause a hypervisor crash
or state corruption here?
Looking at pkvm_its_emulate_handler() in this file, it permits sub-word
accesses to 64-bit registers:
if (reg_handler->access_size < reg_size)
return;
If a host issues a 32-bit write to an unaligned offset (e.g.,
GITS_BASER + 4), this writeq_relaxed() will perform a 64-bit device memory
access at an unaligned address, triggering an Alignment Fault at EL2. Even
if aligned, writing a 32-bit payload via a 64-bit writeq_relaxed() will
overwrite the upper 32 bits of the hardware register with zeros, wiping
critical fields.
Should the payload be adapted for a read-modify-write, or alignment
enforced? The cbaser_write() function appears to share this same behavior.
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260807164322.2970811-2-sebastianene@google.com?part=12
next prev parent reply other threads:[~2026-08-07 17:11 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 16:43 [PATCH v2 00/13] KVM: ITS hardening for pKVM Sebastian Ene
2026-08-07 16:43 ` [PATCH v2 01/13] KVM: arm64: Donate MMIO to the hypervisor Sebastian Ene
2026-08-07 16:58 ` sashiko-bot
2026-08-07 16:43 ` [PATCH v2 02/13] KVM: arm64: Track host-unmapped MMIO regions in a static array Sebastian Ene
2026-08-07 17:00 ` sashiko-bot
2026-08-07 16:43 ` [PATCH v2 03/13] KVM: arm64: Support host MMIO trap handlers for unmapped devices Sebastian Ene
2026-08-07 17:03 ` sashiko-bot
2026-08-07 16:43 ` [PATCH v2 04/13] KVM: Parse the device tree and register the ITS region with pKVM Sebastian Ene
2026-08-07 17:09 ` sashiko-bot
2026-08-07 16:43 ` [PATCH v2 05/13] irqchip/gic-v3-its: Add support for the ITS emulation setup Sebastian Ene
2026-08-07 17:00 ` sashiko-bot
2026-08-07 16:43 ` [PATCH v2 06/13] KVM: arm64: Shadow the ITS command queue and setup emulation Sebastian Ene
2026-08-07 16:57 ` sashiko-bot
2026-08-07 16:43 ` [PATCH v2 07/13] KVM: arm64: Restrict host access to the private ITS tables Sebastian Ene
2026-08-07 17:02 ` sashiko-bot
2026-08-07 16:43 ` [PATCH v2 08/13] KVM: arm64: Trap & emulate the ITS MAPD command Sebastian Ene
2026-08-07 16:57 ` sashiko-bot
2026-08-07 16:43 ` [PATCH v2 09/13] KVM: arm64: Trap & emulate the ITS MAPC command Sebastian Ene
2026-08-07 17:04 ` sashiko-bot
2026-08-07 16:43 ` [PATCH v2 10/13] KVM: arm64: Restrict host updates to GITS_CTLR Sebastian Ene
2026-08-07 17:02 ` sashiko-bot
2026-08-07 16:43 ` [PATCH v2 11/13] KVM: arm64: Prevent the host from specifying a different command queue Sebastian Ene
2026-08-07 17:28 ` sashiko-bot
2026-08-07 16:43 ` [PATCH v2 12/13] KVM: arm64: Prevent the host from programming new GITS_BASER tables Sebastian Ene
2026-08-07 17:11 ` sashiko-bot [this message]
2026-08-07 16:43 ` [PATCH v2 13/13] KVM: arm64: Implement HVC interface for ITS emulation setup Sebastian Ene
2026-08-07 17:17 ` sashiko-bot
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=20260807171133.364CC1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sebastianene@google.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 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.