KVM: PPC: e500: misc MMU stuff
Subsystems (3)
cover KVM: PPC: e500: misc MMU stuff
Liu Yu (1):
KVM: booke: Add booke206 TLB trace
Scott Wood (2):
KVM: PPC: e500: Fix TLBnCFG in KVM_CONFIG_TLB
KVM: PPC: e500: use hardware hint when loading TLB0 entries
arch/powerpc/include/asm/mmu-book3e.h | 1 + arch/powerpc/kvm/e500_tlb.c | 97 ++++++++++++++++++++------------- arch/powerpc/kvm/trace.h | 57 +++++++++++++++++++ 3 files changed, 116 insertions(+), 39 deletions(-)
Signature · 1 line
1.7.7.rc3.4.g8d714
PATCH 1/3 KVM: PPC: e500: Fix TLBnCFG in KVM_CONFIG_TLB
The associativity, not just total size, can differ from the host hardware.
--- arch/powerpc/kvm/e500_tlb.c | 19 ++++++++++++++----- 1 files changed, 14 insertions(+), 5 deletions(-)
arch/powerpc/kvm/e500_tlb.c +14 -5
@@ -1227,12 +1227,14 @@ int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu, vcpu_e500->gtlb_offset[0 ] =0 ; vcpu_e500->gtlb_offset[1 ] = params.tlb_sizes[0 ]; - vcpu_e500->tlb0cfg =mfspr (SPRN_TLB0CFG ) & ~0xfffUL ; + vcpu_e500->tlb0cfg &= ~(TLBnCFG_N_ENTRY | TLBnCFG_ASSOC);if (params.tlb_sizes[0 ] <=2048 ) vcpu_e500->tlb0cfg |= params.tlb_sizes[0 ]; + vcpu_e500->tlb0cfg |= params.tlb_ways[0 ] << TLBnCFG_ASSOC_SHIFT; - vcpu_e500->tlb1cfg =mfspr (SPRN_TLB1CFG ) & ~0xfffUL ; + vcpu_e500->tlb1cfg &= ~(TLBnCFG_N_ENTRY | TLBnCFG_ASSOC); vcpu_e500->tlb1cfg |= params.tlb_sizes[1 ]; + vcpu_e500->tlb1cfg |= params.tlb_ways[1 ] << TLBnCFG_ASSOC_SHIFT; vcpu_e500->shared_tlb_pages = pages; vcpu_e500->num_shared_tlb_pages = num_pages;
@@ -1348,10 +1350,17 @@ int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500) goto err;/* Init TLB configuration register */ - vcpu_e500->tlb0cfg =mfspr (SPRN_TLB0CFG ) & ~0xfffUL ; + vcpu_e500->tlb0cfg =mfspr (SPRN_TLB0CFG ) & + ~(TLBnCFG_N_ENTRY | TLBnCFG_ASSOC); vcpu_e500->tlb0cfg |= vcpu_e500->gtlb_params[0 ].entries; - vcpu_e500->tlb1cfg =mfspr (SPRN_TLB1CFG ) & ~0xfffUL ; - vcpu_e500->tlb1cfg |= vcpu_e500->gtlb_params[1 ].entries; + vcpu_e500->tlb0cfg |= + vcpu_e500->gtlb_params[0 ].ways << TLBnCFG_ASSOC_SHIFT; + + vcpu_e500->tlb1cfg =mfspr (SPRN_TLB1CFG ) & + ~(TLBnCFG_N_ENTRY | TLBnCFG_ASSOC); + vcpu_e500->tlb0cfg |= vcpu_e500->gtlb_params[1 ].entries; + vcpu_e500->tlb0cfg |= + vcpu_e500->gtlb_params[1 ].ways << TLBnCFG_ASSOC_SHIFT;return 0 ;
Signature · 1 line
1.7.7.rc3.4.g8d714
PATCH 2/3 KVM: booke: Add booke206 TLB trace
In reply to Scott WoodFrom: Liu Yu <[email protected]>
--- arch/powerpc/kvm/e500_tlb.c | 10 ++++--- arch/powerpc/kvm/trace.h | 57 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 4 deletions(-)
arch/powerpc/kvm/e500_tlb.c +6 -4
@@ -294,6 +294,9 @@ static inline void __write_host_tlbe(struct kvm_book3e_206_tlb_entry *stlbe,mtspr (SPRN_MAS7 , (u32)(stlbe->mas7_3 >>32 )); asmvolatile ("isync; tlbwe" : : :"memory" );local_irq_restore (flags); + +trace_kvm_booke206_stlb_write (mas0, stlbe->mas8, stlbe->mas1, + stlbe->mas2, stlbe->mas7_3); }/* esel is index into set, not whole array */
@@ -308,8 +311,6 @@ static inline void write_host_tlbe(struct kvmppc_vcpu_e500 *vcpu_e500,MAS0_TLBSEL (1 ) | MAS0_ESEL(to_htlb1_esel(esel))); } -trace_kvm_stlb_write (index_of (tlbsel, esel), stlbe->mas1, stlbe->mas2, - (u32 )stlbe->mas7_3, (u32)(stlbe->mas7_3 >>32 )); }void kvmppc_map_magic (struct kvm_vcpu *vcpu)
@@ -331,6 +332,7 @@ void kvmppc_map_magic(struct kvm_vcpu *vcpu) magic.mas2 = vcpu->arch.magic_page_ea |MAS2_M ; magic.mas7_3 = ((u64 )pfn <<PAGE_SHIFT ) |MAS3_SW |MAS3_SR |MAS3_UW |MAS3_UR ; + magic.mas8 =0 ;__write_host_tlbe (&magic,MAS0_TLBSEL (1 ) |MAS0_ESEL (tlbcam_index));preempt_enable ();
@@ -946,8 +948,8 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu) gtlbe->mas2 = vcpu->arch.shared->mas2; gtlbe->mas7_3 = vcpu->arch.shared->mas7_3; -trace_kvm_gtlb_write (vcpu->arch.shared->mas0, gtlbe->mas1, gtlbe->mas2, - (u32 )gtlbe->mas7_3, (u32)(gtlbe->mas7_3 >>32 )); +trace_kvm_booke206_gtlb_write (vcpu->arch.shared->mas0, gtlbe->mas1, + gtlbe->mas2, gtlbe->mas7_3);/* Invalidate shadow mappings for the about-to-be-clobbered TLBE. */ if (tlbe_is_host_safe (vcpu, gtlbe)) {
arch/powerpc/kvm/trace.h +57 -0
63 lines not on this page · raw message
Signature · 1 line
1.7.7.rc3.4.g8d714
PATCH 3/3 KVM: PPC: e500: use hardware hint when loading TLB0 entries
In reply to Scott WoodThe hardware maintains a per-set next victim hint. Using this reduces conflicts, especially on e500v2 where a single guest TLB entry is mapped to two shadow TLB entries (user and kernel). We want those two entries to go to different TLB ways.
sesel is now only used for TLB1.
--- arch/powerpc/include/asm/mmu-book3e.h | 1 + arch/powerpc/kvm/e500_tlb.c | 68 ++++++++++++++++++-------------- 2 files changed, 39 insertions(+), 30 deletions(-)
arch/powerpc/include/asm/mmu-book3e.h +1 -0
@@ -44,6 +44,7 @@#define MAS0_ESEL (x) (((x) << 16) & 0x0FFF0000)#define MAS0_NV (x) ((x) & 0x00000FFF)#define MAS0_ESEL_MASK 0x0FFF0000 +#define MAS0_ESEL_SHIFT 16#define MAS0_HES 0x00004000#define MAS0_WQ_ALLWAYS 0x00000000#define MAS0_WQ_COND 0x00001000
arch/powerpc/kvm/e500_tlb.c +38 -30
133 lines not on this page · raw message
Signature · 1 line
1.7.7.rc3.4.g8d714
PATCH v2 3/3 KVM: PPC: e500: use hardware hint when loading TLB0 entries
The hardware maintains a per-set next victim hint. Using this reduces conflicts, especially on e500v2 where a single guest TLB entry is mapped to two shadow TLB entries (user and kernel). We want those two entries to go to different TLB ways.
sesel is now only used for TLB1.
---
v2:
- avoid duplication of constants in MAS0_ESEL()
- fix comment typo s/it's right set/it's in the right set/
- consistently use u32 for mas0
arch/powerpc/include/asm/mmu-book3e.h | 5 +- arch/powerpc/kvm/e500_tlb.c | 69 ++++++++++++++++++-------------- 2 files changed, 42 insertions(+), 32 deletions(-)
arch/powerpc/include/asm/mmu-book3e.h +3 -2
@@ -41,9 +41,10 @@/* MAS registers bit definitions */ #define MAS0_TLBSEL (x) (((x) << 28) & 0x30000000) -#define MAS0_ESEL (x) (((x) << 16) & 0x0FFF0000) -#define MAS0_NV (x) ((x) & 0x00000FFF)#define MAS0_ESEL_MASK 0x0FFF0000 +#define MAS0_ESEL_SHIFT 16 +#define MAS0_ESEL (x) (((x) << MAS0_ESEL_SHIFT) & MAS0_ESEL_MASK) +#define MAS0_NV (x) ((x) & 0x00000FFF)#define MAS0_HES 0x00004000#define MAS0_WQ_ALLWAYS 0x00000000#define MAS0_WQ_COND 0x00001000
arch/powerpc/kvm/e500_tlb.c +39 -30
134 lines not on this page · raw message
Signature · 1 line
1.7.7.rc3.4.g8d714
Alexander Graf
AppliedRe: [PATCH 1/3] KVM: PPC: e500: Fix TLBnCFG in KVM_CONFIG_TLB
In reply to Scott WoodQuoted 4 lines · Scott Wood
The associativity, not just total size, can differ from the host hardware.
Signed-off-by Scott Wood <[email protected]>
Thanks, applied to kvm-ppc-next.
Alex
Re: [PATCH 2/3] KVM: booke: Add booke206 TLB trace
In reply to Scott WoodQuoted 2 lines · Scott Wood
From: Liu Yu <[email protected]>
Missing patch description.
Alex
Quoted 126 lines
Signed-off-by Liu Yu <[email protected]>[[email protected]: made mas2 64-bit, and added mas8 init]Signed-off-by Scott Wood <[email protected]>---
arch/powerpc/kvm/e500_tlb.c | 10 ++++--- arch/powerpc/kvm/trace.h | 57 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 4 deletions(-)arch/powerpc/kvm/e500_tlb.c +6
-4@@ -294,6 +294,9 @@ static inline void __write_host_tlbe(struct kvm_book3e_206_tlb_entry *stlbe,mtspr (SPRN_MAS7 , (u32)(stlbe->mas7_3 >>32 )); asmvolatile ("isync; tlbwe" : : :"memory" );local_irq_restore (flags); + +trace_kvm_booke206_stlb_write (mas0, stlbe->mas8, stlbe->mas1, + stlbe->mas2, stlbe->mas7_3); }/* esel is index into set, not whole array */ @@ -308,8 +311,6 @@ static inline void write_host_tlbe(struct kvmppc_vcpu_e500 *vcpu_e500,MAS0_TLBSEL (1 ) | MAS0_ESEL(to_htlb1_esel(esel))); } -trace_kvm_stlb_write (index_of (tlbsel, esel), stlbe->mas1, stlbe->mas2, - (u32 )stlbe->mas7_3, (u32)(stlbe->mas7_3 >>32 )); }void kvmppc_map_magic (struct kvm_vcpu *vcpu)@@ -331,6 +332,7 @@ void kvmppc_map_magic(struct kvm_vcpu *vcpu) magic.mas2 = vcpu->arch.magic_page_ea |MAS2_M ; magic.mas7_3 = ((u64 )pfn <<PAGE_SHIFT ) |MAS3_SW |MAS3_SR |MAS3_UW |MAS3_UR ; + magic.mas8 =0 ;__write_host_tlbe (&magic,MAS0_TLBSEL (1 ) |MAS0_ESEL (tlbcam_index));preempt_enable ();@@ -946,8 +948,8 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu) gtlbe->mas2 = vcpu->arch.shared->mas2; gtlbe->mas7_3 = vcpu->arch.shared->mas7_3; -trace_kvm_gtlb_write (vcpu->arch.shared->mas0, gtlbe->mas1, gtlbe->mas2, - (u32 )gtlbe->mas7_3, (u32)(gtlbe->mas7_3 >>32 )); +trace_kvm_booke206_gtlb_write (vcpu->arch.shared->mas0, gtlbe->mas1, + gtlbe->mas2, gtlbe->mas7_3);/* Invalidate shadow mappings for the about-to-be-clobbered TLBE. */ if (tlbe_is_host_safe (vcpu, gtlbe)) {arch/powerpc/kvm/trace.h +57
-0@@ -337,6 +337,63 @@ TRACE_EVENT(kvm_book3s_slbmte,#endif /* CONFIG_PPC_BOOK3S */ + +/************************************************************************* +* Book3E trace points * +*************************************************************************/ + +#ifdef CONFIG_BOOKE + +TRACE_EVENT (kvm_booke206_stlb_write, + TP_PROTO(__u32 mas0, __u32 mas8, __u32 mas1, __u64 mas2, __u64 mas7_3), +TP_ARGS (mas0, mas8, mas1, mas2, mas7_3), + +TP_STRUCT__entry ( + __field( __u32, mas0 ) + __field( __u32, mas8 ) + __field( __u32, mas1 ) + __field( __u64, mas2 ) +__field ( __u64, mas7_3 ) + ), + +TP_fast_assign ( + __entry->mas0 = mas0; + __entry->mas8 = mas8; + __entry->mas1 = mas1; + __entry->mas2 = mas2; + __entry->mas7_3 = mas7_3; + ), + +TP_printk ("mas0=%x mas8=%x mas1=%x mas2=%llx mas7_3=%llx" , + __entry->mas0, __entry->mas8, __entry->mas1, + __entry->mas2, __entry->mas7_3) +); + +TRACE_EVENT (kvm_booke206_gtlb_write, + TP_PROTO(__u32 mas0, __u32 mas1, __u64 mas2, __u64 mas7_3), +TP_ARGS (mas0, mas1, mas2, mas7_3), + +TP_STRUCT__entry ( + __field( __u32, mas0 ) + __field( __u32, mas1 ) + __field( __u64, mas2 ) +__field ( __u64, mas7_3 ) + ), + +TP_fast_assign ( + __entry->mas0 = mas0; + __entry->mas1 = mas1; + __entry->mas2 = mas2; + __entry->mas7_3 = mas7_3; + ), + +TP_printk ("mas0=%x mas1=%x mas2=%llx mas7_3=%llx" , + __entry->mas0, __entry->mas1, + __entry->mas2, __entry->mas7_3) +); + +#endif +#endif /* _TRACE_KVM_H */ /* This part must be outside protection */ Signature · 7 lines
1.7.7.rc3.4.g8d714 -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html