makedumpfile: arm64: Fix page table walk of 1GB section
Subsystems (2)
PATCH v2 1/1 makedumpfile: arm64: Fix page table walk of 1GB section
From: Bradley Bolen <[email protected]>
makedumpfile was generating large (> 500MB) vmcore files for an arm64 board with 2GB of DRAM. It was not excluding any pages because the mem_map address was not being converted correctly.
readmem: Can't convert a virtual address(ffffffc07fff6000) to physical address.
readmem: type_addr: 0, addr:ffffffc07fff6000, size:16section_mem_map_addr: Can't get a struct mem_section(ffffffc07fff6000). mem_map (0)mem_map : 0
makedumpfile was not handling 1GB sections in the PGD and was trying to drill down to a PTE in which it was trying to dereference invalid memory. This patch adds code to check the PGD for a section type and handle it instead of treating it as a table entry.
---
Changes in v2:
- updated comments
arch/arm64.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
arch/arm64.c +14 -1
@@ -57,6 +57,8 @@ static unsigned long kimage_voffset;#define PGDIR_SHIFT ((PAGESHIFT() - 3) * pgtable_level + 3)#define PTRS_PER_PGD (1 << (va_bits - PGDIR_SHIFT))#define PUD_SHIFT get_pud_shift_arm64() +#define PUD_SIZE (1UL << PUD_SHIFT) +#define PUD_MASK (~(PUD_SIZE - 1))#define PTRS_PER_PTE (1 << (PAGESHIFT() - 3))#define PTRS_PER_PUD PTRS_PER_PTE#define PMD_SHIFT ((PAGESHIFT() - 3) * 2 + 3)
@@ -79,6 +81,10 @@ static unsigned long kimage_voffset;#define PMD_TYPE_SECT 1#define PMD_TYPE_TABLE 3 +#define PUD_TYPE_MASK 3 +#define PUD_TYPE_SECT 1 +#define PUD_TYPE_TABLE 3 +#define pgd_index (vaddr) (((vaddr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))#define pgd_offset (pgdir, vaddr) ((pgd_t *)(pgdir) + pgd_index(vaddr))
@@ -253,6 +259,13 @@ vaddr_to_paddr_arm64(unsigned long vaddr)return NOT_PADDR ; } +if ((pud_val (pudv) &PUD_TYPE_MASK ) ==PUD_TYPE_SECT ) { +/* 1GB section for Page Table level = 4 and Page Size = 4KB */ + paddr = (pud_val (pudv) & (PUD_MASK &PMD_SECTION_MASK )) + + (vaddr & (PUD_SIZE -1 )); +return paddr; + } + pmda =pmd_offset (puda, &pudv, vaddr);if (!readmem (PADDR , (unsigned long long )pmda, &pmdv,sizeof (pmdv))) {ERRMSG ("Can't read pmd\n" );
@@ -278,7 +291,7 @@ vaddr_to_paddr_arm64(unsigned long vaddr) }break ;case PMD_TYPE_SECT : -/* 1GB section */ +/* 512MB section for Page Table level = 3 and Page Size = 64KB*/ paddr = (pmd_val (pmdv) & (PMD_MASK &PMD_SECTION_MASK )) + (vaddr & (PMD_SIZE -1 ));break ;
Signature · 7 lines
1.9.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Quoted 13 lines · Bradley Bolen
From: Bradley Bolen <[email protected]>
makedumpfile was generating large (> 500MB) vmcore files for an arm64 board with 2GB of DRAM. It was not excluding any pages because the
mem_mapaddress was not being converted correctly.readmem: Can't convert a virtual address(ffffffc07fff6000) to physical address.
readmem:type_addr: 0, addr:ffffffc07fff6000, size:16section_mem_map_addr: Can't get a structmem_section(ffffffc07fff6000).mem_map(0)mem_map: 0
Quoted 6 lines
makedumpfile was not handling 1GB sections in the PGD and was trying to drill down to a PTE in which it was trying to dereference invalid memory. This patch adds code to check the PGD for a section type and handle it instead of treating it as a table entry.
Signed-off-by Bradley Bolen <[email protected]>
Quoted 55 lines
---
Changes in v2:
- updated commentsarch/arm64.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)arch/arm64.c +14
-1@@ -57,6 +57,8 @@ static unsigned long kimage_voffset;#define PGDIR_SHIFT ((PAGESHIFT() - 3) * pgtable_level + 3)#define PTRS_PER_PGD (1 << (va_bits - PGDIR_SHIFT))#define PUD_SHIFT get_pud_shift_arm64() +#define PUD_SIZE (1UL << PUD_SHIFT) +#define PUD_MASK (~(PUD_SIZE - 1))#define PTRS_PER_PTE (1 << (PAGESHIFT() - 3))#define PTRS_PER_PUD PTRS_PER_PTE#define PMD_SHIFT ((PAGESHIFT() - 3) * 2 + 3)@@ -79,6 +81,10 @@ static unsigned long kimage_voffset;#define PMD_TYPE_SECT 1#define PMD_TYPE_TABLE 3 +#define PUD_TYPE_MASK 3 +#define PUD_TYPE_SECT 1 +#define PUD_TYPE_TABLE 3 +#define pgd_index (vaddr) (((vaddr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))#define pgd_offset (pgdir, vaddr) ((pgd_t *)(pgdir) + pgd_index(vaddr))@@ -253,6 +259,13 @@ vaddr_to_paddr_arm64(unsigned long vaddr)return NOT_PADDR ; } +if ((pud_val (pudv) &PUD_TYPE_MASK ) ==PUD_TYPE_SECT ) { +/* 1GB section for Page Table level = 4 and Page Size = 4KB */ + paddr = (pud_val (pudv) & (PUD_MASK &PMD_SECTION_MASK )) + + (vaddr & (PUD_SIZE -1 )); +return paddr; + } + pmda =pmd_offset (puda, &pudv, vaddr);if (!readmem (PADDR , (unsigned long long )pmda, &pmdv,sizeof (pmdv))) {ERRMSG ("Can't read pmd\n" );@@ -278,7 +291,7 @@ vaddr_to_paddr_arm64(unsigned long vaddr) }break ;case PMD_TYPE_SECT : -/* 1GB section */ +/* 512MB section for Page Table level = 3 and Page Size = 64KB*/ paddr = (pmd_val (pmdv) & (PMD_MASK &PMD_SECTION_MASK )) + (vaddr & (PMD_SIZE -1 ));break ;
Signature · 7 lines
Regards Pratyush _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Quoted 14 lines · Bradley Bolen
Quoted 13 lines
From: Bradley Bolen <[email protected]>
makedumpfile was generating large (> 500MB) vmcore files for an arm64 board with 2GB of DRAM. It was not excluding any pages because the
mem_mapaddress was not being converted correctly.readmem: Can't convert a virtual address(ffffffc07fff6000) to physical address.
readmem:type_addr: 0, addr:ffffffc07fff6000, size:16section_mem_map_addr: Can't get a structmem_section(ffffffc07fff6000).mem_map(0)mem_map: 0
Quoted 6 lines
Quoted 6 lines
makedumpfile was not handling 1GB sections in the PGD and was trying to drill down to a PTE in which it was trying to dereference invalid memory. This patch adds code to check the PGD for a section type and handle it instead of treating it as a table entry.
Signed-off-by Bradley Bolen <[email protected]>
I'll merge this patch into v1.6.3, thanks,
Quoted 1 line
Reviewed-by Pratyush Anand <[email protected]>
Thanks for your comment for the comments, actually I was just wondering about those comments.
Regards,
Atsushi Kumagai
Quoted 60 lines
Quoted 47 lines
---
Changes in v2:
- updated commentsarch/arm64.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)arch/arm64.c +13
-0@@ -57,6 +57,8 @@ static unsigned long kimage_voffset;#define PGDIR_SHIFT ((PAGESHIFT() - 3) * pgtable_level + 3)#define PTRS_PER_PGD (1 << (va_bits - PGDIR_SHIFT))#define PUD_SHIFT get_pud_shift_arm64() +#define PUD_SIZE (1UL << PUD_SHIFT) +#define PUD_MASK (~(PUD_SIZE - 1))#define PTRS_PER_PTE (1 << (PAGESHIFT() - 3))#define PTRS_PER_PUD PTRS_PER_PTE#define PMD_SHIFT ((PAGESHIFT() - 3) * 2 + 3)@@ -79,6 +81,10 @@ static unsigned long kimage_voffset;#define PMD_TYPE_SECT 1#define PMD_TYPE_TABLE 3 +#define PUD_TYPE_MASK 3 +#define PUD_TYPE_SECT 1 +#define PUD_TYPE_TABLE 3 +#define pgd_index (vaddr) (((vaddr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))#define pgd_offset (pgdir, vaddr) ((pgd_t *)(pgdir) + pgd_index(vaddr))@@ -253,6 +259,13 @@ vaddr_to_paddr_arm64(unsigned long vaddr)return NOT_PADDR ; } +if ((pud_val (pudv) &PUD_TYPE_MASK ) ==PUD_TYPE_SECT ) { +/* 1GB section for Page Table level = 4 and Page Size = 4KB */ + paddr = (pud_val (pudv) & (PUD_MASK &PMD_SECTION_MASK )) + + (vaddr & (PUD_SIZE -1 )); +return paddr; + } + pmda =pmd_offset (puda, &pudv, vaddr);if (!readmem (PADDR , (unsigned long long )pmda, &pmdv,sizeof (pmdv))) {ERRMSG ("Can't read pmd\n" );arch/arm64.c vaddr_to_paddr_arm64(unsigned long vaddr) · line 297
Quoted 8 lines
arch/arm64.c +1
-1@@ -278,7 +291,7 @@ vaddr_to_paddr_arm64(unsigned long vaddr) }break ;case PMD_TYPE_SECT : -/* 1GB section */ +/* 512MB section for Page Table level = 3 and Page Size = 64KB*/ paddr = (pmd_val (pmdv) & (PMD_MASK &PMD_SECTION_MASK )) + (vaddr & (PMD_SIZE -1 ));break ;--
Regards
Pratyush
Quoted 4 lines
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec