KVM: PPC: Book3S HV: Use RADIX_PTE_INDEX_SIZE in Radix MMU code
Subsystems (2)
Michael Ellerman
reviewerPATCH 1/1 KVM: PPC: Book3S HV: Use RADIX_PTE_INDEX_SIZE in Radix MMU code
In kvmppc_unmap_free_pte() in book3s_64_mmu_radix.c, we use the non-constant value PTE_INDEX_SIZE to clear a PTE page.
We can instead use the constant RADIX_PTE_INDEX_SIZE, because we know this code will only be running when the Radix MMU is active.
Note that we already use RADIX_PTE_INDEX_SIZE for the allocation of kvm_pte_cache.
--- arch/powerpc/kvm/book3s_64_mmu_radix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/book3s_64_mmu_radix.c +1 -1
@@ -425,7 +425,7 @@ static void kvmppc_unmap_free_pte(struct kvm *kvm, pte_t *pte, bool full, unsigned int lpid) {if (full) { -memset (pte,0 ,sizeof (long ) <<PTE_INDEX_SIZE ); +memset (pte,0 ,sizeof (long ) <<RADIX_PTE_INDEX_SIZE ); }else {pte_t *p = pte;unsigned long it;
Signature · 1 line
2.21.1
Hello Michael,
Quoted 19 lines · Michael Ellerman
In
kvmppc_unmap_free_pte()inbook3s_64_mmu_radix.c, we use the non-constant valuePTE_INDEX_SIZEto clear a PTE page.We can instead use the constant
RADIX_PTE_INDEX_SIZE, because we know this code will only be running when the Radix MMU is active.Note that we already use
RADIX_PTE_INDEX_SIZEfor the allocation ofkvm_pte_cache.Signed-off-by Michael Ellerman <[email protected]>--- arch/powerpc/kvm/book3s_64_mmu_radix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/kvm/book3s_64_mmu_radix.c +0
-0
arch/powerpc/kvm/book3s_64_mmu_radix.c static void kvmppc_unmap_free_pte(struct kvm *kvm, pte_t *pte, bool full, · line 431
Quoted 8 lines
arch/powerpc/kvm/book3s_64_mmu_radix.c +1
-1@@ -425,7 +425,7 @@ static void kvmppc_unmap_free_pte(struct kvm *kvm, pte_t *pte, bool full, unsigned int lpid) {if (full) { -memset (pte,0 ,sizeof (long ) <<PTE_INDEX_SIZE ); +memset (pte,0 ,sizeof (long ) <<RADIX_PTE_INDEX_SIZE ); }else {pte_t *p = pte;unsigned long it;
Looks fine to mee.
For book3s_64, pgtable.h says:
extern unsigned long __pte_index_size;
#define PTE_INDEX_SIZE __pte_index_size
powerpc/mm/pgtable_64.c defines/export the variable:
unsigned long __pte_index_size; EXPORT_SYMBOL(__pte_index_size);
And book3s64/radix_pgtable.c set the value in radix__early_init_mmu(). __pte_index_size = RADIX_PTE_INDEX_SIZE;
So I think it's ok to use the value directly in book3s_64_mmu_radix.c. The include dependency looks fine for that to work.
FWIW:
Paul Mackerras
AppliedQuoted 10 lines · Michael Ellerman
In
kvmppc_unmap_free_pte()inbook3s_64_mmu_radix.c, we use the non-constant valuePTE_INDEX_SIZEto clear a PTE page.We can instead use the constant
RADIX_PTE_INDEX_SIZE, because we know this code will only be running when the Radix MMU is active.Note that we already use
RADIX_PTE_INDEX_SIZEfor the allocation ofkvm_pte_cache.Signed-off-by Michael Ellerman <[email protected]>
Thanks, applied to my kvm-ppc-next branch.
Paul.