Skip to content

Commit 9a4506e

Browse files
npigginpaulusmack
authored andcommitted
KVM: PPC: Book3S HV: Make radix handle process scoped LPID flush in C, with relocation on
The radix guest code can has fewer restrictions about what context it can run in, so move this flushing out of assembly and have it use the Linux TLB flush implementations introduced previously. This allows powerpc:tlbie trace events to be used. This changes the tlbiel sequence to only execute RIC=2 flush once on the first set flushed, then RIC=0 for the rest of the sets. The end result of the flush should be unchanged. This matches the local PID flush pattern that was introduced in a5998fc ("powerpc/mm/radix: Optimise tlbiel flush all case"). Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent d91cb39 commit 9a4506e

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

arch/powerpc/kvm/book3s_hv.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,6 +2958,32 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc)
29582958
for (sub = 0; sub < core_info.n_subcores; ++sub)
29592959
spin_unlock(&core_info.vc[sub]->lock);
29602960

2961+
if (kvm_is_radix(vc->kvm)) {
2962+
int tmp = pcpu;
2963+
2964+
/*
2965+
* Do we need to flush the process scoped TLB for the LPAR?
2966+
*
2967+
* On POWER9, individual threads can come in here, but the
2968+
* TLB is shared between the 4 threads in a core, hence
2969+
* invalidating on one thread invalidates for all.
2970+
* Thus we make all 4 threads use the same bit here.
2971+
*
2972+
* Hash must be flushed in realmode in order to use tlbiel.
2973+
*/
2974+
mtspr(SPRN_LPID, vc->kvm->arch.lpid);
2975+
isync();
2976+
2977+
if (cpu_has_feature(CPU_FTR_ARCH_300))
2978+
tmp &= ~0x3UL;
2979+
2980+
if (cpumask_test_cpu(tmp, &vc->kvm->arch.need_tlb_flush)) {
2981+
radix__local_flush_tlb_lpid_guest(vc->kvm->arch.lpid);
2982+
/* Clear the bit after the TLB flush */
2983+
cpumask_clear_cpu(tmp, &vc->kvm->arch.need_tlb_flush);
2984+
}
2985+
}
2986+
29612987
/*
29622988
* Interrupts will be enabled once we get into the guest,
29632989
* so tell lockdep that we're about to enable interrupts.

arch/powerpc/kvm/book3s_hv_rmhandlers.S

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,10 @@ kvmppc_hv_entry:
636636
/* Primary thread switches to guest partition. */
637637
cmpwi r6,0
638638
bne 10f
639+
640+
/* Radix has already switched LPID and flushed core TLB */
641+
bne cr7, 22f
642+
639643
lwz r7,KVM_LPID(r9)
640644
BEGIN_FTR_SECTION
641645
ld r6,KVM_SDR1(r9)
@@ -647,7 +651,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_300)
647651
mtspr SPRN_LPID,r7
648652
isync
649653

650-
/* See if we need to flush the TLB */
654+
/* See if we need to flush the TLB. Hash has to be done in RM */
651655
lhz r6,PACAPACAINDEX(r13) /* test_bit(cpu, need_tlb_flush) */
652656
BEGIN_FTR_SECTION
653657
/*
@@ -674,15 +678,10 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
674678
li r7,0x800 /* IS field = 0b10 */
675679
ptesync
676680
li r0,0 /* RS for P9 version of tlbiel */
677-
bne cr7, 29f
678681
28: tlbiel r7 /* On P9, rs=0, RIC=0, PRS=0, R=0 */
679682
addi r7,r7,0x1000
680683
bdnz 28b
681-
b 30f
682-
29: PPC_TLBIEL(7,0,2,1,1) /* for radix, RIC=2, PRS=1, R=1 */
683-
addi r7,r7,0x1000
684-
bdnz 29b
685-
30: ptesync
684+
ptesync
686685
23: ldarx r7,0,r6 /* clear the bit after TLB flushed */
687686
andc r7,r7,r8
688687
stdcx. r7,0,r6

0 commit comments

Comments
 (0)