lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e99afc0e-e0a2-4719-9c04-4fa8fcafb4f0@infradead.org>
Date: Sun, 4 Jan 2026 14:49:33 -0800
From: Randy Dunlap <rdunlap@...radead.org>
To: Graham Roff <grahamr@....qualcomm.com>,
 Nathan Chancellor <nathan@...nel.org>, Nicolas Schier <nsc@...nel.org>,
 Jonathan Corbet <corbet@....net>
Cc: linux-kbuild@...r.kernel.org, linux-doc@...r.kernel.org,
 linux-kernel@...r.kernel.org, Nicolas Pitre <nico@...xnic.net>,
 Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH v3] kconfig: Support conditional deps using "depends on X
 if Y"



On 12/15/25 3:06 PM, Graham Roff wrote:
> From: Nicolas Pitre <nico@...xnic.net>
> 
> Extend the "depends on" syntax to support conditional dependencies
> using "depends on X if Y". While functionally equivalent to "depends
> on X || (Y == n)", "depends on X if Y" is much more readable and
> makes the kconfig language uniform in supporting the "if <expr>"
> suffix.
> This also improves readability for "optional" dependencies, which
> are the subset of conditional dependencies where X is Y.
> Previously such optional dependencies had to be expressed as
> the counterintuitive "depends on X || !X", now this can be
> represented as "depends on X if X".
> 
> The change is implemented by converting the "X if Y" syntax into the
> "X || (Y == n)" syntax during "depends on" token processing.
> 
> Signed-off-by: Nicolas Pitre <nico@...xnic.net>
> 
> [Graham Roff: Rewrote commit message, updated patch, added tests]
> 
> Signed-off-by: Graham Roff <grahamr@....qualcomm.com>

LGTM. Thanks.

Acked-by: Randy Dunlap <rdunlap@...radead.org>

> ---
> This patch updates an earlier one that was not merged to work on 
> the latest kernel release.
> 
> Link: https://lwn.net/ml/linux-kernel/nycvar.YSQ.7.76.2004231102480.2671@knanqh.ubzr/#t
> 
> Support for this change has been expressed by a number of developers
> since the original patch was proposed back in 2020, and has recently
> also been raised as a patch to the Zephyr kconfig system.
> One specific use is when mapping the Bluetooth specification to Kconfig,
> as it explicitly provides dependencies between features as conditional
> on other features. Many other cases exist where the "slightly
> counterintuitive" (quoted from the Kconfig specification) expression 
> "depends on BAR || !BAR" has been used when a proper "if" condition 
> would be more readable. Some examples:
> 
> arch/arm64/Kconfig:
>   depends on ARM64_64K_PAGES || !ARM64_VA_BITS_52 -->
>   depends on ARM64_64K_PAGES if ARM64_VA_BITS_52
> arch/mips/Kconfig:
>   depends on SYS_SUPPORTS_HOTPLUG_CPU || !SMP -->
>   depends on SYS_SUPPORTS_HOTPLUG_CPU if SMP
> arch/riscv/Kconfig:
>   depends on CC_HAS_MIN_FUNCTION_ALIGNMENT || !RISCV_ISA_C -->
>   depends on CC_HAS_MIN_FUNCTION_ALIGNMENT if RISCV_ISA_C
> arch/x86/Kconfig:
>   depends on X86_64 || !SPARSEMEM -->
>   depends on X86_64 if SPARSEMEM
> drivers/acpi/Kconfig:
>   depends on ACPI_WMI || !X86 -->
>   depends on ACPI_WMI if X86
> drivers/bluetooth/Kconfig:
>   depends on USB || !BT_HCIBTUSB_MTK
>   depends on USB if BT_HCIBTUSB_MTK
> mm/Kconfig:
>   depends on !ARM || CPU_CACHE_VIPT -->
>   depends on CPU_CACHE_VIPT if ARM
> kernel/Kconfig.locks:
>   depends on !PREEMPTION || ARCH_INLINE_READ_UNLOCK -->
>   depends on ARCH_INLINE_READ_UNLOCK if PREEMPTION
> 
> The earlier patch discussion ended without a real conclusion and should
> be revisited now.
> ---
> Changes in v3:
> - Updated commit to prefix with "kconfig:".
> - Updated tests to support modules for tri_state configs.
> - Link to v2: https://lore.kernel.org/r/20251118-kconfig_conditional_deps-v2-1-e360792edaed@qti.qualcomm.com
> 
> Changes in v2:
> - Added test cases.
> - Updated documentation to improve the dscription of conditional
>   and optional dependencies
> - Link to v1: https://lore.kernel.org/r/20251107-kconfig_conditional_deps-v1-1-aff22199ec0b@qti.qualcomm.com
> ---
>  Documentation/kbuild/kconfig-language.rst          | 22 +++++++++++++--
>  scripts/kconfig/lkc.h                              |  2 +-
>  scripts/kconfig/menu.c                             | 12 +++++++-
>  scripts/kconfig/parser.y                           |  6 ++--
>  scripts/kconfig/tests/conditional_dep/Kconfig      | 32 ++++++++++++++++++++++
>  scripts/kconfig/tests/conditional_dep/__init__.py  | 14 ++++++++++
>  .../kconfig/tests/conditional_dep/expected_config1 | 11 ++++++++
>  .../kconfig/tests/conditional_dep/expected_config2 |  9 ++++++
>  .../kconfig/tests/conditional_dep/expected_config3 | 11 ++++++++
>  scripts/kconfig/tests/conditional_dep/test_config1 |  6 ++++
>  scripts/kconfig/tests/conditional_dep/test_config2 |  7 +++++
>  scripts/kconfig/tests/conditional_dep/test_config3 |  6 ++++
>  12 files changed, 130 insertions(+), 8 deletions(-)


-- 
~Randy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ