From f1e4447ce91d33c3785db1a7c2bafc768eb3f790 Mon Sep 17 00:00:00 2001 From: Alexander Potapenko Date: Fri, 18 Oct 2024 15:14:40 +0200 Subject: 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 --- sys/linux/socket_vnet.txt | 2 +- .../test/arm64-syz_kvm_setup_syzos_vm-vgicv3-its | 30 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 sys/linux/test/arm64-syz_kvm_setup_syzos_vm-vgicv3-its (limited to 'sys/linux') 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, 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) -- cgit mrf-deployment