1 #ifndef KVM__KVM_CPU_ARCH_H
2 #define KVM__KVM_CPU_ARCH_H
3
4 /* Architecture-specific kvm_cpu definitions. */
5
6 #include <linux/kvm.h> /* for struct kvm_regs */
7 #include "kvm/kvm.h" /* for kvm__emulate_{mm}io() */
8 #include <stdbool.h>
9 #include <pthread.h>
10
11 struct kvm;
12
13 struct kvm_cpu {
14 pthread_t thread; /* VCPU thread */
15
16 unsigned long cpu_id;
17
18 struct kvm *kvm; /* parent KVM */
19 int vcpu_fd; /* For VCPU ioctls() */
20 struct kvm_run *kvm_run;
21 struct kvm_cpu_task *task;
22
23 struct kvm_regs regs;
24 struct kvm_sregs sregs;
25 struct kvm_fpu fpu;
26
27 struct kvm_msrs *msrs; /* dynamically allocated */
28
29 u8 is_running;
30 u8 paused;
31 u8 needs_nmi;
32
33 struct kvm_coalesced_mmio_ring *ring;
34 };
35
36 /*
37 * As these are such simple wrappers, let's have them in the header so they'll
38 * be cheaper to call:
39 */
kvm_cpu__emulate_io(struct kvm_cpu * vcpu,u16 port,void * data,int direction,int size,u32 count)40 static inline bool kvm_cpu__emulate_io(struct kvm_cpu *vcpu, u16 port, void *data, int direction, int size, u32 count)
41 {
42 return kvm__emulate_io(vcpu, port, data, direction, size, count);
43 }
44
kvm_cpu__emulate_mmio(struct kvm_cpu * vcpu,u64 phys_addr,u8 * data,u32 len,u8 is_write)45 static inline bool kvm_cpu__emulate_mmio(struct kvm_cpu *vcpu, u64 phys_addr, u8 *data, u32 len, u8 is_write)
46 {
47 return kvm__emulate_mmio(vcpu, phys_addr, data, len, is_write);
48 }
49
50 #endif /* KVM__KVM_CPU_ARCH_H */
51