From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.20 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796071825; b=3RwlnhPoIwWwXnp4etfAAM5iDD/mYUQXBGWC6J2MTM6+6ZP6Jjh46hMjIY/yHkF38Myr 9X45DGR1KHsTBNbKIJyd7gcV1QPYePtAxpvDbZTtdP/AgM6uWxx80Oj4HaZGqCLLqXpxu JNCVFIYMc5BJ9rntYBl19neDEthahAKgocRFaDXuhRzt7+7cpkfy00fia83Q6RPBKHIxl JFnPHqqQbi0eRFlk+vPifh5PM6IvWsoXCFqYFKKqwO8U8JvRgeQ3Qqous+GVxhtjsJ6bg sI6iiDy/CMN5v5rqZQ0lS6UrQeXAbNMD6b1KtjZbnRAYufwB9x48CfkP57N9qZXEo0g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796071825; 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:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:From: Content-Language:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=lKyH8+9goVJOCWgWC0jF4m6cBhTevfoHkuphrE7GTKM=; b=M7H0LhA3VcaRXIQTRKwZcLoExl2CAE6wfsoYrAE4SF7GIvFP7V4KndqJDfSxtSGTYtIN +bvP6bfg613NDYYMDCfMGEJWGuIQL+1wtgX0zyzHW2e8j3ChCEyH06gfHkZC3ylSXHSpm f3GReKW4cagqNtF2uD7O1b3aV1Q1TH3McU0NVzHlp3G6ulVO9r0tipcmp85Zu/RfoSmRe ppe9uXMtIUs2DGKTqgBQ4hZ8hrNgCcABuTTd8Iry+HmEf1IYwxv1KJP53R31NI35btK56 qVs2r9eu2ngpPZWLnjPU2J6qWMQikS6Hs8c6GmFJqnC500n7dxpEUkdyoSxlXnPJKzQ== ARC-Authentication-Results: i=1; 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=AMJAxE2u; arc=none smtp.remote-ip=198.175.65.20 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 13AB2606A31A; Mon, 30 Nov 2026 20:50:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 13AB2606A31A 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) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=AMJAxE2u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796071825; x=1827607825; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=lKyH8+9goVJOCWgWC0jF4m6cBhTevfoHkuphrE7GTKM=; b=AMJAxE2uhn6BOgxwGPf8hd8VSp23t9SiDdu10XbWgoS2sxaB/73Vk/cI HAmNZx0PG+JhyFbt6CCEIgdjMO31U3svFya11JXzHe4AYRQJIbRPqTB2b ZdKdvYkP+0gY8ACeofq0VFxEfb74X/NDMboLQrYM8XNApHDekqmWwWp1P 0NSn39mSa8XXMFmlzuX4wI9W8Tx/zP99hOQ6t46qQblYq4W5rrOpsCJfb sWVRp0myIhG6i/Ena9gkKSp2xvoJLZ5b+AMXeMeiOPByWqLAD4G/lqVpP R4pCFfXPGGhPuF9tGG7vBPIgQcvvchYWeXTGASuS2nAtGEjOL+jjX27Wg Q==; X-CSE-ConnectionGUID: nCjfs9XdTo6l+FSnON8B9w== X-CSE-MsgGUID: I6nYpgTBT9KCqvIR5PNRxg== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4967508" X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="4967508" Received: from fmviesa013.fm.intel.com ([10.60.135.153]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 12:50:24 -0800 X-CSE-ConnectionGUID: WSwr0/qrR7eDXT6RYgv6Xw== X-CSE-MsgGUID: q7Ax/ABySt+AjJS9yPseQw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="15036445" Received: from cooperst-gp92.amr.corp.intel.com (HELO [10.125.110.218]) ([10.125.110.218]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 12:50:22 -0800 Message-ID: <4b4b4e64-8085-4c32-9441-5882b17927f2@intel.com> Date: Mon, 30 Nov 2026 13:50:21 -0700 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 0/3] cxl/edac: Fix event record lookups for memory repair To: Jongwon Lee , Davidlohr Bueso , Jonathan Cameron , Alison Schofield , Vishal Verma Cc: Dan Williams , Ira Weiny , Li Ming , Richard Cheng , Ben Cheatham , Michal Schmidt , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261126023520.39368-1-ai@linux.com> From: Dave Jiang Content-Language: en-US In-Reply-To: <20261126023520.39368-1-ai@linux.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/25/26 7:35 PM, Jongwon Lee wrote: > This series fixes the cached event record lookups in the CXL memory > repair path. > > Patch 1 fixes a use-after-free that Sashiko reported on v2 [1]. The > repair path reads cached DRAM records without a lock, and the event > path can free them at the same time. The DRAM lookup now runs under > the xarray lock, and the sparing path works on a copy of the record. > > Patch 2 makes both lookups skip records that the device marked > NOT_REPAIRABLE. > > Patch 3 masks the DPA flag bits in the cache key, and depends on > patch 2. With the masked key alone, the trace event DPA would also > match NOT_REPAIRABLE records and let them be repaired. > > I used xa_lock() for the race. kfree_rcu() would need a wrapper with > an rcu_head around the record structs from the spec. Taking > device_lock() in the repair path could deadlock with unbind, which > removes the EDAC sysfs files while holding device_lock(). > > Changes in v6: > - Rebase on cxl/next (32af7819352b), no conflicts > - Patch 2: rename cxl_find_rec_gen_media() to > cxl_check_for_rec_gen_media() and split the two tests (Jonathan) > - Patch 2: changelog wording for the online repair case (Alison) > - Patch 2: drop the Fixes: tag (Jonathan). Patch 3 keeps its Fixes: > tag, so a backport of patch 3 needs patch 2. > - Add the Reviewed-by tags from v5 > - Cc Michal Schmidt for guard(xa_lock), as Jonathan suggested, and > Ben Cheatham as a CXL reviewer > > There is no guard(xa_lock) in the tree, and the 2024 patch for it [2] > was not merged. v6 keeps xa_lock()/xa_unlock(), and I can convert > these sites in a follow-up once a guard exists. > > Changes in v5: > - New patch 2: NOT_REPAIRABLE check split out of v4 patch 2 and moved > before the masking patch (Li Ming) > - Patch 3: rename cxl_rec_key() to cxl_rec_dpa() (Li Ming) > - Patch 1: drop the found variable in cxl_find_rec_dram() (Li Ming) > - Richard's Reviewed-by on v4 2/2 not carried over, as it was split > - Rebase on cxl/next (e44dc3a303) > > Changes in v4: > - Patch 1: copy the whole struct cxl_event_dram out instead of only > validity_flags (Richard Cheng) > - Patch 2: make cxl_rec_key() and cxl_rec_not_repairable() static > inline (Richard Cheng) > - Cover letter: describe patch 1 first (Richard Cheng) > > Changes in v3: > - New patch 1 for the record lifetime race (Sashiko) > - Patch 2: General Media lookup under the xarray lock, returns bool > > Changes in v2: > - Moved the Claude Code note below the --- (Dave Jiang) > > v5: https://lore.kernel.org/r/20261108022022.3352-1-ai@linux.com > v4: https://lore.kernel.org/r/20261102123233.74598-1-ai@linux.com > v3: https://lore.kernel.org/r/20261101013418.87326-1-ai@linux.com > v2: https://lore.kernel.org/r/20261031161121.15948-1-ai@linux.com > v1: https://lore.kernel.org/r/20261030072721.31970-1-ai@linux.com > > Tested in QEMU (master b574eaf) with a CXL type 3 device and a > committed region, on cxl/next 32af7819352b, with KASAN, lockdep, > kmemleak and preempt=full. Not tested on real CXL hardware. > > - Repair requests for eight DPAs on all five mem_repair devices. With > the series, 0x1000 and 0x2000 succeed, 0x5000 succeeds for PPR only, > and NOT_REPAIRABLE (0x3000, 0x6000), missing (0x7000) and unmasked > (0x1001, 0x3002) DPAs get -EINVAL. Unpatched, 0x1000 and PPR at > 0x5000 fail, and 0x1001 and 0x3002 are accepted. > - Race test: event injection from the host, four guest repair loops, > and a test-only mdelay(20) after the lookups. Unpatched, KASAN > reports a slab-use-after-free in cxl_find_rec_dram() within seconds. > With the series: 600 s, 10,950 repairs, 274,946 events, no report. > Without the delay, on the previous base (2101c39473a0) with the same > code: 1,800 s, 98,220 repairs, 1,155,590 events, no report. > - Unbind test: cxl_mem unbound and rebound in a loop during repairs > and event injection. 600 s, 78 cycles, 7,260 repairs, no report. > - kmemleak finds nothing after each run. > - edac.o builds with W=1 after each patch, sparse, clang W=1 (x86_64, > arm64) and CONFIG_CXL_EDAC_MEM_REPAIR=n with no new warnings. The > series also applies to cxl/fixes and v7.4-rc4. > > This series was developed with Claude Code. > > Thanks to Richard, Li Ming, Jonathan and Alison for the reviews. > > [1] https://lore.kernel.org/r/sashiko-outbox-192042@kernel.org > [2] https://lore.kernel.org/all/20240228135352.14444-1-mschmidt@redhat.com/ > > Jongwon Lee (3): > cxl/edac: Read cached DRAM event records under the xarray lock > cxl/edac: Skip event records marked NOT_REPAIRABLE > cxl/edac: Mask DPA flags in the event record cache key > > drivers/cxl/core/edac.c | 116 ++++++++++++++++++++++++++-------------- > 1 file changed, 77 insertions(+), 39 deletions(-) > > > base-commit: 32af7819352bae9c690ebe277a44eceb501d5c68 Applied to cxl/next: d10d3ceac3c0 cxl/edac: Mask DPA flags in the event record cache key 477f1dc61bd0 cxl/edac: Skip event records marked NOT_REPAIRABLE 188f12837f8d cxl/edac: Read cached DRAM event records under the xarray lock