From a9c788f07347cf5dfcbe4bf77bf0f3a2a04c89f1 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Thu, 23 May 2019 18:43:02 +0200 Subject: KVM: selftests: Guard struct kvm_vcpu_events with __KVM_HAVE_VCPU_EVENTS The struct kvm_vcpu_events code is only available on certain architectures (arm, arm64 and x86). To be able to compile kvm_util.c also for other architectures, we have to fence the code with __KVM_HAVE_VCPU_EVENTS. Reviewed-by: David Hildenbrand Reviewed-by: Andrew Jones Signed-off-by: Thomas Huth Message-Id: <20190523164309.13345-3-thuth@redhat.com> Signed-off-by: Christian Borntraeger --- tools/testing/selftests/kvm/include/kvm_util.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tools/testing/selftests/kvm/include') diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h index a5a4b28f14d8..b8bf961074fe 100644 --- a/tools/testing/selftests/kvm/include/kvm_util.h +++ b/tools/testing/selftests/kvm/include/kvm_util.h @@ -114,10 +114,12 @@ void vcpu_sregs_set(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_sregs *sregs); int _vcpu_sregs_set(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_sregs *sregs); +#ifdef __KVM_HAVE_VCPU_EVENTS void vcpu_events_get(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_vcpu_events *events); void vcpu_events_set(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_vcpu_events *events); +#endif #ifdef __x86_64__ void vcpu_nested_state_get(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_nested_state *state); -- cgit v1.2.3 From fe85ec86fcd5998389274b6e12977bcf8509d3e0 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Thu, 23 May 2019 18:43:04 +0200 Subject: KVM: selftests: Introduce a VM_MODE_DEFAULT macro for the default bits This will be required later for tests like the kvm_create_max_vcpus test that do not use the vm_create_default() function. Reviewed-by: Andrew Jones Signed-off-by: Thomas Huth Message-Id: <20190523164309.13345-5-thuth@redhat.com> Signed-off-by: Christian Borntraeger --- tools/testing/selftests/kvm/include/kvm_util.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tools/testing/selftests/kvm/include') diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h index b8bf961074fe..b6eb6471e6b2 100644 --- a/tools/testing/selftests/kvm/include/kvm_util.h +++ b/tools/testing/selftests/kvm/include/kvm_util.h @@ -43,6 +43,12 @@ enum vm_guest_mode { NUM_VM_MODES, }; +#ifdef __aarch64__ +#define VM_MODE_DEFAULT VM_MODE_P40V48_4K +#else +#define VM_MODE_DEFAULT VM_MODE_P52V48_4K +#endif + #define vm_guest_mode_string(m) vm_guest_mode_string[m] extern const char * const vm_guest_mode_string[]; -- cgit v1.2.3 From edf54478d83eb0ca4174a2c9c01682c1d01cbe7d Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Thu, 23 May 2019 18:43:06 +0200 Subject: KVM: selftests: Add processor code for s390x Code that takes care of basic CPU setup, page table walking, etc. Signed-off-by: Thomas Huth Message-Id: <20190523164309.13345-7-thuth@redhat.com> Signed-off-by: Christian Borntraeger --- .../selftests/kvm/include/s390x/processor.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tools/testing/selftests/kvm/include/s390x/processor.h (limited to 'tools/testing/selftests/kvm/include') diff --git a/tools/testing/selftests/kvm/include/s390x/processor.h b/tools/testing/selftests/kvm/include/s390x/processor.h new file mode 100644 index 000000000000..e0e96a5f608c --- /dev/null +++ b/tools/testing/selftests/kvm/include/s390x/processor.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * s390x processor specific defines + */ +#ifndef SELFTEST_KVM_PROCESSOR_H +#define SELFTEST_KVM_PROCESSOR_H + +/* Bits in the region/segment table entry */ +#define REGION_ENTRY_ORIGIN ~0xfffUL /* region/segment table origin */ +#define REGION_ENTRY_PROTECT 0x200 /* region protection bit */ +#define REGION_ENTRY_NOEXEC 0x100 /* region no-execute bit */ +#define REGION_ENTRY_OFFSET 0xc0 /* region table offset */ +#define REGION_ENTRY_INVALID 0x20 /* invalid region table entry */ +#define REGION_ENTRY_TYPE 0x0c /* region/segment table type mask */ +#define REGION_ENTRY_LENGTH 0x03 /* region third length */ + +/* Bits in the page table entry */ +#define PAGE_INVALID 0x400 /* HW invalid bit */ +#define PAGE_PROTECT 0x200 /* HW read-only bit */ +#define PAGE_NOEXEC 0x100 /* HW no-execute bit */ + +#endif -- cgit v1.2.3