/* * The bit 0 ~ bit 15 of kvm_userspace_memory_region::flags are visible for * userspace, other bits are reserved for kvm internal use which are defined * in include/linux/kvm_host.h.
*/ #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) #define KVM_MEM_READONLY (1UL << 1) #define KVM_MEM_GUEST_MEMFD (1UL << 2)
/* for KVM_IRQ_LINE */ struct kvm_irq_level { /* * ACPI gsi notion of irq. * For IA-64 (APIC model) IOAPIC0: irq 0-23; IOAPIC1: irq 24-47.. * For X86 (standard AT mode) PIC0/1: irq 0-15. IOAPIC0: 0-23.. * For ARM: See Documentation/virt/kvm/api.rst
*/ union {
__u32 irq;
__s32 status;
};
__u32 level;
};
/* Flags that describe what fields in emulation_failure hold valid data. */ #define KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES (1ULL << 0)
/* * struct kvm_run can be modified by userspace at any time, so KVM must be * careful to avoid TOCTOU bugs. In order to protect KVM, HINT_UNSAFE_IN_KVM() * renames fields in struct kvm_run from <symbol> to <symbol>__unsafe when * compiled into the kernel, ensuring that any use within KVM is obvious and * gets extra scrutiny.
*/ #ifdef __KERNEL__ #define HINT_UNSAFE_IN_KVM(_symbol) _symbol##__unsafe #else #define HINT_UNSAFE_IN_KVM(_symbol) _symbol #endif
/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ struct kvm_run { /* in */
__u8 request_interrupt_window;
__u8 HINT_UNSAFE_IN_KVM(immediate_exit);
__u8 padding1[6];
union { #ifndef __KERNEL__
__u32 longmode; #endif
__u64 flags;
};
} hypercall; /* KVM_EXIT_TPR_ACCESS */ struct {
__u64 rip;
__u32 is_write;
__u32 pad;
} tpr_access; /* KVM_EXIT_S390_SIEIC */ struct {
__u8 icptcode;
__u16 ipa;
__u32 ipb;
} s390_sieic; /* KVM_EXIT_S390_RESET */
__u64 s390_reset_flags; /* KVM_EXIT_S390_UCONTROL */ struct {
__u64 trans_exc_code;
__u32 pgm_code;
} s390_ucontrol; /* KVM_EXIT_DCR (deprecated) */ struct {
__u32 dcrn;
__u32 data;
__u8 is_write;
} dcr; /* KVM_EXIT_INTERNAL_ERROR */ struct {
__u32 suberror; /* Available with KVM_CAP_INTERNAL_ERROR_DATA: */
__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). * * Space beyond the defined fields may be used to store arbitrary * debug information relating to the emulation failure. It is * accounted for in "ndata" but the format is unspecified and is * not represented in "flags". Any such information is *not* ABI!
*/ struct {
__u32 suberror;
__u32 ndata;
__u64 flags; union { struct {
__u8 insn_size;
__u8 insn_bytes[15];
};
}; /* Arbitrary debug data may follow. */
} emulation_failure; /* KVM_EXIT_OSI */ struct {
__u64 gprs[32];
} osi; /* KVM_EXIT_PAPR_HCALL */ struct {
__u64 nr;
__u64 ret;
__u64 args[9];
} papr_hcall; /* KVM_EXIT_S390_TSCH */ struct {
__u16 subchannel_id;
__u16 subchannel_nr;
__u32 io_int_parm;
__u32 io_int_word;
__u32 ipb;
__u8 dequeued;
} s390_tsch; /* KVM_EXIT_EPR */ struct {
__u32 epr;
} epr; /* KVM_EXIT_SYSTEM_EVENT */ struct { #define KVM_SYSTEM_EVENT_SHUTDOWN 1 #define KVM_SYSTEM_EVENT_RESET 2 #define KVM_SYSTEM_EVENT_CRASH 3 #define KVM_SYSTEM_EVENT_WAKEUP 4 #define KVM_SYSTEM_EVENT_SUSPEND 5 #define KVM_SYSTEM_EVENT_SEV_TERM 6 #define KVM_SYSTEM_EVENT_TDX_FATAL 7
__u32 type;
__u32 ndata; union { #ifndef __KERNEL__
__u64 flags; #endif
__u64 data[16];
};
} system_event; /* KVM_EXIT_S390_STSI */ struct {
__u64 addr;
__u8 ar;
__u8 reserved;
__u8 fc;
__u8 sel1;
__u16 sel2;
} s390_stsi; /* KVM_EXIT_IOAPIC_EOI */ struct {
__u8 vector;
} eoi; /* KVM_EXIT_HYPERV */ struct kvm_hyperv_exit hyperv; /* KVM_EXIT_ARM_NISV */ struct {
__u64 esr_iss;
__u64 fault_ipa;
} arm_nisv; /* KVM_EXIT_X86_RDMSR / KVM_EXIT_X86_WRMSR */ struct {
__u8 error; /* user -> kernel */
__u8 pad[7]; #define KVM_MSR_EXIT_REASON_INVAL (1 << 0) #define KVM_MSR_EXIT_REASON_UNKNOWN (1 << 1) #define KVM_MSR_EXIT_REASON_FILTER (1 << 2) #define KVM_MSR_EXIT_REASON_VALID_MASK (KVM_MSR_EXIT_REASON_INVAL | \
KVM_MSR_EXIT_REASON_UNKNOWN | \
KVM_MSR_EXIT_REASON_FILTER)
__u32 reason; /* kernel -> user */
__u32 index; /* kernel -> user */
__u64 data; /* kernel <-> user */
} msr; /* KVM_EXIT_XEN */ struct kvm_xen_exit xen; /* KVM_EXIT_RISCV_SBI */ struct { unsignedlong extension_id; unsignedlong function_id; unsignedlong args[6]; unsignedlong ret[2];
} riscv_sbi; /* KVM_EXIT_RISCV_CSR */ struct { unsignedlong csr_num; unsignedlong new_value; unsignedlong write_mask; unsignedlong ret_value;
} riscv_csr; /* KVM_EXIT_NOTIFY */ struct { #define KVM_NOTIFY_CONTEXT_INVALID (1 << 0)
__u32 flags;
} notify; /* KVM_EXIT_MEMORY_FAULT */ struct { #define KVM_MEMORY_EXIT_FLAG_PRIVATE (1ULL << 3)
__u64 flags;
__u64 gpa;
__u64 size;
} memory_fault; /* KVM_EXIT_TDX */ struct {
__u64 flags;
__u64 nr; union { struct {
__u64 ret;
__u64 data[5];
} unknown; struct {
__u64 ret;
__u64 gpa;
__u64 size;
} get_quote; struct {
__u64 ret;
__u64 leaf;
__u64 r11, r12, r13, r14;
} get_tdvmcall_info; struct {
__u64 ret;
__u64 vector;
} setup_event_notify;
};
} tdx; /* Fix the size of the union. */ char padding[256];
};
/* 2048 is the size of the char array used to bound/pad the size * of the union that holds sync regs.
*/ #define SYNC_REGS_SIZE_BYTES 2048 /* * shared registers between kvm and userspace. * kvm_valid_regs specifies the register classes set by the host * kvm_dirty_regs specified the register classes dirtied by userspace * struct kvm_sync_regs is architecture specific, as well as the * bits for kvm_valid_regs and kvm_dirty_regs
*/
__u64 kvm_valid_regs;
__u64 kvm_dirty_regs; union { struct kvm_sync_regs regs; char padding[SYNC_REGS_SIZE_BYTES];
} s;
};
/* for KVM_REGISTER_COALESCED_MMIO / KVM_UNREGISTER_COALESCED_MMIO */
/* * On arm64, machine type can be used to request the physical * address size for the VM. Bits[7-0] are reserved for the guest * PA size shift (i.e, log2(PA_Size)). For backward compatibility, * value 0 implies the default IPA size, 40bits.
*/ #define KVM_VM_TYPE_ARM_IPA_SIZE_MASK 0xffULL #define KVM_VM_TYPE_ARM_IPA_SIZE(x) \
((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK) /* * ioctls for /dev/kvm fds:
*/ #define KVM_GET_API_VERSION _IO(KVMIO, 0x00) #define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */ #define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list)
#define KVM_S390_ENABLE_SIE _IO(KVMIO, 0x06) /* * Check if a kvm extension is available. Argument is extension number, * return is 1 (yes) or 0 (no, sorry).
*/ #define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03) /* * Get size for mmap(vcpu_fd)
*/ #define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ #define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2) #define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2) #define KVM_GET_MSR_FEATURE_INDEX_LIST _IOWR(KVMIO, 0x0a, struct kvm_msr_list)
#define KVM_IRQFD_FLAG_DEASSIGN (1 << 0) /* * Available with KVM_CAP_IRQFD_RESAMPLE * * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies * the irqfd to operate in resampling mode for level triggered interrupt * emulation. See Documentation/virt/kvm/api.rst.
*/ #define KVM_IRQFD_FLAG_RESAMPLE (1 << 1)
/* Do not use 1, KVM_CHECK_EXTENSION returned it before we had flags. */ #define KVM_CLOCK_TSC_STABLE 2 #define KVM_CLOCK_REALTIME (1 << 2) #define KVM_CLOCK_HOST_TSC (1 << 3)
/* * Arch needs to define the macro after implementing the dirty ring * feature. KVM_DIRTY_LOG_PAGE_OFFSET should be defined as the * starting page offset of the dirty ring structures.
*/ #ifndef KVM_DIRTY_LOG_PAGE_OFFSET #define KVM_DIRTY_LOG_PAGE_OFFSET 0 #endif
/* * KVM dirty GFN flags, defined as: * * |---------------+---------------+--------------| * | bit 1 (reset) | bit 0 (dirty) | Status | * |---------------+---------------+--------------| * | 0 | 0 | Invalid GFN | * | 0 | 1 | Dirty GFN | * | 1 | X | GFN to reset | * |---------------+---------------+--------------| * * Lifecycle of a dirty GFN goes like: * * dirtied harvested reset * 00 -----------> 01 -------------> 1X -------+ * ^ | * | | * +------------------------------------------+ * * The userspace program is only responsible for the 01->1X state * conversion after harvesting an entry. Also, it must not skip any * dirty bits, so that dirty bits are always harvested in sequence.
*/ #define KVM_DIRTY_GFN_F_DIRTY _BITUL(0) #define KVM_DIRTY_GFN_F_RESET _BITUL(1) #define KVM_DIRTY_GFN_F_MASK 0x3
/* * KVM dirty rings should be mapped at KVM_DIRTY_LOG_PAGE_OFFSET of * per-vcpu mmaped regions as an array of struct kvm_dirty_gfn. The * size of the gfn buffer is decided by the first argument when * enabling KVM_CAP_DIRTY_LOG_RING.
*/ struct kvm_dirty_gfn {
__u32 flags;
__u32 slot;
__u64 offset;
};
/** * 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;
};
/** * 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 * structure kvm or kvm_vcpu. * @bucket_size: A parameter value used for histogram stats. It is only used * for linear histogram stats, specifying the size of the bucket; * @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 bucket_size; char name[];
};
#define KVM_GET_STATS_FD _IO(KVMIO, 0xce)
/* Available with KVM_CAP_XSAVE2 */ #define KVM_GET_XSAVE2 _IOR(KVMIO, 0xcf, struct kvm_xsave)
/* Available with KVM_CAP_S390_PROTECTED_DUMP */ #define KVM_S390_PV_CPU_COMMAND _IOWR(KVMIO, 0xd0, struct kvm_pv_cmd)
/* Available with KVM_CAP_X86_NOTIFY_VMEXIT */ #define KVM_X86_NOTIFY_VMEXIT_ENABLED (1ULL << 0) #define KVM_X86_NOTIFY_VMEXIT_USER (1ULL << 1)
/* Available with KVM_CAP_S390_ZPCI_OP */ #define KVM_S390_ZPCI_OP _IOW(KVMIO, 0xd1, struct kvm_s390_zpci_op)
/* Available with KVM_CAP_MEMORY_ATTRIBUTES */ #define KVM_SET_MEMORY_ATTRIBUTES _IOW(KVMIO, 0xd2, struct kvm_memory_attributes)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.