From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.177 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796392686; b=qsXsKxgChtcQsDU0kkq2OKSD7UWjiFfQRAr5KsvgVXSXVSQfZCfViXkN9vuhdPJRGUIr YyGCv8QGu9mcuAAlTiyiYXEnnsPtTTnh1LIPCeVVQzDKEsj6+PjSJbl0lX++GCCdju9mG bW5ke82SuRxyhoDktkAs7WYW8NXxZj3XUi1S5wpdLonw96nR8LMCG1n5d1w44gvxBt8N2 MWVJNA7paBdnOylO0gm7afZjXy9ufE7NC6RGwNHUKPVj6je85sPs8b6psDPwcsVHMYZso BNeOE4s7CakSmnRHrbZIHCZ/dfuMmFd7nBw4MvgYGVNnaQLJjD9lZ954WIk8rUg4M/Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796392686; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=yWfht2BDKOtYgQ14lX0WqOPfrFp/0KK7jO7wZxavZPg=; b=C1uS2dRmw+EFeu42lH/AAKzePRIwHONXWkYoitJPzd2SzEivTGxlmdRzYzVO+IQPVVwf R9eeEhhc1htRM25bggadaqNqvgcjWvl2a7ydBZ7DV5F9LE/TjuH/iXWKGVQhgU/PPm07j hMdF7DltQyYFpYD8f7m7KvDUIULfwHXNCYIBiqnhquHTOceQ4SUMg2m/QNWgYwX4yvs8L HgLj/8/DRQrKFnn7WidxRi53IkraSj34WVLyYaXVztkbpndTzoiKsS3i1pjPxMrKbu+cT GGG3pb2mZsRFT5bTm7vM6WRsYpxQntCReT+WdJz+3wKHXP6zkE548HR+iTMOXOqR6lQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="jaaVH/s7"; arc=none smtp.remote-ip=209.85.210.177 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 BFA04606A687 for ; Fri, 4 Dec 2026 13:58:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BFA04606A687 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=jaaVH/s7 Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-8c5ebbc5150so609110b3a.3 for ; Fri, 04 Dec 2026 05:58:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796392685; x=1796997485; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=yWfht2BDKOtYgQ14lX0WqOPfrFp/0KK7jO7wZxavZPg=; b=jaaVH/s7RaKXodCto27Io1/GmZzjxNDDZWZn60wCqZFz9QefKPo+ERcwQMpticPmbN AMn4BbP1CScK8F/2MP5TQTBv8Zn7aJ67k8bEEDwHCJddxqorotUO59YNHtpF3O4L73Wn 1ih7OvShxxq+hCChfpvAIWu753c1PAXVD5+gs5ibf0JVojvNWF8M+tA6iD5P7f09nZcN IZMHF2jp1h8rIKFRnRFjaPDsyes2oFncLG4K8tJ9EJRI6RFNdqL18h9XKrbgs7cmtklw 0wCq4IS8MF02LZM9B8mPrjXN9RRjfbDWvlom4JNT6EKut+Ga+wpooliYuTiukqs8/P7W br8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796392685; x=1796997485; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=yWfht2BDKOtYgQ14lX0WqOPfrFp/0KK7jO7wZxavZPg=; b=Esn8WfcD+RqWCqbL97j+CsXaVRkqmEUMe9FdzoIj1pcAYRCUAwGgrDMRM40JjRkw91 8JrfeygNph/Rd2IYwd6eGURvBZORwqx+yOHMHPaRbTEUFjjwPklS4j8HGvAUpNuAXaj1 xso/bxaPfYM95SpwhWvnzZA6ZNNXo7Mj0HLSiuSLG3PBgJWmCUtngFhcuWfFOsGzgPXY tVS6bDNdHJqmP1OEFylmSpYEjDVwtjOL52eRiVqZfmt2755FezeB1Dp49/oiJvIFOqvd Pd8cwiJ+ibdr/MlGsTIr86pnfB2UWFIgo+dRNRz3/5k8vTdAtDJzbiHasq/Ds4i6BKO0 1a3w== X-Gm-Message-State: AB4q+uElAvHnLHxYgzELRjXp813ThXvf5Za+rAB16uIvFOKr8g1sCGWd m7uY/imVVtQcBgm9iDLAnov3iYkmQwAY+eyf4lfO2F1xUUqbZgkwuhokPYA8y3zf X-Gm-Gg: AZFdTZfS21WbRu+LtxUjO29oEKqckrbnSnbhTTMUvpCs8BrLstViPgD+dRYrNl5lfIT ZBaqIqXpYZy6gv7bY/F+ss5on2++/nMydHkVdIY7mys+5PnQjjuRQ/t4faDEIpvFZnmi7fYxagz zXT1flLFjJ6ViZ3XGgxzj1vq5IZhpuCyl3InJYGL7+LCjxGd47P97EXq++UkZ6rXKKsbnOizlRC 2PPzmzHIUdm+1wWU+/XPlCpgE6SGgaHrXeAY1qDDs+eTGS0H+qQNeb8viuMaaxyxDZ8b9QtJDJy apmCzZqCkA/D/dr0gfQTdkHct9quC30IqCxUxeB3ylDYwj25rhWMaYKf0TXVx5Gf9Ax7aeGRVw5 bHO48/C3kx+TXTu5vX6csMYuOv3anR0Eh6tUhH9oTB3aOgphxF2IHpq3wt50i4NBwZB4hssyrIp uL1ZORhaPtEo4CH77Mz2z9F4Y7n18zJAhpaxm8v7ZDabzMzM3hmichbsfwKGdXnH3o3xJf7vlt1 7Lh8j906pwAhK8A5qFsdvRLk9tKF08hRY0+0d5ncS1zN1609oXq1+WvQQlnnd4+mSmoPPI9FYJC 5bzoD1yjMJu+13o10xtXJJ5QKcFaNoIAAro9R+PrJ3dC X-Received: by 2002:a17:90b:6c8:b0:3b0:a757:4f85 with SMTP id 98e67ed59e1d1-3b5e053b59emr1676735a91.2.1796392685017; Fri, 04 Dec 2026 05:58:05 -0800 (PST) Received: from localhost.localdomain ([121.134.184.225]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8de1388210asm1532296b3a.53.2026.12.04.05.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 05:58:04 -0800 (PST) From: Unsung Lee To: linux-cxl@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Dan Williams , Ira Weiny , Li Ming , Richard Cheng , Ben Cheatham , Unsung Lee Subject: [PATCH v2 1/2] cxl/region: Fail region creation for a root decoder without a CXL window Date: Fri, 4 Dec 2026 22:57:53 +0900 Message-Id: <20261204135754.639574-2-unsung0317@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261204135754.639574-1-unsung0317@gmail.com> References: <20261204135754.639574-1-unsung0317@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit A resource overlap can leave a root decoder registered without a usable CXL window. Setting a region's size under that decoder then dereferences NULL with resource_lock held, which can stall other resource tree users. Both the sysfs and the auto-assembly paths create regions through __create_region(). Reject region creation there with -ENXIO, before either path can use the missing resource, and log the unpaired root decoder with its HPA range in pair_cxl_resource(). The oops was reproduced with cxl_test in a QEMU guest whose 64-bit PCI MMIO window overlaps the cxl_test mock windows. The same state can arise when a firmware System RAM range starts inside one CXL window and extends into the next; that case and the auto-assembly path are from code inspection. Fixes: 23a22cd1c98b ("cxl/region: Allocate HPA capacity to regions") Signed-off-by: Unsung Lee --- Notes: Test details cxl/next 5ee57f66c2, QEMU 11.2.0-rc2 (q35, KVM, SeaBIOS 1.17.0, 4 vCPU, 4G), Ubuntu 24.04 guest, one pxb-cxl host bridge with a cxl-type3 volatile device and an 8G fixed memory window, plus "modprobe cxl_test interleave_arithmetic=1". The 64-bit PCI window and the cxl_test mock windows overlap, so Window 0 is expanded over PCI Bus 0000:00 and contains Windows 1-4: 7000000000-700000ffff : PCI Bus 0000:0c 7000010000-787fffffff : CXL Window 0 7000010000-703fffffff : PCI Bus 0000:00 7040000000-704fffffff : PCI Bus 0000:0c 7050000000-787fffffff : PCI Bus 0000:00 Before: decoder2.1-2.4 are left without a window. Writing the size of a pmem region under decoder2.1 oopses and the guest stops responding: BUG: kernel NULL pointer dereference, address: 0000000000000000 RIP: 0010:get_free_mem_region+0xfa/0x360 alloc_free_mem_region+0x1e/0x30 size_store+0x1d5/0x300 [cxl_core] After: create_pmem_region (decoder2.1-2.3) and create_ram_region (decoder2.4) fail with ENXIO, no splat, and with cxl_acpi.dyndbg=+p: cxl decoder2.1: no CXL window covers HPA range 0x7090000000-0x710fffffff cxl decoder2.2: no CXL window covers HPA range 0x7110000000-0x71cfffffff cxl decoder2.3: no CXL window covers HPA range 0x71d0000000-0x724fffffff cxl decoder2.4: no CXL window covers HPA range 0x7250000000-0x728fffffff decoder2.0 still has its window and behaves as before. ndctl v85 cxl suite in the same VM, with cxl-poison.sh run last: without the patch: cxl-poison.sh oopses the same way with the patch: cxl-poison.sh fails at line 262, no oops The other 16 tests give the same results with and without the patch: 12 pass, cxl-security.sh is skipped, and cxl-xor-region.sh (line 30), cxl-destroy-region.sh (exit 5) and cxl-region-replay.sh (line 47) fail. No BUG/WARNING with the patch. drivers/cxl/acpi.c | 7 +++++++ drivers/cxl/core/region.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 666452c04c..13609e2e98 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -898,6 +898,13 @@ static int pair_cxl_resource(struct device *dev, void *data) } } + if (!p) { + struct cxl_decoder *cxld = &to_cxl_root_decoder(dev)->cxlsd.cxld; + + dev_dbg(dev, "no CXL window covers HPA range %#llx-%#llx\n", + cxld->hpa_range.start, cxld->hpa_range.end); + } + return 0; } diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 7573cd115e..4a1386ffa4 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3106,7 +3106,7 @@ static struct cxl_region *__create_region(struct cxl_root_decoder *cxlrd, { int rc; - if (cxlrd->dead) + if (cxlrd->dead || !cxlrd->res) return ERR_PTR(-ENXIO); switch (mode) { -- 2.34.1