From nobody Tue Apr 7 12:55:30 2026 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B55B339EF28 for ; Fri, 13 Mar 2026 13:23:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773408229; cv=none; b=iUt1ZQ6KM/CtpWOKnHf1tNtwrrKbkym8bhJMoww9kwnAMAf1nH6jxTRwmj8C6BhGX6t/S7YowiuSZ1td6NhRpktIwhIhrt/WzUdAyIEZGTEChtlreThm7/dIGhU0vPqoDsmh2x8TPXYOkCUXyvGXSiJVxwBkRyoF5Np6t1z3R5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773408229; c=relaxed/simple; bh=E3BuBLscHxCEFbwBedt+/q2/52T+sJEIsVlq6h+6omI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z9lEAs28jDtrqBhPA1FOC1If98SaeFTnzofWT6vgr+VwggeeLGvcJaGs/iHDUD3GjrHkFp6KukYN2NOTXOctMS4Q+XJ8LcltIPZxFLqz4pmIMc0zKhhspfE7NBrzmC/Px41vaQAkS7ZAcvO7Q9z2yUlGlnqLW6pXcYUVbZKdtmc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QgOKa3pt; arc=none smtp.client-ip=209.85.167.175 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.b="QgOKa3pt" Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-46703fb602fso906685b6e.0 for ; Fri, 13 Mar 2026 06:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773408226; x=1774013026; 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; bh=So1OTSMskFHrYYWc+bNZ+5Ly0eOy3XxdufShv2uDEDM=; b=QgOKa3ptQXk/LdtUFUe/2qHLPC5yd6DeWbbzX/tVbJ+YomDkqEdSduhE4YiOQbm2BZ Tg6yPnM3uz5Mu5x7xQ++MPgE/YafthAhvPfBKU6mZgcVQ7QrOrQTXITJq02su5GsYFnp moZMfa3+zeMfIUOJuCmquyzKhH/zBAnuh/OnmEVmJJpIVvRdkj2jV+ubZYVWkHX+GvKj sU7xE7tQua7+IyTmaaBTCEDN/2X7/TVeLEw9RlxTZCMFl+ArAdgfjwe09tnAUFtzIawC nT2s2mGdvx6IOCH0v/kh1OJ4IYLQX4SZyG+R3LmJ3m7xIhUloP/X5W29690hGvOaoo3R KXtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773408226; x=1774013026; 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; bh=So1OTSMskFHrYYWc+bNZ+5Ly0eOy3XxdufShv2uDEDM=; b=UuLZfe91RhKKCnDc2MUyX6AuwrjPE5JQiVmr9Lx5LwkE/G8qYRa50+WjL8mMVMXfxg vz1CJjV8BYviYc4QydHxaPQqJkzrWSIr6Vpe6ZsEbBISi5tr+ehFmTi/JnQBE19cJBvJ 5Jcu2SeM+ns/FeSlzqjoAvMVNFQVMukAJk3nJhC7RKCS5tRNVdGoZbkCBOxZ/4PqZoic sFkSuRO7D2+BJvuUnB2tZa/lJA+gytYdwtm5cWKyXHRJiYf2XOEKUJYzyyelRqxfb7kV 2D/wQPuEIhul86JZhOW1W3OdxQoQUQ6zyp2eY7qslJe6/iVvXav/2/29K2arlEbheD0D Ypow== X-Forwarded-Encrypted: i=1; AJvYcCVn+4cStVdn6fx0xOEIThhvSga+DUEoJBB6r4utdc4tST+I4dv/UiWZtayMdvyPDAQhv1iKsdG3CRrYeRo=@vger.kernel.org X-Gm-Message-State: AOJu0YznV0SjdPnvWU3mfSm3ohQWVMi9zpOl5vpsBthlCl1xNZiypMys ZGu8KqfqeyOzpEiQ9sWA/EevTe/HJo1mHt+mRvHpX8FuM+8l/5IHzvZV X-Gm-Gg: ATEYQzxsbbVqCSwS+rgi1qnfqvN/XJi/yFMr7YSyTunIEpB40NvOiNFwAyuXcZn1rit bMdETtMbzTl6tMOXjVCfDyPz9DqakHIxMkvrMebVys/e7WPGsiOef5koIJ27qTy7oJeHsNwU3JZ +O5CyiOBiqANoaGIStMyKwHD/73Jdz0XiIOhvo9dGjKtlHnsIhD6XPRYJPc+HihiW987dXFJHRq dv2U3ZB4OZPP4oxQjM63Mc2h1wOttOISJoHghEEDoQVuwI4aQibQQ+MZKAE2Di/Mt/y8BKU7y82 IXbxEMOXKZp+H/WVFrBpoXJ7Skfyi9wOECPbmjVLSFf2Ddr/trNYjSrIojHrfus1GEZS4wSqmLl Xf0ECvNaccRZnJHsKA/Koz6/imjEFpcKgUNWCoKdCRsgClc93diP9M+z/KhG/yX2Ixmr0VTybci phLM02O8yFqacEM9pb230J6tAGXX1Lce7+e2Y0vAuSa8P8gOWh X-Received: by 2002:a05:6808:6717:b0:467:462b:ab0 with SMTP id 5614622812f47-46757050cfbmr1535486b6e.2.1773408226613; Fri, 13 Mar 2026 06:23:46 -0700 (PDT) Received: from frodo (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 5614622812f47-4673434a35csm4795987b6e.20.2026.03.13.06.23.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2026 06:23:45 -0700 (PDT) From: Jim Cromie To: airlied@gmail.com, simona@ffwll.ch, jbaron@akamai.com, gregkh@linuxfoundation.org, Jim Cromie , Andrew Morton , linux-kernel@vger.kernel.org Cc: mripard@kernel.org, tzimmermann@suse.de, maarten.lankhorst@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, christian.koenig@amd.com, matthew.auld@intel.com, arunpravin.paneerselvam@amd.com, louis.chauvet@bootlin.com, skhan@linuxfoundation.org, pmladek@suse.com, ukaszb@chromium.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH v11 23/65] dyndbg: detect class_id reservation conflicts Date: Fri, 13 Mar 2026 07:19:48 -0600 Message-ID: <20260313132103.2529746-24-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313132103.2529746-1-jim.cromie@gmail.com> References: <20260313132103.2529746-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If a module _DEFINEs 2 or more classmaps, it must devise them to share the per-module 0..62 class-id space; ie their respective base,+length reservations cannot overlap. To detect conflicts at modprobe, add ddebug_class_range_overlap(), call it from ddebug_add_module(), and WARN and return -EINVAL when they're detected. This insures that class_id -> classname lookup has just 1 answer, so the 1st-found search in find-class-name works properly. test_dynamic_debug.c: If built with -DFORCE_CLASSID_CONFLICT, the test-modules invoke 2 conflicting DYNAMIC_DEBUG_CLASSMAP_DEFINE() declarations, into parent and the _submod. These conflict with one of the good ones in the parent (D2_CORE..etc), causing the modprobe(s) to warn Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v9 - fix WARN() by adding new 1st arg 1. --- lib/dynamic_debug.c | 10 ++++++++++ lib/test_dynamic_debug.c | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 66f4bfe39e89..ec0d1c427d59 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1317,6 +1317,7 @@ static int ddebug_add_module(struct _ddebug_info *di) struct ddebug_table *dt; struct _ddebug_class_map *cm; struct _ddebug_class_user *cli; + u64 reserved_ids =3D 0; int i; =20 if (!di->descs.len) @@ -1341,6 +1342,11 @@ static int ddebug_add_module(struct _ddebug_info *di) dd_mark_vector_subrange(i, cli, &dt->info, users, dt); /* now di is stale */ =20 + /* insure 2+ classmaps share the per-module 0..62 class_id space */ + for_subvec(i, cm, &dt->info, maps) + if (ddebug_class_range_overlap(cm, &reserved_ids)) + goto cleanup; + mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); @@ -1353,6 +1359,10 @@ static int ddebug_add_module(struct _ddebug_info *di) vpr_info("%3u debug prints in module %s\n", dt->info.descs.len, dt->info.mod_name); return 0; +cleanup: + WARN_ONCE(1, "dyndbg multi-classmap conflict in %s\n", di->mod_name); + kfree(dt); + return -EINVAL; } =20 /* helper for ddebug_dyndbg_(boot|module)_param_cb */ diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 6c4548f63512..1ba4be9a403a 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -128,6 +128,14 @@ DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_level_num, DD_CLASS_= TYPE_LEVEL_NUM, DYNAMIC_DEBUG_CLASSMAP_PARAM(disjoint_bits, p); DYNAMIC_DEBUG_CLASSMAP_PARAM(level_num, p); =20 +#ifdef FORCE_CLASSID_CONFLICT +/* + * Enable with -Dflag on compile to test overlapping class-id range + * detection. This should warn on modprobes. + */ +DYNDBG_CLASSMAP_DEFINE(classid_range_conflict, 0, D2_CORE + 1, "D3_CORE"); +#endif + #else /* TEST_DYNAMIC_DEBUG_SUBMOD */ =20 /* --=20 2.53.0