Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools kvm headers: Update KVM headers from the kernel sources

Some should cause changes in tooling, like the one adding LAST_EXCP, but
the way it is structured end up not making that happen.

The new SVM_EXIT_INVPCID should get used by arch/x86/util/kvm-stat.c,
in the svm_exit_reasons table.

The tools/perf/trace/beauty part has scripts to catch changes and
automagically create tables, like tools/perf/trace/beauty/kvm_ioctl.sh,
but changes are needed to make tools/perf/arch/x86/util/kvm-stat.c catch
those automatically.

These were handled by the existing scripts:

$ tools/perf/trace/beauty/kvm_ioctl.sh > before
$ cp include/uapi/linux/kvm.h tools/include/uapi/linux/kvm.h
$ tools/perf/trace/beauty/kvm_ioctl.sh > after
$ diff -u before after
--- before 2020-11-03 08:43:52.910728608 -0300
+++ after 2020-11-03 08:44:04.273959984 -0300
@@ -89,6 +89,7 @@
[0xbf] = "SET_NESTED_STATE",
[0xc0] = "CLEAR_DIRTY_LOG",
[0xc1] = "GET_SUPPORTED_HV_CPUID",
+ [0xc6] = "X86_SET_MSR_FILTER",
[0xe0] = "CREATE_DEVICE",
[0xe1] = "SET_DEVICE_ATTR",
[0xe2] = "GET_DEVICE_ATTR",
$
$ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > before
$ cp include/uapi/linux/vhost.h tools/include/uapi/linux/vhost.h
$
$ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > after
$ diff -u before after
--- before 2020-11-03 08:45:55.522225198 -0300
+++ after 2020-11-03 08:46:12.881578666 -0300
@@ -37,4 +37,5 @@
[0x71] = "VDPA_GET_STATUS",
[0x73] = "VDPA_GET_CONFIG",
[0x76] = "VDPA_GET_VRING_NUM",
+ [0x78] = "VDPA_GET_IOVA_RANGE",
};
$

This addresses these perf build warnings:

Warning: Kernel ABI header at 'tools/arch/arm64/include/uapi/asm/kvm.h' differs from latest version at 'arch/arm64/include/uapi/asm/kvm.h'
diff -u tools/arch/arm64/include/uapi/asm/kvm.h arch/arm64/include/uapi/asm/kvm.h
Warning: Kernel ABI header at 'tools/arch/s390/include/uapi/asm/sie.h' differs from latest version at 'arch/s390/include/uapi/asm/sie.h'
diff -u tools/arch/s390/include/uapi/asm/sie.h arch/s390/include/uapi/asm/sie.h
Warning: Kernel ABI header at 'tools/arch/x86/include/uapi/asm/kvm.h' differs from latest version at 'arch/x86/include/uapi/asm/kvm.h'
diff -u tools/arch/x86/include/uapi/asm/kvm.h arch/x86/include/uapi/asm/kvm.h
Warning: Kernel ABI header at 'tools/arch/x86/include/uapi/asm/svm.h' differs from latest version at 'arch/x86/include/uapi/asm/svm.h'
diff -u tools/arch/x86/include/uapi/asm/svm.h arch/x86/include/uapi/asm/svm.h
Warning: Kernel ABI header at 'tools/include/uapi/linux/kvm.h' differs from latest version at 'include/uapi/linux/kvm.h'
diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
Warning: Kernel ABI header at 'tools/include/uapi/linux/vhost.h' differs from latest version at 'include/uapi/linux/vhost.h'
diff -u tools/include/uapi/linux/vhost.h include/uapi/linux/vhost.h

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Joerg Roedel <jroedel@suse.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+82 -1
+25
tools/arch/arm64/include/uapi/asm/kvm.h
··· 159 159 struct kvm_arch_memory_slot { 160 160 }; 161 161 162 + /* 163 + * PMU filter structure. Describe a range of events with a particular 164 + * action. To be used with KVM_ARM_VCPU_PMU_V3_FILTER. 165 + */ 166 + struct kvm_pmu_event_filter { 167 + __u16 base_event; 168 + __u16 nevents; 169 + 170 + #define KVM_PMU_EVENT_ALLOW 0 171 + #define KVM_PMU_EVENT_DENY 1 172 + 173 + __u8 action; 174 + __u8 pad[3]; 175 + }; 176 + 162 177 /* for KVM_GET/SET_VCPU_EVENTS */ 163 178 struct kvm_vcpu_events { 164 179 struct { ··· 257 242 #define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_AVAIL 0 258 243 #define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_AVAIL 1 259 244 #define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_REQUIRED 2 245 + 246 + /* 247 + * Only two states can be presented by the host kernel: 248 + * - NOT_REQUIRED: the guest doesn't need to do anything 249 + * - NOT_AVAIL: the guest isn't mitigated (it can still use SSBS if available) 250 + * 251 + * All the other values are deprecated. The host still accepts all 252 + * values (they are ABI), but will narrow them to the above two. 253 + */ 260 254 #define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2 KVM_REG_ARM_FW_REG(2) 261 255 #define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_AVAIL 0 262 256 #define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_UNKNOWN 1 ··· 353 329 #define KVM_ARM_VCPU_PMU_V3_CTRL 0 354 330 #define KVM_ARM_VCPU_PMU_V3_IRQ 0 355 331 #define KVM_ARM_VCPU_PMU_V3_INIT 1 332 + #define KVM_ARM_VCPU_PMU_V3_FILTER 2 356 333 #define KVM_ARM_VCPU_TIMER_CTRL 1 357 334 #define KVM_ARM_VCPU_TIMER_IRQ_VTIMER 0 358 335 #define KVM_ARM_VCPU_TIMER_IRQ_PTIMER 1
+1 -1
tools/arch/s390/include/uapi/asm/sie.h
··· 29 29 { 0x13, "SIGP conditional emergency signal" }, \ 30 30 { 0x15, "SIGP sense running" }, \ 31 31 { 0x16, "SIGP set multithreading"}, \ 32 - { 0x17, "SIGP store additional status ait address"} 32 + { 0x17, "SIGP store additional status at address"} 33 33 34 34 #define icpt_prog_codes \ 35 35 { 0x0001, "Prog Operation" }, \
+20
tools/arch/x86/include/uapi/asm/kvm.h
··· 192 192 __u32 indices[0]; 193 193 }; 194 194 195 + /* Maximum size of any access bitmap in bytes */ 196 + #define KVM_MSR_FILTER_MAX_BITMAP_SIZE 0x600 197 + 198 + /* for KVM_X86_SET_MSR_FILTER */ 199 + struct kvm_msr_filter_range { 200 + #define KVM_MSR_FILTER_READ (1 << 0) 201 + #define KVM_MSR_FILTER_WRITE (1 << 1) 202 + __u32 flags; 203 + __u32 nmsrs; /* number of msrs in bitmap */ 204 + __u32 base; /* MSR index the bitmap starts at */ 205 + __u8 *bitmap; /* a 1 bit allows the operations in flags, 0 denies */ 206 + }; 207 + 208 + #define KVM_MSR_FILTER_MAX_RANGES 16 209 + struct kvm_msr_filter { 210 + #define KVM_MSR_FILTER_DEFAULT_ALLOW (0 << 0) 211 + #define KVM_MSR_FILTER_DEFAULT_DENY (1 << 0) 212 + __u32 flags; 213 + struct kvm_msr_filter_range ranges[KVM_MSR_FILTER_MAX_RANGES]; 214 + }; 195 215 196 216 struct kvm_cpuid_entry { 197 217 __u32 function;
+13
tools/arch/x86/include/uapi/asm/svm.h
··· 29 29 #define SVM_EXIT_WRITE_DR6 0x036 30 30 #define SVM_EXIT_WRITE_DR7 0x037 31 31 #define SVM_EXIT_EXCP_BASE 0x040 32 + #define SVM_EXIT_LAST_EXCP 0x05f 32 33 #define SVM_EXIT_INTR 0x060 33 34 #define SVM_EXIT_NMI 0x061 34 35 #define SVM_EXIT_SMI 0x062 ··· 77 76 #define SVM_EXIT_MWAIT_COND 0x08c 78 77 #define SVM_EXIT_XSETBV 0x08d 79 78 #define SVM_EXIT_RDPRU 0x08e 79 + #define SVM_EXIT_INVPCID 0x0a2 80 80 #define SVM_EXIT_NPF 0x400 81 81 #define SVM_EXIT_AVIC_INCOMPLETE_IPI 0x401 82 82 #define SVM_EXIT_AVIC_UNACCELERATED_ACCESS 0x402 83 + 84 + /* SEV-ES software-defined VMGEXIT events */ 85 + #define SVM_VMGEXIT_MMIO_READ 0x80000001 86 + #define SVM_VMGEXIT_MMIO_WRITE 0x80000002 87 + #define SVM_VMGEXIT_NMI_COMPLETE 0x80000003 88 + #define SVM_VMGEXIT_AP_HLT_LOOP 0x80000004 89 + #define SVM_VMGEXIT_AP_JUMP_TABLE 0x80000005 90 + #define SVM_VMGEXIT_SET_AP_JUMP_TABLE 0 91 + #define SVM_VMGEXIT_GET_AP_JUMP_TABLE 1 92 + #define SVM_VMGEXIT_UNSUPPORTED_EVENT 0x8000ffff 83 93 84 94 #define SVM_EXIT_ERR -1 85 95 ··· 183 171 { SVM_EXIT_MONITOR, "monitor" }, \ 184 172 { SVM_EXIT_MWAIT, "mwait" }, \ 185 173 { SVM_EXIT_XSETBV, "xsetbv" }, \ 174 + { SVM_EXIT_INVPCID, "invpcid" }, \ 186 175 { SVM_EXIT_NPF, "npf" }, \ 187 176 { SVM_EXIT_AVIC_INCOMPLETE_IPI, "avic_incomplete_ipi" }, \ 188 177 { SVM_EXIT_AVIC_UNACCELERATED_ACCESS, "avic_unaccelerated_access" }, \
+19
tools/include/uapi/linux/kvm.h
··· 248 248 #define KVM_EXIT_IOAPIC_EOI 26 249 249 #define KVM_EXIT_HYPERV 27 250 250 #define KVM_EXIT_ARM_NISV 28 251 + #define KVM_EXIT_X86_RDMSR 29 252 + #define KVM_EXIT_X86_WRMSR 30 251 253 252 254 /* For KVM_EXIT_INTERNAL_ERROR */ 253 255 /* Emulate instruction failed. */ ··· 415 413 __u64 esr_iss; 416 414 __u64 fault_ipa; 417 415 } arm_nisv; 416 + /* KVM_EXIT_X86_RDMSR / KVM_EXIT_X86_WRMSR */ 417 + struct { 418 + __u8 error; /* user -> kernel */ 419 + __u8 pad[7]; 420 + #define KVM_MSR_EXIT_REASON_INVAL (1 << 0) 421 + #define KVM_MSR_EXIT_REASON_UNKNOWN (1 << 1) 422 + #define KVM_MSR_EXIT_REASON_FILTER (1 << 2) 423 + __u32 reason; /* kernel -> user */ 424 + __u32 index; /* kernel -> user */ 425 + __u64 data; /* kernel <-> user */ 426 + } msr; 418 427 /* Fix the size of the union. */ 419 428 char padding[256]; 420 429 }; ··· 1050 1037 #define KVM_CAP_SMALLER_MAXPHYADDR 185 1051 1038 #define KVM_CAP_S390_DIAG318 186 1052 1039 #define KVM_CAP_STEAL_TIME 187 1040 + #define KVM_CAP_X86_USER_SPACE_MSR 188 1041 + #define KVM_CAP_X86_MSR_FILTER 189 1042 + #define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 190 1053 1043 1054 1044 #ifdef KVM_CAP_IRQ_ROUTING 1055 1045 ··· 1553 1537 1554 1538 /* Available with KVM_CAP_S390_PROTECTED */ 1555 1539 #define KVM_S390_PV_COMMAND _IOWR(KVMIO, 0xc5, struct kvm_pv_cmd) 1540 + 1541 + /* Available with KVM_CAP_X86_MSR_FILTER */ 1542 + #define KVM_X86_SET_MSR_FILTER _IOW(KVMIO, 0xc6, struct kvm_msr_filter) 1556 1543 1557 1544 /* Secure Encrypted Virtualization command */ 1558 1545 enum sev_cmd_id {
+4
tools/include/uapi/linux/vhost.h
··· 146 146 147 147 /* Set event fd for config interrupt*/ 148 148 #define VHOST_VDPA_SET_CONFIG_CALL _IOW(VHOST_VIRTIO, 0x77, int) 149 + 150 + /* Get the valid iova range */ 151 + #define VHOST_VDPA_GET_IOVA_RANGE _IOR(VHOST_VIRTIO, 0x78, \ 152 + struct vhost_vdpa_iova_range) 149 153 #endif