KVM: s390: selftests: Add selftests for KVM exits on s390x
cover KVM: s390: selftests: Add selftests for KVM exits on s390x
This series adds a selftest for the exits that KVM reports to userspace on s390x, mainly KVM_EXIT_S390_SIEIC. The existing s390 selftests do not check what userspace sees when a guest causes an intercept, for example a DIAG, a SIGP order, a program exception or a wait state.
The tests checks the intercept code, the instruction and program data, and the register state reported in struct kvm_run.
The series is split so that every patch adds tests on top of the previous one:
1: test harness and instruction intercepts (DIAG 0x500 and 0x501) 2: SIGP stop and program exceptions (addressing, segment translation) 3: wait state and VM create/destroy
4: ucontrol helpers, STSI, TSCH and STSCH intercepts
5: ucontrol storage key (KSS) and immediate_exit
6: clock comparator interrupt on a ucontrol VM
The ucontrol tests require KVM_CAP_S390_UCONTROL and CAP_SYS_ADMIN, and the storage key test also requires CPUSTAT_KSS. When one of these is missing, only the affected tests are skipped, with a reason, and the others still run.
These tests were co-developed with Nitya Khamar <[email protected]>
Testing: built with "make -C tools/testing/selftests/kvm ARCH=s390" and ran on a s390x z15 lpar with CONFIG_KVM_S390_UCONTROL=y
as root: pass:13 fail:0 skip:0
as unprivileged: pass:8 fail:0 skip:5 (the five ucontrol tests)
Aaron M. Brown (6):
KVM: s390: selftests: Add kvm_exit test for instruction intercepts
KVM: s390: selftests: Add SIGP and program exception tests
KVM: s390: selftests: Add wait state and VM lifecycle tests
KVM: s390: selftests: Add ucontrol helpers and instruction tests
KVM: s390: selftests: Add ucontrol storage key and immediate exit
tests
KVM: s390: selftests: Add clock comparator interrupt test
tools/testing/selftests/kvm/Makefile.kvm | 1 + .../kvm/include/s390/kvm_lifecycle.h | 43 + tools/testing/selftests/kvm/s390/kvm_exit.c | 835 ++++++++++++++++++ 3 files changed, 879 insertions(+) create mode 100644 tools/testing/selftests/kvm/include/s390/kvm_lifecycle.h create mode 100644 tools/testing/selftests/kvm/s390/kvm_exit.c
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4 --
2.50.1 (Apple Git-155)
PATCH 1/6 KVM: s390: selftests: Add kvm_exit test for instruction intercepts
Add a selftest for the exits KVM reports to userspace on s390x, mainly KVM_EXIT_S390_SIEIC. This patch adds the harness and the instruction intercept tests:
- DIAG 0x500: inject an external call, check it is pending, resume, and compare the registers with those synced in kvm_run.
- DIAG 0x501: check the opcode and diagnose code in ipa and ipb.
- DIAG 0x501 with registers set beforehand: check they are intact.
--- tools/testing/selftests/kvm/Makefile.kvm | 1 + .../kvm/include/s390/kvm_lifecycle.h | 35 +++ tools/testing/selftests/kvm/s390/kvm_exit.c | 212 ++++++++++++++++++ 3 files changed, 248 insertions(+) create mode 100644 tools/testing/selftests/kvm/include/s390/kvm_lifecycle.h create mode 100644 tools/testing/selftests/kvm/s390/kvm_exit.c
tools/testing/selftests/kvm/Makefile.kvm +1 -0
@@ -232,6 +232,7 @@ TEST_GEN_PROGS_s390 += s390/irq_routing TEST_GEN_PROGS_s390 += mmu_stress_test TEST_GEN_PROGS_s390 += pre_fault_memory_test TEST_GEN_PROGS_s390 += s390/irq_injection +TEST_GEN_PROGS_s390 += s390/kvm_exit TEST_GEN_PROGS_riscv = $(TEST_GEN_PROGS_COMMON) TEST_GEN_PROGS_riscv += riscv/sbi_pmu_test
tools/testing/selftests/kvm/include/s390/kvm_lifecycle.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Definition of structs for KVM lifecycle tests. +* +* Copyright IBM Corp. 2026 +* +* Authors: +* Nitya Khamar ([email protected]) +* Aaron Malik Brown ([email protected]) +*/ +#ifndef SELFTEST_KVM_LIFECYCLE_H +#define SELFTEST_KVM_LIFECYCLE_H + +#include "kvm_util.h" +#include <stdbool.h> + +struct kvm_lifecycle_testdef { +const char *name; +bool (*test)(void ); +}; + +struct kvm_parameters { +struct kvm_vm *vm; +struct kvm_vcpu *vcpu; +void *guest_code; +struct kvm_run *run; +unsigned int interrupt_type; +struct kvm_s390_irq *irq; +struct kvm_s390_irq_state *irq_state; +struct { +bool immediate_exit_condition; + } manual_parameters; +}; + +#endif /* SELFTEST_KVM_LIFECYCLE_H */
tools/testing/selftests/kvm/s390/kvm_exit.c new file +212 -0
212 lines not on this page · raw message
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH 2/6 KVM: s390: selftests: Add SIGP and program exception tests
In reply to Aaron M. BrownAdd tests for:
- SIGP: a second vCPU stops vCPU 0. Both vCPUs are set to operating first, as KVM ignores a stop order sent to a stopped vCPU. Check for ICPT_STOP.
- Addressing exception (DAT off): check for program code 0x05.
- Segment translation exception (DAT on): check for program code 0x10.
The program new PSW is set to a disabled wait so the guest exits deterministically.
--- tools/testing/selftests/kvm/s390/kvm_exit.c | 146 ++++++++++++++++++++ 1 file changed, 146 insertions(+)
tools/testing/selftests/kvm/s390/kvm_exit.c +146 -0
@@ -25,6 +25,12 @@#define NUM_GPRS 16#define DIAG_ASSEMBLY_CODE 0x501#define IPA_DIAG 0x83 +#define PSW_MASK_64BIT_DAT_OFF 0x0000000180000000ULL +#define PGM_CODE_SEGMENT_TRANSLATION 0x10 +#define PGM_CODE_GPA_ADDRESS 0x8e +#define PGM_CODE_MASK 0x7f +#define PGM_NEW_PSW_GPA 0x1d0 +#define PSW_DISABLED_WAIT 0x0002000180000000ULLstatic struct kvm_parameters create_vm_kvm_exit (struct kvm_parameters parameters) {
@@ -174,6 +180,134 @@ static bool test_diagnose_conditional_code(void)return true; } +/* +* Make a program interrupt end in a disabled wait, which KVM reports to +* userspace as ICPT_WAIT. This does not depend on how KVM handles +* repeated operation exceptions. +*/ +static void set_pgm_new_psw_disabled_wait (struct kvm_vm *vm) +{ +uint64_t *new_psw =addr_gpa2hva (vm,PGM_NEW_PSW_GPA ); + + new_psw[0 ] =PSW_DISABLED_WAIT ; + new_psw[1 ] =0 ; +} + +static void guestcode_sigp (void ) +{ + asmvolatile ( +"lghi %%r3, 0\n" +"sigp %%r1, %%r3, 0x05\n" + : + : + :"r1" ,"r3" + ); +GUEST_DONE (); +} + +static bool test_sigp_signals (void ) +{ +struct kvm_parameters param = { + .guest_code = guestcode_sigp, + .manual_parameters.immediate_exit_condition = false, + }; +struct kvm_mp_state mp_state = { .mp_state =KVM_MP_STATE_OPERATING }; +struct kvm_vcpu *vcpu1; +struct kvm_regs regs; + +ksft_print_msg ("Testing SIGP KVM Exit\n" ); + param =create_vm_kvm_exit (param); + vcpu1 =vm_vcpu_add (param.vm,1 , guestcode_sigp); +/* New vCPUs are stopped, and KVM ignores a SIGP STOP sent to one */ +vcpu_mp_state_set (param.vcpu, &mp_state); +vcpu_mp_state_set (vcpu1, &mp_state); +vcpu_regs_get (param.vcpu, ®s); + regs.gprs[3 ] =0x3333 ; +vcpu_regs_set (param.vcpu, ®s); +vcpu_run (vcpu1); +/* vcpu1 exits after GUEST_DONE() ucall */ +TEST_ASSERT_KVM_EXIT_REASON (vcpu1,KVM_EXIT_S390_SIEIC ); +vcpu_run (param.vcpu); + param.run = param.vcpu->run; +TEST_ASSERT_KVM_EXIT_REASON (param.vcpu,KVM_EXIT_S390_SIEIC ); +TEST_ASSERT_EQ (param.run->s390_sieic.icptcode,ICPT_STOP ); +/* +* The pending SIGP STOP stops vcpu0 before it runs any guest code +* (the guest would clear r3), so r3 keeps the marker value. +*/ +TEST_ASSERT_EQ (param.run->s.regs.gprs[3 ],0x3333 ); +cleanup_kvm (¶m); +return true; +} + +static void guestcode_address_exception (void ) +{ + asmvolatile ( +"lghi %%r1, 0x1\n" +"sllg %%r1, %%r1, 0x28\n" +"lg %%r2, 0(%%r1)\n" + : + : + :"r1" ,"r2" + ); +} + +static bool test_address_exceptions (void ) +{ +struct kvm_parameters param = {}; +uint16_t pgm_code; + +ksft_print_msg ("Testing Address Exception Exit\n" ); + param.guest_code = guestcode_address_exception; + param =create_vm_kvm_exit (param); +set_pgm_new_psw_disabled_wait (param.vm); + param.vcpu->run->psw_mask &=PSW_MASK_64BIT_DAT_OFF ; +/* The guest runs with DAT off, so the entry point must be a GPA */ + param.vcpu->run->psw_addr =addr_gva2gpa (param.vm, param.vcpu->run->psw_addr); + param.vcpu->run->kvm_dirty_regs |=KVM_SYNC_ARCH0 ; +vcpu_run (param.vcpu); + param.run = param.vcpu->run; +TEST_ASSERT_KVM_EXIT_REASON (param.vcpu,KVM_EXIT_S390_SIEIC ); +TEST_ASSERT_EQ (param.run->s390_sieic.icptcode,ICPT_WAIT ); + pgm_code = *(uint16_t *)addr_gpa2hva (param.vm,PGM_CODE_GPA_ADDRESS ); +TEST_ASSERT ((pgm_code &PGM_CODE_MASK ) ==0x05 , +"Expected PGM code 0x05 (addressing), got 0x%x\n" , pgm_code); +cleanup_kvm (¶m); +return true; +} + +static void guestcode_translation_exception (void ) +{ + asmvolatile ( +"lghi %%r1, 0x1\n" +"sllg %%r1, %%r1, 0x14\n" +"lg %%r2, 0(%%r1)\n" + : + : + :"r1" ,"r2" + ); +} + +static bool test_translation_exceptions (void ) +{ +struct kvm_parameters param = {}; +uint16_t pgm_code; + +ksft_print_msg ("Testing Translation Exception KVM Exit\n" ); + param.guest_code = guestcode_translation_exception; + param =create_vm_kvm_exit (param); +set_pgm_new_psw_disabled_wait (param.vm); +vcpu_run (param.vcpu); + param.run = param.vcpu->run; +TEST_ASSERT_KVM_EXIT_REASON (param.vcpu,KVM_EXIT_S390_SIEIC ); +TEST_ASSERT_EQ (param.run->s390_sieic.icptcode,ICPT_WAIT ); + pgm_code = *(uint16_t *)addr_gpa2hva (param.vm,PGM_CODE_GPA_ADDRESS ); +TEST_ASSERT ((pgm_code &PGM_CODE_MASK ) ==PGM_CODE_SEGMENT_TRANSLATION , +"Expected PGM code 0x10 (segment translation), got 0x%x\n" , pgm_code); +cleanup_kvm (¶m); +return true; +} +static void test (void ) {int i;
@@ -190,6 +324,18 @@ static void test(void) .name = "Testing Conditional DIAG Code", .test = test_diagnose_conditional_code, }, + { + .name = "Testing SIGP Exits", + .test = test_sigp_signals, + }, + { + .name = "Testing Address Exceptions", + .test = test_address_exceptions, + }, + { + .name = "Testing Translation Exceptions", + .test = test_translation_exceptions, + }, }; ksft_print_header();
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH 3/6 KVM: s390: selftests: Add wait state and VM lifecycle tests
In reply to Aaron M. BrownAdd two tests:
- Wait state: the guest loads a PSW with the wait bit (bit 14) set and the I/O, external and machine-check masks (bits 6, 7, 13) clear. Check for ICPT_WAIT and the wait bit in the PSW.
- VM create and destroy: before the first KVM_RUN, check that exit_reason is KVM_EXIT_UNKNOWN and immediate_exit is clear.
--- tools/testing/selftests/kvm/s390/kvm_exit.c | 78 +++++++++++++++++++++ 1 file changed, 78 insertions(+)
tools/testing/selftests/kvm/s390/kvm_exit.c +78 -0
@@ -27,6 +27,7 @@#define IPA_DIAG 0x83#define PSW_MASK_64BIT_DAT_OFF 0x0000000180000000ULL#define PGM_CODE_SEGMENT_TRANSLATION 0x10 +#define PSW_WAIT_BIT_MASK (1ULL << (63 - 14))#define PGM_CODE_GPA_ADDRESS 0x8e#define PGM_CODE_MASK 0x7f#define PGM_NEW_PSW_GPA 0x1d0
@@ -308,6 +309,75 @@ static bool test_translation_exceptions(void)return true; } +static uint64_t psw_save[2 ]__aligned(16) ; + +static void guestcode_wait_state (void ) +{ + register uint64_t *psw_ptr asm("r4") = psw_save; + + asmvolatile ( +"lghi %%r3, 0x3333\n" +"lgrl %%r7, 1f\n" +"stg %%r7, 0(%%r4)\n" +"xgr %%r5, %%r5\n" +"stg %%r5, 8(%%r4)\n" +"lpswe 0(%%r4)\n" +".align 8\n" +"1: .quad 0x0002000180000000\n" + : + :"d" (psw_ptr) + :"r3" ,"r5" ,"r7" ,"memory" + ); +} + +static bool test_wait_state (void ) +{ +struct kvm_parameters param = {}; +struct kvm_regs regs; + +ksft_print_msg ("Testing Wait State Exit\n" ); + param.guest_code = guestcode_wait_state; + param =create_vm_kvm_exit (param); +vcpu_run (param.vcpu); + param.run = param.vcpu->run; +TEST_ASSERT (param.run->exit_reason ==KVM_EXIT_S390_SIEIC , +"Expected KVM_EXIT_S390_SIEIC, got %u\n" , + param.run->exit_reason); +TEST_ASSERT (param.run->s390_sieic.icptcode ==ICPT_WAIT , +"Failed with Unexpected Exit Reason of %u and icptcode of 0x%x\n" , + param.run->exit_reason, param.run->s390_sieic.icptcode); +vcpu_regs_get (param.vcpu, ®s); +TEST_ASSERT (regs.gprs[3 ] ==0x3333 , +"Expected 0x3333 but got 0x%llx\n" , regs.gprs[3 ]); +/* Check PSW wait bit (bit 14 from MSB = bit 63-14 from LSB) */ +TEST_ASSERT ((param.run->psw_mask &PSW_WAIT_BIT_MASK ) !=0 , +"PSW wait bit not set, PSW Mask = 0x%llx\n" , + param.run->psw_mask); +cleanup_kvm (¶m); +return true; +} + +static void guestcode_nop (void ) +{ +GUEST_DONE (); +} + +static bool test_vm_create_and_destroy (void ) +{ +struct kvm_parameters parameters = {.guest_code = guestcode_nop}; + +ksft_print_msg ("Testing VM Closure without Running vCPU\n" ); + parameters =create_vm_kvm_exit (parameters); +TEST_ASSERT (parameters.vcpu->run->exit_reason ==KVM_EXIT_UNKNOWN , +"Unexpected Exit Reason Before vCPU Execution: %u\n" , + parameters.vcpu->run->exit_reason); +TEST_ASSERT (parameters.vcpu->run->immediate_exit ==0 , +"Immediate Exit Unexpected Behavior: %d\n" , + parameters.vcpu->run->immediate_exit); +cleanup_kvm (¶meters); +return true; +} +static void test (void ) {int i;
@@ -336,6 +406,14 @@ static void test(void) .name = "Testing Translation Exceptions", .test = test_translation_exceptions, }, + { + .name = "Testing Wait State", + .test = test_wait_state, + }, + { + .name = "Testing VM Create and Destroy", + .test = test_vm_create_and_destroy, + }, };ksft_print_header ();
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH 4/6 KVM: s390: selftests: Add ucontrol helpers and instruction tests
In reply to Aaron M. BrownAdd helpers to run a guest on a ucontrol VM and use them to test instruction intercepts handled in userspace.
manual_kvm_creation_execution() creates the VM and vCPU, maps 4 MiB with KVM_S390_UCAS_MAP, sets the PSW and r15, and runs the vCPU. r15 must be valid because C guest functions adjust it in their prologue.
ucontrol_available() checks KVM_CAP_S390_UCONTROL and CAP_SYS_ADMIN. Tests that need it are skipped, with a reason from the new skip_reason field.
Tests added: STSI, TSCH and STSCH. Each must cause ICPT_INST with the expected opcode.
--- .../kvm/include/s390/kvm_lifecycle.h | 8 + tools/testing/selftests/kvm/s390/kvm_exit.c | 220 +++++++++++++++++- 2 files changed, 227 insertions(+), 1 deletion(-)
tools/testing/selftests/kvm/include/s390/kvm_lifecycle.h +8 -0
@@ -17,6 +17,7 @@struct kvm_lifecycle_testdef {const char *name;bool (*test)(void ); +const char *skip_reason; };struct kvm_parameters {
@@ -28,7 +29,14 @@ struct kvm_parameters {struct kvm_s390_irq *irq;struct kvm_s390_irq_state *irq_state;struct { +struct kvm_s390_sie_block *sie_block; +struct kvm_s390_ucas_mapping map;bool immediate_exit_condition; +void *vm_mem; +int run_size; +int vcpu_fd; +int kvm_fd; +int vm_fd; } manual_parameters; };
tools/testing/selftests/kvm/s390/kvm_exit.c +219 -1
262 lines not on this page · raw message
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH 5/6 KVM: s390: selftests: Add ucontrol storage key and immediate exit tests
In reply to Aaron M. BrownAdd two more ucontrol tests:
- Storage key: the guest executes SSKE. Check for ICPT_KSS and the key in the guest register. Skip if CPUSTAT_KSS is not set, as the intercept is not generated then.
- Immediate exit: set immediate_exit and a marker register before KVM_RUN. Check for EINTR, exit_reason KVM_EXIT_UNKNOWN, and that the marker is unchanged.
--- tools/testing/selftests/kvm/s390/kvm_exit.c | 107 ++++++++++++++++++++ 1 file changed, 107 insertions(+)
tools/testing/selftests/kvm/s390/kvm_exit.c +107 -0
@@ -37,6 +37,10 @@ int capget(cap_user_header_t header, cap_user_data_t data);#define STSI_IPA 0xb27d#define TSCH_IPA 0xb235#define STSCH_IPA 0xb234 +#define EXPECTED_STORAGE_KEY 0x20 +#define IPA_SUBOPCODE_MASK_SKEY 0xff +#define SSKE_SUBOPCODE 0x2b +#define SSKE_OPCODE 0xb2#define PSW_WAIT_BIT_MASK (1ULL << (63 - 14))#define PGM_CODE_GPA_ADDRESS 0x8e#define PGM_CODE_MASK 0x7f
@@ -121,6 +125,15 @@ static struct kvm_parameters manual_kvm_creation_execution(struct kvm_parameters param.run->s.regs.gprs[15 ] =CODE_GPA -160 ; param.run->kvm_dirty_regs |=KVM_SYNC_GPRS ; +if (param.manual_parameters.immediate_exit_condition) { + param.run->immediate_exit =1 ; + param.run->s.regs.gprs[3 ] =0xdead ; + param.run->kvm_dirty_regs |=KVM_SYNC_GPRS ; + rc =ioctl (param.manual_parameters.vcpu_fd,KVM_RUN ,NULL ); +TEST_ASSERT (rc ==-1 && errno ==EINTR ,"KVM_RUN failed (%d)" , errno); +return param; + } + rc =ioctl (param.manual_parameters.vcpu_fd,KVM_RUN ,NULL );TEST_ASSERT (rc ==0 ,"KVM_RUN failed (%d)" , errno);
@@ -585,6 +598,90 @@ static bool test_io_instruction_code(void)return true; } +static void guestcode_storage_key (void ) +{ + asmvolatile ( +"lghi %%r3, 0\n" +"lghi %%r2, %[skey]\n" +"sske %%r2, %%r3\n" + : + : [skey]"i" (EXPECTED_STORAGE_KEY ) + :"r3" ,"r2" + ); +} + +static bool test_storage_key_interrupt (void ) +{ +struct kvm_parameters parameters = { + .guest_code = guestcode_storage_key, + .manual_parameters.immediate_exit_condition = false, + }; + +if (!ucontrol_available ()) +return false; + +ksft_print_msg ("Testing Storage Key Interrupt KVM Exit\n" ); + parameters =manual_kvm_creation_execution (parameters); + +/* Skip on hosts where sclp.has_kss is false. */ +if (!(parameters.manual_parameters.sie_block->cpuflags &CPUSTAT_KSS )) { +manual_cleanup (parameters); +return false; + } + +TEST_ASSERT (parameters.run->exit_reason ==KVM_EXIT_S390_SIEIC , +"Expected KVM_EXIT_S390_SIEIC, got %u\n" , parameters.run->exit_reason); +TEST_ASSERT (parameters.run->s390_sieic.icptcode ==ICPT_KSS , +"Failed with Unexpected Exit Reason of %u and icptcode of 0x%x\n" , + parameters.run->exit_reason, parameters.run->s390_sieic.icptcode); +TEST_ASSERT ((parameters.run->s390_sieic.ipa &IPA_SUBOPCODE_MASK_SKEY ) ==SSKE_SUBOPCODE , +"Expected SSKE Sub Opcode of 0x2B, Result of 0x%x\n" , + parameters.run->s390_sieic.ipa &IPA_SUBOPCODE_MASK_SKEY ); +TEST_ASSERT ((parameters.run->s390_sieic.ipa >>8 ) ==SSKE_OPCODE , +"Expected SSKE Opcode of 0xb2, Actual of 0x%x\n" , + parameters.run->s390_sieic.ipa >>8 ); +TEST_ASSERT (parameters.run->s.regs.gprs[2 ] ==EXPECTED_STORAGE_KEY , +"Storage Key not stored correctly, got 0x%llx\n" , + parameters.run->s.regs.gprs[2 ]); + +manual_cleanup (parameters); +return true; +} + +static void guestcode_immediate_exit (void ) +{ + asmvolatile ( +"lghi %%r3, 0x3333\n" + : + : + :"r3" + ); +} + +static bool test_immediate_exit (void ) +{ +struct kvm_parameters parameters = { + .guest_code = guestcode_immediate_exit, + .manual_parameters.immediate_exit_condition = true, + }; + +if (!ucontrol_available ()) +return false; + +ksft_print_msg ("Testing KVM Immediate Exit\n" ); + parameters =manual_kvm_creation_execution (parameters); + +TEST_ASSERT (parameters.run->exit_reason ==KVM_EXIT_UNKNOWN , +"Expected KVM_EXIT_UNKNOWN (0), got %u\n" , + parameters.run->exit_reason); +TEST_ASSERT (parameters.run->s.regs.gprs[3 ] ==0xdead , +"Guest code executed when it should not have: r3=0x%llx\n" , + parameters.run->s.regs.gprs[3 ]); + +manual_cleanup (parameters); +return true; +} +static void test (void ) {int i;
@@ -631,6 +728,16 @@ static void test(void) .test = test_io_instruction_code, .skip_reason = "KVM_CAP_S390_UCONTROL unavailable or insufficient privilege" }, + { + .name = "Testing Storage Key Interrupts", + .test = test_storage_key_interrupt, + .skip_reason ="KVM_CAP_S390_UCONTROL, privilege or KSS unavailable" + }, + { + .name = "Testing Immediate Exit", + .test = test_immediate_exit, + .skip_reason ="KVM_CAP_S390_UCONTROL unavailable or insufficient privilege" + }, };ksft_print_header ();
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH 6/6 KVM: s390: selftests: Add clock comparator interrupt test
In reply to Aaron M. BrownAdd a test that injects a clock comparator interrupt into a ucontrol VM. The guest sets the clock comparator far in the future, sets the subclass mask, and waits with the external mask set.
The first KVM_RUN exits with ICPT_WAIT. Inject KVM_S390_INT_CLOCK_COMP and run again. Check for ICPT_EXTREQ.
--- tools/testing/selftests/kvm/s390/kvm_exit.c | 74 +++++++++++++++++++++ 1 file changed, 74 insertions(+)
tools/testing/selftests/kvm/s390/kvm_exit.c +74 -0
@@ -42,6 +42,8 @@ int capget(cap_user_header_t header, cap_user_data_t data);#define SSKE_SUBOPCODE 0x2b#define SSKE_OPCODE 0xb2#define PSW_WAIT_BIT_MASK (1ULL << (63 - 14)) +#define PSW_CLOCK_WAIT 0x0102000180000000ULL +#define CLK_COMPARATOR_MASK_BIT (1ULL << 11)#define PGM_CODE_GPA_ADDRESS 0x8e#define PGM_CODE_MASK 0x7f#define PGM_NEW_PSW_GPA 0x1d0
@@ -682,6 +684,73 @@ static bool test_immediate_exit(void)return true; } +static void guestcode_clock_comparator (void ) +{ + asmvolatile ( +/* Set SCKC to the maximum value so it cannot expire on its own */ +"lghi %%r7, -1\n" +"stg %%r7, 0(%%r15)\n" +"sckc 0(%%r15)\n" +/* Enable clock comparator interrupt in CR0 (bit 52) */ +"stctg %%c0, %%c0, 0(%%r15)\n" +"oi 6(%%r15), 0x8\n" +"lctlg %%c0, %%c0, 0(%%r15)\n" +/* Load enabled wait PSW: 64-bit, DAT off, wait bit, external interrupt enabled */ +"larl %%r8, 1f\n" +"lpswe 0(%%r8)\n" +".align 8\n" +"1: .quad %[wait_psw], 0\n" + : + : [wait_psw]"i" (PSW_CLOCK_WAIT ) + :"r7" ,"r8" ,"memory" + ); +GUEST_DONE (); +} + +static bool test_clock_comparator_interrupt (void ) +{ +struct kvm_parameters param = { + .guest_code = guestcode_clock_comparator, + .manual_parameters.immediate_exit_condition = false, + }; +struct kvm_s390_irq irq = {}; +int rc; + +if (!ucontrol_available ()) +return false; + +ksft_print_msg ("Testing Clock Comparator Interrupt Exit\n" ); + param =manual_kvm_creation_execution (param); + +/* On a ucontrol VM, the guest's enabled wait exits to userspace as ICPT_WAIT. */ +TEST_ASSERT (param.run->exit_reason ==KVM_EXIT_S390_SIEIC , +"Expected SIEIC, got %u\n" , param.run->exit_reason); +TEST_ASSERT (param.run->s390_sieic.icptcode ==ICPT_WAIT , +"Expected ICPT_WAIT (0x1c), got 0x%x\n" , + param.run->s390_sieic.icptcode); +TEST_ASSERT ((param.run->s.regs.crs[0 ] &CLK_COMPARATOR_MASK_BIT ) !=0 , +"CR0 clock comparator bit not set, cr0=0x%llx\n" , + param.run->s.regs.crs[0 ]); + +/* Inject clock comparator interrupt as a ucontrol VMM would */ + irq.type =KVM_S390_INT_CLOCK_COMP ; + rc =ioctl (param.manual_parameters.vcpu_fd,KVM_S390_IRQ , &irq); +TEST_ASSERT (rc ==0 ,"KVM_S390_IRQ (clock comp) failed (%d)" , errno); + +/* With the interrupt pending and external interrupts enabled, expect ICPT_EXTREQ. */ + rc =ioctl (param.manual_parameters.vcpu_fd,KVM_RUN ,NULL ); +TEST_ASSERT (rc ==0 ,"KVM_RUN (2) failed (%d)" , errno); +TEST_ASSERT (param.run->exit_reason ==KVM_EXIT_S390_SIEIC , +"Expected SIEIC on second run, got %u\n" , + param.run->exit_reason); +TEST_ASSERT (param.run->s390_sieic.icptcode ==ICPT_EXTREQ , +"Expected ICPT_EXTREQ (0x10), got 0x%x\n" , + param.run->s390_sieic.icptcode); + +manual_cleanup (param); +return true; +} +static void test (void ) {int i;
@@ -738,6 +807,11 @@ static void test(void) .test = test_immediate_exit, .skip_reason = "KVM_CAP_S390_UCONTROL unavailable or insufficient privilege" }, + { + .name = "Testing Clock Comparator External Interrupts", + .test = test_clock_comparator_interrupt, + .skip_reason ="KVM_CAP_S390_UCONTROL unavailable or insufficient privilege" + }, };ksft_print_header ();
Signature · 1 line
2.50.1 (Apple Git-155)
[email protected]
AI reviewRe: [PATCH 3/6] KVM: s390: selftests: Add wait state and VM lifecycle tests
In reply to Aaron M. BrownSashiko has reviewed this patch and found no issues.
Quoted 11 lines
Add two tests:
- Wait state: the guest loads a PSW with the wait bit (bit 14) set and the I/O, external and machine-check masks (bits 6, 7, 13) clear. Check for
ICPT_WAITand the wait bit in the PSW.
- VM create and destroy: before the firstKVM_RUN, check thatexit_reasonisKVM_EXIT_UNKNOWNandimmediate_exitis clear.Co-developed-by Nitya Khamar <[email protected]>Signed-off-by Nitya Khamar <[email protected]>Signed-off-by Aaron M. Brown <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
[email protected]
AI reviewRe: [PATCH 6/6] KVM: s390: selftests: Add clock comparator interrupt test
In reply to Aaron M. BrownSashiko has reviewed this patch and found no issues.
Quoted 10 lines
Add a test that injects a clock comparator interrupt into a ucontrol VM. The guest sets the clock comparator far in the future, sets the subclass mask, and waits with the external mask set.
The first
KVM_RUNexits withICPT_WAIT. InjectKVM_S390_INT_CLOCK_COMPand run again. Check forICPT_EXTREQ.Co-developed-by Nitya Khamar <[email protected]>Signed-off-by Nitya Khamar <[email protected]>Signed-off-by Aaron M. Brown <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
[email protected]
AI reviewRe: [PATCH 2/6] KVM: s390: selftests: Add SIGP and program exception tests
In reply to Aaron M. BrownSashiko has reviewed this patch and found no issues.
Quoted 8 lines
Add tests for:
- SIGP: a second vCPU stops vCPU 0. Both vCPUs are set to operating first, as KVM ignores a stop order sent to a stopped vCPU. Check for
ICPT_STOP.
- Addressing exception (DAT off): check for program code0x05.
- Segment translation exception (DAT on): check for program code0x10.
Quoted 6 lines
The program new PSW is set to a disabled wait so the guest exits deterministically.
Co-developed-by Nitya Khamar <[email protected]>Signed-off-by Nitya Khamar <[email protected]>Signed-off-by Aaron M. Brown <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
[email protected]
AI reviewRe: [PATCH 4/6] KVM: s390: selftests: Add ucontrol helpers and instruction tests
In reply to Aaron M. BrownSashiko has reviewed this patch and found no issues.
Quoted 11 lines
Add helpers to run a guest on a ucontrol VM and use them to test instruction intercepts handled in userspace.
manual_kvm_creation_execution()creates the VM and vCPU, maps 4 MiB withKVM_S390_UCAS_MAP, sets the PSW and r15, and runs the vCPU. r15 must be valid because C guest functions adjust it in their prologue.
ucontrol_available()checksKVM_CAP_S390_UCONTROLandCAP_SYS_ADMIN. Tests that need it are skipped, with a reason from the newskip_reasonfield.
Quoted 6 lines
Tests added: STSI, TSCH and STSCH. Each must cause
ICPT_INSTwith the expected opcode.Co-developed-by Nitya Khamar <[email protected]>Signed-off-by Nitya Khamar <[email protected]>Signed-off-by Aaron M. Brown <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
[email protected]
AI reviewRe: [PATCH 5/6] KVM: s390: selftests: Add ucontrol storage key and immediate exit tests
In reply to Aaron M. BrownSashiko has reviewed this patch and found no issues.
Quoted 9 lines
Add two more ucontrol tests:
- Storage key: the guest executes SSKE. Check for
ICPT_KSSand the key in the guest register. Skip ifCPUSTAT_KSSis not set, as the intercept is not generated then.
- Immediate exit: setimmediate_exitand a marker register beforeKVM_RUN. Check for EINTR,exit_reasonKVM_EXIT_UNKNOWN, and that the marker is unchanged.
Quoted 3 lines
Co-developed-by Nitya Khamar <[email protected]>Signed-off-by Nitya Khamar <[email protected]>Signed-off-by Aaron M. Brown <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
[email protected]
AI reviewRe: [PATCH 1/6] KVM: s390: selftests: Add kvm_exit test for instruction intercepts
In reply to Aaron M. BrownSashiko has reviewed this patch and found no issues.
Quoted 4 lines
Add a selftest for the exits KVM reports to userspace on s390x, mainly
KVM_EXIT_S390_SIEIC. This patch adds the harness and the instruction intercept tests:
Quoted 8 lines
- DIAG
0x500: inject an external call, check it is pending, resume, and compare the registers with those synced inkvm_run.
- DIAG0x501: check the opcode and diagnose code in ipa and ipb.
- DIAG0x501with registers set beforehand: check they are intact.Co-developed-by Nitya Khamar <[email protected]>Signed-off-by Nitya Khamar <[email protected]>Signed-off-by Aaron M. Brown <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Janosch Frank
maintainerRe: [PATCH 1/6] KVM: s390: selftests: Add kvm_exit test for instruction intercepts
In reply to Aaron M. BrownQuoted 61 lines · Aaron M. Brown
Add a selftest for the exits KVM reports to userspace on s390x, mainly
KVM_EXIT_S390_SIEIC. This patch adds the harness and the instruction intercept tests:- DIAG
0x500: inject an external call, check it is pending, resume, and compare the registers with those synced inkvm_run.
- DIAG0x501: check the opcode and diagnose code in ipa and ipb.
- DIAG0x501with registers set beforehand: check they are intact.Co-developed-by Nitya Khamar <[email protected]>Signed-off-by Nitya Khamar <[email protected]>Signed-off-by Aaron M. Brown <[email protected]>--- tools/testing/selftests/kvm/Makefile.kvm | 1 + .../kvm/include/s390/kvm_lifecycle.h | 35 +++ tools/testing/selftests/kvm/s390/kvm_exit.c | 212 ++++++++++++++++++ 3 files changed, 248 insertions(+)create mode 100644
tools/testing/selftests/kvm/include/s390/kvm_lifecycle.hcreate mode 100644tools/testing/selftests/kvm/s390/kvm_exit.ctools/testing/selftests/kvm/Makefile.kvm +1
-0@@ -232,6 +232,7 @@ TEST_GEN_PROGS_s390 += s390/irq_routing TEST_GEN_PROGS_s390 += mmu_stress_test TEST_GEN_PROGS_s390 += pre_fault_memory_test TEST_GEN_PROGS_s390 += s390/irq_injection +TEST_GEN_PROGS_s390 += s390/kvm_exit TEST_GEN_PROGS_riscv = $(TEST_GEN_PROGS_COMMON) TEST_GEN_PROGS_riscv += riscv/sbi_pmu_testtools/testing/selftests/kvm/include/s390/kvm_lifecycle.h new file +23
-0@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Definition of structs for KVM lifecycle tests. +* +* Copyright IBM Corp. 2026 +* +* Authors: +* Nitya Khamar ([email protected]) +* Aaron Malik Brown ([email protected]) +*/ +#ifndef SELFTEST_KVM_LIFECYCLE_H +#define SELFTEST_KVM_LIFECYCLE_H + +#include "kvm_util.h" +#include <stdbool.h> + +struct kvm_lifecycle_testdef { + const char *name; + bool (*test)(void); +}; + +struct kvm_parameters { + struct kvm_vm *vm;
tools/testing/selftests/kvm/include/s390/kvm_lifecycle.h line 33
Quoted 10 lines
tools/testing/selftests/kvm/include/s390/kvm_lifecycle.h new file +10
-0+struct kvm_vcpu *vcpu; +void *guest_code; +struct kvm_run *run; +unsigned int interrupt_type; +struct kvm_s390_irq *irq; +struct kvm_s390_irq_state *irq_state; +struct { +bool immediate_exit_condition; + } manual_parameters; +};
In this patch I don't see any benefit in having this struct. I'm hoping there's some use for it in later patches.
Quoted 27 lines
tools/testing/selftests/kvm/include/s390/kvm_lifecycle.h new file +2
-0+ +#endif /* SELFTEST_KVM_LIFECYCLE_H */ tools/testing/selftests/kvm/s390/kvm_exit.c new file +19
-0@@ -0,0 +1,212 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Test for KVM Exits to userspace on s390x +* +* Copyright IBM Corp. 2026 +* +* Authors: +* Nitya Khamar <[email protected]> +* Aaron Malik Brown <[email protected]> +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/ioctl.h> +#include "test_util.h" +#include "kvm_util.h" +#include "kselftest.h" +#include <errno.h>
tools/testing/selftests/kvm/s390/kvm_exit.c line 29
Quoted 10 lines
tools/testing/selftests/kvm/s390/kvm_exit.c new file +10
-0+#include "processor.h" +#include "ucall_common.h" +#include "sie.h" +#include "kvm_lifecycle.h" + +#define NUM_GPRS 16 +#define DIAG_ASSEMBLY_CODE 0x501 +#define IPA_DIAG 0x83 + +static struct kvm_parameters create_vm_kvm_exit (struct kvm_parameters parameters)
Why aren't we using a pointer to the argument?
tools/testing/selftests/kvm/s390/kvm_exit.c line 39
Quoted 10 lines
tools/testing/selftests/kvm/s390/kvm_exit.c new file +10
-0+{ + parameters.vm =vm_create_with_one_vcpu (¶meters.vcpu, + parameters.guest_code); +return parameters; +} + +static void cleanup_kvm (struct kvm_parameters *parameters) +{ +kvm_vm_free (parameters->vm); +}
These two function generate >= 4 lines for a single line of useful code.
Quoted 33 lines
tools/testing/selftests/kvm/s390/kvm_exit.c new file +33
-0+ +static void compare_regs (struct kvm_regs *regs,struct kvm_sync_regs *sregs) +{ +int register_number; + +for (register_number =0 ; register_number <NUM_GPRS ; register_number++) +TEST_ASSERT_EQ (regs->gprs[register_number], sregs->gprs[register_number]); +} + +static void guestcode_instruction_intercept (void ) +{ + asmvolatile ("diag 0,0, 0x500\n" :::); +GUEST_DONE (); +} + +static bool test_instruction_intercept (void ) +{ +struct kvm_parameters param = { + .guest_code = guestcode_instruction_intercept, + .interrupt_type =KVM_S390_INT_EXTERNAL_CALL , + .manual_parameters.immediate_exit_condition = false, + }; +struct kvm_s390_irq_state irq_state = {}; +struct kvm_s390_irq irq = {}; +struct kvm_regs regs; +int interrupts; + +ksft_print_msg ("Testing Instruction Intercept Exit\n" ); + param =create_vm_kvm_exit (param); +vcpu_run (param.vcpu); + param.run = param.vcpu->run; + irq.type = param.interrupt_type; + irq.u.extcall.code = param.vcpu->id;
tools/testing/selftests/kvm/s390/kvm_exit.c line 82
Quoted 10 lines
tools/testing/selftests/kvm/s390/kvm_exit.c new file +10
-0+ irq_state.len =sizeof (irq); + irq_state.buf = (unsigned long )&irq; + param.irq = &irq; + param.irq_state = &irq_state; +TEST_ASSERT_KVM_EXIT_REASON (param.vcpu,KVM_EXIT_S390_SIEIC ); +TEST_ASSERT (param.run->s390_sieic.icptcode ==ICPT_INST , +"Failed with Unexpected icptcode of 0x%x\n" , + param.run->s390_sieic.icptcode); + interrupts =__vcpu_ioctl (param.vcpu,KVM_S390_SET_IRQ_STATE , + param.irq_state);
Why are we doing two things at the same time?
What does the IRQ code add to the test?
tools/testing/selftests/kvm/s390/kvm_exit.c line 83
Quoted 1 line
tools/testing/selftests/kvm/s390/kvm_exit.c new file +1
-0+TEST_ASSERT (interrupts >=0 ,"Cannot Inject Interrupt (%d)" , errno);
That should be a == 0, no?
Documentations says "0 on success".
tools/testing/selftests/kvm/s390/kvm_exit.c line 89
Quoted 6 lines
tools/testing/selftests/kvm/s390/kvm_exit.c new file +6
-0+ irq_state.buf = (unsigned long )&irq; + irq_state.len =sizeof (irq); + interrupts =__vcpu_ioctl (param.vcpu,KVM_S390_GET_IRQ_STATE , + &irq_state); +TEST_ASSERT (interrupts >0 , +"Expected pending interrupt after injection, got %d" , interrupts);
Here it's fine since the rc returns the number of bytes KVM copied. But we could actually check for a number being at least len(irq_state)
Quoted 15 lines
tools/testing/selftests/kvm/s390/kvm_exit.c new file +15
-0+TEST_ASSERT_EQ (irq.type,KVM_S390_INT_EXTERNAL_CALL ); +TEST_ASSERT_EQ (irq.u.extcall.code, param.vcpu->id); +vcpu_run (param.vcpu); +TEST_ASSERT_KVM_EXIT_REASON (param.vcpu,KVM_EXIT_S390_SIEIC ); +TEST_ASSERT (param.run->s390_sieic.icptcode ==ICPT_INST , +"Expected ICPT_INST from GUEST_DONE after inject, got 0x%x\n" , + param.run->s390_sieic.icptcode); +vcpu_regs_get (param.vcpu, ®s); +compare_regs (®s, ¶m.run->s.regs); +cleanup_kvm (¶m); +return true; +} + +static void guestcode_diagnose_hypercall (void ) +{
tools/testing/selftests/kvm/s390/kvm_exit.c line 114
Quoted 10 lines
tools/testing/selftests/kvm/s390/kvm_exit.c new file +10
-0+ asmvolatile ("diag 0,0, 0x501\n" :::); +} + +static bool test_diagnose_code (void ) +{ +struct kvm_parameters param = { + .guest_code = guestcode_diagnose_hypercall, + .manual_parameters.immediate_exit_condition = false, + }; +ksft_print_msg ("Testing Diagnosis Hypercall Exit\n" );
Instruction is called diagnose according to the POP.
Quoted 31 lines
tools/testing/selftests/kvm/s390/kvm_exit.c new file +31
-0+ param =create_vm_kvm_exit (param); +vcpu_run (param.vcpu); + param.run = param.vcpu->run; +TEST_ASSERT_KVM_EXIT_REASON (param.vcpu,KVM_EXIT_S390_SIEIC ); +TEST_ASSERT (param.run->s390_sieic.icptcode ==ICPT_INST , +"Failed with Unexpected Exit Reason of %u and icptcode of 0x%x\n" , + param.run->exit_reason, param.run->s390_sieic.icptcode); +TEST_ASSERT (param.run->s390_sieic.ipa >>8 ==IPA_DIAG , +"Failed with Unexpected Opcode of %u\n" , + param.run->s390_sieic.ipa >>8 ); +TEST_ASSERT (param.run->s390_sieic.ipb >>16 ==DIAG_ASSEMBLY_CODE , +"Failed with Unexpected Diagnose Code of %u\n" , + param.run->s390_sieic.ipb >>16 ); +cleanup_kvm (¶m); +return true; +} + +static void guestcode_diagnose_conditional (void ) +{ + asmvolatile ("lghi %%r3,0x3333\n" +"lghi %%r5, 0x555\n" +"lghi %%r6, 0x3333\n" +"cgrjne %%r6, %%r3, 1f\n" +"diag 0,0, 0x501\n" +"1:\n" + : + : + :"r3" ,"r5" ,"r6" + ); +GUEST_DONE (); +}
tools/testing/selftests/kvm/s390/kvm_exit.c line 155
Quoted 10 lines
tools/testing/selftests/kvm/s390/kvm_exit.c new file +10
-0+ +static bool test_diagnose_conditional_code (void ) +{ +struct kvm_parameters param = { + .guest_code = guestcode_diagnose_conditional, + .manual_parameters.immediate_exit_condition = false, + }; +struct kvm_regs regs; + +ksft_print_msg ("Testing Diagnosis Hypercall for Conditional Code Exit\n" );
What is this testing?
tools/testing/selftests/kvm/s390/kvm_exit.c line 125
Quoted 11 lines
tools/testing/selftests/kvm/s390/kvm_exit.c new file +11
-0+ param =create_vm_kvm_exit (param); +vcpu_run (param.vcpu); + param.run = param.vcpu->run; +TEST_ASSERT_KVM_EXIT_REASON (param.vcpu,KVM_EXIT_S390_SIEIC ); +TEST_ASSERT (param.run->s390_sieic.icptcode ==ICPT_INST , +"Failed with Unexpected Exit Reason of %u and icptcode of 0x%x\n" , + param.run->exit_reason, param.run->s390_sieic.icptcode); +TEST_ASSERT (param.run->s390_sieic.ipa >>8 ==IPA_DIAG , +"Failed with Unexpected Opcode of %u\n" , + param.run->s390_sieic.ipa >>8 ); + TEST_ASSERT(param.run->s390_sieic.ipb >> 16 == DIAG_ASSEMBLY_CODE,
Which diag assembly code?
There's a huge number of them and this test already uses 2.
Quoted 46 lines
tools/testing/selftests/kvm/s390/kvm_exit.c new file +46
-0+"Failed with Unexpected Diagnose Code of %u\n" , + param.run->s390_sieic.ipb >> 16); +vcpu_regs_get (param.vcpu, ®s); +TEST_ASSERT_EQ (regs.gprs[3 ],0x3333 ); +TEST_ASSERT_EQ (regs.gprs[5 ],0x555 ); +TEST_ASSERT_EQ (regs.gprs[6 ],0x3333 ); +cleanup_kvm (¶m); +return true; +} + +static void test (void ) +{ +int i; +struct kvm_lifecycle_testdef testlist[] = { + { + .name ="Testing Instruction Intercepts" , + .test = test_instruction_intercept, + }, + { + .name ="Testing DIAG Code" , + .test = test_diagnose_code, + }, + { + .name ="Testing Conditional DIAG Code" , + .test = test_diagnose_conditional_code, + }, + }; + +ksft_print_header (); +ksft_set_plan (ARRAY_SIZE (testlist)); + +for (i =0 ; i <ARRAY_SIZE (testlist); i++) { +if (testlist[i].test ()) +ksft_test_result_pass ("%s\n" , testlist[i].name); +else +ksft_test_result_skip ("%s\n" , testlist[i].name); + } +} + +int main (void ) +{ +TEST_REQUIRE (kvm_has_cap (KVM_CAP_USER_MEMORY2 )); +TEST_REQUIRE (kvm_has_cap (KVM_CAP_SYNC_REGS )); +test (); +ksft_finished (); +}
Re: [PATCH 1/6] KVM: s390: selftests: Add kvm_exit test for instruction intercepts
Quoted 1 line · Janosch Frank
On 11/10/26 12:16 PM, Aaron M. Brown wrote:
[...]
Quoted 30 lines
Quoted 30 lines
+++
b/tools/testing/selftests/kvm/include/s390/kvm_lifecycle.htools/testing/selftests/kvm/include/s390/kvm_lifecycle.h new file +28
-0@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Definition of structs for KVM lifecycle tests. +* +* Copyright IBM Corp. 2026 +* +* Authors: +* Nitya Khamar ([email protected]) +* Aaron Malik Brown ([email protected]) +*/ +#ifndef SELFTEST_KVM_LIFECYCLE_H +#define SELFTEST_KVM_LIFECYCLE_H + +#include "kvm_util.h" +#include <stdbool.h> + +struct kvm_lifecycle_testdef { + const char *name; + bool (*test)(void); +}; + +struct kvm_parameters { + struct kvm_vm *vm; + struct kvm_vcpu *vcpu; + void *guest_code; + struct kvm_run *run; + unsigned int interrupt_type; + struct kvm_s390_irq *irq;
Quoted 8 lines
tools/testing/selftests/kvm/include/s390/kvm_lifecycle.h line 33
Quoted 5 lines
tools/testing/selftests/kvm/include/s390/kvm_lifecycle.h new file +5
-0+ struct kvm_s390_irq_state *irq_state; + struct { + bool immediate_exit_condition; + } manual_parameters; +};In this patch I don't see any benefit in having this struct. I'm hoping there's some use for it in later patches.
Yeah I may have added it a bit prematurely, as most of these fields are only used by the ucontrol tests later in the series, so patch 1 doesn't need them. I'll drop the struct from this patch and use local variables in the next version, thanks
[...]
Quoted 6 lines
Quoted 3 lines
(quoted diff) +2
-0+ +static struct kvm_parameters create_vm_kvm_exit(struct kvm_parametersparameters)
Why aren't we using a pointer to the argument?
Quoted 13 lines
tools/testing/selftests/kvm/s390/kvm_exit.c line 39
Quoted 10 lines
tools/testing/selftests/kvm/s390/kvm_exit.c new file +10
-0+{ + parameters.vm = vm_create_with_one_vcpu(¶meters.vcpu, + parameters.guest_code); + return parameters; +} + +static void cleanup_kvm (struct kvm_parameters *parameters) +{ + kvm_vm_free(parameters->vm); +}These two function generate >= 4 lines for a single line of useful code.
Good point, I'll remove these helpers as well and just call vm_create_with_one_vcpu() and kvm_vm_free() directly
Quoted 41 lines
Quoted 41 lines
(quoted diff) +2
-0+ +static void compare_regs(struct kvm_regs *regs, struct kvm_sync_regs*sregs)
tools/testing/selftests/kvm/s390/kvm_exit.c new file +4
-0+{ + int register_number; + + for (register_number = 0; register_number < NUM_GPRS;register_number++)
+ TEST_ASSERT_EQ(regs->gprs[register_number], sregs-Quoted 1 line
gprs[register_number]);
tools/testing/selftests/kvm/s390/kvm_exit.c new file +31
-0+} + +static void guestcode_instruction_intercept (void ) +{ + asm volatile("diag 0,0, 0x500\n" :::); + GUEST_DONE(); +} + +static bool test_instruction_intercept (void ) +{ + struct kvm_parameters param = { + .guest_code = guestcode_instruction_intercept, + .interrupt_type = KVM_S390_INT_EXTERNAL_CALL, + .manual_parameters.immediate_exit_condition = false, + }; + struct kvm_s390_irq_state irq_state = {}; + struct kvm_s390_irq irq = {}; + struct kvm_regs regs; + int interrupts; + + ksft_print_msg("Testing Instruction Intercept Exit\n"); + param = create_vm_kvm_exit(param); + vcpu_run(param.vcpu); + param.run = param.vcpu->run; + irq.type = param.interrupt_type; + irq.u.extcall.code = param.vcpu->id; + irq_state.len = sizeof(irq); + irq_state.buf = (unsigned long)&irq; + param.irq = &irq; + param.irq_state = &irq_state; + TEST_ASSERT_KVM_EXIT_REASON(param.vcpu, KVM_EXIT_S390_SIEIC);
Quoted 8 lines
Quoted 5 lines
+ TEST_ASSERT(param.run->s390_sieic.icptcode ==
ICPT_INST, + "Failed with Unexpected icptcode of 0x%x\n", +param.run->s390_sieic.icptcode);
+ interrupts =__vcpu_ioctl(param.vcpu, KVM_S390_SET_IRQ_STATE, + param.irq_state);Why are we doing two things at the same time?
What does the IRQ code add to the test?
You're right, we should focus on only testing the exit, moreover irq_injection has gotten its own test file now, ill drop this in v2 >> + TEST_ASSERT(interrupts >= 0, "Cannot Inject Interrupt (%d)", errno);
Quoted 4 lines
That should be a == 0, no?
Documentations says "0 on success".
Indeed, this can also go away in v2, lets keep it simple
Quoted 10 lines
Quoted 7 lines
+ irq_state.buf = (unsigned long)&irq;
+ irq_state.len = sizeof(irq);
+ interrupts =__vcpu_ioctl(param.vcpu, KVM_S390_GET_IRQ_STATE, + &irq_state);
+ TEST_ASSERT(interrupts > 0,
+ "Expected pending interrupt after injection, got %d", interrupts);Here it's fine since the rc returns the number of bytes KVM copied. But we could actually check for a number being at least
len(irq_state)
Good point, I will note that for possibly extending the irq tests in the future! >> + TEST_ASSERT_EQ(irq.type, KVM_S390_INT_EXTERNAL_CALL);
Quoted 19 lines
Quoted 19 lines
+
TEST_ASSERT_EQ(irq.u.extcall.code, param.vcpu->id); +vcpu_run(param.vcpu);
+TEST_ASSERT_KVM_EXIT_REASON(param.vcpu, KVM_EXIT_S390_SIEIC); + TEST_ASSERT(param.run->s390_sieic.icptcode ==ICPT_INST, + "ExpectedICPT_INSTfromGUEST_DONEafter inject, got 0x%x\n",
+param.run->s390_sieic.icptcode);
+vcpu_regs_get(param.vcpu, ®s);
+compare_regs(®s, ¶m.run->s.regs);
+cleanup_kvm(¶m);
+ return true;tools/testing/selftests/kvm/s390/kvm_exit.c new file +8
-0+} + +static void guestcode_diagnose_hypercall (void ) +{ + asm volatile("diag 0,0, 0x501\n" :::); +} + +static bool test_diagnose_code (void )
Quoted 8 lines
Quoted 6 lines
+{
+ structkvm_parametersparam = {
+ .guest_code =guestcode_diagnose_hypercall, + .manual_parameters.immediate_exit_condition = false, + };
+ksft_print_msg("Testing Diagnosis Hypercall Exit\n");Instruction is called diagnose according to the POP.
I will update that accordingly, thanks !
Quoted 37 lines
Quoted 37 lines
+ param =
create_vm_kvm_exit(param);
+vcpu_run(param.vcpu);
+ param.run =param.vcpu->run;
+TEST_ASSERT_KVM_EXIT_REASON(param.vcpu, KVM_EXIT_S390_SIEIC); + TEST_ASSERT(param.run->s390_sieic.icptcode ==ICPT_INST, + "Failed with Unexpected Exit Reason of %u and icptcode of 0x%x\n",
+param.run->exit_reason,param.run->s390_sieic.icptcode); + TEST_ASSERT(param.run->s390_sieic.ipa >> 8 ==IPA_DIAG, + "Failed with Unexpected Opcode of %u\n",
+param.run->s390_sieic.ipa>> 8);
+ TEST_ASSERT(param.run->s390_sieic.ipb >> 16 ==DIAG_ASSEMBLY_CODE, + "Failed with Unexpected Diagnose Code of %u\n", +param.run->s390_sieic.ipb>> 16);
+cleanup_kvm(¶m);
+ return true;tools/testing/selftests/kvm/s390/kvm_exit.c new file +21
-0+} + +static void guestcode_diagnose_conditional (void ) +{ + asm volatile("lghi %%r3,0x3333\n" + "lghi %%r5, 0x555\n" + "lghi %%r6, 0x3333\n" + "cgrjne %%r6, %%r3, 1f\n" + "diag 0,0, 0x501\n" + "1:\n" + : + : + : "r3", "r5", "r6" + ); + GUEST_DONE(); +} + +static bool test_diagnose_conditional_code (void ) +{ + struct kvm_parameters param = { + .guest_code = guestcode_diagnose_conditional,
Quoted 8 lines
Quoted 6 lines
+ .manual_parameters.immediate_exit_condition = false, + };
+ structkvm_regsregs;
+
+ksft_print_msg("Testing Diagnosis Hypercall for Conditional Code Exit\n");What is this testing?
It is only testing that r3-r6 survive the intercept, so I think I can merge it into the DIAG 0x501 test for v2 >> + param = create_vm_kvm_exit(param);
Quoted 12 lines
Quoted 11 lines
+
vcpu_run(param.vcpu);
+ param.run =param.vcpu->run;
+TEST_ASSERT_KVM_EXIT_REASON(param.vcpu, KVM_EXIT_S390_SIEIC); + TEST_ASSERT(param.run->s390_sieic.icptcode ==ICPT_INST, + "Failed with Unexpected Exit Reason of %u and icptcode of 0x%x\n",
+param.run->exit_reason,param.run->s390_sieic.icptcode); + TEST_ASSERT(param.run->s390_sieic.ipa >> 8 ==IPA_DIAG, + "Failed with Unexpected Opcode of %u\n",
+param.run->s390_sieic.ipa>> 8);
+ TEST_ASSERT(param.run->s390_sieic.ipb >> 16 ==DIAG_ASSEMBLY_CODE,
Quoted 2 lines
Which diag assembly code?
There's a huge number of them and this test already uses 2.
This is for the virtio notify hypercall (500) in particular, I will be more explicit with the variable names in v2 ! >> + "Failed with Unexpected Diagnose Code of %u\n",
Quoted 37 lines
Quoted 37 lines
+
param.run->s390_sieic.ipb>> 16);
+vcpu_regs_get(param.vcpu, ®s);
+TEST_ASSERT_EQ(regs.gprs[3], 0x3333);
+TEST_ASSERT_EQ(regs.gprs[5], 0x555);
+TEST_ASSERT_EQ(regs.gprs[6], 0x3333);
+cleanup_kvm(¶m);
+ return true;tools/testing/selftests/kvm/s390/kvm_exit.c new file +30
-0+} + +static void test (void ) +{ + int i; + struct kvm_lifecycle_testdef testlist[] = { + { + .name = "Testing Instruction Intercepts", + .test = test_instruction_intercept, + }, + { + .name = "Testing DIAG Code", + .test = test_diagnose_code, + }, + { + .name = "Testing Conditional DIAG Code", + .test = test_diagnose_conditional_code, + }, + }; + + ksft_print_header(); + ksft_set_plan(ARRAY_SIZE(testlist)); + + for (i = 0; i < ARRAY_SIZE(testlist); i++) { + if (testlist[i].test()) + ksft_test_result_pass("%s\n", testlist[i].name); + else + ksft_test_result_skip("%s\n", testlist[i].name); + } +}
Quoted 9 lines
tools/testing/selftests/kvm/s390/kvm_exit.c line 212
Quoted 8 lines
tools/testing/selftests/kvm/s390/kvm_exit.c new file +8
-0+ +int main (void ) +{ + TEST_REQUIRE(kvm_has_cap(KVM_CAP_USER_MEMORY2)); + TEST_REQUIRE(kvm_has_cap(KVM_CAP_SYNC_REGS)); + test(); + ksft_finished(); +}
thanks for the constructive comments Janosch, I will get to updating this,
Aaron
Janosch Frank
maintainerRe: [PATCH 2/6] KVM: s390: selftests: Add SIGP and program exception tests
In reply to Aaron M. BrownQuoted 67 lines · Aaron M. Brown
Add tests for:
- SIGP: a second vCPU stops vCPU 0. Both vCPUs are set to operating first, as KVM ignores a stop order sent to a stopped vCPU. Check for
ICPT_STOP.
- Addressing exception (DAT off): check for program code0x05.
- Segment translation exception (DAT on): check for program code0x10.The program new PSW is set to a disabled wait so the guest exits deterministically.
Co-developed-by Nitya Khamar <[email protected]>Signed-off-by Nitya Khamar <[email protected]>Signed-off-by Aaron M. Brown <[email protected]>--- tools/testing/selftests/kvm/s390/kvm_exit.c | 146 ++++++++++++++++++++ 1 file changed, 146 insertions(+)tools/testing/selftests/kvm/s390/kvm_exit.c +34
-0@@ -25,6 +25,12 @@#define NUM_GPRS 16#define DIAG_ASSEMBLY_CODE 0x501#define IPA_DIAG 0x83 +#define PSW_MASK_64BIT_DAT_OFF 0x0000000180000000ULL +#define PGM_CODE_SEGMENT_TRANSLATION 0x10 +#define PGM_CODE_GPA_ADDRESS 0x8e +#define PGM_CODE_MASK 0x7f +#define PGM_NEW_PSW_GPA 0x1d0 +#define PSW_DISABLED_WAIT 0x0002000180000000ULLstatic struct kvm_parameters create_vm_kvm_exit (struct kvm_parameters parameters) {@@ -174,6 +180,134 @@ static bool test_diagnose_conditional_code(void)return true; } +/* +* Make a program interrupt end in a disabled wait, which KVM reports to +* userspace as ICPT_WAIT. This does not depend on how KVM handles +* repeated operation exceptions. +*/ +static void set_pgm_new_psw_disabled_wait (struct kvm_vm *vm) +{ +uint64_t *new_psw =addr_gpa2hva (vm,PGM_NEW_PSW_GPA ); + + new_psw[0 ] =PSW_DISABLED_WAIT ; + new_psw[1 ] =0 ; +} + +static void guestcode_sigp (void ) +{ + asmvolatile ( +"lghi %%r3, 0\n" +"sigp %%r1, %%r3, 0x05\n" + : + : + :"r1" ,"r3" + ); +GUEST_DONE (); +} + +static bool test_sigp_signals (void ) +{ +struct kvm_parameters param = {
tools/testing/selftests/kvm/s390/kvm_exit.c static bool test_diagnose_conditional_code(void) · line 220
Quoted 10 lines
tools/testing/selftests/kvm/s390/kvm_exit.c +10
-0+ .guest_code = guestcode_sigp, + .manual_parameters.immediate_exit_condition = false, + }; +struct kvm_mp_state mp_state = { .mp_state =KVM_MP_STATE_OPERATING }; +struct kvm_vcpu *vcpu1; +struct kvm_regs regs; + +ksft_print_msg ("Testing SIGP KVM Exit\n" ); + param =create_vm_kvm_exit (param); + vcpu1 =vm_vcpu_add (param.vm,1 , guestcode_sigp);
Yeah, this makes the struct in patch 1 even worse. One VCPU is in the struct, the other one is a local variable...
tools/testing/selftests/kvm/s390/kvm_exit.c static bool test_diagnose_conditional_code(void) · line 227
Quoted 7 lines
tools/testing/selftests/kvm/s390/kvm_exit.c +7
-0+/* New vCPUs are stopped, and KVM ignores a SIGP STOP sent to one */ +vcpu_mp_state_set (param.vcpu, &mp_state); +vcpu_mp_state_set (vcpu1, &mp_state); +vcpu_regs_get (param.vcpu, ®s); + regs.gprs[3 ] =0x3333 ; +vcpu_regs_set (param.vcpu, ®s); +vcpu_run (vcpu1);
I'm a huge fan of \n between logical code blocks.
The comments are a good start already but a \n before the comments would bring it home.
Quoted 15 lines
tools/testing/selftests/kvm/s390/kvm_exit.c +15
-0+/* vcpu1 exits after GUEST_DONE() ucall */ +TEST_ASSERT_KVM_EXIT_REASON (vcpu1,KVM_EXIT_S390_SIEIC ); +vcpu_run (param.vcpu); + param.run = param.vcpu->run; +TEST_ASSERT_KVM_EXIT_REASON (param.vcpu,KVM_EXIT_S390_SIEIC ); +TEST_ASSERT_EQ (param.run->s390_sieic.icptcode,ICPT_STOP ); +/* +* The pending SIGP STOP stops vcpu0 before it runs any guest code +* (the guest would clear r3), so r3 keeps the marker value. +*/ +TEST_ASSERT_EQ (param.run->s.regs.gprs[3 ],0x3333 ); +cleanup_kvm (¶m); +return true; +} +
[...]
Quoted 10 lines
tools/testing/selftests/kvm/s390/kvm_exit.c +10
-0+ +static bool test_translation_exceptions (void ) +{ +struct kvm_parameters param = {}; +uint16_t pgm_code; + +ksft_print_msg ("Testing Translation Exception KVM Exit\n" ); + param.guest_code = guestcode_translation_exception; + param =create_vm_kvm_exit (param); +set_pgm_new_psw_disabled_wait (param.vm);
tools/testing/selftests/kvm/s390/kvm_exit.c static bool test_diagnose_conditional_code(void) · line 309
Quoted 10 lines
tools/testing/selftests/kvm/s390/kvm_exit.c +10
-0+vcpu_run (param.vcpu); + param.run = param.vcpu->run; +TEST_ASSERT_KVM_EXIT_REASON (param.vcpu,KVM_EXIT_S390_SIEIC ); +TEST_ASSERT_EQ (param.run->s390_sieic.icptcode,ICPT_WAIT ); + pgm_code = *(uint16_t *)addr_gpa2hva (param.vm,PGM_CODE_GPA_ADDRESS ); +TEST_ASSERT ((pgm_code &PGM_CODE_MASK ) ==PGM_CODE_SEGMENT_TRANSLATION , +"Expected PGM code 0x10 (segment translation), got 0x%x\n" , pgm_code); +cleanup_kvm (¶m); +return true; +}
TBH, I don't know what we gain from these mem exception tests. In their current state they are HW/FW tests and not KVM tests.
We could test PGM exits but I think I already added PGM forwarding tests when I added the feature.
For these to have a benefit we'd need to check mem exceptions for instructions which are actually emulated and not interpreted.
Quoted 23 lines
tools/testing/selftests/kvm/s390/kvm_exit.c +13
-0+static void test (void ) {int i;@@ -190,6 +324,18 @@ static void test(void) .name = "Testing Conditional DIAG Code", .test = test_diagnose_conditional_code, }, + { + .name = "Testing SIGP Exits", + .test = test_sigp_signals, + }, + { + .name = "Testing Address Exceptions", + .test = test_address_exceptions, + }, + { + .name = "Testing Translation Exceptions", + .test = test_translation_exceptions, + }, }; ksft_print_header();
Janosch Frank
maintainerRe: [PATCH 3/6] KVM: s390: selftests: Add wait state and VM lifecycle tests
In reply to Aaron M. BrownQuoted 20 lines · Aaron M. Brown
Add two tests:
- Wait state: the guest loads a PSW with the wait bit (bit 14) set and the I/O, external and machine-check masks (bits 6, 7, 13) clear. Check for
ICPT_WAITand the wait bit in the PSW.
- VM create and destroy: before the firstKVM_RUN, check thatexit_reasonisKVM_EXIT_UNKNOWNandimmediate_exitis clear.Co-developed-by Nitya Khamar <[email protected]>Signed-off-by Nitya Khamar <[email protected]>Signed-off-by Aaron M. Brown <[email protected]>--- tools/testing/selftests/kvm/s390/kvm_exit.c | 78 +++++++++++++++++++++ 1 file changed, 78 insertions(+)tools/testing/selftests/kvm/s390/kvm_exit.c +0
-0
tools/testing/selftests/kvm/s390/kvm_exit.c line 30
Quoted 4 lines
tools/testing/selftests/kvm/s390/kvm_exit.c +1
-0@@ -27,6 +27,7 @@#define IPA_DIAG 0x83#define PSW_MASK_64BIT_DAT_OFF 0x0000000180000000ULL#define PGM_CODE_SEGMENT_TRANSLATION 0x10 +#define PSW_WAIT_BIT_MASK (1ULL << (63 - 14))
ptrace.h should have this covered, it even seems to typedef the psw.
tools/testing/selftests/kvm/s390/kvm_exit.c static bool test_translation_exceptions(void) · line 312
Quoted 8 lines
tools/testing/selftests/kvm/s390/kvm_exit.c +1
-0#define PGM_CODE_GPA_ADDRESS 0x8e#define PGM_CODE_MASK 0x7f#define PGM_NEW_PSW_GPA 0x1d0@@ -308,6 +309,75 @@ static bool test_translation_exceptions(void)return true; } +static uint64_t psw_save[2 ]__aligned(16) ;
LPSWE needs a DW alignment, not a QW one, so 8 should be enough.
tools/testing/selftests/kvm/s390/kvm_exit.c static bool test_translation_exceptions(void) · line 324
Quoted 12 lines
tools/testing/selftests/kvm/s390/kvm_exit.c +12
-0+ +static void guestcode_wait_state (void ) +{ + register uint64_t *psw_ptr asm("r4") = psw_save; + + asmvolatile ( +"lghi %%r3, 0x3333\n" +"lgrl %%r7, 1f\n" +"stg %%r7, 0(%%r4)\n" +"xgr %%r5, %%r5\n" +"stg %%r5, 8(%%r4)\n" + "lpswe 0(%%r4)\n"
That's convoluted.
Have a look at the kernel's __load_psw_mask() and friends.
Quoted 42 lines
tools/testing/selftests/kvm/s390/kvm_exit.c +42
-0+ ".align 8\n" + "1: .quad 0x0002000180000000\n" + : + : "d"(psw_ptr) + : "r3", "r5", "r7", "memory" + ); +} + +static bool test_wait_state (void ) +{ +struct kvm_parameters param = {}; +struct kvm_regs regs; + +ksft_print_msg ("Testing Wait State Exit\n" ); + param.guest_code = guestcode_wait_state; + param =create_vm_kvm_exit (param); +vcpu_run (param.vcpu); + param.run = param.vcpu->run; +TEST_ASSERT (param.run->exit_reason ==KVM_EXIT_S390_SIEIC , +"Expected KVM_EXIT_S390_SIEIC, got %u\n" , + param.run->exit_reason); +TEST_ASSERT (param.run->s390_sieic.icptcode ==ICPT_WAIT , +"Failed with Unexpected Exit Reason of %u and icptcode of 0x%x\n" , + param.run->exit_reason, param.run->s390_sieic.icptcode); +vcpu_regs_get (param.vcpu, ®s); +TEST_ASSERT (regs.gprs[3 ] ==0x3333 , +"Expected 0x3333 but got 0x%llx\n" , regs.gprs[3 ]); +/* Check PSW wait bit (bit 14 from MSB = bit 63-14 from LSB) */ +TEST_ASSERT ((param.run->psw_mask &PSW_WAIT_BIT_MASK ) !=0 , +"PSW wait bit not set, PSW Mask = 0x%llx\n" , + param.run->psw_mask); +cleanup_kvm (¶m); +return true; +} + +static void guestcode_nop (void ) +{ +GUEST_DONE (); +} + +static bool test_vm_create_and_destroy (void ) +{
tools/testing/selftests/kvm/s390/kvm_exit.c static bool test_translation_exceptions(void) · line 376
Quoted 10 lines
tools/testing/selftests/kvm/s390/kvm_exit.c +10
-0+struct kvm_parameters parameters = {.guest_code = guestcode_nop}; + +ksft_print_msg ("Testing VM Closure without Running vCPU\n" ); + parameters =create_vm_kvm_exit (parameters); +TEST_ASSERT (parameters.vcpu->run->exit_reason ==KVM_EXIT_UNKNOWN , +"Unexpected Exit Reason Before vCPU Execution: %u\n" , + parameters.vcpu->run->exit_reason); +TEST_ASSERT (parameters.vcpu->run->immediate_exit ==0 , +"Immediate Exit Unexpected Behavior: %d\n" , + parameters.vcpu->run->immediate_exit);
Does the setup code even sync kvm_run?
Are we testing zero initialization of memory?
Quoted 22 lines
tools/testing/selftests/kvm/s390/kvm_exit.c +12
-0+cleanup_kvm (¶meters); +return true; +} +static void test (void ) {int i;@@ -336,6 +406,14 @@ static void test(void) .name = "Testing Translation Exceptions", .test = test_translation_exceptions, }, + { + .name = "Testing Wait State", + .test = test_wait_state, + }, + { + .name = "Testing VM Create and Destroy", + .test = test_vm_create_and_destroy, + }, };ksft_print_header ();
Janosch Frank
maintainerRe: [PATCH 4/6] KVM: s390: selftests: Add ucontrol helpers and instruction tests
In reply to Aaron M. BrownQuoted 11 lines · Aaron M. Brown
Add helpers to run a guest on a ucontrol VM and use them to test instruction intercepts handled in userspace.
manual_kvm_creation_execution()creates the VM and vCPU, maps 4 MiB withKVM_S390_UCAS_MAP, sets the PSW and r15, and runs the vCPU. r15 must be valid because C guest functions adjust it in their prologue.
ucontrol_available()checksKVM_CAP_S390_UCONTROLandCAP_SYS_ADMIN. Tests that need it are skipped, with a reason from the newskip_reasonfield.
Quoted 6 lines
Tests added: STSI, TSCH and STSCH. Each must cause
ICPT_INSTwith the expected opcode.Co-developed-by Nitya Khamar <[email protected]>Signed-off-by Nitya Khamar <[email protected]>Signed-off-by Aaron M. Brown <[email protected]>
We already have ucontrol tests which have a working fixture handling, so check what code is missing in ucontrol_test.c and move that code over instead please.