thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-linux-headers-synchronize-generic-and-x86-KVM-header.patch

b38b0f
From 4a8e202ddd9bde207a5a9caaee6e0f06399a3052 Mon Sep 17 00:00:00 2001
b38b0f
From: Paolo Bonzini <pbonzini@redhat.com>
b38b0f
Date: Mon, 22 Jul 2019 18:22:13 +0100
b38b0f
Subject: [PATCH 32/39] linux-headers: synchronize generic and x86 KVM headers
b38b0f
 with upstream [rhel-only]
b38b0f
b38b0f
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
b38b0f
Message-id: <20190722182220.19374-12-pbonzini@redhat.com>
b38b0f
Patchwork-id: 89628
b38b0f
O-Subject: [RHEL-8.1.0 PATCH qemu-kvm v3 11/18] linux-headers: synchronize generic and x86 KVM headers with upstream [rhel-only]
b38b0f
Bugzilla: 1689269
b38b0f
RH-Acked-by: Peter Xu <zhexu@redhat.com>
b38b0f
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
b38b0f
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
b38b0f
b38b0f
From: Liran Alon <liran.alon@oracle.com>
b38b0f
b38b0f
Relevant files copied from upstream QEMU at commit
b38b0f
1d33bea4d013104f01d1c4badc4c670e55c16cca.
b38b0f
b38b0f
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
b38b0f
---
b38b0f
 linux-headers/asm-x86/kvm.h | 76 ++++++++++++++++++++++++++++++++++++--
b38b0f
 linux-headers/linux/kvm.h   | 89 +++++++++++++++++++++++++++++++++++++++++++--
b38b0f
 2 files changed, 158 insertions(+), 7 deletions(-)
b38b0f
b38b0f
diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h
b38b0f
index dcf4dc9..6e7dd79 100644
b38b0f
--- a/linux-headers/asm-x86/kvm.h
b38b0f
+++ b/linux-headers/asm-x86/kvm.h
b38b0f
@@ -288,6 +288,7 @@ struct kvm_reinject_control {
b38b0f
 #define KVM_VCPUEVENT_VALID_SIPI_VECTOR	0x00000002
b38b0f
 #define KVM_VCPUEVENT_VALID_SHADOW	0x00000004
b38b0f
 #define KVM_VCPUEVENT_VALID_SMM		0x00000008
b38b0f
+#define KVM_VCPUEVENT_VALID_PAYLOAD	0x00000010
b38b0f
 
b38b0f
 /* Interrupt shadow states */
b38b0f
 #define KVM_X86_SHADOW_INT_MOV_SS	0x01
b38b0f
@@ -299,7 +300,7 @@ struct kvm_vcpu_events {
b38b0f
 		__u8 injected;
b38b0f
 		__u8 nr;
b38b0f
 		__u8 has_error_code;
b38b0f
-		__u8 pad;
b38b0f
+		__u8 pending;
b38b0f
 		__u32 error_code;
b38b0f
 	} exception;
b38b0f
 	struct {
b38b0f
@@ -322,7 +323,9 @@ struct kvm_vcpu_events {
b38b0f
 		__u8 smm_inside_nmi;
b38b0f
 		__u8 latched_init;
b38b0f
 	} smi;
b38b0f
-	__u32 reserved[9];
b38b0f
+	__u8 reserved[27];
b38b0f
+	__u8 exception_has_payload;
b38b0f
+	__u64 exception_payload;
b38b0f
 };
b38b0f
 
b38b0f
 /* for KVM_GET/SET_DEBUGREGS */
b38b0f
@@ -354,12 +357,79 @@ struct kvm_xcrs {
b38b0f
 	__u64 padding[16];
b38b0f
 };
b38b0f
 
b38b0f
-/* definition of registers in kvm_run */
b38b0f
+#define KVM_SYNC_X86_REGS      (1UL << 0)
b38b0f
+#define KVM_SYNC_X86_SREGS     (1UL << 1)
b38b0f
+#define KVM_SYNC_X86_EVENTS    (1UL << 2)
b38b0f
+
b38b0f
+#define KVM_SYNC_X86_VALID_FIELDS \
b38b0f
+	(KVM_SYNC_X86_REGS| \
b38b0f
+	 KVM_SYNC_X86_SREGS| \
b38b0f
+	 KVM_SYNC_X86_EVENTS)
b38b0f
+
b38b0f
+/* kvm_sync_regs struct included by kvm_run struct */
b38b0f
 struct kvm_sync_regs {
b38b0f
+	/* Members of this structure are potentially malicious.
b38b0f
+	 * Care must be taken by code reading, esp. interpreting,
b38b0f
+	 * data fields from them inside KVM to prevent TOCTOU and
b38b0f
+	 * double-fetch types of vulnerabilities.
b38b0f
+	 */
b38b0f
+	struct kvm_regs regs;
b38b0f
+	struct kvm_sregs sregs;
b38b0f
+	struct kvm_vcpu_events events;
b38b0f
 };
b38b0f
 
b38b0f
 #define KVM_X86_QUIRK_LINT0_REENABLED	(1 << 0)
b38b0f
 #define KVM_X86_QUIRK_CD_NW_CLEARED	(1 << 1)
b38b0f
 #define KVM_X86_QUIRK_LAPIC_MMIO_HOLE	(1 << 2)
b38b0f
+#define KVM_X86_QUIRK_OUT_7E_INC_RIP	(1 << 3)
b38b0f
+
b38b0f
+#define KVM_STATE_NESTED_FORMAT_VMX	0
b38b0f
+#define KVM_STATE_NESTED_FORMAT_SVM	1
b38b0f
+
b38b0f
+#define KVM_STATE_NESTED_GUEST_MODE	0x00000001
b38b0f
+#define KVM_STATE_NESTED_RUN_PENDING	0x00000002
b38b0f
+#define KVM_STATE_NESTED_EVMCS		0x00000004
b38b0f
+
b38b0f
+#define KVM_STATE_NESTED_VMX_VMCS_SIZE	0x1000
b38b0f
+
b38b0f
+#define KVM_STATE_NESTED_SMM_GUEST_MODE	0x00000001
b38b0f
+#define KVM_STATE_NESTED_SMM_VMXON	0x00000002
b38b0f
+
b38b0f
+struct kvm_vmx_nested_state_data {
b38b0f
+	__u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
b38b0f
+	__u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
b38b0f
+};
b38b0f
+
b38b0f
+struct kvm_vmx_nested_state_hdr {
b38b0f
+	__u64 vmxon_pa;
b38b0f
+	__u64 vmcs12_pa;
b38b0f
+
b38b0f
+	struct {
b38b0f
+		__u16 flags;
b38b0f
+	} smm;
b38b0f
+};
b38b0f
+
b38b0f
+/* for KVM_CAP_NESTED_STATE */
b38b0f
+struct kvm_nested_state {
b38b0f
+	__u16 flags;
b38b0f
+	__u16 format;
b38b0f
+	__u32 size;
b38b0f
+
b38b0f
+	union {
b38b0f
+		struct kvm_vmx_nested_state_hdr vmx;
b38b0f
+
b38b0f
+		/* Pad the header to 128 bytes.  */
b38b0f
+		__u8 pad[120];
b38b0f
+	} hdr;
b38b0f
+
b38b0f
+	/*
b38b0f
+	 * Define data region as 0 bytes to preserve backwards-compatability
b38b0f
+	 * to old definition of kvm_nested_state in order to avoid changing
b38b0f
+	 * KVM_{GET,PUT}_NESTED_STATE ioctl values.
b38b0f
+	 */
b38b0f
+	union {
b38b0f
+		struct kvm_vmx_nested_state_data vmx[0];
b38b0f
+	} data;
b38b0f
+};
b38b0f
 
b38b0f
 #endif /* _ASM_X86_KVM_H */
b38b0f
diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
b38b0f
index 8be1232..c8423e7 100644
b38b0f
--- a/linux-headers/linux/kvm.h
b38b0f
+++ b/linux-headers/linux/kvm.h
b38b0f
@@ -396,6 +396,10 @@ struct kvm_run {
b38b0f
 		char padding[256];
b38b0f
 	};
b38b0f
 
b38b0f
+	/* 2048 is the size of the char array used to bound/pad the size
b38b0f
+	 * of the union that holds sync regs.
b38b0f
+	 */
b38b0f
+	#define SYNC_REGS_SIZE_BYTES 2048
b38b0f
 	/*
b38b0f
 	 * shared registers between kvm and userspace.
b38b0f
 	 * kvm_valid_regs specifies the register classes set by the host
b38b0f
@@ -407,7 +411,7 @@ struct kvm_run {
b38b0f
 	__u64 kvm_dirty_regs;
b38b0f
 	union {
b38b0f
 		struct kvm_sync_regs regs;
b38b0f
-		char padding[2048];
b38b0f
+		char padding[SYNC_REGS_SIZE_BYTES];
b38b0f
 	} s;
b38b0f
 };
b38b0f
 
b38b0f
@@ -416,13 +420,19 @@ struct kvm_run {
b38b0f
 struct kvm_coalesced_mmio_zone {
b38b0f
 	__u64 addr;
b38b0f
 	__u32 size;
b38b0f
-	__u32 pad;
b38b0f
+	union {
b38b0f
+		__u32 pad;
b38b0f
+		__u32 pio;
b38b0f
+	};
b38b0f
 };
b38b0f
 
b38b0f
 struct kvm_coalesced_mmio {
b38b0f
 	__u64 phys_addr;
b38b0f
 	__u32 len;
b38b0f
-	__u32 pad;
b38b0f
+	union {
b38b0f
+		__u32 pad;
b38b0f
+		__u32 pio;
b38b0f
+	};
b38b0f
 	__u8  data[8];
b38b0f
 };
b38b0f
 
b38b0f
@@ -482,6 +492,17 @@ struct kvm_dirty_log {
b38b0f
 	};
b38b0f
 };
b38b0f
 
b38b0f
+/* for KVM_CLEAR_DIRTY_LOG */
b38b0f
+struct kvm_clear_dirty_log {
b38b0f
+	__u32 slot;
b38b0f
+	__u32 num_pages;
b38b0f
+	__u64 first_page;
b38b0f
+	union {
b38b0f
+		void *dirty_bitmap; /* one bit per page */
b38b0f
+		__u64 padding2;
b38b0f
+	};
b38b0f
+};
b38b0f
+
b38b0f
 /* for KVM_SET_SIGNAL_MASK */
b38b0f
 struct kvm_signal_mask {
b38b0f
 	__u32 len;
b38b0f
@@ -672,6 +693,13 @@ struct kvm_ioeventfd {
b38b0f
 	__u8  pad[36];
b38b0f
 };
b38b0f
 
b38b0f
+#define KVM_X86_DISABLE_EXITS_MWAIT          (1 << 0)
b38b0f
+#define KVM_X86_DISABLE_EXITS_HLT            (1 << 1)
b38b0f
+#define KVM_X86_DISABLE_EXITS_PAUSE          (1 << 2)
b38b0f
+#define KVM_X86_DISABLE_VALID_EXITS          (KVM_X86_DISABLE_EXITS_MWAIT | \
b38b0f
+                                              KVM_X86_DISABLE_EXITS_HLT | \
b38b0f
+                                              KVM_X86_DISABLE_EXITS_PAUSE)
b38b0f
+
b38b0f
 /* for KVM_ENABLE_CAP */
b38b0f
 struct kvm_enable_cap {
b38b0f
 	/* in */
b38b0f
@@ -708,6 +736,7 @@ struct kvm_ppc_one_seg_page_size {
b38b0f
 
b38b0f
 #define KVM_PPC_PAGE_SIZES_REAL		0x00000001
b38b0f
 #define KVM_PPC_1T_SEGMENTS		0x00000002
b38b0f
+#define KVM_PPC_NO_HASH			0x00000004
b38b0f
 
b38b0f
 struct kvm_ppc_smmu_info {
b38b0f
 	__u64 flags;
b38b0f
@@ -740,6 +769,15 @@ struct kvm_ppc_resize_hpt {
b38b0f
 #define KVM_S390_SIE_PAGE_OFFSET 1
b38b0f
 
b38b0f
 /*
b38b0f
+ * On arm64, machine type can be used to request the physical
b38b0f
+ * address size for the VM. Bits[7-0] are reserved for the guest
b38b0f
+ * PA size shift (i.e, log2(PA_Size)). For backward compatibility,
b38b0f
+ * value 0 implies the default IPA size, 40bits.
b38b0f
+ */
b38b0f
+#define KVM_VM_TYPE_ARM_IPA_SIZE_MASK	0xffULL
b38b0f
+#define KVM_VM_TYPE_ARM_IPA_SIZE(x)		\
b38b0f
+	((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK)
b38b0f
+/*
b38b0f
  * ioctls for /dev/kvm fds:
b38b0f
  */
b38b0f
 #define KVM_GET_API_VERSION       _IO(KVMIO,   0x00)
b38b0f
@@ -925,7 +963,7 @@ struct kvm_ppc_resize_hpt {
b38b0f
 #define KVM_CAP_S390_GS 140
b38b0f
 #define KVM_CAP_S390_AIS 141
b38b0f
 #define KVM_CAP_SPAPR_TCE_VFIO 142
b38b0f
-#define KVM_CAP_X86_GUEST_MWAIT 143
b38b0f
+#define KVM_CAP_X86_DISABLE_EXITS 143
b38b0f
 #define KVM_CAP_ARM_USER_IRQ 144
b38b0f
 #define KVM_CAP_S390_CMMA_MIGRATION 145
b38b0f
 #define KVM_CAP_PPC_FWNMI 146
b38b0f
@@ -936,11 +974,25 @@ struct kvm_ppc_resize_hpt {
b38b0f
 #define KVM_CAP_PPC_GET_CPU_CHAR 151
b38b0f
 #define KVM_CAP_S390_BPB 152
b38b0f
 #define KVM_CAP_GET_MSR_FEATURES 153
b38b0f
+#define KVM_CAP_HYPERV_EVENTFD 154
b38b0f
+#define KVM_CAP_HYPERV_TLBFLUSH 155
b38b0f
 #define KVM_CAP_S390_HPAGE_1M 156
b38b0f
 #define KVM_CAP_NESTED_STATE 157
b38b0f
 #define KVM_CAP_ARM_INJECT_SERROR_ESR 158
b38b0f
 #define KVM_CAP_MSR_PLATFORM_INFO 159
b38b0f
 #define KVM_CAP_PPC_NESTED_HV 160
b38b0f
+#define KVM_CAP_HYPERV_SEND_IPI 161
b38b0f
+#define KVM_CAP_COALESCED_PIO 162
b38b0f
+#define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163
b38b0f
+#define KVM_CAP_EXCEPTION_PAYLOAD 164
b38b0f
+#define KVM_CAP_ARM_VM_IPA_SIZE 165
b38b0f
+#define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166 /* Obsolete */
b38b0f
+#define KVM_CAP_HYPERV_CPUID 167
b38b0f
+#define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 168
b38b0f
+#define KVM_CAP_PPC_IRQ_XIVE 169
b38b0f
+#define KVM_CAP_ARM_SVE 170
b38b0f
+#define KVM_CAP_ARM_PTRAUTH_ADDRESS 171
b38b0f
+#define KVM_CAP_ARM_PTRAUTH_GENERIC 172
b38b0f
 
b38b0f
 #ifdef KVM_CAP_IRQ_ROUTING
b38b0f
 
b38b0f
@@ -1098,6 +1150,7 @@ struct kvm_dirty_tlb {
b38b0f
 #define KVM_REG_SIZE_U256	0x0050000000000000ULL
b38b0f
 #define KVM_REG_SIZE_U512	0x0060000000000000ULL
b38b0f
 #define KVM_REG_SIZE_U1024	0x0070000000000000ULL
b38b0f
+#define KVM_REG_SIZE_U2048	0x0080000000000000ULL
b38b0f
 
b38b0f
 struct kvm_reg_list {
b38b0f
 	__u64 n; /* number of regs */
b38b0f
@@ -1164,6 +1217,8 @@ enum kvm_device_type {
b38b0f
 #define KVM_DEV_TYPE_ARM_VGIC_V3	KVM_DEV_TYPE_ARM_VGIC_V3
b38b0f
 	KVM_DEV_TYPE_ARM_VGIC_ITS,
b38b0f
 #define KVM_DEV_TYPE_ARM_VGIC_ITS	KVM_DEV_TYPE_ARM_VGIC_ITS
b38b0f
+	KVM_DEV_TYPE_XIVE,
b38b0f
+#define KVM_DEV_TYPE_XIVE		KVM_DEV_TYPE_XIVE
b38b0f
 	KVM_DEV_TYPE_MAX,
b38b0f
 };
b38b0f
 
b38b0f
@@ -1380,6 +1435,22 @@ struct kvm_enc_region {
b38b0f
 #define KVM_MEMORY_ENCRYPT_REG_REGION    _IOR(KVMIO, 0xbb, struct kvm_enc_region)
b38b0f
 #define KVM_MEMORY_ENCRYPT_UNREG_REGION  _IOR(KVMIO, 0xbc, struct kvm_enc_region)
b38b0f
 
b38b0f
+/* Available with KVM_CAP_HYPERV_EVENTFD */
b38b0f
+#define KVM_HYPERV_EVENTFD        _IOW(KVMIO,  0xbd, struct kvm_hyperv_eventfd)
b38b0f
+
b38b0f
+/* Available with KVM_CAP_NESTED_STATE */
b38b0f
+#define KVM_GET_NESTED_STATE         _IOWR(KVMIO, 0xbe, struct kvm_nested_state)
b38b0f
+#define KVM_SET_NESTED_STATE         _IOW(KVMIO,  0xbf, struct kvm_nested_state)
b38b0f
+
b38b0f
+/* Available with KVM_CAP_MANUAL_DIRTY_LOG_PROTECT_2 */
b38b0f
+#define KVM_CLEAR_DIRTY_LOG          _IOWR(KVMIO, 0xc0, struct kvm_clear_dirty_log)
b38b0f
+
b38b0f
+/* Available with KVM_CAP_HYPERV_CPUID */
b38b0f
+#define KVM_GET_SUPPORTED_HV_CPUID _IOWR(KVMIO, 0xc1, struct kvm_cpuid2)
b38b0f
+
b38b0f
+/* Available with KVM_CAP_ARM_SVE */
b38b0f
+#define KVM_ARM_VCPU_FINALIZE	  _IOW(KVMIO,  0xc2, int)
b38b0f
+
b38b0f
 /* Secure Encrypted Virtualization command */
b38b0f
 enum sev_cmd_id {
b38b0f
 	/* Guest initialization commands */
b38b0f
@@ -1520,4 +1591,14 @@ struct kvm_assigned_msix_entry {
b38b0f
 #define KVM_ARM_DEV_EL1_PTIMER		(1 << 1)
b38b0f
 #define KVM_ARM_DEV_PMU			(1 << 2)
b38b0f
 
b38b0f
+struct kvm_hyperv_eventfd {
b38b0f
+	__u32 conn_id;
b38b0f
+	__s32 fd;
b38b0f
+	__u32 flags;
b38b0f
+	__u32 padding[3];
b38b0f
+};
b38b0f
+
b38b0f
+#define KVM_HYPERV_CONN_ID_MASK		0x00ffffff
b38b0f
+#define KVM_HYPERV_EVENTFD_DEASSIGN	(1 << 0)
b38b0f
+
b38b0f
 #endif /* __LINUX_KVM_H */
b38b0f
-- 
b38b0f
1.8.3.1
b38b0f