xref: /kvmtool/powerpc/include/kvm/kvm-cpu-arch.h (revision 015785d4efcc6fde5f6d1c79e4adced42283efb2)
1 /*
2  * PPC64 cpu-specific definitions
3  *
4  * Copyright 2011 Matt Evans <matt@ozlabs.org>, IBM Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License version 2 as published
8  * by the Free Software Foundation.
9  */
10 
11 #ifndef KVM__KVM_CPU_ARCH_H
12 #define KVM__KVM_CPU_ARCH_H
13 
14 /* Architecture-specific kvm_cpu definitions. */
15 
16 #include <linux/kvm.h>	/* for struct kvm_regs */
17 #include <stdbool.h>
18 #include <pthread.h>
19 
20 #define MSR_SF		(1ULL<<63)
21 #define MSR_HV		(1ULL<<60)
22 #define MSR_VEC		(1ULL<<25)
23 #define MSR_VSX		(1ULL<<23)
24 #define MSR_POW		(1ULL<<18)
25 #define MSR_EE		(1ULL<<15)
26 #define MSR_PR		(1ULL<<14)
27 #define MSR_FP		(1ULL<<13)
28 #define MSR_ME		(1ULL<<12)
29 #define MSR_FE0		(1ULL<<11)
30 #define MSR_SE		(1ULL<<10)
31 #define MSR_BE		(1ULL<<9)
32 #define MSR_FE1		(1ULL<<8)
33 #define MSR_IR		(1ULL<<5)
34 #define MSR_DR		(1ULL<<4)
35 #define MSR_PMM		(1ULL<<2)
36 #define MSR_RI		(1ULL<<1)
37 #define MSR_LE		(1ULL<<0)
38 
39 #define POWER7_EXT_IRQ	0
40 
41 #define LPCR_ILE	(1 << (63-38))
42 
43 struct kvm;
44 
45 struct kvm_cpu {
46 	pthread_t		thread;		/* VCPU thread */
47 
48 	unsigned long		cpu_id;
49 
50 	struct kvm		*kvm;		/* parent KVM */
51 	int			vcpu_fd;	/* For VCPU ioctls() */
52 	struct kvm_run		*kvm_run;
53 	struct kvm_cpu_task	*task;
54 
55 	struct kvm_regs		regs;
56 	struct kvm_sregs	sregs;
57 	struct kvm_fpu		fpu;
58 
59 	u8			is_running;
60 	u8			paused;
61 	u8			needs_nmi;
62 	/*
63 	 * Although PPC KVM doesn't yet support coalesced MMIO, generic code
64 	 * needs this in our kvm_cpu:
65 	 */
66 	struct kvm_coalesced_mmio_ring  *ring;
67 };
68 
69 void kvm_cpu__irq(struct kvm_cpu *vcpu, int pin, int level);
70 
71 /* This is never actually called on PPC. */
kvm_cpu__emulate_io(struct kvm_cpu * vcpu,u16 port,void * data,int direction,int size,u32 count)72 static inline bool kvm_cpu__emulate_io(struct kvm_cpu *vcpu, u16 port, void *data, int direction, int size, u32 count)
73 {
74 	return false;
75 }
76 
77 bool kvm_cpu__emulate_mmio(struct kvm_cpu *vcpu, u64 phys_addr, u8 *data, u32 len, u8 is_write);
78 
79 #endif /* KVM__KVM_CPU_ARCH_H */
80