* [PATCH] KVM: arm64: Flush HCR_EL2.VSE to deliver SErrors to pKVM guests
@ 2026-05-31 15:45 tabba
2026-06-01 19:16 ` Oliver Upton
0 siblings, 1 reply; 4+ messages in thread
From: tabba @ 2026-05-31 15:45 UTC (permalink / raw)
To: Marc Zyngier, Oliver Upton, Joey Gouly, Suzuki K Poulose,
Zenghui Yu, Catalin Marinas, Will Deacon, Quentin Perret
Cc: linux-arm-kernel, kvmarm, linux-kernel
With pKVM enabled, the host injects a virtual SError by setting
HCR_EL2.VSE on its vCPU copy, but flush_hyp_vcpu() only flows TWI/TWE
into the hyp vCPU that runs, so VSE never reaches it and a deferred
(masked) SError is never delivered. VSE is a host-owned injection
control, not a trap-configuration bit, so restricting the host's
trap-register values should not have dropped it. Flow it on entry;
sync_hyp_vcpu() already copies hcr_el2 back, so delivery is reflected
to the host.
Fixes: b56680de9c648 ("KVM: arm64: Initialize trap register values in hyp in pKVM")
Reported-by: Sashiko (local):gemini-3.1-pro
Signed-off-by: Fuad Tabba <tabba@google.com>
---
Not an urgent fix. I should stop running Sashiko...
---
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
index 06db299c37a8..9e4a20df6409 100644
--- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
+++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
@@ -129,9 +129,14 @@ static void flush_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu)
hyp_vcpu->vcpu.arch.ctxt = host_vcpu->arch.ctxt;
hyp_vcpu->vcpu.arch.mdcr_el2 = host_vcpu->arch.mdcr_el2;
- hyp_vcpu->vcpu.arch.hcr_el2 &= ~(HCR_TWI | HCR_TWE);
+ /*
+ * HCR_EL2.VSE is host-owned (a pending virtual SError to inject), not a
+ * trap-control bit, so it must flow to the hyp vCPU alongside TWI/TWE
+ * for the vSError to be delivered. sync_hyp_vcpu() reflects it back.
+ */
+ hyp_vcpu->vcpu.arch.hcr_el2 &= ~(HCR_TWI | HCR_TWE | HCR_VSE);
hyp_vcpu->vcpu.arch.hcr_el2 |= READ_ONCE(host_vcpu->arch.hcr_el2) &
- (HCR_TWI | HCR_TWE);
+ (HCR_TWI | HCR_TWE | HCR_VSE);
hyp_vcpu->vcpu.arch.iflags = host_vcpu->arch.iflags;
--
2.54.0.929.g9b7fa37559-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] KVM: arm64: Flush HCR_EL2.VSE to deliver SErrors to pKVM guests
2026-05-31 15:45 [PATCH] KVM: arm64: Flush HCR_EL2.VSE to deliver SErrors to pKVM guests tabba
@ 2026-06-01 19:16 ` Oliver Upton
2026-06-01 19:17 ` Fuad Tabba
0 siblings, 1 reply; 4+ messages in thread
From: Oliver Upton @ 2026-06-01 19:16 UTC (permalink / raw)
To: tabba
Cc: Marc Zyngier, Joey Gouly, Suzuki K Poulose, Zenghui Yu,
Catalin Marinas, Will Deacon, Quentin Perret, linux-arm-kernel,
kvmarm, linux-kernel
On Sun, May 31, 2026 at 04:45:48PM +0100, tabba@google.com wrote:
> With pKVM enabled, the host injects a virtual SError by setting
> HCR_EL2.VSE on its vCPU copy, but flush_hyp_vcpu() only flows TWI/TWE
> into the hyp vCPU that runs, so VSE never reaches it and a deferred
> (masked) SError is never delivered. VSE is a host-owned injection
> control, not a trap-configuration bit, so restricting the host's
> trap-register values should not have dropped it. Flow it on entry;
> sync_hyp_vcpu() already copies hcr_el2 back, so delivery is reflected
> to the host.
Might be worth mentioning that flush_hyp_vcpu() also forwards VSESR_EL2
from the host since that bit is _just_ out of context of this diff :)
> Fixes: b56680de9c648 ("KVM: arm64: Initialize trap register values in hyp in pKVM")
> Reported-by: Sashiko (local):gemini-3.1-pro
> Signed-off-by: Fuad Tabba <tabba@google.com>
Reviewed-by: Oliver Upton <oupton@kernel.org>
Thanks,
Oliver
> ---
> Not an urgent fix. I should stop running Sashiko...
> ---
> arch/arm64/kvm/hyp/nvhe/hyp-main.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> index 06db299c37a8..9e4a20df6409 100644
> --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> @@ -129,9 +129,14 @@ static void flush_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu)
> hyp_vcpu->vcpu.arch.ctxt = host_vcpu->arch.ctxt;
>
> hyp_vcpu->vcpu.arch.mdcr_el2 = host_vcpu->arch.mdcr_el2;
> - hyp_vcpu->vcpu.arch.hcr_el2 &= ~(HCR_TWI | HCR_TWE);
> + /*
> + * HCR_EL2.VSE is host-owned (a pending virtual SError to inject), not a
> + * trap-control bit, so it must flow to the hyp vCPU alongside TWI/TWE
> + * for the vSError to be delivered. sync_hyp_vcpu() reflects it back.
> + */
> + hyp_vcpu->vcpu.arch.hcr_el2 &= ~(HCR_TWI | HCR_TWE | HCR_VSE);
> hyp_vcpu->vcpu.arch.hcr_el2 |= READ_ONCE(host_vcpu->arch.hcr_el2) &
> - (HCR_TWI | HCR_TWE);
> + (HCR_TWI | HCR_TWE | HCR_VSE);
>
> hyp_vcpu->vcpu.arch.iflags = host_vcpu->arch.iflags;
>
> --
> 2.54.0.929.g9b7fa37559-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] KVM: arm64: Flush HCR_EL2.VSE to deliver SErrors to pKVM guests
2026-06-01 19:16 ` Oliver Upton
@ 2026-06-01 19:17 ` Fuad Tabba
2026-06-01 19:19 ` Oliver Upton
0 siblings, 1 reply; 4+ messages in thread
From: Fuad Tabba @ 2026-06-01 19:17 UTC (permalink / raw)
To: Oliver Upton
Cc: Marc Zyngier, Joey Gouly, Suzuki K Poulose, Zenghui Yu,
Catalin Marinas, Will Deacon, Quentin Perret, linux-arm-kernel,
kvmarm, linux-kernel
On Mon, 1 Jun 2026 at 20:16, Oliver Upton <oupton@kernel.org> wrote:
>
> On Sun, May 31, 2026 at 04:45:48PM +0100, tabba@google.com wrote:
> > With pKVM enabled, the host injects a virtual SError by setting
> > HCR_EL2.VSE on its vCPU copy, but flush_hyp_vcpu() only flows TWI/TWE
> > into the hyp vCPU that runs, so VSE never reaches it and a deferred
> > (masked) SError is never delivered. VSE is a host-owned injection
> > control, not a trap-configuration bit, so restricting the host's
> > trap-register values should not have dropped it. Flow it on entry;
> > sync_hyp_vcpu() already copies hcr_el2 back, so delivery is reflected
> > to the host.
>
> Might be worth mentioning that flush_hyp_vcpu() also forwards VSESR_EL2
> from the host since that bit is _just_ out of context of this diff :)
Sure, would you like me to respin? Or would one of the maintainers
kindly add that? :)
Cheers,
/fuad
> > Fixes: b56680de9c648 ("KVM: arm64: Initialize trap register values in hyp in pKVM")
> > Reported-by: Sashiko (local):gemini-3.1-pro
> > Signed-off-by: Fuad Tabba <tabba@google.com>
>
> Reviewed-by: Oliver Upton <oupton@kernel.org>
>
> Thanks,
> Oliver
>
> > ---
> > Not an urgent fix. I should stop running Sashiko...
> > ---
> > arch/arm64/kvm/hyp/nvhe/hyp-main.c | 9 +++++++--
> > 1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> > index 06db299c37a8..9e4a20df6409 100644
> > --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> > +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> > @@ -129,9 +129,14 @@ static void flush_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu)
> > hyp_vcpu->vcpu.arch.ctxt = host_vcpu->arch.ctxt;
> >
> > hyp_vcpu->vcpu.arch.mdcr_el2 = host_vcpu->arch.mdcr_el2;
> > - hyp_vcpu->vcpu.arch.hcr_el2 &= ~(HCR_TWI | HCR_TWE);
> > + /*
> > + * HCR_EL2.VSE is host-owned (a pending virtual SError to inject), not a
> > + * trap-control bit, so it must flow to the hyp vCPU alongside TWI/TWE
> > + * for the vSError to be delivered. sync_hyp_vcpu() reflects it back.
> > + */
> > + hyp_vcpu->vcpu.arch.hcr_el2 &= ~(HCR_TWI | HCR_TWE | HCR_VSE);
> > hyp_vcpu->vcpu.arch.hcr_el2 |= READ_ONCE(host_vcpu->arch.hcr_el2) &
> > - (HCR_TWI | HCR_TWE);
> > + (HCR_TWI | HCR_TWE | HCR_VSE);
> >
> > hyp_vcpu->vcpu.arch.iflags = host_vcpu->arch.iflags;
> >
> > --
> > 2.54.0.929.g9b7fa37559-goog
> >
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] KVM: arm64: Flush HCR_EL2.VSE to deliver SErrors to pKVM guests
2026-06-01 19:17 ` Fuad Tabba
@ 2026-06-01 19:19 ` Oliver Upton
0 siblings, 0 replies; 4+ messages in thread
From: Oliver Upton @ 2026-06-01 19:19 UTC (permalink / raw)
To: Fuad Tabba
Cc: Marc Zyngier, Joey Gouly, Suzuki K Poulose, Zenghui Yu,
Catalin Marinas, Will Deacon, Quentin Perret, linux-arm-kernel,
kvmarm, linux-kernel
On Mon, Jun 01, 2026 at 08:17:18PM +0100, Fuad Tabba wrote:
> On Mon, 1 Jun 2026 at 20:16, Oliver Upton <oupton@kernel.org> wrote:
> >
> > On Sun, May 31, 2026 at 04:45:48PM +0100, tabba@google.com wrote:
> > > With pKVM enabled, the host injects a virtual SError by setting
> > > HCR_EL2.VSE on its vCPU copy, but flush_hyp_vcpu() only flows TWI/TWE
> > > into the hyp vCPU that runs, so VSE never reaches it and a deferred
> > > (masked) SError is never delivered. VSE is a host-owned injection
> > > control, not a trap-configuration bit, so restricting the host's
> > > trap-register values should not have dropped it. Flow it on entry;
> > > sync_hyp_vcpu() already copies hcr_el2 back, so delivery is reflected
> > > to the host.
> >
> > Might be worth mentioning that flush_hyp_vcpu() also forwards VSESR_EL2
> > from the host since that bit is _just_ out of context of this diff :)
>
> Sure, would you like me to respin? Or would one of the maintainers
> kindly add that? :)
Marc is kindly dealing with the tree for the time being so hopefully
he can throw it in.
Thanks,
Oliver
> > > Fixes: b56680de9c648 ("KVM: arm64: Initialize trap register values in hyp in pKVM")
> > > Reported-by: Sashiko (local):gemini-3.1-pro
> > > Signed-off-by: Fuad Tabba <tabba@google.com>
> >
> > Reviewed-by: Oliver Upton <oupton@kernel.org>
> >
> > Thanks,
> > Oliver
> >
> > > ---
> > > Not an urgent fix. I should stop running Sashiko...
> > > ---
> > > arch/arm64/kvm/hyp/nvhe/hyp-main.c | 9 +++++++--
> > > 1 file changed, 7 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> > > index 06db299c37a8..9e4a20df6409 100644
> > > --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> > > +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> > > @@ -129,9 +129,14 @@ static void flush_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu)
> > > hyp_vcpu->vcpu.arch.ctxt = host_vcpu->arch.ctxt;
> > >
> > > hyp_vcpu->vcpu.arch.mdcr_el2 = host_vcpu->arch.mdcr_el2;
> > > - hyp_vcpu->vcpu.arch.hcr_el2 &= ~(HCR_TWI | HCR_TWE);
> > > + /*
> > > + * HCR_EL2.VSE is host-owned (a pending virtual SError to inject), not a
> > > + * trap-control bit, so it must flow to the hyp vCPU alongside TWI/TWE
> > > + * for the vSError to be delivered. sync_hyp_vcpu() reflects it back.
> > > + */
> > > + hyp_vcpu->vcpu.arch.hcr_el2 &= ~(HCR_TWI | HCR_TWE | HCR_VSE);
> > > hyp_vcpu->vcpu.arch.hcr_el2 |= READ_ONCE(host_vcpu->arch.hcr_el2) &
> > > - (HCR_TWI | HCR_TWE);
> > > + (HCR_TWI | HCR_TWE | HCR_VSE);
> > >
> > > hyp_vcpu->vcpu.arch.iflags = host_vcpu->arch.iflags;
> > >
> > > --
> > > 2.54.0.929.g9b7fa37559-goog
> > >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-01 19:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-31 15:45 [PATCH] KVM: arm64: Flush HCR_EL2.VSE to deliver SErrors to pKVM guests tabba
2026-06-01 19:16 ` Oliver Upton
2026-06-01 19:17 ` Fuad Tabba
2026-06-01 19:19 ` Oliver Upton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox