paulgazz / kmax

A collection of analysis tools for Kconfig and Kbuild constraints.
41 stars 19 forks source link

kismet false negative: selector:DRM_RADEON, selectee:BACKLIGHT_CLASS_DEVICE, linux v4.16 #168

Closed necipfazil closed 2 years ago

necipfazil commented 2 years ago

kismet marks a select construct safe although there is an unmet dependency bug.

Details:

selector config: DRM_RADEON
selectee config: BACKLIGHT_CLASS_DEVICE
linux version: v4.16
arch: x86_64

Reproducing bug by a given .config file, which is missed by kismet:

  1. Get linux v4.16 (run git checkout v4.16 inside linux git copy)
  2. Download and extract the following config into the linux source as .config: udd_DRM_selects_BACKLIGHT_config.tar.gz
  3. Run olddefconfig (make ARCH=x86_64 olddefconfig) inside the linux directory

Output (see the 4th line):

scripts/kconfig/conf  --olddefconfig Kconfig
warning: (DRM_RADEON && DRM_AMDGPU && DRM_NOUVEAU && DRM_I915 && DRM_GMA500 && DRM_SHMOBILE && DRM_TILCDC && DRM_FSL_DCU && DRM_TINYDRM && DRM_PARADE_PS8622 && FB_BACKLIGHT && FB_ARMCLCD && FB_MX3 && USB_APPLEDISPLAY && FB_OLPC_DCON && ACPI_CMPC && SAMSUNG_Q10) selects BACKLIGHT_CLASS_DEVICE which has unmet direct dependencies (HAS_IOMEM && BACKLIGHT_LCD_SUPPORT)
warning: (STM32_DFSDM_ADC) selects IIO_BUFFER_HW_CONSUMER which has unmet direct dependencies (IIO && IIO_BUFFER)
warning: (DRM_RADEON && DRM_AMDGPU && DRM_NOUVEAU && DRM_I915 && DRM_GMA500 && DRM_SHMOBILE && DRM_TILCDC && DRM_FSL_DCU && DRM_TINYDRM && DRM_PARADE_PS8622 && FB_BACKLIGHT && FB_ARMCLCD && FB_MX3 && USB_APPLEDISPLAY && FB_OLPC_DCON && ACPI_CMPC && SAMSUNG_Q10) selects BACKLIGHT_CLASS_DEVICE which has unmet direct dependencies (HAS_IOMEM && BACKLIGHT_LCD_SUPPORT)
warning: (STM32_DFSDM_ADC) selects IIO_BUFFER_HW_CONSUMER which has unmet direct dependencies (IIO && IIO_BUFFER)
#
# configuration written to .config
#

Running kismet (kismet can't find the bug): This can be reproduced after merging https://github.com/paulgazz/kmax/pull/166

kismet -a x86_64 --selectees CONFIG_BACKLIGHT_CLASS_DEVICE --selectors CONFIG_DRM_RADEON

Logs (says no alarm):

INFO: Computing the build system id for the Linux source..
INFO: Build system id: f4bb5ef64868
INFO: Kismet will analyze the select constructs of the architecture "x86_64" for unmet direct dependency.
INFO: All times reported are measured using Python's time.perf_counter() utility.
INFO: Prefetching the architecture kclause formulas.
INFO: Architecture kclause formulas were loaded. (2.35sec)
INFO: Identifying the select constructs.
INFO: Identification of the select constructs was done in 0.01sec. 1 constructs were found. unmet safe due to syntactical pass: 0. alarms: 1.
INFO: Doing optimized SAT pass for 1 constructs
INFO: 11:18:32 Optimized SAT pass progress:  1/1 (%100).
INFO: Optimized SAT test was done in 0.01sec. 1 constructs with alarms were checked. unmet safe due to optimized SAT test: 0. alarms: 1.
INFO: Doing precise SAT pass for 1 constructs
INFO: 11:18:33 Precise SAT pass progress:  1/1 (%100).
INFO: Precise SAT test was done in 1.12sec. 1 constructs with alarms were checked. unmet safe due to precise SAT test: 1. alarms: 0.
INFO: During precise SAT test, 0 models were generated.
INFO: Skipping test case generation since there are no models to generate test cases for.
INFO: Skipping verification since there are no test cases to verify.
INFO: Writing the aggregated summary txt to "kismet_summary_x86_64.txt".
INFO: Aggregated summary txt was written.
INFO: Writing the summary csv to "kismet_summary_x86_64.csv".
INFO: Summary csv was written.
necipfazil commented 2 years ago

Another one:

selector: PMAC_BACKLIGHT
selectee: FB_BACKLIGHT
linux version: v4.16
arch: arm64

Reproduce the bug A .config file that exercise the bug: PMAC_selects_FB.tar.gz

make ARCH=arm64 olddefconfig output with the above .config file:

warning: (PMAC_BACKLIGHT && DRM_NOUVEAU && HT16K33 && FB_TFT) selects FB_BACKLIGHT which has unmet direct dependencies (HAS_IOMEM && FB)

kismet can't find it:

kismet -a arm64 --selectees CONFIG_FB_BACKLIGHT --selectors CONFIG_PMAC_BACKLIGHT

kismet output:

INFO: Computing the build system id for the Linux source..
INFO: Build system id: f4bb5ef64868
INFO: Kismet will analyze the select constructs of the architecture "arm64" for unmet direct dependency.
INFO: All times reported are measured using Python's time.perf_counter() utility.
INFO: Prefetching the architecture kclause formulas.
INFO: Architecture kclause formulas were loaded. (2.20sec)
INFO: Identifying the select constructs.
INFO: Identification of the select constructs was done in 0.01sec. 1 constructs were found. unmet safe due to syntactical pass: 0. alarms: 1.
INFO: Doing optimized SAT pass for 1 constructs
INFO: 12:09:08 Optimized SAT pass progress:  1/1 (%100).
INFO: Optimized SAT test was done in 0.01sec. 1 constructs with alarms were checked. unmet safe due to optimized SAT test: 0. alarms: 1.
INFO: Doing precise SAT pass for 1 constructs
INFO: 12:09:09 Precise SAT pass progress:  1/1 (%100).
INFO: Precise SAT test was done in 1.04sec. 1 constructs with alarms were checked. unmet safe due to precise SAT test: 1. alarms: 0.
INFO: During precise SAT test, 0 models were generated.
INFO: Skipping test case generation since there are no models to generate test cases for.
INFO: Skipping verification since there are no test cases to verify.
INFO: Writing the aggregated summary txt to "kismet_summary_arm64.txt".
INFO: Aggregated summary txt was written.
INFO: Writing the summary csv to "kismet_summary_arm64.csv".
INFO: Summary csv was written.
necipfazil commented 2 years ago

Unmet dependency warnings in the old format seem to be misleading.

For example, in the first post of this issue, the provided config file results in the following message:

warning: (DRM_RADEON && DRM_AMDGPU && DRM_NOUVEAU && DRM_I915 && DRM_GMA500 && DRM_SHMOBILE && DRM_TILCDC && DRM_FSL_DCU && DRM_TINYDRM && DRM_PARADE_PS8622 && FB_BACKLIGHT && FB_ARMCLCD && FB_MX3 && USB_APPLEDISPLAY && FB_OLPC_DCON && ACPI_CMPC && SAMSUNG_Q10) selects BACKLIGHT_CLASS_DEVICE which has unmet direct dependencies (HAS_IOMEM && BACKLIGHT_LCD_SUPPORT)

This would suggest DRM_RADEON selecting BACKLIGHT_CLASS_DEVICE without meeting BACKLIGHT_CLASS_DEVICE's dependencies. However, in the config file, DRM_RADEON is off. Therefore, these are not false negatives of kismet.

In fact, the unmet dependency warning message format seem to be changed because of this: https://github.com/torvalds/linux/commit/f8f69dc0b4e070d4a4d39889a85424913cc922d5 (see the commit message, which explains why this old format is problematic ([..] Second, we see false positives.[..])).

necipfazil commented 2 years ago

These are not false negatives of kismet but false positives of old Kconfig warnings. Such risk of misinterpretations of old Kconfig warnings are now avoided by having kismet patch Kconfig code to always print warnings in the new format. See https://github.com/paulgazz/kmax/pull/166/commits/13215f3f542ab78942ed36f9e95a34d1ad1a3a33 in https://github.com/paulgazz/kmax/pull/166