From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FB2723392C; Wed, 9 Sep 2026 00:55:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788915302; cv=none; b=Hxk2AJKWipPV+xBHHIsvy6rAiv/f65nOIAAP+57V8hp2+ZUh4yrYIX7xvQspFlVeJxgDiKO735eRNPFyqS0JswnWGzn1PHie25+wr9WvRzaLo2dlZSTxjxEx3CjtNbFOgfuqsdsRYbJX9X46Ogps13/TMMyEcXWuBZhWFgtoWh8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788915302; c=relaxed/simple; bh=LPf8yjsjFTCgsChR7/cRfsPnjHD4+1UpzmmPALY7BUY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j0q6XsIvY0PxMldV2B0A7jBMJJAZ7TrzEt7B1480TbRLXUNdh9YXmGTDIWWM30SK91S+421hnXVvIkkd1SXYIWXPlUI0MkKUrcaM6g4ldDZLgN0Mm+4aA/rssramXP4n7S0xXng0WIYBXDN8SW7PT1QuPLnB6Lz6tLghAC++yus= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YyjMnIuB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YyjMnIuB" Received: by smtp.kernel.org (Postfix) with ESMTPS id 1470DC2BCFB; Wed, 9 Sep 2026 00:55:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788915302; bh=LPf8yjsjFTCgsChR7/cRfsPnjHD4+1UpzmmPALY7BUY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=YyjMnIuBmSdJP8k+CuGhUDaRLpG46DZPiCQ4wDN5ke3mhDwwuRZ4Cw4rMJG4G8Nmz PjnAvdetRmJl1GYjTKPEOVYJN8rkz1kR4YXltS3te4Hup81bVAxnVC4XsgVNmwrbwl LUkFzIkyG+13rCcG4j9Du9VaBMnmnsyyzpRo92NdQ4pfvfj4fzG2rxThB2K9CuVRMR N17aa6Z6lmSMO4E4f9LwneqpklMzF+5gH3aLGSQcxqUtkLijEhjW0u1wI/MgV7mQ+K lc4iS1qMI3CKIUpMoIUdJPrbxzDD7xMLJ6XF5Jy8VS+TXtulcetRe66bcWhp+57PJ+ P/BBpUq1ciLug== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E710BC79FA1; Wed, 9 Sep 2026 00:55:01 +0000 (UTC) From: Jim Cromie via B4 Relay Date: Tue, 08 Sep 2026 18:54:57 -0600 Subject: [PATCH v9 01/39] selftests/dyndbg: Add kselftest script to verify dynamic-debug Precedence: bulk X-Mailing-List: linux-arch@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260908-dd-cmap-part2-clean-v9-1-3a3f621f4a10@gmail.com> References: <20260908-dd-cmap-part2-clean-v9-0-3a3f621f4a10@gmail.com> In-Reply-To: <20260908-dd-cmap-part2-clean-v9-0-3a3f621f4a10@gmail.com> To: Jason Baron , Shuah Khan , Andrew Morton , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Arnd Bergmann , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Jonathan Corbet , Greg Kroah-Hartman , Nathan Chancellor , Nicolas Schier , Shuah Khan , Randy Dunlap , "Rafael J. Wysocki" , Pavel Machek , Len Brown Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-pm@vger.kernel.org, Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788915300; l=62361; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=W/NfKc1r06KO1HjSrVqxHNlyrb9qVSV2GQ2pseLMxBw=; b=9k8Z3tTfrSa8yRkJhT+s3TIYY81i3Hz0HI+/FUF2it1dHOkxsS0e3iQVc4zzfWO0D+5eksroV KmQgKYNGWo1AML21FcT3Wo9x1ZaOLZsFa3Y7hRvQ3es7STnPsTvMeGJ X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= X-Endpoint-Received: by B4 Relay for jim.cromie@gmail.com/20260203 with auth_id=958 X-Original-From: Jim Cromie Reply-To: jim.cromie@gmail.com From: Jim Cromie Add a kselftest script to attempt full validation of dynamic-debug behavior. The script tests query grammar as documented, responses to bad input, and proper/expected effects on both the control-file display of current state, and on pr_debug logging behavior. NOTE: This script was finished last, then rebased to front; It gives an easy functional test thru the series, not just a does-it-boot. It preserves but disables some tests to pass as a baseline; there are 3 Basics: FT_grammar_ok(), FT_grammar_errs(), FT_basic_queries(). The Canonical Test: A naive dyndbg test might look like: echo "module main +mfp" > /proc/dynamic_debug/control local ct=$(grep -c " =pmf " /proc/dynamic_debug/control) (( $ct == $expected)) || FAIL But you'll find that you've changed 4 different modules, and your count is off. Ad-hoc testing is hard, and fundamentally trades test clarity against thoroughness, precision and brittleness. Here, the canonical test tries harder: 1. Observe the prior dyndbg state-of-interest. 2. Send $cmd to change state-of-interest. a: echo $cmd > control b: echo 1 > "/sys/module/test_dynamic_debug/parameters/do_classes" 3. Observe the results, in control-file or dmesg The key here is 'observe' means `md5sum $state-of-interest`. This gives us total "checksum" precision, and with a little care, $state-of-interest mostly solves the brittleness. If a test should cause logging: 1. Sends a unique 'START_of_label' message directly to syslog/dmesg. 2. Sends the command or parameter configuration, as in b: above. 3. Sends a unique 'END_of_label' message directly to syslog/dmesg. 4. read dmesg, extract START..END This bookended logging allows the script to isolate and reliably extract the precise dmesg/syslog slice between the markers, and fingerprint the state-of-interest cryptographically. Its not truly isolated from busy-kernel messages, unless its a test-vm. Comprehensive Feature Test (FT_*) Script Mapping: The Feature Test (FT_*) functions test major aspects of dynamic-debug, they're in 3 categories: 1: Zero-Dependency Grammar & Core Parser Tests These tests throw legal & illegal commands at the >control file, but don't attempt to select any real pr_debug callsite. * FT_grammar_ok: Verifies successful query grammar parses (exact line, open line range, closed line range, and colon-delimited file:line/file:func syntax) using side-effect-free empty placeholder flags ('+_'). * FT_grammar_errs: Verifies core query parser error-handling and EINVAL paths across multiple verbosity levels (0..3), catching even minor message drift. 2: Built-in Feature & Name Equivalence Tests (Kernel Core) These tests verify the core features compiled directly into the kernel image. They validate "[main]" vs "[init/main]" resolution added recently. * FT_basic_queries: Verifies basic, direct queries (module, func, format, and clear flags '=_') targeting the builtin kernel/params engine. These tests are disabled until KBUILD_MODFILE: * FT_path_module_queries: Verifies path-based and wildcard module query controls (such as module 'init/main', module '*/main') targeting builtin startup callsites. This specifically validates the back-compat resolution of the old 'module main' ambiguity (which selects 5-6 different built-in modules). * FT_hyphen_underscore: Verifies literal name versus kbasename hyphen/underscore equivalence (e.g., kvm_intel vs. kvm-intel), proving that both queries select identical ranges-of-interest. This validates recent kernel fixes establishing name-normalization equivalence inside the query engine, ensuring that character substitutions work as they do in modprobe. 3: Tests which require test_dynamic_debug These tests verify complex classmap configurations, multi-module setups, and load-time/runtime parameter callback equivalence. * FT_test_classes: Verifies classmap-based query enablers and class configurations on a modular target, proving dynamic runtime class configurations via /proc/dynamic_debug/control. * FT_classmap_inheritance: Verifies multi-module classmap propagation and class inheritance checks between a parent and submodule sharing a classmap. This actively demonstrates a key systems distinction: one-time bare class queries (dyndbg=class...) do NOT inherit at load-time, whereas classmap module parameters (p_disjoint_bits, p_level_num) are persistent and successfully propagate state to submodules upon loading. These tests recapitulate the scenario where classmaps-v1 [1] hit regressions and was marked BROKEN. * FT_modprobe_w_param: Verifies load-time parameter callback initialization (via modprobe $param=$val) and subsequent runtime sysfs-write unsetting callbacks sequentially, by looping over verbose levels, and varying (p_disjoint_bits, p_level_num) and (do_classes, do_bulk). NB: within each FT_, tests are numbered and cataloged. This isolates each FT_* test's sequence numbers from each other. Main Test Runner (dyndbg_selftest.sh) Support Functions: * ddcmd("$query", ["$range"], ["$action"]): The core test primitive. Writes a query string to the control file. - ["$range"]: Optional slice filter pattern (triggers transition verification R1 on non-empty values). - ["$action"]: Expected outcome action ('pass' default, 'fail' asserts return code 1 and logs dmesg, 'log' asserts 0 and logs dmesg). * ddcmd_err("$query"): Semantic error query wrapper. Invokes ddcmd expected to fail. * ddcmd_load("$query", "$range", "$param_path", "$val"): Workload-driven syslog verification helper. - "$param_path": Sysfs parameter path of workload trigger. - "$val": Integer trigger value written to workload param. * verify_modprobe_param_logging("$param", "$val", "$tag"): Dynamic parameter test primitive. Coordinates load-time modprobe and runtime sysfs unsetting in a single sequence. - "$param": Module parameter name to configure at load-time. - "$val": Initial value or composite bitmask/level integer. - "$tag": Suffix used to construct the dmesg golden record label. * slice_and_hash_ddctrl("$grep_pattern"): Local control-file wrapper. * ifrmmod("$module"): Defensive module unloader. * handle_exit_code("$lineno", "$func", "$exit_code", ["$expected_code"]): Core exit code verifier. - "$lineno": Caller line number ($BASH_LINENO). - "$func": Caller function name ($FUNCNAME). - ["$expected_code"]: Expected exit code, default 0. Verification Library (syslog_hash_validation.sh) Support Functions: * log_start() / log_stop(): Slicing syslog capture bookends. Marks the start and end of a stimulus-triggered test execution by writing tags to /dev/kmsg. * rdi_resolve_label(): Active sequence resolver. Leverages Bash call-stack reflection (FUNCNAME) to determine active FT_ test functions and automatically re-index sequence numbers. * slice_by_grep("$pattern", ["$file"]): Text slice extractor. Narrows the scope of a captured log or file. - : Regex pattern to narrow the capture scope. - [file_path]: Target file path to slice (defaults to dmesg). * verify_file_slice(, [file_path], [extra_args]): Standard file transition verifier. Captures a state slice, auto- resolves the label, and verifies its cryptographic hash. - : Regex pattern defining the capture scope. - [file_path]: Target file to slice, defaulting to control-file. - [extra_args]: Optional tag appended to the golden record. * verify_dmesg_slice(