From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=192.198.163.19 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796325685; b=kG+XdVY1iWR9HDiEciczLwV3BJ3QZ82qPAe4+s6OyAaf3ys0MlwDdHTalERhPtrHYT42 N1PZU6fGq7J6Dyz0SEZibTCrSNsvlFw5OjO7F6PEELYZ2Gn+zswDg1nvSYlfOw3rrZUdW tLd7nXjRYwczXwW+G/refcm1IOOVne+31Xq69Qofm1x6dBwoG4W9+6pjj4Yuri9y+Vjxb c8CNu/6c2K+lZzjD+X/OjxpxYRt+rBbTtMny+jkzTUNTxBmC4n2aTSfEnZfKUXpA7XB1i nJFfyY05txTwdYWikAfdsXLnWmAJtIXMyjiP3XS1M3qGjrmLwp8ZlrdeKuHX5fXmENQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796325685; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Received:Received: Received:Received:Received:Date:From:To:CC:Subject:Message-ID: References:Content-Type:Content-Disposition:In-Reply-To: X-ClientProxiedBy:MIME-Version:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-Exchange-RoutingPolicyChecked: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-OriginatorOrg; bh=BFbMYex4n54Z955Hg/RfmkcZtSphAoYOTxHaSb2NKSg=; b=hym84gNOf6iF/+LTkyZOHfDgwE1HvgOCswqEncxhqNkeJy0L6dfgYcn+q8cakx9Eq9fu gWqyVY2xHu6vpIqv+vnh8iE4yNsWugivpiNal3s03Hp+BX3RbGS2msFNFwZRE/ekwp3fD iORuqsVrX9R7UyUWPwZXS0Yn6KCJh4LBQAzLlaA2MPASIP/WWCFFwDq7oFga6iFxDGizr KGp6Igzs2WQy0nf+c6mPzvF6tC4GzZ1ywNDeV8vokoH1gDxzzCtOM6yFQP88+6XrXwOyq u53qZtgMndEBl1cRdPHHkOwLtwilOlixzy7U4Ida3KqcdcK4GgXC9y/DZiDmkplFTow== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=F+cft2kr; arc=pass header.oldest-pass=0 smtp.remote-ip=192.198.163.19 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E39BC606A68B; Thu, 3 Dec 2026 19:21:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E39BC606A68B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=F+cft2kr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796325685; x=1827861685; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=BFbMYex4n54Z955Hg/RfmkcZtSphAoYOTxHaSb2NKSg=; b=F+cft2krJoHjbI48ihpghNuADClVH/Pil46pcYh1G612huV06553Irkh WMnOE75l71/k1TXZpE7z80fk92YgeSHi5+zMt+p7w/7hExJPk/asYjoxb pEnut+IQiCsYsdYZhFfUodG0C8gwhtSkw22+HA+KePfXoib6/XzzvSabS +ZnOn08vsfTpmxabJIRIUcFt9tC2uw8i9PUf4Rpj2yBcROyGtw1za+b0E XjIQUKCvM7MvWkn8/0QOh0RB36zpUJsLJ19yrvSvDjVF0awFeKtaJ+U9B 0fxEJZkiWokS/B/vCkbKOjdiV+d3oxaN+M5QwX+4zqdPabx835YLtfa4L g==; X-CSE-ConnectionGUID: e7j/VwnuTiKtPwEtEfV67Q== X-CSE-MsgGUID: 52/XpZ08QwCzO8yJ+eXXWQ== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5317360" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="5317360" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 11:21:24 -0800 X-CSE-ConnectionGUID: geRlQ4RITP6e9fzj6Z1hww== X-CSE-MsgGUID: M2N4GfSaQ8G6hNgPch4IeA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="13677791" Received: from fmsmsx901.amr.corp.intel.com ([10.18.126.90]) by orviesa008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 11:21:22 -0800 Received: from FMSMSX903.amr.corp.intel.com (10.18.126.92) by fmsmsx901.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Thu, 3 Dec 2026 11:21:22 -0800 Received: from fmsedg901.ED.cps.intel.com (10.1.192.143) by FMSMSX903.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57 via Frontend Transport; Thu, 3 Dec 2026 11:21:22 -0800 Received: from BL2PR02CU003.outbound.protection.outlook.com (52.101.52.59) by edgegateway.intel.com (192.55.55.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Thu, 3 Dec 2026 11:21:21 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HQs1es/nhdfQn5LKMsuH5gUeJbiUaQLyfsJjrmW4PRkpi1Ig3JY/IuX6b1gNicsR2ljAJv+mp0MCfhE7PXf6PTZV/Pj5Z/15GtLg19ls3bRF7DPckOVLaRXgWj8F9pIVEN/3fWL4hBHiaNX07sOygSNFkjOTNMbXnVjzsSESz3U47G4QlX2hgp60tb7+t9SprR6mCRiVLIrKcZ0lcuGW64eeGEbByAqvtT6gpETG+eg51reLFep4ghacq4FXC5XtRWJqKuSno8ofy8J+V3HUfw3EXQAQ23LUAQ5/sJ0yd7OZK4KciHOitta3r5XgkL7NO8OSOC3Jpjy6WxqBN9E/hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BFbMYex4n54Z955Hg/RfmkcZtSphAoYOTxHaSb2NKSg=; b=jzPYQvUqe3pxqtzs0R0VsiqR/dJQiTbxrGnRFFS/UjXeIJGGWCFs5cLBM/OlFhtRMVd+lkNGlwMprMR3f/wZ2q0pmQT89oUNPD5Kogak+zYg6v2zxCy3yNGqKPQXWnEEE7Z+B03M34I9IEnRcO/Lv2zheAMe1kLUHhxhN2UL7+js4IrC7Bu8153YahvQ/3DFngq+GwX/Jus9uHz5Y895c1bcjYCId047oVu3NudyBv+ycg97t2m2fN1x2jPZcck/rH1ttvQpjSE369QIHd1UjP0PCI/IpCUr0LFfOvWBUzmMi47zn3D4wOCfNyKTVLBcLyHS8bB1p1eqUlcQV/IJbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS4PPF0BAC23327.namprd11.prod.outlook.com (2603:10b6:f:fc02::9) by LVXPR11MB9756.namprd11.prod.outlook.com (2603:10b6:408:389::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.12; Thu, 3 Dec 2026 19:21:18 +0000 Received: from DS4PPF0BAC23327.namprd11.prod.outlook.com ([fe80::a1fc:97e0:329a:4aa7]) by DS4PPF0BAC23327.namprd11.prod.outlook.com ([fe80::a1fc:97e0:329a:4aa7%6]) with mapi id 15.21.0688.011; Thu, 3 Dec 2026 19:21:18 +0000 Date: Thu, 3 Dec 2026 11:21:08 -0800 From: Alison Schofield To: Unsung Lee CC: , , "Davidlohr Bueso" , Jonathan Cameron , Dave Jiang , Vishal Verma , Dan Williams , Ira Weiny , Li Ming Subject: Re: [PATCH] cxl/region: Fail region creation for a root decoder without a CXL window Message-ID: References: <20261121105714.1542859-1-unsung0317@gmail.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261121105714.1542859-1-unsung0317@gmail.com> X-ClientProxiedBy: PH7PR17CA0064.namprd17.prod.outlook.com (2603:10b6:510:325::21) To DS4PPF0BAC23327.namprd11.prod.outlook.com (2603:10b6:f:fc02::9) 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 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS4PPF0BAC23327:EE_|LVXPR11MB9756:EE_ X-MS-Office365-Filtering-Correlation-Id: c8d79724-95e0-43a0-8a44-08df51729b54 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|23010399003|1800799024|11063799006|6133799003|261009223027099003|22082099003|18002099003|56012099006|10067099003|261021121427099003|261021123027099003|261102123227099003|261028144727099003|261022105027099003|261022075727099003|261026140227099003|261026121527099003; X-Microsoft-Antispam-Message-Info: gfGIdGuB3R33eq122ud63titSK79wtekZGkGZFF/2+B8nm+SU57RwzPisaN/ZtQL87XRx20mFP4z1wI7A9dvsxQ5G5EEcr5zlarRmERPgSkTgbAwadFnoLuxXtatlgyz4ssEBCp8ZwGlefo05OA7Hr+3FcEhu1y56bi5au00mrBb4CQs7f60dSKFOdDu5u33pAbC05OuTQV9sVVj/Qm4hZNkCS8ateuin3x7DN+OyEKGKT+lU7fa6cbdgZjZ9HYE4E0j6Jxy34FCS16h22QaUejAZEmVJ8ScJtHMEhUmlYikfyz9L82PNexL2ORER4Kt5cLYHglLAdW+BUFX/nJQLuf7RM3oSs0SUPLRrvwCRZfp6ErnaaMQ74PEPWA1vRtvz/ZzBcZLdxswojlKP3chBbfzJ/7R/BqeF5NulshNY+a+1gtZY7kAPo1zm+ZBomjORMqSyuCvarUwL5Jas90jgvTmhQhWj4L1siKNDxGb+SqdOSSQDAFruCnLJmxVYBvCqCiUDp+w5K/xXD8fco0RSmWBoAmnHrfG0De1uegV1dv41iUoZ5YYDTvUQiWdq3U6HSV+9TI8iMwvKmESkfMRfZdmEa1Hwgw6j+6ldkxa2hPmVWTC0VRDVPZXPoZpdpnhJFg6EyLiyYLRAcnCZ7RoTrbeIhzLkWbKJ+W8rM46S+Q= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS4PPF0BAC23327.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(23010399003)(1800799024)(11063799006)(6133799003)(261009223027099003)(22082099003)(18002099003)(56012099006)(10067099003)(261021121427099003)(261021123027099003)(261102123227099003)(261028144727099003)(261022105027099003)(261022075727099003)(261026140227099003)(261026121527099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?gGKYuxzpdREVSZViQ9hOoxorLtzHMIzJyatM3/6XgD9YvglJO4BW9OwjVLdo?= =?us-ascii?Q?waTkh1Ftbw/KrFQUvBPdrMtq9YHVCWg81ayPLIM0gVcxRMBgMIYbWOPDpn97?= =?us-ascii?Q?x7AnMU1I1/tGgYdsNfYb2JoeJN3PvSs6zrnw5QWUIMGYpGH0GZZDZALaH/to?= =?us-ascii?Q?DmuW4xGSOT7Ss3b0KxsWbaOvPp/B7PMlLTwzuLK1laPPUgCn6WK5G/GBwdwH?= =?us-ascii?Q?Rv+IHZxg1f5/Lv7gf9vebj8Z/RVRDmYvbYe37VmvPR5PQIz+wA+v+E7g644C?= =?us-ascii?Q?mmqI4o1MRcbbQNZGG62bWE1SNxHN3uq/GS9jk5+rNAqGebt1yWZYNXXMcPS+?= =?us-ascii?Q?MpzG8t0tJdq8aviesjiZud7FhCvZhmaV8N5n6B76h+6lJme6qn2JnhD3wmc/?= =?us-ascii?Q?hqTojo3D/lfqamb/+O7UKscut5M1e+fKkBMhuPJ0MWm/aM9TkxaM5MZ39IPL?= =?us-ascii?Q?ehRHl7S4b9nl2hFgq88T9bm0UKFILju8dXKX6sariYqFt+U45ZTIP5g5zj66?= =?us-ascii?Q?c10LxZosItU3411AKZLUBmbfKUoKac83k4ysRXxox8HNdJsgpHWr9hXODMCz?= =?us-ascii?Q?UlsKxTu3aIW1QFs+g7EXrwAffaR+7BispVxLUS+ZD1oo16C/SiZXCLqirWzi?= =?us-ascii?Q?SgxRmQ98FZ9exwu0f3M96suXtR+vbm4b4hT84YdnVvt5djDcRh1BXSZThay+?= =?us-ascii?Q?EQHkGvwHMHx8RCu2uY05MfeYx9OFvJVQA56DPV7fwV9tOwbZbRls43PgdZfc?= =?us-ascii?Q?6PgC54phfuY6sE8xI7gHdBEDn/M72ApYLLvpQp8hRmzw1wd3Ji9zkF7iPV+2?= =?us-ascii?Q?rlE0ad+qEe/V+amdg8tgWCnSM8o4b3dr3YEYWp57hC5u4RtzmhUDrDsolkb8?= =?us-ascii?Q?+cLlEEBCEBKisfOlfPUB+RDo0Vl+tUhihkOU54bFUITMvuHdnF8WsDl8Y9MY?= =?us-ascii?Q?K0XHBlRGwotzmwwQnXa80Zh5M/1fBcB67VrNnfAvzzopT4QxbcM/kTz9WCn1?= =?us-ascii?Q?fBZdIrfx9Zrar9fQFRmzpIzNMfzmHTHk/46C+DAKqo2jh1CcmfeIlzrOYk6j?= =?us-ascii?Q?r3sDx6OhsecLgBjfENNW93U+7pPYrMnsrBy5gQc4iy/9jPyZm1Pqai3tsquh?= =?us-ascii?Q?pdmc99rncOImMrFJklwFzdyxlXSium3wKxzlqywR8ne8G/hSyT/eAXAUQi9l?= =?us-ascii?Q?elnczQlyA9DczJBXL7md46xsTcNyzQ8dPt9LV/kkJpQod7VASjmMAiSRnuw2?= =?us-ascii?Q?DFR5Xa5fjcjF7rxvzlnL9CSyc7vJ58P683KU+MXy5vSiKww4CZ1s+oI1dWw9?= =?us-ascii?Q?TtZytDKl4zXW2sGuMaorvGtxfHxDCeAav8ni8g5lI7Lo49klupMYZvwrhGTE?= =?us-ascii?Q?z42EyWObJdKYHn/YQvf7pxk1RQXmp9PydSAQn/4nbmxBYIDRahuaEhu+iasF?= =?us-ascii?Q?cAmvb3RLp2hzayTsk1TiGlMusQ55ghyiBnv1r7UeNiL594d5b2qo78TkVEgm?= =?us-ascii?Q?zv2qZoEUetlKzX9HCgSp1ntPdQjDtocEcU6AWDse1Cxp075FHpe9jrxNHuPl?= =?us-ascii?Q?okQ3mOfZbTukxutPy4h2IU1m7Q2oXYFiQqmsI/5vd13nWrJxpCDy017dWBxG?= =?us-ascii?Q?bS/a4ltOHPqRCXex8ZJp2/NnjKBwqHaQOi+WDq6NfCP/silCBivllyfAj8rJ?= =?us-ascii?Q?MHYHRihTJYIEbk8PMVl6tUnNnRcyiiT+MNjM/8v9sXI54PNlq13YoWQcxviu?= =?us-ascii?Q?iw7vjrdJ4t6DKuorLSS4WNGEAASDwUA=3D?= X-Exchange-RoutingPolicyChecked: LQ5ofmcsbmxoCCkm0UQKAQLwl8RcGbU8l73O0HE9qkfAJve2csE6GwznrdA7AKdnLnHD5zxG8L7k+LCPhuO/0LPdRB6sWFusTVyPqzdx0n1m7IEYT+pxbNCkERfTsYZyo4i6oGIIouDBL+aVe/0WvLW3n7hDdZ8LOQzBK4/FtPujjKmOYji47+rdGkLBqk8J1uB2ETkY0zI/Q/YNXy411l+GM3+AtCSd5EKXx8ofW8J5/yzdjyKJtiAGYNDcrIqjyeMw9cb60mpEO3H4LXe5jjWGPC0ehAtUbi+l50mYFVnfnJ+fksuRqWH6mwmXf8tlNZtYNPQ6i21h9+JIgYzgwg== X-MS-Exchange-CrossTenant-Network-Message-Id: c8d79724-95e0-43a0-8a44-08df51729b54 X-MS-Exchange-CrossTenant-AuthSource: DS4PPF0BAC23327.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2026 19:21:18.6390 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: M6XtrMj0l8mAIqHjWPzeoAGFchps0SBJpMF4ZwT0g/oymkSqoMHIPkElRjEwS3Q1oGA6+s0s813vknZ4Ue/m+lyi/+KR9gRFOXYmJHzRqnQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LVXPR11MB9756 X-OriginatorOrg: intel.com On Sat, Nov 21, 2026 at 07:57:14PM +0900, Unsung Lee wrote: Hi Unsung, Thanks for the patch! This is a good fix. __create_region() is the right place for the check because it covers both sysfs region creation and auto-assembly. > add_cxl_resources() expands a CXL window over a conflicting resource > and then removes any following window that the expanded one contains, > or trims the start of one that it partly overlaps. Please replace this walkthrough with a short summary of the bug and the fix. Two short paragraphs should do it. 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. Reject region creation with -ENXIO before either creation path can use the missing resource. Then give the configuration context in a sentence or two. You reproduced the oops with QEMU PCI MMIO overlapping the cxl_test windows. The same unpaired- decoder state can arise when a firmware System RAM range starts inside one CXL window and extends into the next. The firmware case and the auto-assembly failure are from code inspection. Put the relevant /proc/iomem entries, QEMU version and guest configuration, and ndctl results below the --- line. more inline below ... > .... pair_cxl_resource() > only sets cxlrd->res when a window still contains the whole HPA range > of the root decoder, so the root decoder of a removed or trimmed window > stays registered with cxlrd->res == NULL. > > Region code uses cxlrd->res without a check. Writing a region size > under such a decoder passes NULL to alloc_free_mem_region() and oopses > with resource_lock held for write, which then stalls every other > resource tree user: > > 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] > kernfs_fop_write_iter+0x13f/0x1e0 > > Auto-assembly of a committed region under such a decoder would do the > same in __construct_region() and cxl_extended_linear_cache_resize(). > > Both the sysfs and the auto-assembly paths create the region with > __create_region(), so reject a root decoder without a window there, > next to the existing check for a dead root decoder. > > This was hit with cxl_test in a QEMU guest whose 64-bit PCI window > overlaps the cxl_test mock windows: CXL Window 0 is expanded over > PCI Bus 0000:00 and swallows Window 1 and 2. > > The problem was found, reproduced and the fix tested with an LLM coding > assistant driving the QEMU and cxl_test runs. > > Fixes: 23a22cd1c98b ("cxl/region: Allocate HPA capacity to regions") > Signed-off-by: Unsung Lee > --- > Notes: > > - How this patch was made: an LLM coding assistant found the problem > while running cxl_test in QEMU, analysed it, drafted the fix and this > changelog, and drove the reproduction and test runs below. I reviewed > the analysis and the fix against the code. > - Reproduced on v7.3.1, v7.4-rc3 and cxl/next (32af781935). With the > fix on cxl/next, all four root decoders without a window fail > create_pmem_region/create_ram_region with -ENXIO and the guest > stays up; the ndctl v85 cxl suite gives the same results as > without the fix, except cxl-poison.sh, which now fails instead of > oopsing the kernel. > - Only the alloc_hpa() path was reproduced. The auto-assembly path and > the case in the add_cxl_resources() comment (System RAM spanning two > windows, the second window trimmed) are from reading the code. > - With the trimmed window, its decoder now gets -ENXIO instead of > using the remaining tail of the window for dynamic regions, as that > comment suggests. That matches what pair_cxl_resource() already does > (no window, no cxlrd->res); making the tail usable would need the > decoder range to follow the trimmed window and is left alone here. > - An alternative is to warn in pair_cxl_resource() or not to register > such a root decoder at all. Rejecting in __create_region() is the > smallest change that covers every user of cxlrd->res. > > drivers/cxl/core/region.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c > index 27e63e6da..a2cd18571 100644 > --- a/drivers/cxl/core/region.c > +++ b/drivers/cxl/core/region.c > @@ -2792,7 +2792,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); The kernel-doc says the trimmed tail is available for dynamic provisioning. Is that still the intent? If the tail is intentionally unusable, please update the kernel-doc to match. Please add a dev_dbg() in pair_cxl_resource() when a root decoder is left unpaired. Include the decoder name and HPA range. Thanks, Alison > > switch (mode) { > -- > 2.43.0 >