* [PATCH V2 1/8] KVM: arm64: ptdump: Test PMD_TYPE_MASK for block mapping
2025-02-21 4:42 [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT Anshuman Khandual
@ 2025-02-21 4:42 ` Anshuman Khandual
2025-03-11 18:10 ` Catalin Marinas
2025-02-21 4:42 ` [PATCH V2 2/8] arm64/ptdump: " Anshuman Khandual
` (10 subsequent siblings)
11 siblings, 1 reply; 17+ messages in thread
From: Anshuman Khandual @ 2025-02-21 4:42 UTC (permalink / raw)
To: arm-kernel
Cc: Anshuman Khandual, Marc Zyngier, Oliver Upton, James Morse,
Catalin Marinas, Will Deacon, Ard Biesheuvel, Ryan Roberts,
Mark Rutland, kvmarm, linux-arm-kernel, linux-kernel
Test given page table entries against PMD_TYPE_SECT on PMD_TYPE_MASK mask
bits for identifying block mappings in stage 2 page tables.
Cc: Marc Zyngier <maz@kernel.org>
Cc: Oliver Upton <oliver.upton@linux.dev>
Cc: James Morse <james.morse@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: kvmarm@lists.linux.dev
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
arch/arm64/kvm/ptdump.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kvm/ptdump.c b/arch/arm64/kvm/ptdump.c
index e4a342e903e2..098416d7e5c2 100644
--- a/arch/arm64/kvm/ptdump.c
+++ b/arch/arm64/kvm/ptdump.c
@@ -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 = " ",
},
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH V2 1/8] KVM: arm64: ptdump: Test PMD_TYPE_MASK for block mapping
2025-02-21 4:42 ` [PATCH V2 1/8] KVM: arm64: ptdump: Test PMD_TYPE_MASK for block mapping Anshuman Khandual
@ 2025-03-11 18:10 ` Catalin Marinas
2025-03-11 18:22 ` Marc Zyngier
0 siblings, 1 reply; 17+ messages in thread
From: Catalin Marinas @ 2025-03-11 18:10 UTC (permalink / raw)
To: Marc Zyngier, Oliver Upton, Anshuman Khandual
Cc: arm-kernel, James Morse, Will Deacon, Ard Biesheuvel,
Ryan Roberts, Mark Rutland, kvmarm, linux-arm-kernel,
linux-kernel
On Fri, Feb 21, 2025 at 10:12:20AM +0530, Anshuman Khandual wrote:
> Test given page table entries against PMD_TYPE_SECT on PMD_TYPE_MASK mask
> bits for identifying block mappings in stage 2 page tables.
>
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Oliver Upton <oliver.upton@linux.dev>
> Cc: James Morse <james.morse@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: kvmarm@lists.linux.dev
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> arch/arm64/kvm/ptdump.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kvm/ptdump.c b/arch/arm64/kvm/ptdump.c
> index e4a342e903e2..098416d7e5c2 100644
> --- a/arch/arm64/kvm/ptdump.c
> +++ b/arch/arm64/kvm/ptdump.c
> @@ -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.
--
Catalin
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH V2 1/8] KVM: arm64: ptdump: Test PMD_TYPE_MASK for block mapping
2025-03-11 18:10 ` Catalin Marinas
@ 2025-03-11 18:22 ` Marc Zyngier
0 siblings, 0 replies; 17+ messages in thread
From: Marc Zyngier @ 2025-03-11 18:22 UTC (permalink / raw)
To: Catalin Marinas
Cc: Oliver Upton, Anshuman Khandual, arm-kernel, James Morse,
Will Deacon, Ard Biesheuvel, Ryan Roberts, Mark Rutland, kvmarm,
linux-arm-kernel, linux-kernel
On 2025-03-11 18:10, Catalin Marinas wrote:
> On Fri, Feb 21, 2025 at 10:12:20AM +0530, Anshuman Khandual wrote:
>> Test given page table entries against PMD_TYPE_SECT on PMD_TYPE_MASK
>> mask
>> bits for identifying block mappings in stage 2 page tables.
>>
>> Cc: Marc Zyngier <maz@kernel.org>
>> Cc: Oliver Upton <oliver.upton@linux.dev>
>> Cc: James Morse <james.morse@arm.com>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will@kernel.org>
>> Cc: linux-arm-kernel@lists.infradead.org
>> Cc: kvmarm@lists.linux.dev
>> Cc: linux-kernel@vger.kernel.org
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>> ---
>> arch/arm64/kvm/ptdump.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm64/kvm/ptdump.c b/arch/arm64/kvm/ptdump.c
>> index e4a342e903e2..098416d7e5c2 100644
>> --- a/arch/arm64/kvm/ptdump.c
>> +++ b/arch/arm64/kvm/ptdump.c
>> @@ -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?
Yup, looks OK to me.
Acked-by: Marc Zyngier <maz@kernel.org>
M.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH V2 2/8] arm64/ptdump: Test PMD_TYPE_MASK for block mapping
2025-02-21 4:42 [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT Anshuman Khandual
2025-02-21 4:42 ` [PATCH V2 1/8] KVM: arm64: ptdump: Test PMD_TYPE_MASK for block mapping Anshuman Khandual
@ 2025-02-21 4:42 ` Anshuman Khandual
2025-02-21 4:42 ` [PATCH V2 3/8] arm64/mm: Clear PXX_TYPE_MASK in mk_[pmd|pud]_sect_prot() Anshuman Khandual
` (9 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Anshuman Khandual @ 2025-02-21 4:42 UTC (permalink / raw)
To: arm-kernel
Cc: Anshuman Khandual, Marc Zyngier, Oliver Upton, James Morse,
Catalin Marinas, Will Deacon, Ard Biesheuvel, Ryan Roberts,
Mark Rutland, kvmarm, linux-arm-kernel, linux-kernel
Test given page table entries against PMD_TYPE_SECT on PMD_TYPE_MASK mask
bits for identifying block mappings in stage 1 page tables.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
arch/arm64/mm/ptdump.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c
index 688fbe0271ca..8cec0da4cff2 100644
--- a/arch/arm64/mm/ptdump.c
+++ b/arch/arm64/mm/ptdump.c
@@ -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 = " ",
}, {
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH V2 3/8] arm64/mm: Clear PXX_TYPE_MASK in mk_[pmd|pud]_sect_prot()
2025-02-21 4:42 [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT Anshuman Khandual
2025-02-21 4:42 ` [PATCH V2 1/8] KVM: arm64: ptdump: Test PMD_TYPE_MASK for block mapping Anshuman Khandual
2025-02-21 4:42 ` [PATCH V2 2/8] arm64/ptdump: " Anshuman Khandual
@ 2025-02-21 4:42 ` Anshuman Khandual
2025-02-21 4:42 ` [PATCH V2 4/8] arm64/mm: Clear PXX_TYPE_MASK and set PXD_TYPE_SECT in [pmd|pud]_mkhuge() Anshuman Khandual
` (8 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Anshuman Khandual @ 2025-02-21 4:42 UTC (permalink / raw)
To: arm-kernel
Cc: Anshuman Khandual, Marc Zyngier, Oliver Upton, James Morse,
Catalin Marinas, Will Deacon, Ard Biesheuvel, Ryan Roberts,
Mark Rutland, kvmarm, linux-arm-kernel, linux-kernel
Clear PXX_TYPE_MASK bits in mk_[pmd|pud]_sect_prot() while creating section
mappings instead of just clearing the PXX_TABLE_BIT.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
arch/arm64/include/asm/pgtable.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 0b2a2ad1b9e8..c16e9e74e309 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -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)
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH V2 4/8] arm64/mm: Clear PXX_TYPE_MASK and set PXD_TYPE_SECT in [pmd|pud]_mkhuge()
2025-02-21 4:42 [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT Anshuman Khandual
` (2 preceding siblings ...)
2025-02-21 4:42 ` [PATCH V2 3/8] arm64/mm: Clear PXX_TYPE_MASK in mk_[pmd|pud]_sect_prot() Anshuman Khandual
@ 2025-02-21 4:42 ` Anshuman Khandual
2025-02-21 4:42 ` [PATCH V2 5/8] arm64/mm: Check PXD_TYPE_TABLE in [p4d|pgd]_bad() Anshuman Khandual
` (7 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Anshuman Khandual @ 2025-02-21 4:42 UTC (permalink / raw)
To: arm-kernel
Cc: Anshuman Khandual, Marc Zyngier, Oliver Upton, James Morse,
Catalin Marinas, Will Deacon, Ard Biesheuvel, Ryan Roberts,
Mark Rutland, kvmarm, linux-arm-kernel, linux-kernel
Clear 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.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
arch/arm64/include/asm/pgtable.h | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index c16e9e74e309..4485ecdffd8a 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -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)
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH V2 5/8] arm64/mm: Check PXD_TYPE_TABLE in [p4d|pgd]_bad()
2025-02-21 4:42 [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT Anshuman Khandual
` (3 preceding siblings ...)
2025-02-21 4:42 ` [PATCH V2 4/8] arm64/mm: Clear PXX_TYPE_MASK and set PXD_TYPE_SECT in [pmd|pud]_mkhuge() Anshuman Khandual
@ 2025-02-21 4:42 ` Anshuman Khandual
2025-02-21 4:42 ` [PATCH V2 6/8] arm64/mm: Check PUD_TYPE_TABLE in pud_bad() Anshuman Khandual
` (6 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Anshuman Khandual @ 2025-02-21 4:42 UTC (permalink / raw)
To: arm-kernel
Cc: Anshuman Khandual, Marc Zyngier, Oliver Upton, James Morse,
Catalin Marinas, Will Deacon, Ard Biesheuvel, Ryan Roberts,
Mark Rutland, kvmarm, linux-arm-kernel, linux-kernel
Check 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.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
arch/arm64/include/asm/pgtable.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 4485ecdffd8a..0c1691979c14 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -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)
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH V2 6/8] arm64/mm: Check PUD_TYPE_TABLE in pud_bad()
2025-02-21 4:42 [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT Anshuman Khandual
` (4 preceding siblings ...)
2025-02-21 4:42 ` [PATCH V2 5/8] arm64/mm: Check PXD_TYPE_TABLE in [p4d|pgd]_bad() Anshuman Khandual
@ 2025-02-21 4:42 ` Anshuman Khandual
2025-02-21 4:42 ` [PATCH V2 7/8] arm64/mm: Check pmd_table() in pmd_trans_huge() Anshuman Khandual
` (5 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Anshuman Khandual @ 2025-02-21 4:42 UTC (permalink / raw)
To: arm-kernel
Cc: Anshuman Khandual, Marc Zyngier, Oliver Upton, James Morse,
Catalin Marinas, Will Deacon, Ard Biesheuvel, Ryan Roberts,
Mark Rutland, kvmarm, linux-arm-kernel, linux-kernel
From: Ryan Roberts <ryan.roberts@arm.com>
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.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
arch/arm64/include/asm/pgtable.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 0c1691979c14..d16f514bde0f 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -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))
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH V2 7/8] arm64/mm: Check pmd_table() in pmd_trans_huge()
2025-02-21 4:42 [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT Anshuman Khandual
` (5 preceding siblings ...)
2025-02-21 4:42 ` [PATCH V2 6/8] arm64/mm: Check PUD_TYPE_TABLE in pud_bad() Anshuman Khandual
@ 2025-02-21 4:42 ` Anshuman Khandual
2025-02-21 4:42 ` [PATCH V2 8/8] arm64/mm: Drop PXD_TABLE_BIT Anshuman Khandual
` (4 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Anshuman Khandual @ 2025-02-21 4:42 UTC (permalink / raw)
To: arm-kernel
Cc: Anshuman Khandual, Marc Zyngier, Oliver Upton, James Morse,
Catalin Marinas, Will Deacon, Ard Biesheuvel, Ryan Roberts,
Mark Rutland, kvmarm, linux-arm-kernel, linux-kernel
From: Ryan Roberts <ryan.roberts@arm.com>
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().
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
arch/arm64/include/asm/pgtable.h | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index d16f514bde0f..df89e8ec8413 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -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; }
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH V2 8/8] arm64/mm: Drop PXD_TABLE_BIT
2025-02-21 4:42 [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT Anshuman Khandual
` (6 preceding siblings ...)
2025-02-21 4:42 ` [PATCH V2 7/8] arm64/mm: Check pmd_table() in pmd_trans_huge() Anshuman Khandual
@ 2025-02-21 4:42 ` Anshuman Khandual
2025-02-28 3:42 ` [PATCH V2 0/8] " Anshuman Khandual
` (3 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Anshuman Khandual @ 2025-02-21 4:42 UTC (permalink / raw)
To: arm-kernel
Cc: Anshuman Khandual, Marc Zyngier, Oliver Upton, James Morse,
Catalin Marinas, Will Deacon, Ard Biesheuvel, Ryan Roberts,
Mark Rutland, kvmarm, linux-arm-kernel, linux-kernel
Drop all PXD_TABLE_BIT macros as they are not used any more.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
arch/arm64/include/asm/pgtable-hwdef.h | 5 -----
1 file changed, 5 deletions(-)
diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h
index a9136cc551cc..d2a13c329702 100644
--- a/arch/arm64/include/asm/pgtable-hwdef.h
+++ b/arch/arm64/include/asm/pgtable-hwdef.h
@@ -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 */
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT
2025-02-21 4:42 [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT Anshuman Khandual
` (7 preceding siblings ...)
2025-02-21 4:42 ` [PATCH V2 8/8] arm64/mm: Drop PXD_TABLE_BIT Anshuman Khandual
@ 2025-02-28 3:42 ` Anshuman Khandual
2025-02-28 15:32 ` Ryan Roberts
` (2 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Anshuman Khandual @ 2025-02-28 3:42 UTC (permalink / raw)
To: arm-kernel
Cc: Marc Zyngier, Oliver Upton, James Morse, Catalin Marinas,
Will Deacon, Ard Biesheuvel, Ryan Roberts, Mark Rutland, kvmarm,
linux-arm-kernel, linux-kernel
On 2/21/25 10:12, Anshuman Khandual wrote:
> 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/20241005123824.1366397-1-anshuman.khandual@arm.com/
>
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Oliver Upton <oliver.upton@linux.dev>
> Cc: James Morse <james.morse@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: kvmarm@lists.linux.dev
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
>
> 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(-)
>
Gentle ping, just wondering any updates on the series.
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT
2025-02-21 4:42 [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT Anshuman Khandual
` (8 preceding siblings ...)
2025-02-28 3:42 ` [PATCH V2 0/8] " Anshuman Khandual
@ 2025-02-28 15:32 ` Ryan Roberts
2025-03-03 5:02 ` Anshuman Khandual
2025-03-10 6:38 ` Anshuman Khandual
2025-03-12 18:09 ` Catalin Marinas
11 siblings, 1 reply; 17+ messages in thread
From: Ryan Roberts @ 2025-02-28 15:32 UTC (permalink / raw)
To: Anshuman Khandual, arm-kernel
Cc: Marc Zyngier, Oliver Upton, James Morse, Catalin Marinas,
Will Deacon, Ard Biesheuvel, Mark Rutland, kvmarm,
linux-arm-kernel, linux-kernel
On 21/02/2025 04:42, Anshuman Khandual wrote:
> 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.
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
>
> 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/20241005123824.1366397-1-anshuman.khandual@arm.com/
>
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Oliver Upton <oliver.upton@linux.dev>
> Cc: James Morse <james.morse@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: kvmarm@lists.linux.dev
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
>
> 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(-)
>
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT
2025-02-28 15:32 ` Ryan Roberts
@ 2025-03-03 5:02 ` Anshuman Khandual
2025-03-03 10:23 ` Ryan Roberts
0 siblings, 1 reply; 17+ messages in thread
From: Anshuman Khandual @ 2025-03-03 5:02 UTC (permalink / raw)
To: Ryan Roberts, arm-kernel
Cc: Marc Zyngier, Oliver Upton, James Morse, Catalin Marinas,
Will Deacon, Ard Biesheuvel, Mark Rutland, kvmarm,
linux-arm-kernel, linux-kernel
On 2/28/25 21:02, Ryan Roberts wrote:
> On 21/02/2025 04:42, Anshuman Khandual wrote:
>> 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.
>
> 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.
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.
>
> 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/20241005123824.1366397-1-anshuman.khandual@arm.com/
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'm guessing I shouldn't provide a Reviewed-By here, given I wrote the code
> originally...
>
> Thanks,
> Ryan
>
>
>>
>> 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/20241005123824.1366397-1-anshuman.khandual@arm.com/
>>
>> Cc: Marc Zyngier <maz@kernel.org>
>> Cc: Oliver Upton <oliver.upton@linux.dev>
>> Cc: James Morse <james.morse@arm.com>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will@kernel.org>
>> Cc: Ard Biesheuvel <ardb@kernel.org>
>> Cc: Ryan Roberts <ryan.roberts@arm.com>
>> Cc: Mark Rutland <mark.rutland@arm.com>
>> Cc: kvmarm@lists.linux.dev
>> Cc: linux-arm-kernel@lists.infradead.org
>> Cc: linux-kernel@vger.kernel.org
>>
>> 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(-)
>>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT
2025-03-03 5:02 ` Anshuman Khandual
@ 2025-03-03 10:23 ` Ryan Roberts
0 siblings, 0 replies; 17+ messages in thread
From: Ryan Roberts @ 2025-03-03 10:23 UTC (permalink / raw)
To: Anshuman Khandual, arm-kernel
Cc: Marc Zyngier, Oliver Upton, James Morse, Catalin Marinas,
Will Deacon, Ard Biesheuvel, Mark Rutland, kvmarm,
linux-arm-kernel, linux-kernel
On 03/03/2025 05:02, Anshuman Khandual wrote:
>
>
> On 2/28/25 21:02, Ryan Roberts wrote:
>> On 21/02/2025 04:42, Anshuman Khandual wrote:
>>> 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.
>>
>> 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.
>
> 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.
>
>>
>> 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/20241005123824.1366397-1-anshuman.khandual@arm.com/
>
> 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.
>
>>
>> I'm guessing I shouldn't provide a Reviewed-By here, given I wrote the code
>> originally...
>>
>> Thanks,
>> Ryan
>>
>>
>>>
>>> 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/20241005123824.1366397-1-anshuman.khandual@arm.com/
>>>
>>> Cc: Marc Zyngier <maz@kernel.org>
>>> Cc: Oliver Upton <oliver.upton@linux.dev>
>>> Cc: James Morse <james.morse@arm.com>
>>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>>> Cc: Will Deacon <will@kernel.org>
>>> Cc: Ard Biesheuvel <ardb@kernel.org>
>>> Cc: Ryan Roberts <ryan.roberts@arm.com>
>>> Cc: Mark Rutland <mark.rutland@arm.com>
>>> Cc: kvmarm@lists.linux.dev
>>> Cc: linux-arm-kernel@lists.infradead.org
>>> Cc: linux-kernel@vger.kernel.org
>>>
>>> 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(-)
>>>
>>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT
2025-02-21 4:42 [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT Anshuman Khandual
` (9 preceding siblings ...)
2025-02-28 15:32 ` Ryan Roberts
@ 2025-03-10 6:38 ` Anshuman Khandual
2025-03-12 18:09 ` Catalin Marinas
11 siblings, 0 replies; 17+ messages in thread
From: Anshuman Khandual @ 2025-03-10 6:38 UTC (permalink / raw)
To: arm-kernel
Cc: Marc Zyngier, Oliver Upton, James Morse, Catalin Marinas,
Will Deacon, Ard Biesheuvel, Ryan Roberts, Mark Rutland, kvmarm,
linux-arm-kernel, linux-kernel
On 2/21/25 10:12, Anshuman Khandual wrote:
> 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/20241005123824.1366397-1-anshuman.khandual@arm.com/
>
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Oliver Upton <oliver.upton@linux.dev>
> Cc: James Morse <james.morse@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: kvmarm@lists.linux.dev
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
>
> 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(-)
>
Gentle ping again. Does this series look okay or is there any objection ?
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT
2025-02-21 4:42 [PATCH V2 0/8] arm64/mm: Drop PXD_TABLE_BIT Anshuman Khandual
` (10 preceding siblings ...)
2025-03-10 6:38 ` Anshuman Khandual
@ 2025-03-12 18:09 ` Catalin Marinas
11 siblings, 0 replies; 17+ messages in thread
From: Catalin Marinas @ 2025-03-12 18:09 UTC (permalink / raw)
To: arm-kernel, Anshuman Khandual
Cc: Will Deacon, Marc Zyngier, Oliver Upton, James Morse,
Ard Biesheuvel, Ryan Roberts, Mark Rutland, kvmarm,
linux-arm-kernel, linux-kernel
On Fri, 21 Feb 2025 10:12:19 +0530, Anshuman Khandual wrote:
> 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.
>
> [...]
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
--
Catalin
^ permalink raw reply [flat|nested] 17+ messages in thread