xref: /kvmtool/arm/include/arm-common/kvm-cpu-arch.h (revision 7c0e8b0c5560ce2f500fa4d7ba7865e7360e7991)
1*7c0e8b0cSWill Deacon #ifndef ARM_COMMON__KVM_CPU_ARCH_H
2*7c0e8b0cSWill Deacon #define ARM_COMMON__KVM_CPU_ARCH_H
3*7c0e8b0cSWill Deacon 
4*7c0e8b0cSWill Deacon #include <linux/kvm.h>
5*7c0e8b0cSWill Deacon #include <pthread.h>
6*7c0e8b0cSWill Deacon #include <stdbool.h>
7*7c0e8b0cSWill Deacon 
8*7c0e8b0cSWill Deacon struct kvm;
9*7c0e8b0cSWill Deacon 
10*7c0e8b0cSWill Deacon struct kvm_cpu {
11*7c0e8b0cSWill Deacon 	pthread_t	thread;
12*7c0e8b0cSWill Deacon 
13*7c0e8b0cSWill Deacon 	unsigned long	cpu_id;
14*7c0e8b0cSWill Deacon 	unsigned long	cpu_type;
15*7c0e8b0cSWill Deacon 
16*7c0e8b0cSWill Deacon 	struct kvm	*kvm;
17*7c0e8b0cSWill Deacon 	int		vcpu_fd;
18*7c0e8b0cSWill Deacon 	struct kvm_run	*kvm_run;
19*7c0e8b0cSWill Deacon 
20*7c0e8b0cSWill Deacon 	u8		is_running;
21*7c0e8b0cSWill Deacon 	u8		paused;
22*7c0e8b0cSWill Deacon 	u8		needs_nmi;
23*7c0e8b0cSWill Deacon 
24*7c0e8b0cSWill Deacon 	struct kvm_coalesced_mmio_ring	*ring;
25*7c0e8b0cSWill Deacon 
26*7c0e8b0cSWill Deacon 	void		(*generate_fdt_nodes)(void *fdt, struct kvm* kvm,
27*7c0e8b0cSWill Deacon 					      u32 gic_phandle);
28*7c0e8b0cSWill Deacon };
29*7c0e8b0cSWill Deacon 
30*7c0e8b0cSWill Deacon struct kvm_arm_target {
31*7c0e8b0cSWill Deacon 	u32	id;
32*7c0e8b0cSWill Deacon 	int	(*init)(struct kvm_cpu *vcpu);
33*7c0e8b0cSWill Deacon };
34*7c0e8b0cSWill Deacon 
35*7c0e8b0cSWill Deacon int kvm_cpu__register_kvm_arm_target(struct kvm_arm_target *target);
36*7c0e8b0cSWill Deacon 
37*7c0e8b0cSWill Deacon static inline bool kvm_cpu__emulate_io(struct kvm *kvm, u16 port, void *data,
38*7c0e8b0cSWill Deacon 				       int direction, int size, u32 count)
39*7c0e8b0cSWill Deacon {
40*7c0e8b0cSWill Deacon 	return false;
41*7c0e8b0cSWill Deacon }
42*7c0e8b0cSWill Deacon 
43*7c0e8b0cSWill Deacon bool kvm_cpu__emulate_mmio(struct kvm *kvm, u64 phys_addr, u8 *data, u32 len,
44*7c0e8b0cSWill Deacon 			   u8 is_write);
45*7c0e8b0cSWill Deacon 
46*7c0e8b0cSWill Deacon #endif /* ARM_COMMON__KVM_CPU_ARCH_H */
47