From: sashiko-bot@kernel.org
To: "Fuad Tabba" <fuad.tabba@linux.dev>
Cc: kvmarm@lists.linux.dev, "Oliver Upton" <oupton@kernel.org>,
"Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v3 06/18] KVM: arm64: Skip fixed-feature state flush for protected vCPUs
Date: Mon, 14 Sep 2026 13:42:58 +0000 [thread overview]
Message-ID: <20260914134258.9A5B21F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260914113338.159227-7-fuad.tabba@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Early return in `flush_debug_state` leaves the protected guest's `debug_owner` as `VCPU_DEBUG_FREE`, completely bypassing hardware debug register context switching and exposing host physical debug registers to the guest.
--
commit 3ff31a206fa3951489ae8f183dab7b2241b1018e
Author: Fuad Tabba <fuad.tabba@linux.dev>
KVM: arm64: Skip fixed-feature state flush for protected vCPUs
This commit skips the fixed-feature state flush for protected vCPUs by
returning early in flush_debug_state() and sync_debug_state(), and moving the
mdcr_el2 copy into the non-protected branch in flush_hyp_vcpu().
> diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> index ef65c3cd6f810..229a4877d14f5 100644
> --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> @@ -200,6 +200,9 @@ static void flush_debug_state(struct pkvm_hyp_vcpu *hyp_vcpu)
> {
> struct kvm_vcpu *host_vcpu = hyp_vcpu->host_vcpu;
>
> + if (pkvm_hyp_vcpu_is_protected(hyp_vcpu))
> + return;
> +
[Severity: Critical]
Does this early return leave the protected guest's debug_owner as
VCPU_DEBUG_FREE (its zero-initialized value) instead of synchronizing it?
This could bypass hardware debug register context switching, potentially
exposing host physical debug registers to the guest.
> hyp_vcpu->vcpu.arch.debug_owner = host_vcpu->arch.debug_owner;
>
> if (kvm_guest_owns_debug_regs(&hyp_vcpu->vcpu)) {
[ ... ]
> @@ -218,6 +221,9 @@ static void sync_debug_state(struct pkvm_hyp_vcpu *hyp_vcpu)
> {
> struct kvm_vcpu *host_vcpu = hyp_vcpu->host_vcpu;
>
> + if (pkvm_hyp_vcpu_is_protected(hyp_vcpu))
> + return;
> +
[Severity: Critical]
Could this early return ignore debug state updates on exit, further
contributing to the debug isolation bypass?
If KVM's world switch sees !kvm_debug_regs_in_use(), it might skip restoring
the host's debug registers.
> if (kvm_guest_owns_debug_regs(&hyp_vcpu->vcpu))
> host_vcpu->arch.vcpu_debug_state = hyp_vcpu->vcpu.arch.vcpu_debug_state;
> else if (kvm_host_owns_debug_regs(&hyp_vcpu->vcpu))
[ ... ]
> @@ -241,6 +247,12 @@ static void flush_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu)
> if (!pkvm_hyp_vcpu_is_protected(hyp_vcpu)) {
> if (vcpu_get_flag(host_vcpu, PKVM_HOST_STATE_DIRTY))
> flush_hyp_vcpu_state(hyp_vcpu);
> +
> + hyp_vcpu->vcpu.arch.hcr_el2 &= ~(HCR_TWI | HCR_TWE);
> + hyp_vcpu->vcpu.arch.hcr_el2 |= READ_ONCE(host_vcpu->arch.hcr_el2) &
> + (HCR_TWI | HCR_TWE);
> +
> + hyp_vcpu->vcpu.arch.mdcr_el2 = host_vcpu->arch.mdcr_el2;
[Severity: Critical]
By moving the mdcr_el2 copy into the non-protected branch, does the protected
guest retain the EL2-computed mdcr_el2 where TDA is deliberately cleared?
This seems to prevent debug accesses from trapping. If a protected guest
directly executes MSR DBGBVR0_EL1, <addr> without trapping to EL2, and KVM
skips restoring the host's debug registers on exit due to the early returns
above, the guest's malicious values could remain active when the host resumes.
If the host has breakpoints enabled (MDSCR_EL1.MDE = 1), these guest-injected
breakpoints could fire in the host kernel.
> hyp_vcpu->vcpu.arch.iflags = host_vcpu->arch.iflags;
> } else {
> hyp_vcpu->vcpu.arch.ctxt = host_vcpu->arch.ctxt;
> @@ -249,17 +261,13 @@ static void flush_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu)
> /* __hyp_running_vcpu must be NULL in a guest context. */
> hyp_vcpu->vcpu.arch.ctxt.__hyp_running_vcpu = NULL;
>
> - hyp_vcpu->vcpu.arch.mdcr_el2 = host_vcpu->arch.mdcr_el2;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260914113338.159227-1-fuad.tabba@linux.dev?part=6
next prev parent reply other threads:[~2026-09-14 13:42 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 11:33 [PATCH v3 00/18] KVM: arm64: Confine protected VM vCPU state to EL2 Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 01/18] KVM: arm64: Sync HCR_EL2.VSE back to the host vCPU under pKVM Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 02/18] KVM: arm64: Validate the host vCPU's VM before reading it " Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 03/18] KVM: arm64: Pin the host vCPU before adjusting its PC " Fuad Tabba
2026-09-14 13:01 ` sashiko-bot
2026-09-14 14:00 ` Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 04/18] KVM: arm64: Disable steal time for protected VMs Fuad Tabba
2026-09-22 14:34 ` Vincent Donnefort
2026-09-14 11:33 ` [PATCH v3 05/18] KVM: arm64: Introduce per-EC entry handlers for pKVM Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 06/18] KVM: arm64: Skip fixed-feature state flush for protected vCPUs Fuad Tabba
2026-09-14 13:42 ` sashiko-bot [this message]
2026-09-14 14:27 ` Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 07/18] KVM: arm64: Add {flush,sync}_hyp_timer_state() primitives Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 08/18] KVM: arm64: Add system register reset framework for protected VMs Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 09/18] KVM: arm64: Implement HVC handling for protected guests at EL2 Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 10/18] KVM: arm64: Handle PSCI calls for protected VMs " Fuad Tabba
2026-09-22 16:35 ` Vincent Donnefort
2026-09-22 16:37 ` Vincent Donnefort
2026-09-22 17:07 ` Vincent Donnefort
2026-09-23 9:51 ` Fuad Tabba
2026-09-24 8:30 ` Will Deacon
2026-09-24 11:26 ` Fuad Tabba
2026-09-24 12:14 ` Will Deacon
2026-09-24 15:21 ` Fuad Tabba
2026-10-01 12:58 ` Will Deacon
2026-10-01 13:11 ` Fuad Tabba
2026-10-01 12:59 ` Will Deacon
2026-10-01 13:11 ` Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 11/18] KVM: arm64: Restrict KVM_ARM_VCPU_INIT and PSCI version for protected VMs Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 12/18] KVM: arm64: Prevent host PC adjustments for protected vCPUs Fuad Tabba
2026-09-14 13:42 ` Marc Zyngier
2026-09-14 14:43 ` Fuad Tabba
2026-09-15 11:02 ` Marc Zyngier
2026-09-15 11:19 ` Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 13/18] KVM: arm64: Inject an UNDEF at EL2 for unhandled protected guest exits Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 14/18] KVM: arm64: Add per-EC entry/exit state marshalling for protected guests Fuad Tabba
2026-09-16 16:27 ` Marc Zyngier
2026-09-16 19:05 ` Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 15/18] KVM: arm64: Reject host access to protected VM private state Fuad Tabba
2026-09-16 16:30 ` Marc Zyngier
2026-09-16 19:07 ` Fuad Tabba
2026-09-17 8:06 ` Marc Zyngier
2026-09-17 18:42 ` Fuad Tabba
2026-09-18 13:21 ` Will Deacon
2026-09-18 13:24 ` Will Deacon
2026-09-27 8:20 ` Marc Zyngier
2026-09-27 12:37 ` Fuad Tabba
2026-09-28 19:00 ` Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 16/18] KVM: arm64: Reject host power-on of a vCPU that EL2 holds powered off Fuad Tabba
2026-09-16 16:43 ` Marc Zyngier
2026-09-16 19:08 ` Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 17/18] KVM: arm64: Advertise the capabilities that protected VMs support Fuad Tabba
2026-09-14 16:23 ` sashiko-bot
2026-09-14 18:01 ` Fuad Tabba
2026-09-14 11:33 ` [PATCH v3 18/18] KVM: arm64: Document the protected VM userspace API 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=20260914134258.9A5B21F000FF@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 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.