Skip to content

Commit a625df3

Browse files
committed
tools/include: Sync uapi/linux/kvm.h with the kernel sources
And other arch-specific UAPI headers to pick up changes from: 4b23e0c KVM: Ensure new code that references immediate_exit gets extra scrutiny 85542ad KVM: x86: Add KVM_RUN_X86_GUEST_MODE kvm_run flag 6fef518 KVM: x86: Add a capability to configure bus frequency for APIC timer 34ff659 x86/sev: Use kernel provided SVSM Calling Areas 5dcc1e7 Merge tag 'kvm-x86-misc-6.11' of https://github.com/kvm-x86/linux into HEAD 9a0d2f4 KVM: PPC: Book3S HV: Add one-reg interface for HASHPKEYR register e9eb790 KVM: PPC: Book3S HV: Add one-reg interface for HASHKEYR register 1a1e686 KVM: PPC: Book3S HV: Add one-reg interface for DEXCR register This should be used to beautify KVM syscall arguments and it addresses these tools/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 diff -u tools/arch/x86/include/uapi/asm/svm.h arch/x86/include/uapi/asm/svm.h diff -u tools/arch/powerpc/include/uapi/asm/kvm.h arch/powerpc/include/uapi/asm/kvm.h Please see tools/include/uapi/README for details (it's in the first patch of this series). Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: kvm@vger.kernel.org Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent aef21f6 commit a625df3

4 files changed

Lines changed: 69 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,9 @@ struct kvm_ppc_cpu_char {
645645
#define KVM_REG_PPC_SIER3 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc3)
646646
#define KVM_REG_PPC_DAWR1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc4)
647647
#define KVM_REG_PPC_DAWRX1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc5)
648+
#define KVM_REG_PPC_DEXCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc6)
649+
#define KVM_REG_PPC_HASHKEYR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc7)
650+
#define KVM_REG_PPC_HASHPKEYR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc8)
648651

649652
/* Transactional Memory checkpointed state:
650653
* This is all GPRs, all VSX regs and a subset of SPRs

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ struct kvm_ioapic_state {
106106

107107
#define KVM_RUN_X86_SMM (1 << 0)
108108
#define KVM_RUN_X86_BUS_LOCK (1 << 1)
109+
#define KVM_RUN_X86_GUEST_MODE (1 << 2)
109110

110111
/* for KVM_GET_REGS and KVM_SET_REGS */
111112
struct kvm_regs {
@@ -697,6 +698,11 @@ enum sev_cmd_id {
697698
/* Second time is the charm; improved versions of the above ioctls. */
698699
KVM_SEV_INIT2,
699700

701+
/* SNP-specific commands */
702+
KVM_SEV_SNP_LAUNCH_START = 100,
703+
KVM_SEV_SNP_LAUNCH_UPDATE,
704+
KVM_SEV_SNP_LAUNCH_FINISH,
705+
700706
KVM_SEV_NR_MAX,
701707
};
702708

@@ -824,6 +830,48 @@ struct kvm_sev_receive_update_data {
824830
__u32 pad2;
825831
};
826832

833+
struct kvm_sev_snp_launch_start {
834+
__u64 policy;
835+
__u8 gosvw[16];
836+
__u16 flags;
837+
__u8 pad0[6];
838+
__u64 pad1[4];
839+
};
840+
841+
/* Kept in sync with firmware values for simplicity. */
842+
#define KVM_SEV_SNP_PAGE_TYPE_NORMAL 0x1
843+
#define KVM_SEV_SNP_PAGE_TYPE_ZERO 0x3
844+
#define KVM_SEV_SNP_PAGE_TYPE_UNMEASURED 0x4
845+
#define KVM_SEV_SNP_PAGE_TYPE_SECRETS 0x5
846+
#define KVM_SEV_SNP_PAGE_TYPE_CPUID 0x6
847+
848+
struct kvm_sev_snp_launch_update {
849+
__u64 gfn_start;
850+
__u64 uaddr;
851+
__u64 len;
852+
__u8 type;
853+
__u8 pad0;
854+
__u16 flags;
855+
__u32 pad1;
856+
__u64 pad2[4];
857+
};
858+
859+
#define KVM_SEV_SNP_ID_BLOCK_SIZE 96
860+
#define KVM_SEV_SNP_ID_AUTH_SIZE 4096
861+
#define KVM_SEV_SNP_FINISH_DATA_SIZE 32
862+
863+
struct kvm_sev_snp_launch_finish {
864+
__u64 id_block_uaddr;
865+
__u64 id_auth_uaddr;
866+
__u8 id_block_en;
867+
__u8 auth_key_en;
868+
__u8 vcek_disabled;
869+
__u8 host_data[KVM_SEV_SNP_FINISH_DATA_SIZE];
870+
__u8 pad0[3];
871+
__u16 flags;
872+
__u64 pad1[4];
873+
};
874+
827875
#define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)
828876
#define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1)
829877

@@ -874,5 +922,6 @@ struct kvm_hyperv_eventfd {
874922
#define KVM_X86_SW_PROTECTED_VM 1
875923
#define KVM_X86_SEV_VM 2
876924
#define KVM_X86_SEV_ES_VM 3
925+
#define KVM_X86_SNP_VM 4
877926

878927
#endif /* _ASM_X86_KVM_H */

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
#define SVM_VMGEXIT_AP_CREATE_ON_INIT 0
116116
#define SVM_VMGEXIT_AP_CREATE 1
117117
#define SVM_VMGEXIT_AP_DESTROY 2
118+
#define SVM_VMGEXIT_SNP_RUN_VMPL 0x80000018
118119
#define SVM_VMGEXIT_HV_FEATURES 0x8000fffd
119120
#define SVM_VMGEXIT_TERM_REQUEST 0x8000fffe
120121
#define SVM_VMGEXIT_TERM_REASON(reason_set, reason_code) \

tools/include/uapi/linux/kvm.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,24 @@ struct kvm_xen_exit {
192192
/* Flags that describe what fields in emulation_failure hold valid data. */
193193
#define KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES (1ULL << 0)
194194

195+
/*
196+
* struct kvm_run can be modified by userspace at any time, so KVM must be
197+
* careful to avoid TOCTOU bugs. In order to protect KVM, HINT_UNSAFE_IN_KVM()
198+
* renames fields in struct kvm_run from <symbol> to <symbol>__unsafe when
199+
* compiled into the kernel, ensuring that any use within KVM is obvious and
200+
* gets extra scrutiny.
201+
*/
202+
#ifdef __KERNEL__
203+
#define HINT_UNSAFE_IN_KVM(_symbol) _symbol##__unsafe
204+
#else
205+
#define HINT_UNSAFE_IN_KVM(_symbol) _symbol
206+
#endif
207+
195208
/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
196209
struct kvm_run {
197210
/* in */
198211
__u8 request_interrupt_window;
199-
__u8 immediate_exit;
212+
__u8 HINT_UNSAFE_IN_KVM(immediate_exit);
200213
__u8 padding1[6];
201214

202215
/* out */
@@ -918,6 +931,8 @@ struct kvm_enable_cap {
918931
#define KVM_CAP_GUEST_MEMFD 234
919932
#define KVM_CAP_VM_TYPES 235
920933
#define KVM_CAP_PRE_FAULT_MEMORY 236
934+
#define KVM_CAP_X86_APIC_BUS_CYCLES_NS 237
935+
#define KVM_CAP_X86_GUEST_MODE 238
921936

922937
struct kvm_irq_routing_irqchip {
923938
__u32 irqchip;

0 commit comments

Comments
 (0)