The Kconfig is refactored to consolidate KEXEC and CRASH options from
various arch/<arch>/Kconfig files into new file kernel/Kconfig.kexec.
The Kconfig.kexec is now a submenu titled "Kexec and crash features"
located under "General Setup".
The following options are impacted:
- KEXEC
- KEXEC_FILE
- KEXEC_SIG
- KEXEC_SIG_FORCE
- KEXEC_BZIMAGE_VERIFY_SIG
- KEXEC_JUMP
- CRASH_DUMP
Over time, these options have been copied between Kconfig files and
are very similar to one another, but with slight differences.
The following architectures are impacted by the refactor (because of
use of one or more KEXEC/CRASH options):
- arm
- arm64
- ia64
- loongarch
- m68k
- mips
- parisc
- powerpc
- riscv
- s390
- sh
- x86
More information:
In the patch series "crash: Kernel handling of CPU and memory hot
un/plug"
https://lore.kernel.org/lkml/[email protected]/
the new kernel feature introduces the config option CRASH_HOTPLUG.
In reviewing, Thomas Gleixner requested that the new config option
not be placed in x86 Kconfig. Rather the option needs a generic/common
home. To Thomas' point, the KEXEC and CRASH options have largely been
duplicated in the various arch/<arch>/Kconfig files, with minor
differences. This kind of proliferation is to be avoid/stopped.
https://lore.kernel.org/lkml/875y91yv63.ffs@tglx/
To that end, I have refactored the arch Kconfigs so as to consolidate
the various KEXEC and CRASH options. Generally speaking, this work has
the following themes:
- KEXEC and CRASH options are moved into new file kernel/Kconfig.kexec
- These items from arch/Kconfig:
CRASH_CORE KEXEC_CORE KEXEC_ELF HAVE_IMA_KEXEC
- These items from arch/x86/Kconfig form the common options:
KEXEC KEXEC_FILE KEXEC_SIG KEXEC_SIG_FORCE
KEXEC_BZIMAGE_VERIFY_SIG KEXEC_JUMP CRASH_DUMP
- The crash hotplug series appends CRASH_HOTPLUG to Kconfig.kexec
- The Kconfig.kexec is now a submenu titled "Kexec and crash features"
and is now listed in "General Setup" submenu from init/Kconfig.
- To control the main common options, new options ARCH_SUPPORTS_KEXEC,
ARCH_SUPPORTS_KEXEC_FILE and ARCH_SUPPORTS_CRASH_DUMP are introduced.
NOTE: The existing ARCH_HAS_KEXEC_PURGATORY remains unchanged.
- To account for the slight differences, new options ARCH_SELECTS_KEXEC,
ARCH_SELECTS_KEXEC_FILE and ARCH_SELECTS_CRASH_DUMP are used to
elicit the same side effects as the original arch/<arch>/Kconfig
files for KEXEC and CRASH options.
An example, 'make menuconfig' illustrating the submenu:
> General setup > Kexec and crash features
[*] Enable kexec system call
[*] Enable kexec file based system call
[*] Verify kernel signature during kexec_file_load() syscall
[ ] Require a valid signature in kexec_file_load() syscall
[ ] Enable bzImage signature verification support
[*] kexec jump
[*] kernel crash dumps
[*] Update the crash elfcorehdr on system configuration changes
The three main options are KEXEC, KEXEC_FILE and CRASH_DUMP. In the
process of consolidating these options, I encountered slight differences
in the coding of these options in several of the architectures. As a
result, I settled on the following solution:
- Each of three main options has a 'depends on ARCH_SUPPORTS_<option>'
statement: ARCH_SUPPORTS_KEXEC, ARCH_SUPPORTS_KEXEC_FILE,
ARCH_SUPPORTS_CRASH_DUMP.
For example, the KEXEC_FILE option has a 'depends on
ARCH_SUPPORTS_KEXEC_FILE' statement.
- The boolean ARCH_SUPPORTS_<option> in effect allows the arch to
determine when the feature is allowed. Archs which don't have the
feature simply do not provide the corresponding ARCH_SUPPORTS_<option>.
For each arch, where there previously were KEXEC and/or CRASH
options, these have been replaced with the corresponding boolean
ARCH_SUPPORTS_<option>, and an appropriate def_bool statement.
For example, if the arch supports KEXEC_FILE, then the
ARCH_SUPPORTS_KEXEC_FILE simply has a 'def_bool y'. This permits the
KEXEC_FILE option to be available.
If the arch has a 'depends on' statement in its original coding
of the option, then that expression becomes part of the def_bool
expression. For example, arm64 had:
config KEXEC
depends on PM_SLEEP_SMP
and in this solution, this converts to:
config ARCH_SUPPORTS_KEXEC
def_bool PM_SLEEP_SMP
- In order to account for the differences in the config coding for
the three common options, the ARCH_SELECTS_<option> is used.
This options has a 'depends on <option>' statement to couple it
to the main option, and from there can insert the differences
from the common option and the arch original coding of that option.
For example, a few archs enable CRYPTO and CRYTPO_SHA256 for
KEXEC_FILE. These require a ARCH_SELECTS_KEXEC_FILE and
'select CRYPTO' and 'select CRYPTO_SHA256' statements.
Illustrating the option relationships:
For KEXEC:
ARCH_SUPPORTS_KEXEC <- KEXEC <- ARCH_SELECTS_KEXEC
KEXEC # in Kconfig.kexec
ARCH_SUPPORTS_KEXEC # in arch/<arch>/Kconfig, as needed
ARCH_SELECTS_KEXEC # in arch/<arch>/Kconfig, as needed
For KEXEC_FILE:
ARCH_SUPPORTS_KEXEC_FILE <- KEXEC_FILE <- ARCH_SELECTS_KEXEC_FILE
KEXEC_FILE # in Kconfig.kexec
ARCH_SUPPORTS_KEXEC_FILE # in arch/<arch>/Kconfig, as needed
ARCH_SELECTS_KEXEC_FILE # in arch/<arch>/Kconfig, as needed
For CRASH:
ARCH_SUPPORTS_CRASH_DUMP <- CRASH_DUMP <- ARCH_SELECTS_CRASH_DUMP
CRASH_DUMP # in Kconfig.kexec
ARCH_SUPPORTS_CRASH_DUMP # in arch/<arch>/Kconfig, as needed
ARCH_SELECTS_CRASH_DUMP # in arch/<arch>/Kconfig, as needed
To summarize, the ARCH_SUPPORTS_<option> permits the <option> to be
enabled, and the ARCH_SELECTS_<option> handles side effects (ie.
select statements).
Examples:
A few examples to show the new strategy in action:
===== x86 (minus the help section) =====
Original:
config KEXEC
bool "kexec system call"
select KEXEC_CORE
config KEXEC_FILE
bool "kexec file based system call"
select KEXEC_CORE
select HAVE_IMA_KEXEC if IMA
depends on X86_64
depends on CRYPTO=y
depends on CRYPTO_SHA256=y
config ARCH_HAS_KEXEC_PURGATORY
def_bool KEXEC_FILE
config KEXEC_SIG
bool "Verify kernel signature during kexec_file_load() syscall"
depends on KEXEC_FILE
config KEXEC_SIG_FORCE
bool "Require a valid signature in kexec_file_load() syscall"
depends on KEXEC_SIG
config KEXEC_BZIMAGE_VERIFY_SIG
bool "Enable bzImage signature verification support"
depends on KEXEC_SIG
depends on SIGNED_PE_FILE_VERIFICATION
select SYSTEM_TRUSTED_KEYRING
config CRASH_DUMP
bool "kernel crash dumps"
depends on X86_64 || (X86_32 && HIGHMEM)
config KEXEC_JUMP
bool "kexec jump"
depends on KEXEC && HIBERNATION
help
becomes...
New:
config ARCH_SUPPORTS_KEXEC
def_bool y
config ARCH_SUPPORTS_KEXEC_FILE
def_bool X86_64 && CRYPTO && CRYPTO_SHA256
config ARCH_SELECTS_KEXEC_FILE
def_bool y
depends on KEXEC_FILE
select HAVE_IMA_KEXEC if IMA
config ARCH_HAS_KEXEC_PURGATORY
def_bool KEXEC_FILE
config ARCH_SUPPORTS_KEXEC_JUMP
def_bool y
config ARCH_SUPPORTS_CRASH_DUMP
def_bool X86_64 || (X86_32 && HIGHMEM)
===== powerpc (minus the help section) =====
Original:
config KEXEC
bool "kexec system call"
depends on PPC_BOOK3S || PPC_E500 || (44x && !SMP)
select KEXEC_CORE
config KEXEC_FILE
bool "kexec file based system call"
select KEXEC_CORE
select HAVE_IMA_KEXEC if IMA
select KEXEC_ELF
depends on PPC64
depends on CRYPTO=y
depends on CRYPTO_SHA256=y
config ARCH_HAS_KEXEC_PURGATORY
def_bool KEXEC_FILE
config CRASH_DUMP
bool "Build a dump capture kernel"
depends on PPC64 || PPC_BOOK3S_32 || PPC_85xx || (44x && !SMP)
select RELOCATABLE if PPC64 || 44x || PPC_85xx
becomes...
New:
config ARCH_SUPPORTS_KEXEC
def_bool PPC_BOOK3S || PPC_E500 || (44x && !SMP)
config ARCH_SUPPORTS_KEXEC_FILE
def_bool PPC64 && CRYPTO=y && CRYPTO_SHA256=y
config ARCH_HAS_KEXEC_PURGATORY
def_bool KEXEC_FILE
config ARCH_SELECTS_KEXEC_FILE
def_bool y
depends on KEXEC_FILE
select KEXEC_ELF
select HAVE_IMA_KEXEC if IMA
config ARCH_SUPPORTS_CRASH_DUMP
def_bool PPC64 || PPC_BOOK3S_32 || PPC_85xx || (44x && !SMP)
config ARCH_SELECTS_CRASH_DUMP
def_bool y
depends on CRASH_DUMP
select RELOCATABLE if PPC64 || 44x || PPC_85xx
Testing Approach and Results
There are 388 config files in the arch/<arch>/configs directories.
For each of these config files, a .config is generated both before and
after this Kconfig series, and checked for equivalence. This approach
allows for a rather rapid check of all architectures and a wide
variety of configs wrt/ KEXEC and CRASH, and avoids requiring
compiling for all architectures and running kernels and run-time
testing.
As such, the following script steps compare the before and after
of 'make olddefconfig'. The new symbols introduced by this series
are filtered out, but otherwise the config files are PASS only if
they were equivalent, and FAIL otherwise.
The script performs the test by doing the following:
# Obtain the "golden" .config output for given config file
# Reset test sandbox
git checkout master
git branch -D test_Kconfig
git checkout -B test_Kconfig master
make distclean
# Write out updated config
cp -f <config file> .config
make ARCH=<arch> olddefconfig
# Track each item in .config, LHSB is "golden"
scoreboard .config
# Obtain the "changed" .config output for given config file
# Reset test sandbox
make distclean
# Apply this Kconfig series
git am <this Kconfig series>
# Write out updated config
cp -f <config file> .config
make ARCH=<arch> olddefconfig
# Track each item in .config, RHSB is "changed"
scoreboard .config
# Determine test result
# Filter-out new symbols introduced by this series
# Filter-out symbol=n which not in either scoreboard
# Compare LHSB "golden" and RHSB "changed" scoreboards and issue PASS/FAIL
The script was instrumental during the refactoring of Kconfig as it
continually revealed problems. The end result being that the solution
presented in this series passes all configs as checked by the script.
Regards,
eric
---
v4: 5jul2023
- Corrected conversion issue with riscv, per Conor Dooley.
- Andrew Mortons's akpm test machinery found a problem with config
files generated by randconfig. The problem existed prior to this
series and manifests because most arch/<arch>/Kconfig CRASH_DUMP
does not have any dependencies on KEXEC. As a result, randconfig
produces a config file enabling CRASH_DUMP but not KEXEC, which
leads to compile/link-time problems. Andrew requested closing
this hole. To that end 'select KEXEC' has been added to CRASH_DUMP.
This behavior pre-existed for arm arm64 ia64 loongarch mips powerpc
riscv sh and x86.
- Applied Acked-by's from:
s390: Alexander Gordeev <[email protected]>
v3: 26jun2023
https://lore.kernel.org/lkml/[email protected]/
- Rebased onto 6.4.0
- Reworded s390 commit message to clarify MODULE_SIG_FORMAT,
per Alexander Gordeev
- Applied Acked-by's from:
m68k: Geert Uytterhoeven <[email protected]>
mips: Thomas Bogendoerfer <[email protected]>
sh: John Paul Adrian Glaubitz <[email protected]>
v2: 19jun2023
https://lore.kernel.org/lkml/[email protected]/
- The ARCH_HAS_ and ARCH_SUPPORTS_ combination was found to be
too similar/confusing. Renamed these two new options as such:
ARCH_HAS_<option> ---> ARCH_SUPPORTS_<option>
ARCH_SUPPORTS_<option> ---> ARCH_SELECTS_<option>
Per Kees Cook, Michael Ellerman
NOTE: ARCH_HAS_KEXEC_PURGATORY was left as-is, as that is what
it is prior to this series.
Updated this cover letter to reflect the same.
- Some minor cleaning up of the help sections, per Zhen Lei and
Alexander Gordeev.
- Removed the MODULE_SIG_FORMAT dependency from KEXEC_SIG in
kernel/Kconfig.kexec. Only s390 had it prior to this series.
See also commit message in
"s390/kexec: refactor for kernel/Kconfig.kexec"
- Added to Kconfig.kexec the KEXEC_IMAGE_VERIFY_SIG from arm64,
per Zhen Lei.
- Fixed the powerpc ARCH_SUPPORTS_KEXEC_FILE conversion, per
Michael Ellerman.
v1: 12jun2023
https://lore.kernel.org/lkml/[email protected]/
- Initial
- Based on 6.4.0-rc6
---
Eric DeVolder (13):
kexec: consolidate kexec and crash options into kernel/Kconfig.kexec
x86/kexec: refactor for kernel/Kconfig.kexec
arm/kexec: refactor for kernel/Kconfig.kexec
ia64/kexec: refactor for kernel/Kconfig.kexec
arm64/kexec: refactor for kernel/Kconfig.kexec
loongarch/kexec: refactor for kernel/Kconfig.kexec
m68k/kexec: refactor for kernel/Kconfig.kexec
mips/kexec: refactor for kernel/Kconfig.kexec
parisc/kexec: refactor for kernel/Kconfig.kexec
powerpc/kexec: refactor for kernel/Kconfig.kexec
riscv/kexec: refactor for kernel/Kconfig.kexec
s390/kexec: refactor for kernel/Kconfig.kexec
sh/kexec: refactor for kernel/Kconfig.kexec
arch/Kconfig | 13 -----
arch/arm/Kconfig | 29 ++---------
arch/arm64/Kconfig | 62 +++++------------------
arch/ia64/Kconfig | 28 ++---------
arch/loongarch/Kconfig | 26 +++-------
arch/m68k/Kconfig | 19 +------
arch/mips/Kconfig | 32 ++----------
arch/parisc/Kconfig | 34 +++++--------
arch/powerpc/Kconfig | 55 +++++++--------------
arch/riscv/Kconfig | 44 +++++------------
arch/s390/Kconfig | 65 +++++++-----------------
arch/sh/Kconfig | 46 +++--------------
arch/x86/Kconfig | 89 +++++----------------------------
init/Kconfig | 2 +
kernel/Kconfig.kexec | 110 +++++++++++++++++++++++++++++++++++++++++
15 files changed, 228 insertions(+), 426 deletions(-)
create mode 100644 kernel/Kconfig.kexec
--
2.31.1
The kexec and crash kernel options are provided in the common
kernel/Kconfig.kexec. Utilize the common options and provide
the ARCH_SUPPORTS_ and ARCH_SELECTS_ entries to recreate the
equivalent set of KEXEC and CRASH options.
Signed-off-by: Eric DeVolder <[email protected]>
---
arch/loongarch/Kconfig | 26 +++++++-------------------
1 file changed, 7 insertions(+), 19 deletions(-)
diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index e55511af4c77..397203e18800 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -537,28 +537,16 @@ config CPU_HAS_PREFETCH
bool
default y
-config KEXEC
- bool "Kexec system call"
- select KEXEC_CORE
- help
- kexec is a system call that implements the ability to shutdown your
- current kernel, and to start another kernel. It is like a reboot
- but it is independent of the system firmware. And like a reboot
- you can start any kernel with it, not just Linux.
+config ARCH_SUPPORTS_KEXEC
+ def_bool y
- The name comes from the similarity to the exec system call.
+config ARCH_SUPPORTS_CRASH_DUMP
+ def_bool y
-config CRASH_DUMP
- bool "Build kdump crash kernel"
+config ARCH_SELECTS_CRASH_DUMP
+ def_bool y
+ depends on CRASH_DUMP
select RELOCATABLE
- help
- Generate crash dump after being started by kexec. This should
- be normally only set in special crash dump kernels which are
- loaded in the main kernel with kexec-tools into a specially
- reserved region and then later executed after a crash by
- kdump/kexec.
-
- For more details see Documentation/admin-guide/kdump/kdump.rst
config RELOCATABLE
bool "Relocatable kernel"
--
2.31.1
The kexec and crash kernel options are provided in the common
kernel/Kconfig.kexec. Utilize the common options and provide
the ARCH_SUPPORTS_ and ARCH_SELECTS_ entries to recreate the
equivalent set of KEXEC and CRASH options.
Signed-off-by: Eric DeVolder <[email protected]>
---
arch/arm/Kconfig | 29 ++++-------------------------
1 file changed, 4 insertions(+), 25 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 7a27550ff3c1..1a6a6eb48a15 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1645,20 +1645,8 @@ config XIP_DEFLATED_DATA
copied, saving some precious ROM space. A possible drawback is a
slightly longer boot delay.
-config KEXEC
- bool "Kexec system call (EXPERIMENTAL)"
- depends on (!SMP || PM_SLEEP_SMP)
- depends on MMU
- select KEXEC_CORE
- help
- kexec is a system call that implements the ability to shutdown your
- current kernel, and to start another kernel. It is like a reboot
- but it is independent of the system firmware. And like a reboot
- you can start any kernel with it, not just Linux.
-
- It is an ongoing process to be certain the hardware in a machine
- is properly shutdown, so do not be surprised if this code does not
- initially work for you.
+config ARCH_SUPPORTS_KEXEC
+ def_bool (!SMP || PM_SLEEP_SMP) && MMU
config ATAGS_PROC
bool "Export atags in procfs"
@@ -1668,17 +1656,8 @@ config ATAGS_PROC
Should the atags used to boot the kernel be exported in an "atags"
file in procfs. Useful with kexec.
-config CRASH_DUMP
- bool "Build kdump crash kernel (EXPERIMENTAL)"
- help
- Generate crash dump after being started by kexec. This should
- be normally only set in special crash dump kernels which are
- loaded in the main kernel with kexec-tools into a specially
- reserved region and then later executed after a crash by
- kdump/kexec. The crash dump kernel must be compiled to a
- memory address not used by the main kernel
-
- For more details see Documentation/admin-guide/kdump/kdump.rst
+config ARCH_SUPPORTS_CRASH_DUMP
+ def_bool y
config AUTO_ZRELADDR
bool "Auto calculation of the decompressed kernel image address" if !ARCH_MULTIPLATFORM
--
2.31.1
The kexec and crash kernel options are provided in the common
kernel/Kconfig.kexec. Utilize the common options and provide
the ARCH_SUPPORTS_ and ARCH_SELECTS_ entries to recreate the
equivalent set of KEXEC and CRASH options.
Signed-off-by: Eric DeVolder <[email protected]>
Acked-by: Thomas Bogendoerfer <[email protected]>
---
arch/mips/Kconfig | 32 +++++---------------------------
1 file changed, 5 insertions(+), 27 deletions(-)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index fc6fba925aea..bc8421859006 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2878,33 +2878,11 @@ config HZ
config SCHED_HRTICK
def_bool HIGH_RES_TIMERS
-config KEXEC
- bool "Kexec system call"
- select KEXEC_CORE
- help
- kexec is a system call that implements the ability to shutdown your
- current kernel, and to start another kernel. It is like a reboot
- but it is independent of the system firmware. And like a reboot
- you can start any kernel with it, not just Linux.
-
- The name comes from the similarity to the exec system call.
-
- It is an ongoing process to be certain the hardware in a machine
- is properly shutdown, so do not be surprised if this code does not
- initially work for you. As of this writing the exact hardware
- interface is strongly in flux, so no good recommendation can be
- made.
-
-config CRASH_DUMP
- bool "Kernel crash dumps"
- help
- Generate crash dump after being started by kexec.
- This should be normally only set in special crash dump kernels
- which are loaded in the main kernel with kexec-tools into
- a specially reserved region and then later executed after
- a crash by kdump/kexec. The crash dump kernel must be compiled
- to a memory address not used by the main kernel or firmware using
- PHYSICAL_START.
+config ARCH_SUPPORTS_KEXEC
+ def_bool y
+
+config ARCH_SUPPORTS_CRASH_DUMP
+ def_bool y
config PHYSICAL_START
hex "Physical address where the kernel is loaded"
--
2.31.1
The kexec and crash kernel options are provided in the common
kernel/Kconfig.kexec. Utilize the common options and provide
the ARCH_SUPPORTS_ and ARCH_SELECTS_ entries to recreate the
equivalent set of KEXEC and CRASH options.
Signed-off-by: Eric DeVolder <[email protected]>
---
arch/parisc/Kconfig | 34 +++++++++++-----------------------
1 file changed, 11 insertions(+), 23 deletions(-)
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 4cb46d5c64a2..2ef6843aae60 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -339,29 +339,17 @@ config NR_CPUS
default "8" if 64BIT
default "16"
-config KEXEC
- bool "Kexec system call"
- select KEXEC_CORE
- help
- kexec is a system call that implements the ability to shutdown your
- current kernel, and to start another kernel. It is like a reboot
- but it is independent of the system firmware. And like a reboot
- you can start any kernel with it, not just Linux.
-
- It is an ongoing process to be certain the hardware in a machine
- shutdown, so do not be surprised if this code does not
- initially work for you.
-
-config KEXEC_FILE
- bool "kexec file based system call"
- select KEXEC_CORE
- select KEXEC_ELF
- help
- This enables the kexec_file_load() System call. This is
- file based and takes file descriptors as system call argument
- for kernel and initramfs as opposed to list of segments as
- accepted by previous system call.
-
endmenu
+config ARCH_SUPPORTS_KEXEC
+ def_bool y
+
+config ARCH_SUPPORTS_KEXEC_FILE
+ def_bool y
+
+config ARCH_SELECTS_KEXEC_FILE
+ def_bool y
+ depends on KEXEC_FILE
+ select KEXEC_ELF
+
source "drivers/parisc/Kconfig"
--
2.31.1
The kexec and crash kernel options are provided in the common
kernel/Kconfig.kexec. Utilize the common options and provide
the ARCH_SUPPORTS_ and ARCH_SELECTS_ entries to recreate the
equivalent set of KEXEC and CRASH options.
Signed-off-by: Eric DeVolder <[email protected]>
Reviewed-by: Sourabh Jain <[email protected]>
---
arch/powerpc/Kconfig | 55 ++++++++++++++------------------------------
1 file changed, 17 insertions(+), 38 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 0b1172cbeccb..1695a71777f0 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -589,41 +589,21 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
default "y" if PPC_POWERNV
select ARCH_SUPPORTS_MEMORY_FAILURE
-config KEXEC
- bool "kexec system call"
- depends on PPC_BOOK3S || PPC_E500 || (44x && !SMP)
- select KEXEC_CORE
- help
- kexec is a system call that implements the ability to shutdown your
- current kernel, and to start another kernel. It is like a reboot
- but it is independent of the system firmware. And like a reboot
- you can start any kernel with it, not just Linux.
-
- The name comes from the similarity to the exec system call.
-
- It is an ongoing process to be certain the hardware in a machine
- is properly shutdown, so do not be surprised if this code does not
- initially work for you. As of this writing the exact hardware
- interface is strongly in flux, so no good recommendation can be
- made.
-
-config KEXEC_FILE
- bool "kexec file based system call"
- select KEXEC_CORE
- select HAVE_IMA_KEXEC if IMA
- select KEXEC_ELF
- depends on PPC64
- depends on CRYPTO=y
- depends on CRYPTO_SHA256=y
- help
- This is a new version of the kexec system call. This call is
- file based and takes in file descriptors as system call arguments
- for kernel and initramfs as opposed to a list of segments as is the
- case for the older kexec call.
+config ARCH_SUPPORTS_KEXEC
+ def_bool PPC_BOOK3S || PPC_E500 || (44x && !SMP)
+
+config ARCH_SUPPORTS_KEXEC_FILE
+ def_bool PPC64 && CRYPTO=y && CRYPTO_SHA256=y
config ARCH_HAS_KEXEC_PURGATORY
def_bool KEXEC_FILE
+config ARCH_SELECTS_KEXEC_FILE
+ def_bool y
+ depends on KEXEC_FILE
+ select KEXEC_ELF
+ select HAVE_IMA_KEXEC if IMA
+
config PPC64_BIG_ENDIAN_ELF_ABI_V2
# Option is available to BFD, but LLD does not support ELFv1 so this is
# always true there.
@@ -683,14 +663,13 @@ config RELOCATABLE_TEST
loaded at, which tends to be non-zero and therefore test the
relocation code.
-config CRASH_DUMP
- bool "Build a dump capture kernel"
- depends on PPC64 || PPC_BOOK3S_32 || PPC_85xx || (44x && !SMP)
+config ARCH_SUPPORTS_CRASH_DUMP
+ def_bool PPC64 || PPC_BOOK3S_32 || PPC_85xx || (44x && !SMP)
+
+config ARCH_SELECTS_CRASH_DUMP
+ def_bool y
+ depends on CRASH_DUMP
select RELOCATABLE if PPC64 || 44x || PPC_85xx
- help
- Build a kernel suitable for use as a dump capture kernel.
- The same kernel binary can be used as production kernel and dump
- capture kernel.
config FA_DUMP
bool "Firmware-assisted dump"
--
2.31.1
The config options for kexec and crash features are consolidated
into new file kernel/Kconfig.kexec. Under the "General Setup" submenu
is a new submenu "Kexec and crash handling". All the kexec and
crash options that were once in the arch-dependent submenu "Processor
type and features" are now consolidated in the new submenu.
The following options are impacted:
- KEXEC
- KEXEC_FILE
- KEXEC_SIG
- KEXEC_SIG_FORCE
- KEXEC_BZIMAGE_VERIFY_SIG
- KEXEC_JUMP
- CRASH_DUMP
The three main options are KEXEC, KEXEC_FILE and CRASH_DUMP.
Architectures specify support of certain KEXEC and CRASH features with
similarly named new ARCH_SUPPORTS_<option> config options.
Architectures can utilize the new ARCH_SELECTS_<option> config
options to specify additional components when <option> is enabled.
To summarize, the ARCH_SUPPORTS_<option> permits the <option> to be
enabled, and the ARCH_SELECTS_<option> handles side effects (ie.
select statements).
Signed-off-by: Eric DeVolder <[email protected]>
---
arch/Kconfig | 13 -----
init/Kconfig | 2 +
kernel/Kconfig.kexec | 110 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 112 insertions(+), 13 deletions(-)
create mode 100644 kernel/Kconfig.kexec
diff --git a/arch/Kconfig b/arch/Kconfig
index aff2746c8af2..b2872e9d3760 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -11,19 +11,6 @@ source "arch/$(SRCARCH)/Kconfig"
menu "General architecture-dependent options"
-config CRASH_CORE
- bool
-
-config KEXEC_CORE
- select CRASH_CORE
- bool
-
-config KEXEC_ELF
- bool
-
-config HAVE_IMA_KEXEC
- bool
-
config ARCH_HAS_SUBPAGE_FAULTS
bool
help
diff --git a/init/Kconfig b/init/Kconfig
index f7f65af4ee12..639e8a3363c3 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1927,6 +1927,8 @@ config BINDGEN_VERSION_TEXT
config TRACEPOINTS
bool
+source "kernel/Kconfig.kexec"
+
endmenu # General setup
source "arch/Kconfig"
diff --git a/kernel/Kconfig.kexec b/kernel/Kconfig.kexec
new file mode 100644
index 000000000000..d82a7ce59c05
--- /dev/null
+++ b/kernel/Kconfig.kexec
@@ -0,0 +1,110 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+menu "Kexec and crash features"
+
+config CRASH_CORE
+ bool
+
+config KEXEC_CORE
+ select CRASH_CORE
+ bool
+
+config KEXEC_ELF
+ bool
+
+config HAVE_IMA_KEXEC
+ bool
+
+config KEXEC
+ bool "Enable kexec system call"
+ default ARCH_DEFAULT_KEXEC
+ depends on ARCH_SUPPORTS_KEXEC
+ select KEXEC_CORE
+ help
+ kexec is a system call that implements the ability to shutdown your
+ current kernel, and to start another kernel. It is like a reboot
+ but it is independent of the system firmware. And like a reboot
+ you can start any kernel with it, not just Linux.
+
+ The name comes from the similarity to the exec system call.
+
+ It is an ongoing process to be certain the hardware in a machine
+ is properly shutdown, so do not be surprised if this code does not
+ initially work for you. As of this writing the exact hardware
+ interface is strongly in flux, so no good recommendation can be
+ made.
+
+config KEXEC_FILE
+ bool "Enable kexec file based system call"
+ depends on ARCH_SUPPORTS_KEXEC_FILE
+ select KEXEC_CORE
+ help
+ This is new version of kexec system call. This system call is
+ file based and takes file descriptors as system call argument
+ for kernel and initramfs as opposed to list of segments as
+ accepted by kexec system call.
+
+config KEXEC_SIG
+ bool "Verify kernel signature during kexec_file_load() syscall"
+ depends on KEXEC_FILE
+ help
+ This option makes the kexec_file_load() syscall check for a valid
+ signature of the kernel image. The image can still be loaded without
+ a valid signature unless you also enable KEXEC_SIG_FORCE, though if
+ there's a signature that we can check, then it must be valid.
+
+ In addition to this option, you need to enable signature
+ verification for the corresponding kernel image type being
+ loaded in order for this to work.
+
+config KEXEC_SIG_FORCE
+ bool "Require a valid signature in kexec_file_load() syscall"
+ depends on KEXEC_SIG
+ help
+ This option makes kernel signature verification mandatory for
+ the kexec_file_load() syscall.
+
+config KEXEC_IMAGE_VERIFY_SIG
+ bool "Enable Image signature verification support (ARM)"
+ default ARCH_DEFAULT_KEXEC_IMAGE_VERIFY_SIG
+ depends on KEXEC_SIG
+ depends on EFI && SIGNED_PE_FILE_VERIFICATION
+ help
+ Enable Image signature verification support.
+
+config KEXEC_BZIMAGE_VERIFY_SIG
+ bool "Enable bzImage signature verification support"
+ depends on KEXEC_SIG
+ depends on SIGNED_PE_FILE_VERIFICATION
+ select SYSTEM_TRUSTED_KEYRING
+ help
+ Enable bzImage signature verification support.
+
+config KEXEC_JUMP
+ bool "kexec jump"
+ depends on KEXEC && HIBERNATION
+ depends on ARCH_SUPPORTS_KEXEC_JUMP
+ help
+ Jump between original kernel and kexeced kernel and invoke
+ code in physical address mode via KEXEC
+
+config CRASH_DUMP
+ bool "kernel crash dumps"
+ depends on ARCH_SUPPORTS_CRASH_DUMP
+ select CRASH_CORE
+ select KEXEC
+ help
+ Generate crash dump after being started by kexec.
+ This should be normally only set in special crash dump kernels
+ which are loaded in the main kernel with kexec-tools into
+ a specially reserved region and then later executed after
+ a crash by kdump/kexec. The crash dump kernel must be compiled
+ to a memory address not used by the main kernel or BIOS using
+ PHYSICAL_START, or it must be built as a relocatable image
+ (CONFIG_RELOCATABLE=y).
+ For more details see Documentation/admin-guide/kdump/kdump.rst
+
+ For s390, this option also enables zfcpdump.
+ See also <file:Documentation/s390/zfcpdump.rst>
+
+endmenu
--
2.31.1
The kexec and crash kernel options are provided in the common
kernel/Kconfig.kexec. Utilize the common options and provide
the ARCH_SUPPORTS_ and ARCH_SELECTS_ entries to recreate the
equivalent set of KEXEC and CRASH options.
Signed-off-by: Eric DeVolder <[email protected]>
---
arch/x86/Kconfig | 89 +++++++-----------------------------------------
1 file changed, 13 insertions(+), 76 deletions(-)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 7422db409770..6d2212c38046 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2040,88 +2040,25 @@ config EFI_RUNTIME_MAP
source "kernel/Kconfig.hz"
-config KEXEC
- bool "kexec system call"
- select KEXEC_CORE
- help
- kexec is a system call that implements the ability to shutdown your
- current kernel, and to start another kernel. It is like a reboot
- but it is independent of the system firmware. And like a reboot
- you can start any kernel with it, not just Linux.
-
- The name comes from the similarity to the exec system call.
-
- It is an ongoing process to be certain the hardware in a machine
- is properly shutdown, so do not be surprised if this code does not
- initially work for you. As of this writing the exact hardware
- interface is strongly in flux, so no good recommendation can be
- made.
-
-config KEXEC_FILE
- bool "kexec file based system call"
- select KEXEC_CORE
- select HAVE_IMA_KEXEC if IMA
- depends on X86_64
- depends on CRYPTO=y
- depends on CRYPTO_SHA256=y
- help
- This is new version of kexec system call. This system call is
- file based and takes file descriptors as system call argument
- for kernel and initramfs as opposed to list of segments as
- accepted by previous system call.
+config ARCH_SUPPORTS_KEXEC
+ def_bool y
-config ARCH_HAS_KEXEC_PURGATORY
- def_bool KEXEC_FILE
+config ARCH_SUPPORTS_KEXEC_FILE
+ def_bool X86_64 && CRYPTO && CRYPTO_SHA256
-config KEXEC_SIG
- bool "Verify kernel signature during kexec_file_load() syscall"
+config ARCH_SELECTS_KEXEC_FILE
+ def_bool y
depends on KEXEC_FILE
- help
-
- This option makes the kexec_file_load() syscall check for a valid
- signature of the kernel image. The image can still be loaded without
- a valid signature unless you also enable KEXEC_SIG_FORCE, though if
- there's a signature that we can check, then it must be valid.
-
- In addition to this option, you need to enable signature
- verification for the corresponding kernel image type being
- loaded in order for this to work.
-
-config KEXEC_SIG_FORCE
- bool "Require a valid signature in kexec_file_load() syscall"
- depends on KEXEC_SIG
- help
- This option makes kernel signature verification mandatory for
- the kexec_file_load() syscall.
+ select HAVE_IMA_KEXEC if IMA
-config KEXEC_BZIMAGE_VERIFY_SIG
- bool "Enable bzImage signature verification support"
- depends on KEXEC_SIG
- depends on SIGNED_PE_FILE_VERIFICATION
- select SYSTEM_TRUSTED_KEYRING
- help
- Enable bzImage signature verification support.
+config ARCH_HAS_KEXEC_PURGATORY
+ def_bool KEXEC_FILE
-config CRASH_DUMP
- bool "kernel crash dumps"
- depends on X86_64 || (X86_32 && HIGHMEM)
- help
- Generate crash dump after being started by kexec.
- This should be normally only set in special crash dump kernels
- which are loaded in the main kernel with kexec-tools into
- a specially reserved region and then later executed after
- a crash by kdump/kexec. The crash dump kernel must be compiled
- to a memory address not used by the main kernel or BIOS using
- PHYSICAL_START, or it must be built as a relocatable image
- (CONFIG_RELOCATABLE=y).
- For more details see Documentation/admin-guide/kdump/kdump.rst
+config ARCH_SUPPORTS_KEXEC_JUMP
+ def_bool y
-config KEXEC_JUMP
- bool "kexec jump"
- depends on KEXEC && HIBERNATION
- help
- Jump between original kernel and kexeced kernel and invoke
- code in physical address mode via KEXEC
+config ARCH_SUPPORTS_CRASH_DUMP
+ def_bool X86_64 || (X86_32 && HIGHMEM)
config PHYSICAL_START
hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP)
--
2.31.1
The kexec and crash kernel options are provided in the common
kernel/Kconfig.kexec. Utilize the common options and provide
the ARCH_SUPPORTS_ and ARCH_SELECTS_ entries to recreate the
equivalent set of KEXEC and CRASH options.
Signed-off-by: Eric DeVolder <[email protected]>
Acked-by: John Paul Adrian Glaubitz <[email protected]>
---
arch/sh/Kconfig | 46 ++++++++--------------------------------------
1 file changed, 8 insertions(+), 38 deletions(-)
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 2b3ce4fd3956..1cf6603781c7 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -548,44 +548,14 @@ menu "Kernel features"
source "kernel/Kconfig.hz"
-config KEXEC
- bool "kexec system call (EXPERIMENTAL)"
- depends on MMU
- select KEXEC_CORE
- help
- kexec is a system call that implements the ability to shutdown your
- current kernel, and to start another kernel. It is like a reboot
- but it is independent of the system firmware. And like a reboot
- you can start any kernel with it, not just Linux.
-
- The name comes from the similarity to the exec system call.
-
- It is an ongoing process to be certain the hardware in a machine
- is properly shutdown, so do not be surprised if this code does not
- initially work for you. As of this writing the exact hardware
- interface is strongly in flux, so no good recommendation can be
- made.
-
-config CRASH_DUMP
- bool "kernel crash dumps (EXPERIMENTAL)"
- depends on BROKEN_ON_SMP
- help
- Generate crash dump after being started by kexec.
- This should be normally only set in special crash dump kernels
- which are loaded in the main kernel with kexec-tools into
- a specially reserved region and then later executed after
- a crash by kdump/kexec. The crash dump kernel must be compiled
- to a memory address not used by the main kernel using
- PHYSICAL_START.
-
- For more details see Documentation/admin-guide/kdump/kdump.rst
-
-config KEXEC_JUMP
- bool "kexec jump (EXPERIMENTAL)"
- depends on KEXEC && HIBERNATION
- help
- Jump between original kernel and kexeced kernel and invoke
- code via KEXEC
+config ARCH_SUPPORTS_KEXEC
+ def_bool MMU
+
+config ARCH_SUPPORTS_CRASH_DUMP
+ def_bool BROKEN_ON_SMP
+
+config ARCH_SUPPORTS_KEXEC_JUMP
+ def_bool y
config PHYSICAL_START
hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP)
--
2.31.1
The kexec and crash kernel options are provided in the common
kernel/Kconfig.kexec. Utilize the common options and provide
the ARCH_SUPPORTS_ and ARCH_SELECTS_ entries to recreate the
equivalent set of KEXEC and CRASH options.
Signed-off-by: Eric DeVolder <[email protected]>
---
arch/riscv/Kconfig | 44 +++++++++++++-------------------------------
1 file changed, 13 insertions(+), 31 deletions(-)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index b49793cf34eb..8a3af850597a 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -647,48 +647,30 @@ config RISCV_BOOT_SPINWAIT
If unsure what to do here, say N.
-config KEXEC
- bool "Kexec system call"
- depends on MMU
+config ARCH_SUPPORTS_KEXEC
+ def_bool MMU
+
+config ARCH_SELECTS_KEXEC
+ def_bool y
+ depends on KEXEC
select HOTPLUG_CPU if SMP
- select KEXEC_CORE
- help
- kexec is a system call that implements the ability to shutdown your
- current kernel, and to start another kernel. It is like a reboot
- but it is independent of the system firmware. And like a reboot
- you can start any kernel with it, not just Linux.
- The name comes from the similarity to the exec system call.
+config ARCH_SUPPORTS_KEXEC_FILE
+ def_bool 64BIT && MMU
-config KEXEC_FILE
- bool "kexec file based systmem call"
- depends on 64BIT && MMU
+config ARCH_SELECTS_KEXEC_FILE
+ def_bool y
+ depends on KEXEC_FILE
select HAVE_IMA_KEXEC if IMA
- select KEXEC_CORE
select KEXEC_ELF
- help
- This is new version of kexec system call. This system call is
- file based and takes file descriptors as system call argument
- for kernel and initramfs as opposed to list of segments as
- accepted by previous system call.
-
- If you don't know what to do here, say Y.
config ARCH_HAS_KEXEC_PURGATORY
def_bool KEXEC_FILE
depends on CRYPTO=y
depends on CRYPTO_SHA256=y
-config CRASH_DUMP
- bool "Build kdump crash kernel"
- help
- Generate crash dump after being started by kexec. This should
- be normally only set in special crash dump kernels which are
- loaded in the main kernel with kexec-tools into a specially
- reserved region and then later executed after a crash by
- kdump/kexec.
-
- For more details see Documentation/admin-guide/kdump/kdump.rst
+config ARCH_SUPPORTS_CRASH_DUMP
+ def_bool y
config COMPAT
bool "Kernel support for 32-bit U-mode"
--
2.31.1
The kexec and crash kernel options are provided in the common
kernel/Kconfig.kexec. Utilize the common options and provide
the ARCH_SUPPORTS_ and ARCH_SELECTS_ entries to recreate the
equivalent set of KEXEC and CRASH options.
Signed-off-by: Eric DeVolder <[email protected]>
---
arch/ia64/Kconfig | 28 +++++-----------------------
1 file changed, 5 insertions(+), 23 deletions(-)
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 2cd93e6bf0fe..88382f105301 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -361,31 +361,13 @@ config IA64_HP_AML_NFW
the "force" module parameter, e.g., with the "aml_nfw.force"
kernel command line option.
-config KEXEC
- bool "kexec system call"
- depends on !SMP || HOTPLUG_CPU
- select KEXEC_CORE
- help
- kexec is a system call that implements the ability to shutdown your
- current kernel, and to start another kernel. It is like a reboot
- but it is independent of the system firmware. And like a reboot
- you can start any kernel with it, not just Linux.
-
- The name comes from the similarity to the exec system call.
-
- It is an ongoing process to be certain the hardware in a machine
- is properly shutdown, so do not be surprised if this code does not
- initially work for you. As of this writing the exact hardware
- interface is strongly in flux, so no good recommendation can be
- made.
+endmenu
-config CRASH_DUMP
- bool "kernel crash dumps"
- depends on IA64_MCA_RECOVERY && (!SMP || HOTPLUG_CPU)
- help
- Generate crash dump after being started by kexec.
+config ARCH_SUPPORTS_KEXEC
+ def_bool !SMP || HOTPLUG_CPU
-endmenu
+config ARCH_SUPPORTS_CRASH_DUMP
+ def_bool IA64_MCA_RECOVERY && (!SMP || HOTPLUG_CPU)
menu "Power management and ACPI options"
--
2.31.1
On 7/5/23 10:05, Arnd Bergmann wrote:
> On Wed, Jul 5, 2023, at 16:19, Eric DeVolder wrote:
>> The kexec and crash kernel options are provided in the common
>> kernel/Kconfig.kexec. Utilize the common options and provide
>> the ARCH_SUPPORTS_ and ARCH_SELECTS_ entries to recreate the
>> equivalent set of KEXEC and CRASH options.
>>
>> Signed-off-by: Eric DeVolder <[email protected]>
>
>> +config ARCH_SUPPORTS_KEXEC
>> + def_bool (!SMP || PM_SLEEP_SMP) && MMU
>>
>> config ATAGS_PROC
>> bool "Export atags in procfs"
>> @@ -1668,17 +1656,8 @@ config ATAGS_PROC
>> Should the atags used to boot the kernel be exported in an "atags"
>> file in procfs. Useful with kexec.
>>
>> -config CRASH_DUMP
>> - bool "Build kdump crash kernel (EXPERIMENTAL)"
>> - help
>> - Generate crash dump after being started by kexec. This should
>> - be normally only set in special crash dump kernels which are
>> - loaded in the main kernel with kexec-tools into a specially
>> - reserved region and then later executed after a crash by
>> - kdump/kexec. The crash dump kernel must be compiled to a
>> - memory address not used by the main kernel
>> -
>> - For more details see Documentation/admin-guide/kdump/kdump.rst
>> +config ARCH_SUPPORTS_CRASH_DUMP
>> + def_bool y
>>
>
> I see this is now in linux-next, and it caused a few randconfig
> build issues, these never happened in the past:
Arnd,
Thanks for looking at this!
I received randconfig errors from Andrew Morton's machinery. When investigating I
found that randconfig was able to specify CRASH_DUMP without KEXEC, and that lead
to problems. I believe this situation existed prior to this series as well.
Specifically CRASH_DUMP does not have a dependency on KEXEC, or select (only s390
has this hole closed).
For CRASH_DUMP, this series now selects KEXEC to close this gap, which is what a
sane config would have (ie both CRASH_DUMP and KEXEC).
Do you think the changes outlined below are still needed?
eric
>
> * The #ifdef CONFIG_KEXEC check in arch/arm/include/asm/kexec.h
> needs to be changed to CONFIG_KEXEC_CORE:
>
> include/linux/kexec.h:41:2: error: #error KEXEC_SOURCE_MEMORY_LIMIT not defined
>
> same thing on m68k
>
> * ARCH_SUPPORTS_CRASH_DUMP needs the same dependency as ARCH_SUPPORTS_KEXEC,
> otherwise we seem to run into an obscure assembler error building the kdump
> core on architectures that do not support kdump:
>
> /tmp/ccpYl6w9.s:1546: Error: selected processor does not support requested special purpose register -- `mrs r2,cpsr'
>
> * Most architectures build machine_kexec.o only when KEXEC is enabled,
> this also needs to be changed to KEXEC_CORE:
>
> --- a/arch/arm/kernel/Makefile
> +++ b/arch/arm/kernel/Makefile
> @@ -59,7 +59,7 @@ obj-$(CONFIG_FUNCTION_TRACER) += entry-ftrace.o
> obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o insn.o patch.o
> obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o insn.o patch.o
> obj-$(CONFIG_JUMP_LABEL) += jump_label.o insn.o patch.o
> -obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
> +obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o relocate_kernel.o
> # Main staffs in KPROBES are in arch/arm/probes/ .
> obj-$(CONFIG_KPROBES) += patch.o insn.o
> obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o
>
>
> Arnd
The kexec and crash kernel options are provided in the common
kernel/Kconfig.kexec. Utilize the common options and provide
the ARCH_SUPPORTS_ and ARCH_SELECTS_ entries to recreate the
equivalent set of KEXEC and CRASH options.
NOTE: The original Kconfig has a KEXEC_SIG which depends on
MODULE_SIG_FORMAT. However, attempts to keep the MODULE_SIG_FORMAT
dependency (using the strategy outlined in this series, and other
techniques) results in 'error: recursive dependency detected'
on CRYPTO.
Per Alexander Gordeev <[email protected]>: "the MODULE_SIG_FORMAT
dependency was introduced with [git commit below] and in fact was not
necessary, since s390 did/does not use mod_check_sig() anyway.
commit c8424e776b09 ("MODSIGN: Export module signature definitions")
MODULE_SIG_FORMAT is needed to select SYSTEM_DATA_VERIFICATION. But
SYSTEM_DATA_VERIFICATION is also selected by FS_VERITY*, so dropping
MODULE_SIG_FORMAT does not hurt."
Therefore, the solution is to drop the MODULE_SIG_FORMAT dependency
from KEXEC_SIG. Still results in equivalent .config files for s390.
Signed-off-by: Eric DeVolder <[email protected]>
Acked-by: Alexander Gordeev <[email protected]>
---
arch/s390/Kconfig | 65 ++++++++++++++---------------------------------
1 file changed, 19 insertions(+), 46 deletions(-)
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 5b39918b7042..5d4fbbfdd1cd 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -244,6 +244,25 @@ config PGTABLE_LEVELS
source "kernel/livepatch/Kconfig"
+config ARCH_DEFAULT_KEXEC
+ def_bool y
+
+config ARCH_SUPPORTS_KEXEC
+ def_bool y
+
+config ARCH_SUPPORTS_KEXEC_FILE
+ def_bool CRYPTO && CRYPTO_SHA256 && CRYPTO_SHA256_S390
+
+config ARCH_HAS_KEXEC_PURGATORY
+ def_bool KEXEC_FILE
+
+config ARCH_SUPPORTS_CRASH_DUMP
+ def_bool y
+ help
+ Refer to <file:Documentation/s390/zfcpdump.rst> for more details on this.
+ This option also enables s390 zfcpdump.
+ See also <file:Documentation/s390/zfcpdump.rst>
+
menu "Processor type and features"
config HAVE_MARCH_Z10_FEATURES
@@ -482,36 +501,6 @@ config SCHED_TOPOLOGY
source "kernel/Kconfig.hz"
-config KEXEC
- def_bool y
- select KEXEC_CORE
-
-config KEXEC_FILE
- bool "kexec file based system call"
- select KEXEC_CORE
- depends on CRYPTO
- depends on CRYPTO_SHA256
- depends on CRYPTO_SHA256_S390
- help
- Enable the kexec file based system call. In contrast to the normal
- kexec system call this system call takes file descriptors for the
- kernel and initramfs as arguments.
-
-config ARCH_HAS_KEXEC_PURGATORY
- def_bool y
- depends on KEXEC_FILE
-
-config KEXEC_SIG
- bool "Verify kernel signature during kexec_file_load() syscall"
- depends on KEXEC_FILE && MODULE_SIG_FORMAT
- help
- This option makes kernel signature verification mandatory for
- the kexec_file_load() syscall.
-
- In addition to that option, you need to enable signature
- verification for the corresponding kernel image type being
- loaded in order for this to work.
-
config KERNEL_NOBP
def_bool n
prompt "Enable modified branch prediction for the kernel by default"
@@ -733,22 +722,6 @@ config VFIO_AP
endmenu
-menu "Dump support"
-
-config CRASH_DUMP
- bool "kernel crash dumps"
- select KEXEC
- help
- Generate crash dump after being started by kexec.
- Crash dump kernels are loaded in the main kernel with kexec-tools
- into a specially reserved region and then later executed after
- a crash by kdump/kexec.
- Refer to <file:Documentation/s390/zfcpdump.rst> for more details on this.
- This option also enables s390 zfcpdump.
- See also <file:Documentation/s390/zfcpdump.rst>
-
-endmenu
-
config CCW
def_bool y
--
2.31.1
On Wed, Jul 5, 2023, at 16:19, Eric DeVolder wrote:
> The kexec and crash kernel options are provided in the common
> kernel/Kconfig.kexec. Utilize the common options and provide
> the ARCH_SUPPORTS_ and ARCH_SELECTS_ entries to recreate the
> equivalent set of KEXEC and CRASH options.
>
> Signed-off-by: Eric DeVolder <[email protected]>
> +config ARCH_SUPPORTS_KEXEC
> + def_bool (!SMP || PM_SLEEP_SMP) && MMU
>
> config ATAGS_PROC
> bool "Export atags in procfs"
> @@ -1668,17 +1656,8 @@ config ATAGS_PROC
> Should the atags used to boot the kernel be exported in an "atags"
> file in procfs. Useful with kexec.
>
> -config CRASH_DUMP
> - bool "Build kdump crash kernel (EXPERIMENTAL)"
> - help
> - Generate crash dump after being started by kexec. This should
> - be normally only set in special crash dump kernels which are
> - loaded in the main kernel with kexec-tools into a specially
> - reserved region and then later executed after a crash by
> - kdump/kexec. The crash dump kernel must be compiled to a
> - memory address not used by the main kernel
> -
> - For more details see Documentation/admin-guide/kdump/kdump.rst
> +config ARCH_SUPPORTS_CRASH_DUMP
> + def_bool y
>
I see this is now in linux-next, and it caused a few randconfig
build issues, these never happened in the past:
* The #ifdef CONFIG_KEXEC check in arch/arm/include/asm/kexec.h
needs to be changed to CONFIG_KEXEC_CORE:
include/linux/kexec.h:41:2: error: #error KEXEC_SOURCE_MEMORY_LIMIT not defined
same thing on m68k
* ARCH_SUPPORTS_CRASH_DUMP needs the same dependency as ARCH_SUPPORTS_KEXEC,
otherwise we seem to run into an obscure assembler error building the kdump
core on architectures that do not support kdump:
/tmp/ccpYl6w9.s:1546: Error: selected processor does not support requested special purpose register -- `mrs r2,cpsr'
* Most architectures build machine_kexec.o only when KEXEC is enabled,
this also needs to be changed to KEXEC_CORE:
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -59,7 +59,7 @@ obj-$(CONFIG_FUNCTION_TRACER) += entry-ftrace.o
obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o insn.o patch.o
obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o insn.o patch.o
obj-$(CONFIG_JUMP_LABEL) += jump_label.o insn.o patch.o
-obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
+obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o relocate_kernel.o
# Main staffs in KPROBES are in arch/arm/probes/ .
obj-$(CONFIG_KPROBES) += patch.o insn.o
obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o
Arnd
Hi Eric,
On Wed, Jul 05, 2023 at 10:20:03AM -0400, Eric DeVolder wrote:
> The kexec and crash kernel options are provided in the common
> kernel/Kconfig.kexec. Utilize the common options and provide
> the ARCH_SUPPORTS_ and ARCH_SELECTS_ entries to recreate the
> equivalent set of KEXEC and CRASH options.
>
> NOTE: The original Kconfig has a KEXEC_SIG which depends on
> MODULE_SIG_FORMAT. However, attempts to keep the MODULE_SIG_FORMAT
> dependency (using the strategy outlined in this series, and other
> techniques) results in 'error: recursive dependency detected'
> on CRYPTO.
>
> Per Alexander Gordeev <[email protected]>: "the MODULE_SIG_FORMAT
> dependency was introduced with [git commit below] and in fact was not
> necessary, since s390 did/does not use mod_check_sig() anyway.
>
> commit c8424e776b09 ("MODSIGN: Export module signature definitions")
>
> MODULE_SIG_FORMAT is needed to select SYSTEM_DATA_VERIFICATION. But
> SYSTEM_DATA_VERIFICATION is also selected by FS_VERITY*, so dropping
> MODULE_SIG_FORMAT does not hurt."
>
> Therefore, the solution is to drop the MODULE_SIG_FORMAT dependency
> from KEXEC_SIG. Still results in equivalent .config files for s390.
>
> Signed-off-by: Eric DeVolder <[email protected]>
> Acked-by: Alexander Gordeev <[email protected]>
> ---
> arch/s390/Kconfig | 65 ++++++++++++++---------------------------------
> 1 file changed, 19 insertions(+), 46 deletions(-)
>
> diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
> index 5b39918b7042..5d4fbbfdd1cd 100644
> --- a/arch/s390/Kconfig
> +++ b/arch/s390/Kconfig
> @@ -244,6 +244,25 @@ config PGTABLE_LEVELS
>
> source "kernel/livepatch/Kconfig"
>
> +config ARCH_DEFAULT_KEXEC
> + def_bool y
> +
> +config ARCH_SUPPORTS_KEXEC
> + def_bool y
> +
> +config ARCH_SUPPORTS_KEXEC_FILE
> + def_bool CRYPTO && CRYPTO_SHA256 && CRYPTO_SHA256_S390
> +
> +config ARCH_HAS_KEXEC_PURGATORY
> + def_bool KEXEC_FILE
> +
> +config ARCH_SUPPORTS_CRASH_DUMP
> + def_bool y
> + help
> + Refer to <file:Documentation/s390/zfcpdump.rst> for more details on this.
> + This option also enables s390 zfcpdump.
> + See also <file:Documentation/s390/zfcpdump.rst>
> +
> menu "Processor type and features"
>
> config HAVE_MARCH_Z10_FEATURES
> @@ -482,36 +501,6 @@ config SCHED_TOPOLOGY
>
> source "kernel/Kconfig.hz"
>
> -config KEXEC
> - def_bool y
> - select KEXEC_CORE
> -
> -config KEXEC_FILE
> - bool "kexec file based system call"
> - select KEXEC_CORE
> - depends on CRYPTO
> - depends on CRYPTO_SHA256
> - depends on CRYPTO_SHA256_S390
> - help
> - Enable the kexec file based system call. In contrast to the normal
> - kexec system call this system call takes file descriptors for the
> - kernel and initramfs as arguments.
> -
> -config ARCH_HAS_KEXEC_PURGATORY
> - def_bool y
> - depends on KEXEC_FILE
> -
> -config KEXEC_SIG
> - bool "Verify kernel signature during kexec_file_load() syscall"
> - depends on KEXEC_FILE && MODULE_SIG_FORMAT
> - help
> - This option makes kernel signature verification mandatory for
> - the kexec_file_load() syscall.
> -
> - In addition to that option, you need to enable signature
> - verification for the corresponding kernel image type being
> - loaded in order for this to work.
> -
> config KERNEL_NOBP
> def_bool n
> prompt "Enable modified branch prediction for the kernel by default"
> @@ -733,22 +722,6 @@ config VFIO_AP
>
> endmenu
>
> -menu "Dump support"
> -
> -config CRASH_DUMP
> - bool "kernel crash dumps"
> - select KEXEC
> - help
> - Generate crash dump after being started by kexec.
> - Crash dump kernels are loaded in the main kernel with kexec-tools
> - into a specially reserved region and then later executed after
> - a crash by kdump/kexec.
> - Refer to <file:Documentation/s390/zfcpdump.rst> for more details on this.
> - This option also enables s390 zfcpdump.
> - See also <file:Documentation/s390/zfcpdump.rst>
> -
> -endmenu
> -
> config CCW
> def_bool y
>
> --
> 2.31.1
>
I just bisected the following build failure visible with 'ARCH=s390
allnoconfig' to this change as commit 842ce0e1dafa ("s390/kexec:
refactor for kernel/Kconfig.kexec") in -next.
arch/s390/kernel/machine_kexec.c:120:37: warning: 'struct kimage' declared inside parameter list will not be visible outside of this definition or declaration
120 | static bool kdump_csum_valid(struct kimage *image)
| ^~~~~~
arch/s390/kernel/machine_kexec.c:188:34: warning: 'struct kimage' declared inside parameter list will not be visible outside of this definition or declaration
188 | int machine_kexec_prepare(struct kimage *image)
| ^~~~~~
arch/s390/kernel/machine_kexec.c: In function 'machine_kexec_prepare':
arch/s390/kernel/machine_kexec.c:192:18: error: invalid use of undefined type 'struct kimage'
192 | if (image->type == KEXEC_TYPE_CRASH)
| ^~
arch/s390/kernel/machine_kexec.c:192:28: error: 'KEXEC_TYPE_CRASH' undeclared (first use in this function); did you mean 'KEXEC_ON_CRASH'?
192 | if (image->type == KEXEC_TYPE_CRASH)
| ^~~~~~~~~~~~~~~~
| KEXEC_ON_CRASH
arch/s390/kernel/machine_kexec.c:192:28: note: each undeclared identifier is reported only once for each function it appears in
arch/s390/kernel/machine_kexec.c:196:18: error: invalid use of undefined type 'struct kimage'
196 | if (image->type != KEXEC_TYPE_DEFAULT)
| ^~
arch/s390/kernel/machine_kexec.c:196:28: error: 'KEXEC_TYPE_DEFAULT' undeclared (first use in this function); did you mean 'KEXEC_ARCH_DEFAULT'?
196 | if (image->type != KEXEC_TYPE_DEFAULT)
| ^~~~~~~~~~~~~~~~~~
| KEXEC_ARCH_DEFAULT
In file included from arch/s390/include/asm/thread_info.h:31,
from include/linux/thread_info.h:60,
from arch/s390/include/asm/preempt.h:6,
from include/linux/preempt.h:79,
from arch/s390/include/asm/percpu.h:5,
from include/linux/irqflags.h:18,
from include/linux/rcupdate.h:26,
from include/linux/rculist.h:11,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/ratelimit.h:6,
from include/linux/dev_printk.h:16,
from include/linux/device.h:15,
from arch/s390/kernel/machine_kexec.c:9:
arch/s390/kernel/machine_kexec.c:200:48: error: invalid use of undefined type 'struct kimage'
200 | reboot_code_buffer = page_to_virt(image->control_code_page);
| ^~
arch/s390/include/asm/page.h:186:58: note: in definition of macro '__va'
186 | #define __va(x) ((void *)(unsigned long)(x))
| ^
arch/s390/include/asm/page.h:194:38: note: in expansion of macro 'pfn_to_phys'
194 | #define pfn_to_virt(pfn) __va(pfn_to_phys(pfn))
| ^~~~~~~~~~~
arch/s390/include/asm/page.h:199:33: note: in expansion of macro 'pfn_to_virt'
199 | #define page_to_virt(page) pfn_to_virt(page_to_pfn(page))
| ^~~~~~~~~~~
include/asm-generic/memory_model.h:64:21: note: in expansion of macro '__page_to_pfn'
64 | #define page_to_pfn __page_to_pfn
| ^~~~~~~~~~~~~
arch/s390/kernel/machine_kexec.c:200:30: note: in expansion of macro 'page_to_virt'
200 | reboot_code_buffer = page_to_virt(image->control_code_page);
| ^~~~~~~~~~~~
arch/s390/kernel/machine_kexec.c: At top level:
arch/s390/kernel/machine_kexec.c:207:35: warning: 'struct kimage' declared inside parameter list will not be visible outside of this definition or declaration
207 | void machine_kexec_cleanup(struct kimage *image)
| ^~~~~~
arch/s390/kernel/machine_kexec.c: In function '__do_machine_kexec':
arch/s390/kernel/machine_kexec.c:243:40: error: invalid use of undefined type 'struct kimage'
243 | data_mover = page_to_phys(image->control_code_page);
| ^~
arch/s390/include/asm/page.h:189:35: note: in definition of macro 'pfn_to_phys'
189 | #define pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT)
| ^~~
include/asm-generic/memory_model.h:64:21: note: in expansion of macro '__page_to_pfn'
64 | #define page_to_pfn __page_to_pfn
| ^~~~~~~~~~~~~
arch/s390/kernel/machine_kexec.c:243:22: note: in expansion of macro 'page_to_phys'
243 | data_mover = page_to_phys(image->control_code_page);
| ^~~~~~~~~~~~
arch/s390/kernel/machine_kexec.c:244:36: error: invalid use of undefined type 'struct kimage'
244 | entry = virt_to_phys(&image->head);
| ^~
In file included from arch/s390/kernel/machine_kexec.c:27:
arch/s390/kernel/machine_kexec.c:252:40: error: invalid use of undefined type 'struct kimage'
252 | unsigned long, image->start,
| ^~
arch/s390/include/asm/stacktrace.h:101:32: note: in definition of macro 'CALL_LARGS_2'
101 | long arg2 = (long)(t2)(a2)
| ^~
arch/s390/include/asm/stacktrace.h:216:9: note: in expansion of macro 'CALL_LARGS_3'
216 | CALL_LARGS_##nr(__VA_ARGS__); \
| ^~~~~~~~~~~
arch/s390/kernel/machine_kexec.c:250:9: note: in expansion of macro 'call_nodat'
250 | call_nodat(3, void, (relocate_kernel_t)data_mover,
| ^~~~~~~~~~
In file included from include/linux/irqflags.h:15:
arch/s390/kernel/machine_kexec.c:252:40: error: invalid use of undefined type 'struct kimage'
252 | unsigned long, image->start,
| ^~
include/linux/typecheck.h:11:16: note: in definition of macro 'typecheck'
11 | typeof(x) __dummy2; \
| ^
arch/s390/include/asm/stacktrace.h:136:9: note: in expansion of macro 'CALL_TYPECHECK_2'
136 | CALL_TYPECHECK_2(__VA_ARGS__); \
| ^~~~~~~~~~~~~~~~
arch/s390/include/asm/stacktrace.h:219:9: note: in expansion of macro 'CALL_TYPECHECK_3'
219 | CALL_TYPECHECK_##nr(__VA_ARGS__); \
| ^~~~~~~~~~~~~~~
arch/s390/kernel/machine_kexec.c:250:9: note: in expansion of macro 'call_nodat'
250 | call_nodat(3, void, (relocate_kernel_t)data_mover,
| ^~~~~~~~~~
include/linux/typecheck.h:12:25: warning: comparison of distinct pointer types lacks a cast
12 | (void)(&__dummy == &__dummy2); \
| ^~
arch/s390/include/asm/stacktrace.h:134:9: note: in expansion of macro 'typecheck'
134 | typecheck(t, a)
| ^~~~~~~~~
arch/s390/include/asm/stacktrace.h:136:9: note: in expansion of macro 'CALL_TYPECHECK_2'
136 | CALL_TYPECHECK_2(__VA_ARGS__); \
| ^~~~~~~~~~~~~~~~
arch/s390/include/asm/stacktrace.h:219:9: note: in expansion of macro 'CALL_TYPECHECK_3'
219 | CALL_TYPECHECK_##nr(__VA_ARGS__); \
| ^~~~~~~~~~~~~~~
arch/s390/kernel/machine_kexec.c:250:9: note: in expansion of macro 'call_nodat'
250 | call_nodat(3, void, (relocate_kernel_t)data_mover,
| ^~~~~~~~~~
arch/s390/kernel/machine_kexec.c: At top level:
arch/s390/kernel/machine_kexec.c:278:27: warning: 'struct kimage' declared inside parameter list will not be visible outside of this definition or declaration
278 | void machine_kexec(struct kimage *image)
| ^~~~~~
arch/s390/kernel/machine_kexec.c: In function 'machine_kexec':
arch/s390/kernel/machine_kexec.c:280:18: error: invalid use of undefined type 'struct kimage'
280 | if (image->type == KEXEC_TYPE_CRASH && !kdump_csum_valid(image))
| ^~
arch/s390/kernel/machine_kexec.c:280:28: error: 'KEXEC_TYPE_CRASH' undeclared (first use in this function); did you mean 'KEXEC_ON_CRASH'?
280 | if (image->type == KEXEC_TYPE_CRASH && !kdump_csum_valid(image))
| ^~~~~~~~~~~~~~~~
| KEXEC_ON_CRASH
arch/s390/kernel/machine_kexec.c:280:66: error: passing argument 1 of 'kdump_csum_valid' from incompatible pointer type [-Werror=incompatible-pointer-types]
280 | if (image->type == KEXEC_TYPE_CRASH && !kdump_csum_valid(image))
| ^~~~~
| |
| struct kimage *
arch/s390/kernel/machine_kexec.c:120:45: note: expected 'struct kimage *' but argument is of type 'struct kimage *'
120 | static bool kdump_csum_valid(struct kimage *image)
| ~~~~~~~~~~~~~~~^~~~~
cc1: some warnings being treated as errors
I don't think this change is equivalent for s390, which had
config KEXEC
def_bool y
select KEXEC_CORE
but it is now the equivalent of
config KEXEC
bool "Enable kexec system call"
default y
which enables KEXEC by default but it also allows KEXEC to be disabled
for s390 now, because it is a user-visible symbol, not one that is
unconditionally enabled no matter what. If s390 can tolerate KEXEC being
user selectable, then I assume the fix is just adjusting
arch/s390/kernel/Makefile to only build the machine_kexec files when
CONFIG_KEXEC_CORE is set:
diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
index 6b2a051e1f8a..a06b39da95f0 100644
--- a/arch/s390/kernel/Makefile
+++ b/arch/s390/kernel/Makefile
@@ -37,10 +37,10 @@ CFLAGS_unwind_bc.o += -fno-optimize-sibling-calls
obj-y := head64.o traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtime.o
obj-y += processor.o syscall.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
obj-y += debug.o irq.o ipl.o dis.o diag.o vdso.o cpufeature.o
-obj-y += sysinfo.o lgr.o os_info.o machine_kexec.o
+obj-y += sysinfo.o lgr.o os_info.o
obj-y += runtime_instr.o cache.o fpu.o dumpstack.o guarded_storage.o sthyi.o
obj-y += entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o
-obj-y += nospec-branch.o ipl_vmparm.o machine_kexec_reloc.o unwind_bc.o
+obj-y += nospec-branch.o ipl_vmparm.o unwind_bc.o
obj-y += smp.o text_amode31.o stacktrace.o abs_lowcore.o
extra-y += vmlinux.lds
@@ -66,6 +66,7 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
obj-$(CONFIG_UPROBES) += uprobes.o
obj-$(CONFIG_JUMP_LABEL) += jump_label.o
+obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o machine_kexec_reloc.o
obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_image.o
obj-$(CONFIG_KEXEC_FILE) += kexec_elf.o
Otherwise, the prompt for KEXEC could be made conditional on some ARCH
symbol so that architectures can opt out of it.
As an aside, is this intended for the 6.5 merge window? If not, it
shouldn't be in -next at this point, I was surprised to see new broken
builds.
Cheers,
Nathan
On Wed, Jul 5, 2023, at 17:22, Eric DeVolder wrote:
> On 7/5/23 10:05, Arnd Bergmann wrote:
>> On Wed, Jul 5, 2023, at 16:19, Eric DeVolder wrote:
>>
>> I see this is now in linux-next, and it caused a few randconfig
>> build issues, these never happened in the past:
>
> Arnd,
> Thanks for looking at this!
>
> I received randconfig errors from Andrew Morton's machinery. When
> investigating I
> found that randconfig was able to specify CRASH_DUMP without KEXEC, and
> that lead
> to problems. I believe this situation existed prior to this series as
> well.
On Arm, there was definitely a bug because one could enable CRASH_DUMP
without enabling KEXEC, but that had no effect at all. I only noticed
the problem testing linux-next because it turned from silently broken
into a build failure
> Specifically CRASH_DUMP does not have a dependency on KEXEC, or select
> (only s390
> has this hole closed).
>
> For CRASH_DUMP, this series now selects KEXEC to close this gap, which is what a
> sane config would have (ie both CRASH_DUMP and KEXEC).
Right, that is the easier way out here.
> Do you think the changes outlined below are still needed?
I think only the first one still applies on arm, you need to ensure
that ARCH_SUPPORTS_CRASH_DUMP has the same dependency as
ARCH_SUPPORTS_KEXEC, or it just depends on ARCH_SUPPORTS_KEXEC.
Arnd
On 7/5/23 10:49, Nathan Chancellor wrote:
> Hi Eric,
>
> On Wed, Jul 05, 2023 at 10:20:03AM -0400, Eric DeVolder wrote:
>> The kexec and crash kernel options are provided in the common
>> kernel/Kconfig.kexec. Utilize the common options and provide
>> the ARCH_SUPPORTS_ and ARCH_SELECTS_ entries to recreate the
>> equivalent set of KEXEC and CRASH options.
>>
>> NOTE: The original Kconfig has a KEXEC_SIG which depends on
>> MODULE_SIG_FORMAT. However, attempts to keep the MODULE_SIG_FORMAT
>> dependency (using the strategy outlined in this series, and other
>> techniques) results in 'error: recursive dependency detected'
>> on CRYPTO.
>>
>> Per Alexander Gordeev <[email protected]>: "the MODULE_SIG_FORMAT
>> dependency was introduced with [git commit below] and in fact was not
>> necessary, since s390 did/does not use mod_check_sig() anyway.
>>
>> commit c8424e776b09 ("MODSIGN: Export module signature definitions")
>>
>> MODULE_SIG_FORMAT is needed to select SYSTEM_DATA_VERIFICATION. But
>> SYSTEM_DATA_VERIFICATION is also selected by FS_VERITY*, so dropping
>> MODULE_SIG_FORMAT does not hurt."
>>
>> Therefore, the solution is to drop the MODULE_SIG_FORMAT dependency
>> from KEXEC_SIG. Still results in equivalent .config files for s390.
>>
>> Signed-off-by: Eric DeVolder <[email protected]>
>> Acked-by: Alexander Gordeev <[email protected]>
>> ---
>> arch/s390/Kconfig | 65 ++++++++++++++---------------------------------
>> 1 file changed, 19 insertions(+), 46 deletions(-)
>>
>> diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
>> index 5b39918b7042..5d4fbbfdd1cd 100644
>> --- a/arch/s390/Kconfig
>> +++ b/arch/s390/Kconfig
>> @@ -244,6 +244,25 @@ config PGTABLE_LEVELS
>>
>> source "kernel/livepatch/Kconfig"
>>
>> +config ARCH_DEFAULT_KEXEC
>> + def_bool y
>> +
>> +config ARCH_SUPPORTS_KEXEC
>> + def_bool y
>> +
>> +config ARCH_SUPPORTS_KEXEC_FILE
>> + def_bool CRYPTO && CRYPTO_SHA256 && CRYPTO_SHA256_S390
>> +
>> +config ARCH_HAS_KEXEC_PURGATORY
>> + def_bool KEXEC_FILE
>> +
>> +config ARCH_SUPPORTS_CRASH_DUMP
>> + def_bool y
>> + help
>> + Refer to <file:Documentation/s390/zfcpdump.rst> for more details on this.
>> + This option also enables s390 zfcpdump.
>> + See also <file:Documentation/s390/zfcpdump.rst>
>> +
>> menu "Processor type and features"
>>
>> config HAVE_MARCH_Z10_FEATURES
>> @@ -482,36 +501,6 @@ config SCHED_TOPOLOGY
>>
>> source "kernel/Kconfig.hz"
>>
>> -config KEXEC
>> - def_bool y
>> - select KEXEC_CORE
>> -
>> -config KEXEC_FILE
>> - bool "kexec file based system call"
>> - select KEXEC_CORE
>> - depends on CRYPTO
>> - depends on CRYPTO_SHA256
>> - depends on CRYPTO_SHA256_S390
>> - help
>> - Enable the kexec file based system call. In contrast to the normal
>> - kexec system call this system call takes file descriptors for the
>> - kernel and initramfs as arguments.
>> -
>> -config ARCH_HAS_KEXEC_PURGATORY
>> - def_bool y
>> - depends on KEXEC_FILE
>> -
>> -config KEXEC_SIG
>> - bool "Verify kernel signature during kexec_file_load() syscall"
>> - depends on KEXEC_FILE && MODULE_SIG_FORMAT
>> - help
>> - This option makes kernel signature verification mandatory for
>> - the kexec_file_load() syscall.
>> -
>> - In addition to that option, you need to enable signature
>> - verification for the corresponding kernel image type being
>> - loaded in order for this to work.
>> -
>> config KERNEL_NOBP
>> def_bool n
>> prompt "Enable modified branch prediction for the kernel by default"
>> @@ -733,22 +722,6 @@ config VFIO_AP
>>
>> endmenu
>>
>> -menu "Dump support"
>> -
>> -config CRASH_DUMP
>> - bool "kernel crash dumps"
>> - select KEXEC
>> - help
>> - Generate crash dump after being started by kexec.
>> - Crash dump kernels are loaded in the main kernel with kexec-tools
>> - into a specially reserved region and then later executed after
>> - a crash by kdump/kexec.
>> - Refer to <file:Documentation/s390/zfcpdump.rst> for more details on this.
>> - This option also enables s390 zfcpdump.
>> - See also <file:Documentation/s390/zfcpdump.rst>
>> -
>> -endmenu
>> -
>> config CCW
>> def_bool y
>>
>> --
>> 2.31.1
>>
>
> I just bisected the following build failure visible with 'ARCH=s390
> allnoconfig' to this change as commit 842ce0e1dafa ("s390/kexec:
> refactor for kernel/Kconfig.kexec") in -next.
>
> arch/s390/kernel/machine_kexec.c:120:37: warning: 'struct kimage' declared inside parameter list will not be visible outside of this definition or declaration
> 120 | static bool kdump_csum_valid(struct kimage *image)
> | ^~~~~~
> arch/s390/kernel/machine_kexec.c:188:34: warning: 'struct kimage' declared inside parameter list will not be visible outside of this definition or declaration
> 188 | int machine_kexec_prepare(struct kimage *image)
> | ^~~~~~
> arch/s390/kernel/machine_kexec.c: In function 'machine_kexec_prepare':
> arch/s390/kernel/machine_kexec.c:192:18: error: invalid use of undefined type 'struct kimage'
> 192 | if (image->type == KEXEC_TYPE_CRASH)
> | ^~
> arch/s390/kernel/machine_kexec.c:192:28: error: 'KEXEC_TYPE_CRASH' undeclared (first use in this function); did you mean 'KEXEC_ON_CRASH'?
> 192 | if (image->type == KEXEC_TYPE_CRASH)
> | ^~~~~~~~~~~~~~~~
> | KEXEC_ON_CRASH
> arch/s390/kernel/machine_kexec.c:192:28: note: each undeclared identifier is reported only once for each function it appears in
> arch/s390/kernel/machine_kexec.c:196:18: error: invalid use of undefined type 'struct kimage'
> 196 | if (image->type != KEXEC_TYPE_DEFAULT)
> | ^~
> arch/s390/kernel/machine_kexec.c:196:28: error: 'KEXEC_TYPE_DEFAULT' undeclared (first use in this function); did you mean 'KEXEC_ARCH_DEFAULT'?
> 196 | if (image->type != KEXEC_TYPE_DEFAULT)
> | ^~~~~~~~~~~~~~~~~~
> | KEXEC_ARCH_DEFAULT
> In file included from arch/s390/include/asm/thread_info.h:31,
> from include/linux/thread_info.h:60,
> from arch/s390/include/asm/preempt.h:6,
> from include/linux/preempt.h:79,
> from arch/s390/include/asm/percpu.h:5,
> from include/linux/irqflags.h:18,
> from include/linux/rcupdate.h:26,
> from include/linux/rculist.h:11,
> from include/linux/pid.h:5,
> from include/linux/sched.h:14,
> from include/linux/ratelimit.h:6,
> from include/linux/dev_printk.h:16,
> from include/linux/device.h:15,
> from arch/s390/kernel/machine_kexec.c:9:
> arch/s390/kernel/machine_kexec.c:200:48: error: invalid use of undefined type 'struct kimage'
> 200 | reboot_code_buffer = page_to_virt(image->control_code_page);
> | ^~
> arch/s390/include/asm/page.h:186:58: note: in definition of macro '__va'
> 186 | #define __va(x) ((void *)(unsigned long)(x))
> | ^
> arch/s390/include/asm/page.h:194:38: note: in expansion of macro 'pfn_to_phys'
> 194 | #define pfn_to_virt(pfn) __va(pfn_to_phys(pfn))
> | ^~~~~~~~~~~
> arch/s390/include/asm/page.h:199:33: note: in expansion of macro 'pfn_to_virt'
> 199 | #define page_to_virt(page) pfn_to_virt(page_to_pfn(page))
> | ^~~~~~~~~~~
> include/asm-generic/memory_model.h:64:21: note: in expansion of macro '__page_to_pfn'
> 64 | #define page_to_pfn __page_to_pfn
> | ^~~~~~~~~~~~~
> arch/s390/kernel/machine_kexec.c:200:30: note: in expansion of macro 'page_to_virt'
> 200 | reboot_code_buffer = page_to_virt(image->control_code_page);
> | ^~~~~~~~~~~~
> arch/s390/kernel/machine_kexec.c: At top level:
> arch/s390/kernel/machine_kexec.c:207:35: warning: 'struct kimage' declared inside parameter list will not be visible outside of this definition or declaration
> 207 | void machine_kexec_cleanup(struct kimage *image)
> | ^~~~~~
> arch/s390/kernel/machine_kexec.c: In function '__do_machine_kexec':
> arch/s390/kernel/machine_kexec.c:243:40: error: invalid use of undefined type 'struct kimage'
> 243 | data_mover = page_to_phys(image->control_code_page);
> | ^~
> arch/s390/include/asm/page.h:189:35: note: in definition of macro 'pfn_to_phys'
> 189 | #define pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT)
> | ^~~
> include/asm-generic/memory_model.h:64:21: note: in expansion of macro '__page_to_pfn'
> 64 | #define page_to_pfn __page_to_pfn
> | ^~~~~~~~~~~~~
> arch/s390/kernel/machine_kexec.c:243:22: note: in expansion of macro 'page_to_phys'
> 243 | data_mover = page_to_phys(image->control_code_page);
> | ^~~~~~~~~~~~
> arch/s390/kernel/machine_kexec.c:244:36: error: invalid use of undefined type 'struct kimage'
> 244 | entry = virt_to_phys(&image->head);
> | ^~
> In file included from arch/s390/kernel/machine_kexec.c:27:
> arch/s390/kernel/machine_kexec.c:252:40: error: invalid use of undefined type 'struct kimage'
> 252 | unsigned long, image->start,
> | ^~
> arch/s390/include/asm/stacktrace.h:101:32: note: in definition of macro 'CALL_LARGS_2'
> 101 | long arg2 = (long)(t2)(a2)
> | ^~
> arch/s390/include/asm/stacktrace.h:216:9: note: in expansion of macro 'CALL_LARGS_3'
> 216 | CALL_LARGS_##nr(__VA_ARGS__); \
> | ^~~~~~~~~~~
> arch/s390/kernel/machine_kexec.c:250:9: note: in expansion of macro 'call_nodat'
> 250 | call_nodat(3, void, (relocate_kernel_t)data_mover,
> | ^~~~~~~~~~
> In file included from include/linux/irqflags.h:15:
> arch/s390/kernel/machine_kexec.c:252:40: error: invalid use of undefined type 'struct kimage'
> 252 | unsigned long, image->start,
> | ^~
> include/linux/typecheck.h:11:16: note: in definition of macro 'typecheck'
> 11 | typeof(x) __dummy2; \
> | ^
> arch/s390/include/asm/stacktrace.h:136:9: note: in expansion of macro 'CALL_TYPECHECK_2'
> 136 | CALL_TYPECHECK_2(__VA_ARGS__); \
> | ^~~~~~~~~~~~~~~~
> arch/s390/include/asm/stacktrace.h:219:9: note: in expansion of macro 'CALL_TYPECHECK_3'
> 219 | CALL_TYPECHECK_##nr(__VA_ARGS__); \
> | ^~~~~~~~~~~~~~~
> arch/s390/kernel/machine_kexec.c:250:9: note: in expansion of macro 'call_nodat'
> 250 | call_nodat(3, void, (relocate_kernel_t)data_mover,
> | ^~~~~~~~~~
> include/linux/typecheck.h:12:25: warning: comparison of distinct pointer types lacks a cast
> 12 | (void)(&__dummy == &__dummy2); \
> | ^~
> arch/s390/include/asm/stacktrace.h:134:9: note: in expansion of macro 'typecheck'
> 134 | typecheck(t, a)
> | ^~~~~~~~~
> arch/s390/include/asm/stacktrace.h:136:9: note: in expansion of macro 'CALL_TYPECHECK_2'
> 136 | CALL_TYPECHECK_2(__VA_ARGS__); \
> | ^~~~~~~~~~~~~~~~
> arch/s390/include/asm/stacktrace.h:219:9: note: in expansion of macro 'CALL_TYPECHECK_3'
> 219 | CALL_TYPECHECK_##nr(__VA_ARGS__); \
> | ^~~~~~~~~~~~~~~
> arch/s390/kernel/machine_kexec.c:250:9: note: in expansion of macro 'call_nodat'
> 250 | call_nodat(3, void, (relocate_kernel_t)data_mover,
> | ^~~~~~~~~~
> arch/s390/kernel/machine_kexec.c: At top level:
> arch/s390/kernel/machine_kexec.c:278:27: warning: 'struct kimage' declared inside parameter list will not be visible outside of this definition or declaration
> 278 | void machine_kexec(struct kimage *image)
> | ^~~~~~
> arch/s390/kernel/machine_kexec.c: In function 'machine_kexec':
> arch/s390/kernel/machine_kexec.c:280:18: error: invalid use of undefined type 'struct kimage'
> 280 | if (image->type == KEXEC_TYPE_CRASH && !kdump_csum_valid(image))
> | ^~
> arch/s390/kernel/machine_kexec.c:280:28: error: 'KEXEC_TYPE_CRASH' undeclared (first use in this function); did you mean 'KEXEC_ON_CRASH'?
> 280 | if (image->type == KEXEC_TYPE_CRASH && !kdump_csum_valid(image))
> | ^~~~~~~~~~~~~~~~
> | KEXEC_ON_CRASH
> arch/s390/kernel/machine_kexec.c:280:66: error: passing argument 1 of 'kdump_csum_valid' from incompatible pointer type [-Werror=incompatible-pointer-types]
> 280 | if (image->type == KEXEC_TYPE_CRASH && !kdump_csum_valid(image))
> | ^~~~~
> | |
> | struct kimage *
> arch/s390/kernel/machine_kexec.c:120:45: note: expected 'struct kimage *' but argument is of type 'struct kimage *'
> 120 | static bool kdump_csum_valid(struct kimage *image)
> | ~~~~~~~~~~~~~~~^~~~~
> cc1: some warnings being treated as errors
>
> I don't think this change is equivalent for s390, which had
>
> config KEXEC
> def_bool y
> select KEXEC_CORE
>
> but it is now the equivalent of
>
> config KEXEC
> bool "Enable kexec system call"
> default y
>
> which enables KEXEC by default but it also allows KEXEC to be disabled
> for s390 now, because it is a user-visible symbol, not one that is
> unconditionally enabled no matter what. If s390 can tolerate KEXEC being
> user selectable, then I assume the fix is just adjusting
> arch/s390/kernel/Makefile to only build the machine_kexec files when
> CONFIG_KEXEC_CORE is set:
>
> diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
> index 6b2a051e1f8a..a06b39da95f0 100644
> --- a/arch/s390/kernel/Makefile
> +++ b/arch/s390/kernel/Makefile
> @@ -37,10 +37,10 @@ CFLAGS_unwind_bc.o += -fno-optimize-sibling-calls
> obj-y := head64.o traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtime.o
> obj-y += processor.o syscall.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
> obj-y += debug.o irq.o ipl.o dis.o diag.o vdso.o cpufeature.o
> -obj-y += sysinfo.o lgr.o os_info.o machine_kexec.o
> +obj-y += sysinfo.o lgr.o os_info.o
> obj-y += runtime_instr.o cache.o fpu.o dumpstack.o guarded_storage.o sthyi.o
> obj-y += entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o
> -obj-y += nospec-branch.o ipl_vmparm.o machine_kexec_reloc.o unwind_bc.o
> +obj-y += nospec-branch.o ipl_vmparm.o unwind_bc.o
> obj-y += smp.o text_amode31.o stacktrace.o abs_lowcore.o
>
> extra-y += vmlinux.lds
> @@ -66,6 +66,7 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
> obj-$(CONFIG_UPROBES) += uprobes.o
> obj-$(CONFIG_JUMP_LABEL) += jump_label.o
>
> +obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o machine_kexec_reloc.o
> obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_image.o
> obj-$(CONFIG_KEXEC_FILE) += kexec_elf.o
>
>
> Otherwise, the prompt for KEXEC could be made conditional on some ARCH
> symbol so that architectures can opt out of it.
Nathan,
Thanks for looking at this! I've been receiving broken build info from Andrew's
machinery. I've investigated and learned that CRASH_DUMP can be specified without
KEXEC. I also realized that s390 originally had this right, but in the conversion
I did, I got it wrong.
This v4 series corrects that by having CRASH_DUMP select KEXEC.
The new KEXEC looks like:
config KEXEC
bool "Enable kexec system call"
default ARCH_DEFAULT_KEXEC
depends on ARCH_SUPPORTS_KEXEC
select KEXEC_CORE
which appears to be equivalent, I think the CRASH_DUMP issue is the root problem.
In a separate thread with Arnd Bergmann wrt/ arm build issues, he identifies
similar problems&solutions as you did, but points out that CRASH_DUMP might still
need some refinement; I'm looking into that.
The goal really is to make this series to result in equivalent configs as before,
but there are small problems in the conversion that are showing up that I'm working.
>
> As an aside, is this intended for the 6.5 merge window? If not, it
> shouldn't be in -next at this point, I was surprised to see new broken
> builds.
>
> Cheers,
> Nathan
I'm not going to pretend I know when this will make it...
eric
On 7/5/23 11:23, Eric DeVolder wrote:
>
>
> On 7/5/23 10:49, Nathan Chancellor wrote:
>> Hi Eric,
>>
>> On Wed, Jul 05, 2023 at 10:20:03AM -0400, Eric DeVolder wrote:
>>> The kexec and crash kernel options are provided in the common
>>> kernel/Kconfig.kexec. Utilize the common options and provide
>>> the ARCH_SUPPORTS_ and ARCH_SELECTS_ entries to recreate the
>>> equivalent set of KEXEC and CRASH options.
>>>
>>> NOTE: The original Kconfig has a KEXEC_SIG which depends on
>>> MODULE_SIG_FORMAT. However, attempts to keep the MODULE_SIG_FORMAT
>>> dependency (using the strategy outlined in this series, and other
>>> techniques) results in 'error: recursive dependency detected'
>>> on CRYPTO.
>>>
>>> Per Alexander Gordeev <[email protected]>: "the MODULE_SIG_FORMAT
>>> dependency was introduced with [git commit below] and in fact was not
>>> necessary, since s390 did/does not use mod_check_sig() anyway.
>>>
>>> commit c8424e776b09 ("MODSIGN: Export module signature definitions")
>>>
>>> MODULE_SIG_FORMAT is needed to select SYSTEM_DATA_VERIFICATION. But
>>> SYSTEM_DATA_VERIFICATION is also selected by FS_VERITY*, so dropping
>>> MODULE_SIG_FORMAT does not hurt."
>>>
>>> Therefore, the solution is to drop the MODULE_SIG_FORMAT dependency
>>> from KEXEC_SIG. Still results in equivalent .config files for s390.
>>>
>>> Signed-off-by: Eric DeVolder <[email protected]>
>>> Acked-by: Alexander Gordeev <[email protected]>
>>> ---
>>> arch/s390/Kconfig | 65 ++++++++++++++---------------------------------
>>> 1 file changed, 19 insertions(+), 46 deletions(-)
>>>
>>> diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
>>> index 5b39918b7042..5d4fbbfdd1cd 100644
>>> --- a/arch/s390/Kconfig
>>> +++ b/arch/s390/Kconfig
>>> @@ -244,6 +244,25 @@ config PGTABLE_LEVELS
>>> source "kernel/livepatch/Kconfig"
>>> +config ARCH_DEFAULT_KEXEC
>>> + def_bool y
>>> +
>>> +config ARCH_SUPPORTS_KEXEC
>>> + def_bool y
>>> +
>>> +config ARCH_SUPPORTS_KEXEC_FILE
>>> + def_bool CRYPTO && CRYPTO_SHA256 && CRYPTO_SHA256_S390
>>> +
>>> +config ARCH_HAS_KEXEC_PURGATORY
>>> + def_bool KEXEC_FILE
>>> +
>>> +config ARCH_SUPPORTS_CRASH_DUMP
>>> + def_bool y
>>> + help
>>> + Refer to <file:Documentation/s390/zfcpdump.rst> for more details on this.
>>> + This option also enables s390 zfcpdump.
>>> + See also <file:Documentation/s390/zfcpdump.rst>
>>> +
>>> menu "Processor type and features"
>>> config HAVE_MARCH_Z10_FEATURES
>>> @@ -482,36 +501,6 @@ config SCHED_TOPOLOGY
>>> source "kernel/Kconfig.hz"
>>> -config KEXEC
>>> - def_bool y
>>> - select KEXEC_CORE
>>> -
>>> -config KEXEC_FILE
>>> - bool "kexec file based system call"
>>> - select KEXEC_CORE
>>> - depends on CRYPTO
>>> - depends on CRYPTO_SHA256
>>> - depends on CRYPTO_SHA256_S390
>>> - help
>>> - Enable the kexec file based system call. In contrast to the normal
>>> - kexec system call this system call takes file descriptors for the
>>> - kernel and initramfs as arguments.
>>> -
>>> -config ARCH_HAS_KEXEC_PURGATORY
>>> - def_bool y
>>> - depends on KEXEC_FILE
>>> -
>>> -config KEXEC_SIG
>>> - bool "Verify kernel signature during kexec_file_load() syscall"
>>> - depends on KEXEC_FILE && MODULE_SIG_FORMAT
>>> - help
>>> - This option makes kernel signature verification mandatory for
>>> - the kexec_file_load() syscall.
>>> -
>>> - In addition to that option, you need to enable signature
>>> - verification for the corresponding kernel image type being
>>> - loaded in order for this to work.
>>> -
>>> config KERNEL_NOBP
>>> def_bool n
>>> prompt "Enable modified branch prediction for the kernel by default"
>>> @@ -733,22 +722,6 @@ config VFIO_AP
>>> endmenu
>>> -menu "Dump support"
>>> -
>>> -config CRASH_DUMP
>>> - bool "kernel crash dumps"
>>> - select KEXEC
>>> - help
>>> - Generate crash dump after being started by kexec.
>>> - Crash dump kernels are loaded in the main kernel with kexec-tools
>>> - into a specially reserved region and then later executed after
>>> - a crash by kdump/kexec.
>>> - Refer to <file:Documentation/s390/zfcpdump.rst> for more details on this.
>>> - This option also enables s390 zfcpdump.
>>> - See also <file:Documentation/s390/zfcpdump.rst>
>>> -
>>> -endmenu
>>> -
>>> config CCW
>>> def_bool y
>>> --
>>> 2.31.1
>>>
>>
>> I just bisected the following build failure visible with 'ARCH=s390
>> allnoconfig' to this change as commit 842ce0e1dafa ("s390/kexec:
>> refactor for kernel/Kconfig.kexec") in -next.
>>
>> arch/s390/kernel/machine_kexec.c:120:37: warning: 'struct kimage' declared inside parameter
>> list will not be visible outside of this definition or declaration
>> 120 | static bool kdump_csum_valid(struct kimage *image)
>> | ^~~~~~
>> arch/s390/kernel/machine_kexec.c:188:34: warning: 'struct kimage' declared inside parameter
>> list will not be visible outside of this definition or declaration
>> 188 | int machine_kexec_prepare(struct kimage *image)
>> | ^~~~~~
>> arch/s390/kernel/machine_kexec.c: In function 'machine_kexec_prepare':
>> arch/s390/kernel/machine_kexec.c:192:18: error: invalid use of undefined type 'struct kimage'
>> 192 | if (image->type == KEXEC_TYPE_CRASH)
>> | ^~
>> arch/s390/kernel/machine_kexec.c:192:28: error: 'KEXEC_TYPE_CRASH' undeclared (first use in
>> this function); did you mean 'KEXEC_ON_CRASH'?
>> 192 | if (image->type == KEXEC_TYPE_CRASH)
>> | ^~~~~~~~~~~~~~~~
>> | KEXEC_ON_CRASH
>> arch/s390/kernel/machine_kexec.c:192:28: note: each undeclared identifier is reported only once
>> for each function it appears in
>> arch/s390/kernel/machine_kexec.c:196:18: error: invalid use of undefined type 'struct kimage'
>> 196 | if (image->type != KEXEC_TYPE_DEFAULT)
>> | ^~
>> arch/s390/kernel/machine_kexec.c:196:28: error: 'KEXEC_TYPE_DEFAULT' undeclared (first use in
>> this function); did you mean 'KEXEC_ARCH_DEFAULT'?
>> 196 | if (image->type != KEXEC_TYPE_DEFAULT)
>> | ^~~~~~~~~~~~~~~~~~
>> | KEXEC_ARCH_DEFAULT
>> In file included from arch/s390/include/asm/thread_info.h:31,
>> from include/linux/thread_info.h:60,
>> from arch/s390/include/asm/preempt.h:6,
>> from include/linux/preempt.h:79,
>> from arch/s390/include/asm/percpu.h:5,
>> from include/linux/irqflags.h:18,
>> from include/linux/rcupdate.h:26,
>> from include/linux/rculist.h:11,
>> from include/linux/pid.h:5,
>> from include/linux/sched.h:14,
>> from include/linux/ratelimit.h:6,
>> from include/linux/dev_printk.h:16,
>> from include/linux/device.h:15,
>> from arch/s390/kernel/machine_kexec.c:9:
>> arch/s390/kernel/machine_kexec.c:200:48: error: invalid use of undefined type 'struct kimage'
>> 200 | reboot_code_buffer = page_to_virt(image->control_code_page);
>> | ^~
>> arch/s390/include/asm/page.h:186:58: note: in definition of macro '__va'
>> 186 | #define __va(x) ((void *)(unsigned long)(x))
>> | ^
>> arch/s390/include/asm/page.h:194:38: note: in expansion of macro 'pfn_to_phys'
>> 194 | #define pfn_to_virt(pfn) __va(pfn_to_phys(pfn))
>> | ^~~~~~~~~~~
>> arch/s390/include/asm/page.h:199:33: note: in expansion of macro 'pfn_to_virt'
>> 199 | #define page_to_virt(page) pfn_to_virt(page_to_pfn(page))
>> | ^~~~~~~~~~~
>> include/asm-generic/memory_model.h:64:21: note: in expansion of macro '__page_to_pfn'
>> 64 | #define page_to_pfn __page_to_pfn
>> | ^~~~~~~~~~~~~
>> arch/s390/kernel/machine_kexec.c:200:30: note: in expansion of macro 'page_to_virt'
>> 200 | reboot_code_buffer = page_to_virt(image->control_code_page);
>> | ^~~~~~~~~~~~
>> arch/s390/kernel/machine_kexec.c: At top level:
>> arch/s390/kernel/machine_kexec.c:207:35: warning: 'struct kimage' declared inside parameter
>> list will not be visible outside of this definition or declaration
>> 207 | void machine_kexec_cleanup(struct kimage *image)
>> | ^~~~~~
>> arch/s390/kernel/machine_kexec.c: In function '__do_machine_kexec':
>> arch/s390/kernel/machine_kexec.c:243:40: error: invalid use of undefined type 'struct kimage'
>> 243 | data_mover = page_to_phys(image->control_code_page);
>> | ^~
>> arch/s390/include/asm/page.h:189:35: note: in definition of macro 'pfn_to_phys'
>> 189 | #define pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT)
>> | ^~~
>> include/asm-generic/memory_model.h:64:21: note: in expansion of macro '__page_to_pfn'
>> 64 | #define page_to_pfn __page_to_pfn
>> | ^~~~~~~~~~~~~
>> arch/s390/kernel/machine_kexec.c:243:22: note: in expansion of macro 'page_to_phys'
>> 243 | data_mover = page_to_phys(image->control_code_page);
>> | ^~~~~~~~~~~~
>> arch/s390/kernel/machine_kexec.c:244:36: error: invalid use of undefined type 'struct kimage'
>> 244 | entry = virt_to_phys(&image->head);
>> | ^~
>> In file included from arch/s390/kernel/machine_kexec.c:27:
>> arch/s390/kernel/machine_kexec.c:252:40: error: invalid use of undefined type 'struct kimage'
>> 252 | unsigned long, image->start,
>> | ^~
>> arch/s390/include/asm/stacktrace.h:101:32: note: in definition of macro 'CALL_LARGS_2'
>> 101 | long arg2 = (long)(t2)(a2)
>> | ^~
>> arch/s390/include/asm/stacktrace.h:216:9: note: in expansion of macro 'CALL_LARGS_3'
>> 216 | CALL_LARGS_##nr(__VA_ARGS__); \
>> | ^~~~~~~~~~~
>> arch/s390/kernel/machine_kexec.c:250:9: note: in expansion of macro 'call_nodat'
>> 250 | call_nodat(3, void, (relocate_kernel_t)data_mover,
>> | ^~~~~~~~~~
>> In file included from include/linux/irqflags.h:15:
>> arch/s390/kernel/machine_kexec.c:252:40: error: invalid use of undefined type 'struct kimage'
>> 252 | unsigned long, image->start,
>> | ^~
>> include/linux/typecheck.h:11:16: note: in definition of macro 'typecheck'
>> 11 | typeof(x) __dummy2; \
>> | ^
>> arch/s390/include/asm/stacktrace.h:136:9: note: in expansion of macro 'CALL_TYPECHECK_2'
>> 136 | CALL_TYPECHECK_2(__VA_ARGS__); \
>> | ^~~~~~~~~~~~~~~~
>> arch/s390/include/asm/stacktrace.h:219:9: note: in expansion of macro 'CALL_TYPECHECK_3'
>> 219 | CALL_TYPECHECK_##nr(__VA_ARGS__); \
>> | ^~~~~~~~~~~~~~~
>> arch/s390/kernel/machine_kexec.c:250:9: note: in expansion of macro 'call_nodat'
>> 250 | call_nodat(3, void, (relocate_kernel_t)data_mover,
>> | ^~~~~~~~~~
>> include/linux/typecheck.h:12:25: warning: comparison of distinct pointer types lacks a cast
>> 12 | (void)(&__dummy == &__dummy2); \
>> | ^~
>> arch/s390/include/asm/stacktrace.h:134:9: note: in expansion of macro 'typecheck'
>> 134 | typecheck(t, a)
>> | ^~~~~~~~~
>> arch/s390/include/asm/stacktrace.h:136:9: note: in expansion of macro 'CALL_TYPECHECK_2'
>> 136 | CALL_TYPECHECK_2(__VA_ARGS__); \
>> | ^~~~~~~~~~~~~~~~
>> arch/s390/include/asm/stacktrace.h:219:9: note: in expansion of macro 'CALL_TYPECHECK_3'
>> 219 | CALL_TYPECHECK_##nr(__VA_ARGS__); \
>> | ^~~~~~~~~~~~~~~
>> arch/s390/kernel/machine_kexec.c:250:9: note: in expansion of macro 'call_nodat'
>> 250 | call_nodat(3, void, (relocate_kernel_t)data_mover,
>> | ^~~~~~~~~~
>> arch/s390/kernel/machine_kexec.c: At top level:
>> arch/s390/kernel/machine_kexec.c:278:27: warning: 'struct kimage' declared inside parameter
>> list will not be visible outside of this definition or declaration
>> 278 | void machine_kexec(struct kimage *image)
>> | ^~~~~~
>> arch/s390/kernel/machine_kexec.c: In function 'machine_kexec':
>> arch/s390/kernel/machine_kexec.c:280:18: error: invalid use of undefined type 'struct kimage'
>> 280 | if (image->type == KEXEC_TYPE_CRASH && !kdump_csum_valid(image))
>> | ^~
>> arch/s390/kernel/machine_kexec.c:280:28: error: 'KEXEC_TYPE_CRASH' undeclared (first use in
>> this function); did you mean 'KEXEC_ON_CRASH'?
>> 280 | if (image->type == KEXEC_TYPE_CRASH && !kdump_csum_valid(image))
>> | ^~~~~~~~~~~~~~~~
>> | KEXEC_ON_CRASH
>> arch/s390/kernel/machine_kexec.c:280:66: error: passing argument 1 of 'kdump_csum_valid' from
>> incompatible pointer type [-Werror=incompatible-pointer-types]
>> 280 | if (image->type == KEXEC_TYPE_CRASH && !kdump_csum_valid(image))
>> | ^~~~~
>> | |
>> | struct kimage *
>> arch/s390/kernel/machine_kexec.c:120:45: note: expected 'struct kimage *' but argument is of
>> type 'struct kimage *'
>> 120 | static bool kdump_csum_valid(struct kimage *image)
>> | ~~~~~~~~~~~~~~~^~~~~
>> cc1: some warnings being treated as errors
>>
>> I don't think this change is equivalent for s390, which had
>>
>> config KEXEC
>> def_bool y
>> select KEXEC_CORE
>>
>> but it is now the equivalent of
>>
>> config KEXEC
>> bool "Enable kexec system call"
>> default y
>>
>> which enables KEXEC by default but it also allows KEXEC to be disabled
>> for s390 now, because it is a user-visible symbol, not one that is
>> unconditionally enabled no matter what. If s390 can tolerate KEXEC being
>> user selectable, then I assume the fix is just adjusting
>> arch/s390/kernel/Makefile to only build the machine_kexec files when
>> CONFIG_KEXEC_CORE is set:
>>
>> diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
>> index 6b2a051e1f8a..a06b39da95f0 100644
>> --- a/arch/s390/kernel/Makefile
>> +++ b/arch/s390/kernel/Makefile
>> @@ -37,10 +37,10 @@ CFLAGS_unwind_bc.o += -fno-optimize-sibling-calls
>> obj-y := head64.o traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtime.o
>> obj-y += processor.o syscall.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
>> obj-y += debug.o irq.o ipl.o dis.o diag.o vdso.o cpufeature.o
>> -obj-y += sysinfo.o lgr.o os_info.o machine_kexec.o
>> +obj-y += sysinfo.o lgr.o os_info.o
>> obj-y += runtime_instr.o cache.o fpu.o dumpstack.o guarded_storage.o sthyi.o
>> obj-y += entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o
>> -obj-y += nospec-branch.o ipl_vmparm.o machine_kexec_reloc.o unwind_bc.o
>> +obj-y += nospec-branch.o ipl_vmparm.o unwind_bc.o
>> obj-y += smp.o text_amode31.o stacktrace.o abs_lowcore.o
>> extra-y += vmlinux.lds
>> @@ -66,6 +66,7 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
>> obj-$(CONFIG_UPROBES) += uprobes.o
>> obj-$(CONFIG_JUMP_LABEL) += jump_label.o
>> +obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o machine_kexec_reloc.o
>> obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_image.o
>> obj-$(CONFIG_KEXEC_FILE) += kexec_elf.o
>>
>> Otherwise, the prompt for KEXEC could be made conditional on some ARCH
>> symbol so that architectures can opt out of it.
>
> Nathan,
> Thanks for looking at this! I've been receiving broken build info from Andrew's
> machinery. I've investigated and learned that CRASH_DUMP can be specified without
> KEXEC. I also realized that s390 originally had this right, but in the conversion
> I did, I got it wrong.
>
> This v4 series corrects that by having CRASH_DUMP select KEXEC.
>
> The new KEXEC looks like:
>
> config KEXEC
> bool "Enable kexec system call"
> default ARCH_DEFAULT_KEXEC
> depends on ARCH_SUPPORTS_KEXEC
> select KEXEC_CORE
>
> which appears to be equivalent, I think the CRASH_DUMP issue is the root problem.
>
> In a separate thread with Arnd Bergmann wrt/ arm build issues, he identifies
> similar problems&solutions as you did, but points out that CRASH_DUMP might still
> need some refinement; I'm looking into that.
>
> The goal really is to make this series to result in equivalent configs as before,
> but there are small problems in the conversion that are showing up that I'm working.
Nathan,
Thanks again for looking at this! Your feedback made me realize that relying on
'olddefconfig' for equivalence has proven to be inadequate. As a result, I've
retooled my testing environment to use olddefconfig, allnoconfig and allyesconfig.
That enhancement has revealed a small number of issues, which I have now fixed.
I'll be posting a v5 once I've worked through all architecture results.
Thanks again!
eric
>
>
>>
>> As an aside, is this intended for the 6.5 merge window? If not, it
>> shouldn't be in -next at this point, I was surprised to see new broken
>> builds.
>>
>> Cheers,
>> Nathan
> I'm not going to pretend I know when this will make it...
> eric
On Wed, Jul 5, 2023, at 16:19, Eric DeVolder wrote:
> +
> +config CRASH_DUMP
> + bool "kernel crash dumps"
> + depends on ARCH_SUPPORTS_CRASH_DUMP
> + select CRASH_CORE
> + select KEXEC
Today's linux-next now runs into a warning on arm64 and
presumably others, with the same problem as on arm earlier:
WARNING: unmet direct dependencies detected for KEXEC
Depends on [n]: ARCH_SUPPORTS_KEXEC [=n]
Selected by [y]:
- CRASH_DUMP [=y] && ARCH_SUPPORTS_CRASH_DUMP [=y]
I think the easiest way to make this reliable would be
this fixup:
diff --git a/kernel/Kconfig.kexec b/kernel/Kconfig.kexec
index d82a7ce59c051..e58ca6128d6ee 100644
--- a/kernel/Kconfig.kexec
+++ b/kernel/Kconfig.kexec
@@ -91,6 +91,7 @@ config KEXEC_JUMP
config CRASH_DUMP
bool "kernel crash dumps"
depends on ARCH_SUPPORTS_CRASH_DUMP
+ depends on ARCH_SUPPORTS_KEXEC
select CRASH_CORE
select KEXEC
help
Arnd
On 7/6/23 07:18, Arnd Bergmann wrote:
> On Wed, Jul 5, 2023, at 16:19, Eric DeVolder wrote:
>> +
>> +config CRASH_DUMP
>> + bool "kernel crash dumps"
>> + depends on ARCH_SUPPORTS_CRASH_DUMP
>> + select CRASH_CORE
>> + select KEXEC
>
> Today's linux-next now runs into a warning on arm64 and
> presumably others, with the same problem as on arm earlier:
>
> WARNING: unmet direct dependencies detected for KEXEC
> Depends on [n]: ARCH_SUPPORTS_KEXEC [=n]
> Selected by [y]:
> - CRASH_DUMP [=y] && ARCH_SUPPORTS_CRASH_DUMP [=y]
>
> I think the easiest way to make this reliable would be
> this fixup:
>
> diff --git a/kernel/Kconfig.kexec b/kernel/Kconfig.kexec
> index d82a7ce59c051..e58ca6128d6ee 100644
> --- a/kernel/Kconfig.kexec
> +++ b/kernel/Kconfig.kexec
> @@ -91,6 +91,7 @@ config KEXEC_JUMP
> config CRASH_DUMP
> bool "kernel crash dumps"
> depends on ARCH_SUPPORTS_CRASH_DUMP
> + depends on ARCH_SUPPORTS_KEXEC
> select CRASH_CORE
> select KEXEC
> help
>
> Arnd
Will do, thanks!
I changed my testing to include allnoconfig and allyesconfig and that revealed some minor issues as
well. Almost there!
eric
On Wed, Jul 05, 2023 at 08:49:58AM -0700, Nathan Chancellor wrote:
...
> I just bisected the following build failure visible with 'ARCH=s390
> allnoconfig' to this change as commit 842ce0e1dafa ("s390/kexec:
> refactor for kernel/Kconfig.kexec") in -next.
>
> arch/s390/kernel/machine_kexec.c:120:37: warning: 'struct kimage' declared inside parameter list will not be visible outside of this definition or declaration
> 120 | static bool kdump_csum_valid(struct kimage *image)
> | ^~~~~~
> arch/s390/kernel/machine_kexec.c:188:34: warning: 'struct kimage' declared inside parameter list will not be visible outside of this definition or declaration
> 188 | int machine_kexec_prepare(struct kimage *image)
> | ^~~~~~
> arch/s390/kernel/machine_kexec.c: In function 'machine_kexec_prepare':
> arch/s390/kernel/machine_kexec.c:192:18: error: invalid use of undefined type 'struct kimage'
> 192 | if (image->type == KEXEC_TYPE_CRASH)
> | ^~
> arch/s390/kernel/machine_kexec.c:192:28: error: 'KEXEC_TYPE_CRASH' undeclared (first use in this function); did you mean 'KEXEC_ON_CRASH'?
> 192 | if (image->type == KEXEC_TYPE_CRASH)
> | ^~~~~~~~~~~~~~~~
> | KEXEC_ON_CRASH
> arch/s390/kernel/machine_kexec.c:192:28: note: each undeclared identifier is reported only once for each function it appears in
> arch/s390/kernel/machine_kexec.c:196:18: error: invalid use of undefined type 'struct kimage'
> 196 | if (image->type != KEXEC_TYPE_DEFAULT)
> | ^~
> arch/s390/kernel/machine_kexec.c:196:28: error: 'KEXEC_TYPE_DEFAULT' undeclared (first use in this function); did you mean 'KEXEC_ARCH_DEFAULT'?
> 196 | if (image->type != KEXEC_TYPE_DEFAULT)
> | ^~~~~~~~~~~~~~~~~~
> | KEXEC_ARCH_DEFAULT
> In file included from arch/s390/include/asm/thread_info.h:31,
> from include/linux/thread_info.h:60,
> from arch/s390/include/asm/preempt.h:6,
> from include/linux/preempt.h:79,
> from arch/s390/include/asm/percpu.h:5,
> from include/linux/irqflags.h:18,
> from include/linux/rcupdate.h:26,
> from include/linux/rculist.h:11,
> from include/linux/pid.h:5,
> from include/linux/sched.h:14,
> from include/linux/ratelimit.h:6,
> from include/linux/dev_printk.h:16,
> from include/linux/device.h:15,
> from arch/s390/kernel/machine_kexec.c:9:
> arch/s390/kernel/machine_kexec.c:200:48: error: invalid use of undefined type 'struct kimage'
> 200 | reboot_code_buffer = page_to_virt(image->control_code_page);
> | ^~
> arch/s390/include/asm/page.h:186:58: note: in definition of macro '__va'
> 186 | #define __va(x) ((void *)(unsigned long)(x))
> | ^
> arch/s390/include/asm/page.h:194:38: note: in expansion of macro 'pfn_to_phys'
> 194 | #define pfn_to_virt(pfn) __va(pfn_to_phys(pfn))
> | ^~~~~~~~~~~
> arch/s390/include/asm/page.h:199:33: note: in expansion of macro 'pfn_to_virt'
> 199 | #define page_to_virt(page) pfn_to_virt(page_to_pfn(page))
> | ^~~~~~~~~~~
> include/asm-generic/memory_model.h:64:21: note: in expansion of macro '__page_to_pfn'
> 64 | #define page_to_pfn __page_to_pfn
> | ^~~~~~~~~~~~~
> arch/s390/kernel/machine_kexec.c:200:30: note: in expansion of macro 'page_to_virt'
> 200 | reboot_code_buffer = page_to_virt(image->control_code_page);
> | ^~~~~~~~~~~~
> arch/s390/kernel/machine_kexec.c: At top level:
> arch/s390/kernel/machine_kexec.c:207:35: warning: 'struct kimage' declared inside parameter list will not be visible outside of this definition or declaration
> 207 | void machine_kexec_cleanup(struct kimage *image)
> | ^~~~~~
> arch/s390/kernel/machine_kexec.c: In function '__do_machine_kexec':
> arch/s390/kernel/machine_kexec.c:243:40: error: invalid use of undefined type 'struct kimage'
> 243 | data_mover = page_to_phys(image->control_code_page);
> | ^~
> arch/s390/include/asm/page.h:189:35: note: in definition of macro 'pfn_to_phys'
> 189 | #define pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT)
> | ^~~
> include/asm-generic/memory_model.h:64:21: note: in expansion of macro '__page_to_pfn'
> 64 | #define page_to_pfn __page_to_pfn
> | ^~~~~~~~~~~~~
> arch/s390/kernel/machine_kexec.c:243:22: note: in expansion of macro 'page_to_phys'
> 243 | data_mover = page_to_phys(image->control_code_page);
> | ^~~~~~~~~~~~
> arch/s390/kernel/machine_kexec.c:244:36: error: invalid use of undefined type 'struct kimage'
> 244 | entry = virt_to_phys(&image->head);
> | ^~
> In file included from arch/s390/kernel/machine_kexec.c:27:
> arch/s390/kernel/machine_kexec.c:252:40: error: invalid use of undefined type 'struct kimage'
> 252 | unsigned long, image->start,
> | ^~
> arch/s390/include/asm/stacktrace.h:101:32: note: in definition of macro 'CALL_LARGS_2'
> 101 | long arg2 = (long)(t2)(a2)
> | ^~
> arch/s390/include/asm/stacktrace.h:216:9: note: in expansion of macro 'CALL_LARGS_3'
> 216 | CALL_LARGS_##nr(__VA_ARGS__); \
> | ^~~~~~~~~~~
> arch/s390/kernel/machine_kexec.c:250:9: note: in expansion of macro 'call_nodat'
> 250 | call_nodat(3, void, (relocate_kernel_t)data_mover,
> | ^~~~~~~~~~
> In file included from include/linux/irqflags.h:15:
> arch/s390/kernel/machine_kexec.c:252:40: error: invalid use of undefined type 'struct kimage'
> 252 | unsigned long, image->start,
> | ^~
> include/linux/typecheck.h:11:16: note: in definition of macro 'typecheck'
> 11 | typeof(x) __dummy2; \
> | ^
> arch/s390/include/asm/stacktrace.h:136:9: note: in expansion of macro 'CALL_TYPECHECK_2'
> 136 | CALL_TYPECHECK_2(__VA_ARGS__); \
> | ^~~~~~~~~~~~~~~~
> arch/s390/include/asm/stacktrace.h:219:9: note: in expansion of macro 'CALL_TYPECHECK_3'
> 219 | CALL_TYPECHECK_##nr(__VA_ARGS__); \
> | ^~~~~~~~~~~~~~~
> arch/s390/kernel/machine_kexec.c:250:9: note: in expansion of macro 'call_nodat'
> 250 | call_nodat(3, void, (relocate_kernel_t)data_mover,
> | ^~~~~~~~~~
> include/linux/typecheck.h:12:25: warning: comparison of distinct pointer types lacks a cast
> 12 | (void)(&__dummy == &__dummy2); \
> | ^~
> arch/s390/include/asm/stacktrace.h:134:9: note: in expansion of macro 'typecheck'
> 134 | typecheck(t, a)
> | ^~~~~~~~~
> arch/s390/include/asm/stacktrace.h:136:9: note: in expansion of macro 'CALL_TYPECHECK_2'
> 136 | CALL_TYPECHECK_2(__VA_ARGS__); \
> | ^~~~~~~~~~~~~~~~
> arch/s390/include/asm/stacktrace.h:219:9: note: in expansion of macro 'CALL_TYPECHECK_3'
> 219 | CALL_TYPECHECK_##nr(__VA_ARGS__); \
> | ^~~~~~~~~~~~~~~
> arch/s390/kernel/machine_kexec.c:250:9: note: in expansion of macro 'call_nodat'
> 250 | call_nodat(3, void, (relocate_kernel_t)data_mover,
> | ^~~~~~~~~~
> arch/s390/kernel/machine_kexec.c: At top level:
> arch/s390/kernel/machine_kexec.c:278:27: warning: 'struct kimage' declared inside parameter list will not be visible outside of this definition or declaration
> 278 | void machine_kexec(struct kimage *image)
> | ^~~~~~
> arch/s390/kernel/machine_kexec.c: In function 'machine_kexec':
> arch/s390/kernel/machine_kexec.c:280:18: error: invalid use of undefined type 'struct kimage'
> 280 | if (image->type == KEXEC_TYPE_CRASH && !kdump_csum_valid(image))
> | ^~
> arch/s390/kernel/machine_kexec.c:280:28: error: 'KEXEC_TYPE_CRASH' undeclared (first use in this function); did you mean 'KEXEC_ON_CRASH'?
> 280 | if (image->type == KEXEC_TYPE_CRASH && !kdump_csum_valid(image))
> | ^~~~~~~~~~~~~~~~
> | KEXEC_ON_CRASH
> arch/s390/kernel/machine_kexec.c:280:66: error: passing argument 1 of 'kdump_csum_valid' from incompatible pointer type [-Werror=incompatible-pointer-types]
> 280 | if (image->type == KEXEC_TYPE_CRASH && !kdump_csum_valid(image))
> | ^~~~~
> | |
> | struct kimage *
> arch/s390/kernel/machine_kexec.c:120:45: note: expected 'struct kimage *' but argument is of type 'struct kimage *'
> 120 | static bool kdump_csum_valid(struct kimage *image)
> | ~~~~~~~~~~~~~~~^~~~~
> cc1: some warnings being treated as errors
>
> I don't think this change is equivalent for s390, which had
>
> config KEXEC
> def_bool y
> select KEXEC_CORE
>
> but it is now the equivalent of
>
> config KEXEC
> bool "Enable kexec system call"
> default y
>
> which enables KEXEC by default but it also allows KEXEC to be disabled
> for s390 now, because it is a user-visible symbol, not one that is
> unconditionally enabled no matter what. If s390 can tolerate KEXEC being
> user selectable, then I assume the fix is just adjusting
> arch/s390/kernel/Makefile to only build the machine_kexec files when
> CONFIG_KEXEC_CORE is set:
>
> diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
> index 6b2a051e1f8a..a06b39da95f0 100644
> --- a/arch/s390/kernel/Makefile
> +++ b/arch/s390/kernel/Makefile
> @@ -37,10 +37,10 @@ CFLAGS_unwind_bc.o += -fno-optimize-sibling-calls
> obj-y := head64.o traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtime.o
> obj-y += processor.o syscall.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
> obj-y += debug.o irq.o ipl.o dis.o diag.o vdso.o cpufeature.o
> -obj-y += sysinfo.o lgr.o os_info.o machine_kexec.o
> +obj-y += sysinfo.o lgr.o os_info.o
> obj-y += runtime_instr.o cache.o fpu.o dumpstack.o guarded_storage.o sthyi.o
> obj-y += entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o
> -obj-y += nospec-branch.o ipl_vmparm.o machine_kexec_reloc.o unwind_bc.o
> +obj-y += nospec-branch.o ipl_vmparm.o unwind_bc.o
> obj-y += smp.o text_amode31.o stacktrace.o abs_lowcore.o
>
> extra-y += vmlinux.lds
> @@ -66,6 +66,7 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
> obj-$(CONFIG_UPROBES) += uprobes.o
> obj-$(CONFIG_JUMP_LABEL) += jump_label.o
>
> +obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o machine_kexec_reloc.o
> obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_image.o
> obj-$(CONFIG_KEXEC_FILE) += kexec_elf.o
>
>
> Otherwise, the prompt for KEXEC could be made conditional on some ARCH
> symbol so that architectures can opt out of it.
Hi Nathan,
Thanks a lot for looking into it!
With few modification the fix would looke like below.
It probably needs to be a pre-requisite for this series:
[PATCH] s390/kexec: make machine_kexec depend on CONFIG_KEXEC_CORE
Make machine_kexec.o and relocate_kernel.o depend on
CONFIG_KEXEC_CORE option as other architectures do.
Still generate machine_kexec_reloc.o unconditionally,
since arch_kexec_do_relocs() function is neded by the
decompressor.
Probably, #include <asm/kexec.h> could be be removed from
machine_kexec_reloc.c source as well, but that would revert
commit 155e6c706125 ("s390/kexec: add missing include to
machine_kexec_reloc.c").
Suggested-by: Nathan Chancellor <[email protected]>
Reported-by: Nathan Chancellor <[email protected]>
Reported-by: Linux Kernel Functional Testing <[email protected]>
Signed-off-by: Alexander Gordeev <[email protected]>
---
arch/s390/kernel/Makefile | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
index 8d7514c72bb8..0df2b88cc0da 100644
--- a/arch/s390/kernel/Makefile
+++ b/arch/s390/kernel/Makefile
@@ -37,9 +37,9 @@ CFLAGS_unwind_bc.o += -fno-optimize-sibling-calls
obj-y := head64.o traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtime.o
obj-y += processor.o syscall.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
obj-y += debug.o irq.o ipl.o dis.o diag.o vdso.o cpufeature.o
-obj-y += sysinfo.o lgr.o os_info.o machine_kexec.o
+obj-y += sysinfo.o lgr.o os_info.o
obj-y += runtime_instr.o cache.o fpu.o dumpstack.o guarded_storage.o sthyi.o
-obj-y += entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o
+obj-y += entry.o reipl.o kdebugfs.o alternative.o
obj-y += nospec-branch.o ipl_vmparm.o machine_kexec_reloc.o unwind_bc.o
obj-y += smp.o text_amode31.o stacktrace.o abs_lowcore.o
@@ -63,6 +63,7 @@ obj-$(CONFIG_RETHOOK) += rethook.o
obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o
obj-$(CONFIG_FUNCTION_TRACER) += mcount.o
obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
+obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o relocate_kernel.o
obj-$(CONFIG_UPROBES) += uprobes.o
obj-$(CONFIG_JUMP_LABEL) += jump_label.o
> Cheers,
> Nathan
Thanks!
On 7/6/23 10:58, Alexander Gordeev wrote:
> On Wed, Jul 05, 2023 at 08:49:58AM -0700, Nathan Chancellor wrote:
> ...
>> I just bisected the following build failure visible with 'ARCH=s390
>> allnoconfig' to this change as commit 842ce0e1dafa ("s390/kexec:
>> refactor for kernel/Kconfig.kexec") in -next.
>>
>> arch/s390/kernel/machine_kexec.c:120:37: warning: 'struct kimage' declared inside parameter list will not be visible outside of this definition or declaration
>> 120 | static bool kdump_csum_valid(struct kimage *image)
>> | ^~~~~~
>> arch/s390/kernel/machine_kexec.c:188:34: warning: 'struct kimage' declared inside parameter list will not be visible outside of this definition or declaration
>> 188 | int machine_kexec_prepare(struct kimage *image)
>> | ^~~~~~
>> arch/s390/kernel/machine_kexec.c: In function 'machine_kexec_prepare':
>> arch/s390/kernel/machine_kexec.c:192:18: error: invalid use of undefined type 'struct kimage'
>> 192 | if (image->type == KEXEC_TYPE_CRASH)
>> | ^~
>> arch/s390/kernel/machine_kexec.c:192:28: error: 'KEXEC_TYPE_CRASH' undeclared (first use in this function); did you mean 'KEXEC_ON_CRASH'?
>> 192 | if (image->type == KEXEC_TYPE_CRASH)
>> | ^~~~~~~~~~~~~~~~
>> | KEXEC_ON_CRASH
>> arch/s390/kernel/machine_kexec.c:192:28: note: each undeclared identifier is reported only once for each function it appears in
>> arch/s390/kernel/machine_kexec.c:196:18: error: invalid use of undefined type 'struct kimage'
>> 196 | if (image->type != KEXEC_TYPE_DEFAULT)
>> | ^~
>> arch/s390/kernel/machine_kexec.c:196:28: error: 'KEXEC_TYPE_DEFAULT' undeclared (first use in this function); did you mean 'KEXEC_ARCH_DEFAULT'?
>> 196 | if (image->type != KEXEC_TYPE_DEFAULT)
>> | ^~~~~~~~~~~~~~~~~~
>> | KEXEC_ARCH_DEFAULT
>> In file included from arch/s390/include/asm/thread_info.h:31,
>> from include/linux/thread_info.h:60,
>> from arch/s390/include/asm/preempt.h:6,
>> from include/linux/preempt.h:79,
>> from arch/s390/include/asm/percpu.h:5,
>> from include/linux/irqflags.h:18,
>> from include/linux/rcupdate.h:26,
>> from include/linux/rculist.h:11,
>> from include/linux/pid.h:5,
>> from include/linux/sched.h:14,
>> from include/linux/ratelimit.h:6,
>> from include/linux/dev_printk.h:16,
>> from include/linux/device.h:15,
>> from arch/s390/kernel/machine_kexec.c:9:
>> arch/s390/kernel/machine_kexec.c:200:48: error: invalid use of undefined type 'struct kimage'
>> 200 | reboot_code_buffer = page_to_virt(image->control_code_page);
>> | ^~
>> arch/s390/include/asm/page.h:186:58: note: in definition of macro '__va'
>> 186 | #define __va(x) ((void *)(unsigned long)(x))
>> | ^
>> arch/s390/include/asm/page.h:194:38: note: in expansion of macro 'pfn_to_phys'
>> 194 | #define pfn_to_virt(pfn) __va(pfn_to_phys(pfn))
>> | ^~~~~~~~~~~
>> arch/s390/include/asm/page.h:199:33: note: in expansion of macro 'pfn_to_virt'
>> 199 | #define page_to_virt(page) pfn_to_virt(page_to_pfn(page))
>> | ^~~~~~~~~~~
>> include/asm-generic/memory_model.h:64:21: note: in expansion of macro '__page_to_pfn'
>> 64 | #define page_to_pfn __page_to_pfn
>> | ^~~~~~~~~~~~~
>> arch/s390/kernel/machine_kexec.c:200:30: note: in expansion of macro 'page_to_virt'
>> 200 | reboot_code_buffer = page_to_virt(image->control_code_page);
>> | ^~~~~~~~~~~~
>> arch/s390/kernel/machine_kexec.c: At top level:
>> arch/s390/kernel/machine_kexec.c:207:35: warning: 'struct kimage' declared inside parameter list will not be visible outside of this definition or declaration
>> 207 | void machine_kexec_cleanup(struct kimage *image)
>> | ^~~~~~
>> arch/s390/kernel/machine_kexec.c: In function '__do_machine_kexec':
>> arch/s390/kernel/machine_kexec.c:243:40: error: invalid use of undefined type 'struct kimage'
>> 243 | data_mover = page_to_phys(image->control_code_page);
>> | ^~
>> arch/s390/include/asm/page.h:189:35: note: in definition of macro 'pfn_to_phys'
>> 189 | #define pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT)
>> | ^~~
>> include/asm-generic/memory_model.h:64:21: note: in expansion of macro '__page_to_pfn'
>> 64 | #define page_to_pfn __page_to_pfn
>> | ^~~~~~~~~~~~~
>> arch/s390/kernel/machine_kexec.c:243:22: note: in expansion of macro 'page_to_phys'
>> 243 | data_mover = page_to_phys(image->control_code_page);
>> | ^~~~~~~~~~~~
>> arch/s390/kernel/machine_kexec.c:244:36: error: invalid use of undefined type 'struct kimage'
>> 244 | entry = virt_to_phys(&image->head);
>> | ^~
>> In file included from arch/s390/kernel/machine_kexec.c:27:
>> arch/s390/kernel/machine_kexec.c:252:40: error: invalid use of undefined type 'struct kimage'
>> 252 | unsigned long, image->start,
>> | ^~
>> arch/s390/include/asm/stacktrace.h:101:32: note: in definition of macro 'CALL_LARGS_2'
>> 101 | long arg2 = (long)(t2)(a2)
>> | ^~
>> arch/s390/include/asm/stacktrace.h:216:9: note: in expansion of macro 'CALL_LARGS_3'
>> 216 | CALL_LARGS_##nr(__VA_ARGS__); \
>> | ^~~~~~~~~~~
>> arch/s390/kernel/machine_kexec.c:250:9: note: in expansion of macro 'call_nodat'
>> 250 | call_nodat(3, void, (relocate_kernel_t)data_mover,
>> | ^~~~~~~~~~
>> In file included from include/linux/irqflags.h:15:
>> arch/s390/kernel/machine_kexec.c:252:40: error: invalid use of undefined type 'struct kimage'
>> 252 | unsigned long, image->start,
>> | ^~
>> include/linux/typecheck.h:11:16: note: in definition of macro 'typecheck'
>> 11 | typeof(x) __dummy2; \
>> | ^
>> arch/s390/include/asm/stacktrace.h:136:9: note: in expansion of macro 'CALL_TYPECHECK_2'
>> 136 | CALL_TYPECHECK_2(__VA_ARGS__); \
>> | ^~~~~~~~~~~~~~~~
>> arch/s390/include/asm/stacktrace.h:219:9: note: in expansion of macro 'CALL_TYPECHECK_3'
>> 219 | CALL_TYPECHECK_##nr(__VA_ARGS__); \
>> | ^~~~~~~~~~~~~~~
>> arch/s390/kernel/machine_kexec.c:250:9: note: in expansion of macro 'call_nodat'
>> 250 | call_nodat(3, void, (relocate_kernel_t)data_mover,
>> | ^~~~~~~~~~
>> include/linux/typecheck.h:12:25: warning: comparison of distinct pointer types lacks a cast
>> 12 | (void)(&__dummy == &__dummy2); \
>> | ^~
>> arch/s390/include/asm/stacktrace.h:134:9: note: in expansion of macro 'typecheck'
>> 134 | typecheck(t, a)
>> | ^~~~~~~~~
>> arch/s390/include/asm/stacktrace.h:136:9: note: in expansion of macro 'CALL_TYPECHECK_2'
>> 136 | CALL_TYPECHECK_2(__VA_ARGS__); \
>> | ^~~~~~~~~~~~~~~~
>> arch/s390/include/asm/stacktrace.h:219:9: note: in expansion of macro 'CALL_TYPECHECK_3'
>> 219 | CALL_TYPECHECK_##nr(__VA_ARGS__); \
>> | ^~~~~~~~~~~~~~~
>> arch/s390/kernel/machine_kexec.c:250:9: note: in expansion of macro 'call_nodat'
>> 250 | call_nodat(3, void, (relocate_kernel_t)data_mover,
>> | ^~~~~~~~~~
>> arch/s390/kernel/machine_kexec.c: At top level:
>> arch/s390/kernel/machine_kexec.c:278:27: warning: 'struct kimage' declared inside parameter list will not be visible outside of this definition or declaration
>> 278 | void machine_kexec(struct kimage *image)
>> | ^~~~~~
>> arch/s390/kernel/machine_kexec.c: In function 'machine_kexec':
>> arch/s390/kernel/machine_kexec.c:280:18: error: invalid use of undefined type 'struct kimage'
>> 280 | if (image->type == KEXEC_TYPE_CRASH && !kdump_csum_valid(image))
>> | ^~
>> arch/s390/kernel/machine_kexec.c:280:28: error: 'KEXEC_TYPE_CRASH' undeclared (first use in this function); did you mean 'KEXEC_ON_CRASH'?
>> 280 | if (image->type == KEXEC_TYPE_CRASH && !kdump_csum_valid(image))
>> | ^~~~~~~~~~~~~~~~
>> | KEXEC_ON_CRASH
>> arch/s390/kernel/machine_kexec.c:280:66: error: passing argument 1 of 'kdump_csum_valid' from incompatible pointer type [-Werror=incompatible-pointer-types]
>> 280 | if (image->type == KEXEC_TYPE_CRASH && !kdump_csum_valid(image))
>> | ^~~~~
>> | |
>> | struct kimage *
>> arch/s390/kernel/machine_kexec.c:120:45: note: expected 'struct kimage *' but argument is of type 'struct kimage *'
>> 120 | static bool kdump_csum_valid(struct kimage *image)
>> | ~~~~~~~~~~~~~~~^~~~~
>> cc1: some warnings being treated as errors
>>
>> I don't think this change is equivalent for s390, which had
>>
>> config KEXEC
>> def_bool y
>> select KEXEC_CORE
>>
>> but it is now the equivalent of
>>
>> config KEXEC
>> bool "Enable kexec system call"
>> default y
>>
>> which enables KEXEC by default but it also allows KEXEC to be disabled
>> for s390 now, because it is a user-visible symbol, not one that is
>> unconditionally enabled no matter what. If s390 can tolerate KEXEC being
>> user selectable, then I assume the fix is just adjusting
>> arch/s390/kernel/Makefile to only build the machine_kexec files when
>> CONFIG_KEXEC_CORE is set:
>>
>> diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
>> index 6b2a051e1f8a..a06b39da95f0 100644
>> --- a/arch/s390/kernel/Makefile
>> +++ b/arch/s390/kernel/Makefile
>> @@ -37,10 +37,10 @@ CFLAGS_unwind_bc.o += -fno-optimize-sibling-calls
>> obj-y := head64.o traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtime.o
>> obj-y += processor.o syscall.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
>> obj-y += debug.o irq.o ipl.o dis.o diag.o vdso.o cpufeature.o
>> -obj-y += sysinfo.o lgr.o os_info.o machine_kexec.o
>> +obj-y += sysinfo.o lgr.o os_info.o
>> obj-y += runtime_instr.o cache.o fpu.o dumpstack.o guarded_storage.o sthyi.o
>> obj-y += entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o
>> -obj-y += nospec-branch.o ipl_vmparm.o machine_kexec_reloc.o unwind_bc.o
>> +obj-y += nospec-branch.o ipl_vmparm.o unwind_bc.o
>> obj-y += smp.o text_amode31.o stacktrace.o abs_lowcore.o
>>
>> extra-y += vmlinux.lds
>> @@ -66,6 +66,7 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
>> obj-$(CONFIG_UPROBES) += uprobes.o
>> obj-$(CONFIG_JUMP_LABEL) += jump_label.o
>>
>> +obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o machine_kexec_reloc.o
>> obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_image.o
>> obj-$(CONFIG_KEXEC_FILE) += kexec_elf.o
>>
>>
>> Otherwise, the prompt for KEXEC could be made conditional on some ARCH
>> symbol so that architectures can opt out of it.
>
> Hi Nathan,
>
> Thanks a lot for looking into it!
> With few modification the fix would looke like below.
> It probably needs to be a pre-requisite for this series:
>
>
> [PATCH] s390/kexec: make machine_kexec depend on CONFIG_KEXEC_CORE
>
> Make machine_kexec.o and relocate_kernel.o depend on
> CONFIG_KEXEC_CORE option as other architectures do.
>
> Still generate machine_kexec_reloc.o unconditionally,
> since arch_kexec_do_relocs() function is neded by the
> decompressor.
>
> Probably, #include <asm/kexec.h> could be be removed from
> machine_kexec_reloc.c source as well, but that would revert
> commit 155e6c706125 ("s390/kexec: add missing include to
> machine_kexec_reloc.c").
>
> Suggested-by: Nathan Chancellor <[email protected]>
> Reported-by: Nathan Chancellor <[email protected]>
> Reported-by: Linux Kernel Functional Testing <[email protected]>
> Signed-off-by: Alexander Gordeev <[email protected]>
> ---
> arch/s390/kernel/Makefile | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
> index 8d7514c72bb8..0df2b88cc0da 100644
> --- a/arch/s390/kernel/Makefile
> +++ b/arch/s390/kernel/Makefile
> @@ -37,9 +37,9 @@ CFLAGS_unwind_bc.o += -fno-optimize-sibling-calls
> obj-y := head64.o traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtime.o
> obj-y += processor.o syscall.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
> obj-y += debug.o irq.o ipl.o dis.o diag.o vdso.o cpufeature.o
> -obj-y += sysinfo.o lgr.o os_info.o machine_kexec.o
> +obj-y += sysinfo.o lgr.o os_info.o
> obj-y += runtime_instr.o cache.o fpu.o dumpstack.o guarded_storage.o sthyi.o
> -obj-y += entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o
> +obj-y += entry.o reipl.o kdebugfs.o alternative.o
> obj-y += nospec-branch.o ipl_vmparm.o machine_kexec_reloc.o unwind_bc.o
> obj-y += smp.o text_amode31.o stacktrace.o abs_lowcore.o
>
> @@ -63,6 +63,7 @@ obj-$(CONFIG_RETHOOK) += rethook.o
> obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o
> obj-$(CONFIG_FUNCTION_TRACER) += mcount.o
> obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
> +obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o relocate_kernel.o
> obj-$(CONFIG_UPROBES) += uprobes.o
> obj-$(CONFIG_JUMP_LABEL) += jump_label.o
>
>> Cheers,
>> Nathan
>
> Thanks!
A bit of additional information. I've corrected the problem with s390 and now all config files pass
with the olddefconfig, allyesconfig and allnoconfig targets (using approach outlined in the cover
letter). What I did to resolve the last s390 problem is that I realized that KEXEC was
unconditionally set, so I did the same by adding 'select KEXEC' to the config S390 section.
I'm not saying you shouldn't do the above changes, but wanted to make you aware that we're attacking
the same problem...
I'm running my final regression run here (takes about 8 hours to get through all 385 now) and then I
hope to post v5 within a day.
Thanks,
eric