[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7c49fa2c-b732-4b82-a853-22fdf241d361@arm.com>
Date: Mon, 2 Dec 2024 11:52:59 +0000
From: Ryan Roberts <ryan.roberts@....com>
To: Anshuman Khandual <anshuman.khandual@....com>,
linux-arm-kernel@...ts.infradead.org
Cc: Catalin Marinas <catalin.marinas@....com>, Will Deacon <will@...nel.org>,
Ard Biesheuvel <ardb@...nel.org>, Mark Rutland <mark.rutland@....com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] arm64/mm: Ensure adequate HUGE_MAX_HSTATE
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@....com>
> Cc: Will Deacon <will@...nel.org>
> Cc: Ard Biesheuvel <ardb@...nel.org>
> Cc: Ryan Roberts <ryan.roberts@....com>
> Cc: Mark Rutland <mark.rutland@....com>
> Cc: linux-arm-kernel@...ts.infradead.org
> Cc: linux-kernel@...r.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@....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@....com>
> if (pud_sect_supported())
> hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
>
Powered by blists - more mailing lists