Linux Serial subsystem development
 help / color / mirror / Atom feed
* Re: [PATCH] kconfig: fix extra output from savedefconfig on out-of-range defaults
       [not found] ` <CAMuHMdWkPtJinDa10S_r7Pj2DTgcKpwgxt7U3tqm7fnSwGxm-Q@mail.gmail.com>
@ 2026-09-01 10:17   ` Geert Uytterhoeven
  2026-09-01 13:48     ` Julian Braha
  0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2026-09-01 10:17 UTC (permalink / raw)
  To: Julian Braha
  Cc: nathan, nsc, xiang, chao, zbestahu, jefflexu, dhavale, hongbohbli,
	guochunhai, michael.bommarito, kees, vegard.nossum, sam,
	u.kleine-koenig, mmarek, linux-kernel, linux-kbuild,
	open list:SERIAL DRIVERS

On Mon, 31 Aug 2026 at 14:36, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> On Mon, 31 Aug 2026 at 00:12, Julian Braha <julianbraha@gmail.com> wrote:
> > The Kconfig interpreter currently allows defaults that are outside of the
> > range bounds.
> >
> > In these cases, the 'sym_validate_range' function will adjust the default
> > value to the nearest range bound. For example, see this example:
> >
> >   config A
> >     int
> >     range 1 2
> >     default 16
> >
> > Here, since the default value of 16 is greater than the bounds, the
> > effective default value gets adjusted down to the upper bound, 2.
> >
> > However, 'savedefconfig' writes non-default values, and without being
>
> s/non-default/non-adjusted/?
>
> > aware of the automatic adjustment to the range bound, it would write: A=2
> >
> > This limitation is also documented in a comment: "The following fails to
> > handle the situation where a default value is further limited by the valid
> > range."
> >
> > To resolve this, let's factor out the default-range adjustment logic from
> > the existing 'sym_validate_range' function into its own
> > 'sym_get_near_range_bound' function for 'savedefconfig' to use too, so
> > that it compares against the effective value.
> >
> > Adds tests, accordingly.
> >
> > Fixes: 7cf3d73b4360 ("kconfig: add savedefconfig")
> > Assisted-by: Codex:gpt-5.6-sol
> > Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > Closes: https://lore.kernel.org/lkml/CAMuHMdVyUAA3L4mUkSjmnuE3cvj-+N8z-Bhxsh1wa-FQWc=fjw@mail.gmail.com/
> > Signed-off-by: Julian Braha <julianbraha@gmail.com>
>
> Thanks, this fixes the issue, and would let us revert commit
> ab74edaeb1ae7c71 ("erofs: Fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
> default logic") in v7.3-rc1.
>
> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>

FTR, this will impact all defconfigs that restrict SERIAL_8250_NR_UARTS
to a value lower than 4:

    config SERIAL_8250_NR_UARTS
            int "Maximum number of 8250/16550 serial ports"
            depends on SERIAL_8250
            default "4"

    config SERIAL_8250_RUNTIME_UARTS
            int "Number of 8250/16550 serial ports to register at runtime"
            depends on SERIAL_8250
            range 0 SERIAL_8250_NR_UARTS
            default "4"

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] kconfig: fix extra output from savedefconfig on out-of-range defaults
  2026-09-01 10:17   ` [PATCH] kconfig: fix extra output from savedefconfig on out-of-range defaults Geert Uytterhoeven
@ 2026-09-01 13:48     ` Julian Braha
  0 siblings, 0 replies; 2+ messages in thread
From: Julian Braha @ 2026-09-01 13:48 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: nathan, nsc, xiang, chao, zbestahu, jefflexu, dhavale, hongbohbli,
	guochunhai, michael.bommarito, kees, vegard.nossum, sam,
	u.kleine-koenig, mmarek, linux-kernel, linux-kbuild,
	open list:SERIAL DRIVERS, Arnd Bergmann,
	Christophe Leroy (CS GROUP), mpe

CC: Arnd, Christophe

On 9/1/26 11:17, Geert Uytterhoeven wrote:

> FTR, this will impact all defconfigs that restrict SERIAL_8250_NR_UARTS
> to a value lower than 4:
> 
>     config SERIAL_8250_NR_UARTS
>             int "Maximum number of 8250/16550 serial ports"
>             depends on SERIAL_8250
>             default "4"
> 
>     config SERIAL_8250_RUNTIME_UARTS
>             int "Number of 8250/16550 serial ports to register at runtime"
>             depends on SERIAL_8250
>             range 0 SERIAL_8250_NR_UARTS
>             default "4"

I suspected that there could be some cases where these out-of-range
defaults were actually accidents and causing bugs, so I added a check
with my SMT solver [1], which also detected these two (powerpc-only):


  config DATA_SHIFT
    int "Data shift" if DATA_SHIFT_BOOL
    default 24 if STRICT_KERNEL_RWX && PPC64
    range 17 28 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC || KFENCE) &&
PPC_BOOK3S_32
    range 14 23 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC || KFENCE) &&
PPC_8xx
    range 20 24 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC || KFENCE) &&
PPC_85xx
    default 22 if STRICT_KERNEL_RWX && PPC_BOOK3S_32
    default 18 if (DEBUG_PAGEALLOC || KFENCE) && PPC_BOOK3S_32
    default 23 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC || KFENCE) &&
PPC_8xx && \
      (PIN_TLB_DATA || PIN_TLB_TEXT)
    default 19 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC || KFENCE) &&
PPC_8xx
    default 24 if STRICT_KERNEL_RWX && PPC_85xx
    default PAGE_SHIFT

  config MODULES_SIZE
    int "Size of modules/execmem area (In Mbytes)" if MODULES_SIZE_BOOL
    range 1 256 if EXECMEM
    default 64 if EXECMEM && PPC_BOOK3S_32
    default 32 if EXECMEM && PPC_8xx
    default 0


The DATA_SHIFT case may be bug, where it should be 12, but incorrectly
adjusts to 20 when:
  PPC_85xx=y

  DEBUG_PAGEALLOC=y

  STRICT_KERNEL_RWX=n

  PAGE_SHIFT=12

The MODULES_SIZE case seems harmless since the only systems using that
option are PPC_BOOK3S_32 and PPC_8xx.

Anyway, this change to savedefconfig would also affect those 2.

[1] https://github.com/julianbraha/kconfirm/tree/smt

- Julian Braha



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-01 13:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260830221129.2668354-1-julianbraha@gmail.com>
     [not found] ` <CAMuHMdWkPtJinDa10S_r7Pj2DTgcKpwgxt7U3tqm7fnSwGxm-Q@mail.gmail.com>
2026-09-01 10:17   ` [PATCH] kconfig: fix extra output from savedefconfig on out-of-range defaults Geert Uytterhoeven
2026-09-01 13:48     ` Julian Braha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox