yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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