-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the MRS instruction in a similar manner to MSR.
- Loading branch information
Showing
5 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
sys/linux/test/arm64-syz_kvm_setup_syzos_vm-enable-pmu-mrs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# | ||
# requires: arch=arm64 -threaded | ||
# | ||
r0 = openat$kvm(0, &AUTO='/dev/kvm\x00', 0x0, 0x0) | ||
r1 = ioctl$KVM_CREATE_VM(r0, AUTO, 0x0) | ||
r2 = syz_kvm_setup_syzos_vm(r1, &(0x7f0000c00000/0x400000)=nil) | ||
# | ||
# 0x603000000013df40 is PMEVCNTR0_EL0, write to it will trigger access_pmu_evcntr() 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(r2, &AUTO={0x0, &AUTO=[@mrs={AUTO, AUTO, {0x603000000013df40}}], 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(r5, 0xffffffffffffffff) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# | ||
# requires: arch=arm64 -threaded | ||
# | ||
r0 = openat$kvm(0, &AUTO='/dev/kvm\x00', 0x0, 0x0) | ||
r1 = ioctl$KVM_CREATE_VM(r0, AUTO, 0x0) | ||
r2 = syz_kvm_setup_syzos_vm(r1, &(0x7f0000c00000/0x400000)=nil) | ||
# | ||
# 0x6030000000138010 is MDCCINT_EL1. | ||
# | ||
r3 = syz_kvm_add_vcpu(r2, &AUTO={0x0, &AUTO=[@mrs={AUTO, AUTO, {0x6030000000138010}}], AUTO}, 0x0, 0x0) | ||
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(r5, 0xffffffffffffffff) |