[PATCH v3 3/6] KVM: PPC: selftests: add support for powerpc

Joel Stanley joel at jms.id.au
Wed Jun 14 10:20:59 AEST 2023


On Thu, 8 Jun 2023 at 03:28, Nicholas Piggin <npiggin at gmail.com> wrote:
>
> Implement 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.

I saw a few failures on a power9 running Ubuntu's 6.2.0-20-generic kernel:

# selftests: kvm: kvm_create_max_vcpus
# KVM_CAP_MAX_VCPU_ID: 16384
# KVM_CAP_MAX_VCPUS: 2048
# Testing creating 2048 vCPUs, with IDs 0...2047.
# Testing creating 2048 vCPUs, with IDs 14336...16383.
# ==== Test Assertion Failure ====
#   lib/kvm_util.c:1221: vcpu->fd >= 0
#   pid=40390 tid=40390 errno=22 - Invalid argument
#      1    0x0000000010006903: __vm_vcpu_add at kvm_util.c:1221
#      2    0x0000000010002e53: test_vcpu_creation at
kvm_create_max_vcpus.c:35 (discriminator 3)
#      3    0x0000000010002953: main at kvm_create_max_vcpus.c:90
#      4    0x0000795fb3224c23: ?? ??:0
#      5    0x0000795fb3224e6b: ?? ??:0
#   KVM_CREATE_VCPU failed, rc: -1 errno: 22 (Invalid argument)
not ok 10 selftests: kvm: kvm_create_max_vcpus # exit=254

# selftests: kvm: max_guest_memory_test
# No guest physical pages available, paddr_min: 0x180000 page_size:
0x10000 memslot: 0 num_pages: 1 align: 1
# ---- vm dump ----
#   mode: 0xc
#   fd: 6
#   page_size: 0x10000
#   Mem Regions:
#     guest_phys: 0x0 size: 0x4200000 host_virt: 0x7ce4c0800000
#     unused_phy_pages: 0x1
#   Mapped Virtual Pages:
#     0x1, 0xac:0x183, 0x1000:0x1003
#   pgd_created: 1
#     Virtual Translation Tables:
#     Virtual Translation Tables:
#       PDE1[0] gVA:0x0000000000000000
#         PDE2[0] gVA:0x0000000000000000
#           PDE3[0] gVA:0x0000000000000000
#              PTE[1] gVA:0x0000000000010000 -> gRA:0x0000000000060000
#           PDE3[5] gVA:0x0000000000a00000
#              PTE[12] gVA:0x0000000000ac0000 -> gRA:0x0000000000070000

and then finally:

# ==== Test Assertion Failure ====
#   lib/kvm_util.c:1962: false
#   pid=40446 tid=40446 errno=0 - Success
#      1    0x0000000010008f83: vm_phy_pages_alloc_align at kvm_util.c:1962
#      2    0x00000000100110d3: __virt_arch_pg_map at processor.c:232
#      3    0x0000000010002bcf: virt_pg_map at kvm_util_base.h:877
(discriminator 3)
#      4     (inlined by) main at max_guest_memory_test.c:249 (discriminator 3)
#      5    0x00007ce4c4a24c23: ?? ??:0
#      6    0x00007ce4c4a24e6b: ?? ??:0
#   false
not ok 12 selftests: kvm: max_guest_memory_test # exit=254


# selftests: kvm: rseq_test
# ==== Test Assertion Failure ====
#   rseq_test.c:258: i > (NR_TASK_MIGRATIONS / 2)
#   pid=40529 tid=40529 errno=4 - Interrupted system call
#      1    0x0000000010002e57: main at rseq_test.c:258
#      2    0x00007369e2824c23: ?? ??:0
#      3    0x00007369e2824e6b: ?? ??:0
#   Only performed 32590 KVM_RUNs, task stalled too much?
#
not ok 15 selftests: kvm: rseq_test # exit=254

I have attached the log from the full test run.

>
> Acked-by: Michael Ellerman <mpe at ellerman.id.au> (powerpc)
> Signed-off-by: Nicholas Piggin <npiggin at gmail.com>

> +#ifdef __powerpc__
> +       {
> +               TEST_ASSERT(kvm_check_cap(KVM_CAP_PPC_MMU_RADIX),
> +                           "Radix MMU not available, KVM selftests "
> +                           "does not support Hash MMU!");

Back on the power8 system, this produces a backtrace along with the warning:

TAP version 13
1..17
# selftests: kvm: interrupt_perf
# ==== Test Assertion Failure ====
#   lib/guest_modes.c:95: kvm_check_cap(KVM_CAP_PPC_MMU_RADIX)
#   pid=3800487 tid=3800487 errno=0 - Success
#      1    0x0000000010003d57: guest_modes_append_default at guest_modes.c:95
#      2    0x0000000010011d67: kvm_selftest_arch_init at processor.c:540
#      3    0x00000000100029af: kvm_selftest_init at kvm_util.c:2178
#      4    0x000000001001325b: __libc_csu_init at ??:?
#      5    0x0000742d64f54c5b: ?? ??:0
#      6    0x0000742d64f54ea3: ?? ??:0
#   Radix MMU not available, KVM selftests does not support Hash MMU!
not ok 1 selftests: kvm: interrupt_perf # exit=254

You could instead use TEST_REQUIRE:

TAP version 131..17
# selftests: kvm: interrupt_perf
# 1..0 # SKIP - Requirement not met: kvm_check_cap(KVM_CAP_PPC_MMU_RADIX)
ok 1 selftests: kvm: interrupt_perf # SKIP


> +               /* 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
>  }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kvm-selftests-powerpc-6.2.txt.gz
Type: application/gzip
Size: 168609 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20230614/f39d371d/attachment-0001.gz>


More information about the Linuxppc-dev mailing list