All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvdimm: add missing prompt for NVDIMM_KMSAN
@ 2026-12-04  2:09 Pengpeng Hou
  2026-12-04  2:28 ` sashiko-bot
  2026-12-04  2:52 ` Alison Schofield
  0 siblings, 2 replies; 3+ messages in thread
From: Pengpeng Hou @ 2026-12-04  2:09 UTC (permalink / raw)
  To: Dan Williams, Vishal Verma, Dave Jiang, Alison Schofield
  Cc: Ira Weiny, nvdimm, Pengpeng Hou

NVDIMM_KMSAN has help text asking users to choose whether to allow a
larger struct page reservation, but its boolean has no prompt, default
enabling value or selecting user.

Add a prompt under the existing KMSAN dependency. Keep the default off
and retain the warning about persistent namespace capacity.

The issue was found by our static-analysis tool and manually reviewed.

Fixes: c91d71363084 ("nvdimm: Support sizeof(struct page) > MAX_STRUCT_PAGE_SIZE")
Signed-off-by: Pengpeng Hou <hppiscas@163.com>
---
The original patch was prepared with Gemini. Codex assisted with this
review and revision (Assisted-by: gpt 5).
With real Clang 18 and KMSAN and LIBNVDIMM enabled, Kconfig ignored an
explicit NVDIMM_KMSAN=y before this change and accepted it afterwards.
Without that request the default remained off. This was a configuration
test; no target binary was built.

 drivers/nvdimm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvdimm/Kconfig b/drivers/nvdimm/Kconfig
index 44ab929a1ad54dcc94b2ee1f0aa45643311440d2..7db8fb321279c81565816226737c6dd93788df20 100644
--- a/drivers/nvdimm/Kconfig
+++ b/drivers/nvdimm/Kconfig
@@ -122,7 +122,7 @@ config NVDIMM_KEYS
 	depends on (LIBNVDIMM=ENCRYPTED_KEYS) || LIBNVDIMM=m
 
 config NVDIMM_KMSAN
-	bool
+	bool "Support KMSAN debug builds with oversized struct page"
 	depends on KMSAN
 	help
 	  KMSAN, and other memory debug facilities, increase the size of

base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvdimm: add missing prompt for NVDIMM_KMSAN
  2026-12-04  2:09 [PATCH] nvdimm: add missing prompt for NVDIMM_KMSAN Pengpeng Hou
@ 2026-12-04  2:28 ` sashiko-bot
  2026-12-04  2:52 ` Alison Schofield
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-04  2:28 UTC (permalink / raw)
  To: Pengpeng Hou; +Cc: nvdimm

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] nvdimm: undersized altmap reservation in nd_pfn_init() with
  NVDIMM_KMSAN
- [Low] nvdimm: NVDIMM_KMSAN prompt lacks depends on NVDIMM_PFN
--

commit 56c04a3394507617001fb5a7be4447d1a5e74f98
Author: Pengpeng Hou <hppiscas@163.com>

nvdimm: add missing prompt for NVDIMM_KMSAN

This commit adds a Kconfig prompt string to NVDIMM_KMSAN so the option can
be selected when KMSAN is enabled.

> diff --git a/drivers/nvdimm/Kconfig b/drivers/nvdimm/Kconfig
> index 44ab929a1ad54..7db8fb321279c 100644
> --- a/drivers/nvdimm/Kconfig
> +++ b/drivers/nvdimm/Kconfig
> @@ -122,7 +122,7 @@ config NVDIMM_KEYS
>  	depends on (LIBNVDIMM=ENCRYPTED_KEYS) || LIBNVDIMM=m
>  
>  config NVDIMM_KMSAN
> -	bool
> +	bool "Support KMSAN debug builds with oversized struct page"

[Severity: Medium]
Does making NVDIMM_KMSAN selectable expose an undersized altmap reservation
in nd_pfn_init() that fails namespace creation with -ENOMEM?

With KMSAN enabled on x86_64, sizeof(struct page) is 80 bytes, so a 128 MiB
section needs 2.5 MiB of vmemmap across two 2 MiB PMDs.  For a 128 MiB
namespace with 2 MiB alignment, nd_pfn_init() rounds offset to 4 MiB and
__nvdimm_setup_pfn() sets altmap->free to 1022 pages after the SZ_8K reserve.

When devm_memremap_pages() calls vmemmap_populate_hugepages(), the first
2 MiB PMD in altmap_alloc_block_buf() consumes 510 pages for PMD alignment
plus 512 pages for the PMD itself.  That exhausts altmap->free before the
second PMD is allocated, returning -ENOMEM.

Because nd_pfn_init() persists pfn_sb via nvdimm_write_bytes() before
devm_memremap_pages() runs, the undersized dataoff remains on pmem and
subsequent probes keep failing until the superblock is cleared.

>  	depends on KMSAN

[Severity: Low]
Should NVDIMM_KMSAN also depend on NVDIMM_PFN, like NVDIMM_DAX does?  The
only consumer is page_struct_override in drivers/nvdimm/pfn_devs.c, which
drivers/nvdimm/Makefile only builds when CONFIG_NVDIMM_PFN is enabled.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/179635015160.74470.1493242467117928008@163.com?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvdimm: add missing prompt for NVDIMM_KMSAN
  2026-12-04  2:09 [PATCH] nvdimm: add missing prompt for NVDIMM_KMSAN Pengpeng Hou
  2026-12-04  2:28 ` sashiko-bot
@ 2026-12-04  2:52 ` Alison Schofield
  1 sibling, 0 replies; 3+ messages in thread
From: Alison Schofield @ 2026-12-04  2:52 UTC (permalink / raw)
  To: Pengpeng Hou; +Cc: Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny, nvdimm

On Fri, Dec 04, 2026 at 10:09:11AM +0800, Pengpeng Hou wrote:
> NVDIMM_KMSAN has help text asking users to choose whether to allow a
> larger struct page reservation, but its boolean has no prompt, default
> enabling value or selecting user.
> 
> Add a prompt under the existing KMSAN dependency. Keep the default off
> and retain the warning about persistent namespace capacity.
> 
> The issue was found by our static-analysis tool and manually reviewed.

Hi Pengpeng,

What’s the use case for exposing NVDIMM_KMSAN as a user-visible option?
What did the static checker flag? A bool without a prompt is valid Kconfig.

-- Alison


> 
> Fixes: c91d71363084 ("nvdimm: Support sizeof(struct page) > MAX_STRUCT_PAGE_SIZE")
> Signed-off-by: Pengpeng Hou <hppiscas@163.com>
> ---
> The original patch was prepared with Gemini. Codex assisted with this
> review and revision (Assisted-by: gpt 5).
> With real Clang 18 and KMSAN and LIBNVDIMM enabled, Kconfig ignored an
> explicit NVDIMM_KMSAN=y before this change and accepted it afterwards.
> Without that request the default remained off. This was a configuration
> test; no target binary was built.
> 
>  drivers/nvdimm/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/nvdimm/Kconfig b/drivers/nvdimm/Kconfig
> index 44ab929a1ad54dcc94b2ee1f0aa45643311440d2..7db8fb321279c81565816226737c6dd93788df20 100644
> --- a/drivers/nvdimm/Kconfig
> +++ b/drivers/nvdimm/Kconfig
> @@ -122,7 +122,7 @@ config NVDIMM_KEYS
>  	depends on (LIBNVDIMM=ENCRYPTED_KEYS) || LIBNVDIMM=m
>  
>  config NVDIMM_KMSAN
> -	bool
> +	bool "Support KMSAN debug builds with oversized struct page"
>  	depends on KMSAN
>  	help
>  	  KMSAN, and other memory debug facilities, increase the size of
> 
> base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-04  2:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  2:09 [PATCH] nvdimm: add missing prompt for NVDIMM_KMSAN Pengpeng Hou
2026-12-04  2:28 ` sashiko-bot
2026-12-04  2:52 ` Alison Schofield

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.