Skip to content

Commit e30dca9

Browse files
committed
tools headers UAPI: Sync kvm headers with the kernel sources
To pick the changes in: a5d3df8 ("KVM: remove deprecated UAPIs") 6d72283 ("KVM x86/xen: add an override for PVCLOCK_TSC_STABLE_BIT") 89ea60c ("KVM: x86: Add support for "protected VMs" that can utilize private memory") 8dd2eee ("KVM: x86/mmu: Handle page fault for private memory") a7800aa ("KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory") 5a47555 ("KVM: Introduce per-page memory attributes") 16f95f3 ("KVM: Add KVM_EXIT_MEMORY_FAULT exit to report faults to userspace") bb58b90 ("KVM: Introduce KVM_SET_USER_MEMORY_REGION2") 3f9cd0c ("KVM: arm64: Allow userspace to get the writable masks for feature ID registers") That automatically adds support for some new ioctls and remove a bunch of deprecated ones. This ends up making the new binary to forget about the deprecated one, so when used in an older system it will not be able to resolve those codes to strings. $ 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 2024-01-27 14:48:16.523014020 -0300 +++ after 2024-01-27 14:48:24.183932866 -0300 @@ -14,6 +14,7 @@ [0x46] = "SET_USER_MEMORY_REGION", [0x47] = "SET_TSS_ADDR", [0x48] = "SET_IDENTITY_MAP_ADDR", + [0x49] = "SET_USER_MEMORY_REGION2", [0x60] = "CREATE_IRQCHIP", [0x61] = "IRQ_LINE", [0x62] = "GET_IRQCHIP", @@ -22,14 +23,8 @@ [0x65] = "GET_PIT", [0x66] = "SET_PIT", [0x67] = "IRQ_LINE_STATUS", - [0x69] = "ASSIGN_PCI_DEVICE", [0x6a] = "SET_GSI_ROUTING", - [0x70] = "ASSIGN_DEV_IRQ", [0x71] = "REINJECT_CONTROL", - [0x72] = "DEASSIGN_PCI_DEVICE", - [0x73] = "ASSIGN_SET_MSIX_NR", - [0x74] = "ASSIGN_SET_MSIX_ENTRY", - [0x75] = "DEASSIGN_DEV_IRQ", [0x76] = "IRQFD", [0x77] = "CREATE_PIT2", [0x78] = "SET_BOOT_CPU_ID", @@ -66,7 +61,6 @@ [0x9f] = "GET_VCPU_EVENTS", [0xa0] = "SET_VCPU_EVENTS", [0xa3] = "ENABLE_CAP", - [0xa4] = "ASSIGN_SET_INTX_MASK", [0xa5] = "SIGNAL_MSI", [0xa6] = "GET_XCRS", [0xa7] = "SET_XCRS", @@ -97,6 +91,8 @@ [0xcd] = "SET_SREGS2", [0xce] = "GET_STATS_FD", [0xd0] = "XEN_HVM_EVTCHN_SEND", + [0xd2] = "SET_MEMORY_ATTRIBUTES", + [0xd4] = "CREATE_GUEST_MEMFD", [0xe0] = "CREATE_DEVICE", [0xe1] = "SET_DEVICE_ATTR", [0xe2] = "GET_DEVICE_ATTR", $ This silences these perf build warnings: Warning: Kernel ABI header differences: diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h diff -u tools/arch/x86/include/uapi/asm/kvm.h arch/x86/include/uapi/asm/kvm.h Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Chao Peng <chao.p.peng@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Jing Zhang <jingzhangos@google.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Oliver Upton <oliver.upton@linux.dev> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Paul Durrant <pdurrant@amazon.com> Cc: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/lkml/ZbVLbkngp4oq13qN@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 7bbe8f0 commit e30dca9

File tree

2 files changed

+53
-90
lines changed
  • tools
    • arch/x86/include/uapi/asm
    • include/uapi/linux

2 files changed

+53
-90
lines changed

tools/arch/x86/include/uapi/asm/kvm.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,4 +562,7 @@ struct kvm_pmu_event_filter {
562562
/* x86-specific KVM_EXIT_HYPERCALL flags. */
563563
#define KVM_EXIT_HYPERCALL_LONG_MODE BIT(0)
564564

565+
#define KVM_X86_DEFAULT_VM 0
566+
#define KVM_X86_SW_PROTECTED_VM 1
567+
565568
#endif /* _ASM_X86_KVM_H */

tools/include/uapi/linux/kvm.h

Lines changed: 50 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -16,76 +16,6 @@
1616

1717
#define KVM_API_VERSION 12
1818

19-
/* *** Deprecated interfaces *** */
20-
21-
#define KVM_TRC_SHIFT 16
22-
23-
#define KVM_TRC_ENTRYEXIT (1 << KVM_TRC_SHIFT)
24-
#define KVM_TRC_HANDLER (1 << (KVM_TRC_SHIFT + 1))
25-
26-
#define KVM_TRC_VMENTRY (KVM_TRC_ENTRYEXIT + 0x01)
27-
#define KVM_TRC_VMEXIT (KVM_TRC_ENTRYEXIT + 0x02)
28-
#define KVM_TRC_PAGE_FAULT (KVM_TRC_HANDLER + 0x01)
29-
30-
#define KVM_TRC_HEAD_SIZE 12
31-
#define KVM_TRC_CYCLE_SIZE 8
32-
#define KVM_TRC_EXTRA_MAX 7
33-
34-
#define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02)
35-
#define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03)
36-
#define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04)
37-
#define KVM_TRC_IO_READ (KVM_TRC_HANDLER + 0x05)
38-
#define KVM_TRC_IO_WRITE (KVM_TRC_HANDLER + 0x06)
39-
#define KVM_TRC_CR_READ (KVM_TRC_HANDLER + 0x07)
40-
#define KVM_TRC_CR_WRITE (KVM_TRC_HANDLER + 0x08)
41-
#define KVM_TRC_DR_READ (KVM_TRC_HANDLER + 0x09)
42-
#define KVM_TRC_DR_WRITE (KVM_TRC_HANDLER + 0x0A)
43-
#define KVM_TRC_MSR_READ (KVM_TRC_HANDLER + 0x0B)
44-
#define KVM_TRC_MSR_WRITE (KVM_TRC_HANDLER + 0x0C)
45-
#define KVM_TRC_CPUID (KVM_TRC_HANDLER + 0x0D)
46-
#define KVM_TRC_INTR (KVM_TRC_HANDLER + 0x0E)
47-
#define KVM_TRC_NMI (KVM_TRC_HANDLER + 0x0F)
48-
#define KVM_TRC_VMMCALL (KVM_TRC_HANDLER + 0x10)
49-
#define KVM_TRC_HLT (KVM_TRC_HANDLER + 0x11)
50-
#define KVM_TRC_CLTS (KVM_TRC_HANDLER + 0x12)
51-
#define KVM_TRC_LMSW (KVM_TRC_HANDLER + 0x13)
52-
#define KVM_TRC_APIC_ACCESS (KVM_TRC_HANDLER + 0x14)
53-
#define KVM_TRC_TDP_FAULT (KVM_TRC_HANDLER + 0x15)
54-
#define KVM_TRC_GTLB_WRITE (KVM_TRC_HANDLER + 0x16)
55-
#define KVM_TRC_STLB_WRITE (KVM_TRC_HANDLER + 0x17)
56-
#define KVM_TRC_STLB_INVAL (KVM_TRC_HANDLER + 0x18)
57-
#define KVM_TRC_PPC_INSTR (KVM_TRC_HANDLER + 0x19)
58-
59-
struct kvm_user_trace_setup {
60-
__u32 buf_size;
61-
__u32 buf_nr;
62-
};
63-
64-
#define __KVM_DEPRECATED_MAIN_W_0x06 \
65-
_IOW(KVMIO, 0x06, struct kvm_user_trace_setup)
66-
#define __KVM_DEPRECATED_MAIN_0x07 _IO(KVMIO, 0x07)
67-
#define __KVM_DEPRECATED_MAIN_0x08 _IO(KVMIO, 0x08)
68-
69-
#define __KVM_DEPRECATED_VM_R_0x70 _IOR(KVMIO, 0x70, struct kvm_assigned_irq)
70-
71-
struct kvm_breakpoint {
72-
__u32 enabled;
73-
__u32 padding;
74-
__u64 address;
75-
};
76-
77-
struct kvm_debug_guest {
78-
__u32 enabled;
79-
__u32 pad;
80-
struct kvm_breakpoint breakpoints[4];
81-
__u32 singlestep;
82-
};
83-
84-
#define __KVM_DEPRECATED_VCPU_W_0x87 _IOW(KVMIO, 0x87, struct kvm_debug_guest)
85-
86-
/* *** End of deprecated interfaces *** */
87-
88-
8919
/* for KVM_SET_USER_MEMORY_REGION */
9020
struct kvm_userspace_memory_region {
9121
__u32 slot;
@@ -95,13 +25,27 @@ struct kvm_userspace_memory_region {
9525
__u64 userspace_addr; /* start of the userspace allocated memory */
9626
};
9727

28+
/* for KVM_SET_USER_MEMORY_REGION2 */
29+
struct kvm_userspace_memory_region2 {
30+
__u32 slot;
31+
__u32 flags;
32+
__u64 guest_phys_addr;
33+
__u64 memory_size;
34+
__u64 userspace_addr;
35+
__u64 guest_memfd_offset;
36+
__u32 guest_memfd;
37+
__u32 pad1;
38+
__u64 pad2[14];
39+
};
40+
9841
/*
9942
* The bit 0 ~ bit 15 of kvm_userspace_memory_region::flags are visible for
10043
* userspace, other bits are reserved for kvm internal use which are defined
10144
* in include/linux/kvm_host.h.
10245
*/
10346
#define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0)
10447
#define KVM_MEM_READONLY (1UL << 1)
48+
#define KVM_MEM_GUEST_MEMFD (1UL << 2)
10549

10650
/* for KVM_IRQ_LINE */
10751
struct kvm_irq_level {
@@ -265,6 +209,7 @@ struct kvm_xen_exit {
265209
#define KVM_EXIT_RISCV_CSR 36
266210
#define KVM_EXIT_NOTIFY 37
267211
#define KVM_EXIT_LOONGARCH_IOCSR 38
212+
#define KVM_EXIT_MEMORY_FAULT 39
268213

269214
/* For KVM_EXIT_INTERNAL_ERROR */
270215
/* Emulate instruction failed. */
@@ -518,6 +463,13 @@ struct kvm_run {
518463
#define KVM_NOTIFY_CONTEXT_INVALID (1 << 0)
519464
__u32 flags;
520465
} notify;
466+
/* KVM_EXIT_MEMORY_FAULT */
467+
struct {
468+
#define KVM_MEMORY_EXIT_FLAG_PRIVATE (1ULL << 3)
469+
__u64 flags;
470+
__u64 gpa;
471+
__u64 size;
472+
} memory_fault;
521473
/* Fix the size of the union. */
522474
char padding[256];
523475
};
@@ -945,9 +897,6 @@ struct kvm_ppc_resize_hpt {
945897
*/
946898
#define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */
947899
#define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2)
948-
#define KVM_TRACE_ENABLE __KVM_DEPRECATED_MAIN_W_0x06
949-
#define KVM_TRACE_PAUSE __KVM_DEPRECATED_MAIN_0x07
950-
#define KVM_TRACE_DISABLE __KVM_DEPRECATED_MAIN_0x08
951900
#define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2)
952901
#define KVM_GET_MSR_FEATURE_INDEX_LIST _IOWR(KVMIO, 0x0a, struct kvm_msr_list)
953902

@@ -1201,6 +1150,11 @@ struct kvm_ppc_resize_hpt {
12011150
#define KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE 228
12021151
#define KVM_CAP_ARM_SUPPORTED_BLOCK_SIZES 229
12031152
#define KVM_CAP_ARM_SUPPORTED_REG_MASK_RANGES 230
1153+
#define KVM_CAP_USER_MEMORY2 231
1154+
#define KVM_CAP_MEMORY_FAULT_INFO 232
1155+
#define KVM_CAP_MEMORY_ATTRIBUTES 233
1156+
#define KVM_CAP_GUEST_MEMFD 234
1157+
#define KVM_CAP_VM_TYPES 235
12041158

12051159
#ifdef KVM_CAP_IRQ_ROUTING
12061160

@@ -1291,6 +1245,7 @@ struct kvm_x86_mce {
12911245
#define KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL (1 << 4)
12921246
#define KVM_XEN_HVM_CONFIG_EVTCHN_SEND (1 << 5)
12931247
#define KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG (1 << 6)
1248+
#define KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE (1 << 7)
12941249

12951250
struct kvm_xen_hvm_config {
12961251
__u32 flags;
@@ -1483,6 +1438,8 @@ struct kvm_vfio_spapr_tce {
14831438
struct kvm_userspace_memory_region)
14841439
#define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47)
14851440
#define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64)
1441+
#define KVM_SET_USER_MEMORY_REGION2 _IOW(KVMIO, 0x49, \
1442+
struct kvm_userspace_memory_region2)
14861443

14871444
/* enable ucontrol for s390 */
14881445
struct kvm_s390_ucas_mapping {
@@ -1507,20 +1464,8 @@ struct kvm_s390_ucas_mapping {
15071464
_IOW(KVMIO, 0x67, struct kvm_coalesced_mmio_zone)
15081465
#define KVM_UNREGISTER_COALESCED_MMIO \
15091466
_IOW(KVMIO, 0x68, struct kvm_coalesced_mmio_zone)
1510-
#define KVM_ASSIGN_PCI_DEVICE _IOR(KVMIO, 0x69, \
1511-
struct kvm_assigned_pci_dev)
15121467
#define KVM_SET_GSI_ROUTING _IOW(KVMIO, 0x6a, struct kvm_irq_routing)
1513-
/* deprecated, replaced by KVM_ASSIGN_DEV_IRQ */
1514-
#define KVM_ASSIGN_IRQ __KVM_DEPRECATED_VM_R_0x70
1515-
#define KVM_ASSIGN_DEV_IRQ _IOW(KVMIO, 0x70, struct kvm_assigned_irq)
15161468
#define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71)
1517-
#define KVM_DEASSIGN_PCI_DEVICE _IOW(KVMIO, 0x72, \
1518-
struct kvm_assigned_pci_dev)
1519-
#define KVM_ASSIGN_SET_MSIX_NR _IOW(KVMIO, 0x73, \
1520-
struct kvm_assigned_msix_nr)
1521-
#define KVM_ASSIGN_SET_MSIX_ENTRY _IOW(KVMIO, 0x74, \
1522-
struct kvm_assigned_msix_entry)
1523-
#define KVM_DEASSIGN_DEV_IRQ _IOW(KVMIO, 0x75, struct kvm_assigned_irq)
15241469
#define KVM_IRQFD _IOW(KVMIO, 0x76, struct kvm_irqfd)
15251470
#define KVM_CREATE_PIT2 _IOW(KVMIO, 0x77, struct kvm_pit_config)
15261471
#define KVM_SET_BOOT_CPU_ID _IO(KVMIO, 0x78)
@@ -1537,9 +1482,6 @@ struct kvm_s390_ucas_mapping {
15371482
* KVM_CAP_VM_TSC_CONTROL to set defaults for a VM */
15381483
#define KVM_SET_TSC_KHZ _IO(KVMIO, 0xa2)
15391484
#define KVM_GET_TSC_KHZ _IO(KVMIO, 0xa3)
1540-
/* Available with KVM_CAP_PCI_2_3 */
1541-
#define KVM_ASSIGN_SET_INTX_MASK _IOW(KVMIO, 0xa4, \
1542-
struct kvm_assigned_pci_dev)
15431485
/* Available with KVM_CAP_SIGNAL_MSI */
15441486
#define KVM_SIGNAL_MSI _IOW(KVMIO, 0xa5, struct kvm_msi)
15451487
/* Available with KVM_CAP_PPC_GET_SMMU_INFO */
@@ -1592,8 +1534,6 @@ struct kvm_s390_ucas_mapping {
15921534
#define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs)
15931535
#define KVM_TRANSLATE _IOWR(KVMIO, 0x85, struct kvm_translation)
15941536
#define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt)
1595-
/* KVM_DEBUG_GUEST is no longer supported, use KVM_SET_GUEST_DEBUG instead */
1596-
#define KVM_DEBUG_GUEST __KVM_DEPRECATED_VCPU_W_0x87
15971537
#define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs)
15981538
#define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs)
15991539
#define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid)
@@ -2267,4 +2207,24 @@ struct kvm_s390_zpci_op {
22672207
/* flags for kvm_s390_zpci_op->u.reg_aen.flags */
22682208
#define KVM_S390_ZPCIOP_REGAEN_HOST (1 << 0)
22692209

2210+
/* Available with KVM_CAP_MEMORY_ATTRIBUTES */
2211+
#define KVM_SET_MEMORY_ATTRIBUTES _IOW(KVMIO, 0xd2, struct kvm_memory_attributes)
2212+
2213+
struct kvm_memory_attributes {
2214+
__u64 address;
2215+
__u64 size;
2216+
__u64 attributes;
2217+
__u64 flags;
2218+
};
2219+
2220+
#define KVM_MEMORY_ATTRIBUTE_PRIVATE (1ULL << 3)
2221+
2222+
#define KVM_CREATE_GUEST_MEMFD _IOWR(KVMIO, 0xd4, struct kvm_create_guest_memfd)
2223+
2224+
struct kvm_create_guest_memfd {
2225+
__u64 size;
2226+
__u64 flags;
2227+
__u64 reserved[6];
2228+
};
2229+
22702230
#endif /* __LINUX_KVM_H */

0 commit comments

Comments
 (0)