diff options
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/include/asm/kvm_ppc.h | 1 | ||||
-rw-r--r-- | arch/powerpc/kvm/book3s.c | 8 | ||||
-rw-r--r-- | arch/powerpc/kvm/book3s_64_mmu_host.c | 18 |
3 files changed, 20 insertions, 7 deletions
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index edade847b8f8..18d139ec2d22 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h | |||
@@ -69,6 +69,7 @@ extern void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gpa_t gpaddr, | |||
69 | extern void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode); | 69 | extern void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode); |
70 | extern void kvmppc_mmu_switch_pid(struct kvm_vcpu *vcpu, u32 pid); | 70 | extern void kvmppc_mmu_switch_pid(struct kvm_vcpu *vcpu, u32 pid); |
71 | extern void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu); | 71 | extern void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu); |
72 | extern int kvmppc_mmu_init(struct kvm_vcpu *vcpu); | ||
72 | extern int kvmppc_mmu_dtlb_index(struct kvm_vcpu *vcpu, gva_t eaddr); | 73 | extern int kvmppc_mmu_dtlb_index(struct kvm_vcpu *vcpu, gva_t eaddr); |
73 | extern int kvmppc_mmu_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr); | 74 | extern int kvmppc_mmu_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr); |
74 | extern gpa_t kvmppc_mmu_xlate(struct kvm_vcpu *vcpu, unsigned int gtlb_index, | 75 | extern gpa_t kvmppc_mmu_xlate(struct kvm_vcpu *vcpu, unsigned int gtlb_index, |
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 7ff80f9f13a8..d0986968a611 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c | |||
@@ -1202,14 +1202,9 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id) | |||
1202 | 1202 | ||
1203 | vcpu->arch.shadow_msr = MSR_USER64; | 1203 | vcpu->arch.shadow_msr = MSR_USER64; |
1204 | 1204 | ||
1205 | err = __init_new_context(); | 1205 | err = kvmppc_mmu_init(vcpu); |
1206 | if (err < 0) | 1206 | if (err < 0) |
1207 | goto free_shadow_vcpu; | 1207 | goto free_shadow_vcpu; |
1208 | vcpu_book3s->context_id = err; | ||
1209 | |||
1210 | vcpu_book3s->vsid_max = ((vcpu_book3s->context_id + 1) << USER_ESID_BITS) - 1; | ||
1211 | vcpu_book3s->vsid_first = vcpu_book3s->context_id << USER_ESID_BITS; | ||
1212 | vcpu_book3s->vsid_next = vcpu_book3s->vsid_first; | ||
1213 | 1208 | ||
1214 | return vcpu; | 1209 | return vcpu; |
1215 | 1210 | ||
@@ -1225,7 +1220,6 @@ void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu) | |||
1225 | { | 1220 | { |
1226 | struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu); | 1221 | struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu); |
1227 | 1222 | ||
1228 | __destroy_context(vcpu_book3s->context_id); | ||
1229 | kvm_vcpu_uninit(vcpu); | 1223 | kvm_vcpu_uninit(vcpu); |
1230 | kfree(vcpu_book3s->shadow_vcpu); | 1224 | kfree(vcpu_book3s->shadow_vcpu); |
1231 | vfree(vcpu_book3s); | 1225 | vfree(vcpu_book3s); |
diff --git a/arch/powerpc/kvm/book3s_64_mmu_host.c b/arch/powerpc/kvm/book3s_64_mmu_host.c index b0f5b4edaec2..0eea589dbef0 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_host.c +++ b/arch/powerpc/kvm/book3s_64_mmu_host.c | |||
@@ -405,4 +405,22 @@ void kvmppc_mmu_flush_segments(struct kvm_vcpu *vcpu) | |||
405 | void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu) | 405 | void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu) |
406 | { | 406 | { |
407 | kvmppc_mmu_pte_flush(vcpu, 0, 0); | 407 | kvmppc_mmu_pte_flush(vcpu, 0, 0); |
408 | __destroy_context(to_book3s(vcpu)->context_id); | ||
409 | } | ||
410 | |||
411 | int kvmppc_mmu_init(struct kvm_vcpu *vcpu) | ||
412 | { | ||
413 | struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); | ||
414 | int err; | ||
415 | |||
416 | err = __init_new_context(); | ||
417 | if (err < 0) | ||
418 | return -1; | ||
419 | vcpu3s->context_id = err; | ||
420 | |||
421 | vcpu3s->vsid_max = ((vcpu3s->context_id + 1) << USER_ESID_BITS) - 1; | ||
422 | vcpu3s->vsid_first = vcpu3s->context_id << USER_ESID_BITS; | ||
423 | vcpu3s->vsid_next = vcpu3s->vsid_first; | ||
424 | |||
425 | return 0; | ||
408 | } | 426 | } |