* [PATCH] arm64/mm: Ensure adequate HUGE_MAX_HSTATE
@ 2024-12-02 6:44 Anshuman Khandual
2024-12-02 11:52 ` Ryan Roberts
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Anshuman Khandual @ 2024-12-02 6:44 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Anshuman Khandual, Catalin Marinas, Will Deacon, Ard Biesheuvel,
Ryan Roberts, Mark Rutland, linux-kernel
This asserts that HUGE_MAX_HSTATE is sufficient enough preventing potential
hugetlb_max_hstate runtime overflow in hugetlb_add_hstate() thus triggering
a BUG_ON() there after.
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>
---
This patch applies on v6.13-rc1
arch/arm64/mm/hugetlbpage.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index 3215adf48a1b..98a2a0e64e25 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -519,6 +519,18 @@ pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
static int __init hugetlbpage_init(void)
{
+ /*
+ * HugeTLB pages are supported on maximum four page table
+ * levels (PUD, CONT PMD, PMD, CONT PTE) for a given base
+ * page size, corresponding to hugetlb_add_hstate() calls
+ * here.
+ *
+ * HUGE_MAX_HSTATE should at least match maximum supported
+ * HugeTLB page sizes on the platform. Any new addition to
+ * supported HugeTLB page sizes will also require changing
+ * HUGE_MAX_HSTATE as well.
+ */
+ BUILD_BUG_ON(HUGE_MAX_HSTATE < 4);
if (pud_sect_supported())
hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64/mm: Ensure adequate HUGE_MAX_HSTATE
2024-12-02 6:44 [PATCH] arm64/mm: Ensure adequate HUGE_MAX_HSTATE Anshuman Khandual
@ 2024-12-02 11:52 ` Ryan Roberts
2024-12-03 2:47 ` Gavin Shan
2024-12-10 18:34 ` Will Deacon
2 siblings, 0 replies; 4+ messages in thread
From: Ryan Roberts @ 2024-12-02 11:52 UTC (permalink / raw)
To: Anshuman Khandual, linux-arm-kernel
Cc: Catalin Marinas, Will Deacon, Ard Biesheuvel, Mark Rutland, linux-kernel
On 02/12/2024 06:44, Anshuman Khandual wrote:
> This asserts that HUGE_MAX_HSTATE is sufficient enough preventing potential
> hugetlb_max_hstate runtime overflow in hugetlb_add_hstate() thus triggering
> a BUG_ON() there after.
>
> 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>
> ---
> This patch applies on v6.13-rc1
>
> arch/arm64/mm/hugetlbpage.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
> index 3215adf48a1b..98a2a0e64e25 100644
> --- a/arch/arm64/mm/hugetlbpage.c
> +++ b/arch/arm64/mm/hugetlbpage.c
> @@ -519,6 +519,18 @@ pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
>
> static int __init hugetlbpage_init(void)
> {
> + /*
> + * HugeTLB pages are supported on maximum four page table
> + * levels (PUD, CONT PMD, PMD, CONT PTE) for a given base
> + * page size, corresponding to hugetlb_add_hstate() calls
> + * here.
> + *
> + * HUGE_MAX_HSTATE should at least match maximum supported
> + * HugeTLB page sizes on the platform. Any new addition to
> + * supported HugeTLB page sizes will also require changing
> + * HUGE_MAX_HSTATE as well.
> + */
> + BUILD_BUG_ON(HUGE_MAX_HSTATE < 4);
I guess we only technically need 3 if pud_sect_supported() == false ? Although
for simplicity (and to reduce my rebasing effort for boot-time page size :) ),
agree we should always just compare to 4.
Reviewed-by: Ryan Roberts <ryan.roberts@arm.com>
> if (pud_sect_supported())
> hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64/mm: Ensure adequate HUGE_MAX_HSTATE
2024-12-02 6:44 [PATCH] arm64/mm: Ensure adequate HUGE_MAX_HSTATE Anshuman Khandual
2024-12-02 11:52 ` Ryan Roberts
@ 2024-12-03 2:47 ` Gavin Shan
2024-12-10 18:34 ` Will Deacon
2 siblings, 0 replies; 4+ messages in thread
From: Gavin Shan @ 2024-12-03 2:47 UTC (permalink / raw)
To: Anshuman Khandual, linux-arm-kernel
Cc: Catalin Marinas, Will Deacon, Ard Biesheuvel, Ryan Roberts,
Mark Rutland, linux-kernel
On 12/2/24 4:44 PM, Anshuman Khandual wrote:
> This asserts that HUGE_MAX_HSTATE is sufficient enough preventing potential
> hugetlb_max_hstate runtime overflow in hugetlb_add_hstate() thus triggering
> a BUG_ON() there after.
>
> 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>
> ---
> This patch applies on v6.13-rc1
>
> arch/arm64/mm/hugetlbpage.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
Reviewed-by: Gavin Shan <gshan@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64/mm: Ensure adequate HUGE_MAX_HSTATE
2024-12-02 6:44 [PATCH] arm64/mm: Ensure adequate HUGE_MAX_HSTATE Anshuman Khandual
2024-12-02 11:52 ` Ryan Roberts
2024-12-03 2:47 ` Gavin Shan
@ 2024-12-10 18:34 ` Will Deacon
2 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2024-12-10 18:34 UTC (permalink / raw)
To: linux-arm-kernel, Anshuman Khandual
Cc: catalin.marinas, kernel-team, Will Deacon, Ard Biesheuvel,
Ryan Roberts, Mark Rutland, linux-kernel
On Mon, 02 Dec 2024 12:14:07 +0530, Anshuman Khandual wrote:
> This asserts that HUGE_MAX_HSTATE is sufficient enough preventing potential
> hugetlb_max_hstate runtime overflow in hugetlb_add_hstate() thus triggering
> a BUG_ON() there after.
>
>
Applied to arm64 (for-next/misc), thanks!
[1/1] arm64/mm: Ensure adequate HUGE_MAX_HSTATE
https://git.kernel.org/arm64/c/1e5823c8e86d
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-10 18:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-02 6:44 [PATCH] arm64/mm: Ensure adequate HUGE_MAX_HSTATE Anshuman Khandual
2024-12-02 11:52 ` Ryan Roberts
2024-12-03 2:47 ` Gavin Shan
2024-12-10 18:34 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®