18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 28c2ecf20Sopenharmony_ci#ifndef _UAPI_ASM_X86_KVM_PARA_H 38c2ecf20Sopenharmony_ci#define _UAPI_ASM_X86_KVM_PARA_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/types.h> 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci/* This CPUID returns the signature 'KVMKVMKVM' in ebx, ecx, and edx. It 88c2ecf20Sopenharmony_ci * should be used to determine that a VM is running under KVM. 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci#define KVM_CPUID_SIGNATURE 0x40000000 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci/* This CPUID returns two feature bitmaps in eax, edx. Before enabling 138c2ecf20Sopenharmony_ci * a particular paravirtualization, the appropriate feature bit should 148c2ecf20Sopenharmony_ci * be checked in eax. The performance hint feature bit should be checked 158c2ecf20Sopenharmony_ci * in edx. 168c2ecf20Sopenharmony_ci */ 178c2ecf20Sopenharmony_ci#define KVM_CPUID_FEATURES 0x40000001 188c2ecf20Sopenharmony_ci#define KVM_FEATURE_CLOCKSOURCE 0 198c2ecf20Sopenharmony_ci#define KVM_FEATURE_NOP_IO_DELAY 1 208c2ecf20Sopenharmony_ci#define KVM_FEATURE_MMU_OP 2 218c2ecf20Sopenharmony_ci/* This indicates that the new set of kvmclock msrs 228c2ecf20Sopenharmony_ci * are available. The use of 0x11 and 0x12 is deprecated 238c2ecf20Sopenharmony_ci */ 248c2ecf20Sopenharmony_ci#define KVM_FEATURE_CLOCKSOURCE2 3 258c2ecf20Sopenharmony_ci#define KVM_FEATURE_ASYNC_PF 4 268c2ecf20Sopenharmony_ci#define KVM_FEATURE_STEAL_TIME 5 278c2ecf20Sopenharmony_ci#define KVM_FEATURE_PV_EOI 6 288c2ecf20Sopenharmony_ci#define KVM_FEATURE_PV_UNHALT 7 298c2ecf20Sopenharmony_ci#define KVM_FEATURE_PV_TLB_FLUSH 9 308c2ecf20Sopenharmony_ci#define KVM_FEATURE_ASYNC_PF_VMEXIT 10 318c2ecf20Sopenharmony_ci#define KVM_FEATURE_PV_SEND_IPI 11 328c2ecf20Sopenharmony_ci#define KVM_FEATURE_POLL_CONTROL 12 338c2ecf20Sopenharmony_ci#define KVM_FEATURE_PV_SCHED_YIELD 13 348c2ecf20Sopenharmony_ci#define KVM_FEATURE_ASYNC_PF_INT 14 358c2ecf20Sopenharmony_ci#define KVM_FEATURE_MSI_EXT_DEST_ID 15 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define KVM_HINTS_REALTIME 0 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/* The last 8 bits are used to indicate how to interpret the flags field 408c2ecf20Sopenharmony_ci * in pvclock structure. If no bits are set, all flags are ignored. 418c2ecf20Sopenharmony_ci */ 428c2ecf20Sopenharmony_ci#define KVM_FEATURE_CLOCKSOURCE_STABLE_BIT 24 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#define MSR_KVM_WALL_CLOCK 0x11 458c2ecf20Sopenharmony_ci#define MSR_KVM_SYSTEM_TIME 0x12 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#define KVM_MSR_ENABLED 1 488c2ecf20Sopenharmony_ci/* Custom MSRs falls in the range 0x4b564d00-0x4b564dff */ 498c2ecf20Sopenharmony_ci#define MSR_KVM_WALL_CLOCK_NEW 0x4b564d00 508c2ecf20Sopenharmony_ci#define MSR_KVM_SYSTEM_TIME_NEW 0x4b564d01 518c2ecf20Sopenharmony_ci#define MSR_KVM_ASYNC_PF_EN 0x4b564d02 528c2ecf20Sopenharmony_ci#define MSR_KVM_STEAL_TIME 0x4b564d03 538c2ecf20Sopenharmony_ci#define MSR_KVM_PV_EOI_EN 0x4b564d04 548c2ecf20Sopenharmony_ci#define MSR_KVM_POLL_CONTROL 0x4b564d05 558c2ecf20Sopenharmony_ci#define MSR_KVM_ASYNC_PF_INT 0x4b564d06 568c2ecf20Sopenharmony_ci#define MSR_KVM_ASYNC_PF_ACK 0x4b564d07 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistruct kvm_steal_time { 598c2ecf20Sopenharmony_ci __u64 steal; 608c2ecf20Sopenharmony_ci __u32 version; 618c2ecf20Sopenharmony_ci __u32 flags; 628c2ecf20Sopenharmony_ci __u8 preempted; 638c2ecf20Sopenharmony_ci __u8 u8_pad[3]; 648c2ecf20Sopenharmony_ci __u32 pad[11]; 658c2ecf20Sopenharmony_ci}; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#define KVM_VCPU_PREEMPTED (1 << 0) 688c2ecf20Sopenharmony_ci#define KVM_VCPU_FLUSH_TLB (1 << 1) 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define KVM_CLOCK_PAIRING_WALLCLOCK 0 718c2ecf20Sopenharmony_cistruct kvm_clock_pairing { 728c2ecf20Sopenharmony_ci __s64 sec; 738c2ecf20Sopenharmony_ci __s64 nsec; 748c2ecf20Sopenharmony_ci __u64 tsc; 758c2ecf20Sopenharmony_ci __u32 flags; 768c2ecf20Sopenharmony_ci __u32 pad[9]; 778c2ecf20Sopenharmony_ci}; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci#define KVM_STEAL_ALIGNMENT_BITS 5 808c2ecf20Sopenharmony_ci#define KVM_STEAL_VALID_BITS ((-1ULL << (KVM_STEAL_ALIGNMENT_BITS + 1))) 818c2ecf20Sopenharmony_ci#define KVM_STEAL_RESERVED_MASK (((1 << KVM_STEAL_ALIGNMENT_BITS) - 1 ) << 1) 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#define KVM_MAX_MMU_OP_BATCH 32 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci#define KVM_ASYNC_PF_ENABLED (1 << 0) 868c2ecf20Sopenharmony_ci#define KVM_ASYNC_PF_SEND_ALWAYS (1 << 1) 878c2ecf20Sopenharmony_ci#define KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT (1 << 2) 888c2ecf20Sopenharmony_ci#define KVM_ASYNC_PF_DELIVERY_AS_INT (1 << 3) 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci/* MSR_KVM_ASYNC_PF_INT */ 918c2ecf20Sopenharmony_ci#define KVM_ASYNC_PF_VEC_MASK GENMASK(7, 0) 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci/* Operations for KVM_HC_MMU_OP */ 958c2ecf20Sopenharmony_ci#define KVM_MMU_OP_WRITE_PTE 1 968c2ecf20Sopenharmony_ci#define KVM_MMU_OP_FLUSH_TLB 2 978c2ecf20Sopenharmony_ci#define KVM_MMU_OP_RELEASE_PT 3 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci/* Payload for KVM_HC_MMU_OP */ 1008c2ecf20Sopenharmony_cistruct kvm_mmu_op_header { 1018c2ecf20Sopenharmony_ci __u32 op; 1028c2ecf20Sopenharmony_ci __u32 pad; 1038c2ecf20Sopenharmony_ci}; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_cistruct kvm_mmu_op_write_pte { 1068c2ecf20Sopenharmony_ci struct kvm_mmu_op_header header; 1078c2ecf20Sopenharmony_ci __u64 pte_phys; 1088c2ecf20Sopenharmony_ci __u64 pte_val; 1098c2ecf20Sopenharmony_ci}; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_cistruct kvm_mmu_op_flush_tlb { 1128c2ecf20Sopenharmony_ci struct kvm_mmu_op_header header; 1138c2ecf20Sopenharmony_ci}; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_cistruct kvm_mmu_op_release_pt { 1168c2ecf20Sopenharmony_ci struct kvm_mmu_op_header header; 1178c2ecf20Sopenharmony_ci __u64 pt_phys; 1188c2ecf20Sopenharmony_ci}; 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci#define KVM_PV_REASON_PAGE_NOT_PRESENT 1 1218c2ecf20Sopenharmony_ci#define KVM_PV_REASON_PAGE_READY 2 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_cistruct kvm_vcpu_pv_apf_data { 1248c2ecf20Sopenharmony_ci /* Used for 'page not present' events delivered via #PF */ 1258c2ecf20Sopenharmony_ci __u32 flags; 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci /* Used for 'page ready' events delivered via interrupt notification */ 1288c2ecf20Sopenharmony_ci __u32 token; 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci __u8 pad[56]; 1318c2ecf20Sopenharmony_ci __u32 enabled; 1328c2ecf20Sopenharmony_ci}; 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci#define KVM_PV_EOI_BIT 0 1358c2ecf20Sopenharmony_ci#define KVM_PV_EOI_MASK (0x1 << KVM_PV_EOI_BIT) 1368c2ecf20Sopenharmony_ci#define KVM_PV_EOI_ENABLED KVM_PV_EOI_MASK 1378c2ecf20Sopenharmony_ci#define KVM_PV_EOI_DISABLED 0x0 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci#endif /* _UAPI_ASM_X86_KVM_PARA_H */ 140