arm64/mm: Drop PXD_TABLE_BIT
v2 cover arm64/mm: Drop PXD_TABLE_BIT
Remove the PXX_TABLE_BIT definitions and instead rely on PXX_TYPE_MASK, PXX_TYPE_SECT and PXX_TYPE_TABLE. The latter versions are more abstract and also include the PTE_VALID bit.
This abstraction is valuable for the impending D128 page table support, which doesn't have a single page table bit to determine table vs block. Instead it has the skip level (SKL) field, where it will consider 0 to mean table and any other value to mean a block entry. So PXX_TABLE_BIT therefore doesn't fit into the D128 model well, but the type fields do.
This series applies on v6.14-rc3.
Changes in V2:
- Changed pmd_mkhuge() and pud_mkhuge() implementation
- Changed pud_bad() implementation with an additional patch
Changes in V1:
https://lore.kernel.org/all/[email protected]/
Anshuman Khandual (6):
KVM: arm64: ptdump: Test PMD_TYPE_MASK for block mapping arm64/ptdump: Test PMD_TYPE_MASK for block mapping
arm64/mm: Clear PXX_TYPE_MASK in mk_[pmd|pud]_sect_prot() arm64/mm: Clear PXX_TYPE_MASK and set PXD_TYPE_SECT in [pmd|pud]_mkhuge() arm64/mm: Check PXD_TYPE_TABLE in [p4d|pgd]_bad()
arm64/mm: Drop PXD_TABLE_BIT
Ryan Roberts (2):
arm64/mm: Check PUD_TYPE_TABLE in pud_bad()
arm64/mm: Check pmd_table() in pmd_trans_huge()
arch/arm64/include/asm/pgtable-hwdef.h | 5 -- arch/arm64/include/asm/pgtable.h | 65 ++++++++++++++++++-------- arch/arm64/kvm/ptdump.c | 4 +- arch/arm64/mm/ptdump.c | 4 +- 4 files changed, 50 insertions(+), 28 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/8 KVM: arm64: ptdump: Test PMD_TYPE_MASK for block mapping
Test given page table entries against PMD_TYPE_SECT on PMD_TYPE_MASK mask bits for identifying block mappings in stage 2 page tables.
--- arch/arm64/kvm/ptdump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/ptdump.c +2 -2
@@ -52,8 +52,8 @@ static const struct ptdump_prot_bits stage2_pte_bits[] = { .set = "AF", .clear = " ", }, { - .mask = PTE_TABLE_BIT | PTE_VALID, - .val = PTE_VALID, + .mask = PMD_TYPE_MASK, + .val = PMD_TYPE_SECT, .set = "BLK", .clear = " ", },
Signature · 1 line
2.25.1
Catalin Marinas
maintainerRe: [PATCH V2 1/8] KVM: arm64: ptdump: Test PMD_TYPE_MASK for block mapping
Quoted 21 lines · Anshuman Khandual
Test given page table entries against
PMD_TYPE_SECTonPMD_TYPE_MASKmask bits for identifying block mappings in stage 2 page tables.Cc Marc Zyngier <[email protected]>Cc Oliver Upton <[email protected]>Cc James Morse <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>--- arch/arm64/kvm/ptdump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm64/kvm/ptdump.c +0
-0
arch/arm64/kvm/ptdump.c static const struct ptdump_prot_bits stage2_pte_bits[] = { · line 59
Quoted 10 lines
arch/arm64/kvm/ptdump.c +2
-2@@ -52,8 +52,8 @@ static const struct ptdump_prot_bits stage2_pte_bits[] = { .set = "AF", .clear = " ", }, { - .mask = PTE_TABLE_BIT | PTE_VALID, - .val = PTE_VALID, + .mask = PMD_TYPE_MASK, + .val = PMD_TYPE_SECT, .set = "BLK", .clear = " ", },
Marc, Oliver - are you ok with this patch going in through the arm64 tree?
Thanks.
Signature · 1 line
Catalin
Re: [PATCH V2 1/8] KVM: arm64: ptdump: Test PMD_TYPE_MASK for block mapping
Quoted 28 lines · Catalin Marinas
Quoted 27 lines · Anshuman Khandual
Test given page table entries against
PMD_TYPE_SECTonPMD_TYPE_MASKmask bits for identifying block mappings in stage 2 page tables.Cc Marc Zyngier <[email protected]>Cc Oliver Upton <[email protected]>Cc James Morse <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>--- arch/arm64/kvm/ptdump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm64/kvm/ptdump.c +0
-2@@ -52,8 +52,8 @@ static const struct ptdump_prot_bits stage2_pte_bits[] = { .set = "AF", .clear = " ", }, { - .mask = PTE_TABLE_BIT | PTE_VALID, - .val = PTE_VALID,
Quoted 8 lines
Quoted 5 lines
arch/arm64/kvm/ptdump.c +2
-0+ .mask = PMD_TYPE_MASK, + .val = PMD_TYPE_SECT, .set = "BLK", .clear = " ",},
Marc, Oliver - are you ok with this patch going in through the arm64 tree?
Yup, looks OK to me.
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
PATCH v2 2/8 arm64/ptdump: Test PMD_TYPE_MASK for block mapping
In reply to Anshuman KhandualTest given page table entries against PMD_TYPE_SECT on PMD_TYPE_MASK mask bits for identifying block mappings in stage 1 page tables.
--- arch/arm64/mm/ptdump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/mm/ptdump.c +2 -2
@@ -80,8 +80,8 @@ static const struct ptdump_prot_bits pte_bits[] = { .set = "CON", .clear = " ", }, { - .mask = PTE_TABLE_BIT | PTE_VALID, - .val = PTE_VALID, + .mask = PMD_TYPE_MASK, + .val = PMD_TYPE_SECT, .set = "BLK", .clear = " ", }, {
Signature · 1 line
2.25.1
PATCH v2 3/8 arm64/mm: Clear PXX_TYPE_MASK in mk_[pmd|pud]_sect_prot()
In reply to Anshuman KhandualClear PXX_TYPE_MASK bits in mk_[pmd|pud]_sect_prot() while creating section mappings instead of just clearing the PXX_TABLE_BIT.
--- arch/arm64/include/asm/pgtable.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/pgtable.h +2 -2
@@ -483,12 +483,12 @@ static inline pmd_t pte_pmd(pte_t pte)static inline pgprot_t mk_pud_sect_prot (pgprot_t prot) { -return __pgprot ((pgprot_val (prot) & ~PUD_TABLE_BIT ) |PUD_TYPE_SECT ); +return __pgprot ((pgprot_val (prot) & ~PUD_TYPE_MASK ) |PUD_TYPE_SECT ); }static inline pgprot_t mk_pmd_sect_prot (pgprot_t prot) { -return __pgprot ((pgprot_val (prot) & ~PMD_TABLE_BIT ) |PMD_TYPE_SECT ); +return __pgprot ((pgprot_val (prot) & ~PMD_TYPE_MASK ) |PMD_TYPE_SECT ); }static inline pte_t pte_swp_mkexclusive (pte_t pte)
Signature · 1 line
2.25.1
PATCH v2 4/8 arm64/mm: Clear PXX_TYPE_MASK and set PXD_TYPE_SECT in [pmd|pud]_mkhuge()
In reply to Anshuman KhandualClear PXX_TYPE_MASK in [pmd|pud]_mkhuge() while creating section mappings instead of just the PXX_TABLE_BIT and also set PXD_TYPE_SECT. Also ensure PTE_VALID does not get modified in these helpers, because present-invalid entries should preserve their state across.
--- arch/arm64/include/asm/pgtable.h | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
arch/arm64/include/asm/pgtable.h +24 -2
@@ -585,7 +585,18 @@ static inline int pmd_trans_huge(pmd_t pmd)#define pmd_write (pmd) pte_write(pmd_pte(pmd)) -#define pmd_mkhuge (pmd) (__pmd(pmd_val(pmd) & ~PMD_TABLE_BIT)) +static inline pmd_t pmd_mkhuge (pmd_t pmd) +{ +/* +* It's possible that the pmd is present-invalid on entry +* and in that case it needs to remain present-invalid on +* exit. So ensure the VALID bit does not get modified. +*/ +pmdval_t mask =PMD_TYPE_MASK & ~PTE_VALID ; +pmdval_t val =PMD_TYPE_SECT & ~PTE_VALID ; + +return __pmd ((pmd_val (pmd) & ~mask) | val); +}#ifdef CONFIG_TRANSPARENT_HUGEPAGE #define pmd_devmap (pmd) pte_devmap(pmd_pte(pmd))
@@ -613,7 +624,18 @@ static inline pmd_t pmd_mkspecial(pmd_t pmd)#define pud_mkyoung (pud) pte_pud(pte_mkyoung(pud_pte(pud)))#define pud_write (pud) pte_write(pud_pte(pud)) -#define pud_mkhuge (pud) (__pud(pud_val(pud) & ~PUD_TABLE_BIT)) +static inline pud_t pud_mkhuge (pud_t pud) +{ +/* +* It's possible that the pud is present-invalid on entry +* and in that case it needs to remain present-invalid on +* exit. So ensure the VALID bit does not get modified. +*/ +pudval_t mask =PUD_TYPE_MASK & ~PTE_VALID ; +pudval_t val =PUD_TYPE_SECT & ~PTE_VALID ; + +return __pud ((pud_val (pud) & ~mask) | val); +}#define __pud_to_phys (pud) __pte_to_phys(pud_pte(pud))#define __phys_to_pud_val (phys) __phys_to_pte_val(phys)
Signature · 1 line
2.25.1
PATCH v2 5/8 arm64/mm: Check PXD_TYPE_TABLE in [p4d|pgd]_bad()
In reply to Anshuman KhandualCheck page table entries against PXD_TYPE_TABLE on PXD_TYPE_MASK mask bits in [p4d|pgd]_bad() while determining a table entry instead of just checking only for PXD_TABLE_BIT.
--- arch/arm64/include/asm/pgtable.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/arm64/include/asm/pgtable.h +6 -2
@@ -918,7 +918,9 @@ static inline bool mm_pud_folded(const struct mm_struct *mm) pr_err("%s:%d: bad pud %016llx.\n", __FILE__, __LINE__, pud_val(e))#define p4d_none (p4d) (pgtable_l4_enabled() && !p4d_val(p4d)) -#define p4d_bad (p4d) (pgtable_l4_enabled() && !(p4d_val(p4d) & P4D_TABLE_BIT)) +#define p4d_bad (p4d) (pgtable_l4_enabled() && \ + ((p4d_val(p4d) & P4D_TYPE_MASK) != \ + P4D_TYPE_TABLE))#define p4d_present (p4d) (!p4d_none(p4d))static inline void set_p4d (p4d_t *p4dp,p4d_t p4d)
@@ -1045,7 +1047,9 @@ static inline bool mm_p4d_folded(const struct mm_struct *mm) pr_err("%s:%d: bad p4d %016llx.\n", __FILE__, __LINE__, p4d_val(e))#define pgd_none (pgd) (pgtable_l5_enabled() && !pgd_val(pgd)) -#define pgd_bad (pgd) (pgtable_l5_enabled() && !(pgd_val(pgd) & PGD_TABLE_BIT)) +#define pgd_bad (pgd) (pgtable_l5_enabled() && \ + ((pgd_val(pgd) & PGD_TYPE_MASK) != \ + PGD_TYPE_TABLE))#define pgd_present (pgd) (!pgd_none(pgd))static inline void set_pgd (pgd_t *pgdp,pgd_t pgd)
Signature · 1 line
2.25.1
PATCH v2 6/8 arm64/mm: Check PUD_TYPE_TABLE in pud_bad()
In reply to Anshuman KhandualFrom: Ryan Roberts <[email protected]>
pud_bad() is currently defined in terms of pud_table(). Although for some configs, pud_table() is hard-coded to true i.e. when using 64K base pages or when page table levels are less than 3.
pud_bad() is intended to check that the pud is configured correctly. Hence let's open-code the same check that the full version of pud_table() uses into pud_bad(). Then it always performs the check regardless of the config.
--- arch/arm64/include/asm/pgtable.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/include/asm/pgtable.h +2 -1
@@ -827,7 +827,8 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd) pr_err("%s:%d: bad pmd %016llx.\n", __FILE__, __LINE__, pmd_val(e))#define pud_none (pud) (!pud_val(pud)) -#define pud_bad (pud) (!pud_table(pud)) +#define pud_bad (pud) ((pud_val(pud) & PUD_TYPE_MASK) != \ + PUD_TYPE_TABLE)#define pud_present (pud) pte_present(pud_pte(pud))#ifndef __PAGETABLE_PMD_FOLDED#define pud_leaf (pud) (pud_present(pud) && !pud_table(pud))
Signature · 1 line
2.25.1
PATCH v2 7/8 arm64/mm: Check pmd_table() in pmd_trans_huge()
In reply to Anshuman KhandualFrom: Ryan Roberts <[email protected]>
Check for pmd_table() in pmd_trans_huge() rather then just checking for the PMD_TABLE_BIT. But ensure all present-invalid entries are handled correctly by always setting PTE_VALID before checking with pmd_table().
--- arch/arm64/include/asm/pgtable.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
arch/arm64/include/asm/pgtable.h +12 -12
@@ -548,18 +548,6 @@ static inline int pmd_protnone(pmd_t pmd)#endif #define pmd_present (pmd) pte_present(pmd_pte(pmd)) - -/* -* THP definitions. -*/ - -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -static inline int pmd_trans_huge (pmd_t pmd) -{ -return pmd_val (pmd) &&pmd_present (pmd) && !(pmd_val (pmd) &PMD_TABLE_BIT ); -} -#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ -#define pmd_dirty (pmd) pte_dirty(pmd_pte(pmd))#define pmd_young (pmd) pte_young(pmd_pte(pmd))#define pmd_valid (pmd) pte_valid(pmd_pte(pmd))
@@ -746,6 +734,18 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,#define pmd_leaf_size (pmd) (pmd_cont(pmd) ? CONT_PMD_SIZE : PMD_SIZE)#define pte_leaf_size (pte) (pte_cont(pte) ? CONT_PTE_SIZE : PAGE_SIZE) +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +static inline int pmd_trans_huge (pmd_t pmd) +{ +/* +* If pmd is present-invalid, pmd_table() won't detect it +* as a table, so force the valid bit for the comparison. +*/ +return pmd_val (pmd) &&pmd_present (pmd) && + !pmd_table (__pmd (pmd_val (pmd) |PTE_VALID )); +} +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +#if defined(CONFIG_ARM64_64K_PAGES ) ||CONFIG_PGTABLE_LEVELS <3 static inline bool pud_sect (pud_t pud) {return false; }static inline bool pud_table (pud_t pud) {return true; }
Signature · 1 line
2.25.1
PATCH v2 8/8 arm64/mm: Drop PXD_TABLE_BIT
In reply to Anshuman KhandualDrop all PXD_TABLE_BIT macros as they are not used any more.
--- arch/arm64/include/asm/pgtable-hwdef.h | 5 ----- 1 file changed, 5 deletions(-)
arch/arm64/include/asm/pgtable-hwdef.h +0 -5
@@ -97,7 +97,6 @@* Level -1 descriptor (PGD). */ #define PGD_TYPE_TABLE (_AT(pgdval_t, 3) << 0) -#define PGD_TABLE_BIT (_AT(pgdval_t, 1) << 1)#define PGD_TYPE_MASK (_AT(pgdval_t, 3) << 0)#define PGD_TABLE_AF (_AT(pgdval_t, 1) << 10)/* Ignored if no FEAT_HAFT */ #define PGD_TABLE_PXN (_AT(pgdval_t, 1) << 59)
@@ -107,7 +106,6 @@* Level 0 descriptor (P4D). */ #define P4D_TYPE_TABLE (_AT(p4dval_t, 3) << 0) -#define P4D_TABLE_BIT (_AT(p4dval_t, 1) << 1)#define P4D_TYPE_MASK (_AT(p4dval_t, 3) << 0)#define P4D_TYPE_SECT (_AT(p4dval_t, 1) << 0)#define P4D_SECT_RDONLY (_AT(p4dval_t, 1) << 7)/* AP[2] */
@@ -119,7 +117,6 @@* Level 1 descriptor (PUD). */ #define PUD_TYPE_TABLE (_AT(pudval_t, 3) << 0) -#define PUD_TABLE_BIT (_AT(pudval_t, 1) << 1)#define PUD_TYPE_MASK (_AT(pudval_t, 3) << 0)#define PUD_TYPE_SECT (_AT(pudval_t, 1) << 0)#define PUD_SECT_RDONLY (_AT(pudval_t, 1) << 7)/* AP[2] */
@@ -133,7 +130,6 @@#define PMD_TYPE_MASK (_AT(pmdval_t, 3) << 0)#define PMD_TYPE_TABLE (_AT(pmdval_t, 3) << 0)#define PMD_TYPE_SECT (_AT(pmdval_t, 1) << 0) -#define PMD_TABLE_BIT (_AT(pmdval_t, 1) << 1)#define PMD_TABLE_AF (_AT(pmdval_t, 1) << 10)/* Ignored if no FEAT_HAFT */ /*
@@ -162,7 +158,6 @@#define PTE_VALID (_AT(pteval_t, 1) << 0)#define PTE_TYPE_MASK (_AT(pteval_t, 3) << 0)#define PTE_TYPE_PAGE (_AT(pteval_t, 3) << 0) -#define PTE_TABLE_BIT (_AT(pteval_t, 1) << 1)#define PTE_USER (_AT(pteval_t, 1) << 6)/* AP[1] */ #define PTE_RDONLY (_AT(pteval_t, 1) << 7)/* AP[2] */ #define PTE_SHARED (_AT(pteval_t, 3) << 8)/* SH[1:0], inner shareable */
Signature · 1 line
2.25.1
Quoted 45 lines · Anshuman Khandual
Remove the
PXX_TABLE_BITdefinitions and instead rely onPXX_TYPE_MASK,PXX_TYPE_SECTandPXX_TYPE_TABLE. The latter versions are more abstract and also include thePTE_VALIDbit.This abstraction is valuable for the impending D128 page table support, which doesn't have a single page table bit to determine table vs block. Instead it has the skip level (SKL) field, where it will consider 0 to mean table and any other value to mean a block entry. So
PXX_TABLE_BITtherefore doesn't fit into the D128 model well, but the type fields do.This series applies on v6.14-rc3.
Changes in V2:
- Changed
pmd_mkhuge()andpud_mkhuge()implementation
- Changedpud_bad()implementation with an additional patchChanges in V1:
https://lore.kernel.org/all/[email protected]/
Cc Marc Zyngier <[email protected]>Cc Oliver Upton <[email protected]>Cc James Morse <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Ard Biesheuvel <[email protected]>Cc Ryan Roberts <[email protected]>Cc Mark Rutland <[email protected]>Anshuman Khandual (6):
KVM: arm64: ptdump: TestPMD_TYPE_MASKfor block mapping arm64/ptdump: TestPMD_TYPE_MASKfor block mapping
arm64/mm: ClearPXX_TYPE_MASKin mk_[pmd|pud]_sect_prot() arm64/mm: ClearPXX_TYPE_MASKand setPXD_TYPE_SECTin [pmd|pud]_mkhuge() arm64/mm: CheckPXD_TYPE_TABLEin [p4d|pgd]_bad()
arm64/mm: DropPXD_TABLE_BITRyan Roberts (2):
arm64/mm: CheckPUD_TYPE_TABLEinpud_bad()
arm64/mm: Checkpmd_table()inpmd_trans_huge()
Quoted 6 lines
arch/arm64/include/asm/pgtable-hwdef.h | 5 -- arch/arm64/include/asm/pgtable.h | 65 ++++++++++++++++++-------- arch/arm64/kvm/ptdump.c | 4 +- arch/arm64/mm/ptdump.c | 4 +- 4 files changed, 50 insertions(+), 28 deletions(-)
Gentle ping, just wondering any updates on the series.
Quoted 9 lines · Anshuman Khandual
Remove the
PXX_TABLE_BITdefinitions and instead rely onPXX_TYPE_MASK,PXX_TYPE_SECTandPXX_TYPE_TABLE. The latter versions are more abstract and also include thePTE_VALIDbit.This abstraction is valuable for the impending D128 page table support, which doesn't have a single page table bit to determine table vs block. Instead it has the skip level (SKL) field, where it will consider 0 to mean table and any other value to mean a block entry. So
PXX_TABLE_BITtherefore doesn't fit into the D128 model well, but the type fields do.
All the patches look logically correct to me and I agree with the intention of removing PXX_TABLE_BIT. But personally I'd prefer to see a single patch that just does everything that's required to remove PXX_TABLE_BIT. And then a second patch for the pud_bad() fix/improvement (currently patch 6) which is orthogonal to the removal of PXX_TABLE_BIT.
That would make it much easier to review IMHO, and would also allow for writing a single commit log which provides the justification for the change. I find the current set of 7 commit logs to not be hugely helpful.
But I wrote the original patches and wrote them as I'm suggesting, so I would say that :)
I'm guessing I shouldn't provide a Reviewed-By here, given I wrote the code originally...
Thanks,
Ryan
Quoted 42 lines
This series applies on v6.14-rc3.
Changes in V2:
- Changed
pmd_mkhuge()andpud_mkhuge()implementation
- Changedpud_bad()implementation with an additional patchChanges in V1:
https://lore.kernel.org/all/[email protected]/
Cc Marc Zyngier <[email protected]>Cc Oliver Upton <[email protected]>Cc James Morse <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Ard Biesheuvel <[email protected]>Cc Ryan Roberts <[email protected]>Cc Mark Rutland <[email protected]>Anshuman Khandual (6):
KVM: arm64: ptdump: TestPMD_TYPE_MASKfor block mapping arm64/ptdump: TestPMD_TYPE_MASKfor block mapping
arm64/mm: ClearPXX_TYPE_MASKin mk_[pmd|pud]_sect_prot() arm64/mm: ClearPXX_TYPE_MASKand setPXD_TYPE_SECTin [pmd|pud]_mkhuge() arm64/mm: CheckPXD_TYPE_TABLEin [p4d|pgd]_bad()
arm64/mm: DropPXD_TABLE_BITRyan Roberts (2):
arm64/mm: CheckPUD_TYPE_TABLEinpud_bad()
arm64/mm: Checkpmd_table()inpmd_trans_huge()arch/arm64/include/asm/pgtable-hwdef.h | 5 -- arch/arm64/include/asm/pgtable.h | 65 ++++++++++++++++++-------- arch/arm64/kvm/ptdump.c | 4 +- arch/arm64/mm/ptdump.c | 4 +- 4 files changed, 50 insertions(+), 28 deletions(-)
Quoted 17 lines · Ryan Roberts
Quoted 9 lines · Anshuman Khandual
Remove the
PXX_TABLE_BITdefinitions and instead rely onPXX_TYPE_MASK,PXX_TYPE_SECTandPXX_TYPE_TABLE. The latter versions are more abstract and also include thePTE_VALIDbit.This abstraction is valuable for the impending D128 page table support, which doesn't have a single page table bit to determine table vs block. Instead it has the skip level (SKL) field, where it will consider 0 to mean table and any other value to mean a block entry. So
PXX_TABLE_BITtherefore doesn't fit into the D128 model well, but the type fields do.All the patches look logically correct to me and I agree with the intention of removing
PXX_TABLE_BIT. But personally I'd prefer to see a single patch that just does everything that's required to removePXX_TABLE_BIT. And then a second patch for thepud_bad()fix/improvement (currently patch 6) which is orthogonal to the removal ofPXX_TABLE_BIT.
Quoted 3 lines
That would make it much easier to review IMHO, and would also allow for writing a single commit log which provides the justification for the change. I find the current set of 7 commit logs to not be hugely helpful.
Dropping PXX_TABLE_BIT from individual functional components which stand on their own progressively leads to its complete removal from the tree. Even though goal is PXX_TABLE_BIT mask's complete removal, each patch here could be justified on its own improving consistent reasoning around various section mapping creation and identification while keeping the functionality unchanged and also improving code readability as well.
Quoted 3 lines
But I wrote the original patches and wrote them as I'm suggesting, so I would say that :)
I can understand :) Although it also follows and expands on the previous attempt in removing this mask that formed a patch series instead.
https://lore.kernel.org/all/[email protected]/
TBH this is not a big deal. I can merge all but last one into a single patch as you have suggested if that's a general consensus. Although I would prefer the current logically progressive series based approach but that's just me.
Quoted 51 lines
I'm guessing I shouldn't provide a Reviewed-By here, given I wrote the code originally...
Thanks,
RyanQuoted 42 lines
This series applies on v6.14-rc3.
Changes in V2:
- Changed
pmd_mkhuge()andpud_mkhuge()implementation
- Changedpud_bad()implementation with an additional patchChanges in V1:
https://lore.kernel.org/all/[email protected]/
Cc Marc Zyngier <[email protected]>Cc Oliver Upton <[email protected]>Cc James Morse <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Ard Biesheuvel <[email protected]>Cc Ryan Roberts <[email protected]>Cc Mark Rutland <[email protected]>Anshuman Khandual (6):
KVM: arm64: ptdump: TestPMD_TYPE_MASKfor block mapping arm64/ptdump: TestPMD_TYPE_MASKfor block mapping
arm64/mm: ClearPXX_TYPE_MASKin mk_[pmd|pud]_sect_prot() arm64/mm: ClearPXX_TYPE_MASKand setPXD_TYPE_SECTin [pmd|pud]_mkhuge() arm64/mm: CheckPXD_TYPE_TABLEin [p4d|pgd]_bad()
arm64/mm: DropPXD_TABLE_BITRyan Roberts (2):
arm64/mm: CheckPUD_TYPE_TABLEinpud_bad()
arm64/mm: Checkpmd_table()inpmd_trans_huge()arch/arm64/include/asm/pgtable-hwdef.h | 5 -- arch/arm64/include/asm/pgtable.h | 65 ++++++++++++++++++-------- arch/arm64/kvm/ptdump.c | 4 +- arch/arm64/mm/ptdump.c | 4 +- 4 files changed, 50 insertions(+), 28 deletions(-)
Quoted 35 lines · Anshuman Khandual
Quoted 17 lines · Ryan Roberts
Quoted 9 lines · Anshuman Khandual
Remove the
PXX_TABLE_BITdefinitions and instead rely onPXX_TYPE_MASK,PXX_TYPE_SECTandPXX_TYPE_TABLE. The latter versions are more abstract and also include thePTE_VALIDbit.This abstraction is valuable for the impending D128 page table support, which doesn't have a single page table bit to determine table vs block. Instead it has the skip level (SKL) field, where it will consider 0 to mean table and any other value to mean a block entry. So
PXX_TABLE_BITtherefore doesn't fit into the D128 model well, but the type fields do.All the patches look logically correct to me and I agree with the intention of removing
PXX_TABLE_BIT. But personally I'd prefer to see a single patch that just does everything that's required to removePXX_TABLE_BIT. And then a second patch for thepud_bad()fix/improvement (currently patch 6) which is orthogonal to the removal ofPXX_TABLE_BIT.Quoted 3 lines
That would make it much easier to review IMHO, and would also allow for writing a single commit log which provides the justification for the change. I find the current set of 7 commit logs to not be hugely helpful.
Dropping
PXX_TABLE_BITfrom individual functional components which stand on their own progressively leads to its complete removal from the tree. Even though goal isPXX_TABLE_BITmask's complete removal, each patch here could be justified on its own improving consistent reasoning around various section mapping creation and identification while keeping the functionality unchanged and also improving code readability as well.Quoted 3 lines
But I wrote the original patches and wrote them as I'm suggesting, so I would say that :)
Quoted 8 lines
I can understand :) Although it also follows and expands on the previous attempt in removing this mask that formed a patch series instead.
https://lore.kernel.org/all/[email protected]/
TBH this is not a big deal. I can merge all but last one into a single patch as you have suggested if that's a general consensus. Although I would prefer the current logically progressive series based approach but that's just me.
I guess leave as is for now and see what others say.
Quoted 52 lines
Quoted 52 lines
I'm guessing I shouldn't provide a Reviewed-By here, given I wrote the code originally...
Thanks,
RyanQuoted 42 lines
This series applies on v6.14-rc3.
Changes in V2:
- Changed
pmd_mkhuge()andpud_mkhuge()implementation
- Changedpud_bad()implementation with an additional patchChanges in V1:
https://lore.kernel.org/all/[email protected]/
Cc Marc Zyngier <[email protected]>Cc Oliver Upton <[email protected]>Cc James Morse <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Ard Biesheuvel <[email protected]>Cc Ryan Roberts <[email protected]>Cc Mark Rutland <[email protected]>Anshuman Khandual (6):
KVM: arm64: ptdump: TestPMD_TYPE_MASKfor block mapping arm64/ptdump: TestPMD_TYPE_MASKfor block mapping
arm64/mm: ClearPXX_TYPE_MASKin mk_[pmd|pud]_sect_prot() arm64/mm: ClearPXX_TYPE_MASKand setPXD_TYPE_SECTin [pmd|pud]_mkhuge() arm64/mm: CheckPXD_TYPE_TABLEin [p4d|pgd]_bad()
arm64/mm: DropPXD_TABLE_BITRyan Roberts (2):
arm64/mm: CheckPUD_TYPE_TABLEinpud_bad()
arm64/mm: Checkpmd_table()inpmd_trans_huge()arch/arm64/include/asm/pgtable-hwdef.h | 5 -- arch/arm64/include/asm/pgtable.h | 65 ++++++++++++++++++-------- arch/arm64/kvm/ptdump.c | 4 +- arch/arm64/mm/ptdump.c | 4 +- 4 files changed, 50 insertions(+), 28 deletions(-)
Quoted 45 lines · Anshuman Khandual
Remove the
PXX_TABLE_BITdefinitions and instead rely onPXX_TYPE_MASK,PXX_TYPE_SECTandPXX_TYPE_TABLE. The latter versions are more abstract and also include thePTE_VALIDbit.This abstraction is valuable for the impending D128 page table support, which doesn't have a single page table bit to determine table vs block. Instead it has the skip level (SKL) field, where it will consider 0 to mean table and any other value to mean a block entry. So
PXX_TABLE_BITtherefore doesn't fit into the D128 model well, but the type fields do.This series applies on v6.14-rc3.
Changes in V2:
- Changed
pmd_mkhuge()andpud_mkhuge()implementation
- Changedpud_bad()implementation with an additional patchChanges in V1:
https://lore.kernel.org/all/[email protected]/
Cc Marc Zyngier <[email protected]>Cc Oliver Upton <[email protected]>Cc James Morse <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Ard Biesheuvel <[email protected]>Cc Ryan Roberts <[email protected]>Cc Mark Rutland <[email protected]>Anshuman Khandual (6):
KVM: arm64: ptdump: TestPMD_TYPE_MASKfor block mapping arm64/ptdump: TestPMD_TYPE_MASKfor block mapping
arm64/mm: ClearPXX_TYPE_MASKin mk_[pmd|pud]_sect_prot() arm64/mm: ClearPXX_TYPE_MASKand setPXD_TYPE_SECTin [pmd|pud]_mkhuge() arm64/mm: CheckPXD_TYPE_TABLEin [p4d|pgd]_bad()
arm64/mm: DropPXD_TABLE_BITRyan Roberts (2):
arm64/mm: CheckPUD_TYPE_TABLEinpud_bad()
arm64/mm: Checkpmd_table()inpmd_trans_huge()
Quoted 6 lines
arch/arm64/include/asm/pgtable-hwdef.h | 5 -- arch/arm64/include/asm/pgtable.h | 65 ++++++++++++++++++-------- arch/arm64/kvm/ptdump.c | 4 +- arch/arm64/mm/ptdump.c | 4 +- 4 files changed, 50 insertions(+), 28 deletions(-)
Gentle ping again. Does this series look okay or is there any objection ?
Quoted 11 lines · Anshuman Khandual
Remove the
PXX_TABLE_BITdefinitions and instead rely onPXX_TYPE_MASK,PXX_TYPE_SECTandPXX_TYPE_TABLE. The latter versions are more abstract and also include thePTE_VALIDbit.This abstraction is valuable for the impending D128 page table support, which doesn't have a single page table bit to determine table vs block. Instead it has the skip level (SKL) field, where it will consider 0 to mean table and any other value to mean a block entry. So
PXX_TABLE_BITtherefore doesn't fit into the D128 model well, but the type fields do.[...]
Applied to arm64 (for-next/drop-pxd_table_bit), thanks!
[1/8] KVM: arm64: ptdump: Test PMD_TYPE_MASK for block mapping
https://git.kernel.org/arm64/c/0b626b245c57 [2/8] arm64/ptdump: Test PMD_TYPE_MASK for block mapping https://git.kernel.org/arm64/c/f5e93819e2cc [3/8] arm64/mm: Clear PXX_TYPE_MASK in mk_[pmd|pud]_sect_prot() https://git.kernel.org/arm64/c/dba954801004 [4/8] arm64/mm: Clear PXX_TYPE_MASK and set PXD_TYPE_SECT in [pmd|pud]_mkhuge() https://git.kernel.org/arm64/c/1601df9e366e [5/8] arm64/mm: Check PXD_TYPE_TABLE in [p4d|pgd]_bad() https://git.kernel.org/arm64/c/4fa8a9c0fc99 [6/8] arm64/mm: Check PUD_TYPE_TABLE in pud_bad() https://git.kernel.org/arm64/c/bfb1d2b9021c [7/8] arm64/mm: Check pmd_table() in pmd_trans_huge() https://git.kernel.org/arm64/c/d1770e909898 [8/8] arm64/mm: Drop PXD_TABLE_BIT https://git.kernel.org/arm64/c/50c2726654bb
Signature · 1 line
Catalin