diff options
author | Scott Wood <scottwood@freescale.com> | 2013-06-06 20:16:31 -0400 |
---|---|---|
committer | Gleb Natapov <gleb@redhat.com> | 2013-06-11 04:10:59 -0400 |
commit | f1e89028f020ca982bf51be6eaba0d462ba0f7fa (patch) | |
tree | b6d06ea63e61d1f93037f1f9ff76fe19358dfd52 /arch | |
parent | 2b6398fcf2831f52a8ad9f01c123b3ce2ea31277 (diff) |
kvm/ppc/booke: Hold srcu lock when calling gfn functions
KVM core expects arch code to acquire the srcu lock when calling
gfn_to_memslot and similar functions.
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/kvm/44x_tlb.c | 5 | ||||
-rw-r--r-- | arch/powerpc/kvm/booke.c | 7 | ||||
-rw-r--r-- | arch/powerpc/kvm/e500_mmu.c | 5 |
3 files changed, 17 insertions, 0 deletions
diff --git a/arch/powerpc/kvm/44x_tlb.c b/arch/powerpc/kvm/44x_tlb.c index 5dd3ab469976..ed0385448148 100644 --- a/arch/powerpc/kvm/44x_tlb.c +++ b/arch/powerpc/kvm/44x_tlb.c | |||
@@ -441,6 +441,7 @@ int kvmppc_44x_emul_tlbwe(struct kvm_vcpu *vcpu, u8 ra, u8 rs, u8 ws) | |||
441 | struct kvmppc_vcpu_44x *vcpu_44x = to_44x(vcpu); | 441 | struct kvmppc_vcpu_44x *vcpu_44x = to_44x(vcpu); |
442 | struct kvmppc_44x_tlbe *tlbe; | 442 | struct kvmppc_44x_tlbe *tlbe; |
443 | unsigned int gtlb_index; | 443 | unsigned int gtlb_index; |
444 | int idx; | ||
444 | 445 | ||
445 | gtlb_index = kvmppc_get_gpr(vcpu, ra); | 446 | gtlb_index = kvmppc_get_gpr(vcpu, ra); |
446 | if (gtlb_index >= KVM44x_GUEST_TLB_SIZE) { | 447 | if (gtlb_index >= KVM44x_GUEST_TLB_SIZE) { |
@@ -473,6 +474,8 @@ int kvmppc_44x_emul_tlbwe(struct kvm_vcpu *vcpu, u8 ra, u8 rs, u8 ws) | |||
473 | return EMULATE_FAIL; | 474 | return EMULATE_FAIL; |
474 | } | 475 | } |
475 | 476 | ||
477 | idx = srcu_read_lock(&vcpu->kvm->srcu); | ||
478 | |||
476 | if (tlbe_is_host_safe(vcpu, tlbe)) { | 479 | if (tlbe_is_host_safe(vcpu, tlbe)) { |
477 | gva_t eaddr; | 480 | gva_t eaddr; |
478 | gpa_t gpaddr; | 481 | gpa_t gpaddr; |
@@ -489,6 +492,8 @@ int kvmppc_44x_emul_tlbwe(struct kvm_vcpu *vcpu, u8 ra, u8 rs, u8 ws) | |||
489 | kvmppc_mmu_map(vcpu, eaddr, gpaddr, gtlb_index); | 492 | kvmppc_mmu_map(vcpu, eaddr, gpaddr, gtlb_index); |
490 | } | 493 | } |
491 | 494 | ||
495 | srcu_read_unlock(&vcpu->kvm->srcu, idx); | ||
496 | |||
492 | trace_kvm_gtlb_write(gtlb_index, tlbe->tid, tlbe->word0, tlbe->word1, | 497 | trace_kvm_gtlb_write(gtlb_index, tlbe->tid, tlbe->word0, tlbe->word1, |
493 | tlbe->word2); | 498 | tlbe->word2); |
494 | 499 | ||
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 1020119226db..ecbe9081c9c2 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c | |||
@@ -832,6 +832,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
832 | { | 832 | { |
833 | int r = RESUME_HOST; | 833 | int r = RESUME_HOST; |
834 | int s; | 834 | int s; |
835 | int idx; | ||
835 | 836 | ||
836 | /* update before a new last_exit_type is rewritten */ | 837 | /* update before a new last_exit_type is rewritten */ |
837 | kvmppc_update_timing_stats(vcpu); | 838 | kvmppc_update_timing_stats(vcpu); |
@@ -1053,6 +1054,8 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
1053 | break; | 1054 | break; |
1054 | } | 1055 | } |
1055 | 1056 | ||
1057 | idx = srcu_read_lock(&vcpu->kvm->srcu); | ||
1058 | |||
1056 | gpaddr = kvmppc_mmu_xlate(vcpu, gtlb_index, eaddr); | 1059 | gpaddr = kvmppc_mmu_xlate(vcpu, gtlb_index, eaddr); |
1057 | gfn = gpaddr >> PAGE_SHIFT; | 1060 | gfn = gpaddr >> PAGE_SHIFT; |
1058 | 1061 | ||
@@ -1075,6 +1078,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
1075 | kvmppc_account_exit(vcpu, MMIO_EXITS); | 1078 | kvmppc_account_exit(vcpu, MMIO_EXITS); |
1076 | } | 1079 | } |
1077 | 1080 | ||
1081 | srcu_read_unlock(&vcpu->kvm->srcu, idx); | ||
1078 | break; | 1082 | break; |
1079 | } | 1083 | } |
1080 | 1084 | ||
@@ -1098,6 +1102,8 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
1098 | 1102 | ||
1099 | kvmppc_account_exit(vcpu, ITLB_VIRT_MISS_EXITS); | 1103 | kvmppc_account_exit(vcpu, ITLB_VIRT_MISS_EXITS); |
1100 | 1104 | ||
1105 | idx = srcu_read_lock(&vcpu->kvm->srcu); | ||
1106 | |||
1101 | gpaddr = kvmppc_mmu_xlate(vcpu, gtlb_index, eaddr); | 1107 | gpaddr = kvmppc_mmu_xlate(vcpu, gtlb_index, eaddr); |
1102 | gfn = gpaddr >> PAGE_SHIFT; | 1108 | gfn = gpaddr >> PAGE_SHIFT; |
1103 | 1109 | ||
@@ -1114,6 +1120,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
1114 | kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_MACHINE_CHECK); | 1120 | kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_MACHINE_CHECK); |
1115 | } | 1121 | } |
1116 | 1122 | ||
1123 | srcu_read_unlock(&vcpu->kvm->srcu, idx); | ||
1117 | break; | 1124 | break; |
1118 | } | 1125 | } |
1119 | 1126 | ||
diff --git a/arch/powerpc/kvm/e500_mmu.c b/arch/powerpc/kvm/e500_mmu.c index c41a5a96b558..6d6f153b6c1d 100644 --- a/arch/powerpc/kvm/e500_mmu.c +++ b/arch/powerpc/kvm/e500_mmu.c | |||
@@ -396,6 +396,7 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu) | |||
396 | struct kvm_book3e_206_tlb_entry *gtlbe; | 396 | struct kvm_book3e_206_tlb_entry *gtlbe; |
397 | int tlbsel, esel; | 397 | int tlbsel, esel; |
398 | int recal = 0; | 398 | int recal = 0; |
399 | int idx; | ||
399 | 400 | ||
400 | tlbsel = get_tlb_tlbsel(vcpu); | 401 | tlbsel = get_tlb_tlbsel(vcpu); |
401 | esel = get_tlb_esel(vcpu, tlbsel); | 402 | esel = get_tlb_esel(vcpu, tlbsel); |
@@ -430,6 +431,8 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu) | |||
430 | kvmppc_set_tlb1map_range(vcpu, gtlbe); | 431 | kvmppc_set_tlb1map_range(vcpu, gtlbe); |
431 | } | 432 | } |
432 | 433 | ||
434 | idx = srcu_read_lock(&vcpu->kvm->srcu); | ||
435 | |||
433 | /* Invalidate shadow mappings for the about-to-be-clobbered TLBE. */ | 436 | /* Invalidate shadow mappings for the about-to-be-clobbered TLBE. */ |
434 | if (tlbe_is_host_safe(vcpu, gtlbe)) { | 437 | if (tlbe_is_host_safe(vcpu, gtlbe)) { |
435 | u64 eaddr = get_tlb_eaddr(gtlbe); | 438 | u64 eaddr = get_tlb_eaddr(gtlbe); |
@@ -444,6 +447,8 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu) | |||
444 | kvmppc_mmu_map(vcpu, eaddr, raddr, index_of(tlbsel, esel)); | 447 | kvmppc_mmu_map(vcpu, eaddr, raddr, index_of(tlbsel, esel)); |
445 | } | 448 | } |
446 | 449 | ||
450 | srcu_read_unlock(&vcpu->kvm->srcu, idx); | ||
451 | |||
447 | kvmppc_set_exit_type(vcpu, EMULATED_TLBWE_EXITS); | 452 | kvmppc_set_exit_type(vcpu, EMULATED_TLBWE_EXITS); |
448 | return EMULATE_DONE; | 453 | return EMULATE_DONE; |
449 | } | 454 | } |