Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796170819; b=oU8sTT4S/srO9gy9O13JupF3msQYpFWKWt5L+wGX4f/vxAYNRZxSGBGrzwvbFNirwGLx pvVUOifp4KrXnwQjefbKLOm1DC/zDfvccnXzEEM9nvaHJ4cLLGMAPuA49wslQ2RV/JyDy j8gtxyAduTfhsY0RhiKvdxeI73tOMb08iud6KgJLOzz1JdRRuhik8ocN7oQrEIXpbeMPF DLMPaGWH/wwqXpKCLSJQ4UumhcERDXPI/sAQ477KaBa7DYUdMmv1mxdQNhZryY9YeE2kP GuhNdoBAVxUdGpxbCkyGkgMgBaZM0J1ygP8VYtPW/y2ATH5t7iuTn8lET7w/2Ai39ww== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796170819; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=PiPGvDT3quazREgux8awHme0bPbDZFuaTIzx8BLEyzA=; b=3+1U3S56G2R1RVaTZZyoc9/2IXGO+c3dut4TO3Wo+TXIjqDF0G0H6/bEl4sgZlPnGjdW u3HJ+8Ou3m2TfyK8tqCs2ORGgT9RR1UcqbEk6KSOvfMJc4+PpngYAhFKh9lrHcGHveGc9 HTxFThdKt9895qmVt4SbQKUR0h6FsKstShxSesszYXZJ0ZHobY5GycjH1xWZTIgwCwdwf hG4JN/fj2bM22iArkkbrd2p2pWWF4QDlviHcwr4ZCB6zN9JkWtkVRUuc/RCCEMnuJfaL/ wMyvNVWF+6WrTD+NgGStWP/6wRwZ6kse+FZXacDsIkFGdW6qvHTgbZv2CoD/Hs4QjOQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--suseendranb.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Y79C8NCt; arc=none smtp.remote-ip=74.125.82.69 Received: from mail-dl1-f69.google.com (mail-dl1-f69.google.com [74.125.82.69]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBF0D606A691 for ; Wed, 2 Dec 2026 00:20:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CBF0D606A691 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--suseendranb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Y79C8NCt Received: by mail-dl1-f69.google.com with SMTP id a92af1059eb24-1b59be340dbso3786743c88.1 for ; Tue, 01 Dec 2026 16:20:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796170818; x=1796775618; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=PiPGvDT3quazREgux8awHme0bPbDZFuaTIzx8BLEyzA=; b=Y79C8NCtF+INIxTVpX1N6+NyFK139rt90n7rGOGIWRVimWQQablTPB3xl2Tp6HdZC1 +v+AmNn5jdIr1szpZsJgFKVjVJqh85IyH0A4cu49d2eX4QfMUfs+9yzzjjIGBjEJpjnV faeqIYWaArKyv59b5cbuKnrgGwecPXUnYjek9T2Yf8nFSrDhc5DxviYyvOcYS2mawDuU qZpPkfn5GwX9yO1ietuLDbHhw0xNrp+8b5bNdFB943YNvkdigXsGWhwo9G1epUXnBi2G bih3z3FdS6t/q6Kg9ndELdjbtauLfgF95dtPRiggyDhrmiMWsQrFRrXMMVBIrA8QnRX7 JEdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796170818; x=1796775618; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=PiPGvDT3quazREgux8awHme0bPbDZFuaTIzx8BLEyzA=; b=pf4kocdMDOX7GmT/Bfjqd8s0jygja4AczGQ2qB1GHCuFJh6FIkj3zoq5TKmv7pGtPx 3LzhaECTcQCRiiq1MjpMw6R48q34Dk2kM0lThmgz6+DcdKNH5wPIvrufE/QJPxlFv6ye V/p+RR/lQw23pqm/yISzr1Opa6d2v5yyXSCLqXxCsn97UHTwnD80Pa1xN2SyPw5hPCbg jlaNZxrf5/b6fI5rZRXYy5mejsKwBpf731kk8EjulPw2g8d8uEDlKjcD7ntx1fdCkG6N wdaTsmCYYERjl8ZJEVLucaisXnhpMEvGeSDhlMzPoUIJAKk9DcY7GGCEu/AB7r6yn5c8 4roQ== X-Forwarded-Encrypted: i=1; AL+hErHZpnQ+CUVNsooSbF9h74Y+Dij7WVvNm5IXEA30daQMWjX/Hkdla3MRFYiIOXw++EkLaAPTrUQuYNU=@vger.kernel.org X-Gm-Message-State: APuU4Z8LW0QVg0O3wb9BAKWvinT6EWV8n4+kgVGF8fLXew4l3+DnxvQU MmsxTDPOF8kzBv9n8/Syf3cwnY6m0Pv01BvHZZrWX6EmznmieD1VUxFYAogtisQO5z/HOKOfMR3 fwrSDPDfcSAUPCv2TSZNrH/xCRw== X-Received: from dly27-n1.prod.google.com ([2002:a05:701b:205b:10b0:1ac:f9af:14c]) (user=suseendranb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:20ce:20b0:1b5:709f:d57a with SMTP id a92af1059eb24-1b5709fd6e6mr29225854c88.31.1796170817520; Tue, 01 Dec 2026 16:20:17 -0800 (PST) Date: Wed, 2 Dec 2026 00:19:41 +0000 In-Reply-To: <20261202001946.1226273-1-suseendranb@google.com> X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261202001946.1226273-1-suseendranb@google.com> X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261202001946.1226273-7-suseendranb@google.com> Subject: [RFC PATCH 06/11] dax/hmem: bind extmem platform devices with per-region alignment From: Suseendran Bhaskaran To: Andrew Morton , Mike Rapoport , Dan Williams , David Hildenbrand Cc: Alexander Graf , Alison Schofield , Andy Lutomirski , Borislav Petkov , Catalin Marinas , Changyuan Lyu , Dave Hansen , Dave Jiang , David Rientjes , Frank van der Linden , "H. Peter Anvin" , Ingo Molnar , Ira Weiny , Jonathan Corbet , "Liam R. Howlett" , Mark Rutland , Michal Hocko , Oscar Salvador , Pasha Tatashin , Peter Zijlstra , Pratyush Yadav , Randy Dunlap , Shuah Khan , Thomas Gleixner , Vishal Verma , Vlastimil Babka , Will Deacon , kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, nvdimm@lists.linux.dev, x86@kernel.org, Suseendran Bhaskaran Content-Type: text/plain; charset="UTF-8" dax_hmem_probe() only matches "hmem" platform devices, hardcodes PMD_SIZE alignment, and defaults to IORESOURCE_DAX_KMEM (unless region_idle is set), without checking device identity or a non-NULL platform_data pointer. Boot memory carveouts published as "extmem" platform devices need a default driver match without hardcoding "hmem" inside mm/, need PUD_SIZE alignment (1 GiB on x86_64) when carved on PUD boundaries, and must default to device_dax (flags = 0) instead of routing to dax_kmem (where onlining into System RAM would overwrite memory preserved across Kexec HandOver). Allow CONFIG_DEV_DAX_HMEM with CONFIG_EXTMEM (using set_dev_node() for !CONFIG_NUMA builds), match both "hmem" and "extmem" via platform_device_id, honor mri->align in dax_hmem_probe() while keeping PMD_SIZE and default IORESOURCE_DAX_KMEM (when !region_idle) for EFI Soft Reserved devices, and reject driver_override binds from unrelated platform devices. Signed-off-by: Suseendran Bhaskaran --- .../admin-guide/kernel-parameters.txt | 6 ++++- drivers/dax/Kconfig | 2 +- drivers/dax/hmem/hmem.c | 27 +++++++++++++------ 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index c20667240080..e75b35d9a66b 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1700,7 +1700,11 @@ Kernel parameters struct page allocation, unmap them from the kernel direct/linear map, and expose them as "extmem" platform devices (up to 8 contiguous ranges per node and 64 - regions total). + regions total). When CONFIG_DEV_DAX_HMEM is enabled, + dax_hmem matches "extmem" devices by default, exposing + device_dax instances at PUD or PMD alignment (configurable + via daxctl, or left idle at boot with + dax_hmem.region_idle=1). defaults to and must be at least the sparsemem section size (128 MiB on 4K/16K pages, 512 MiB on 64K pages), and must be a multiple of . diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig index 602f9a0839a9..834208398f4f 100644 --- a/drivers/dax/Kconfig +++ b/drivers/dax/Kconfig @@ -29,7 +29,7 @@ config DEV_DAX_PMEM config DEV_DAX_HMEM tristate "HMEM DAX: direct access to 'specific purpose' memory" - depends on EFI_SOFT_RESERVE + depends on EFI_SOFT_RESERVE || EXTMEM select NUMA_KEEP_MEMINFO if NUMA_MEMBLKS default DEV_DAX depends on CXL_ACPI || !CXL_ACPI diff --git a/drivers/dax/hmem/hmem.c b/drivers/dax/hmem/hmem.c index af21f66bf872..e82ffbadfe20 100644 --- a/drivers/dax/hmem/hmem.c +++ b/drivers/dax/hmem/hmem.c @@ -1,7 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include +#include #include #include "../../cxl/cxl.h" #include "../bus.h" @@ -11,24 +13,25 @@ module_param_named(region_idle, region_idle, bool, 0644); static int dax_hmem_probe(struct platform_device *pdev) { - unsigned long flags = IORESOURCE_DAX_KMEM; struct device *dev = &pdev->dev; + struct memregion_info *mri = dev->platform_data; + bool is_hmem = strcmp(pdev->name, "hmem") == 0; struct dax_region *dax_region; - struct memregion_info *mri; struct dev_dax_data data; + if ((!is_hmem && strcmp(pdev->name, "extmem") != 0) || !mri) + return -EINVAL; + /* * @region_idle == true indicates that an administrative agent * wants to manipulate the range partitioning before the devices * are created, so do not send them to the dax_kmem driver by * default. */ - if (region_idle) - flags = 0; - - mri = dev->platform_data; dax_region = alloc_dax_region(dev, pdev->id, &mri->range, - mri->target_node, PMD_SIZE, flags); + mri->target_node, mri->align ?: PMD_SIZE, + is_hmem && !region_idle ? + IORESOURCE_DAX_KMEM : 0); if (!dax_region) return -ENOMEM; @@ -42,8 +45,16 @@ static int dax_hmem_probe(struct platform_device *pdev) return PTR_ERR_OR_ZERO(devm_create_dev_dax(&data)); } +static const struct platform_device_id dax_hmem_ids[] = { + { "hmem" }, + { "extmem" }, + { } +}; +MODULE_DEVICE_TABLE(platform, dax_hmem_ids); + static struct platform_driver dax_hmem_driver = { .probe = dax_hmem_probe, + .id_table = dax_hmem_ids, .driver = { .name = "hmem", }, @@ -97,7 +108,7 @@ static int __hmem_register_device(struct device *host, int target_nid, } pdev->dev.parent = host; - pdev->dev.numa_node = numa_map_to_online_node(target_nid); + set_dev_node(&pdev->dev, numa_map_to_online_node(target_nid)); info = (struct memregion_info) { .target_node = target_nid, .range = {