# # requires: arch=arm64 -threaded # # This series of tests exercise the PMU registers that are exposed in the QEMU emulation mode. # They should not be used in the corpus when running on real HW. # r0 = openat$kvm(0, &AUTO='/dev/kvm\x00', 0x0, 0x0) r1 = ioctl$KVM_CREATE_VM(r0, AUTO, 0x0) r2 = syz_kvm_setup_syzos_vm$arm64(r1, &(0x7f0000c00000/0x400000)=nil) # # 0x603000000013c4f1 is PMINTENSET_EL1. # 0x603000000013c4f2 is PMINTENCLR_EL1. # 0x603000000013dce0 is PMCR_EL0. # 0x603000000013dce1 is PMCNTENSET_EL0. # 0x603000000013dce2 is PMCNTENCLR_EL0. # 0x603000000013dce3 is PMOVSCLR_EL0. # 0x603000000013dce4 is PMSWINC_EL0. # 0x603000000013dce5 is PMSELR_EL0. # 0x603000000013dce8 is PMCCNTR_EL0. # 0x603000000013dce9 is PMXEVTYPER_EL0. # Writes to these registers will trigger kvm_handle_sys_reg in arch/arm64/kvm/sys_regs.c # This is done to illustrate that PMU is accessible. # 0x8 corresponds to the KVM_ARM_VCPU_PMU_V3 feature bit and is required to enable PMU. # r3 = syz_kvm_add_vcpu$arm64(r2, &AUTO={0x0, &AUTO=[@msr={AUTO, AUTO, {0x603000000013c4f1, 0x8000}}, @msr={AUTO, AUTO, {0x603000000013c4f2, 0x8000}}, @msr={AUTO, AUTO, {0x603000000013dce0, 0x8000}}, @msr={AUTO, AUTO, {0x603000000013dce1, 0x8000}}, @msr={AUTO, AUTO, {0x603000000013dce2, 0x8000}}, @msr={AUTO, AUTO, {0x603000000013dce3, 0x8000}}, @msr={AUTO, AUTO, {0x603000000013dce4, 0x8000}}, @msr={AUTO, AUTO, {0x603000000013dce5, 0x8000}}, @msr={AUTO, AUTO, {0x603000000013dce8, 0x8000}}, @msr={AUTO, AUTO, {0x603000000013dce9, 0x8000}}], AUTO}, &AUTO=[@featur1={0x1, 0x8}], 0x1) # # Call ioctl(KVM_SET_DEVICE_ATTR) with group=KVM_ARM_VCPU_PMU_V3_CTRL and attr=KVM_ARM_VCPU_PMU_V3_INIT, # as per https://www.kernel.org/doc/Documentation/virt/kvm/devices/vcpu.rst. # ioctl$KVM_SET_DEVICE_ATTR_vcpu(r3, AUTO, &AUTO=@attr_pmu_init) r4 = ioctl$KVM_GET_VCPU_MMAP_SIZE(r0, AUTO) r5 = mmap$KVM_VCPU(&(0x7f0000009000/0x1000)=nil, r4, 0x3, 0x1, r3, 0x0) # # Run till the end of guest_main(). 0xffffffffffffffff is UEXIT_END. # ioctl$KVM_RUN(r3, AUTO, 0x0) syz_kvm_assert_syzos_uexit$arm64(r3, r5, 0xffffffffffffffff) syz_kvm_assert_reg(r3, 0x603000000013c4f1, 0x8000) syz_kvm_assert_reg(r3, 0x603000000013c4f2, 0x8000) syz_kvm_assert_reg(r3, 0x603000000013dce0, 0x8000) syz_kvm_assert_reg(r3, 0x603000000013dce1, 0x8000) syz_kvm_assert_reg(r3, 0x603000000013dce2, 0x8000) syz_kvm_assert_reg(r3, 0x603000000013dce3, 0x8000) syz_kvm_assert_reg(r3, 0x603000000013dce4, 0x8000) syz_kvm_assert_reg(r3, 0x603000000013dce5, 0x8000) syz_kvm_assert_reg(r3, 0x603000000013dce8, 0x8000) syz_kvm_assert_reg(r3, 0x603000000013dce9, 0x8000)