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 03/18] KVM: arm64: Pin the host vCPU before adjusting its PC under pKVM
Date: Mon, 14 Sep 2026 13:01:52 +0000 [thread overview]
Message-ID: <20260914130152.F0D5F1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260914113338.159227-4-fuad.tabba@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Unmapped host `kvm_s2_mmu` pointer dereference in EL2 TLB flush handlers panics the hypervisor before the first KVM_RUN.
--
commit 201c7baf4784bec3cde62591e1662c2fd50608dc
Author: Fuad Tabba <fuad.tabba@linux.dev>
KVM: arm64: Pin the host vCPU before adjusting its PC under pKVM
This commit fixes a hypervisor panic in pKVM caused by dereferencing an
unmapped host vCPU before its first KVM_RUN. It introduces temporary pinning
of the host vCPU around __kvm_adjust_pc() when no hyp vCPU is loaded.
> diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> index b6bfe502bcd04..52a65b13b3810 100644
> --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> @@ -546,8 +546,25 @@ static void handle___pkvm_host_mkyoung_guest(struct kvm_cpu_context *host_ctxt)
> static void handle___kvm_adjust_pc(struct kvm_cpu_context *host_ctxt)
> {
> DECLARE_REG(struct kvm_vcpu *, vcpu, host_ctxt, 1);
> + struct pkvm_hyp_vcpu *hyp_vcpu;
> + struct kvm_vcpu *host_vcpu;
> +
> + host_vcpu = __get_host_hyp_vcpus(vcpu, &hyp_vcpu);
> + if (host_vcpu) {
> + __kvm_adjust_pc(host_vcpu);
> + return;
> + }
> +
> + /*
> + * With no hyp vCPU loaded for it, the host vCPU may be unpinned,
> + * and so unmapped at EL2: its first run pins it.
> + */
> + host_vcpu = kern_hyp_va(vcpu);
> + if (hyp_pin_shared_mem(host_vcpu, host_vcpu + 1))
> + return;
>
> - __kvm_adjust_pc(kern_hyp_va(vcpu));
> + __kvm_adjust_pc(host_vcpu);
> + hyp_unpin_shared_mem(host_vcpu, host_vcpu + 1);
> }
[Severity: Critical]
This is a pre-existing issue, but does this same vulnerability apply to the
TLB flush handlers in this file?
If a userspace process creates a VM and a memory slot, and then immediately
deletes it via KVM_SET_USER_MEMORY_REGION with a zero memory size before
the first KVM_RUN, this triggers kvm_arch_flush_shadow_memslot().
This unconditionally calls kvm_tlb_flush_vmid_range(), which issues an HVC
call that ends up in handle___kvm_tlb_flush_vmid_range():
arch/arm64/kvm/hyp/nvhe/hyp-main.c:handle___kvm_tlb_flush_vmid_range() {
DECLARE_REG(struct kvm_s2_mmu *, mmu, host_ctxt, 1);
DECLARE_REG(phys_addr_t, start, host_ctxt, 2);
DECLARE_REG(unsigned long, pages, host_ctxt, 3);
__kvm_tlb_flush_vmid_range(kern_hyp_va(mmu), start, pages);
}
Since the kvm struct (containing kvm_s2_mmu) is not pinned until
pkvm_create_hyp_vm() runs during the first KVM_RUN, passing kern_hyp_va(mmu)
without pinning it first might cause a data abort at EL2.
The unmapped pointer is eventually dereferenced in enter_vmid_context():
arch/arm64/kvm/hyp/nvhe/tlb.c:enter_vmid_context() {
...
__load_stage2(mmu);
...
}
arch/arm64/kvm/hyp/nvhe/tlb.c:__load_stage2() {
write_sysreg(mmu->vtcr, vtcr_el2);
...
}
Since this is the exact same sequence described in the commit message (a host
pointer unmapped at EL2 being dereferenced before the first run), should we
also pin the mmu pointer around these TLB flush operations?
>
> static void handle___kvm_flush_vm_context(struct kvm_cpu_context *host_ctxt)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260914113338.159227-1-fuad.tabba@linux.dev?part=3
next prev parent reply other threads:[~2026-09-14 13:01 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 [this message]
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
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=20260914130152.F0D5F1F000FF@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.