Linux s390 Architecture development
 help / color / mirror / Atom feed
From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: Eric Farman <farman@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	David Hildenbrand <david@kernel.org>,
	kvm@vger.kernel.org, linux-s390@vger.kernel.org
Subject: Re: [PATCH v2 2/3] KVM: s390: selftests: Extended user_operexec tests
Date: Fri, 8 May 2026 12:30:09 +0200	[thread overview]
Message-ID: <20260508123009.50b406be@p-imbrenda> (raw)
In-Reply-To: <20260507200836.3500368-3-farman@linux.ibm.com>

On Thu,  7 May 2026 22:08:35 +0200
Eric Farman <farman@linux.ibm.com> wrote:

> There is a possibility that the user_operexec capability
> only works if facility bit 74 is enabled. This is now fixed,
> but add a selftest to demonstrate that.
> 
> Signed-off-by: Eric Farman <farman@linux.ibm.com>

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


> ---
>  .../selftests/kvm/include/s390/facility.h     |   6 +
>  .../selftests/kvm/s390/user_operexec.c        | 110 ++++++++++++++++++
>  2 files changed, 116 insertions(+)
> 
> diff --git a/tools/testing/selftests/kvm/include/s390/facility.h b/tools/testing/selftests/kvm/include/s390/facility.h
> index 41a265742666..e5259f63be22 100644
> --- a/tools/testing/selftests/kvm/include/s390/facility.h
> +++ b/tools/testing/selftests/kvm/include/s390/facility.h
> @@ -11,6 +11,7 @@
>  #ifndef SELFTEST_KVM_FACILITY_H
>  #define SELFTEST_KVM_FACILITY_H
>  
> +#include <linux/atomic.h>
>  #include <linux/bitops.h>
>  
>  /* alt_stfle_fac_list[16] + stfle_fac_list[16] */
> @@ -19,6 +20,11 @@
>  extern u64 stfl_doublewords[NB_STFL_DOUBLEWORDS];
>  extern bool stfle_flag;
>  
> +static inline bool clear_bit_inv(unsigned long nr, unsigned long *ptr)
> +{
> +	return clear_bit(nr ^ (BITS_PER_LONG - 1), ptr);
> +}
> +
>  static inline bool test_bit_inv(unsigned long nr, const unsigned long *ptr)
>  {
>  	return test_bit(nr ^ (BITS_PER_LONG - 1), ptr);
> diff --git a/tools/testing/selftests/kvm/s390/user_operexec.c b/tools/testing/selftests/kvm/s390/user_operexec.c
> index 714906c1d12a..b24c1f9dbbe8 100644
> --- a/tools/testing/selftests/kvm/s390/user_operexec.c
> +++ b/tools/testing/selftests/kvm/s390/user_operexec.c
> @@ -6,6 +6,7 @@
>   * Authors:
>   *  Janosch Frank <frankja@linux.ibm.com>
>   */
> +#include "facility.h"
>  #include "kselftest.h"
>  #include "kvm_util.h"
>  #include "test_util.h"
> @@ -109,6 +110,111 @@ static void test_user_operexec_combined(void)
>  	kvm_vm_free(vm);
>  }
>  
> +static struct kvm_vm *create_vm_without_sthyi(void)
> +{
> +	struct kvm_s390_vm_cpu_processor info;
> +	struct kvm_vm *vm;
> +
> +	vm = vm_create(1);
> +
> +	kvm_device_attr_get(vm->fd, KVM_S390_VM_CPU_MODEL,
> +			    KVM_S390_VM_CPU_PROCESSOR, &info);
> +
> +	clear_bit_inv(74, (unsigned long *)&info.fac_list);
> +	kvm_device_attr_set(vm->fd, KVM_S390_VM_CPU_MODEL,
> +			    KVM_S390_VM_CPU_PROCESSOR, &info);
> +
> +	return vm;
> +}
> +
> +static void test_user_instr0_no_stfle_74(void)
> +{
> +	struct kvm_vcpu *vcpu;
> +	struct kvm_vm *vm;
> +	int rc;
> +
> +	vm = create_vm_without_sthyi();
> +
> +	rc = __vm_enable_cap(vm, KVM_CAP_S390_USER_INSTR0, 0);
> +	TEST_ASSERT_EQ(0, rc);
> +
> +	vcpu = vm_vcpu_add(vm, 0, guest_code_instr0);
> +
> +	vcpu_run(vcpu);
> +	TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_S390_SIEIC);
> +	TEST_ASSERT_EQ(vcpu->run->s390_sieic.icptcode, ICPT_OPEREXC);
> +	TEST_ASSERT_EQ(vcpu->run->s390_sieic.ipa, 0x0000);
> +
> +	kvm_vm_free(vm);
> +}
> +
> +static void test_user_operexec_no_stfle_74(void)
> +{
> +	struct kvm_vcpu *vcpu;
> +	struct kvm_vm *vm;
> +	int rc;
> +
> +	vm = create_vm_without_sthyi();
> +
> +	rc = __vm_enable_cap(vm, KVM_CAP_S390_USER_OPEREXEC, 0);
> +	TEST_ASSERT_EQ(0, rc);
> +
> +	vcpu = vm_vcpu_add(vm, 0, guest_code_user_operexec);
> +
> +	vcpu_run(vcpu);
> +	TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_S390_SIEIC);
> +	TEST_ASSERT_EQ(vcpu->run->s390_sieic.icptcode, ICPT_OPEREXC);
> +	TEST_ASSERT_EQ(vcpu->run->s390_sieic.ipa, 0x0807);
> +
> +	kvm_vm_free(vm);
> +}
> +
> +static void test_instr0_combined_no_stfle_74(void)
> +{
> +	struct kvm_vcpu *vcpu;
> +	struct kvm_vm *vm;
> +	int rc;
> +
> +	vm = create_vm_without_sthyi();
> +
> +	rc = __vm_enable_cap(vm, KVM_CAP_S390_USER_INSTR0, 0);
> +	TEST_ASSERT_EQ(0, rc);
> +	rc = __vm_enable_cap(vm, KVM_CAP_S390_USER_OPEREXEC, 0);
> +	TEST_ASSERT_EQ(0, rc);
> +
> +	vcpu = vm_vcpu_add(vm, 0, guest_code_instr0);
> +
> +	vcpu_run(vcpu);
> +	TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_S390_SIEIC);
> +	TEST_ASSERT_EQ(vcpu->run->s390_sieic.icptcode, ICPT_OPEREXC);
> +	TEST_ASSERT_EQ(vcpu->run->s390_sieic.ipa, 0x0000);
> +
> +	kvm_vm_free(vm);
> +}
> +
> +static void test_operexec_combined_no_stfle_74(void)
> +{
> +	struct kvm_vcpu *vcpu;
> +	struct kvm_vm *vm;
> +	int rc;
> +
> +	vm = create_vm_without_sthyi();
> +
> +	rc = __vm_enable_cap(vm, KVM_CAP_S390_USER_INSTR0, 0);
> +	TEST_ASSERT_EQ(0, rc);
> +	rc = __vm_enable_cap(vm, KVM_CAP_S390_USER_OPEREXEC, 0);
> +	TEST_ASSERT_EQ(0, rc);
> +
> +	vcpu = vm_vcpu_add(vm, 0, guest_code_user_operexec);
> +
> +	vcpu_run(vcpu);
> +	TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_S390_SIEIC);
> +	TEST_ASSERT_EQ(vcpu->run->s390_sieic.icptcode, ICPT_OPEREXC);
> +	TEST_ASSERT_EQ(vcpu->run->s390_sieic.ipa, 0x0807);
> +
> +	kvm_vm_free(vm);
> +}
> +
>  /*
>   * Run all tests above.
>   *
> @@ -122,6 +228,10 @@ static struct testdef {
>  	{ "instr0", test_user_instr0 },
>  	{ "operexec", test_user_operexec },
>  	{ "operexec_combined", test_user_operexec_combined},
> +	{ "instr0_no_stfle_74", test_user_instr0_no_stfle_74 },
> +	{ "instr0_combined_no_stfle_74", test_instr0_combined_no_stfle_74 },
> +	{ "operexec_combined_no_stfle_74", test_operexec_combined_no_stfle_74 },
> +	{ "operexec_no_stfle_74", test_user_operexec_no_stfle_74 },
>  };
>  
>  int main(int argc, char *argv[])


  parent reply	other threads:[~2026-05-08 13:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-07 20:08 [PATCH v2 0/3] KVM: s390: Toggle operation exception for userspace Eric Farman
2026-05-07 20:08 ` [PATCH v2 1/3] " Eric Farman
2026-05-08  9:54   ` Christian Borntraeger
2026-05-11  8:01   ` Janosch Frank
2026-05-11  8:08   ` Janosch Frank
2026-05-11 12:56     ` Eric Farman
2026-05-07 20:08 ` [PATCH v2 2/3] KVM: s390: selftests: Extended user_operexec tests Eric Farman
2026-05-08 10:05   ` Christian Borntraeger
2026-05-08 10:30   ` Claudio Imbrenda [this message]
2026-05-11  8:04   ` Janosch Frank
2026-05-07 20:08 ` [PATCH v2 3/3] KVM: s390: Fix typo in UCONTROL documentation Eric Farman
2026-05-08 10:29   ` Claudio Imbrenda
2026-05-11 10:59   ` Hendrik Brueckner
2026-05-08 10:07 ` [PATCH v2 0/3] KVM: s390: Toggle operation exception for userspace Christian Borntraeger
2026-05-08 13:08   ` Eric Farman
2026-05-08 14:50 ` Christian Borntraeger

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=20260508123009.50b406be@p-imbrenda \
    --to=imbrenda@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=david@kernel.org \
    --cc=farman@linux.ibm.com \
    --cc=frankja@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    /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