github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/sys/linux/test/arm64-syz_kvm_setup_syzos_vm-enable-pmu-msr-emul-0 (about) 1 # 2 # requires: arch=arm64 -threaded 3 # 4 # This series of tests exercise the PMU registers that are exposed in the QEMU emulation mode. 5 # They should not be used in the corpus when running on real HW. 6 # 7 r0 = openat$kvm(0, &AUTO='/dev/kvm\x00', 0x0, 0x0) 8 r1 = ioctl$KVM_CREATE_VM(r0, AUTO, 0x0) 9 r2 = syz_kvm_setup_syzos_vm$arm64(r1, &(0x7f0000c00000/0x400000)=nil) 10 # 11 # 0x603000000013c4f1 is PMINTENSET_EL1. 12 # 0x603000000013c4f2 is PMINTENCLR_EL1. 13 # 0x603000000013dce0 is PMCR_EL0. 14 # 0x603000000013dce1 is PMCNTENSET_EL0. 15 # 0x603000000013dce2 is PMCNTENCLR_EL0. 16 # 0x603000000013dce3 is PMOVSCLR_EL0. 17 # 0x603000000013dce4 is PMSWINC_EL0. 18 # 0x603000000013dce5 is PMSELR_EL0. 19 # 0x603000000013dce8 is PMCCNTR_EL0. 20 # 0x603000000013dce9 is PMXEVTYPER_EL0. 21 # Writes to these registers will trigger kvm_handle_sys_reg in arch/arm64/kvm/sys_regs.c 22 # This is done to illustrate that PMU is accessible. 23 # 0x8 corresponds to the KVM_ARM_VCPU_PMU_V3 feature bit and is required to enable PMU. 24 # 25 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) 26 # 27 # Call ioctl(KVM_SET_DEVICE_ATTR) with group=KVM_ARM_VCPU_PMU_V3_CTRL and attr=KVM_ARM_VCPU_PMU_V3_INIT, 28 # as per https://www.kernel.org/doc/Documentation/virt/kvm/devices/vcpu.rst. 29 # 30 ioctl$KVM_SET_DEVICE_ATTR_vcpu(r3, AUTO, &AUTO=@attr_pmu_init) 31 32 r4 = ioctl$KVM_GET_VCPU_MMAP_SIZE(r0, AUTO) 33 r5 = mmap$KVM_VCPU(&(0x7f0000009000/0x1000)=nil, r4, 0x3, 0x1, r3, 0x0) 34 # 35 # Run till the end of guest_main(). 0xffffffffffffffff is UEXIT_END. 36 # 37 ioctl$KVM_RUN(r3, AUTO, 0x0) 38 syz_kvm_assert_syzos_uexit$arm64(r5, 0xffffffffffffffff) 39 syz_kvm_assert_reg(r3, 0x603000000013c4f1, 0x8000) 40 syz_kvm_assert_reg(r3, 0x603000000013c4f2, 0x8000) 41 syz_kvm_assert_reg(r3, 0x603000000013dce0, 0x8000) 42 syz_kvm_assert_reg(r3, 0x603000000013dce1, 0x8000) 43 syz_kvm_assert_reg(r3, 0x603000000013dce2, 0x8000) 44 syz_kvm_assert_reg(r3, 0x603000000013dce3, 0x8000) 45 syz_kvm_assert_reg(r3, 0x603000000013dce4, 0x8000) 46 syz_kvm_assert_reg(r3, 0x603000000013dce5, 0x8000) 47 syz_kvm_assert_reg(r3, 0x603000000013dce8, 0x8000) 48 syz_kvm_assert_reg(r3, 0x603000000013dce9, 0x8000)