[PATCH v2 08/11] Documentation: kconfig-audit: Describe policy overlays
From: Ahmed S. Darwish
Date: Thu Dec 03 2026 - 17:50:18 EST
Document kconfig-audit's policy overlays structure and usage.
Signed-off-by: Ahmed S. Darwish <darwi@xxxxxxxxxxxxx>
---
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