Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64/mm: Use phys_to_page() to access pgtable memory

The macros {pgd, pud, pmd}_page() retrieves the page struct of the
corresponding page frame, which is reserved as page table. There
is already a macro (phys_to_page), defined in memory.h as below,
to convert the physical address to the page struct. Also, the header
file (memory.h) has been included by pgtable.h.

#define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys)))

So it's reasonable to use the macro in pgtable.h.

Signed-off-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20200427234655.111847-1-gshan@redhat.com
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Gavin Shan and committed by
Will Deacon
68ecabd0 2eaf63ba

+3 -3
+3 -3
arch/arm64/include/asm/pgtable.h
··· 508 508 #define pte_set_fixmap_offset(pmd, addr) pte_set_fixmap(pte_offset_phys(pmd, addr)) 509 509 #define pte_clear_fixmap() clear_fixmap(FIX_PTE) 510 510 511 - #define pmd_page(pmd) pfn_to_page(__phys_to_pfn(__pmd_to_phys(pmd))) 511 + #define pmd_page(pmd) phys_to_page(__pmd_to_phys(pmd)) 512 512 513 513 /* use ONLY for statically allocated translation tables */ 514 514 #define pte_offset_kimg(dir,addr) ((pte_t *)__phys_to_kimg(pte_offset_phys((dir), (addr)))) ··· 566 566 #define pmd_set_fixmap_offset(pud, addr) pmd_set_fixmap(pmd_offset_phys(pud, addr)) 567 567 #define pmd_clear_fixmap() clear_fixmap(FIX_PMD) 568 568 569 - #define pud_page(pud) pfn_to_page(__phys_to_pfn(__pud_to_phys(pud))) 569 + #define pud_page(pud) phys_to_page(__pud_to_phys(pud)) 570 570 571 571 /* use ONLY for statically allocated translation tables */ 572 572 #define pmd_offset_kimg(dir,addr) ((pmd_t *)__phys_to_kimg(pmd_offset_phys((dir), (addr)))) ··· 624 624 #define pud_set_fixmap_offset(pgd, addr) pud_set_fixmap(pud_offset_phys(pgd, addr)) 625 625 #define pud_clear_fixmap() clear_fixmap(FIX_PUD) 626 626 627 - #define pgd_page(pgd) pfn_to_page(__phys_to_pfn(__pgd_to_phys(pgd))) 627 + #define pgd_page(pgd) phys_to_page(__pgd_to_phys(pgd)) 628 628 629 629 /* use ONLY for statically allocated translation tables */ 630 630 #define pud_offset_kimg(dir,addr) ((pud_t *)__phys_to_kimg(pud_offset_phys((dir), (addr))))