2023-02-21 16:17:16

by [email protected]

[permalink] [raw]
Subject: .config and "make" / turning off all debug

Is there a command line parameter to Make that will disable anything
that results in a debuggable kernel?

Is there a tool that will modify .config removing anything that will
result in a debuggable kernel?

Thank you.


2023-02-22 00:17:50

by Randy Dunlap

[permalink] [raw]
Subject: Re: .config and "make" / turning off all debug

Hi--

On 2/21/23 08:16, Hanasaki Jiji wrote:
> Is there a command line parameter to Make that will disable anything
> that results in a debuggable kernel?

No.

> Is there a tool that will modify .config removing anything that will
> result in a debuggable kernel?

We don't have a nice, clean, packaged way to do this.

It also depends on what you mean by DEBUG. I would first disable
CONFIG_COMPILE_TEST, then decide if you want TRACE/TRACING features
disabled or enabled. Also decide whether you want DEBUGFS
options enabled or disabled.

There are a couple of things that you can try. YMMV.

Neither of these is a complete solution; option 2 requires
the user to update the list of config options that should be disabled
as needed.

(1) Use a script to convert all occurrences of
/CONFIG.*DEBUG=y/ to /# CONFIG.*DEBUG is not set/.

This misses a few CONFIG options where "DEBUG" is toward the middle
of the CONFIG option, like CONFIG_DEBUG_RSEQ, CONFIG_DEBUG_TEST_DRIVER_REMOVE,
CONFIG_C710_DEBUG_ASSUMPTIONS, CONFIG_DM_DEBUG_BLOCK_MANAGER_LOCKING,
CONFIG_DRM_DEBUG_xyzzz (a few like this), CONFIG_DEBUG_KERNEL_DC,
CONFIG_NOUVEAU_DEBUG_xyzzz (a few), CONFIG_DRM_I915_DEBUG_xyzzz (a few),
CONFIG_SND_SOC_SOF_xyzzz (several), CONFIG_HFI1_DEBUG_SDMA_ORDER,
CONFIG_AFS_DEBUG_CURSOR, CONFIG_DEBUG_NET, lots of entries in the
Kernel Hacking menu. Then there are several SELFTEST config options,
but they are not always spelled "SELFTEST"; they might just be spelled
TEST or TESTS.

I'll attach a Perl script (from 2009) that begins the work on option 1,
but I haven't used it since forever.

(2) Make a "mini.config" file that contains a list of all the options that you
want to have set in a certain way (can be either enabled or disabled).
Then use
$ KCONFIG_ALLCONFIG=your.mini.config make allmodconfig

This is the documented and supported way. It is documented in
Documentation/kbuild/kconfig.rst:

<begin quote>

KCONFIG_ALLCONFIG
-----------------
(partially based on lkml email from/by Rob Landley, re: miniconfig)

--------------------------------------------------

The allyesconfig/allmodconfig/allnoconfig/randconfig variants can also
use the environment variable KCONFIG_ALLCONFIG as a flag or a filename
that contains config symbols that the user requires to be set to a
specific value. If KCONFIG_ALLCONFIG is used without a filename where
KCONFIG_ALLCONFIG == "" or KCONFIG_ALLCONFIG == "1", `make *config`
checks for a file named "all{yes/mod/no/def/random}.config"
(corresponding to the `*config` command that was used) for symbol values
that are to be forced. If this file is not found, it checks for a
file named "all.config" to contain forced values.

This enables you to create "miniature" config (miniconfig) or custom
config files containing just the config symbols that you are interested
in. Then the kernel config system generates the full .config file,
including symbols of your miniconfig file.

This 'KCONFIG_ALLCONFIG' file is a config file which contains
(usually a subset of all) preset config symbols. These variable
settings are still subject to normal dependency checks.

Examples::

KCONFIG_ALLCONFIG=custom-notebook.config make allnoconfig

or::

KCONFIG_ALLCONFIG=mini.config make allnoconfig

or::

make KCONFIG_ALLCONFIG=mini.config allnoconfig

These examples will disable most options (allnoconfig) but enable or
disable the options that are explicitly listed in the specified
mini-config files.

<end quote>

Note that this only works with "make allyesconfig/allmodconfig/allnoconfig/randconfig"
variants. You could try it and see if it works for you.

I'll also attach a sample "disable.all.debug.config" file for this option.
You will need to update this CONFIG options list continually.

HTH. Good luck.

--
~Randy


Attachments:
config.debug.off (575.00 B)
disable.all.debug.config (6.81 kB)
Download all attachments

2023-02-23 00:22:16

by [email protected]

[permalink] [raw]
Subject: Re: .config and "make" / turning off all debug

Hello,

Thank you so much for helping out.

Might the below accomplish the task?

cat f | grep -v DEBUG| grep -v TRACE | grep -v TRACING > newConfigFileWithout

On Tue, Feb 21, 2023 at 7:17 PM Randy Dunlap <[email protected]> wrote:
>
> Hi--
>
> On 2/21/23 08:16, Hanasaki Jiji wrote:
> > Is there a command line parameter to Make that will disable anything
> > that results in a debuggable kernel?
>
> No.
>
> > Is there a tool that will modify .config removing anything that will
> > result in a debuggable kernel?
>
> We don't have a nice, clean, packaged way to do this.
>
> It also depends on what you mean by DEBUG. I would first disable
> CONFIG_COMPILE_TEST, then decide if you want TRACE/TRACING features
> disabled or enabled. Also decide whether you want DEBUGFS
> options enabled or disabled.
>
> There are a couple of things that you can try. YMMV.
>
> Neither of these is a complete solution; option 2 requires
> the user to update the list of config options that should be disabled
> as needed.
>
> (1) Use a script to convert all occurrences of
> /CONFIG.*DEBUG=y/ to /# CONFIG.*DEBUG is not set/.
>
> This misses a few CONFIG options where "DEBUG" is toward the middle
> of the CONFIG option, like CONFIG_DEBUG_RSEQ, CONFIG_DEBUG_TEST_DRIVER_REMOVE,
> CONFIG_C710_DEBUG_ASSUMPTIONS, CONFIG_DM_DEBUG_BLOCK_MANAGER_LOCKING,
> CONFIG_DRM_DEBUG_xyzzz (a few like this), CONFIG_DEBUG_KERNEL_DC,
> CONFIG_NOUVEAU_DEBUG_xyzzz (a few), CONFIG_DRM_I915_DEBUG_xyzzz (a few),
> CONFIG_SND_SOC_SOF_xyzzz (several), CONFIG_HFI1_DEBUG_SDMA_ORDER,
> CONFIG_AFS_DEBUG_CURSOR, CONFIG_DEBUG_NET, lots of entries in the
> Kernel Hacking menu. Then there are several SELFTEST config options,
> but they are not always spelled "SELFTEST"; they might just be spelled
> TEST or TESTS.
>
> I'll attach a Perl script (from 2009) that begins the work on option 1,
> but I haven't used it since forever.
>
> (2) Make a "mini.config" file that contains a list of all the options that you
> want to have set in a certain way (can be either enabled or disabled).
> Then use
> $ KCONFIG_ALLCONFIG=your.mini.config make allmodconfig
>
> This is the documented and supported way. It is documented in
> Documentation/kbuild/kconfig.rst:
>
> <begin quote>
>
> KCONFIG_ALLCONFIG
> -----------------
> (partially based on lkml email from/by Rob Landley, re: miniconfig)
>
> --------------------------------------------------
>
> The allyesconfig/allmodconfig/allnoconfig/randconfig variants can also
> use the environment variable KCONFIG_ALLCONFIG as a flag or a filename
> that contains config symbols that the user requires to be set to a
> specific value. If KCONFIG_ALLCONFIG is used without a filename where
> KCONFIG_ALLCONFIG == "" or KCONFIG_ALLCONFIG == "1", `make *config`
> checks for a file named "all{yes/mod/no/def/random}.config"
> (corresponding to the `*config` command that was used) for symbol values
> that are to be forced. If this file is not found, it checks for a
> file named "all.config" to contain forced values.
>
> This enables you to create "miniature" config (miniconfig) or custom
> config files containing just the config symbols that you are interested
> in. Then the kernel config system generates the full .config file,
> including symbols of your miniconfig file.
>
> This 'KCONFIG_ALLCONFIG' file is a config file which contains
> (usually a subset of all) preset config symbols. These variable
> settings are still subject to normal dependency checks.
>
> Examples::
>
> KCONFIG_ALLCONFIG=custom-notebook.config make allnoconfig
>
> or::
>
> KCONFIG_ALLCONFIG=mini.config make allnoconfig
>
> or::
>
> make KCONFIG_ALLCONFIG=mini.config allnoconfig
>
> These examples will disable most options (allnoconfig) but enable or
> disable the options that are explicitly listed in the specified
> mini-config files.
>
> <end quote>
>
> Note that this only works with "make allyesconfig/allmodconfig/allnoconfig/randconfig"
> variants. You could try it and see if it works for you.
>
> I'll also attach a sample "disable.all.debug.config" file for this option.
> You will need to update this CONFIG options list continually.
>
> HTH. Good luck.
>
> --
> ~Randy

2023-02-23 00:29:57

by Randy Dunlap

[permalink] [raw]
Subject: Re: .config and "make" / turning off all debug

Hi,

On 2/22/23 16:21, Hanasaki Jiji wrote:
> Hello,
>
> Thank you so much for helping out.
>
> Might the below accomplish the task?
>
> cat f | grep -v DEBUG| grep -v TRACE | grep -v TRACING > newConfigFileWithout

It will disable CONFIG_DEBUG_FS. That's OK if that's what you want to do.

But this will just give you something to begin with. It will need more work.
There are lots of config options that use "select" to force another config
option to be set/enabled. Even if you disable an option and you have one of
these other options set/enabled, they will just enable the DEBUG/TRACE options
again for you.

When you find one of these, they pretty much have to be checked and tuned
one-by-one. It can take a lot of time to do that.


--
~Randy
https://people.kernel.org/tglx/notes-about-netiquette

2023-02-24 00:11:33

by [email protected]

[permalink] [raw]
Subject: Re: .config and "make" / turning off all debug

CONFIG_DEBUG_FS appears to be a relevant to kernel development. So,
turning that off should be fine for me.

The below are from grep SELECT. Looking each up, none seem to enable
DEBUG/TRACE elsewhere. However I am still somewhat a newbie.
CONFIG_PROCESSOR_SELECT=
CONFIG_B44_PCI_AUTOSELECT=
CONFIG_B44_PCICORE_AUTOSELECT=
CONFIG_B43_PCI_AUTOSELECT=
CONFIG_B43_PCICORE_AUTOSELECT=
CONFIG_B43LEGACY_PCI_AUTOSELECT=
CONFIG_B43LEGACY_PCICORE_AUTOSELECT=
CONFIG_MEDIA_SUBDRV_AUTOSELECT=
CONFIG_INTEL_SPEED_SELECT_INTERFACE=

If interest are the keys for grep LEGACY or _LEGACY
which, semantically, I would hope to be able to turnoff/disable on
hardware more current than perhaps 3-5 years ago or a KVM or
VirtualBox VM. Your thoughts and input are appreciated.

Thank you,

On Wed, Feb 22, 2023 at 7:29 PM Randy Dunlap <[email protected]> wrote:
>
> Hi,
>
> On 2/22/23 16:21, Hanasaki Jiji wrote:
> > Hello,
> >
> > Thank you so much for helping out.
> >
> > Might the below accomplish the task?
> >
> > cat f | grep -v DEBUG| grep -v TRACE | grep -v TRACING > newConfigFileWithout
>
> It will disable CONFIG_DEBUG_FS. That's OK if that's what you want to do.
>
> But this will just give you something to begin with. It will need more work.
> There are lots of config options that use "select" to force another config
> option to be set/enabled. Even if you disable an option and you have one of
> these other options set/enabled, they will just enable the DEBUG/TRACE options
> again for you.
>
> When you find one of these, they pretty much have to be checked and tuned
> one-by-one. It can take a lot of time to do that.
>
>
> --
> ~Randy
> https://people.kernel.org/tglx/notes-about-netiquette