From: Dan Carpenter <dan@pereq.eu>
To: Oliver Upton <oupton@kernel.org>
Cc: sashiko-reviews@lists.linux.dev, kvmarm@lists.linux.dev,
kvm@vger.kernel.org, Marc Zyngier <maz@kernel.org>
Subject: Re: [PATCH v2 6/8] KVM: arm64: nv: Don't deliver a pending SError to the wrong guest
Date: Wed, 25 Nov 2026 14:11:01 +0300 [thread overview]
Message-ID: <awbCRenrEfnRszC_@stanley.mountain> (raw)
In-Reply-To: <awaWhy3IywYrP2JZ@kernel.org>
On Wed, Nov 25, 2026 at 12:04:23AM -0800, Oliver Upton wrote:
> >
> > [Severity: High]
> > Can stashing NESTED_SERROR_PENDING here cause sleeping in atomic context
> > on the next guest entry when a virtual PMU counter is active?
> >
> > When L1 has a masked pending SError in HCR_EL2_VSE with HCR_EL2.AMO set
> > and executes ERET into L2, setting NESTED_SERROR_PENDING causes the next
> > iteration of kvm_arch_vcpu_ioctl_run() to re-inject the SError back to
> > vEL2 while preemption is disabled:
> >
> > kvm_arch_vcpu_ioctl_run()
> > preempt_disable()
> > kvm_nested_flush_hwstate()
> > kvm_inject_serror_esr()
> > kvm_inject_nested_serror()
> > kvm_inject_nested()
> > preempt_disable()
> > ...
> > preempt_enable()
> > kvm_pmu_nested_transition()
> > kvm_pmu_create_perf_event()
>
> The PMU crap should probably go in a vCPU request to avoid this.
Claude is happy to write a commit to do that... I can add that to
v3.
regards,
dan carpenter
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 0614c3b3a40d..6a22156c9107 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -62,6 +62,7 @@
#define KVM_REQ_MAP_L1_VNCR_EL2 KVM_ARCH_REQ(10)
#define KVM_REQ_VGIC_PROCESS_UPDATE KVM_ARCH_REQ(11)
#define KVM_REQ_RELOAD_GICv5 KVM_ARCH_REQ(12)
+#define KVM_REQ_NESTED_PMU_TRANSITION KVM_ARCH_REQ(13)
/* Bit indices for kvm_arch::flags */
enum {
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index a148e80d0aef..fe5e4e47b935 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -1310,6 +1310,9 @@ static int check_vcpu_requests(struct kvm_vcpu *vcpu)
return 0;
check_nested_vcpu_requests(vcpu);
+
+ if (kvm_check_request(KVM_REQ_NESTED_PMU_TRANSITION, vcpu))
+ kvm_pmu_nested_transition(vcpu);
}
return 1;
diff --git a/arch/arm64/kvm/emulate-nested.c b/arch/arm64/kvm/emulate-nested.c
index 39136a89d74b..ee71dfc4b861 100644
--- a/arch/arm64/kvm/emulate-nested.c
+++ b/arch/arm64/kvm/emulate-nested.c
@@ -2837,7 +2837,7 @@ void kvm_emulate_nested_eret(struct kvm_vcpu *vcpu)
preempt_enable();
if (kvm_vcpu_has_pmu(vcpu))
- kvm_pmu_nested_transition(vcpu);
+ kvm_make_request(KVM_REQ_NESTED_PMU_TRANSITION, vcpu);
}
static void kvm_inject_el2_exception(struct kvm_vcpu *vcpu, u64 esr_el2,
@@ -2929,7 +2929,7 @@ static int kvm_inject_nested(struct kvm_vcpu *vcpu, u64 esr_el2,
preempt_enable();
if (kvm_vcpu_has_pmu(vcpu))
- kvm_pmu_nested_transition(vcpu);
+ kvm_make_request(KVM_REQ_NESTED_PMU_TRANSITION, vcpu);
return 1;
}
next prev parent reply other threads:[~2026-11-25 11:11 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 6:56 [PATCH v2 0/8] KVM: arm64: Fix kvm_reset_vcpu() and SError handling for nested virt Dan Carpenter
2026-11-25 6:56 ` [PATCH v2 1/8] KVM: arm64: Drop an incomplete MMIO access when resetting a vcpu Dan Carpenter
2026-11-25 6:56 ` [PATCH v2 2/8] KVM: arm64: Reset SP_EL1, ELR_EL1 and SPSR_EL1 " Dan Carpenter
2026-11-25 7:15 ` sashiko-bot
2026-11-25 9:14 ` Dan Carpenter
2026-11-25 9:18 ` Dan Carpenter
2026-11-26 13:37 ` Steffen Eiden
2026-11-26 14:04 ` Dan Carpenter
2026-11-25 9:08 ` Suzuki K Poulose
2026-11-25 9:32 ` Dan Carpenter
2026-11-25 6:56 ` [PATCH v2 3/8] KVM: arm64: Discard a pending SError " Dan Carpenter
2026-11-25 6:56 ` [PATCH v2 4/8] KVM: arm64: nv: Discard nested SError in kvm_reset_vcpu() Dan Carpenter
2026-11-25 6:56 ` [PATCH v2 5/8] KVM: arm64: nv: Replace a pending SError when injecting a new one Dan Carpenter
2026-11-25 8:00 ` Oliver Upton
2026-11-25 9:51 ` Dan Carpenter
2026-11-25 6:56 ` [PATCH v2 6/8] KVM: arm64: nv: Don't deliver a pending SError to the wrong guest Dan Carpenter
2026-11-25 7:24 ` sashiko-bot
2026-11-25 8:04 ` Oliver Upton
2026-11-25 11:11 ` Dan Carpenter [this message]
2026-11-25 11:05 ` Dan Carpenter
2026-11-25 6:56 ` [PATCH v2 7/8] KVM: arm64: nv: Re-inject a stored SError after the exit is handled Dan Carpenter
2026-11-25 6:56 ` [PATCH v2 8/8] KVM: arm64: selftests: Test that a vcpu reset clears the vcpu's state 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=awbCRenrEfnRszC_@stanley.mountain \
--to=dan@pereq.eu \
--cc=kvm@vger.kernel.org \
--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