KVM: selftests: add powerpc support
Subsystems (3)
v4 cover KVM: selftests: add powerpc support
PATCH v3 -> PATCH v4:
==================
- Rebased on top of Sean's new page allocator patch series v2 [1] This allowed to drop and patch-2 since it will now come from Sean's v2.
- Addressed review comments from Sean - squashed patches 6-10 in patch-1 of this.
- Dropped patch-5 to print vcpu_id when KVM_CREATE_VCPU ioctl fails.
- Added additional patch-3 to this series to allow dirty_log_test to run on all big-endian machines.
[1]: https://lore.kernel.org/kvm/[email protected]/
[v3]: https://lore.kernel.org/linuxppc-dev/2d2c46be7f051c7f1c645afaec67f57067d37a81.1781093720.git.ritesh.list@gmail.com/
Testing updates:
================
I have done some fair amount of testing of the selftests both on real HW and using various combinations on qemu (powernv+LE (default), pseries+cap-nested-hv, pseries+cap-nested-papr, powernv+BE). There were few powerpc kvm kernel fixes which were identified as part of this work. I will send those patches separately as those anyway needs to go in separately.
<pasted snippet of cover letter from previous versions>
=======================================================
Hi All,
This series primarly adds KVM selftests support for powerpc (64-bit, BookS, radix MMU).
This patch series is originally Nick's work. I have mainly only rebased it on the latest upstream tree. Since the rebase required few changes to all the four patches (Patch 1-4), I have dropped the earlier Acked-by from Michael Ellerman.
Since the last series was posted three years ago [1], I am resetting the version to RFC. This rebase was done as part of a larger effort to improve the selftests infrastructure for Linux on PowerPC tree. Thanks to Harsh and Maddy for their help on this.
Nicholas Piggin (1):
KVM: PPC: selftests: add support for powerpc
Ritesh Harjani (IBM) (2):
KVM: PPC: selftests: powerpc enable kvm_create_max_vcpus test
KVM: selftests: Use LE bitops for dirty bitmaps on all big-endian
hosts
MAINTAINERS | 2 + tools/testing/selftests/kvm/Makefile | 2 +- tools/testing/selftests/kvm/Makefile.kvm | 10 + tools/testing/selftests/kvm/dirty_log_test.c | 12 +- .../testing/selftests/kvm/include/kvm_util.h | 9 + .../selftests/kvm/include/powerpc/hcall.h | 17 + .../kvm/include/powerpc/kvm_util_arch.h | 22 + .../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 | 8 +- tools/testing/selftests/kvm/lib/guest_modes.c | 20 +- tools/testing/selftests/kvm/lib/kvm_util.c | 8 + .../selftests/kvm/lib/powerpc/handlers.S | 93 ++++ .../testing/selftests/kvm/lib/powerpc/hcall.c | 45 ++ .../selftests/kvm/lib/powerpc/processor.c | 512 ++++++++++++++++++ .../testing/selftests/kvm/lib/powerpc/ucall.c | 22 + 17 files changed, 862 insertions(+), 12 deletions(-) create mode 100644 tools/testing/selftests/kvm/include/powerpc/hcall.h create mode 100644 tools/testing/selftests/kvm/include/powerpc/kvm_util_arch.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
--
2.39.5
PATCH v4 1/3 KVM: PPC: selftests: add support for powerpc
From: Nicholas Piggin <[email protected]>
Implement KVM selftests support for powerpc (Book3S-64).
ucalls are implemented with an unsupported 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 be switched on and off.
This patch series also changes the following types as done in other selftests. These changes are squashed in this main patch as discussed here [1]:
- Use u64 instead of uint64_t
- Use s64 instead of int64_t
- Use u32 instead of uint32_t
- Use u8 instead of uint8_t
- Replace u64 gpa, u64 gva|vaddr with gpa_t and gva_t
- Adopt to the new page table allocator APIs
- Start the guest at the entry point and not the descriptor in case of elfv1
[1]: https://lore.kernel.org/linuxppc-dev/[email protected]/
[Rebased to latest mainline tree, "cc" to clobber list, fix the
size calculation in kvm_arch_vm_post_create()]
--- MAINTAINERS | 2 + tools/testing/selftests/kvm/Makefile | 2 +- tools/testing/selftests/kvm/Makefile.kvm | 10 + .../testing/selftests/kvm/include/kvm_util.h | 9 + .../selftests/kvm/include/powerpc/hcall.h | 17 + .../kvm/include/powerpc/kvm_util_arch.h | 22 + .../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 | 20 +- tools/testing/selftests/kvm/lib/kvm_util.c | 8 + .../selftests/kvm/lib/powerpc/handlers.S | 93 ++++ .../testing/selftests/kvm/lib/powerpc/hcall.c | 45 ++ .../selftests/kvm/lib/powerpc/processor.c | 512 ++++++++++++++++++ .../testing/selftests/kvm/lib/powerpc/ucall.c | 22 + 15 files changed, 851 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/kvm/include/powerpc/hcall.h create mode 100644 tools/testing/selftests/kvm/include/powerpc/kvm_util_arch.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
MAINTAINERS +2 -0
@@ -14349,6 +14349,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 +1 -1
@@ -3,7 +3,7 @@ top_srcdir = ../../../.. include $(top_srcdir)/scripts/subarch.include ARCH ?= $(SUBARCH) -ifeq ($(ARCH),$(filter $(ARCH),arm64 s390 riscv x86 x86_64 loongarch)) +ifeq ($(ARCH),$(filter $(ARCH),arm64 s390 riscv x86 x86_64 loongarch powerpc)) # Top-level selftests allows ARCH=x86_64 :-( ifeq ($(ARCH),x86_64) override ARCH := x86
tools/testing/selftests/kvm/Makefile.kvm +10 -0
@@ -53,6 +53,11 @@ LIBKVM_loongarch += lib/loongarch/processor.c LIBKVM_loongarch += lib/loongarch/ucall.c LIBKVM_loongarch += lib/loongarch/exception.S +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 += x86/nx_huge_pages_test.sh
@@ -251,6 +256,11 @@ TEST_GEN_PROGS_loongarch += memslot_perf_test TEST_GEN_PROGS_loongarch += set_memory_region_test TEST_GEN_PROGS_loongarch += steal_time +TEST_GEN_PROGS_powerpc = $(TEST_GEN_PROGS_COMMON) +TEST_GEN_PROGS_powerpc += access_tracking_perf_test +TEST_GEN_PROGS_powerpc += dirty_log_perf_test +TEST_GEN_PROGS_powerpc += hardware_disable_test + SPLIT_TESTS += arch_timer SPLIT_TESTS += get-reg-list
tools/testing/selftests/kvm/include/kvm_util.h +9 -0
@@ -241,6 +241,9 @@ enum vm_guest_mode {VM_MODE_P41V48_4K ,VM_MODE_P41V39_4K , +VM_MODE_P52V52_4K ,/* For powerpc64 */ +VM_MODE_P52V52_64K , + NUM_VM_MODES, };
@@ -300,6 +303,12 @@ 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__) + +#define VM_MODE_DEFAULT vm_mode_default +#define MIN_PAGE_SHIFT 12U +#define ptes_per_page (page_size) ((page_size) / 8) +#endif #define VM_SHAPE_DEFAULT VM_SHAPE(VM_MODE_DEFAULT)
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 + +s64 hcall0 (u64 token); +s64 hcall1 (u64 token,u64 arg1); +s64 hcall2 (u64 token,u64 arg1,u64 arg2); + +#endif
tools/testing/selftests/kvm/include/powerpc/kvm_util_arch.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef SELFTEST_KVM_UTIL_ARCH_H +#define SELFTEST_KVM_UTIL_ARCH_H + +#include <stdint.h> + +#include "kvm_util_types.h" + +struct kvm_mmu_arch {}; + +/* Page table fragment cache for guest page tables < page size */ +struct vm_pt_frag_cache { +gpa_t page; +size_t page_nr_used; +}; + +struct kvm_vm_arch { +gpa_t prtb;/* process table */ +struct vm_pt_frag_cache pt_frag_cache[2 ];/* 256B and 4KB PT caches */ +}; + +#endif /* SELFTEST_KVM_UTIL_ARCH_H */
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" +#include "kvm_util_types.h" + +extern unsigned char __interrupts_start[]; +extern unsigned char __interrupts_end[]; + +struct kvm_vm ; +struct kvm_vcpu ; + +struct ex_regs { +u64 gprs[32 ]; +u64 nia; +u64 msr; +u64 cfar; +u64 lr; +u64 ctr; +u64 xer; +u32 cr; +u32 trap; +gva_t gva;/* gva 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,gpa_t mmio_gpa) +{ +} + +static inline void ucall_arch_do_ucall (gva_t uc) +{ +hcall2 (H_UCALL ,UCALL_R4_UCALL , (uintptr_t )(uc)); +} + +#endif
tools/testing/selftests/kvm/lib/guest_modes.c +18 -2
@@ -4,16 +4,20 @@*/ #include "guest_modes.h" -#if defined(__aarch64__) || defined(__riscv) +#if defined(__aarch64__) || defined(__riscv) || defined(__powerpc64__)#include "processor.h" enum vm_guest_mode vm_mode_default;#endif +#if defined(__powerpc64__) +#include <unistd.h> +#endif +struct guest_mode guest_modes[NUM_VM_MODES ];void guest_modes_append_default (void ) { -#if !defined(__aarch64__) && !defined(__riscv) +#if !defined(__aarch64__) && !defined(__riscv) && !defined(__powerpc64__)guest_mode_append (VM_MODE_DEFAULT , true);#endif
@@ -108,6 +112,18 @@ void guest_modes_append_default(void) TEST_ASSERT(vm_mode_default != NUM_VM_MODES, "No supported mode!"); }#endif +#ifdef __powerpc64__ + { +TEST_REQUIRE (kvm_has_cap (KVM_CAP_PPC_MMU_RADIX)); +/* 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); +guest_mode_append (VM_MODE_P52V52_64K , true); + } +#endif }void for_each_guest_mode (void (*func)(enum vm_guest_mode ,void *),void *arg)
tools/testing/selftests/kvm/lib/kvm_util.c +8 -0
@@ -227,6 +227,8 @@ const char *vm_guest_mode_string(u32 i) [VM_MODE_P41V57_4K] = "PA-bits:41, VA-bits:57, 4K pages", [VM_MODE_P41V48_4K] = "PA-bits:41, VA-bits:48, 4K pages", [VM_MODE_P41V39_4K] = "PA-bits:41, VA-bits:39, 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" , };_Static_assert (sizeof (strings)/sizeof (char *) ==NUM_VM_MODES ,"Missing new mode strings?" );
@@ -263,6 +265,8 @@ const struct vm_guest_mode_params vm_guest_mode_params[] = { [VM_MODE_P41V57_4K] = { 41, 57, 0x1000, 12 }, [VM_MODE_P41V48_4K] = { 41, 48, 0x1000, 12 }, [VM_MODE_P41V39_4K] = { 41, 39, 0x1000, 12 }, + [VM_MODE_P52V52_4K] = { 52, 52, 0x1000, 12 }, + [VM_MODE_P52V52_64K] = { 52, 52, 0x10000, 16 }, };_Static_assert (sizeof (vm_guest_mode_params)/sizeof (struct vm_guest_mode_params ) ==NUM_VM_MODES ,"Missing new mode params?" );
@@ -383,6 +387,10 @@ struct kvm_vm *____vm_create(struct vm_shape shape)case VM_MODE_P41V39_4K : vm->mmu.pgtable_levels =3 ;break ; +case VM_MODE_P52V52_4K : +case VM_MODE_P52V52_64K : + vm->mmu.pgtable_levels =4 ; +break ;default :TEST_FAIL ("Unknown guest mode: 0x%x" , vm->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 +512 -0
512 lines not on this page · raw message
tools/testing/selftests/kvm/lib/powerpc/ucall.c new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* ucall support. A ucall is a "hypercall to host userspace". +*/ +#include "kvm_util.h" +#include "ucall_common.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 ; +}
Signature · 1 line
2.39.5
[email protected]
AI reviewRe: [PATCH v4 1/3] KVM: PPC: selftests: add support for powerpc
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The patch relies on a missing KVM selftests core infrastructure patch, leading to undefined…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The patch relies on a missing KVM selftests core infrastructure patch, leading to undefined function calls and a build failure. --
commit abd17de4492c780fa3b8540774bca368e3f9baa2
Author: Nicholas Piggin <[email protected]>
KVM: PPC: selftests: add support for powerpc
This commit implements KVM selftests support for powerpc (Book3S-64), including virtual memory for the radix MMU and guest interrupt handling in real-mode. It also updates various types and adapts to the new page table allocator APIs.
Quoted 5 lines
tools/testing/selftests/kvm/lib/powerpc/processor.c new file +0
-0
[ ... ]
Quoted 10 lines
tools/testing/selftests/kvm/lib/powerpc/processor.c new file +10
-0+void virt_arch_pgd_alloc (struct kvm_vm *vm) +{ +struct kvm_ppc_mmuv3_cfg mmu_cfg; +gpa_t prtb, pgtb; +size_t pgd_pages; + +TEST_ASSERT ((vm->mode ==VM_MODE_P52V52_4K ) || + (vm->mode ==VM_MODE_P52V52_64K ), +"Unsupported guest mode, mode: 0x%x" , vm->mode); +
tools/testing/selftests/kvm/lib/powerpc/processor.c line 59
Quoted 10 lines
tools/testing/selftests/kvm/lib/powerpc/processor.c new file +10
-0+if (vm->mmu.pgd_created) +return ; + + prtb =vm_alloc_page_table (vm); + vm->arch.prtb = prtb; + + pgd_pages = (1UL << (RADIX_PGD_INDEX_SIZE +3 )) >> vm->page_shift; +if (!pgd_pages) + pgd_pages =1 ; + pgtb =vm_alloc_page_table_pages (vm, pgd_pages);
[Severity: Low]
Are we missing a prerequisite patch for the selftests core infrastructure? Building the tests for powerpc fails in virt_arch_pgd_alloc() because vm_alloc_page_table_pages() is undefined.
Quoted 4 lines
tools/testing/selftests/kvm/lib/powerpc/processor.c new file +4
-0+ vm->mmu.pgd = pgtb; + +/* Set the base page directory in the proc table */ +set_radix_proc_table (vm,0 , pgtb);
[ ... ]
tools/testing/selftests/kvm/lib/powerpc/processor.c line 172
Quoted 8 lines
tools/testing/selftests/kvm/lib/powerpc/processor.c new file +8
-0+static gpa_t __vm_alloc_pt (struct kvm_vm *vm,u64 pt_shift) +{ +gpa_t pt; + +if (pt_shift >= vm->page_shift) { +size_t pt_pages =1ULL << (pt_shift - vm->page_shift); + + pt =vm_alloc_page_table_pages (vm, pt_pages);
[Severity: Low]
Is the definition for vm_alloc_page_table_pages() missing from the tree? Calling this in __vm_alloc_pt() leads to an undefined function build failure.
Quoted 2 lines
tools/testing/selftests/kvm/lib/powerpc/processor.c new file +2
-0+ }else { +struct vm_pt_frag_cache *pt_frag_cache;
[ ... ]
Quoted 6 lines
tools/testing/selftests/kvm/lib/powerpc/processor.c new file +6
-0+void kvm_arch_vm_post_create (struct kvm_vm *vm,unsigned int nr_vcpus) +{ +size_t excp_size = __interrupts_end - __interrupts_start; +size_t excp_pages = (excp_size + vm->page_size -1 ) / vm->page_size; +gpa_t excp_paddr; +void *mem;
tools/testing/selftests/kvm/lib/powerpc/processor.c line 434
Quoted 10 lines
tools/testing/selftests/kvm/lib/powerpc/processor.c new file +10
-0+ +/* +* Guest interrupts are taken in real-mode, i.e. the vectors must live +* at gPA 0. Use the innermost allocator to override the minimum GPA +* that MEM_REGION_DATA would otherwise impose. +*/ + excp_paddr =____vm_phy_pages_alloc (vm, excp_pages,0 , + vm->memslots[MEM_REGION_DATA ], +vm_arch_has_protected_memory (vm), + false);
[Severity: Low]
Is the definition for ____vm_phy_pages_alloc() with 6 arguments missing? Calling this undefined function in kvm_arch_vm_post_create() causes a build failure when compiling the powerpc KVM selftests.
Quoted 8 lines
tools/testing/selftests/kvm/lib/powerpc/processor.c new file +8
-0+ +TEST_ASSERT (excp_paddr ==0 , +"Interrupt vectors not allocated at gPA address 0: (0x%lx)" , + excp_paddr); + + mem =addr_gpa2hva (vm, excp_paddr); +memcpy (mem, __interrupts_start, excp_size); +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v4 2/3 KVM: selftests: Enable kvm_create_max_vcpus test for powerpc
In reply to Ritesh Harjani (IBM)powerpc'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.
This patch allows us to skip the vCPU ID test when running on PowerPC with SMT support, in which case system topology is encoded into the vCPU ID, and so a VM can't use the full advertised vCPU ID range without crafting a valid platform specific topology.
--- tools/testing/selftests/kvm/kvm_create_max_vcpus.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
tools/testing/selftests/kvm/kvm_create_max_vcpus.c +7 -1
@@ -58,7 +58,13 @@ int main(int argc, char *argv[])test_vcpu_creation (0 , kvm_max_vcpus); -if (kvm_max_vcpu_id > kvm_max_vcpus) +/* +* Skip the vCPU ID test when running on PowerPC with SMT support, in +* which case system topology is encoded into the vCPU ID, and so a VM +* can't use the full advertised vCPU ID range without crafting a valid +* platform specific topology. +*/ +if (kvm_max_vcpu_id > kvm_max_vcpus && !kvm_check_cap (KVM_CAP_PPC_SMT ))test_vcpu_creation ( kvm_max_vcpu_id - kvm_max_vcpus, kvm_max_vcpus);
--
2.39.5
PATCH v4 3/3 KVM: selftests: Don't limit LE dirty-bitmap bitops to s390x
In reply to Ritesh Harjani (IBM)dirty_log_test already has BITOP_LE_SWIZZLE helpers, but they were compiled in only for s390x, so every other big-endian host used native test_bit().
The test fails on big-endian powerpc because it treated dirty host pages as clean (because of the endianness issue)
w/o the fix the test fails with:
Clear page 1 value (1) >= iteration (1)
--- tools/testing/selftests/kvm/dirty_log_test.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
tools/testing/selftests/kvm/dirty_log_test.c +4 -8
@@ -44,8 +44,11 @@#define TEST_MIN_WRITES_PER_ITERATION 0x100/* Dirty bitmaps are always little endian, so we need to swap on big endian */ -#if defined(__s390x__) +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__# define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) +#else +# define BITOP_LE_SWIZZLE 0 +#endif # define test_bit_le (nr, addr) \ test_bit((nr) ^ BITOP_LE_SWIZZLE, addr)# define __set_bit_le (nr, addr) \
@@ -56,13 +59,6 @@ __test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, addr)# define __test_and_clear_bit_le (nr, addr) \ __test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, addr) -#else -# define test_bit_le test_bit -# define __set_bit_le __set_bit -# define __clear_bit_le __clear_bit -# define __test_and_set_bit_le __test_and_set_bit -# define __test_and_clear_bit_le __test_and_clear_bit -#endif #define TEST_DIRTY_RING_COUNT 65536
--
2.39.5
Quoted 75 lines · Ritesh Harjani (IBM)
PATCH v3 -> PATCH v4:
==================
- Rebased on top of Sean's new page allocator patch series v2 [1] This allowed to drop and patch-2 since it will now come from Sean's v2.
- Addressed review comments from Sean - squashed patches 6-10 in patch-1 of this.
- Dropped patch-5 to printvcpu_idwhenKVM_CREATE_VCPUioctl fails.
- Added additional patch-3 to this series to allowdirty_log_testto run on all big-endian machines.[1]: https://lore.kernel.org/kvm/[email protected]/
[v3]: https://lore.kernel.org/linuxppc-dev/2d2c46be7f051c7f1c645afaec67f57067d37a81.1781093720.git.ritesh.list@gmail.com/Testing updates:
================
I have done some fair amount of testing of the selftests both on real HW and using various combinations on qemu (powernv+LE (default), pseries+cap-nested-hv, pseries+cap-nested-papr, powernv+BE). There were few powerpc kvm kernel fixes which were identified as part of this work. I will send those patches separately as those anyway needs to go in separately.<pasted snippet of cover letter from previous versions>
=======================================================Hi All,
This series primarly adds KVM selftests support for powerpc (64-bit, BookS, radix MMU).
This patch series is originally Nick's work. I have mainly only rebased it on the latest upstream tree. Since the rebase required few changes to all the four patches (Patch 1-4), I have dropped the earlier Acked-by from Michael Ellerman.
Since the last series was posted three years ago [1], I am resetting the version to RFC. This rebase was done as part of a larger effort to improve the selftests infrastructure for Linux on PowerPC tree. Thanks to Harsh and Maddy for their help on this.
Nicholas Piggin (1):
KVM: PPC: selftests: add support for powerpcRitesh Harjani (IBM) (2):
KVM: PPC: selftests: powerpc enablekvm_create_max_vcpustest
KVM: selftests: Use LE bitops for dirty bitmaps on all big-endian
hostsMAINTAINERS | 2 + tools/testing/selftests/kvm/Makefile | 2 +- tools/testing/selftests/kvm/Makefile.kvm | 10 + tools/testing/selftests/kvm/dirty_log_test.c | 12 +- .../testing/selftests/kvm/include/kvm_util.h | 9 + .../selftests/kvm/include/powerpc/hcall.h | 17 + .../kvm/include/powerpc/kvm_util_arch.h | 22 + .../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 | 8 +- tools/testing/selftests/kvm/lib/guest_modes.c | 20 +- tools/testing/selftests/kvm/lib/kvm_util.c | 8 + .../selftests/kvm/lib/powerpc/handlers.S | 93 ++++ .../testing/selftests/kvm/lib/powerpc/hcall.c | 45 ++ .../selftests/kvm/lib/powerpc/processor.c | 512 ++++++++++++++++++ .../testing/selftests/kvm/lib/powerpc/ucall.c | 22 + 17 files changed, 862 insertions(+), 12 deletions(-)create mode 100644
tools/testing/selftests/kvm/include/powerpc/hcall.hcreate mode 100644tools/testing/selftests/kvm/include/powerpc/kvm_util_arch.hcreate mode 100644tools/testing/selftests/kvm/include/powerpc/ppc_asm.hcreate mode 100644tools/testing/selftests/kvm/include/powerpc/processor.hcreate mode 100644tools/testing/selftests/kvm/include/powerpc/ucall.hcreate mode 100644tools/testing/selftests/kvm/lib/powerpc/handlers.Screate mode 100644tools/testing/selftests/kvm/lib/powerpc/hcall.ccreate mode 100644tools/testing/selftests/kvm/lib/powerpc/processor.ccreate mode 100644tools/testing/selftests/kvm/lib/powerpc/ucall.c
Quoted 3 lines
--
2.39.5
Hi Ritesh,
Thanks for working on this enablement. I have tested kvm selftests after applying this patch on top of Sean's patch as mentioned and even I applied this patch for the kvm_create_max_vcpus issue as rc=-56 "https://lore.kernel.org/linuxppc-dev/[email protected]/" But still few tests got failed. Providing a summary below:
System details where I tested this : PowerVM P11 (ppc64le) KVM enabled lpar!
Test Results:
=============
PASS: demand_paging_test
PASS: dirty_log_test (dirty-log mode, 4K + 64K pages, 32 iterations)
PASS: guest_print_test
PASS: kvm_binary_stats_test (4/4 subtests)
PASS: kvm_page_table_test (4K + 64K pages)
PASS: set_memory_region_test
PASS: memslot_modification_stress_test (4K + 64K pages)
PASS: memslot_perf_test
PASS: dirty_log_perf_test (4K + 64K pages)
SKIP: irqfd_test
- kvm_arch_has_default_irqchip() not yet implemented for PowerPC
SKIP: vm_types_test
- KVM_CAP_VM_TYPES not supported on PowerPC
Failures seen for the following tests
FAIL: kvm_create_max_vcpus
- RFC patch-3 partially helps: KVM_CAP_MAX_VCPU_ID correctly capped from 16384 to 2048.
- But vCPU creation still fails with rc=-44 below the 2048 limit.
- dmesg: KVM: Create Guest vcpu hcall failed, rc=-44
for the above test in dmesg I saw the following error everytime I ran this test
dmesg -w
[ 2640.213798] KVM: Create Guest vcpu hcall failed, rc=-44 [ 2923.048989] KVM: Create Guest hcall failed, rc=-44 [ 3650.642771] KVM: Create Guest vcpu hcall failed, rc=-44
FAIL: hardware_disable_test
- KVM_CREATE_VM fails with ENOMEM
- dmesg: KVM: Create Guest vcpu hcall failed, rc=-44
- Likely the same underlying hcall issue as kvm_create_max_vcpus.
FAIL: access_tracking_perf_test
- Too many idle pages (245385 out of 262144)
- errno=4 (Interrupted system call)
- page_idle tracking may not be fully supported on PowerPC yet.
I believe these issues might be real kernel issue. If you plan to send fixed please feel free to add my Reported-by:
Thank you,
Anushree Mathur
Quoted 132 lines · Anushree Mathur
Quoted 67 lines · Ritesh Harjani (IBM)
PATCH v3 -> PATCH v4:
==================
- Rebased on top of Sean's new page allocator patch series v2 [1] This allowed to drop and patch-2 since it will now come from Sean's v2.
- Addressed review comments from Sean - squashed patches 6-10 in patch-1 of
this.
- Dropped patch-5 to printvcpu_idwhenKVM_CREATE_VCPUioctl fails.
- Added additional patch-3 to this series to allowdirty_log_testto run on all
big-endian machines.[1]: https://lore.kernel.org/kvm/[email protected]/
[v3]: https://lore.kernel.org/linuxppc-dev/2d2c46be7f051c7f1c645afaec67f57067d37a81.1781093720.git.ritesh.list@gmail.com/Testing updates:
================
I have done some fair amount of testing of the selftests both on real HW and using various combinations on qemu (powernv+LE (default), pseries+cap-nested-hv, pseries+cap-nested-papr, powernv+BE). There were few powerpc kvm kernel fixes which were identified as part of this work. I will send those patches separately as those anyway needs to go in separately.<pasted snippet of cover letter from previous versions>
=======================================================Hi All,
This series primarly adds KVM selftests support for powerpc (64-bit, BookS, radix MMU).
This patch series is originally Nick's work. I have mainly only rebased it on the latest upstream tree. Since the rebase required few changes to all the four patches (Patch 1-4), I have dropped the earlier Acked-by from Michael Ellerman.
Since the last series was posted three years ago [1], I am resetting the version to RFC. This rebase was done as part of a larger effort to improve the selftests infrastructure for Linux on PowerPC tree. Thanks to Harsh and Maddy for their help on this.
Nicholas Piggin (1):
KVM: PPC: selftests: add support for powerpcRitesh Harjani (IBM) (2):
KVM: PPC: selftests: powerpc enablekvm_create_max_vcpustest
KVM: selftests: Use LE bitops for dirty bitmaps on all big-endian hostsMAINTAINERS | 2 + tools/testing/selftests/kvm/Makefile | 2 +- tools/testing/selftests/kvm/Makefile.kvm | 10 + tools/testing/selftests/kvm/dirty_log_test.c | 12 +- .../testing/selftests/kvm/include/kvm_util.h | 9 + .../selftests/kvm/include/powerpc/hcall.h | 17 + .../kvm/include/powerpc/kvm_util_arch.h | 22 + .../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 | 8 +-tools/testing/selftests/kvm/lib/guest_modes.c| 20 +- tools/testing/selftests/kvm/lib/kvm_util.c | 8 + .../selftests/kvm/lib/powerpc/handlers.S | 93 ++++.../testing/selftests/kvm/lib/powerpc/hcall.c| 45 ++ .../selftests/kvm/lib/powerpc/processor.c | 512 ++++++++++++++++++.../testing/selftests/kvm/lib/powerpc/ucall.c| 22 +17 files changed, 862 insertions(+), 12 deletions(-)Quoted 13 lines
create mode 100644
tools/testing/selftests/kvm/include/powerpc/hcall.hcreate mode 100644tools/testing/selftests/kvm/include/powerpc/kvm_util_arch.hcreate mode 100644tools/testing/selftests/kvm/include/powerpc/ppc_asm.hcreate mode 100644tools/testing/selftests/kvm/include/powerpc/processor.hcreate mode 100644tools/testing/selftests/kvm/include/powerpc/ucall.hcreate mode 100644tools/testing/selftests/kvm/lib/powerpc/handlers.Screate mode 100644tools/testing/selftests/kvm/lib/powerpc/hcall.ccreate mode 100644tools/testing/selftests/kvm/lib/powerpc/processor.ccreate mode 100644tools/testing/selftests/kvm/lib/powerpc/ucall.cSignature · 1 line
2.39.5Hi Ritesh,
Thanks for working on this enablement. I have tested kvm selftests after applying this patch on top of Sean's patch as mentioned and even I applied this patch for thekvm_create_max_vcpusissue as rc=-56 "https://lore.kernel.org/linuxppc-dev/[email protected]/" But still few tests got failed. Providing a summary below:System details where I tested this : PowerVM P11 (ppc64le) KVM enabled lpar!
Test Results:
=============PASS:
demand_paging_test
PASS:dirty_log_test(dirty-log mode, 4K + 64K pages, 32 iterations)
PASS:guest_print_test
PASS:kvm_binary_stats_test(4/4 subtests)
PASS:kvm_page_table_test(4K + 64K pages)
PASS:set_memory_region_test
PASS:memslot_modification_stress_test(4K + 64K pages)
PASS:memslot_perf_test
PASS:dirty_log_perf_test(4K + 64K pages)SKIP:
irqfd_test
-kvm_arch_has_default_irqchip()not yet implemented for PowerPCSKIP:
vm_types_test
-KVM_CAP_VM_TYPESnot supported on PowerPCFailures seen for the following tests
FAIL:
kvm_create_max_vcpus
- RFC patch-3 partially helps:KVM_CAP_MAX_VCPU_IDcorrectly capped from 16384 to 2048.
- But vCPU creation still fails with rc=-44 below the 2048 limit.
- dmesg: KVM: Create Guest vcpu hcall failed, rc=-44for the above test in dmesg I saw the following error everytime I ran this test
dmesg -w
[ 2640.213798] KVM: Create Guest vcpu hcall failed, rc=-44 [ 2923.048989] KVM: Create Guest hcall failed, rc=-44 [ 3650.642771] KVM: Create Guest vcpu hcall failed, rc=-44FAIL:
hardware_disable_test
-KVM_CREATE_VMfails with ENOMEM
- dmesg: KVM: Create Guest vcpu hcall failed, rc=-44
- Likely the same underlying hcall issue askvm_create_max_vcpus.FAIL:
access_tracking_perf_test
- Too many idle pages (245385 out of 262144)
- errno=4 (Interrupted system call)
-page_idletracking may not be fully supported on PowerPC yet.
Quoted 6 lines
I believe these issues might be real kernel issue. If you plan to send fixed please feel free to add my Reported-by:
Reported-by Anushree Mathur <[email protected]>Thank you,
Anushree Mathur
Here are some more detailed logs for the Failed selftests:
./kvm_create_max_vcpus
Random seed: 0x62af7caKVM_CAP_MAX_VCPU_ID: 2048KVM_CAP_MAX_VCPUS: 2048
Testing creating 2048 vCPUs, with IDs 0...2047.
==== Test Assertion Failure ====
lib/kvm_util.c:1388: vcpu->fd >= 0
pid=3808 tid=3808 errno=12 - Cannot allocate memory
1 0x0000000010008667: __vm_vcpu_add at kvm_util.c:1388 (discriminator 18) 2 0x0000000010004093: test_vcpu_creation at kvm_create_max_vcpus.c:32 3 0x0000000010003c93: main at kvm_create_max_vcpus.c:59
4 0x00007fffae42b4fb: ?? ??:0
5 0x00007fffae42b77b: ?? ??:0
KVM_CREATE_VCPU failed, rc: -1 errno: 12 (Cannot allocate memory)
./hardware_disable_test
Random seed: 0x7c401041
==== Test Assertion Failure ====
lib/kvm_util.c:193: vm->fd >= 0
pid=5544 tid=5544 errno=12 - Cannot allocate memory
1 0x00000000100069cb: vm_open at kvm_util.c:193 (discriminator 3) 2 0x000000001000b95f: ____vm_create at kvm_util.c:404 3 0x000000001000c403: __vm_create at kvm_util.c:513
4 0x0000000010004037: vm_create at kvm_util.h:1126
5 (inlined by) run_test at hardware_disable_test.c:78 6 (inlined by) main at hardware_disable_test.c:148
7 0x00007fff95c2b4fb: ?? ??:0
8 0x00007fff95c2b77b: ?? ??:0
KVM_CREATE_VM failed, rc: -1 errno: 12 (Cannot allocate memory)
./access_tracking_perf_test
Random seed: 0x50130229lru_gen: Could not open /sys/kernel/mm/lru_gen/enabled Using page_idle for aging
Testing guest mode: PA-bits:52, VA-bits:52, 4K pages guest physical test memory: [0xfffffbfff0000, 0xfffffffff0000)
Populating memory : 0.324930580s Writing to populated memory : 0.007850148s Reading from populated memory : 0.008390886s
==== Test Assertion Failure ====
access_tracking_perf_test.c:164: idle_pages_warn_only
pid=5558 tid=5560 errno=4 - Interrupted system call
1 0x0000000010004cdf: too_many_idle_pages at access_tracking_perf_test.c:164 2 (inlined by) pageidle_mark_vcpu_memory_idle at access_tracking_perf_test.c:229 3 (inlined by) vcpu_thread_main at access_tracking_perf_test.c:339 4 0x000000001000f5f7: vcpu_thread_main at memstress.c:277
5 0x00007fff822b8063: ?? ??:0
vCPU0: Too many pages still idle (245400 out of 262144)
Thank you,
Anushree Mathur
Quoted 76 lines · Anushree Mathur
Quoted 75 lines · Ritesh Harjani (IBM)
PATCH v3 -> PATCH v4:
==================
- Rebased on top of Sean's new page allocator patch series v2 [1] This allowed to drop and patch-2 since it will now come from Sean's v2.
- Addressed review comments from Sean - squashed patches 6-10 in patch-1 of this.
- Dropped patch-5 to printvcpu_idwhenKVM_CREATE_VCPUioctl fails.
- Added additional patch-3 to this series to allowdirty_log_testto run on all big-endian machines.[1]: https://lore.kernel.org/kvm/[email protected]/
[v3]: https://lore.kernel.org/linuxppc-dev/2d2c46be7f051c7f1c645afaec67f57067d37a81.1781093720.git.ritesh.list@gmail.com/Testing updates:
================
I have done some fair amount of testing of the selftests both on real HW and using various combinations on qemu (powernv+LE (default), pseries+cap-nested-hv, pseries+cap-nested-papr, powernv+BE). There were few powerpc kvm kernel fixes which were identified as part of this work. I will send those patches separately as those anyway needs to go in separately.<pasted snippet of cover letter from previous versions>
=======================================================Hi All,
This series primarly adds KVM selftests support for powerpc (64-bit, BookS, radix MMU).
This patch series is originally Nick's work. I have mainly only rebased it on the latest upstream tree. Since the rebase required few changes to all the four patches (Patch 1-4), I have dropped the earlier Acked-by from Michael Ellerman.
Since the last series was posted three years ago [1], I am resetting the version to RFC. This rebase was done as part of a larger effort to improve the selftests infrastructure for Linux on PowerPC tree. Thanks to Harsh and Maddy for their help on this.
Nicholas Piggin (1):
KVM: PPC: selftests: add support for powerpcRitesh Harjani (IBM) (2):
KVM: PPC: selftests: powerpc enablekvm_create_max_vcpustest
KVM: selftests: Use LE bitops for dirty bitmaps on all big-endian
hostsMAINTAINERS | 2 + tools/testing/selftests/kvm/Makefile | 2 +- tools/testing/selftests/kvm/Makefile.kvm | 10 + tools/testing/selftests/kvm/dirty_log_test.c | 12 +- .../testing/selftests/kvm/include/kvm_util.h | 9 + .../selftests/kvm/include/powerpc/hcall.h | 17 + .../kvm/include/powerpc/kvm_util_arch.h | 22 + .../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 | 8 +- tools/testing/selftests/kvm/lib/guest_modes.c | 20 +- tools/testing/selftests/kvm/lib/kvm_util.c | 8 + .../selftests/kvm/lib/powerpc/handlers.S | 93 ++++ .../testing/selftests/kvm/lib/powerpc/hcall.c | 45 ++ .../selftests/kvm/lib/powerpc/processor.c | 512 ++++++++++++++++++ .../testing/selftests/kvm/lib/powerpc/ucall.c | 22 + 17 files changed, 862 insertions(+), 12 deletions(-)create mode 100644
tools/testing/selftests/kvm/include/powerpc/hcall.hcreate mode 100644tools/testing/selftests/kvm/include/powerpc/kvm_util_arch.hcreate mode 100644tools/testing/selftests/kvm/include/powerpc/ppc_asm.hcreate mode 100644tools/testing/selftests/kvm/include/powerpc/processor.hcreate mode 100644tools/testing/selftests/kvm/include/powerpc/ucall.hcreate mode 100644tools/testing/selftests/kvm/lib/powerpc/handlers.Screate mode 100644tools/testing/selftests/kvm/lib/powerpc/hcall.ccreate mode 100644tools/testing/selftests/kvm/lib/powerpc/processor.ccreate mode 100644tools/testing/selftests/kvm/lib/powerpc/ucall.c
Quoted 5 lines
Quoted 3 lines
--
2.39.5Hi Ritesh,
Thanks for working on this enablement. I have tested kvm selftests after
Thanks for testing this.
Quoted 20 lines
applying this patch on top of Sean's patch as mentioned and even I applied this patch for the
kvm_create_max_vcpusissue as rc=-56 "https://lore.kernel.org/linuxppc-dev/[email protected]/" But still few tests got failed. Providing a summary below:System details where I tested this : PowerVM P11 (ppc64le) KVM enabled lpar!
Test Results:
=============PASS:
demand_paging_test
PASS:dirty_log_test(dirty-log mode, 4K + 64K pages, 32 iterations)
PASS:guest_print_test
PASS:kvm_binary_stats_test(4/4 subtests)
PASS:kvm_page_table_test(4K + 64K pages)
PASS:set_memory_region_test
PASS:memslot_modification_stress_test(4K + 64K pages)
PASS:memslot_perf_test
PASS:dirty_log_perf_test(4K + 64K pages)
Quoted 6 lines
SKIP:
irqfd_test
-kvm_arch_has_default_irqchip()not yet implemented for PowerPCSKIP:
vm_types_test
-KVM_CAP_VM_TYPESnot supported on PowerPC
So far so good then.
Quoted 12 lines
Failures seen for the following tests
FAIL:
kvm_create_max_vcpus
- RFC patch-3 partially helps:KVM_CAP_MAX_VCPU_IDcorrectly capped from 16384 to 2048.
- But vCPU creation still fails with rc=-44 below the 2048 limit.
- dmesg: KVM: Create Guest vcpu hcall failed, rc=-44for the above test in dmesg I saw the following error everytime I ran this test
dmesg -w
Quoted 9 lines
[ 2640.213798] KVM: Create Guest vcpu hcall failed, rc=-44 [ 2923.048989] KVM: Create Guest hcall failed, rc=-44 [ 3650.642771] KVM: Create Guest vcpu hcall failed, rc=-44FAIL:
hardware_disable_test
-KVM_CREATE_VMfails with ENOMEM
- dmesg: KVM: Create Guest vcpu hcall failed, rc=-44
- Likely the same underlying hcall issue askvm_create_max_vcpus.
In both above cases it looks like the hcall failed due to limited resources. I looked at the spec and it seems, create vm hcall (H_GUEST_CREATE) or create vcpu hcall (H_GUEST_CREATE_VCPU) can fail with -44 (H_Not_Enough_Resources) error. This can happen because L0 (Power firmware) in our case can run with a limited/finite memory for guest management, so if we are running out of space there, then it can essentially return -44, which the L1 KVM considers as -ENOMEM to the user.
i.e.
case H_NOT_ENOUGH_RESOURCES: case H_ABORTED: return -ENOMEM;
So I am planning to add something like for all arches ...
_weak bool kvm_arch_vm_limited_resources(void)
{
return false;
}... and for powerpc we will decide if our host is the LPAR which "mostly" means we will be running kvm on powervm.
(For now I am planning to use this dirty trick to make sure these testcases are not reported as test failures).
bool kvm_arch_vm_limited_resources(void)
{
return !access("/proc/device-tree/rtas/ibm,hypertas-functions", F_OK);
}For kvm_create_max_vcpus I will break the loop when ENOMEM occurs and for hardware_disable_test I will limit the number of iterations to a very low value for now e.g. NUM_ITERATIONS_LIM=5 (since that test case does few things asynchronously).
Quoted 5 lines
FAIL:
access_tracking_perf_test
- Too many idle pages (245385 out of 262144)
- errno=4 (Interrupted system call)
-page_idletracking may not be fully supported on PowerPC yet.
hmm, looks like there are 2 issues here:
1. one seems to be testcase related: guest 4k pagesize v/s host 64K pagesize.
2. The issue reported when guest and host pagesize=64K is since we don't TLB invalidate during Reference bit update in L1 - I guess due to performance reasons. But for now I will make it warn only like how x86 does. Will add a todo in my list to revisit this later (I am currently anyways looking into related area, but I don't want to block the selftests changes for that).
Quoted 6 lines
I believe these issues might be real kernel issue. If you plan to send fixed please feel free to add my Reported-by:
Reported-by Anushree Mathur <[email protected]>
Sure Thanks!
So mostly these failures were kvm on powervm or nested guest related. It would be nice if you can also publish the results of running these tests on PowerNV.
Meanwhile I will soon share a couple of fixes (or maybe v5) which should fix the reported failures.
-ritesh