| Elliott Hughes | 180edef | 2023-11-02 00:08:05 +0000 | [diff] [blame] | 1 | /* | 
|  | 2 | * This file is auto-generated. Modifications will be lost. | 
|  | 3 | * | 
|  | 4 | * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/ | 
|  | 5 | * for more information. | 
|  | 6 | */ | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 7 | #ifndef _ASM_X86_KVM_H | 
|  | 8 | #define _ASM_X86_KVM_H | 
| Christopher Ferris | 7f4c837 | 2024-06-03 14:22:19 -0700 | [diff] [blame] | 9 | #include <linux/const.h> | 
|  | 10 | #include <linux/bits.h> | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 11 | #include <linux/types.h> | 
|  | 12 | #include <linux/ioctl.h> | 
| Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 13 | #include <linux/stddef.h> | 
| Christopher Ferris | 525ce91 | 2017-07-26 13:12:53 -0700 | [diff] [blame] | 14 | #define KVM_PIO_PAGE_OFFSET 1 | 
|  | 15 | #define KVM_COALESCED_MMIO_PAGE_OFFSET 2 | 
| Christopher Ferris | 05667cd | 2021-02-16 16:01:34 -0800 | [diff] [blame] | 16 | #define KVM_DIRTY_LOG_PAGE_OFFSET 64 | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 17 | #define DE_VECTOR 0 | 
|  | 18 | #define DB_VECTOR 1 | 
|  | 19 | #define BP_VECTOR 3 | 
|  | 20 | #define OF_VECTOR 4 | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 21 | #define BR_VECTOR 5 | 
|  | 22 | #define UD_VECTOR 6 | 
|  | 23 | #define NM_VECTOR 7 | 
|  | 24 | #define DF_VECTOR 8 | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 25 | #define TS_VECTOR 10 | 
|  | 26 | #define NP_VECTOR 11 | 
|  | 27 | #define SS_VECTOR 12 | 
|  | 28 | #define GP_VECTOR 13 | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 29 | #define PF_VECTOR 14 | 
|  | 30 | #define MF_VECTOR 16 | 
| Christopher Ferris | 82d7504 | 2015-01-26 10:57:07 -0800 | [diff] [blame] | 31 | #define AC_VECTOR 17 | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 32 | #define MC_VECTOR 18 | 
| Christopher Ferris | 82d7504 | 2015-01-26 10:57:07 -0800 | [diff] [blame] | 33 | #define XM_VECTOR 19 | 
|  | 34 | #define VE_VECTOR 20 | 
|  | 35 | #define __KVM_HAVE_PIT | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 36 | #define __KVM_HAVE_IOAPIC | 
|  | 37 | #define __KVM_HAVE_IRQ_LINE | 
|  | 38 | #define __KVM_HAVE_MSI | 
|  | 39 | #define __KVM_HAVE_USER_NMI | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 40 | #define __KVM_HAVE_MSIX | 
|  | 41 | #define __KVM_HAVE_MCE | 
|  | 42 | #define __KVM_HAVE_PIT_STATE2 | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 43 | #define __KVM_HAVE_XEN_HVM | 
|  | 44 | #define __KVM_HAVE_VCPU_EVENTS | 
|  | 45 | #define __KVM_HAVE_DEBUGREGS | 
|  | 46 | #define __KVM_HAVE_XSAVE | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 47 | #define __KVM_HAVE_XCRS | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 48 | #define KVM_NR_INTERRUPTS 256 | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 49 | struct kvm_pic_state { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 50 | __u8 last_irr; | 
|  | 51 | __u8 irr; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 52 | __u8 imr; | 
|  | 53 | __u8 isr; | 
|  | 54 | __u8 priority_add; | 
|  | 55 | __u8 irq_base; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 56 | __u8 read_reg_select; | 
|  | 57 | __u8 poll; | 
|  | 58 | __u8 special_mask; | 
|  | 59 | __u8 init_state; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 60 | __u8 auto_eoi; | 
|  | 61 | __u8 rotate_on_auto_eoi; | 
|  | 62 | __u8 special_fully_nested_mode; | 
|  | 63 | __u8 init4; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 64 | __u8 elcr; | 
|  | 65 | __u8 elcr_mask; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 66 | }; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 67 | #define KVM_IOAPIC_NUM_PINS 24 | 
|  | 68 | struct kvm_ioapic_state { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 69 | __u64 base_address; | 
|  | 70 | __u32 ioregsel; | 
|  | 71 | __u32 id; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 72 | __u32 irr; | 
|  | 73 | __u32 pad; | 
|  | 74 | union { | 
|  | 75 | __u64 bits; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 76 | struct { | 
|  | 77 | __u8 vector; | 
|  | 78 | __u8 delivery_mode : 3; | 
|  | 79 | __u8 dest_mode : 1; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 80 | __u8 delivery_status : 1; | 
|  | 81 | __u8 polarity : 1; | 
|  | 82 | __u8 remote_irr : 1; | 
|  | 83 | __u8 trig_mode : 1; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 84 | __u8 mask : 1; | 
|  | 85 | __u8 reserve : 7; | 
|  | 86 | __u8 reserved[4]; | 
|  | 87 | __u8 dest_id; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 88 | } fields; | 
|  | 89 | } redirtbl[KVM_IOAPIC_NUM_PINS]; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 90 | }; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 91 | #define KVM_IRQCHIP_PIC_MASTER 0 | 
|  | 92 | #define KVM_IRQCHIP_PIC_SLAVE 1 | 
|  | 93 | #define KVM_IRQCHIP_IOAPIC 2 | 
|  | 94 | #define KVM_NR_IRQCHIPS 3 | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 95 | #define KVM_RUN_X86_SMM (1 << 0) | 
| Christopher Ferris | a9750ed | 2021-05-03 14:02:49 -0700 | [diff] [blame] | 96 | #define KVM_RUN_X86_BUS_LOCK (1 << 1) | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 97 | struct kvm_regs { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 98 | __u64 rax, rbx, rcx, rdx; | 
|  | 99 | __u64 rsi, rdi, rsp, rbp; | 
|  | 100 | __u64 r8, r9, r10, r11; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 101 | __u64 r12, r13, r14, r15; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 102 | __u64 rip, rflags; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 103 | }; | 
|  | 104 | #define KVM_APIC_REG_SIZE 0x400 | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 105 | struct kvm_lapic_state { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 106 | char regs[KVM_APIC_REG_SIZE]; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 107 | }; | 
|  | 108 | struct kvm_segment { | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 109 | __u64 base; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 110 | __u32 limit; | 
|  | 111 | __u16 selector; | 
|  | 112 | __u8 type; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 113 | __u8 present, dpl, db, s, l, g, avl; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 114 | __u8 unusable; | 
|  | 115 | __u8 padding; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 116 | }; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 117 | struct kvm_dtable { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 118 | __u64 base; | 
|  | 119 | __u16 limit; | 
|  | 120 | __u16 padding[3]; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 121 | }; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 122 | struct kvm_sregs { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 123 | struct kvm_segment cs, ds, es, fs, gs, ss; | 
|  | 124 | struct kvm_segment tr, ldt; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 125 | struct kvm_dtable gdt, idt; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 126 | __u64 cr0, cr2, cr3, cr4, cr8; | 
|  | 127 | __u64 efer; | 
|  | 128 | __u64 apic_base; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 129 | __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64]; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 130 | }; | 
| Christopher Ferris | 3a39c0b | 2021-09-02 00:03:38 +0000 | [diff] [blame] | 131 | struct kvm_sregs2 { | 
|  | 132 | struct kvm_segment cs, ds, es, fs, gs, ss; | 
|  | 133 | struct kvm_segment tr, ldt; | 
|  | 134 | struct kvm_dtable gdt, idt; | 
|  | 135 | __u64 cr0, cr2, cr3, cr4, cr8; | 
|  | 136 | __u64 efer; | 
|  | 137 | __u64 apic_base; | 
|  | 138 | __u64 flags; | 
|  | 139 | __u64 pdptrs[4]; | 
|  | 140 | }; | 
|  | 141 | #define KVM_SREGS2_FLAGS_PDPTRS_VALID 1 | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 142 | struct kvm_fpu { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 143 | __u8 fpr[8][16]; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 144 | __u16 fcw; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 145 | __u16 fsw; | 
|  | 146 | __u8 ftwx; | 
|  | 147 | __u8 pad1; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 148 | __u16 last_opcode; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 149 | __u64 last_ip; | 
|  | 150 | __u64 last_dp; | 
|  | 151 | __u8 xmm[16][16]; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 152 | __u32 mxcsr; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 153 | __u32 pad2; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 154 | }; | 
|  | 155 | struct kvm_msr_entry { | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 156 | __u32 index; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 157 | __u32 reserved; | 
|  | 158 | __u64 data; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 159 | }; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 160 | struct kvm_msrs { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 161 | __u32 nmsrs; | 
|  | 162 | __u32 pad; | 
| Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 163 | struct kvm_msr_entry entries[]; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 164 | }; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 165 | struct kvm_msr_list { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 166 | __u32 nmsrs; | 
| Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 167 | __u32 indices[]; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 168 | }; | 
| Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 169 | #define KVM_MSR_FILTER_MAX_BITMAP_SIZE 0x600 | 
|  | 170 | struct kvm_msr_filter_range { | 
|  | 171 | #define KVM_MSR_FILTER_READ (1 << 0) | 
|  | 172 | #define KVM_MSR_FILTER_WRITE (1 << 1) | 
| Christopher Ferris | 8b7fdc9 | 2023-02-21 13:36:32 -0800 | [diff] [blame] | 173 | #define KVM_MSR_FILTER_RANGE_VALID_MASK (KVM_MSR_FILTER_READ | KVM_MSR_FILTER_WRITE) | 
| Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 174 | __u32 flags; | 
|  | 175 | __u32 nmsrs; | 
|  | 176 | __u32 base; | 
|  | 177 | __u8 * bitmap; | 
|  | 178 | }; | 
|  | 179 | #define KVM_MSR_FILTER_MAX_RANGES 16 | 
|  | 180 | struct kvm_msr_filter { | 
|  | 181 | #define KVM_MSR_FILTER_DEFAULT_ALLOW (0 << 0) | 
|  | 182 | #define KVM_MSR_FILTER_DEFAULT_DENY (1 << 0) | 
| Christopher Ferris | 8b7fdc9 | 2023-02-21 13:36:32 -0800 | [diff] [blame] | 183 | #define KVM_MSR_FILTER_VALID_MASK (KVM_MSR_FILTER_DEFAULT_DENY) | 
| Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 184 | __u32 flags; | 
|  | 185 | struct kvm_msr_filter_range ranges[KVM_MSR_FILTER_MAX_RANGES]; | 
|  | 186 | }; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 187 | struct kvm_cpuid_entry { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 188 | __u32 function; | 
|  | 189 | __u32 eax; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 190 | __u32 ebx; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 191 | __u32 ecx; | 
|  | 192 | __u32 edx; | 
|  | 193 | __u32 padding; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 194 | }; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 195 | struct kvm_cpuid { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 196 | __u32 nent; | 
|  | 197 | __u32 padding; | 
| Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 198 | struct kvm_cpuid_entry entries[]; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 199 | }; | 
|  | 200 | struct kvm_cpuid_entry2 { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 201 | __u32 function; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 202 | __u32 index; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 203 | __u32 flags; | 
|  | 204 | __u32 eax; | 
|  | 205 | __u32 ebx; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 206 | __u32 ecx; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 207 | __u32 edx; | 
|  | 208 | __u32 padding[3]; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 209 | }; | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 210 | #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX (1 << 0) | 
|  | 211 | #define KVM_CPUID_FLAG_STATEFUL_FUNC (1 << 1) | 
|  | 212 | #define KVM_CPUID_FLAG_STATE_READ_NEXT (1 << 2) | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 213 | struct kvm_cpuid2 { | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 214 | __u32 nent; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 215 | __u32 padding; | 
| Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 216 | struct kvm_cpuid_entry2 entries[]; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 217 | }; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 218 | struct kvm_pit_channel_state { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 219 | __u32 count; | 
|  | 220 | __u16 latched_count; | 
|  | 221 | __u8 count_latched; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 222 | __u8 status_latched; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 223 | __u8 status; | 
|  | 224 | __u8 read_state; | 
|  | 225 | __u8 write_state; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 226 | __u8 write_latch; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 227 | __u8 rw_mode; | 
|  | 228 | __u8 mode; | 
|  | 229 | __u8 bcd; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 230 | __u8 gate; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 231 | __s64 count_load_time; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 232 | }; | 
|  | 233 | struct kvm_debug_exit_arch { | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 234 | __u32 exception; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 235 | __u32 pad; | 
|  | 236 | __u64 pc; | 
|  | 237 | __u64 dr6; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 238 | __u64 dr7; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 239 | }; | 
|  | 240 | #define KVM_GUESTDBG_USE_SW_BP 0x00010000 | 
|  | 241 | #define KVM_GUESTDBG_USE_HW_BP 0x00020000 | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 242 | #define KVM_GUESTDBG_INJECT_DB 0x00040000 | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 243 | #define KVM_GUESTDBG_INJECT_BP 0x00080000 | 
| Christopher Ferris | 2abfa9e | 2021-11-01 16:26:06 -0700 | [diff] [blame] | 244 | #define KVM_GUESTDBG_BLOCKIRQ 0x00100000 | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 245 | struct kvm_guest_debug_arch { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 246 | __u64 debugreg[8]; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 247 | }; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 248 | struct kvm_pit_state { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 249 | struct kvm_pit_channel_state channels[3]; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 250 | }; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 251 | #define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001 | 
| Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 252 | #define KVM_PIT_FLAGS_SPEAKER_DATA_ON 0x00000002 | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 253 | struct kvm_pit_state2 { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 254 | struct kvm_pit_channel_state channels[3]; | 
|  | 255 | __u32 flags; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 256 | __u32 reserved[9]; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 257 | }; | 
|  | 258 | struct kvm_reinject_control { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 259 | __u8 pit_reinject; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 260 | __u8 reserved[31]; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 261 | }; | 
|  | 262 | #define KVM_VCPUEVENT_VALID_NMI_PENDING 0x00000001 | 
|  | 263 | #define KVM_VCPUEVENT_VALID_SIPI_VECTOR 0x00000002 | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 264 | #define KVM_VCPUEVENT_VALID_SHADOW 0x00000004 | 
|  | 265 | #define KVM_VCPUEVENT_VALID_SMM 0x00000008 | 
| Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 266 | #define KVM_VCPUEVENT_VALID_PAYLOAD 0x00000010 | 
| Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 267 | #define KVM_VCPUEVENT_VALID_TRIPLE_FAULT 0x00000020 | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 268 | #define KVM_X86_SHADOW_INT_MOV_SS 0x01 | 
|  | 269 | #define KVM_X86_SHADOW_INT_STI 0x02 | 
|  | 270 | struct kvm_vcpu_events { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 271 | struct { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 272 | __u8 injected; | 
|  | 273 | __u8 nr; | 
|  | 274 | __u8 has_error_code; | 
| Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 275 | __u8 pending; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 276 | __u32 error_code; | 
|  | 277 | } exception; | 
|  | 278 | struct { | 
|  | 279 | __u8 injected; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 280 | __u8 nr; | 
|  | 281 | __u8 soft; | 
|  | 282 | __u8 shadow; | 
|  | 283 | } interrupt; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 284 | struct { | 
|  | 285 | __u8 injected; | 
|  | 286 | __u8 pending; | 
|  | 287 | __u8 masked; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 288 | __u8 pad; | 
|  | 289 | } nmi; | 
|  | 290 | __u32 sipi_vector; | 
|  | 291 | __u32 flags; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 292 | struct { | 
|  | 293 | __u8 smm; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 294 | __u8 pending; | 
|  | 295 | __u8 smm_inside_nmi; | 
|  | 296 | __u8 latched_init; | 
|  | 297 | } smi; | 
| Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 298 | struct { | 
|  | 299 | __u8 pending; | 
|  | 300 | } triple_fault; | 
|  | 301 | __u8 reserved[26]; | 
| Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 302 | __u8 exception_has_payload; | 
|  | 303 | __u64 exception_payload; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 304 | }; | 
|  | 305 | struct kvm_debugregs { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 306 | __u64 db[4]; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 307 | __u64 dr6; | 
|  | 308 | __u64 dr7; | 
|  | 309 | __u64 flags; | 
|  | 310 | __u64 reserved[9]; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 311 | }; | 
|  | 312 | struct kvm_xsave { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 313 | __u32 region[1024]; | 
| Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 314 | __u32 extra[]; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 315 | }; | 
|  | 316 | #define KVM_MAX_XCRS 16 | 
|  | 317 | struct kvm_xcr { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 318 | __u32 xcr; | 
|  | 319 | __u32 reserved; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 320 | __u64 value; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 321 | }; | 
|  | 322 | struct kvm_xcrs { | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 323 | __u32 nr_xcrs; | 
| Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 324 | __u32 flags; | 
|  | 325 | struct kvm_xcr xcrs[KVM_MAX_XCRS]; | 
|  | 326 | __u64 padding[16]; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 327 | }; | 
| Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 328 | #define KVM_SYNC_X86_REGS (1UL << 0) | 
|  | 329 | #define KVM_SYNC_X86_SREGS (1UL << 1) | 
|  | 330 | #define KVM_SYNC_X86_EVENTS (1UL << 2) | 
|  | 331 | #define KVM_SYNC_X86_VALID_FIELDS (KVM_SYNC_X86_REGS | KVM_SYNC_X86_SREGS | KVM_SYNC_X86_EVENTS) | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 332 | struct kvm_sync_regs { | 
| Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 333 | struct kvm_regs regs; | 
|  | 334 | struct kvm_sregs sregs; | 
|  | 335 | struct kvm_vcpu_events events; | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 336 | }; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 337 | #define KVM_X86_QUIRK_LINT0_REENABLED (1 << 0) | 
|  | 338 | #define KVM_X86_QUIRK_CD_NW_CLEARED (1 << 1) | 
| Christopher Ferris | 9ce2884 | 2018-10-25 12:11:39 -0700 | [diff] [blame] | 339 | #define KVM_X86_QUIRK_LAPIC_MMIO_HOLE (1 << 2) | 
| Christopher Ferris | 24f97eb | 2019-05-20 12:58:13 -0700 | [diff] [blame] | 340 | #define KVM_X86_QUIRK_OUT_7E_INC_RIP (1 << 3) | 
| Christopher Ferris | b8a95e2 | 2019-10-02 18:29:20 -0700 | [diff] [blame] | 341 | #define KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT (1 << 4) | 
| Christopher Ferris | 80ae69d | 2022-08-02 16:32:21 -0700 | [diff] [blame] | 342 | #define KVM_X86_QUIRK_FIX_HYPERCALL_INSN (1 << 5) | 
| Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 343 | #define KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS (1 << 6) | 
| Christopher Ferris | aeddbcf | 2019-07-08 12:45:46 -0700 | [diff] [blame] | 344 | #define KVM_STATE_NESTED_FORMAT_VMX 0 | 
|  | 345 | #define KVM_STATE_NESTED_FORMAT_SVM 1 | 
| Christopher Ferris | 9ce2884 | 2018-10-25 12:11:39 -0700 | [diff] [blame] | 346 | #define KVM_STATE_NESTED_GUEST_MODE 0x00000001 | 
|  | 347 | #define KVM_STATE_NESTED_RUN_PENDING 0x00000002 | 
| Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 348 | #define KVM_STATE_NESTED_EVMCS 0x00000004 | 
| Christopher Ferris | bb9fcb4 | 2020-04-06 11:38:04 -0700 | [diff] [blame] | 349 | #define KVM_STATE_NESTED_MTF_PENDING 0x00000008 | 
| Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 350 | #define KVM_STATE_NESTED_GIF_SET 0x00000100 | 
| Christopher Ferris | 9ce2884 | 2018-10-25 12:11:39 -0700 | [diff] [blame] | 351 | #define KVM_STATE_NESTED_SMM_GUEST_MODE 0x00000001 | 
|  | 352 | #define KVM_STATE_NESTED_SMM_VMXON 0x00000002 | 
| Christopher Ferris | aeddbcf | 2019-07-08 12:45:46 -0700 | [diff] [blame] | 353 | #define KVM_STATE_NESTED_VMX_VMCS_SIZE 0x1000 | 
| Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 354 | #define KVM_STATE_NESTED_SVM_VMCB_SIZE 0x1000 | 
|  | 355 | #define KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE 0x00000001 | 
| Christopher Ferris | 7ac54f5 | 2024-08-07 21:07:12 +0000 | [diff] [blame] | 356 | #define KVM_X86_GRP_SYSTEM 0 | 
| Christopher Ferris | 1ed5534 | 2022-03-22 16:06:25 -0700 | [diff] [blame] | 357 | #define KVM_X86_XCOMP_GUEST_SUPP 0 | 
| Christopher Ferris | 7ac54f5 | 2024-08-07 21:07:12 +0000 | [diff] [blame] | 358 | #define KVM_X86_GRP_SEV 1 | 
|  | 359 | #define KVM_X86_SEV_VMSA_FEATURES 0 | 
| Christopher Ferris | aeddbcf | 2019-07-08 12:45:46 -0700 | [diff] [blame] | 360 | struct kvm_vmx_nested_state_data { | 
|  | 361 | __u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE]; | 
|  | 362 | __u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE]; | 
|  | 363 | }; | 
|  | 364 | struct kvm_vmx_nested_state_hdr { | 
| Christopher Ferris | 9ce2884 | 2018-10-25 12:11:39 -0700 | [diff] [blame] | 365 | __u64 vmxon_pa; | 
| Christopher Ferris | aeddbcf | 2019-07-08 12:45:46 -0700 | [diff] [blame] | 366 | __u64 vmcs12_pa; | 
| Christopher Ferris | 9ce2884 | 2018-10-25 12:11:39 -0700 | [diff] [blame] | 367 | struct { | 
|  | 368 | __u16 flags; | 
|  | 369 | } smm; | 
| Christopher Ferris | fcc3b4f | 2021-07-01 01:30:21 +0000 | [diff] [blame] | 370 | __u16 pad; | 
| Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 371 | __u32 flags; | 
|  | 372 | __u64 preemption_timer_deadline; | 
|  | 373 | }; | 
|  | 374 | struct kvm_svm_nested_state_data { | 
|  | 375 | __u8 vmcb12[KVM_STATE_NESTED_SVM_VMCB_SIZE]; | 
|  | 376 | }; | 
|  | 377 | struct kvm_svm_nested_state_hdr { | 
|  | 378 | __u64 vmcb_pa; | 
| Christopher Ferris | 9ce2884 | 2018-10-25 12:11:39 -0700 | [diff] [blame] | 379 | }; | 
|  | 380 | struct kvm_nested_state { | 
|  | 381 | __u16 flags; | 
|  | 382 | __u16 format; | 
|  | 383 | __u32 size; | 
|  | 384 | union { | 
| Christopher Ferris | aeddbcf | 2019-07-08 12:45:46 -0700 | [diff] [blame] | 385 | struct kvm_vmx_nested_state_hdr vmx; | 
| Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 386 | struct kvm_svm_nested_state_hdr svm; | 
| Christopher Ferris | 9ce2884 | 2018-10-25 12:11:39 -0700 | [diff] [blame] | 387 | __u8 pad[120]; | 
| Christopher Ferris | aeddbcf | 2019-07-08 12:45:46 -0700 | [diff] [blame] | 388 | } hdr; | 
|  | 389 | union { | 
| Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 390 | __DECLARE_FLEX_ARRAY(struct kvm_vmx_nested_state_data, vmx); | 
|  | 391 | __DECLARE_FLEX_ARRAY(struct kvm_svm_nested_state_data, svm); | 
| Christopher Ferris | aeddbcf | 2019-07-08 12:45:46 -0700 | [diff] [blame] | 392 | } data; | 
| Christopher Ferris | 9ce2884 | 2018-10-25 12:11:39 -0700 | [diff] [blame] | 393 | }; | 
| Christopher Ferris | b8a95e2 | 2019-10-02 18:29:20 -0700 | [diff] [blame] | 394 | struct kvm_pmu_event_filter { | 
|  | 395 | __u32 action; | 
|  | 396 | __u32 nevents; | 
|  | 397 | __u32 fixed_counter_bitmap; | 
|  | 398 | __u32 flags; | 
|  | 399 | __u32 pad[4]; | 
| Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 400 | __u64 events[]; | 
| Christopher Ferris | b8a95e2 | 2019-10-02 18:29:20 -0700 | [diff] [blame] | 401 | }; | 
|  | 402 | #define KVM_PMU_EVENT_ALLOW 0 | 
|  | 403 | #define KVM_PMU_EVENT_DENY 1 | 
| Christopher Ferris | 7f4c837 | 2024-06-03 14:22:19 -0700 | [diff] [blame] | 404 | #define KVM_PMU_EVENT_FLAG_MASKED_EVENTS _BITUL(0) | 
| Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 405 | #define KVM_PMU_EVENT_FLAGS_VALID_MASK (KVM_PMU_EVENT_FLAG_MASKED_EVENTS) | 
| Christopher Ferris | 7f4c837 | 2024-06-03 14:22:19 -0700 | [diff] [blame] | 406 | struct kvm_x86_mce { | 
|  | 407 | __u64 status; | 
|  | 408 | __u64 addr; | 
|  | 409 | __u64 misc; | 
|  | 410 | __u64 mcg_status; | 
|  | 411 | __u8 bank; | 
|  | 412 | __u8 pad1[7]; | 
|  | 413 | __u64 pad2[3]; | 
|  | 414 | }; | 
|  | 415 | #define KVM_XEN_HVM_CONFIG_HYPERCALL_MSR (1 << 0) | 
|  | 416 | #define KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL (1 << 1) | 
|  | 417 | #define KVM_XEN_HVM_CONFIG_SHARED_INFO (1 << 2) | 
|  | 418 | #define KVM_XEN_HVM_CONFIG_RUNSTATE (1 << 3) | 
|  | 419 | #define KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL (1 << 4) | 
|  | 420 | #define KVM_XEN_HVM_CONFIG_EVTCHN_SEND (1 << 5) | 
|  | 421 | #define KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG (1 << 6) | 
|  | 422 | #define KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE (1 << 7) | 
|  | 423 | #define KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA (1 << 8) | 
|  | 424 | struct kvm_xen_hvm_config { | 
|  | 425 | __u32 flags; | 
|  | 426 | __u32 msr; | 
|  | 427 | __u64 blob_addr_32; | 
|  | 428 | __u64 blob_addr_64; | 
|  | 429 | __u8 blob_size_32; | 
|  | 430 | __u8 blob_size_64; | 
|  | 431 | __u8 pad2[30]; | 
|  | 432 | }; | 
|  | 433 | struct kvm_xen_hvm_attr { | 
|  | 434 | __u16 type; | 
|  | 435 | __u16 pad[3]; | 
|  | 436 | union { | 
|  | 437 | __u8 long_mode; | 
|  | 438 | __u8 vector; | 
|  | 439 | __u8 runstate_update_flag; | 
|  | 440 | union { | 
|  | 441 | __u64 gfn; | 
|  | 442 | #define KVM_XEN_INVALID_GFN ((__u64) - 1) | 
|  | 443 | __u64 hva; | 
|  | 444 | } shared_info; | 
|  | 445 | struct { | 
|  | 446 | __u32 send_port; | 
|  | 447 | __u32 type; | 
|  | 448 | __u32 flags; | 
|  | 449 | #define KVM_XEN_EVTCHN_DEASSIGN (1 << 0) | 
|  | 450 | #define KVM_XEN_EVTCHN_UPDATE (1 << 1) | 
|  | 451 | #define KVM_XEN_EVTCHN_RESET (1 << 2) | 
|  | 452 | union { | 
|  | 453 | struct { | 
|  | 454 | __u32 port; | 
|  | 455 | __u32 vcpu; | 
|  | 456 | __u32 priority; | 
|  | 457 | } port; | 
|  | 458 | struct { | 
|  | 459 | __u32 port; | 
|  | 460 | __s32 fd; | 
|  | 461 | } eventfd; | 
|  | 462 | __u32 padding[4]; | 
|  | 463 | } deliver; | 
|  | 464 | } evtchn; | 
|  | 465 | __u32 xen_version; | 
|  | 466 | __u64 pad[8]; | 
|  | 467 | } u; | 
|  | 468 | }; | 
|  | 469 | #define KVM_XEN_ATTR_TYPE_LONG_MODE 0x0 | 
|  | 470 | #define KVM_XEN_ATTR_TYPE_SHARED_INFO 0x1 | 
|  | 471 | #define KVM_XEN_ATTR_TYPE_UPCALL_VECTOR 0x2 | 
|  | 472 | #define KVM_XEN_ATTR_TYPE_EVTCHN 0x3 | 
|  | 473 | #define KVM_XEN_ATTR_TYPE_XEN_VERSION 0x4 | 
|  | 474 | #define KVM_XEN_ATTR_TYPE_RUNSTATE_UPDATE_FLAG 0x5 | 
|  | 475 | #define KVM_XEN_ATTR_TYPE_SHARED_INFO_HVA 0x6 | 
|  | 476 | struct kvm_xen_vcpu_attr { | 
|  | 477 | __u16 type; | 
|  | 478 | __u16 pad[3]; | 
|  | 479 | union { | 
|  | 480 | __u64 gpa; | 
|  | 481 | #define KVM_XEN_INVALID_GPA ((__u64) - 1) | 
|  | 482 | __u64 hva; | 
|  | 483 | __u64 pad[8]; | 
|  | 484 | struct { | 
|  | 485 | __u64 state; | 
|  | 486 | __u64 state_entry_time; | 
|  | 487 | __u64 time_running; | 
|  | 488 | __u64 time_runnable; | 
|  | 489 | __u64 time_blocked; | 
|  | 490 | __u64 time_offline; | 
|  | 491 | } runstate; | 
|  | 492 | __u32 vcpu_id; | 
|  | 493 | struct { | 
|  | 494 | __u32 port; | 
|  | 495 | __u32 priority; | 
|  | 496 | __u64 expires_ns; | 
|  | 497 | } timer; | 
|  | 498 | __u8 vector; | 
|  | 499 | } u; | 
|  | 500 | }; | 
|  | 501 | #define KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO 0x0 | 
|  | 502 | #define KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO 0x1 | 
|  | 503 | #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR 0x2 | 
|  | 504 | #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT 0x3 | 
|  | 505 | #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA 0x4 | 
|  | 506 | #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST 0x5 | 
|  | 507 | #define KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID 0x6 | 
|  | 508 | #define KVM_XEN_VCPU_ATTR_TYPE_TIMER 0x7 | 
|  | 509 | #define KVM_XEN_VCPU_ATTR_TYPE_UPCALL_VECTOR 0x8 | 
|  | 510 | #define KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO_HVA 0x9 | 
|  | 511 | enum sev_cmd_id { | 
|  | 512 | KVM_SEV_INIT = 0, | 
|  | 513 | KVM_SEV_ES_INIT, | 
|  | 514 | KVM_SEV_LAUNCH_START, | 
|  | 515 | KVM_SEV_LAUNCH_UPDATE_DATA, | 
|  | 516 | KVM_SEV_LAUNCH_UPDATE_VMSA, | 
|  | 517 | KVM_SEV_LAUNCH_SECRET, | 
|  | 518 | KVM_SEV_LAUNCH_MEASURE, | 
|  | 519 | KVM_SEV_LAUNCH_FINISH, | 
|  | 520 | KVM_SEV_SEND_START, | 
|  | 521 | KVM_SEV_SEND_UPDATE_DATA, | 
|  | 522 | KVM_SEV_SEND_UPDATE_VMSA, | 
|  | 523 | KVM_SEV_SEND_FINISH, | 
|  | 524 | KVM_SEV_RECEIVE_START, | 
|  | 525 | KVM_SEV_RECEIVE_UPDATE_DATA, | 
|  | 526 | KVM_SEV_RECEIVE_UPDATE_VMSA, | 
|  | 527 | KVM_SEV_RECEIVE_FINISH, | 
|  | 528 | KVM_SEV_GUEST_STATUS, | 
|  | 529 | KVM_SEV_DBG_DECRYPT, | 
|  | 530 | KVM_SEV_DBG_ENCRYPT, | 
|  | 531 | KVM_SEV_CERT_EXPORT, | 
|  | 532 | KVM_SEV_GET_ATTESTATION_REPORT, | 
|  | 533 | KVM_SEV_SEND_CANCEL, | 
| Christopher Ferris | 7ac54f5 | 2024-08-07 21:07:12 +0000 | [diff] [blame] | 534 | KVM_SEV_INIT2, | 
| Christopher Ferris | 7f4c837 | 2024-06-03 14:22:19 -0700 | [diff] [blame] | 535 | KVM_SEV_NR_MAX, | 
|  | 536 | }; | 
|  | 537 | struct kvm_sev_cmd { | 
|  | 538 | __u32 id; | 
|  | 539 | __u32 pad0; | 
|  | 540 | __u64 data; | 
|  | 541 | __u32 error; | 
|  | 542 | __u32 sev_fd; | 
|  | 543 | }; | 
| Christopher Ferris | 7ac54f5 | 2024-08-07 21:07:12 +0000 | [diff] [blame] | 544 | struct kvm_sev_init { | 
|  | 545 | __u64 vmsa_features; | 
|  | 546 | __u32 flags; | 
|  | 547 | __u16 ghcb_version; | 
|  | 548 | __u16 pad1; | 
|  | 549 | __u32 pad2[8]; | 
|  | 550 | }; | 
| Christopher Ferris | 7f4c837 | 2024-06-03 14:22:19 -0700 | [diff] [blame] | 551 | struct kvm_sev_launch_start { | 
|  | 552 | __u32 handle; | 
|  | 553 | __u32 policy; | 
|  | 554 | __u64 dh_uaddr; | 
|  | 555 | __u32 dh_len; | 
|  | 556 | __u32 pad0; | 
|  | 557 | __u64 session_uaddr; | 
|  | 558 | __u32 session_len; | 
|  | 559 | __u32 pad1; | 
|  | 560 | }; | 
|  | 561 | struct kvm_sev_launch_update_data { | 
|  | 562 | __u64 uaddr; | 
|  | 563 | __u32 len; | 
|  | 564 | __u32 pad0; | 
|  | 565 | }; | 
|  | 566 | struct kvm_sev_launch_secret { | 
|  | 567 | __u64 hdr_uaddr; | 
|  | 568 | __u32 hdr_len; | 
|  | 569 | __u32 pad0; | 
|  | 570 | __u64 guest_uaddr; | 
|  | 571 | __u32 guest_len; | 
|  | 572 | __u32 pad1; | 
|  | 573 | __u64 trans_uaddr; | 
|  | 574 | __u32 trans_len; | 
|  | 575 | __u32 pad2; | 
|  | 576 | }; | 
|  | 577 | struct kvm_sev_launch_measure { | 
|  | 578 | __u64 uaddr; | 
|  | 579 | __u32 len; | 
|  | 580 | __u32 pad0; | 
|  | 581 | }; | 
|  | 582 | struct kvm_sev_guest_status { | 
|  | 583 | __u32 handle; | 
|  | 584 | __u32 policy; | 
|  | 585 | __u32 state; | 
|  | 586 | }; | 
|  | 587 | struct kvm_sev_dbg { | 
|  | 588 | __u64 src_uaddr; | 
|  | 589 | __u64 dst_uaddr; | 
|  | 590 | __u32 len; | 
|  | 591 | __u32 pad0; | 
|  | 592 | }; | 
|  | 593 | struct kvm_sev_attestation_report { | 
|  | 594 | __u8 mnonce[16]; | 
|  | 595 | __u64 uaddr; | 
|  | 596 | __u32 len; | 
|  | 597 | __u32 pad0; | 
|  | 598 | }; | 
|  | 599 | struct kvm_sev_send_start { | 
|  | 600 | __u32 policy; | 
|  | 601 | __u32 pad0; | 
|  | 602 | __u64 pdh_cert_uaddr; | 
|  | 603 | __u32 pdh_cert_len; | 
|  | 604 | __u32 pad1; | 
|  | 605 | __u64 plat_certs_uaddr; | 
|  | 606 | __u32 plat_certs_len; | 
|  | 607 | __u32 pad2; | 
|  | 608 | __u64 amd_certs_uaddr; | 
|  | 609 | __u32 amd_certs_len; | 
|  | 610 | __u32 pad3; | 
|  | 611 | __u64 session_uaddr; | 
|  | 612 | __u32 session_len; | 
|  | 613 | __u32 pad4; | 
|  | 614 | }; | 
|  | 615 | struct kvm_sev_send_update_data { | 
|  | 616 | __u64 hdr_uaddr; | 
|  | 617 | __u32 hdr_len; | 
|  | 618 | __u32 pad0; | 
|  | 619 | __u64 guest_uaddr; | 
|  | 620 | __u32 guest_len; | 
|  | 621 | __u32 pad1; | 
|  | 622 | __u64 trans_uaddr; | 
|  | 623 | __u32 trans_len; | 
|  | 624 | __u32 pad2; | 
|  | 625 | }; | 
|  | 626 | struct kvm_sev_receive_start { | 
|  | 627 | __u32 handle; | 
|  | 628 | __u32 policy; | 
|  | 629 | __u64 pdh_uaddr; | 
|  | 630 | __u32 pdh_len; | 
|  | 631 | __u32 pad0; | 
|  | 632 | __u64 session_uaddr; | 
|  | 633 | __u32 session_len; | 
|  | 634 | __u32 pad1; | 
|  | 635 | }; | 
|  | 636 | struct kvm_sev_receive_update_data { | 
|  | 637 | __u64 hdr_uaddr; | 
|  | 638 | __u32 hdr_len; | 
|  | 639 | __u32 pad0; | 
|  | 640 | __u64 guest_uaddr; | 
|  | 641 | __u32 guest_len; | 
|  | 642 | __u32 pad1; | 
|  | 643 | __u64 trans_uaddr; | 
|  | 644 | __u32 trans_len; | 
|  | 645 | __u32 pad2; | 
|  | 646 | }; | 
|  | 647 | #define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0) | 
|  | 648 | #define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1) | 
|  | 649 | struct kvm_hyperv_eventfd { | 
|  | 650 | __u32 conn_id; | 
|  | 651 | __s32 fd; | 
|  | 652 | __u32 flags; | 
|  | 653 | __u32 padding[3]; | 
|  | 654 | }; | 
|  | 655 | #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff | 
|  | 656 | #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0) | 
| Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 657 | #define KVM_PMU_ENCODE_MASKED_ENTRY(event_select,mask,match,exclude) (((event_select) & 0xFFULL) | (((event_select) & 0XF00ULL) << 24) | (((mask) & 0xFFULL) << 56) | (((match) & 0xFFULL) << 8) | ((__u64) (! ! (exclude)) << 55)) | 
| Christopher Ferris | 7f4c837 | 2024-06-03 14:22:19 -0700 | [diff] [blame] | 658 | #define KVM_PMU_MASKED_ENTRY_EVENT_SELECT (__GENMASK_ULL(7, 0) | __GENMASK_ULL(35, 32)) | 
|  | 659 | #define KVM_PMU_MASKED_ENTRY_UMASK_MASK (__GENMASK_ULL(63, 56)) | 
|  | 660 | #define KVM_PMU_MASKED_ENTRY_UMASK_MATCH (__GENMASK_ULL(15, 8)) | 
|  | 661 | #define KVM_PMU_MASKED_ENTRY_EXCLUDE (_BITULL(55)) | 
| Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 662 | #define KVM_PMU_MASKED_ENTRY_UMASK_MASK_SHIFT (56) | 
| Christopher Ferris | a479261 | 2022-01-10 13:51:15 -0800 | [diff] [blame] | 663 | #define KVM_VCPU_TSC_CTRL 0 | 
|  | 664 | #define KVM_VCPU_TSC_OFFSET 0 | 
| Christopher Ferris | 7f4c837 | 2024-06-03 14:22:19 -0700 | [diff] [blame] | 665 | #define KVM_EXIT_HYPERCALL_LONG_MODE _BITULL(0) | 
| Christopher Ferris | b830ddf | 2024-03-28 11:48:08 -0700 | [diff] [blame] | 666 | #define KVM_X86_DEFAULT_VM 0 | 
|  | 667 | #define KVM_X86_SW_PROTECTED_VM 1 | 
| Christopher Ferris | 7ac54f5 | 2024-08-07 21:07:12 +0000 | [diff] [blame] | 668 | #define KVM_X86_SEV_VM 2 | 
|  | 669 | #define KVM_X86_SEV_ES_VM 3 | 
| Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 670 | #endif |