arm64: Statically enable TSO for KVM VM

Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
diff --git a/arm64/kvm.c b/arm64/kvm.c
index 23b4dab..105ccb5 100644
--- a/arm64/kvm.c
+++ b/arm64/kvm.c
@@ -119,6 +119,23 @@
 	pr_debug("MTE capability enabled");
 }
 
+#define APPLE_VIRT_TSO_IO	0x61
+#define APPLE_VIRT_TSO_ENABLE	_IOW(APPLE_VIRT_TSO_IO, 0x00, int *)
+
+static void kvm__arch_enable_tso(struct kvm *kvm)
+{
+	int fd;
+
+	fd = open("/dev/apple_virt_tso", O_RDWR);
+	if (fd < 0)
+		die_perror("open()");
+
+	if (ioctl(fd, APPLE_VIRT_TSO_ENABLE, &kvm->vm_fd))
+		die_perror("APPLE_VIRT_TSO_ENABLE");
+
+	close(fd);
+}
+
 void kvm__arch_init(struct kvm *kvm)
 {
 	/* Create the virtual GIC. */
@@ -126,6 +143,7 @@
 		die("Failed to create virtual GIC");
 
 	kvm__arch_enable_mte(kvm);
+	kvm__arch_enable_tso(kvm);
 }
 
 static u64 kvm__arch_get_payload_region_size(struct kvm *kvm)