aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kvm/44x.c
diff options
context:
space:
mode:
authorHollis Blanchard <hollisb@us.ibm.com>2008-11-05 10:36:17 -0500
committerAvi Kivity <avi@redhat.com>2008-12-31 09:52:22 -0500
commit5cbb5106f50b4515815cd32cf944958c0d4da83f (patch)
tree9e77820c11e173b141a2c4672ce8ecf7be7a286b /arch/powerpc/kvm/44x.c
parent75f74f0dbe086c239b4b0cc5ed75b903ea3e663f (diff)
KVM: ppc: Move the last bits of 44x code out of booke.c
Needed to port to other Book E processors. Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/powerpc/kvm/44x.c')
-rw-r--r--arch/powerpc/kvm/44x.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/arch/powerpc/kvm/44x.c b/arch/powerpc/kvm/44x.c
index fcf8c7d0af45..f5d7028eeb09 100644
--- a/arch/powerpc/kvm/44x.c
+++ b/arch/powerpc/kvm/44x.c
@@ -121,3 +121,56 @@ int kvmppc_core_check_processor_compat(void)
121 121
122 return r; 122 return r;
123} 123}
124
125int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu)
126{
127 struct kvmppc_44x_tlbe *tlbe = &vcpu->arch.guest_tlb[0];
128
129 tlbe->tid = 0;
130 tlbe->word0 = PPC44x_TLB_16M | PPC44x_TLB_VALID;
131 tlbe->word1 = 0;
132 tlbe->word2 = PPC44x_TLB_SX | PPC44x_TLB_SW | PPC44x_TLB_SR;
133
134 tlbe++;
135 tlbe->tid = 0;
136 tlbe->word0 = 0xef600000 | PPC44x_TLB_4K | PPC44x_TLB_VALID;
137 tlbe->word1 = 0xef600000;
138 tlbe->word2 = PPC44x_TLB_SX | PPC44x_TLB_SW | PPC44x_TLB_SR
139 | PPC44x_TLB_I | PPC44x_TLB_G;
140
141 /* Since the guest can directly access the timebase, it must know the
142 * real timebase frequency. Accordingly, it must see the state of
143 * CCR1[TCS]. */
144 vcpu->arch.ccr1 = mfspr(SPRN_CCR1);
145
146 return 0;
147}
148
149/* 'linear_address' is actually an encoding of AS|PID|EADDR . */
150int kvmppc_core_vcpu_translate(struct kvm_vcpu *vcpu,
151 struct kvm_translation *tr)
152{
153 struct kvmppc_44x_tlbe *gtlbe;
154 int index;
155 gva_t eaddr;
156 u8 pid;
157 u8 as;
158
159 eaddr = tr->linear_address;
160 pid = (tr->linear_address >> 32) & 0xff;
161 as = (tr->linear_address >> 40) & 0x1;
162
163 index = kvmppc_44x_tlb_index(vcpu, eaddr, pid, as);
164 if (index == -1) {
165 tr->valid = 0;
166 return 0;
167 }
168
169 gtlbe = &vcpu->arch.guest_tlb[index];
170
171 tr->physical_address = tlb_xlate(gtlbe, eaddr);
172 /* XXX what does "writeable" and "usermode" even mean? */
173 tr->valid = 1;
174
175 return 0;
176}