[PATCH v13 00/36] fix dynamic-debug classmaps regression for DRM

Jim Cromie posted 36 patches 2 months, 1 week ago
.../admin-guide/dynamic-debug-howto.rst       | 184 +++-
MAINTAINERS                                   |   3 +-
include/asm-generic/bounded_sections.lds.h    |  21 +
include/asm-generic/dyndbg.lds.h              |  26 +
include/asm-generic/vmlinux.lds.h             |  48 +-
include/linux/dynamic_debug.h                 | 309 +++++--
kernel/module/main.c                          |  15 +-
lib/Kconfig.debug                             |  24 +-
lib/Makefile                                  |   5 +
lib/dynamic_debug.c                           | 831 ++++++++++++------
lib/test_dynamic_debug.c                      | 211 +++--
lib/test_dynamic_debug_submod.c               |  21 +
scripts/module.lds.S                          |   2 +
tools/testing/selftests/Makefile              |   1 +
.../testing/selftests/dynamic_debug/Makefile  |   9 +
tools/testing/selftests/dynamic_debug/config  |   7 +
.../dynamic_debug/dyndbg_selftest.sh          | 373 ++++++++
17 files changed, 1595 insertions(+), 495 deletions(-)
create mode 100644 include/asm-generic/bounded_sections.lds.h
create mode 100644 include/asm-generic/dyndbg.lds.h
create mode 100644 lib/test_dynamic_debug_submod.c
create mode 100644 tools/testing/selftests/dynamic_debug/Makefile
create mode 100644 tools/testing/selftests/dynamic_debug/config
create mode 100755 tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh
[PATCH v13 00/36] fix dynamic-debug classmaps regression for DRM
Posted by Jim Cromie 2 months, 1 week ago
dynamic-debug classmaps in master is BROKEN for DRM, due to a design
error in DECLARE_DYNAMIC_DEBUG_ClASSMAP; its use in both drm-core and
drivers made multiple/redundant definitions of the classmap.  This led
to a regression enabling drm.debug at boot, on builtin drivers.

This patchset retires the macro, and replaces it with
DYNAMIC_DEBUG_ClASSMAP_DEFINE and DYNAMIC_DEBUG_ClASSMAP_USE.  1st is
invoked in drm-core, and defines the classmap, 2nd refers to that
exported definition, and is used in drivers and drm-helpers.

-v13 is a basically a -v12-resend, but:

1. Drops DRM's use of the new API; it can adopt them on its schedule.
   IOW it omits the 1-liner calls to DYNAMIC_DEBUG_CLASSMAP_USE().
   and a few other patches.
   
2. rewords 2 macro-invokes to verify validations on bad API uses.
   changed to better explain what is being tested and prevented.
   these are inactive unless compiled with -DDD_MACRO_ARGCHECK

3. includes patch from Philip Hahn to fix pr_fmt with 2+ terms
   this was also in v12.

-v12 
https://lore.kernel.org/lkml/20260326185413.1205870-1-jim.cromie@gmail.com/
had:

vmlinux.lds.h is refactored:
- BOUNDED_SECTION* macros are pulled into bounded_section.lds.h
- dynamic-debug sections are factored into dyndbg.lds.h,
  which reuses bounded_section.lds.h
- scripts/module.lds.S gets proper output sections for dyndbg
  this fixes lost sections seen in some setups
- based upon codetag.lds.h

DYNAMIC_DEBUG_CLASSMAP_USE*() is refined:
- previous had static class-map decl and unique names
- now have extern'd <classname>-<usermod> names, matching 1-per-module model
- now with compile-time offset check
- _USE/_USE_ together allows more squashing

better modprobe-time classmap definition error detection:
- test descriptors for unknown class-names
- more complete class-map/user conflict detection

rebased onto -rc5
- applies cleanly to drm-misc-fixes
- passes a few more tests on DRM-CI

include patch from Philipp Hahn <phahn-oss@avm.de>

clean subsystem chunks
- dyndbg 1st
- drm - fixes for DRM-CI, adapt,use new API, un-BROKEN
- drm/accel - least mature, I have no HW

-v11 is here
https://lore.kernel.org/lkml/20260313132103.2529746-1-jim.cromie@gmail.com/



Jim Cromie (35):
  dyndbg: fix NULL ptr on i386 due to section mis-alignment
  vmlinux.lds.h: move BOUNDED_SECTION_* macros to reuse later
  dyndbg.lds.S: fix lost dyndbg sections in modules
  vmlinux.lds.h: drop unused HEADERED_SECTION* macros
  dyndbg: factor ddebug_match_desc out from ddebug_change
  dyndbg: add stub macro for DECLARE_DYNDBG_CLASSMAP
  docs/dyndbg: update examples \012 to \n
  docs/dyndbg: explain flags parse 1st
  test-dyndbg: fixup CLASSMAP usage error
  dyndbg: reword "class unknown," to "class:_UNKNOWN_"
  dyndbg: make ddebug_class_param union members same size
  dyndbg: drop NUM_TYPE_ARRAY
  dyndbg: tweak pr_fmt to avoid expansion conflicts
  dyndbg: reduce verbose/debug clutter
  dyndbg: refactor param_set_dyndbg_classes and below
  dyndbg: tighten fn-sig of ddebug_apply_class_bitmap
  dyndbg: replace classmap list with a vector
  dyndbg: macrofy a 2-index for-loop pattern
  dyndbg,module: make proper substructs in _ddebug_info
  dyndbg: move mod_name down from struct ddebug_table to _ddebug_info
  dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module
  dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code
  selftests-dyndbg: add a dynamic_debug run_tests target
  dyndbg: change __dynamic_func_call_cls* macros into expressions
  dyndbg-API: replace DECLARE_DYNDBG_CLASSMAP
  dyndbg: detect class_id reservation conflicts
  dyndbg: check DYNAMIC_DEBUG_CLASSMAP_{DEFINE,USE_} args at
    compile-time
  dyndbg-test: change do_prints testpoint to accept a loopct
  dyndbg-API: promote DYNAMIC_DEBUG_CLASSMAP_PARAM to API
  dyndbg: treat comma as a token separator
  dyndbg: split multi-query strings with %
  selftests-dyndbg: add test_mod_submod
  dyndbg: resolve "protection" of class'd pr_debug
  dyndbg: harden classmap and descriptor validation
  docs/dyndbg: add classmap info to howto

Philipp Hahn (1):
  dyndbg: Ignore additional arguments from pr_fmt

 .../admin-guide/dynamic-debug-howto.rst       | 184 +++-
 MAINTAINERS                                   |   3 +-
 include/asm-generic/bounded_sections.lds.h    |  21 +
 include/asm-generic/dyndbg.lds.h              |  26 +
 include/asm-generic/vmlinux.lds.h             |  48 +-
 include/linux/dynamic_debug.h                 | 309 +++++--
 kernel/module/main.c                          |  15 +-
 lib/Kconfig.debug                             |  24 +-
 lib/Makefile                                  |   5 +
 lib/dynamic_debug.c                           | 831 ++++++++++++------
 lib/test_dynamic_debug.c                      | 211 +++--
 lib/test_dynamic_debug_submod.c               |  21 +
 scripts/module.lds.S                          |   2 +
 tools/testing/selftests/Makefile              |   1 +
 .../testing/selftests/dynamic_debug/Makefile  |   9 +
 tools/testing/selftests/dynamic_debug/config  |   7 +
 .../dynamic_debug/dyndbg_selftest.sh          | 373 ++++++++
 17 files changed, 1595 insertions(+), 495 deletions(-)
 create mode 100644 include/asm-generic/bounded_sections.lds.h
 create mode 100644 include/asm-generic/dyndbg.lds.h
 create mode 100644 lib/test_dynamic_debug_submod.c
 create mode 100644 tools/testing/selftests/dynamic_debug/Makefile
 create mode 100644 tools/testing/selftests/dynamic_debug/config
 create mode 100755 tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh

-- 
2.53.0