KVM: selftests: add powerpc support
Subsystems (5)
Nicholas Piggin
reviewerv4 cover KVM: selftests: add powerpc support
This series adds initial KVM selftests support for powerpc (64-bit, BookS, radix MMU).
Since v3:
https://lore.kernel.org/linuxppc-dev/[email protected]/
- Rebased to upstream (on top of Sean's ucall and guest assert rework).
- Drop powerpc specific tests for now, concentrate on base enablement.
- Fix a bunch of bugs and issues including the ones noticed by Joel in v3:
- Work around powerpc's max VCPU ID complexity to fix test case failure.
- Use TEST_REQUIRE for radix mode so hash hosts don't assert.
- Pack page table "fragments" in pages (like Linux kernel does), which fixes PTE memory consumption estimation and prevents the max memory test from failing with no memory for page tables.
Since v2:
- Added a couple of new tests (patch 5,6)
- Make default page size match host page size.
- Check for radix MMU capability.
- Build a few more of the generic tests.
Since v1:
- Update MAINTAINERS KVM PPC entry to include kvm selftests.
- Fixes and cleanups from Sean's review including new patch 1.
- Add 4K guest page support requiring new patch 2.
Thanks,
Nick
Nicholas Piggin (4):
KVM: selftests: Move pgd_created check into virt_pgd_alloc
KVM: selftests: Add aligned guest physical page allocator
KVM: PPC: selftests: add support for powerpc
KVM: PPC: selftests: powerpc enable kvm_create_max_vcpus test
MAINTAINERS | 2 + tools/testing/selftests/kvm/Makefile | 20 + .../selftests/kvm/include/kvm_util_base.h | 31 ++ .../selftests/kvm/include/powerpc/hcall.h | 17 + .../selftests/kvm/include/powerpc/ppc_asm.h | 32 ++ .../selftests/kvm/include/powerpc/processor.h | 39 ++ .../selftests/kvm/include/powerpc/ucall.h | 21 + .../selftests/kvm/kvm_create_max_vcpus.c | 9 + .../selftests/kvm/lib/aarch64/processor.c | 4 - tools/testing/selftests/kvm/lib/guest_modes.c | 27 +- tools/testing/selftests/kvm/lib/kvm_util.c | 56 ++- .../selftests/kvm/lib/powerpc/handlers.S | 93 ++++ .../testing/selftests/kvm/lib/powerpc/hcall.c | 45 ++ .../selftests/kvm/lib/powerpc/processor.c | 468 ++++++++++++++++++ .../testing/selftests/kvm/lib/powerpc/ucall.c | 21 + .../selftests/kvm/lib/riscv/processor.c | 4 - .../selftests/kvm/lib/s390x/processor.c | 4 - .../selftests/kvm/lib/x86_64/processor.c | 7 +- tools/testing/selftests/kvm/powerpc/helpers.h | 46 ++ 19 files changed, 908 insertions(+), 38 deletions(-) create mode 100644 tools/testing/selftests/kvm/include/powerpc/hcall.h create mode 100644 tools/testing/selftests/kvm/include/powerpc/ppc_asm.h create mode 100644 tools/testing/selftests/kvm/include/powerpc/processor.h create mode 100644 tools/testing/selftests/kvm/include/powerpc/ucall.h create mode 100644 tools/testing/selftests/kvm/lib/powerpc/handlers.S create mode 100644 tools/testing/selftests/kvm/lib/powerpc/hcall.c create mode 100644 tools/testing/selftests/kvm/lib/powerpc/processor.c create mode 100644 tools/testing/selftests/kvm/lib/powerpc/ucall.c create mode 100644 tools/testing/selftests/kvm/powerpc/helpers.h
Signature · 1 line
2.42.0
Nicholas Piggin
reviewerPATCH v4 1/4 KVM: selftests: Move pgd_created check into virt_pgd_alloc
virt_arch_pgd_alloc all do the same test and set of pgd_created. Move this into common code.
--- tools/testing/selftests/kvm/include/kvm_util_base.h | 5 +++++ tools/testing/selftests/kvm/lib/aarch64/processor.c | 4 ---- tools/testing/selftests/kvm/lib/riscv/processor.c | 4 ---- tools/testing/selftests/kvm/lib/s390x/processor.c | 4 ---- tools/testing/selftests/kvm/lib/x86_64/processor.c | 7 ++----- 5 files changed, 7 insertions(+), 17 deletions(-)
tools/testing/selftests/kvm/include/kvm_util_base.h +5 -0
@@ -846,7 +846,12 @@ void virt_arch_pgd_alloc(struct kvm_vm *vm);static inline void virt_pgd_alloc (struct kvm_vm *vm) { +if (vm->pgd_created) +return ; +virt_arch_pgd_alloc (vm); + + vm->pgd_created = true; }/*
tools/testing/selftests/kvm/lib/aarch64/processor.c +0 -4
@@ -96,13 +96,9 @@ void virt_arch_pgd_alloc(struct kvm_vm *vm) {size_t nr_pages =page_align (vm,ptrs_per_pgd (vm) *8 ) / vm->page_size; -if (vm->pgd_created) -return ; - vm->pgd =vm_phy_pages_alloc (vm, nr_pages,KVM_GUEST_PAGE_TABLE_MIN_PADDR , vm->memslots[MEM_REGION_PT ]); - vm->pgd_created = true; } static void _virt_pg_map(struct kvm_vm *vm, uint64_t vaddr, uint64_t paddr,
tools/testing/selftests/kvm/lib/riscv/processor.c +0 -4
@@ -57,13 +57,9 @@ void virt_arch_pgd_alloc(struct kvm_vm *vm) {size_t nr_pages =page_align (vm,ptrs_per_pte (vm) *8 ) / vm->page_size; -if (vm->pgd_created) -return ; - vm->pgd =vm_phy_pages_alloc (vm, nr_pages,KVM_GUEST_PAGE_TABLE_MIN_PADDR , vm->memslots[MEM_REGION_PT ]); - vm->pgd_created = true; }void virt_arch_pg_map (struct kvm_vm *vm,uint64_t vaddr,uint64_t paddr)
tools/testing/selftests/kvm/lib/s390x/processor.c +0 -4
@@ -17,16 +17,12 @@ void virt_arch_pgd_alloc(struct kvm_vm *vm)TEST_ASSERT (vm->page_size ==4096 ,"Unsupported page size: 0x%x" , vm->page_size); -if (vm->pgd_created) -return ; - paddr =vm_phy_pages_alloc (vm,PAGES_PER_REGION ,KVM_GUEST_PAGE_TABLE_MIN_PADDR , vm->memslots[MEM_REGION_PT ]);memset (addr_gpa2hva (vm, paddr),0xff ,PAGES_PER_REGION * vm->page_size); vm->pgd = paddr; - vm->pgd_created = true; }/*
tools/testing/selftests/kvm/lib/x86_64/processor.c +2 -5
@@ -127,11 +127,8 @@ void virt_arch_pgd_alloc(struct kvm_vm *vm)TEST_ASSERT (vm->mode ==VM_MODE_PXXV48_4K ,"Attempt to use " "unknown or unsupported guest mode, mode: 0x%x" , vm->mode); -/* If needed, create page map l4 table. */ -if (!vm->pgd_created) { - vm->pgd =vm_alloc_page_table (vm); - vm->pgd_created = true; - } +/* Create page map l4 table. */ + vm->pgd =vm_alloc_page_table (vm); } static void *virt_get_pte(struct kvm_vm *vm, uint64_t *parent_pte,
Signature · 1 line
2.42.0
Nicholas Piggin
reviewerPATCH v4 2/4 KVM: selftests: Add aligned guest physical page allocator
In reply to Nicholas Pigginpowerpc will require this to allocate MMU tables in guest memory that are larger than guest base page size.
--- .../selftests/kvm/include/kvm_util_base.h | 2 + tools/testing/selftests/kvm/lib/kvm_util.c | 44 ++++++++++++------- 2 files changed, 29 insertions(+), 17 deletions(-)
tools/testing/selftests/kvm/include/kvm_util_base.h +2 -0
@@ -703,6 +703,8 @@ const char *exit_reason_str(unsigned int exit_reason);vm_paddr_t vm_phy_page_alloc (struct kvm_vm *vm,vm_paddr_t paddr_min,uint32_t memslot); +vm_paddr_t vm_phy_pages_alloc_align (struct kvm_vm *vm,size_t num,size_t align, +vm_paddr_t paddr_min,uint32_t memslot);vm_paddr_t vm_phy_pages_alloc (struct kvm_vm *vm,size_t num,vm_paddr_t paddr_min,uint32_t memslot);vm_paddr_t vm_alloc_page_table (struct kvm_vm *vm);
tools/testing/selftests/kvm/lib/kvm_util.c +27 -17
70 lines not on this page · raw message
Signature · 1 line
2.42.0
Nicholas Piggin
reviewerPATCH v4 3/4 KVM: PPC: selftests: add support for powerpc
In reply to Nicholas PigginImplement KVM selftests support for powerpc (Book3S-64).
ucalls are implemented with an unsuppored PAPR hcall number which will always cause KVM to exit to userspace.
Virtual memory is implemented for the radix MMU, and only a base page size is supported (both 4K and 64K).
Guest interrupts are taken in real-mode, so require a page allocated at gRA 0x0. Interrupt entry is complicated because gVA:gRA is not 1:1 mapped (like the kernel is), so the MMU can not just just be switched on and off.
--- MAINTAINERS | 2 + tools/testing/selftests/kvm/Makefile | 19 + .../selftests/kvm/include/kvm_util_base.h | 24 + .../selftests/kvm/include/powerpc/hcall.h | 17 + .../selftests/kvm/include/powerpc/ppc_asm.h | 32 ++ .../selftests/kvm/include/powerpc/processor.h | 39 ++ .../selftests/kvm/include/powerpc/ucall.h | 21 + tools/testing/selftests/kvm/lib/guest_modes.c | 27 +- tools/testing/selftests/kvm/lib/kvm_util.c | 12 + .../selftests/kvm/lib/powerpc/handlers.S | 93 ++++ .../testing/selftests/kvm/lib/powerpc/hcall.c | 45 ++ .../selftests/kvm/lib/powerpc/processor.c | 468 ++++++++++++++++++ .../testing/selftests/kvm/lib/powerpc/ucall.c | 21 + tools/testing/selftests/kvm/powerpc/helpers.h | 46 ++ 14 files changed, 862 insertions(+), 4 deletions(-) create mode 100644 tools/testing/selftests/kvm/include/powerpc/hcall.h create mode 100644 tools/testing/selftests/kvm/include/powerpc/ppc_asm.h create mode 100644 tools/testing/selftests/kvm/include/powerpc/processor.h create mode 100644 tools/testing/selftests/kvm/include/powerpc/ucall.h create mode 100644 tools/testing/selftests/kvm/lib/powerpc/handlers.S create mode 100644 tools/testing/selftests/kvm/lib/powerpc/hcall.c create mode 100644 tools/testing/selftests/kvm/lib/powerpc/processor.c create mode 100644 tools/testing/selftests/kvm/lib/powerpc/ucall.c create mode 100644 tools/testing/selftests/kvm/powerpc/helpers.h
MAINTAINERS +2 -0
@@ -11705,6 +11705,8 @@ F: arch/powerpc/include/asm/kvm* F: arch/powerpc/include/uapi/asm/kvm* F: arch/powerpc/kernel/kvm* F: arch/powerpc/kvm/ +F: tools/testing/selftests/kvm/*/powerpc/ +F: tools/testing/selftests/kvm/powerpc/ KERNEL VIRTUAL MACHINE FOR RISC-V (KVM/riscv) M: Anup Patel <[email protected]>
tools/testing/selftests/kvm/Makefile +19 -0
@@ -65,6 +65,11 @@ LIBKVM_s390x += lib/s390x/ucall.c LIBKVM_riscv += lib/riscv/processor.c LIBKVM_riscv += lib/riscv/ucall.c +LIBKVM_powerpc += lib/powerpc/handlers.S +LIBKVM_powerpc += lib/powerpc/processor.c +LIBKVM_powerpc += lib/powerpc/ucall.c +LIBKVM_powerpc += lib/powerpc/hcall.c + # Non-compiled test targets TEST_PROGS_x86_64 += x86_64/nx_huge_pages_test.sh
@@ -200,6 +205,20 @@ TEST_GEN_PROGS_riscv += kvm_page_table_test TEST_GEN_PROGS_riscv += set_memory_region_test TEST_GEN_PROGS_riscv += kvm_binary_stats_test +TEST_GEN_PROGS_powerpc += access_tracking_perf_test +TEST_GEN_PROGS_powerpc += demand_paging_test +TEST_GEN_PROGS_powerpc += dirty_log_test +TEST_GEN_PROGS_powerpc += dirty_log_perf_test +TEST_GEN_PROGS_powerpc += guest_print_test +TEST_GEN_PROGS_powerpc += hardware_disable_test +TEST_GEN_PROGS_powerpc += kvm_page_table_test +TEST_GEN_PROGS_powerpc += max_guest_memory_test +TEST_GEN_PROGS_powerpc += memslot_modification_stress_test +TEST_GEN_PROGS_powerpc += memslot_perf_test +TEST_GEN_PROGS_powerpc += rseq_test +TEST_GEN_PROGS_powerpc += set_memory_region_test +TEST_GEN_PROGS_powerpc += kvm_binary_stats_test + SPLIT_TESTS += get-reg-list TEST_PROGS += $(TEST_PROGS_$(ARCH_DIR))
tools/testing/selftests/kvm/include/kvm_util_base.h +24 -0
@@ -87,6 +87,12 @@ enum kvm_mem_region_type { NR_MEM_REGIONS, }; +/* Page table fragment cache for guest page table < page size */ +struct vm_pt_frag_cache { +vm_paddr_t page; +size_t page_nr_used; +}; +struct kvm_vm {int mode;unsigned long type;
@@ -106,6 +112,10 @@ struct kvm_vm {bool pgd_created;vm_paddr_t ucall_mmio_addr;vm_paddr_t pgd; +#if defined(__powerpc64__) +vm_paddr_t prtb;// process table +struct vm_pt_frag_cache pt_frag_cache[2 ];// 256B and 4KB PT caches +#endif vm_vaddr_t gdt;vm_vaddr_t tss;vm_vaddr_t idt;
@@ -181,6 +191,8 @@ enum vm_guest_mode {VM_MODE_PXXV48_4K ,/* For 48bits VA but ANY bits PA */ VM_MODE_P47V64_4K ,VM_MODE_P44V64_4K , +VM_MODE_P52V52_4K , +VM_MODE_P52V52_64K ,VM_MODE_P36V48_4K ,VM_MODE_P36V48_16K , VM_MODE_P36V48_64K,
@@ -218,6 +230,18 @@ extern enum vm_guest_mode vm_mode_default;#define MIN_PAGE_SHIFT 12U#define ptes_per_page (page_size) ((page_size) / 8) +#elif defined(__powerpc64__) + +extern enum vm_guest_mode vm_mode_default; + +#define VM_MODE_DEFAULT vm_mode_default +#define MIN_PAGE_SHIFT 12U +#define ptes_per_page (page_size) ((page_size) / 8) + +#else + +#error "KVM selftests not implemented for architecture" +#endif #define MIN_PAGE_SIZE (1U << MIN_PAGE_SHIFT)
tools/testing/selftests/kvm/include/powerpc/hcall.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* powerpc hcall defines +*/ +#ifndef SELFTEST_KVM_HCALL_H +#define SELFTEST_KVM_HCALL_H + +#include <linux/compiler.h> + +/* Ucalls use unimplemented PAPR hcall 0 which exits KVM */ +#define H_UCALL 0 + +int64_t hcall0 (uint64_t token); +int64_t hcall1 (uint64_t token,uint64_t arg1); +int64_t hcall2 (uint64_t token,uint64_t arg1,uint64_t arg2); + +#endif
tools/testing/selftests/kvm/include/powerpc/ppc_asm.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* powerpc asm specific defines +*/ +#ifndef SELFTEST_KVM_PPC_ASM_H +#define SELFTEST_KVM_PPC_ASM_H + +#define STACK_FRAME_MIN_SIZE 112/* Could be 32 on ELFv2 */ +#define STACK_REDZONE_SIZE 512 + +#define INT_FRAME_SIZE (STACK_FRAME_MIN_SIZE + STACK_REDZONE_SIZE) + +#define SPR_SRR0 0x01a +#define SPR_SRR1 0x01b +#define SPR_CFAR 0x01c + +#define MSR_SF 0x8000000000000000ULL +#define MSR_HV 0x1000000000000000ULL +#define MSR_VEC 0x0000000002000000ULL +#define MSR_VSX 0x0000000000800000ULL +#define MSR_EE 0x0000000000008000ULL +#define MSR_PR 0x0000000000004000ULL +#define MSR_FP 0x0000000000002000ULL +#define MSR_ME 0x0000000000001000ULL +#define MSR_IR 0x0000000000000020ULL +#define MSR_DR 0x0000000000000010ULL +#define MSR_RI 0x0000000000000002ULL +#define MSR_LE 0x0000000000000001ULL + +#define LPCR_ILE 0x0000000002000000ULL + +#endif
tools/testing/selftests/kvm/include/powerpc/processor.h new file +39 -0
@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* powerpc processor specific defines +*/ +#ifndef SELFTEST_KVM_PROCESSOR_H +#define SELFTEST_KVM_PROCESSOR_H + +#include <linux/compiler.h> +#include "ppc_asm.h" + +extern unsigned char __interrupts_start[]; +extern unsigned char __interrupts_end[]; + +struct kvm_vm ; +struct kvm_vcpu ; +extern bool (*interrupt_handler)(struct kvm_vcpu *vcpu,unsigned trap); + +struct ex_regs { +uint64_t gprs[32 ]; +uint64_t nia; +uint64_t msr; +uint64_t cfar; +uint64_t lr; +uint64_t ctr; +uint64_t xer; +uint32_t cr; +uint32_t trap; +uint64_t vaddr;/* vaddr of this struct */ +}; + +void vm_install_exception_handler (struct kvm_vm *vm,int vector, +void (*handler)(struct ex_regs *)); + +static inline void cpu_relax (void ) +{ + asmvolatile ("" :::"memory" ); +} + +#endif
tools/testing/selftests/kvm/include/powerpc/ucall.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef SELFTEST_KVM_UCALL_H +#define SELFTEST_KVM_UCALL_H + +#include "hcall.h" + +#define UCALL_EXIT_REASON KVM_EXIT_PAPR_HCALL + +#define UCALL_R4_UCALL 0x5715 // regular ucall, r5 contains ucall pointer +#define UCALL_R4_SIMPLE 0x0000 // simple exit usable by asm with no ucall data + +static inline void ucall_arch_init (struct kvm_vm *vm,vm_paddr_t mmio_gpa) +{ +} + +static inline void ucall_arch_do_ucall (vm_vaddr_t uc) +{ +hcall2 (H_UCALL ,UCALL_R4_UCALL , (uintptr_t )(uc)); +} + +#endif
tools/testing/selftests/kvm/lib/guest_modes.c +23 -4
@@ -4,7 +4,11 @@*/ #include "guest_modes.h" -#ifdef __aarch64__ +#if defined(__powerpc__) +#include <unistd.h> +#endif + +#if defined(__aarch64__) || defined(__powerpc__)#include "processor.h" enum vm_guest_mode vm_mode_default;#endif
@@ -13,9 +17,7 @@ struct guest_mode guest_modes[NUM_VM_MODES];void guest_modes_append_default (void ) { -#ifndef __aarch64__ -guest_mode_append (VM_MODE_DEFAULT , true, true); -#else +#ifdef __aarch64__ {unsigned int limit =kvm_check_cap (KVM_CAP_ARM_VM_IPA_SIZE );bool ps4k, ps16k, ps64k;
@@ -70,6 +72,8 @@ void guest_modes_append_default(void) KVM_S390_VM_CPU_PROCESSOR, &info);close (vm_fd);close (kvm_fd); + +guest_mode_append (VM_MODE_DEFAULT , true, true);/* Starting with z13 we have 47bits of physical address */ if (info.ibc >=0x30 )guest_mode_append (VM_MODE_P47V64_4K , true, true);
@@ -79,12 +83,27 @@ void guest_modes_append_default(void) {unsigned int sz =kvm_check_cap (KVM_CAP_VM_GPA_BITS ); +guest_mode_append (VM_MODE_DEFAULT , true, true);if (sz >=52 )guest_mode_append (VM_MODE_P52V48_4K , true, true);if (sz >=48 )guest_mode_append (VM_MODE_P48V48_4K , true, true); }#endif +#ifdef __powerpc__ + { +TEST_ASSERT (kvm_check_cap (KVM_CAP_PPC_MMU_RADIX ), +"Radix MMU not available, KVM selftests " +"does not support Hash MMU!" ); +/* Radix guest EA and RA are 52-bit on POWER9 and POWER10 */ +if (sysconf (_SC_PAGESIZE) ==4096 ) + vm_mode_default =VM_MODE_P52V52_4K ; +else + vm_mode_default =VM_MODE_P52V52_64K ; +guest_mode_append (VM_MODE_P52V52_4K , true, true); +guest_mode_append (VM_MODE_P52V52_64K , true, true); + } +#endif }void for_each_guest_mode (void (*func)(enum vm_guest_mode ,void *),void *arg)
tools/testing/selftests/kvm/lib/kvm_util.c +12 -0
@@ -158,6 +158,8 @@ const char *vm_guest_mode_string(uint32_t i) [VM_MODE_PXXV48_4K] = "PA-bits:ANY, VA-bits:48, 4K pages", [VM_MODE_P47V64_4K] = "PA-bits:47, VA-bits:64, 4K pages", [VM_MODE_P44V64_4K] = "PA-bits:44, VA-bits:64, 4K pages", + [VM_MODE_P52V52_4K] = "PA-bits:52, VA-bits:52, 4K pages", + [VM_MODE_P52V52_64K] = "PA-bits:52, VA-bits:52, 64K pages", [VM_MODE_P36V48_4K] = "PA-bits:36, VA-bits:48, 4K pages", [VM_MODE_P36V48_16K] = "PA-bits:36, VA-bits:48, 16K pages", [VM_MODE_P36V48_64K] = "PA-bits:36, VA-bits:48, 64K pages",
@@ -183,6 +185,8 @@ const struct vm_guest_mode_params vm_guest_mode_params[] = { [VM_MODE_PXXV48_4K] = { 0, 0, 0x1000, 12 }, [VM_MODE_P47V64_4K] = { 47, 64, 0x1000, 12 }, [VM_MODE_P44V64_4K] = { 44, 64, 0x1000, 12 }, + [VM_MODE_P52V52_4K] = { 52, 52, 0x1000, 12 }, + [VM_MODE_P52V52_64K] = { 52, 52, 0x10000, 16 }, [VM_MODE_P36V48_4K] = { 36, 48, 0x1000, 12 }, [VM_MODE_P36V48_16K] = { 36, 48, 0x4000, 14 }, [VM_MODE_P36V48_64K] = { 36, 48, 0x10000, 16 },
@@ -284,6 +288,14 @@ struct kvm_vm *____vm_create(enum vm_guest_mode mode)case VM_MODE_P44V64_4K : vm->pgtable_levels =5 ;break ; +#ifdef __powerpc__ +case VM_MODE_P52V52_64K : + vm->pgtable_levels =4 ; +break ; +case VM_MODE_P52V52_4K : + vm->pgtable_levels =4 ; +break ; +#endif default :TEST_FAIL ("Unknown guest mode, mode: 0x%x" , mode); }
tools/testing/selftests/kvm/lib/powerpc/handlers.S new file +93 -0
93 lines not on this page · raw message
tools/testing/selftests/kvm/lib/powerpc/hcall.c new file +45 -0
45 lines not on this page · raw message
tools/testing/selftests/kvm/lib/powerpc/processor.c new file +468 -0
468 lines not on this page · raw message
tools/testing/selftests/kvm/lib/powerpc/ucall.c new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* ucall support. A ucall is a "hypercall to host userspace". +*/ +#include "kvm_util.h" +#include "hcall.h" + +void *ucall_arch_get_ucall (struct kvm_vcpu *vcpu) +{ +struct kvm_run *run = vcpu->run; + +if (run->exit_reason ==UCALL_EXIT_REASON && + run->papr_hcall.nr ==H_UCALL ) { +struct kvm_regs regs; + +vcpu_regs_get (vcpu, ®s); +if (regs.gpr[4 ] ==UCALL_R4_UCALL ) +return (void *)regs.gpr[5 ]; + } +return NULL ; +}
tools/testing/selftests/kvm/powerpc/helpers.h new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
2.42.0
Nicholas Piggin
reviewerPATCH v4 4/4 KVM: PPC: selftests: powerpc enable kvm_create_max_vcpus test
In reply to Nicholas Pigginpowerpc's maximum permitted vCPU ID depends on the VM's SMT mode, and the maximum reported by KVM_CAP_MAX_VCPU_ID exceeds a simple non-SMT VM's limit.
The powerpc KVM selftest port uses non-SMT VMs, so add a workaround to the kvm_create_max_vcpus test case to limit vCPU IDs to KVM_CAP_MAX_VCPUS on powerpc. And enable the test case.
--- tools/testing/selftests/kvm/Makefile | 1 + tools/testing/selftests/kvm/kvm_create_max_vcpus.c | 9 +++++++++ 2 files changed, 10 insertions(+)
tools/testing/selftests/kvm/Makefile +1 -0
@@ -211,6 +211,7 @@ TEST_GEN_PROGS_powerpc += dirty_log_test TEST_GEN_PROGS_powerpc += dirty_log_perf_test TEST_GEN_PROGS_powerpc += guest_print_test TEST_GEN_PROGS_powerpc += hardware_disable_test +TEST_GEN_PROGS_powerpc += kvm_create_max_vcpus TEST_GEN_PROGS_powerpc += kvm_page_table_test TEST_GEN_PROGS_powerpc += max_guest_memory_test TEST_GEN_PROGS_powerpc += memslot_modification_stress_test
tools/testing/selftests/kvm/kvm_create_max_vcpus.c +9 -0
@@ -51,6 +51,15 @@ int main(int argc, char *argv[])pr_info ("KVM_CAP_MAX_VCPU_ID: %d\n" , kvm_max_vcpu_id);pr_info ("KVM_CAP_MAX_VCPUS: %d\n" , kvm_max_vcpus); +#ifdef __powerpc64__ +/* +* powerpc has a particular format for the vcpu ID that depends on +* the guest SMT mode, and the max ID cap is too large for non-SMT +* modes, where the maximum ID is the same as the maximum vCPUs. +*/ + kvm_max_vcpu_id = kvm_max_vcpus; +#endif +/* * Check that we're allowed to open nr_fds_wanted file descriptors and * try raising the limits if needed.
Signature · 1 line
2.42.0