aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kvm.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/kvm.h')
-rw-r--r--include/linux/kvm.h127
1 files changed, 91 insertions, 36 deletions
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 3db5d8d37485..f8f8900fc5ec 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -14,7 +14,7 @@
14 14
15#define KVM_API_VERSION 12 15#define KVM_API_VERSION 12
16 16
17/* for KVM_TRACE_ENABLE */ 17/* for KVM_TRACE_ENABLE, deprecated */
18struct kvm_user_trace_setup { 18struct kvm_user_trace_setup {
19 __u32 buf_size; /* sub_buffer size of each per-cpu */ 19 __u32 buf_size; /* sub_buffer size of each per-cpu */
20 __u32 buf_nr; /* the number of sub_buffers of each per-cpu */ 20 __u32 buf_nr; /* the number of sub_buffers of each per-cpu */
@@ -70,6 +70,14 @@ struct kvm_irqchip {
70 } chip; 70 } chip;
71}; 71};
72 72
73/* for KVM_CREATE_PIT2 */
74struct kvm_pit_config {
75 __u32 flags;
76 __u32 pad[15];
77};
78
79#define KVM_PIT_SPEAKER_DUMMY 1
80
73#define KVM_EXIT_UNKNOWN 0 81#define KVM_EXIT_UNKNOWN 0
74#define KVM_EXIT_EXCEPTION 1 82#define KVM_EXIT_EXCEPTION 1
75#define KVM_EXIT_IO 2 83#define KVM_EXIT_IO 2
@@ -87,6 +95,10 @@ struct kvm_irqchip {
87#define KVM_EXIT_S390_RESET 14 95#define KVM_EXIT_S390_RESET 14
88#define KVM_EXIT_DCR 15 96#define KVM_EXIT_DCR 15
89#define KVM_EXIT_NMI 16 97#define KVM_EXIT_NMI 16
98#define KVM_EXIT_INTERNAL_ERROR 17
99
100/* For KVM_EXIT_INTERNAL_ERROR */
101#define KVM_INTERNAL_ERROR_EMULATION 1
90 102
91/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ 103/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
92struct kvm_run { 104struct kvm_run {
@@ -173,6 +185,9 @@ struct kvm_run {
173 __u32 data; 185 __u32 data;
174 __u8 is_write; 186 __u8 is_write;
175 } dcr; 187 } dcr;
188 struct {
189 __u32 suberror;
190 } internal;
176 /* Fix the size of the union. */ 191 /* Fix the size of the union. */
177 char padding[256]; 192 char padding[256];
178 }; 193 };
@@ -292,6 +307,28 @@ struct kvm_guest_debug {
292 struct kvm_guest_debug_arch arch; 307 struct kvm_guest_debug_arch arch;
293}; 308};
294 309
310enum {
311 kvm_ioeventfd_flag_nr_datamatch,
312 kvm_ioeventfd_flag_nr_pio,
313 kvm_ioeventfd_flag_nr_deassign,
314 kvm_ioeventfd_flag_nr_max,
315};
316
317#define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch)
318#define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio)
319#define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign)
320
321#define KVM_IOEVENTFD_VALID_FLAG_MASK ((1 << kvm_ioeventfd_flag_nr_max) - 1)
322
323struct kvm_ioeventfd {
324 __u64 datamatch;
325 __u64 addr; /* legal pio/mmio address */
326 __u32 len; /* 1, 2, 4, or 8 bytes */
327 __s32 fd;
328 __u32 flags;
329 __u8 pad[36];
330};
331
295#define KVM_TRC_SHIFT 16 332#define KVM_TRC_SHIFT 16
296/* 333/*
297 * kvm trace categories 334 * kvm trace categories
@@ -310,35 +347,6 @@ struct kvm_guest_debug {
310#define KVM_TRC_CYCLE_SIZE 8 347#define KVM_TRC_CYCLE_SIZE 8
311#define KVM_TRC_EXTRA_MAX 7 348#define KVM_TRC_EXTRA_MAX 7
312 349
313/* This structure represents a single trace buffer record. */
314struct kvm_trace_rec {
315 /* variable rec_val
316 * is split into:
317 * bits 0 - 27 -> event id
318 * bits 28 -30 -> number of extra data args of size u32
319 * bits 31 -> binary indicator for if tsc is in record
320 */
321 __u32 rec_val;
322 __u32 pid;
323 __u32 vcpu_id;
324 union {
325 struct {
326 __u64 timestamp;
327 __u32 extra_u32[KVM_TRC_EXTRA_MAX];
328 } __attribute__((packed)) timestamp;
329 struct {
330 __u32 extra_u32[KVM_TRC_EXTRA_MAX];
331 } notimestamp;
332 } u;
333};
334
335#define TRACE_REC_EVENT_ID(val) \
336 (0x0fffffff & (val))
337#define TRACE_REC_NUM_DATA_ARGS(val) \
338 (0x70000000 & ((val) << 28))
339#define TRACE_REC_TCS(val) \
340 (0x80000000 & ((val) << 31))
341
342#define KVMIO 0xAE 350#define KVMIO 0xAE
343 351
344/* 352/*
@@ -415,6 +423,19 @@ struct kvm_trace_rec {
415#define KVM_CAP_ASSIGN_DEV_IRQ 29 423#define KVM_CAP_ASSIGN_DEV_IRQ 29
416/* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */ 424/* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */
417#define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30 425#define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30
426#ifdef __KVM_HAVE_MCE
427#define KVM_CAP_MCE 31
428#endif
429#define KVM_CAP_IRQFD 32
430#ifdef __KVM_HAVE_PIT
431#define KVM_CAP_PIT2 33
432#endif
433#define KVM_CAP_SET_BOOT_CPU_ID 34
434#ifdef __KVM_HAVE_PIT_STATE2
435#define KVM_CAP_PIT_STATE2 35
436#endif
437#define KVM_CAP_IOEVENTFD 36
438#define KVM_CAP_SET_IDENTITY_MAP_ADDR 37
418 439
419#ifdef KVM_CAP_IRQ_ROUTING 440#ifdef KVM_CAP_IRQ_ROUTING
420 441
@@ -454,15 +475,32 @@ struct kvm_irq_routing {
454 475
455#endif 476#endif
456 477
478#ifdef KVM_CAP_MCE
479/* x86 MCE */
480struct kvm_x86_mce {
481 __u64 status;
482 __u64 addr;
483 __u64 misc;
484 __u64 mcg_status;
485 __u8 bank;
486 __u8 pad1[7];
487 __u64 pad2[3];
488};
489#endif
490
491#define KVM_IRQFD_FLAG_DEASSIGN (1 << 0)
492
493struct kvm_irqfd {
494 __u32 fd;
495 __u32 gsi;
496 __u32 flags;
497 __u8 pad[20];
498};
499
457/* 500/*
458 * ioctls for VM fds 501 * ioctls for VM fds
459 */ 502 */
460#define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region) 503#define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region)
461#define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44)
462#define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45)
463#define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46,\
464 struct kvm_userspace_memory_region)
465#define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47)
466/* 504/*
467 * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns 505 * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns
468 * a vcpu fd. 506 * a vcpu fd.
@@ -470,6 +508,12 @@ struct kvm_irq_routing {
470#define KVM_CREATE_VCPU _IO(KVMIO, 0x41) 508#define KVM_CREATE_VCPU _IO(KVMIO, 0x41)
471#define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) 509#define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log)
472#define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias) 510#define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias)
511#define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44)
512#define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45)
513#define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46,\
514 struct kvm_userspace_memory_region)
515#define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47)
516#define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64)
473/* Device model IOC */ 517/* Device model IOC */
474#define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) 518#define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60)
475#define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) 519#define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level)
@@ -498,6 +542,10 @@ struct kvm_irq_routing {
498#define KVM_ASSIGN_SET_MSIX_ENTRY \ 542#define KVM_ASSIGN_SET_MSIX_ENTRY \
499 _IOW(KVMIO, 0x74, struct kvm_assigned_msix_entry) 543 _IOW(KVMIO, 0x74, struct kvm_assigned_msix_entry)
500#define KVM_DEASSIGN_DEV_IRQ _IOW(KVMIO, 0x75, struct kvm_assigned_irq) 544#define KVM_DEASSIGN_DEV_IRQ _IOW(KVMIO, 0x75, struct kvm_assigned_irq)
545#define KVM_IRQFD _IOW(KVMIO, 0x76, struct kvm_irqfd)
546#define KVM_CREATE_PIT2 _IOW(KVMIO, 0x77, struct kvm_pit_config)
547#define KVM_SET_BOOT_CPU_ID _IO(KVMIO, 0x78)
548#define KVM_IOEVENTFD _IOW(KVMIO, 0x79, struct kvm_ioeventfd)
501 549
502/* 550/*
503 * ioctls for vcpu fds 551 * ioctls for vcpu fds
@@ -541,6 +589,10 @@ struct kvm_irq_routing {
541#define KVM_NMI _IO(KVMIO, 0x9a) 589#define KVM_NMI _IO(KVMIO, 0x9a)
542/* Available with KVM_CAP_SET_GUEST_DEBUG */ 590/* Available with KVM_CAP_SET_GUEST_DEBUG */
543#define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug) 591#define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug)
592/* MCE for x86 */
593#define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, __u64)
594#define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, __u64)
595#define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce)
544 596
545/* 597/*
546 * Deprecated interfaces 598 * Deprecated interfaces
@@ -563,6 +615,9 @@ struct kvm_debug_guest {
563#define KVM_IA64_VCPU_GET_STACK _IOR(KVMIO, 0x9a, void *) 615#define KVM_IA64_VCPU_GET_STACK _IOR(KVMIO, 0x9a, void *)
564#define KVM_IA64_VCPU_SET_STACK _IOW(KVMIO, 0x9b, void *) 616#define KVM_IA64_VCPU_SET_STACK _IOW(KVMIO, 0x9b, void *)
565 617
618#define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2)
619#define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2)
620
566#define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02) 621#define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02)
567#define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03) 622#define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03)
568#define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04) 623#define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04)
@@ -633,7 +688,7 @@ struct kvm_assigned_msix_nr {
633 __u16 padding; 688 __u16 padding;
634}; 689};
635 690
636#define KVM_MAX_MSIX_PER_DEV 512 691#define KVM_MAX_MSIX_PER_DEV 256
637struct kvm_assigned_msix_entry { 692struct kvm_assigned_msix_entry {
638 __u32 assigned_dev_id; 693 __u32 assigned_dev_id;
639 __u32 gsi; 694 __u32 gsi;