Re: [PATCH v1 03/10] kconfig-checker: Add the configuration checker code
From: Julian Braha
Date: Thu Nov 12 2026 - 21:50:31 EST
On 11/9/26 13:00, Ahmed S. Darwish wrote:
> On Sun, 08 Nov 2026, Julian Braha wrote:
>> On 11/6/26 09:19, Ahmed S. Darwish wrote:
>>> +
>>> +class KernelConfig:
>>> + """.config file parser"""
> ...
>>> +
>>> + def _parse_symbols(self) -> dict[str, str]:
>>> + """Extract CONFIG_* symbol assignments from .config"""
>>> + symbol_set = re.compile(r'^(CONFIG_[A-Za-z0-9_]+)=([ym])$')
>>> + symbol_unset = re.compile(r'^# (CONFIG_[A-Za-z0-9_]+) is not set$')
>> What does this do for Kconfig's int, hex, and string options?
>>
> So far, the tool only supports stating whether an option is enabled,
> disabled, or have a neutral 'allowed' policy.
>
> But there's nothing stopping us from supporting something like:
>
> - name: CONFIG_PANIC_TIMEOUT
> expected: int
> expected_value: 10
>
> - name: CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE
> expected: hex
> expected_value: 0x1
>
> - name: CONFIG_NLS_DEFAULT
> expected: string
> expected_value: "utf-8"
>
> In v2 of this series, I'll make the schema explicitly versioned. This way,
> new features like the above can be cleanly added.
Adding schema versioning would be great.
>
> P.S., I can definitely implement such support, but I'm a bit hesitant to
> adding features that are not yet needed by the existing mainline policies.
I suppose it's not necessary to support these option types at the start,
as there are few of them, relatively speaking. But it would be good to
add some input validation in case a user attempts this.
So I've finally had some time to sit down and test this:
I created my own policy with these other types, and sure enough, if I
specify them as 'disabled' in the policy like this:
rules:
- name: CONFIG_LOG_BUF_SHIFT
expected: n
severity: high
- name: CONFIG_PHYSICAL_START
expected: n
severity: high
- name: CONFIG_DEFAULT_HOSTNAME
expected: n
severity: high
and my .config has these values:
CONFIG_LOG_BUF_SHIFT=17
CONFIG_PHYSICAL_START=0x1000000
CONFIG_DEFAULT_HOSTNAME="example"
then the config passes the check -- but it would probably be better to
provide a warning or something about these options.
Also, if I modify my policy to set 'expected' to 'y' for these, it
reports "not in .config" (which would likely be confusing to the user).
This regex stmt should match all int, hex, and string options for you:
unsupported = re.compile(r'^(CONFIG_[A-Za-z0-9_]+)=[0-9a-fA-F"-]')
by checking the first character of its value.
The included preempt_rt policy worked as expected (nice).
- Julian Braha
Attachment:
OpenPGP_0x0664101D2FC252D1.asc
Description: OpenPGP public key
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature