KVM: cleanup linux/kvm.h
Paolo Bonzini
maintainercover KVM: cleanup linux/kvm.h
More cleanups of KVM's main header:
* remove thoroughly obsolete APIs
* move architecture-dependent stuff to uapi/asm/kvm.h
* small cleanups to __KVM_HAVE_* symbols
Paolo
Paolo Bonzini (8):
KVM: remove more traces of device assignment UAPI
KVM: x86: move x86-specific structs to uapi/asm/kvm.h
KVM: powerpc: move powerpc-specific structs to uapi/asm/kvm.h
KVM: s390: move s390-specific structs to uapi/asm/kvm.h
KVM: arm64: move ARM-specific defines to uapi/asm/kvm.h
kvm: replace __KVM_HAVE_READONLY_MEM with Kconfig symbol
KVM: define __KVM_HAVE_GUEST_DEBUG unconditionally
KVM: remove unnecessary #ifdef
arch/arm64/include/uapi/asm/kvm.h | 7 +- arch/arm64/kvm/Kconfig | 1 + arch/loongarch/include/uapi/asm/kvm.h | 2 - arch/loongarch/kvm/Kconfig | 1 + arch/mips/include/uapi/asm/kvm.h | 2 - arch/mips/kvm/Kconfig | 1 + arch/powerpc/include/uapi/asm/kvm.h | 45 +- arch/riscv/include/uapi/asm/kvm.h | 1 - arch/riscv/kvm/Kconfig | 1 + arch/s390/include/uapi/asm/kvm.h | 315 +++++++++++- arch/x86/include/uapi/asm/kvm.h | 264 +++++++++- arch/x86/kvm/Kconfig | 1 + include/uapi/linux/kvm.h | 692 +------------------------- virt/kvm/Kconfig | 3 + virt/kvm/kvm_main.c | 2 +- 15 files changed, 642 insertions(+), 696 deletions(-)
Signature · 1 line
2.39.0
Paolo Bonzini
maintainerPATCH 1/8 KVM: remove more traces of device assignment UAPI
--- include/uapi/linux/kvm.h | 50 ---------------------------------------- 1 file changed, 50 deletions(-)
include/uapi/linux/kvm.h +0 -50
@@ -1965,56 +1965,6 @@ struct kvm_sev_receive_update_data {__u32 trans_len; }; -#define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) -#define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) -#define KVM_DEV_ASSIGN_MASK_INTX (1 << 2) - -struct kvm_assigned_pci_dev { -__u32 assigned_dev_id; -__u32 busnr; -__u32 devfn; -__u32 flags; -__u32 segnr; -union { -__u32 reserved[11 ]; - }; -}; - -#define KVM_DEV_IRQ_HOST_INTX (1 << 0) -#define KVM_DEV_IRQ_HOST_MSI (1 << 1) -#define KVM_DEV_IRQ_HOST_MSIX (1 << 2) - -#define KVM_DEV_IRQ_GUEST_INTX (1 << 8) -#define KVM_DEV_IRQ_GUEST_MSI (1 << 9) -#define KVM_DEV_IRQ_GUEST_MSIX (1 << 10) - -#define KVM_DEV_IRQ_HOST_MASK 0x00ff -#define KVM_DEV_IRQ_GUEST_MASK 0xff00 - -struct kvm_assigned_irq { -__u32 assigned_dev_id; -__u32 host_irq;/* ignored (legacy field) */ -__u32 guest_irq; -__u32 flags; -union { -__u32 reserved[12 ]; - }; -}; - -struct kvm_assigned_msix_nr { -__u32 assigned_dev_id; -__u16 entry_nr; -__u16 padding; -}; - -#define KVM_MAX_MSIX_PER_DEV 256 -struct kvm_assigned_msix_entry { -__u32 assigned_dev_id; -__u32 gsi; -__u16 entry;/* The index of entry in the MSI-X table */ -__u16 padding[3 ]; -}; -#define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)#define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1)
Signature · 1 line
2.39.0
Paolo Bonzini
maintainerPATCH 2/8 KVM: x86: move x86-specific structs to uapi/asm/kvm.h
In reply to Paolo BonziniSeveral capabilities that exist only on x86 nevertheless have their structs defined in include/uapi/linux/kvm.h. Move them to arch/x86/include/uapi/asm/kvm.h for cleanliness.
--- arch/x86/include/uapi/asm/kvm.h | 262 +++++++++++++++++++++++++++++++ include/uapi/linux/kvm.h | 265 -------------------------------- 2 files changed, 262 insertions(+), 265 deletions(-)
arch/x86/include/uapi/asm/kvm.h +262 -0
@@ -531,6 +531,268 @@ struct kvm_pmu_event_filter {#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS _BITUL(0)#define KVM_PMU_EVENT_FLAGS_VALID_MASK (KVM_PMU_EVENT_FLAG_MASKED_EVENTS) +/* for KVM_CAP_MCE */ +struct kvm_x86_mce { +__u64 status; +__u64 addr; +__u64 misc; +__u64 mcg_status; +__u8 bank; +__u8 pad1[7 ]; +__u64 pad2[3 ]; +}; + +/* for KVM_CAP_XEN_HVM */ +#define KVM_XEN_HVM_CONFIG_HYPERCALL_MSR (1 << 0) +#define KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL (1 << 1) +#define KVM_XEN_HVM_CONFIG_SHARED_INFO (1 << 2) +#define KVM_XEN_HVM_CONFIG_RUNSTATE (1 << 3) +#define KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL (1 << 4) +#define KVM_XEN_HVM_CONFIG_EVTCHN_SEND (1 << 5) +#define KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG (1 << 6) +#define KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE (1 << 7) + +struct kvm_xen_hvm_config { +__u32 flags; +__u32 msr; +__u64 blob_addr_32; +__u64 blob_addr_64; +__u8 blob_size_32; +__u8 blob_size_64; +__u8 pad2[30 ]; +}; + +struct kvm_xen_hvm_attr { +__u16 type; +__u16 pad[3 ]; +union { +__u8 long_mode; +__u8 vector; +__u8 runstate_update_flag; +struct { +__u64 gfn; +#define KVM_XEN_INVALID_GFN ((__u64)-1) + } shared_info; +struct { +__u32 send_port; +__u32 type;/* EVTCHNSTAT_ipi / EVTCHNSTAT_interdomain */ +__u32 flags; +#define KVM_XEN_EVTCHN_DEASSIGN (1 << 0) +#define KVM_XEN_EVTCHN_UPDATE (1 << 1) +#define KVM_XEN_EVTCHN_RESET (1 << 2) +/* +* Events sent by the guest are either looped back to +* the guest itself (potentially on a different port#) +* or signalled via an eventfd. +*/ +union { +struct { +__u32 port; +__u32 vcpu; +__u32 priority; + } port; +struct { +__u32 port;/* Zero for eventfd */ +__s32 fd; + } eventfd; +__u32 padding[4 ]; + } deliver; + } evtchn; +__u32 xen_version; +__u64 pad[8 ]; + } u; +}; + + +/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO */ +#define KVM_XEN_ATTR_TYPE_LONG_MODE 0x0 +#define KVM_XEN_ATTR_TYPE_SHARED_INFO 0x1 +#define KVM_XEN_ATTR_TYPE_UPCALL_VECTOR 0x2 +/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */ +#define KVM_XEN_ATTR_TYPE_EVTCHN 0x3 +#define KVM_XEN_ATTR_TYPE_XEN_VERSION 0x4 +/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG */ +#define KVM_XEN_ATTR_TYPE_RUNSTATE_UPDATE_FLAG 0x5 + +struct kvm_xen_vcpu_attr { +__u16 type; +__u16 pad[3 ]; +union { +__u64 gpa; +#define KVM_XEN_INVALID_GPA ((__u64)-1) +__u64 pad[8 ]; +struct { +__u64 state; +__u64 state_entry_time; +__u64 time_running; +__u64 time_runnable; +__u64 time_blocked; +__u64 time_offline; + } runstate; +__u32 vcpu_id; +struct { +__u32 port; +__u32 priority; +__u64 expires_ns; + } timer; +__u8 vector; + } u; +}; + +/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO */ +#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO 0x0 +#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO 0x1 +#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR 0x2 +#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT 0x3 +#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA 0x4 +#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST 0x5 +/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */ +#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID 0x6 +#define KVM_XEN_VCPU_ATTR_TYPE_TIMER 0x7 +#define KVM_XEN_VCPU_ATTR_TYPE_UPCALL_VECTOR 0x8 + +/* Secure Encrypted Virtualization command */ +enum sev_cmd_id { +/* Guest initialization commands */ +KVM_SEV_INIT =0 , +KVM_SEV_ES_INIT , +/* Guest launch commands */ +KVM_SEV_LAUNCH_START , +KVM_SEV_LAUNCH_UPDATE_DATA , +KVM_SEV_LAUNCH_UPDATE_VMSA , +KVM_SEV_LAUNCH_SECRET , +KVM_SEV_LAUNCH_MEASURE , +KVM_SEV_LAUNCH_FINISH , +/* Guest migration commands (outgoing) */ +KVM_SEV_SEND_START , +KVM_SEV_SEND_UPDATE_DATA , +KVM_SEV_SEND_UPDATE_VMSA , +KVM_SEV_SEND_FINISH , +/* Guest migration commands (incoming) */ +KVM_SEV_RECEIVE_START , +KVM_SEV_RECEIVE_UPDATE_DATA , +KVM_SEV_RECEIVE_UPDATE_VMSA , +KVM_SEV_RECEIVE_FINISH , +/* Guest status and debug commands */ +KVM_SEV_GUEST_STATUS , +KVM_SEV_DBG_DECRYPT , +KVM_SEV_DBG_ENCRYPT , +/* Guest certificates commands */ +KVM_SEV_CERT_EXPORT , +/* Attestation report */ +KVM_SEV_GET_ATTESTATION_REPORT , +/* Guest Migration Extension */ +KVM_SEV_SEND_CANCEL , + +KVM_SEV_NR_MAX , +}; + +struct kvm_sev_cmd { +__u32 id; +__u64 data; +__u32 error; +__u32 sev_fd; +}; + +struct kvm_sev_launch_start { +__u32 handle; +__u32 policy; +__u64 dh_uaddr; +__u32 dh_len; +__u64 session_uaddr; +__u32 session_len; +}; + +struct kvm_sev_launch_update_data { +__u64 uaddr; +__u32 len; +}; + + +struct kvm_sev_launch_secret { +__u64 hdr_uaddr; +__u32 hdr_len; +__u64 guest_uaddr; +__u32 guest_len; +__u64 trans_uaddr; +__u32 trans_len; +}; + +struct kvm_sev_launch_measure { +__u64 uaddr; +__u32 len; +}; + +struct kvm_sev_guest_status { +__u32 handle; +__u32 policy; +__u32 state; +}; + +struct kvm_sev_dbg { +__u64 src_uaddr; +__u64 dst_uaddr; +__u32 len; +}; + +struct kvm_sev_attestation_report { +__u8 mnonce[16 ]; +__u64 uaddr; +__u32 len; +}; + +struct kvm_sev_send_start { +__u32 policy; +__u64 pdh_cert_uaddr; +__u32 pdh_cert_len; +__u64 plat_certs_uaddr; +__u32 plat_certs_len; +__u64 amd_certs_uaddr; +__u32 amd_certs_len; +__u64 session_uaddr; +__u32 session_len; +}; + +struct kvm_sev_send_update_data { +__u64 hdr_uaddr; +__u32 hdr_len; +__u64 guest_uaddr; +__u32 guest_len; +__u64 trans_uaddr; +__u32 trans_len; +}; + +struct kvm_sev_receive_start { +__u32 handle; +__u32 policy; +__u64 pdh_uaddr; +__u32 pdh_len; +__u64 session_uaddr; +__u32 session_len; +}; + +struct kvm_sev_receive_update_data { +__u64 hdr_uaddr; +__u32 hdr_len; +__u64 guest_uaddr; +__u32 guest_len; +__u64 trans_uaddr; +__u32 trans_len; +}; + +#define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0) +#define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1) + +struct kvm_hyperv_eventfd { +__u32 conn_id; +__s32 fd; +__u32 flags; +__u32 padding[3 ]; +}; + +#define KVM_HYPERV_CONN_ID_MASK 0x00ffffff +#define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0) +/* * Masked event layout. * Bits Description
include/uapi/linux/kvm.h +0 -265
289 lines not on this page · raw message
Signature · 1 line
2.39.0
Paolo Bonzini
maintainerPATCH 3/8 KVM: powerpc: move powerpc-specific structs to uapi/asm/kvm.h
In reply to Paolo BonziniWhile this in principle breaks the appearance of KVM_PPC_* ioctls on architectures other than powerpc, this seems unlikely to be a problem considering that there are already many "struct kvm_ppc_*" definitions in arch/powerpc/include/uapi.
--- arch/powerpc/include/uapi/asm/kvm.h | 44 +++++++++++++++++++++++++++++ include/uapi/linux/kvm.h | 44 ----------------------------- 2 files changed, 44 insertions(+), 44 deletions(-)
arch/powerpc/include/uapi/asm/kvm.h +44 -0
@@ -733,4 +733,48 @@ struct kvm_ppc_xive_eq {#define KVM_XIVE_TIMA_PAGE_OFFSET 0#define KVM_XIVE_ESB_PAGE_OFFSET 4 +/* for KVM_PPC_GET_PVINFO */ + +#define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0) + +struct kvm_ppc_pvinfo { +/* out */ +__u32 flags; +__u32 hcall[4 ]; +__u8 pad[108 ]; +}; + +/* for KVM_PPC_GET_SMMU_INFO */ +#define KVM_PPC_PAGE_SIZES_MAX_SZ 8 + +struct kvm_ppc_one_page_size { +__u32 page_shift;/* Page shift (or 0) */ +__u32 pte_enc;/* Encoding in the HPTE (>>12) */ +}; + +struct kvm_ppc_one_seg_page_size { +__u32 page_shift;/* Base page shift of segment (or 0) */ +__u32 slb_enc;/* SLB encoding for BookS */ +struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ ]; +}; + +#define KVM_PPC_PAGE_SIZES_REAL 0x00000001 +#define KVM_PPC_1T_SEGMENTS 0x00000002 +#define KVM_PPC_NO_HASH 0x00000004 + +struct kvm_ppc_smmu_info { +__u64 flags; +__u32 slb_size; +__u16 data_keys;/* # storage keys supported for data */ +__u16 instr_keys;/* # storage keys supported for instructions */ +struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ ]; +}; + +/* for KVM_PPC_RESIZE_HPT_{PREPARE,COMMIT} */ +struct kvm_ppc_resize_hpt { +__u64 flags; +__u32 shift; +__u32 pad; +}; +#endif /* __LINUX_KVM_POWERPC_H */
include/uapi/linux/kvm.h +0 -44
50 lines not on this page · raw message
Signature · 1 line
2.39.0
Paolo Bonzini
maintainerPATCH 4/8 KVM: s390: move s390-specific structs to uapi/asm/kvm.h
In reply to Paolo BonziniWhile this in principle breaks the appearance of KVM_S390_* ioctls on architectures other than s390, this seems unlikely to be a problem considering that there are already many "struct kvm_s390_*" definitions in arch/s390/include/uapi.
--- arch/s390/include/uapi/asm/kvm.h | 314 +++++++++++++++++++++++++++++++ include/uapi/linux/kvm.h | 312 ------------------------------ 2 files changed, 314 insertions(+), 312 deletions(-)
arch/s390/include/uapi/asm/kvm.h +314 -0
@@ -14,6 +14,320 @@#define __KVM_S390#define __KVM_HAVE_GUEST_DEBUG +struct kvm_s390_skeys { +__u64 start_gfn; +__u64 count; +__u64 skeydata_addr; +__u32 flags; +__u32 reserved[9 ]; +}; + +#define KVM_S390_CMMA_PEEK (1 << 0) + +/** +* kvm_s390_cmma_log - Used for CMMA migration. +* +* Used both for input and output. +* +* @start_gfn: Guest page number to start from. +* @count: Size of the result buffer. +* @flags: Control operation mode via KVM_S390_CMMA_* flags +* @remaining: Used with KVM_S390_GET_CMMA_BITS. Indicates how many dirty +* pages are still remaining. +* @mask: Used with KVM_S390_SET_CMMA_BITS. Bitmap of bits to actually set +* in the PGSTE. +* @values: Pointer to the values buffer. +* +* Used in KVM_S390_{G,S}ET_CMMA_BITS ioctls. +*/ +struct kvm_s390_cmma_log { +__u64 start_gfn; +__u32 count; +__u32 flags; +union { +__u64 remaining; +__u64 mask; + }; +__u64 values; +}; + +#define KVM_S390_RESET_POR 1 +#define KVM_S390_RESET_CLEAR 2 +#define KVM_S390_RESET_SUBSYSTEM 4 +#define KVM_S390_RESET_CPU_INIT 8 +#define KVM_S390_RESET_IPL 16 + +/* for KVM_S390_MEM_OP */ +struct kvm_s390_mem_op { +/* in */ +__u64 gaddr;/* the guest address */ +__u64 flags;/* flags */ +__u32 size;/* amount of bytes */ +__u32 op;/* type of operation */ +__u64 buf;/* buffer in userspace */ +union { +struct { +__u8 ar;/* the access register number */ +__u8 key;/* access key, ignored if flag unset */ +__u8 pad1[6 ];/* ignored */ +__u64 old_addr;/* ignored if cmpxchg flag unset */ + }; +__u32 sida_offset;/* offset into the sida */ +__u8 reserved[32 ];/* ignored */ + }; +}; +/* types for kvm_s390_mem_op->op */ +#define KVM_S390_MEMOP_LOGICAL_READ 0 +#define KVM_S390_MEMOP_LOGICAL_WRITE 1 +#define KVM_S390_MEMOP_SIDA_READ 2 +#define KVM_S390_MEMOP_SIDA_WRITE 3 +#define KVM_S390_MEMOP_ABSOLUTE_READ 4 +#define KVM_S390_MEMOP_ABSOLUTE_WRITE 5 +#define KVM_S390_MEMOP_ABSOLUTE_CMPXCHG 6 + +/* flags for kvm_s390_mem_op->flags */ +#define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0) +#define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1) +#define KVM_S390_MEMOP_F_SKEY_PROTECTION (1ULL << 2) + +/* flags specifying extension support via KVM_CAP_S390_MEM_OP_EXTENSION */ +#define KVM_S390_MEMOP_EXTENSION_CAP_BASE (1 << 0) +#define KVM_S390_MEMOP_EXTENSION_CAP_CMPXCHG (1 << 1) + +struct kvm_s390_psw { +__u64 mask; +__u64 addr; +}; + +/* valid values for type in kvm_s390_interrupt */ +#define KVM_S390_SIGP_STOP 0xfffe0000u +#define KVM_S390_PROGRAM_INT 0xfffe0001u +#define KVM_S390_SIGP_SET_PREFIX 0xfffe0002u +#define KVM_S390_RESTART 0xfffe0003u +#define KVM_S390_INT_PFAULT_INIT 0xfffe0004u +#define KVM_S390_INT_PFAULT_DONE 0xfffe0005u +#define KVM_S390_MCHK 0xfffe1000u +#define KVM_S390_INT_CLOCK_COMP 0xffff1004u +#define KVM_S390_INT_CPU_TIMER 0xffff1005u +#define KVM_S390_INT_VIRTIO 0xffff2603u +#define KVM_S390_INT_SERVICE 0xffff2401u +#define KVM_S390_INT_EMERGENCY 0xffff1201u +#define KVM_S390_INT_EXTERNAL_CALL 0xffff1202u +/* Anything below 0xfffe0000u is taken by INT_IO */ +#define KVM_S390_INT_IO (ai,cssid,ssid,schid) \ + (((schid)) | \ + ((ssid) << 16) | \ + ((cssid) << 18) | \ + ((ai) << 26)) +#define KVM_S390_INT_IO_MIN 0x00000000u +#define KVM_S390_INT_IO_MAX 0xfffdffffu +#define KVM_S390_INT_IO_AI_MASK 0x04000000u + + +struct kvm_s390_interrupt { +__u32 type; +__u32 parm; +__u64 parm64; +}; + +struct kvm_s390_io_info { +__u16 subchannel_id; +__u16 subchannel_nr; +__u32 io_int_parm; +__u32 io_int_word; +}; + +struct kvm_s390_ext_info { +__u32 ext_params; +__u32 pad; +__u64 ext_params2; +}; + +struct kvm_s390_pgm_info { +__u64 trans_exc_code; +__u64 mon_code; +__u64 per_address; +__u32 data_exc_code; +__u16 code; +__u16 mon_class_nr; +__u8 per_code; +__u8 per_atmid; +__u8 exc_access_id; +__u8 per_access_id; +__u8 op_access_id; +#define KVM_S390_PGM_FLAGS_ILC_VALID 0x01 +#define KVM_S390_PGM_FLAGS_ILC_0 0x02 +#define KVM_S390_PGM_FLAGS_ILC_1 0x04 +#define KVM_S390_PGM_FLAGS_ILC_MASK 0x06 +#define KVM_S390_PGM_FLAGS_NO_REWIND 0x08 +__u8 flags; +__u8 pad[2 ]; +}; + +struct kvm_s390_prefix_info { +__u32 address; +}; + +struct kvm_s390_extcall_info { +__u16 code; +}; + +struct kvm_s390_emerg_info { +__u16 code; +}; + +#define KVM_S390_STOP_FLAG_STORE_STATUS 0x01 +struct kvm_s390_stop_info { +__u32 flags; +}; + +struct kvm_s390_mchk_info { +__u64 cr14; +__u64 mcic; +__u64 failing_storage_address; +__u32 ext_damage_code; +__u32 pad; +__u8 fixed_logout[16 ]; +}; + +struct kvm_s390_irq { +__u64 type; +union { +struct kvm_s390_io_info io; +struct kvm_s390_ext_info ext; +struct kvm_s390_pgm_info pgm; +struct kvm_s390_emerg_info emerg; +struct kvm_s390_extcall_info extcall; +struct kvm_s390_prefix_info prefix; +struct kvm_s390_stop_info stop; +struct kvm_s390_mchk_info mchk; +char reserved[64 ]; + } u; +}; + +struct kvm_s390_irq_state { +__u64 buf; +__u32 flags;/* will stay unused for compatibility reasons */ +__u32 len; +__u32 reserved[4 ];/* will stay unused for compatibility reasons */ +}; + +struct kvm_s390_ucas_mapping { +__u64 user_addr; +__u64 vcpu_addr; +__u64 length; +}; + +struct kvm_s390_pv_sec_parm { +__u64 origin; +__u64 length; +}; + +struct kvm_s390_pv_unp { +__u64 addr; +__u64 size; +__u64 tweak; +}; + +enum pv_cmd_dmp_id { +KVM_PV_DUMP_INIT , +KVM_PV_DUMP_CONFIG_STOR_STATE , +KVM_PV_DUMP_COMPLETE , +KVM_PV_DUMP_CPU , +}; + +struct kvm_s390_pv_dmp { +__u64 subcmd; +__u64 buff_addr; +__u64 buff_len; +__u64 gaddr;/* For dump storage state */ +__u64 reserved[4 ]; +}; + +enum pv_cmd_info_id { +KVM_PV_INFO_VM , +KVM_PV_INFO_DUMP , +}; + +struct kvm_s390_pv_info_dump { +__u64 dump_cpu_buffer_len; +__u64 dump_config_mem_buffer_per_1m; +__u64 dump_config_finalize_len; +}; + +struct kvm_s390_pv_info_vm { +__u64 inst_calls_list[4 ]; +__u64 max_cpus; +__u64 max_guests; +__u64 max_guest_addr; +__u64 feature_indication; +}; + +struct kvm_s390_pv_info_header { +__u32 id; +__u32 len_max; +__u32 len_written; +__u32 reserved; +}; + +struct kvm_s390_pv_info { +struct kvm_s390_pv_info_header header; +union { +struct kvm_s390_pv_info_dump dump; +struct kvm_s390_pv_info_vm vm; + }; +}; + +enum pv_cmd_id { +KVM_PV_ENABLE , +KVM_PV_DISABLE , +KVM_PV_SET_SEC_PARMS , +KVM_PV_UNPACK , +KVM_PV_VERIFY , +KVM_PV_PREP_RESET , +KVM_PV_UNSHARE_ALL , +KVM_PV_INFO , +KVM_PV_DUMP , +KVM_PV_ASYNC_CLEANUP_PREPARE , +KVM_PV_ASYNC_CLEANUP_PERFORM , +}; + +struct kvm_pv_cmd { +__u32 cmd;/* Command to be executed */ +__u16 rc;/* Ultravisor return code */ +__u16 rrc;/* Ultravisor return reason code */ +__u64 data;/* Data or address */ +__u32 flags;/* flags for future extensions. Must be 0 for now */ +__u32 reserved[3 ]; +}; + +struct kvm_s390_zpci_op { +/* in */ +__u32 fh;/* target device */ +__u8 op;/* operation to perform */ +__u8 pad[3 ]; +union { +/* for KVM_S390_ZPCIOP_REG_AEN */ +struct { +__u64 ibv;/* Guest addr of interrupt bit vector */ +__u64 sb;/* Guest addr of summary bit */ +__u32 flags; +__u32 noi;/* Number of interrupts */ +__u8 isc;/* Guest interrupt subclass */ +__u8 sbo;/* Offset of guest summary bit vector */ +__u16 pad; + } reg_aen; +__u64 reserved[8 ]; + } u; +}; + +/* types for kvm_s390_zpci_op->op */ +#define KVM_S390_ZPCIOP_REG_AEN 0 +#define KVM_S390_ZPCIOP_DEREG_AEN 1 + +/* flags for kvm_s390_zpci_op->u.reg_aen.flags */ +#define KVM_S390_ZPCIOP_REGAEN_HOST (1 << 0) +/* Device control API: s390-specific devices */ #define KVM_DEV_FLIC_GET_ALL_IRQS 1#define KVM_DEV_FLIC_ENQUEUE 2
include/uapi/linux/kvm.h +0 -312
354 lines not on this page · raw message
Signature · 1 line
2.39.0
Paolo Bonzini
maintainerPATCH 5/8 KVM: arm64: move ARM-specific defines to uapi/asm/kvm.h
In reply to Paolo BonziniWhile this in principle breaks userspace code that mentions KVM_ARM_DEV_* on architectures other than aarch64, this seems unlikely to be a problem considering that run->s.regs.device_irq_level is only defined on that architecture.
--- arch/arm64/include/uapi/asm/kvm.h | 5 +++++ include/uapi/linux/kvm.h | 7 ------- 2 files changed, 5 insertions(+), 7 deletions(-)
arch/arm64/include/uapi/asm/kvm.h +5 -0
@@ -162,6 +162,11 @@ struct kvm_sync_regs {__u64 device_irq_level; }; +/* Bits for run->s.regs.device_irq_level */ +#define KVM_ARM_DEV_EL1_VTIMER (1 << 0) +#define KVM_ARM_DEV_EL1_PTIMER (1 << 1) +#define KVM_ARM_DEV_PMU (1 << 2) +/* * PMU filter structure. Describe a range of events with a particular * action. To be used with KVM_ARM_VCPU_PMU_V3_FILTER.
include/uapi/linux/kvm.h +0 -7
@@ -1384,13 +1384,6 @@ struct kvm_enc_region {#define KVM_GET_SREGS2 _IOR(KVMIO, 0xcc, struct kvm_sregs2)#define KVM_SET_SREGS2 _IOW(KVMIO, 0xcd, struct kvm_sregs2) -/* Available with KVM_CAP_ARM_USER_IRQ */ - -/* Bits for run->s.regs.device_irq_level */ -#define KVM_ARM_DEV_EL1_VTIMER (1 << 0) -#define KVM_ARM_DEV_EL1_PTIMER (1 << 1) -#define KVM_ARM_DEV_PMU (1 << 2) -#define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0)#define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1)
Signature · 1 line
2.39.0
Paolo Bonzini
maintainerPATCH 6/8 kvm: replace __KVM_HAVE_READONLY_MEM with Kconfig symbol
In reply to Paolo BonziniKVM uses __KVM_HAVE_* symbols in the architecture-dependent uapi/asm/kvm.h to mask unused definitions in include/uapi/linux/kvm.h. __KVM_HAVE_READONLY_MEM however was nothing but a misguided attempt to define KVM_CAP_READONLY_MEM only on architectures where KVM_CHECK_EXTENSION(KVM_CAP_READONLY_MEM) could possibly return nonzero. This however does not make sense, and it prevented userspace from supporting this architecture-independent feature without recompilation.
Therefore, these days __KVM_HAVE_READONLY_MEM does not mask anything and is only used in virt/kvm/kvm_main.c. Userspace does not need to test it and there should be no need for it to exist. Remove it and replace it with a Kconfig symbol within Linux source code.
--- arch/arm64/include/uapi/asm/kvm.h | 1 - arch/arm64/kvm/Kconfig | 1 + arch/loongarch/include/uapi/asm/kvm.h | 2 -- arch/loongarch/kvm/Kconfig | 1 + arch/mips/include/uapi/asm/kvm.h | 2 -- arch/mips/kvm/Kconfig | 1 + arch/riscv/include/uapi/asm/kvm.h | 1 - arch/riscv/kvm/Kconfig | 1 + arch/x86/include/uapi/asm/kvm.h | 1 - arch/x86/kvm/Kconfig | 1 + include/uapi/linux/kvm.h | 7 +++++++ virt/kvm/Kconfig | 3 +++ virt/kvm/kvm_main.c | 2 +- 13 files changed, 16 insertions(+), 8 deletions(-)
arch/arm64/include/uapi/asm/kvm.h +0 -1
@@ -39,7 +39,6 @@#define __KVM_HAVE_GUEST_DEBUG#define __KVM_HAVE_IRQ_LINE -#define __KVM_HAVE_READONLY_MEM#define __KVM_HAVE_VCPU_EVENTS#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
arch/arm64/kvm/Kconfig +1 -0
@@ -34,6 +34,7 @@ menuconfig KVM select HAVE_KVM_IRQCHIP select HAVE_KVM_IRQ_ROUTING select HAVE_KVM_IRQ_BYPASS + select HAVE_KVM_READONLY_MEM select HAVE_KVM_VCPU_RUN_PID_CHANGE select SCHED_INFO select GUEST_PERF_EVENTS if PERF_EVENTS
arch/loongarch/include/uapi/asm/kvm.h +0 -2
@@ -14,8 +14,6 @@* Some parts derived from the x86 version of this file. */ -#define __KVM_HAVE_READONLY_MEM -#define KVM_COALESCED_MMIO_PAGE_OFFSET 1#define KVM_DIRTY_LOG_PAGE_OFFSET 64
arch/loongarch/kvm/Kconfig +1 -0
@@ -27,6 +27,7 @@ config KVM select KVM_GENERIC_HARDWARE_ENABLING select KVM_GENERIC_MMU_NOTIFIER select KVM_MMIO + select HAVE_KVM_READONLY_MEM select KVM_XFER_TO_GUEST_WORK help Support hosting virtualized guest machines using
arch/mips/include/uapi/asm/kvm.h +0 -2
@@ -20,8 +20,6 @@* Some parts derived from the x86 version of this file. */ -#define __KVM_HAVE_READONLY_MEM -#define KVM_COALESCED_MMIO_PAGE_OFFSET 1/*
arch/mips/kvm/Kconfig +1 -0
@@ -26,6 +26,7 @@ config KVM select KVM_MMIO select KVM_GENERIC_MMU_NOTIFIER select KVM_GENERIC_HARDWARE_ENABLING + select HAVE_KVM_READONLY_MEM help Support for hosting Guest kernels.
arch/riscv/include/uapi/asm/kvm.h +0 -1
@@ -16,7 +16,6 @@#include <asm/ptrace.h> #define __KVM_HAVE_IRQ_LINE -#define __KVM_HAVE_READONLY_MEM#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
arch/riscv/kvm/Kconfig +1 -0
@@ -24,6 +24,7 @@ config KVM select HAVE_KVM_IRQ_ROUTING select HAVE_KVM_MSI select HAVE_KVM_VCPU_ASYNC_IOCTL + select HAVE_KVM_READONLY_MEM select KVM_COMMON select KVM_GENERIC_DIRTYLOG_READ_PROTECT select KVM_GENERIC_HARDWARE_ENABLING
arch/x86/include/uapi/asm/kvm.h +0 -1
@@ -51,7 +51,6 @@#define __KVM_HAVE_DEBUGREGS#define __KVM_HAVE_XSAVE#define __KVM_HAVE_XCRS -#define __KVM_HAVE_READONLY_MEM/* Architectural interrupt line count. */ #define KVM_NR_INTERRUPTS 256
arch/x86/kvm/Kconfig +1 -0
@@ -29,6 +29,7 @@ config KVM select HAVE_KVM_DIRTY_RING_ACQ_REL select HAVE_KVM_IRQ_BYPASS select HAVE_KVM_IRQ_ROUTING + select HAVE_KVM_READONLY_MEM select KVM_ASYNC_PF select USER_RETURN_NOTIFIER select KVM_MMIO
virt/kvm/Kconfig +3 -0
@@ -52,6 +52,9 @@ config KVM_ASYNC_PF_SYNC config HAVE_KVM_MSI bool +config HAVE_KVM_READONLY_MEM + bool + config HAVE_KVM_CPU_RELAX_INTERCEPT bool
virt/kvm/kvm_main.c +1 -1
@@ -1614,7 +1614,7 @@ static int check_memory_region_flags(struct kvm *kvm,if (mem->flags &KVM_MEM_GUEST_MEMFD ) valid_flags &= ~KVM_MEM_LOG_DIRTY_PAGES ; -#ifdef __KVM_HAVE_READONLY_MEM +#ifdef CONFIG_HAVE_KVM_READONLY_MEM valid_flags |=KVM_MEM_READONLY ;#endif
Signature · 1 line
2.39.0
Paolo Bonzini
maintainerPATCH 7/8 KVM: define __KVM_HAVE_GUEST_DEBUG unconditionally
In reply to Paolo BonziniSince all architectures (for historical reasons) have to define struct kvm_guest_debug_arch, and since userspace has to check KVM_CHECK_EXTENSION(KVM_CAP_SET_GUEST_DEBUG) anyway, there is no advantage in masking the capability #define itself. Remove the #define __KVM_HAVE_GUEST_DEBUG from architecture-specific headers.
--- arch/arm64/include/uapi/asm/kvm.h | 1 - arch/powerpc/include/uapi/asm/kvm.h | 1 - arch/s390/include/uapi/asm/kvm.h | 1 - arch/x86/include/uapi/asm/kvm.h | 1 - include/uapi/linux/kvm.h | 3 +-- 5 files changed, 1 insertion(+), 6 deletions(-)
arch/arm64/include/uapi/asm/kvm.h +0 -1
@@ -37,7 +37,6 @@#include <asm/ptrace.h> #include <asm/sve_context.h> -#define __KVM_HAVE_GUEST_DEBUG#define __KVM_HAVE_IRQ_LINE#define __KVM_HAVE_VCPU_EVENTS
arch/powerpc/include/uapi/asm/kvm.h +0 -1
@@ -28,7 +28,6 @@#define __KVM_HAVE_PPC_SMT#define __KVM_HAVE_IRQCHIP#define __KVM_HAVE_IRQ_LINE -#define __KVM_HAVE_GUEST_DEBUG/* Not always available, but if it is, this is the correct offset. */ #define KVM_COALESCED_MMIO_PAGE_OFFSET 1
arch/s390/include/uapi/asm/kvm.h +0 -1
@@ -12,7 +12,6 @@#include <linux/types.h> #define __KVM_S390 -#define __KVM_HAVE_GUEST_DEBUGstruct kvm_s390_skeys {__u64 start_gfn;
arch/x86/include/uapi/asm/kvm.h +0 -1
@@ -42,7 +42,6 @@#define __KVM_HAVE_IRQ_LINE#define __KVM_HAVE_MSI#define __KVM_HAVE_USER_NMI -#define __KVM_HAVE_GUEST_DEBUG#define __KVM_HAVE_MSIX#define __KVM_HAVE_MCE#define __KVM_HAVE_PIT_STATE2
include/uapi/linux/kvm.h +5 -2
@@ -16,6 +16,11 @@#define KVM_API_VERSION 12 +/* +* Backwards-compatible definitions. +*/ +#define __KVM_HAVE_GUEST_DEBUG +/* for KVM_SET_USER_MEMORY_REGION */ struct kvm_userspace_memory_region {__u32 slot;
@@ -689,9 +690,7 @@ struct kvm_enable_cap {/* Bug in KVM_SET_USER_MEMORY_REGION fixed: */ #define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21#define KVM_CAP_USER_NMI 22 -#ifdef __KVM_HAVE_GUEST_DEBUG#define KVM_CAP_SET_GUEST_DEBUG 23 -#endif #ifdef __KVM_HAVE_PIT#define KVM_CAP_REINJECT_CONTROL 24#endif
Signature · 1 line
2.39.0
Paolo Bonzini
maintainerPATCH 8/8 KVM: remove unnecessary #ifdef
In reply to Paolo BonziniKVM_CAP_IRQ_ROUTING is always defined, so there is no need to check if it is.
--- include/uapi/linux/kvm.h | 4 ---- 1 file changed, 4 deletions(-)
include/uapi/linux/kvm.h +0 -4
@@ -921,8 +921,6 @@ struct kvm_enable_cap {#define KVM_CAP_GUEST_MEMFD 234#define KVM_CAP_VM_TYPES 235 -#ifdef KVM_CAP_IRQ_ROUTING -struct kvm_irq_routing_irqchip {__u32 irqchip;__u32 pin;
@@ -987,8 +985,6 @@ struct kvm_irq_routing {struct kvm_irq_routing_entry entries[]; }; -#endif -#define KVM_IRQFD_FLAG_DEASSIGN (1 << 0)/* * Available with KVM_CAP_IRQFD_RESAMPLE
Signature · 1 line
2.39.0
Sean Christopherson
maintainerQuoted 7 lines · Paolo Bonzini
More cleanups of KVM's main header:
* remove thoroughly obsolete APIs
* move architecture-dependent stuff to
uapi/asm/kvm.h* small cleanups to __KVM_HAVE_* symbols
Do you have any thoughts on how/when you're going to apply this? The kvm.h code movement is likely going to generate conflicts for any new uAPI, e.g. I know Paul's Xen series at least conflicts.
A topic branch is probably overkill. Maybe getting this into kvm/next sooner than later so that kvm/next can be used as a base will suffice?
Paolo Bonzini
maintainerQuoted 6 lines · Sean Christopherson
Quoted 4 lines · Paolo Bonzini
More cleanups of KVM's main header:
* remove thoroughly obsolete APIs
Quoted 7 lines
Quoted 3 lines
* move architecture-dependent stuff to
uapi/asm/kvm.h* small cleanups to __KVM_HAVE_* symbols
Do you have any thoughts on how/when you're going to apply this? The
kvm.hcode movement is likely going to generate conflicts for any new uAPI, e.g. I know Paul's Xen series at least conflicts.
It also conflicts (and was partly motivated by) the SEV API cleanups that I am going to post soon.
Quoted 2 lines
A topic branch is probably overkill. Maybe getting this into kvm/next sooner than later so that kvm/next can be used as a base will suffice?
I can do both, a topic branch is free. But if you think this is in the "if it compiles, apply it", then I can take that as Acked-by and apply it today or tomorrow.
Paolo
Quoted 18 lines · Paolo Bonzini
Quoted 6 lines · Sean Christopherson
Quoted 4 lines · Paolo Bonzini
More cleanups of KVM's main header:
* remove thoroughly obsolete APIs
Quoted 7 lines
Quoted 3 lines
* move architecture-dependent stuff to
uapi/asm/kvm.h* small cleanups to __KVM_HAVE_* symbols
Do you have any thoughts on how/when you're going to apply this? The
kvm.hcode movement is likely going to generate conflicts for any new uAPI, e.g. I know Paul's Xen series at least conflicts.It also conflicts (and was partly motivated by) the SEV API cleanups that I am going to post soon.
Quoted 6 lines
Quoted 2 lines
A topic branch is probably overkill. Maybe getting this into kvm/next sooner than later so that kvm/next can be used as a base will suffice?
I can do both, a topic branch is free. But if you think this is in the "if it compiles, apply it", then I can take that as Acked-by and apply it today or tomorrow.
Looks like you already created and merged a topic branch, but for giggles:
Paolo Bonzini
maintainerQuoted 5 lines · Sean Christopherson
Quoted 3 lines
I can do both, a topic branch is free. But if you think this is in the "if it compiles, apply it", then I can take that as Acked-by and apply it today or tomorrow.
Looks like you already created and merged a topic branch, but for giggles:
Only to kvm/queue to show myself how it would look like...
Quoted 1 line
Thanks!
Paolo