diff options
| author | Alexander Potapenko <glider@google.com> | 2024-10-18 15:14:40 +0200 |
|---|---|---|
| committer | Alexander Potapenko <glider@google.com> | 2024-10-21 11:18:37 +0000 |
| commit | f1e4447ce91d33c3785db1a7c2bafc768eb3f790 (patch) | |
| tree | f16515afcd07d5636c6cd1acc5668827c54f047b | |
| parent | c66d80fe3bfd4c25b3a19011d02b18510db69c05 (diff) | |
executor: sys/linux: arm64: reserve address for ITS, add a seed for ITS creation
Reserve SYZOS address for the ITS redistributor at 0x08080000, add it to the
list of kvm_guest_addrs.
Also implement a syzlang test for the host part of ITS configuration as per
https://www.kernel.org/doc/html/v6.1/virt/kvm/devices/arm-vgic-its.html
| -rw-r--r-- | executor/kvm.h | 5 | ||||
| -rw-r--r-- | sys/linux/socket_vnet.txt | 2 | ||||
| -rw-r--r-- | sys/linux/test/arm64-syz_kvm_setup_syzos_vm-vgicv3-its | 30 |
3 files changed, 35 insertions, 2 deletions
diff --git a/executor/kvm.h b/executor/kvm.h index 47348e3d4..f69322bfd 100644 --- a/executor/kvm.h +++ b/executor/kvm.h @@ -76,8 +76,11 @@ #define NEXT_INSN $0xbadc0de #define PREFIX_SIZE 0xba1d -// GICv3 distributor/redistributor addresses. +// GICv3 distributor address. #define ARM64_ADDR_GICD_BASE 0x08000000 +// GICv3 ITS address. +#define ARM64_ADDR_GICI_BASE 0x08080000 +// GICv3 redistributor address. #define ARM64_ADDR_GICR_BASE 0x080a0000 // Write to this page to trigger a page fault and stop KVM_RUN. #define ARM64_ADDR_EXIT 0xdddd0000 diff --git a/sys/linux/socket_vnet.txt b/sys/linux/socket_vnet.txt index f2629fc9e..ed9b5e513 100644 --- a/sys/linux/socket_vnet.txt +++ b/sys/linux/socket_vnet.txt @@ -171,7 +171,7 @@ vhost_features = VHOST_LOG_ALL, VIRTIO_NOTIFY_ON_EMPTY, VIRTIO_RING_F_INDIRECT_D vhost_vring_index = VSOCK_VQ_RX, VSOCK_VQ_TX, VSOCK_VQ_EVENT, VSOCK_VQ_MAX vhost_iotlb_type = VHOST_IOTLB_MISS, VHOST_IOTLB_UPDATE, VHOST_IOTLB_INVALIDATE, VHOST_IOTLB_ACCESS_FAIL vhost_iotlb_perm = VHOST_ACCESS_RO, VHOST_ACCESS_WO, VHOST_ACCESS_RW -kvm_guest_addrs = 0, 1, 2, 4, 0x1000, 0x2000, 0x3000, 0x4000, 0x5000, 0x6000, 0xd000, 0xf000, 0x10000, 0x100000, 0x8000000, 0x80a0000, 0xdddd0000, 0xdddd1000, 0xeeee0000, 0xeeee8000, 0xeeef0000, 0xffff1000 +kvm_guest_addrs = 0, 1, 2, 4, 0x1000, 0x2000, 0x3000, 0x4000, 0x5000, 0x6000, 0xd000, 0xf000, 0x10000, 0x100000, 0x8000000, 0x8080000, 0x80a0000, 0xdddd0000, 0xdddd1000, 0xeeee0000, 0xeeee8000, 0xeeef0000, 0xffff1000 define VHOST_LOG_ALL 1 << VHOST_F_LOG_ALL define VIRTIO_NOTIFY_ON_EMPTY 1 << VIRTIO_F_NOTIFY_ON_EMPTY diff --git a/sys/linux/test/arm64-syz_kvm_setup_syzos_vm-vgicv3-its b/sys/linux/test/arm64-syz_kvm_setup_syzos_vm-vgicv3-its new file mode 100644 index 000000000..c1f151c8a --- /dev/null +++ b/sys/linux/test/arm64-syz_kvm_setup_syzos_vm-vgicv3-its @@ -0,0 +1,30 @@ +# +# requires: arch=arm64 +# +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) +r3 = syz_kvm_add_vcpu(r2, &AUTO={0x0, &AUTO=[@irq_setup={AUTO, AUTO, {0x1, 0x20}}], AUTO}, 0x0, 0x0) +syz_kvm_vgic_v3_setup(r1, 0x1, 0x100) + +# +# Set up ITS device with redistributor at address 0x08080000 (declared at executor/kvm.h) +# Create KVM_DEV_TYPE_ARM_VGIC_ITS. +# +ioctl$KVM_CREATE_DEVICE(r1, AUTO, &AUTO={0x8, <r4=>0xffffffffffffffff, 0x0}) +# +# Set device attribute {KVM_DEV_ARM_VGIC_GRP_CTRL, KVM_DEV_ARM_VGIC_CTRL_INIT, 0}. +# +ioctl$KVM_SET_DEVICE_ATTR(r4, AUTO, &AUTO=@attr_arm64={0x0, 0x4, 0x0, 0x0}) +# +# Set device attribute {KVM_DEV_ARM_VGIC_GRP_ADDR, KVM_VGIC_ITS_ADDR_TYPE, &addr=0x08080000}. +# +ioctl$KVM_SET_DEVICE_ATTR(r4, AUTO, &AUTO=@attr_arm64={0x0, 0x0, 0x4, &AUTO=0x08080000}) + +ioctl$KVM_RUN(r3, AUTO, 0x0) +# +# Calling KVM_RUN here again would result in infinite loop. +# Instead, signal SPI 32 (0x1000020), so that the guest can execute another uexit in the IRQ handler. +# +ioctl$KVM_IRQ_LINE(r1, AUTO, &AUTO={0x1000020, 0x1}) +ioctl$KVM_RUN(r3, AUTO, 0x0) |
