diff options
author | Scott Wood <scottwood@freescale.com> | 2011-06-14 19:35:20 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-07-12 06:16:40 -0400 |
commit | 1aee47a0276f75a371e13a936a48f64eb5d3ec1b (patch) | |
tree | a8fa2c437a7a562b61b8a028e3d8c78a422d2e1f /arch/powerpc | |
parent | dd9ebf1f94354b010f2ac7a98bf69168636cb08e (diff) |
KVM: PPC: e500: Don't search over the entire TLB0.
Only look in the 4 entries that could possibly contain the
entry we're looking for.
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/kvm/e500_tlb.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c index ea394571bbb6..13c432ea2fa8 100644 --- a/arch/powerpc/kvm/e500_tlb.c +++ b/arch/powerpc/kvm/e500_tlb.c | |||
@@ -418,11 +418,21 @@ static void kvmppc_e500_stlbe_invalidate(struct kvmppc_vcpu_e500 *vcpu_e500, | |||
418 | static int kvmppc_e500_tlb_index(struct kvmppc_vcpu_e500 *vcpu_e500, | 418 | static int kvmppc_e500_tlb_index(struct kvmppc_vcpu_e500 *vcpu_e500, |
419 | gva_t eaddr, int tlbsel, unsigned int pid, int as) | 419 | gva_t eaddr, int tlbsel, unsigned int pid, int as) |
420 | { | 420 | { |
421 | int size = vcpu_e500->gtlb_size[tlbsel]; | ||
422 | int set_base; | ||
421 | int i; | 423 | int i; |
422 | 424 | ||
423 | /* XXX Replace loop with fancy data structures. */ | 425 | if (tlbsel == 0) { |
424 | for (i = 0; i < vcpu_e500->gtlb_size[tlbsel]; i++) { | 426 | int mask = size / KVM_E500_TLB0_WAY_NUM - 1; |
425 | struct tlbe *tlbe = &vcpu_e500->gtlb_arch[tlbsel][i]; | 427 | set_base = (eaddr >> PAGE_SHIFT) & mask; |
428 | set_base *= KVM_E500_TLB0_WAY_NUM; | ||
429 | size = KVM_E500_TLB0_WAY_NUM; | ||
430 | } else { | ||
431 | set_base = 0; | ||
432 | } | ||
433 | |||
434 | for (i = 0; i < size; i++) { | ||
435 | struct tlbe *tlbe = &vcpu_e500->gtlb_arch[tlbsel][set_base + i]; | ||
426 | unsigned int tid; | 436 | unsigned int tid; |
427 | 437 | ||
428 | if (eaddr < get_tlb_eaddr(tlbe)) | 438 | if (eaddr < get_tlb_eaddr(tlbe)) |
@@ -441,7 +451,7 @@ static int kvmppc_e500_tlb_index(struct kvmppc_vcpu_e500 *vcpu_e500, | |||
441 | if (get_tlb_ts(tlbe) != as && as != -1) | 451 | if (get_tlb_ts(tlbe) != as && as != -1) |
442 | continue; | 452 | continue; |
443 | 453 | ||
444 | return i; | 454 | return set_base + i; |
445 | } | 455 | } |
446 | 456 | ||
447 | return -1; | 457 | return -1; |