KVM: selftests: Enable ucall and dirty_log_test on s390x
v3 cover KVM: selftests: Enable ucall and dirty_log_test on s390x
Implement the ucall() interface on s390x to be able to use the dirty_log_test KVM selftest on s390x, too.
v3:
- Fix compilation issue on aarch64 (thanks to Andrew for testing it!)
- Added Reviewed-bys
v2:
- Split up ucall.c into architecture specific files
- Removed some #ifdef __s390x__ in the dirty_log patch
Thomas Huth (3):
KVM: selftests: Split ucall.c into architecture specific files
KVM: selftests: Implement ucall() for s390x
KVM: selftests: Enable dirty_log_test on s390x
tools/testing/selftests/kvm/Makefile | 9 +- tools/testing/selftests/kvm/dirty_log_test.c | 61 ++++++- .../testing/selftests/kvm/include/kvm_util.h | 8 +- .../testing/selftests/kvm/lib/aarch64/ucall.c | 112 +++++++++++++ tools/testing/selftests/kvm/lib/s390x/ucall.c | 56 +++++++ tools/testing/selftests/kvm/lib/ucall.c | 157 ------------------ .../testing/selftests/kvm/lib/x86_64/ucall.c | 56 +++++++ .../selftests/kvm/s390x/sync_regs_test.c | 6 +- 8 files changed, 287 insertions(+), 178 deletions(-) create mode 100644 tools/testing/selftests/kvm/lib/aarch64/ucall.c create mode 100644 tools/testing/selftests/kvm/lib/s390x/ucall.c delete mode 100644 tools/testing/selftests/kvm/lib/ucall.c create mode 100644 tools/testing/selftests/kvm/lib/x86_64/ucall.c
Signature · 1 line
2.21.0
PATCH v3 1/3 KVM: selftests: Split ucall.c into architecture specific files
The way we exit from a guest to userspace is very specific to the
architecture: On x86, we use PIO, on aarch64 we are using MMIO and on s390x we're going to use an instruction instead. The possibility to select a type via the ucall_type_t enum is currently also completely unused, so the code in ucall.c currently looks more complex than required. Let's split this up into architecture specific ucall.c files instead, so we can get rid of the #ifdefs and the unnecessary ucall_type_t handling.
--- tools/testing/selftests/kvm/Makefile | 6 +- tools/testing/selftests/kvm/dirty_log_test.c | 2 +- .../testing/selftests/kvm/include/kvm_util.h | 8 +- .../testing/selftests/kvm/lib/aarch64/ucall.c | 112 +++++++++++++ tools/testing/selftests/kvm/lib/ucall.c | 157 ------------------ .../testing/selftests/kvm/lib/x86_64/ucall.c | 56 +++++++ 6 files changed, 173 insertions(+), 168 deletions(-) create mode 100644 tools/testing/selftests/kvm/lib/aarch64/ucall.c delete mode 100644 tools/testing/selftests/kvm/lib/ucall.c create mode 100644 tools/testing/selftests/kvm/lib/x86_64/ucall.c
tools/testing/selftests/kvm/Makefile +3 -3
@@ -7,9 +7,9 @@ top_srcdir = ../../../.. KSFT_KHDR_INSTALL := 1 UNAME_M := $(shell uname -m) -LIBKVM = lib/assert.c lib/elf.c lib/io.c lib/kvm_util.c lib/ucall.c lib/sparsebit.c -LIBKVM_x86_64 = lib/x86_64/processor.c lib/x86_64/vmx.c -LIBKVM_aarch64 = lib/aarch64/processor.c +LIBKVM = lib/assert.c lib/elf.c lib/io.c lib/kvm_util.c lib/sparsebit.c +LIBKVM_x86_64 = lib/x86_64/processor.c lib/x86_64/vmx.c lib/x86_64/ucall.c +LIBKVM_aarch64 = lib/aarch64/processor.c lib/aarch64/ucall.c LIBKVM_s390x = lib/s390x/processor.c TEST_GEN_PROGS_x86_64 = x86_64/cr4_cpuid_sync_test
tools/testing/selftests/kvm/dirty_log_test.c +1 -1
@@ -337,7 +337,7 @@ static void run_test(enum vm_guest_mode mode, unsigned long iterations,vcpu_set_cpuid (vm,VCPU_ID ,kvm_get_supported_cpuid ());#endif #ifdef __aarch64__ -ucall_init (vm,UCALL_MMIO ,NULL ); +ucall_init (vm,NULL );#endif /* Export the shared variables to the guest */
tools/testing/selftests/kvm/include/kvm_util.h +1 -7
@@ -165,12 +165,6 @@ int vm_create_device(struct kvm_vm *vm, struct kvm_create_device *cd);memcpy (&(g), _p,sizeof (g)); \ }) -/* ucall implementation types */ -typedef enum { -UCALL_PIO , -UCALL_MMIO , -}ucall_type_t ; -/* Common ucalls */ enum {UCALL_NONE ,
@@ -186,7 +180,7 @@ struct ucall {uint64_t args[UCALL_MAX_ARGS ]; }; -void ucall_init (struct kvm_vm *vm,ucall_type_t type,void *arg); +void ucall_init (struct kvm_vm *vm,void *arg);void ucall_uninit (struct kvm_vm *vm);void ucall (uint64_t cmd,int nargs, ...);uint64_t get_ucall (struct kvm_vm *vm,uint32_t vcpu_id,struct ucall *uc);
tools/testing/selftests/kvm/lib/aarch64/ucall.c new file +112 -0
112 lines not on this page · raw message
tools/testing/selftests/kvm/lib/ucall.c deleted +0 -157
157 lines not on this page · raw message
tools/testing/selftests/kvm/lib/x86_64/ucall.c new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v3 2/3 KVM: selftests: Implement ucall() for s390x
In reply to Thomas HuthOn s390x, we can neither exit via PIO nor MMIO, but have to use an instruction like DIAGNOSE. Now that ucall() is implemented, we can use it in the sync_reg_test on s390x, too.
--- tools/testing/selftests/kvm/Makefile | 2 +- tools/testing/selftests/kvm/lib/s390x/ucall.c | 56 +++++++++++++++++++ .../selftests/kvm/s390x/sync_regs_test.c | 6 +- 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/kvm/lib/s390x/ucall.c
tools/testing/selftests/kvm/Makefile +1 -1
@@ -10,7 +10,7 @@ UNAME_M := $(shell uname -m) LIBKVM = lib/assert.c lib/elf.c lib/io.c lib/kvm_util.c lib/sparsebit.c LIBKVM_x86_64 = lib/x86_64/processor.c lib/x86_64/vmx.c lib/x86_64/ucall.c LIBKVM_aarch64 = lib/aarch64/processor.c lib/aarch64/ucall.c -LIBKVM_s390x = lib/s390x/processor.c +LIBKVM_s390x = lib/s390x/processor.c lib/s390x/ucall.c TEST_GEN_PROGS_x86_64 = x86_64/cr4_cpuid_sync_test TEST_GEN_PROGS_x86_64 += x86_64/evmcs_test
tools/testing/selftests/kvm/lib/s390x/ucall.c new file +56 -0
56 lines not on this page · raw message
tools/testing/selftests/kvm/s390x/sync_regs_test.c +4 -2
@@ -25,9 +25,11 @@static void guest_code (void ) { + register u64 stage asm("11") = 0; +for (;;) { - asmvolatile ("diag 0,0,0x501" ); - asmvolatile ("ahi 11,1" ); +GUEST_SYNC (0 ); + asmvolatile ("ahi %0,1" : :"r" (stage)); } }
Signature · 1 line
2.21.0
PATCH v3 3/3 KVM: selftests: Enable dirty_log_test on s390x
In reply to Thomas HuthTo run the dirty_log_test on s390x, we have to make sure that we access the dirty log bitmap with little endian byte ordering and we have to properly align the memslot of the guest. Also all dirty bits of a segment are set once on s390x when one of the pages of a segment are written to for the first time, so we have to make sure that we touch all pages during the first iteration to keep the test in sync here. DEFAULT_GUEST_TEST_MEM needs an adjustment, too. On some s390x distributions, the ELF binary is linked to address 0x80000000, so we have to avoid that our test region overlaps into this area. 0xc0000000 seems to be a good alternative that should work on x86 and aarch64, too.
--- tools/testing/selftests/kvm/Makefile | 1 + tools/testing/selftests/kvm/dirty_log_test.c | 59 +++++++++++++++++--- 2 files changed, 53 insertions(+), 7 deletions(-)
tools/testing/selftests/kvm/Makefile +1 -0
@@ -33,6 +33,7 @@ TEST_GEN_PROGS_aarch64 += dirty_log_test TEST_GEN_PROGS_aarch64 += kvm_create_max_vcpus TEST_GEN_PROGS_s390x += s390x/sync_regs_test +TEST_GEN_PROGS_s390x += dirty_log_test TEST_GEN_PROGS_s390x += kvm_create_max_vcpus TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M))
tools/testing/selftests/kvm/dirty_log_test.c +52 -7
117 lines not on this page · raw message
Signature · 1 line
2.21.0
Quoted 16 lines · Thomas Huth
Implement the
ucall()interface on s390x to be able to use thedirty_log_testKVM selftest on s390x, too.v3:
- Fix compilation issue on aarch64 (thanks to Andrew for testing it!)
- Added Reviewed-bysv2:
- Split upucall.cinto architecture specific files
- Removed some #ifdef__s390x__in thedirty_logpatchThomas Huth (3):
KVM: selftests: Splitucall.cinto architecture specific files
KVM: selftests: Implementucall()for s390x
KVM: selftests: Enabledirty_log_teston s390x
Quoted 14 lines
tools/testing/selftests/kvm/Makefile | 9 +- tools/testing/selftests/kvm/dirty_log_test.c | 61 ++++++- .../testing/selftests/kvm/include/kvm_util.h | 8 +- .../testing/selftests/kvm/lib/aarch64/ucall.c | 112 +++++++++++++ tools/testing/selftests/kvm/lib/s390x/ucall.c | 56 +++++++ tools/testing/selftests/kvm/lib/ucall.c | 157 ------------------ .../testing/selftests/kvm/lib/x86_64/ucall.c | 56 +++++++ .../selftests/kvm/s390x/sync_regs_test.c | 6 +- 8 files changed, 287 insertions(+), 178 deletions(-) create mode 100644 tools/testing/selftests/kvm/lib/aarch64/ucall.c create mode 100644 tools/testing/selftests/kvm/lib/s390x/ucall.c delete mode 100644 tools/testing/selftests/kvm/lib/ucall.c create mode 100644 tools/testing/selftests/kvm/lib/x86_64/ucall.c
Paolo, I guess you do not mind if I carry patch 1 also via the s390x tree?
Thanks, all applied
Quoted 32 lines · Christian Borntraeger
Quoted 16 lines · Thomas Huth
Implement the
ucall()interface on s390x to be able to use thedirty_log_testKVM selftest on s390x, too.v3:
- Fix compilation issue on aarch64 (thanks to Andrew for testing it!)
- Added Reviewed-bysv2:
- Split upucall.cinto architecture specific files
- Removed some #ifdef__s390x__in thedirty_logpatchThomas Huth (3):
KVM: selftests: Splitucall.cinto architecture specific files
KVM: selftests: Implementucall()for s390x
KVM: selftests: Enabledirty_log_teston s390xQuoted 14 lines
tools/testing/selftests/kvm/Makefile | 9 +- tools/testing/selftests/kvm/dirty_log_test.c | 61 ++++++- .../testing/selftests/kvm/include/kvm_util.h | 8 +- .../testing/selftests/kvm/lib/aarch64/ucall.c | 112 +++++++++++++ tools/testing/selftests/kvm/lib/s390x/ucall.c | 56 +++++++ tools/testing/selftests/kvm/lib/ucall.c | 157 ------------------ .../testing/selftests/kvm/lib/x86_64/ucall.c | 56 +++++++ .../selftests/kvm/s390x/sync_regs_test.c | 6 +- 8 files changed, 287 insertions(+), 178 deletions(-) create mode 100644 tools/testing/selftests/kvm/lib/aarch64/ucall.c create mode 100644 tools/testing/selftests/kvm/lib/s390x/ucall.c delete mode 100644 tools/testing/selftests/kvm/lib/ucall.c create mode 100644 tools/testing/selftests/kvm/lib/x86_64/ucall.c
Quoted 1 line
Paolo, I guess you do not mind if I carry patch 1 also via the s390x tree?
Sure,
Paolo