mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ahmed S. Darwish" <darwi@linutronix.de>
To: Nathan Chancellor <nathan@kernel.org>,
	Nicolas Schier <nsc@kernel.org>,
	Julian Braha <julianbraha@gmail.com>,
	Emanuele Rocca <ema@debian.org>,
	Clark Williams <clrkwllms@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@redhat.com>
Cc: "Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
	"Frederic Weisbecker" <frederic@kernel.org>,
	"John Ogness" <john.ogness@linutronix.de>,
	"Derek Barbosa" <debarbos@redhat.com>,
	"Zbigniew Jędrzejewski-Szmek" <zbyszek@amutable.com>,
	"Daan De Meyer" <daan.j.demeyer@gmail.com>,
	"Luca Boccassi" <luca.boccassi@gmail.com>,
	linux-rt-devel@lists.linux.dev, debian-kernel@lists.debian.org,
	linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Ahmed S. Darwish" <darwi@linutronix.de>
Subject: [PATCH v2 08/11] Documentation: kconfig-audit: Describe policy overlays
Date: Thu,  3 Dec 2026 23:49:09 +0100	[thread overview]
Message-ID: <20261203224916.118064-9-darwi@linutronix.de> (raw)
In-Reply-To: <20261203224916.118064-1-darwi@linutronix.de>

Document kconfig-audit's policy overlays structure and usage.

Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
---
 Documentation/tools/kconfig-audit.rst | 128 ++++++++++++++++++++++++--
 1 file changed, 118 insertions(+), 10 deletions(-)

diff --git a/Documentation/tools/kconfig-audit.rst b/Documentation/tools/kconfig-audit.rst
index 5b8e2fa842b1..e83eb56e43ed 100644
--- a/Documentation/tools/kconfig-audit.rst
+++ b/Documentation/tools/kconfig-audit.rst
@@ -26,6 +26,10 @@ Check a ``.config`` against a policy known to the checker::
 
    audit.py check -c path/to/.config -p preempt_rt
 
+An optional overlay may be supplied with ``-o``::
+
+   audit.py check -c path/to/.config -p preempt_rt -o path/to/overlay.yml
+
 Example invocation from within the kernel tree:
 
 .. code-block:: shell
@@ -121,6 +125,24 @@ The supplied PREEMPT_RT policy resides in the kernel source tree at::
 For field-by-field descriptions of the policy's top-level and rule fields,
 see :ref:`Policy file reference <policy-file-reference>`.
 
+Policy overlays format
+======================
+
+Policy overlay files are YAML documents applied on top of the requested
+configuration policy.  A policy overlay typically looks like:
+
+.. code-block:: yaml
+
+   api_version: kconfig-audit.kernel.org/v1
+   kind: PolicyOverlay
+
+   rules:
+     - name: CONFIG_DRM
+       severity: high
+
+where in the above case, the base policy's ``CONFIG_DRM`` rule severity is
+overriden to high.
+
 Rule matching
 =============
 
@@ -285,10 +307,86 @@ Duplicate exact symbol rules are rejected.  The policy below:
 
 is considered malformed.
 
+Writing overlay files
+=====================
+
+Overlays are intended for local policy, distribution kernel packaging, CI
+environments, and board support packages.  Use an overlay to adjust the
+behaviour of a mainline kernel configuration policy.
+
+Overriding an existing rule
+---------------------------
+
+An overlay identifies an existing rule by its exact ``name`` or exact
+``name_pattern`` string.  It changes only the fields it supplies.  Omitted
+fields keep their values from the base policy.
+
+For example, if the mainline PREEMPT_RT policy contains below rules:
+
+.. code-block:: yaml
+
+   rules:
+     - name: CONFIG_DRM
+       expected: disabled
+       severity: info
+
+     - name: CONFIG_EFI_DISABLE_RUNTIME
+       expected: enabled
+       severity: medium
+
+A board support package may override such rules with an overlay like:
+
+.. code-block:: yaml
+
+   api_version: kconfig-audit.kernel.org/v1
+   kind: PolicyOverlay
+
+   rules:
+     - name: CONFIG_DRM
+       expected: neutral
+       rationale:
+         This product requires a display controller and accepts the latency
+         cost.
+
+     - name: CONFIG_EFI_DISABLE_RUNTIME
+       expected: disabled
+       rationale:
+         The efi_runtime workqueue is pinned to housekeeping CPU#0.
+
+Note that an overlay ``name_pattern`` does not select every base rule whose
+regex matches the same symbols.  It selects only a base rule with the
+*identical* regular expression pattern text.  If no base rule has that
+target, the overlay creates a new rule.
+
+Adding a new rule
+-----------------
+
+When an overlay target is not in the base policy, a new rule is created.
+In that case, the new rule must provide both ``expected`` and ``severity``
+as well.  Below is an example overlay file which adds a new rule:
+
+.. code-block:: yaml
+
+   api_version: kconfig-audit.kernel.org/v1
+   kind: PolicyOverlay
+
+   rules:
+     - name: CONFIG_USB_STORAGE
+       expected: disabled
+       severity: high
+       rationale: This appliance does not accept removable storage.
+
+Overlay behavior
+----------------
+
+An overlay cannot delete a base rule.  Use ``expected: neutral`` to exempt
+a symbol from policy checking.  To retain inherited values, omit those
+fields.
+
 .. _policy-file-reference:
 
-Policy file reference
-=====================
+Policy files reference
+======================
 
 Top-level fields
 ----------------
@@ -304,11 +402,16 @@ tag is supported so far::
 ``kind``
 ++++++++
 
-*Required*.  Identifies the YAML document's type.  For a configuration
-policy file, the value must be::
+*Required*.  Identifies the YAML document's type.
+
+For a configuration policy file, the value must be::
 
    Policy
 
+For a policy overlay file, the value must be::
+
+   PolicyOverlay
+
 ``docs_url``
 ++++++++++++
 
@@ -323,7 +426,7 @@ A rule may then provide ``docs_hint`` to form a full rationale URL.
 ``rules``
 +++++++++
 
-*Required*.  A non-empty list of rule entries.
+*Required for policy files*.  A non-empty list of rule entries.
 
 Each rule describes either one exact configuration symbol or a pattern that
 matches several symbols.  See :ref:`Rule fields <rule-fields>`.
@@ -408,10 +511,12 @@ an exact ``name`` rule.
 ``expected``
 ++++++++++++
 
-*Required*.  Describes the expected state of the matching symbol or
-symbols.
+*Required for all rules in policy files*.
+
+*Required for newly-added rules in policy overlays*.
 
-Allowed values are:
+Describes the expected state of the matching symbol or symbols.  Allowed
+values are:
 
 ``enabled``
    The symbol must be set to ``y`` or ``m``.
@@ -441,9 +546,12 @@ Allowed values are:
 ``severity``
 ++++++++++++
 
-*Required*.  Describes how serious a rule violation is.
+*Required for all rules in policy files*.
+
+*Required for newly-added rules in policy overlays*.
 
-Allowed values are, from highest to lowest::
+Describes how serious a rule violation is.  Allowed values are, from
+highest to lowest::
 
     fatal
     high
-- 
2.56.0


  parent reply	other threads:[~2026-12-03 22:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 22:49 [PATCH v2 00/11] tools: Introduce a kernel configuration checker Ahmed S. Darwish
2026-12-03 22:49 ` [PATCH v2 01/11] kconfig-audit: Add schema for policy files Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` [PATCH v2 02/11] kconfig-audit: Introduce a PREEMPT_RT configuration policy Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` [PATCH v2 03/11] kconfig-audit: Add the configuration checker code Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` [PATCH v2 04/11] Documentation: Describe kconfig-audit usage and design Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` [PATCH v2 05/11] kconfig-audit: Split policy schema for component reuse Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` [PATCH v2 06/11] kconfig-audit: Introduce policy overlays schema Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` [PATCH v2 07/11] kconfig-audit: Add support for policy overlays Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` Ahmed S. Darwish [this message]
2026-12-04 22:50   ` [PATCH v2 08/11] Documentation: kconfig-audit: Describe " sashiko-bot
2026-12-03 22:49 ` [PATCH v2 09/11] MAINTAINERS: Add entry for kernel configuration audit Ahmed S. Darwish
2026-12-03 22:49 ` [PATCH v2 10/11] kconfig: Introduce auditconfig target Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot
2026-12-03 22:49 ` [PATCH v2 11/11] Documentation: Describe auditconfig build target Ahmed S. Darwish
2026-12-04 22:50   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261203224916.118064-9-darwi@linutronix.de \
    --to=darwi@linutronix.de \
    --cc=bigeasy@linutronix.de \
    --cc=clrkwllms@kernel.org \
    --cc=daan.j.demeyer@gmail.com \
    --cc=debarbos@redhat.com \
    --cc=debian-kernel@lists.debian.org \
    --cc=ema@debian.org \
    --cc=frederic@kernel.org \
    --cc=john.ogness@linutronix.de \
    --cc=julianbraha@gmail.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=luca.boccassi@gmail.com \
    --cc=mingo@redhat.com \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=zbyszek@amutable.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®