diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2021-06-28 15:40:51 -0700 | 
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2021-06-28 15:40:51 -0700 | 
| commit | 36824f198c621cebeb22966b5e244378fa341295 (patch) | |
| tree | ee1e358a4ed0cd022ae12b4b7ba1fa3d0e5746d5 /include/uapi | |
| parent | 9840cfcb97fc8b6aa7b36cec3cc3fd763f14052e (diff) | |
| parent | b8917b4ae44d1b945f6fba3d8ee6777edb44633b (diff) | |
| download | linux-36824f198c621cebeb22966b5e244378fa341295.tar.bz2 | |
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull kvm updates from Paolo Bonzini:
 "This covers all architectures (except MIPS) so I don't expect any
  other feature pull requests this merge window.
  ARM:
   - Add MTE support in guests, complete with tag save/restore interface
   - Reduce the impact of CMOs by moving them in the page-table code
   - Allow device block mappings at stage-2
   - Reduce the footprint of the vmemmap in protected mode
   - Support the vGIC on dumb systems such as the Apple M1
   - Add selftest infrastructure to support multiple configuration and
     apply that to PMU/non-PMU setups
   - Add selftests for the debug architecture
   - The usual crop of PMU fixes
  PPC:
   - Support for the H_RPT_INVALIDATE hypercall
   - Conversion of Book3S entry/exit to C
   - Bug fixes
  S390:
   - new HW facilities for guests
   - make inline assembly more robust with KASAN and co
  x86:
   - Allow userspace to handle emulation errors (unknown instructions)
   - Lazy allocation of the rmap (host physical -> guest physical
     address)
   - Support for virtualizing TSC scaling on VMX machines
   - Optimizations to avoid shattering huge pages at the beginning of
     live migration
   - Support for initializing the PDPTRs without loading them from
     memory
   - Many TLB flushing cleanups
   - Refuse to load if two-stage paging is available but NX is not (this
     has been a requirement in practice for over a year)
   - A large series that separates the MMU mode (WP/SMAP/SMEP etc.) from
     CR0/CR4/EFER, using the MMU mode everywhere once it is computed
     from the CPU registers
   - Use PM notifier to notify the guest about host suspend or hibernate
   - Support for passing arguments to Hyper-V hypercalls using XMM
     registers
   - Support for Hyper-V TLB flush hypercalls and enlightened MSR bitmap
     on AMD processors
   - Hide Hyper-V hypercalls that are not included in the guest CPUID
   - Fixes for live migration of virtual machines that use the Hyper-V
     "enlightened VMCS" optimization of nested virtualization
   - Bugfixes (not many)
  Generic:
   - Support for retrieving statistics without debugfs
   - Cleanups for the KVM selftests API"
* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (314 commits)
  KVM: x86: rename apic_access_page_done to apic_access_memslot_enabled
  kvm: x86: disable the narrow guest module parameter on unload
  selftests: kvm: Allows userspace to handle emulation errors.
  kvm: x86: Allow userspace to handle emulation errors
  KVM: x86/mmu: Let guest use GBPAGES if supported in hardware and TDP is on
  KVM: x86/mmu: Get CR4.SMEP from MMU, not vCPU, in shadow page fault
  KVM: x86/mmu: Get CR0.WP from MMU, not vCPU, in shadow page fault
  KVM: x86/mmu: Drop redundant rsvd bits reset for nested NPT
  KVM: x86/mmu: Optimize and clean up so called "last nonleaf level" logic
  KVM: x86: Enhance comments for MMU roles and nested transition trickiness
  KVM: x86/mmu: WARN on any reserved SPTE value when making a valid SPTE
  KVM: x86/mmu: Add helpers to do full reserved SPTE checks w/ generic MMU
  KVM: x86/mmu: Use MMU's role to determine PTTYPE
  KVM: x86/mmu: Collapse 32-bit PAE and 64-bit statements for helpers
  KVM: x86/mmu: Add a helper to calculate root from role_regs
  KVM: x86/mmu: Add helper to update paging metadata
  KVM: x86/mmu: Don't update nested guest's paging bitmasks if CR0.PG=0
  KVM: x86/mmu: Consolidate reset_rsvds_bits_mask() calls
  KVM: x86/mmu: Use MMU role_regs to get LA57, and drop vCPU LA57 helper
  KVM: x86/mmu: Get nested MMU's root level from the MMU's role
  ...
Diffstat (limited to 'include/uapi')
| -rw-r--r-- | include/uapi/linux/kvm.h | 105 | ||||
| -rw-r--r-- | include/uapi/linux/kvm_para.h | 1 | 
2 files changed, 106 insertions, 0 deletions
| diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 79d9c44d1ad7..d9e4aabcb31a 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -280,6 +280,9 @@ struct kvm_xen_exit {  /* Encounter unexpected vm-exit reason */  #define KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON	4 +/* Flags that describe what fields in emulation_failure hold valid data. */ +#define KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES (1ULL << 0) +  /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */  struct kvm_run {  	/* in */ @@ -383,6 +386,25 @@ struct kvm_run {  			__u32 ndata;  			__u64 data[16];  		} internal; +		/* +		 * KVM_INTERNAL_ERROR_EMULATION +		 * +		 * "struct emulation_failure" is an overlay of "struct internal" +		 * that is used for the KVM_INTERNAL_ERROR_EMULATION sub-type of +		 * KVM_EXIT_INTERNAL_ERROR.  Note, unlike other internal error +		 * sub-types, this struct is ABI!  It also needs to be backwards +		 * compatible with "struct internal".  Take special care that +		 * "ndata" is correct, that new fields are enumerated in "flags", +		 * and that each flag enumerates fields that are 64-bit aligned +		 * and sized (so that ndata+internal.data[] is valid/accurate). +		 */ +		struct { +			__u32 suberror; +			__u32 ndata; +			__u64 flags; +			__u8  insn_size; +			__u8  insn_bytes[15]; +		} emulation_failure;  		/* KVM_EXIT_OSI */  		struct {  			__u64 gprs[32]; @@ -1083,6 +1105,13 @@ struct kvm_ppc_resize_hpt {  #define KVM_CAP_SGX_ATTRIBUTE 196  #define KVM_CAP_VM_COPY_ENC_CONTEXT_FROM 197  #define KVM_CAP_PTP_KVM 198 +#define KVM_CAP_HYPERV_ENFORCE_CPUID 199 +#define KVM_CAP_SREGS2 200 +#define KVM_CAP_EXIT_HYPERCALL 201 +#define KVM_CAP_PPC_RPT_INVALIDATE 202 +#define KVM_CAP_BINARY_STATS_FD 203 +#define KVM_CAP_EXIT_ON_EMULATION_FAILURE 204 +#define KVM_CAP_ARM_MTE 205  #ifdef KVM_CAP_IRQ_ROUTING @@ -1428,6 +1457,7 @@ struct kvm_s390_ucas_mapping {  /* Available with KVM_CAP_PMU_EVENT_FILTER */  #define KVM_SET_PMU_EVENT_FILTER  _IOW(KVMIO,  0xb2, struct kvm_pmu_event_filter)  #define KVM_PPC_SVM_OFF		  _IO(KVMIO,  0xb3) +#define KVM_ARM_MTE_COPY_TAGS	  _IOR(KVMIO,  0xb4, struct kvm_arm_copy_mte_tags)  /* ioctl for vm fd */  #define KVM_CREATE_DEVICE	  _IOWR(KVMIO,  0xe0, struct kvm_create_device) @@ -1621,6 +1651,9 @@ struct kvm_xen_hvm_attr {  #define KVM_XEN_VCPU_GET_ATTR	_IOWR(KVMIO, 0xca, struct kvm_xen_vcpu_attr)  #define KVM_XEN_VCPU_SET_ATTR	_IOW(KVMIO,  0xcb, struct kvm_xen_vcpu_attr) +#define KVM_GET_SREGS2             _IOR(KVMIO,  0xcc, struct kvm_sregs2) +#define KVM_SET_SREGS2             _IOW(KVMIO,  0xcd, struct kvm_sregs2) +  struct kvm_xen_vcpu_attr {  	__u16 type;  	__u16 pad[3]; @@ -1899,4 +1932,76 @@ struct kvm_dirty_gfn {  #define KVM_BUS_LOCK_DETECTION_OFF             (1 << 0)  #define KVM_BUS_LOCK_DETECTION_EXIT            (1 << 1) +/** + * struct kvm_stats_header - Header of per vm/vcpu binary statistics data. + * @flags: Some extra information for header, always 0 for now. + * @name_size: The size in bytes of the memory which contains statistics + *             name string including trailing '\0'. The memory is allocated + *             at the send of statistics descriptor. + * @num_desc: The number of statistics the vm or vcpu has. + * @id_offset: The offset of the vm/vcpu stats' id string in the file pointed + *             by vm/vcpu stats fd. + * @desc_offset: The offset of the vm/vcpu stats' descriptor block in the file + *               pointd by vm/vcpu stats fd. + * @data_offset: The offset of the vm/vcpu stats' data block in the file + *               pointed by vm/vcpu stats fd. + * + * This is the header userspace needs to read from stats fd before any other + * readings. It is used by userspace to discover all the information about the + * vm/vcpu's binary statistics. + * Userspace reads this header from the start of the vm/vcpu's stats fd. + */ +struct kvm_stats_header { +	__u32 flags; +	__u32 name_size; +	__u32 num_desc; +	__u32 id_offset; +	__u32 desc_offset; +	__u32 data_offset; +}; + +#define KVM_STATS_TYPE_SHIFT		0 +#define KVM_STATS_TYPE_MASK		(0xF << KVM_STATS_TYPE_SHIFT) +#define KVM_STATS_TYPE_CUMULATIVE	(0x0 << KVM_STATS_TYPE_SHIFT) +#define KVM_STATS_TYPE_INSTANT		(0x1 << KVM_STATS_TYPE_SHIFT) +#define KVM_STATS_TYPE_PEAK		(0x2 << KVM_STATS_TYPE_SHIFT) +#define KVM_STATS_TYPE_MAX		KVM_STATS_TYPE_PEAK + +#define KVM_STATS_UNIT_SHIFT		4 +#define KVM_STATS_UNIT_MASK		(0xF << KVM_STATS_UNIT_SHIFT) +#define KVM_STATS_UNIT_NONE		(0x0 << KVM_STATS_UNIT_SHIFT) +#define KVM_STATS_UNIT_BYTES		(0x1 << KVM_STATS_UNIT_SHIFT) +#define KVM_STATS_UNIT_SECONDS		(0x2 << KVM_STATS_UNIT_SHIFT) +#define KVM_STATS_UNIT_CYCLES		(0x3 << KVM_STATS_UNIT_SHIFT) +#define KVM_STATS_UNIT_MAX		KVM_STATS_UNIT_CYCLES + +#define KVM_STATS_BASE_SHIFT		8 +#define KVM_STATS_BASE_MASK		(0xF << KVM_STATS_BASE_SHIFT) +#define KVM_STATS_BASE_POW10		(0x0 << KVM_STATS_BASE_SHIFT) +#define KVM_STATS_BASE_POW2		(0x1 << KVM_STATS_BASE_SHIFT) +#define KVM_STATS_BASE_MAX		KVM_STATS_BASE_POW2 + +/** + * struct kvm_stats_desc - Descriptor of a KVM statistics. + * @flags: Annotations of the stats, like type, unit, etc. + * @exponent: Used together with @flags to determine the unit. + * @size: The number of data items for this stats. + *        Every data item is of type __u64. + * @offset: The offset of the stats to the start of stat structure in + *          struture kvm or kvm_vcpu. + * @unused: Unused field for future usage. Always 0 for now. + * @name: The name string for the stats. Its size is indicated by the + *        &kvm_stats_header->name_size. + */ +struct kvm_stats_desc { +	__u32 flags; +	__s16 exponent; +	__u16 size; +	__u32 offset; +	__u32 unused; +	char name[]; +}; + +#define KVM_GET_STATS_FD  _IO(KVMIO,  0xce) +  #endif /* __LINUX_KVM_H */ diff --git a/include/uapi/linux/kvm_para.h b/include/uapi/linux/kvm_para.h index 8b86609849b9..960c7e93d1a9 100644 --- a/include/uapi/linux/kvm_para.h +++ b/include/uapi/linux/kvm_para.h @@ -29,6 +29,7 @@  #define KVM_HC_CLOCK_PAIRING		9  #define KVM_HC_SEND_IPI		10  #define KVM_HC_SCHED_YIELD		11 +#define KVM_HC_MAP_GPA_RANGE		12  /*   * hypercalls use architecture specific |