All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Jiakai Xu <xujiakai2025@iscas.ac.cn>
Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	David Hildenbrand <david@kernel.org>, Guo Ren <guoren@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Vishal Moola <vishal.moola@gmail.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	Junhui Liu <junhui.liu@pigmoral.tech>,
	Kiryl Shutsemau <kas@kernel.org>,
	Muchun Song <muchun.song@linux.dev>,
	Nam Cao <namcao@linutronix.de>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Paul Walmsley <pjw@kernel.org>,
	Vivian Wang <wangruikang@iscas.ac.cn>
Subject: Re: [PATCH] riscv/mm: use physical alignment for vmemmap_start_pfn
Date: Fri, 17 Jul 2026 19:23:54 -0700	[thread overview]
Message-ID: <20260717192354.045ed96b3f67e78b00a0319d@linux-foundation.org> (raw)
In-Reply-To: <20260716115326.3466926-1-xujiakai2025@iscas.ac.cn>

On Thu, 16 Jul 2026 11:53:25 +0000 Jiakai Xu <xujiakai2025@iscas.ac.cn> wrote:

> RISC-V computes vmemmap_start_pfn by rounding phys_ram_base down to
> VMEMMAP_ADDR_ALIGN. That alignment must therefore be expressed in the
> physical-address domain.
> 
> Commit 476849b0fba4 ("riscv/mm: align vmemmap to maximal folio size")
> attempted to account for the maximal folio alignment by feeding
> MAX_FOLIO_VMEMMAP_ALIGN directly into VMEMMAP_ADDR_ALIGN. However,
> MAX_FOLIO_VMEMMAP_ALIGN is measured in bytes of struct page storage,
> whereas VMEMMAP_ADDR_ALIGN is used to align a physical address.
> 
> The mask-based compound_info encoding requires pfn_to_page(0) to be
> naturally aligned to MAX_FOLIO_VMEMMAP_ALIGN. Commit 9f94db4c7eaa
> ("mm/sparse: check memmap alignment for compound_info_has_mask()")
> added a check for that requirement and exposed the unit mismatch on
> systems such as QEMU virt, where the DRAM base is not aligned to
> MAX_FOLIO_NR_PAGES * PAGE_SIZE.
> 
> Convert MAX_FOLIO_VMEMMAP_ALIGN to the equivalent physical alignment
> before using it in VMEMMAP_ADDR_ALIGN. This keeps the existing
> round_down() logic while making the resulting vmemmap base satisfy the
> mask-alignment requirement.

Thanks.

> Fixes: 476849b0fba4 ("riscv/mm: align vmemmap to maximal folio size")

That's in 7.1, so I'll add a cc:stable to help ensure this gets
backported.

The changelog doesn't tell people *why* we're proposing a backport - to
understand that we should tell them how the bug affects users.  So I'll
paste your following boot-time warning messages into the changelog.

> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -63,7 +63,8 @@ EXPORT_SYMBOL(phys_ram_base);
>  
>  #ifdef CONFIG_SPARSEMEM_VMEMMAP
>  #define VMEMMAP_ADDR_ALIGN	max(1ULL << SECTION_SIZE_BITS, \
> -				    MAX_FOLIO_VMEMMAP_ALIGN)
> +				    PFN_PHYS(MAX_FOLIO_VMEMMAP_ALIGN / \
> +					     sizeof(struct page)))
>  
>  unsigned long vmemmap_start_pfn __ro_after_init;
>  EXPORT_SYMBOL(vmemmap_start_pfn);

I'll queue this as a backportable hotfix and shall await reviewer input
(please).


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: Jiakai Xu <xujiakai2025@iscas.ac.cn>
Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	David Hildenbrand <david@kernel.org>, Guo Ren <guoren@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Vishal Moola <vishal.moola@gmail.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	Junhui Liu <junhui.liu@pigmoral.tech>,
	Kiryl Shutsemau <kas@kernel.org>,
	Muchun Song <muchun.song@linux.dev>,
	Nam Cao <namcao@linutronix.de>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Paul Walmsley <pjw@kernel.org>,
	Vivian Wang <wangruikang@iscas.ac.cn>
Subject: Re: [PATCH] riscv/mm: use physical alignment for vmemmap_start_pfn
Date: Fri, 17 Jul 2026 19:23:54 -0700	[thread overview]
Message-ID: <20260717192354.045ed96b3f67e78b00a0319d@linux-foundation.org> (raw)
In-Reply-To: <20260716115326.3466926-1-xujiakai2025@iscas.ac.cn>

On Thu, 16 Jul 2026 11:53:25 +0000 Jiakai Xu <xujiakai2025@iscas.ac.cn> wrote:

> RISC-V computes vmemmap_start_pfn by rounding phys_ram_base down to
> VMEMMAP_ADDR_ALIGN. That alignment must therefore be expressed in the
> physical-address domain.
> 
> Commit 476849b0fba4 ("riscv/mm: align vmemmap to maximal folio size")
> attempted to account for the maximal folio alignment by feeding
> MAX_FOLIO_VMEMMAP_ALIGN directly into VMEMMAP_ADDR_ALIGN. However,
> MAX_FOLIO_VMEMMAP_ALIGN is measured in bytes of struct page storage,
> whereas VMEMMAP_ADDR_ALIGN is used to align a physical address.
> 
> The mask-based compound_info encoding requires pfn_to_page(0) to be
> naturally aligned to MAX_FOLIO_VMEMMAP_ALIGN. Commit 9f94db4c7eaa
> ("mm/sparse: check memmap alignment for compound_info_has_mask()")
> added a check for that requirement and exposed the unit mismatch on
> systems such as QEMU virt, where the DRAM base is not aligned to
> MAX_FOLIO_NR_PAGES * PAGE_SIZE.
> 
> Convert MAX_FOLIO_VMEMMAP_ALIGN to the equivalent physical alignment
> before using it in VMEMMAP_ADDR_ALIGN. This keeps the existing
> round_down() logic while making the resulting vmemmap base satisfy the
> mask-alignment requirement.

Thanks.

> Fixes: 476849b0fba4 ("riscv/mm: align vmemmap to maximal folio size")

That's in 7.1, so I'll add a cc:stable to help ensure this gets
backported.

The changelog doesn't tell people *why* we're proposing a backport - to
understand that we should tell them how the bug affects users.  So I'll
paste your following boot-time warning messages into the changelog.

> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -63,7 +63,8 @@ EXPORT_SYMBOL(phys_ram_base);
>  
>  #ifdef CONFIG_SPARSEMEM_VMEMMAP
>  #define VMEMMAP_ADDR_ALIGN	max(1ULL << SECTION_SIZE_BITS, \
> -				    MAX_FOLIO_VMEMMAP_ALIGN)
> +				    PFN_PHYS(MAX_FOLIO_VMEMMAP_ALIGN / \
> +					     sizeof(struct page)))
>  
>  unsigned long vmemmap_start_pfn __ro_after_init;
>  EXPORT_SYMBOL(vmemmap_start_pfn);

I'll queue this as a backportable hotfix and shall await reviewer input
(please).


  parent reply	other threads:[~2026-07-18  2:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16 11:53 [PATCH] riscv/mm: use physical alignment for vmemmap_start_pfn Jiakai Xu
2026-07-16 11:53 ` Jiakai Xu
2026-07-16 11:53 ` Jiakai Xu
2026-07-18  2:23 ` Andrew Morton [this message]
2026-07-18  2:23   ` Andrew Morton
2026-07-20  8:52 ` David Hildenbrand (Arm)
2026-07-20  8:52   ` David Hildenbrand (Arm)
2026-07-20  9:20 ` Muchun Song
2026-07-20  9:20   ` Muchun Song
2026-07-22 12:29   ` Kiryl Shutsemau
2026-07-22 12:29     ` Kiryl Shutsemau
2026-07-22 12:32 ` Kiryl Shutsemau
2026-07-22 12:32   ` Kiryl Shutsemau
  -- strict thread matches above, loose matches on Subject: below --
2026-07-16 11:49 Jiakai Xu
2026-07-16 11:49 ` Jiakai Xu
2026-07-16 12:04 ` Jiakai Xu
2026-07-16 12:04   ` Jiakai Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260717192354.045ed96b3f67e78b00a0319d@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=david@kernel.org \
    --cc=guoren@kernel.org \
    --cc=junhui.liu@pigmoral.tech \
    --cc=kas@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=muchun.song@linux.dev \
    --cc=namcao@linutronix.de \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=rppt@kernel.org \
    --cc=vishal.moola@gmail.com \
    --cc=wangruikang@iscas.ac.cn \
    --cc=xujiakai2025@iscas.ac.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.