aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJames Hogan <james.hogan@imgtec.com>2014-05-29 05:16:26 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-05-30 07:00:02 -0400
commitb5dfc6c10608fdf0c35a747a0a3bf3f6e40a38e1 (patch)
tree3b9722c836af500a362e73930dbf0f1b21685211 /arch
parentfacaaec1a72db90127b71d22e788596cf1991ae1 (diff)
MIPS: KVM: Use tlb_write_random
When MIPS KVM needs to write a TLB entry for the guest it reads the CP0_Random register, uses it to generate the CP_Index, and writes the TLB entry using the TLBWI instruction (tlb_write_indexed()). However there's an instruction for that, TLBWR (tlb_write_random()) so use that instead. This happens to also fix an issue with Ingenic XBurst cores where the same TLB entry is replaced each time preventing forward progress on stores due to alternating between TLB load misses for the instruction fetch and TLB store misses. Signed-off-by: James Hogan <james.hogan@imgtec.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Gleb Natapov <gleb@kernel.org> Cc: kvm@vger.kernel.org Cc: Ralf Baechle <ralf@linux-mips.org> Cc: linux-mips@linux-mips.org Cc: Sanjay Lal <sanjayl@kymasys.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/mips/kvm/kvm_tlb.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/arch/mips/kvm/kvm_tlb.c b/arch/mips/kvm/kvm_tlb.c
index 50ab9c4d4a5d..9d371ee0a755 100644
--- a/arch/mips/kvm/kvm_tlb.c
+++ b/arch/mips/kvm/kvm_tlb.c
@@ -222,16 +222,14 @@ kvm_mips_host_tlb_write(struct kvm_vcpu *vcpu, unsigned long entryhi,
222 return -1; 222 return -1;
223 } 223 }
224 224
225 if (idx < 0) {
226 idx = read_c0_random() % current_cpu_data.tlbsize;
227 write_c0_index(idx);
228 mtc0_tlbw_hazard();
229 }
230 write_c0_entrylo0(entrylo0); 225 write_c0_entrylo0(entrylo0);
231 write_c0_entrylo1(entrylo1); 226 write_c0_entrylo1(entrylo1);
232 mtc0_tlbw_hazard(); 227 mtc0_tlbw_hazard();
233 228
234 tlb_write_indexed(); 229 if (idx < 0)
230 tlb_write_random();
231 else
232 tlb_write_indexed();
235 tlbw_use_hazard(); 233 tlbw_use_hazard();
236 234
237#ifdef DEBUG 235#ifdef DEBUG