diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2026-10-28 19:01:07 +0100 |
|---|---|---|
| committer | Paolo Bonzini <pbonzini@redhat.com> | 2026-10-28 19:01:07 +0100 |
| commit | 1689c80fca308978ea1c9f03d15a500f4e44e2e1 (patch) | |
| tree | 8032be194e2d213bd21237d60c8f9d85554ac6be /tools/testing | |
| parent | 7e60162b16f9da0d2fa83da5c1723b6853a0ac1d (diff) | |
| parent | 9e9283e4c941e806d2735f09b66763487bc48b50 (diff) | |
Merge tag 'kvmarm-fixes-7.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
KVM/arm64 fixes for 7.4, take #1
- Fix a couple of embarrassing merge mistakes in kvmarm-7.4
- Cleanup the HCR_EL2 bit fields to exclusively use the generated
definitions, fixings a nasty regression introduced in 6.16, where
barriers were not upgraded from NSH to ISH anymore
- Fix publication of state when a vcpu is forced out of the guest
- Let vcpu pausing nest correctly
- Sanitise ID_AA64MMFR3_EL1.S1P[IO]E to follow the rules of the architecture
- Don't warn on SMCCC filter reserved range allocation failure
- Prevent GICv5 and TLBI hypercalls to be used from the host when pKVM
is active
- Enforce that only GICv3 guests are supported for pKVM
- Don't try to access GICv5 EL2 sysregs from EL1
- Compute architectrally correct values for ID_AA64MMFR3_EL1.S1P[IO]E
by checking the feature dependencies
- Require matching VGIC and ITS model
- Cleanup TRACE_REMOTE dependencies
- selftests: Skip unwritable ID fields in the failed-run test
- Move pkvm_selftests() after all CPUs have initialized EL2
- Fix random comments
Diffstat (limited to 'tools/testing')
| -rw-r--r-- | tools/testing/selftests/kvm/arm64/set_id_regs.c | 13 | ||||
| -rw-r--r-- | tools/testing/selftests/kvm/arm64/vgic_v5.c | 32 |
2 files changed, 44 insertions, 1 deletions
diff --git a/tools/testing/selftests/kvm/arm64/set_id_regs.c b/tools/testing/selftests/kvm/arm64/set_id_regs.c index 10849d21c0dd..1d2cc25cb3f4 100644 --- a/tools/testing/selftests/kvm/arm64/set_id_regs.c +++ b/tools/testing/selftests/kvm/arm64/set_id_regs.c @@ -815,6 +815,10 @@ static void test_idreg_frozen_after_failed_run(void) SYS_REVIDR_EL1, SYS_AIDR_EL1, }; + u64 masks[KVM_ARM_FEATURE_ID_RANGE_SIZE]; + struct reg_mask_range range = { + .addr = (__u64)masks, + }; struct kvm_vcpu_init init; struct kvm_vcpu *vcpu; struct kvm_vm *vm; @@ -831,6 +835,7 @@ static void test_idreg_frozen_after_failed_run(void) vm = vm_create(1); vm_enable_cap(vm, KVM_CAP_ARM_WRITABLE_IMP_ID_REGS, 0); + vm_ioctl(vm, KVM_ARM_GET_REG_WRITABLE_MASKS, &range); kvm_get_default_vcpu_target(vm, &init); init.features[0] |= (1 << KVM_ARM_VCPU_PMU_V3); vcpu = aarch64_vcpu_add(vm, 0, &init, guest_code); @@ -852,7 +857,9 @@ static void test_idreg_frozen_after_failed_run(void) */ for (int i = 0; i < ARRAY_SIZE(test_regs); i++) { const struct reg_ftr_bits *ftr_bits = test_regs[i].ftr_bits; - u64 reg = KVM_ARM64_SYS_REG(test_regs[i].reg); + u32 reg_id = test_regs[i].reg; + u64 reg = KVM_ARM64_SYS_REG(reg_id); + u64 mask = masks[encoding_to_range_idx(reg_id)]; u64 val = vcpu_get_reg(vcpu, reg); for (int j = 0; ftr_bits[j].type != FTR_END; j++) { @@ -860,6 +867,10 @@ static void test_idreg_frozen_after_failed_run(void) u64 safe = get_safe_value(&ftr_bits[j], ftr); u64 new_val; + /* Only a field userspace could change can be frozen. */ + if ((mask & ftr_bits[j].mask) != ftr_bits[j].mask) + continue; + if (safe == ftr) continue; diff --git a/tools/testing/selftests/kvm/arm64/vgic_v5.c b/tools/testing/selftests/kvm/arm64/vgic_v5.c index d5df742b2300..5bf7d99d2914 100644 --- a/tools/testing/selftests/kvm/arm64/vgic_v5.c +++ b/tools/testing/selftests/kvm/arm64/vgic_v5.c @@ -2003,8 +2003,40 @@ int test_kvm_device(u32 gic_dev_type) return 0; } +static void test_vgic_v3_its_with_vgic_v5(void) +{ + struct kvm_vm *vm = vm_create_barebones(); + int gic_fd, its_fd, ret; + + if (__kvm_test_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_ITS)) { + pr_info("No GICv3 ITS support; skipping mixed-model test.\n"); + kvm_vm_free(vm); + return; + } + + gic_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V5); + ret = __kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_ITS); + TEST_ASSERT(ret < 0 && errno == ENODEV, + "GICv3 ITS created after GICv5 VGIC: ret=%d errno=%d", + ret, errno); + close(gic_fd); + kvm_vm_free(vm); + + vm = vm_create_barebones(); + its_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_ITS); + ret = __kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V5); + TEST_ASSERT(ret < 0 && errno == ENODEV, + "GICv5 VGIC created after GICv3 ITS: ret=%d errno=%d", + ret, errno); + close(its_fd); + kvm_vm_free(vm); +} + void run_tests(u32 gic_dev_type) { + pr_info("Test VGICv5 and GICv3 ITS model mismatch\n"); + test_vgic_v3_its_with_vgic_v5(); + pr_info("Test VGICv5 address attrs\n"); test_vgic_v5_addr_attrs(); |
