public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: s390: Toggle operation exception for userspace
@ 2026-05-05 20:45 Eric Farman
  2026-05-06 13:19 ` Claudio Imbrenda
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Farman @ 2026-05-05 20:45 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank, Claudio Imbrenda,
	David Hildenbrand
  Cc: kvm, linux-s390, Eric Farman

The KVM_CAP_S390_USER_OPEREXEC capability allows operation exceptions
to be forwarded to userspace. But the actual enablement at the hardware
level occurs in kvm_arch_vcpu_postcreate(), and only if STFLE.74 or
user_instr0 are enabled. The latter is associated with a separate
capability (KVM_CAP_S390_USER_INSTR0), so the only way this happens
for the USER_OPEREXEC capability is if STFLE.74 is enabled. KVM
unconditionally enables this bit in kvm_arch_init_vm(), but the guest
could disable it from the CPU model and thus ignore this capability.

Add USER_OPEREXEC to the check in kvm_arch_vcpu_postcreate(), such that
either capability would enable this type of exception.

Fixes: 8e8678e740ec ("KVM: s390: Add capability that forwards operation exceptions")
Signed-off-by: Eric Farman <farman@linux.ibm.com>
---
 arch/s390/kvm/kvm-s390.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index e09960c2e6ed..a91a42174302 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -3521,7 +3521,8 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
 		vcpu->arch.gmap = vcpu->kvm->arch.gmap;
 		sca_add_vcpu(vcpu);
 	}
-	if (test_kvm_facility(vcpu->kvm, 74) || vcpu->kvm->arch.user_instr0)
+	if (test_kvm_facility(vcpu->kvm, 74) || vcpu->kvm->arch.user_instr0 ||
+	    vcpu->kvm->arch.user_operexec)
 		vcpu->arch.sie_block->ictl |= ICTL_OPEREXC;
 }
 
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: s390: Toggle operation exception for userspace
  2026-05-05 20:45 [PATCH] KVM: s390: Toggle operation exception for userspace Eric Farman
@ 2026-05-06 13:19 ` Claudio Imbrenda
  2026-05-06 13:55   ` Eric Farman
  0 siblings, 1 reply; 3+ messages in thread
From: Claudio Imbrenda @ 2026-05-06 13:19 UTC (permalink / raw)
  To: Eric Farman
  Cc: Christian Borntraeger, Janosch Frank, David Hildenbrand, kvm,
	linux-s390

On Tue,  5 May 2026 22:45:21 +0200
Eric Farman <farman@linux.ibm.com> wrote:

> The KVM_CAP_S390_USER_OPEREXEC capability allows operation exceptions
> to be forwarded to userspace. But the actual enablement at the hardware
> level occurs in kvm_arch_vcpu_postcreate(), and only if STFLE.74 or
> user_instr0 are enabled. The latter is associated with a separate
> capability (KVM_CAP_S390_USER_INSTR0), so the only way this happens
> for the USER_OPEREXEC capability is if STFLE.74 is enabled. KVM
> unconditionally enables this bit in kvm_arch_init_vm(), but the guest
> could disable it from the CPU model and thus ignore this capability.
> 
> Add USER_OPEREXEC to the check in kvm_arch_vcpu_postcreate(), such
> that either capability would enable this type of exception.
> KVM_CAP_S390_USER_INSTR0
> Fixes: 8e8678e740ec ("KVM: s390: Add capability that forwards
> operation exceptions") Signed-off-by: Eric Farman
> <farman@linux.ibm.com>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

can you also extend the existing selftest for KVM_CAP_S390_USER_OPEREXEC
to also properly test with all combinations of
STFLE.74 / KVM_CAP_S390_USER_OPEREXEC / KVM_CAP_S390_USER_INSTR0

> ---
>  arch/s390/kvm/kvm-s390.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index e09960c2e6ed..a91a42174302 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -3521,7 +3521,8 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
>  		vcpu->arch.gmap = vcpu->kvm->arch.gmap;
>  		sca_add_vcpu(vcpu);
>  	}
> -	if (test_kvm_facility(vcpu->kvm, 74) || vcpu->kvm->arch.user_instr0)
> +	if (test_kvm_facility(vcpu->kvm, 74) || vcpu->kvm->arch.user_instr0 ||
> +	    vcpu->kvm->arch.user_operexec)
>  		vcpu->arch.sie_block->ictl |= ICTL_OPEREXC;
>  }
>  


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: s390: Toggle operation exception for userspace
  2026-05-06 13:19 ` Claudio Imbrenda
@ 2026-05-06 13:55   ` Eric Farman
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Farman @ 2026-05-06 13:55 UTC (permalink / raw)
  To: Claudio Imbrenda
  Cc: Christian Borntraeger, Janosch Frank, David Hildenbrand, kvm,
	linux-s390

On Wed, 2026-05-06 at 15:19 +0200, Claudio Imbrenda wrote:
> On Tue,  5 May 2026 22:45:21 +0200
> Eric Farman <farman@linux.ibm.com> wrote:
> 
> > The KVM_CAP_S390_USER_OPEREXEC capability allows operation exceptions
> > to be forwarded to userspace. But the actual enablement at the hardware
> > level occurs in kvm_arch_vcpu_postcreate(), and only if STFLE.74 or
> > user_instr0 are enabled. The latter is associated with a separate
> > capability (KVM_CAP_S390_USER_INSTR0), so the only way this happens
> > for the USER_OPEREXEC capability is if STFLE.74 is enabled. KVM
> > unconditionally enables this bit in kvm_arch_init_vm(), but the guest
> > could disable it from the CPU model and thus ignore this capability.
> > 
> > Add USER_OPEREXEC to the check in kvm_arch_vcpu_postcreate(), such
> > that either capability would enable this type of exception.
> > KVM_CAP_S390_USER_INSTR0
> > Fixes: 8e8678e740ec ("KVM: s390: Add capability that forwards
> > operation exceptions") Signed-off-by: Eric Farman
> > <farman@linux.ibm.com>
> 
> Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> 
> can you also extend the existing selftest for KVM_CAP_S390_USER_OPEREXEC
> to also properly test with all combinations of
> STFLE.74 / KVM_CAP_S390_USER_OPEREXEC / KVM_CAP_S390_USER_INSTR0

Ah, of course. Will do.

> 
> > ---
> >  arch/s390/kvm/kvm-s390.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> > index e09960c2e6ed..a91a42174302 100644
> > --- a/arch/s390/kvm/kvm-s390.c
> > +++ b/arch/s390/kvm/kvm-s390.c
> > @@ -3521,7 +3521,8 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
> >  		vcpu->arch.gmap = vcpu->kvm->arch.gmap;
> >  		sca_add_vcpu(vcpu);
> >  	}
> > -	if (test_kvm_facility(vcpu->kvm, 74) || vcpu->kvm->arch.user_instr0)
> > +	if (test_kvm_facility(vcpu->kvm, 74) || vcpu->kvm->arch.user_instr0 ||
> > +	    vcpu->kvm->arch.user_operexec)
> >  		vcpu->arch.sie_block->ictl |= ICTL_OPEREXC;
> >  }
> >  

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-06 13:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-05 20:45 [PATCH] KVM: s390: Toggle operation exception for userspace Eric Farman
2026-05-06 13:19 ` Claudio Imbrenda
2026-05-06 13:55   ` Eric Farman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox