Skip to contentSkip to conversation

Make allmodconfig boot in qemu-arm64

RFC PATCH In review Anders Roxell 4 participants 13 messages Dec 13, 2018 – Jan 7, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover Make allmodconfig boot in qemu-arm64

Hi,

With this patch set I've been able to get a allmodconfig kernel to boot under qemu-system-aarch64.

The patch "config: provide a fragment to enable gdb for qemu" I found useful when trying to figure out how it fall over. So when I have to debug a kernel with gdb I just ran this:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -skj$(getconf
_NPROCESSORS_ONLN) O=obj-arm64-next-20181213 allmodconfig
kvm_guest.config qemu-gdb.config
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -skj$(getconf
_NPROCESSORS_ONLN) O=obj-arm64-next-20181213 Image

Before we do the same job on other architectures we wanted to reach out and ask to see if this seams a reasonable way forward ?

The end goal would be to be able to run test suites on a allmodconfig kernel. We may end up with another fragment that turn off/on a lot of debug options and selftests during boot up since that may cause issues for other test suites like kseftest, LTP and so on.

Cheers,
Anders

Anders Roxell (3):
config: provide a fragment to enable gdb for qemu lib/ubsan: default UBSAN_ALIGNMENT to not set
arm64: add a new config option KTEST_RUNNABLE

 arch/arm64/Kconfig             |  8 ++++++++
 drivers/tty/hvc/Kconfig        |  1 +
 init/Kconfig                   |  1 +
 kernel/configs/qemu-gdb.config |  7 +++++++
 lib/Kconfig.ubsan              | 14 +++++++++-----
 5 files changed, 26 insertions(+), 5 deletions(-)
 create mode 100644 kernel/configs/qemu-gdb.config
Signature · 1 line
2.19.2
#1 lore raw

RFC PATCH 1/3 config: provide a fragment to enable gdb for qemu

Adding a fragment to make it easier to know what options is needed to build a kernel to get the that you can debug in qemu.

First you need to start qemu with flags '-s -S' and then connect with gdb like below:

$ gdb \
 ./obj-dir/vmlinux -iex 'add-auto-load-safe-path \
 ./obj-dir' -ex 'target remote localhost:1234'
---
 kernel/configs/qemu-gdb.config | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 kernel/configs/qemu-gdb.config
kernel/configs/qemu-gdb.config new file +7 -0
new file mode 100644
index 000000000000..30465905ff93
@@ -0,0 +1,7 @@
+# Enable debug info for gdb
+# CONFIG_COMPILE_TEST is not set
+CONFIG_DEBUG_INFO=y
+CONFIG_GDB_SCRIPTS=y
+
+# Easier to debug
+# CONFIG_RANDOMIZE_BASE is not set
Signature · 1 line
2.19.2
#2 lore raw

Re: [RFC PATCH 1/3] config: provide a fragment to enable gdb for qemu

kernel/configs/qemu-gdb.config line 4

Quoted 8 lines · Anders Roxell

Adding a fragment to make it easier to know what options is needed to build a kernel to get the that you can debug in qemu.

kernel/configs/qemu-gdb.config new file +4 -0
@@ -0,0 +1,7 @@
+# Enable debug info for gdb
+# CONFIG_COMPILE_TEST is not set
+CONFIG_DEBUG_INFO=y
+CONFIG_GDB_SCRIPTS=y

Is this specifically for qemu or is this just good for debugging with GDB in general (eg, via JTAG)?

#3 lore raw

Re: [RFC PATCH 1/3] config: provide a fragment to enable gdb for qemu

Quoted 5 lines · Mark Brown
Quoted 2 lines · Anders Roxell

Adding a fragment to make it easier to know what options is needed to build a kernel to get the that you can debug in qemu.

Quoted 8 lines

kernel/configs/qemu-gdb.config line 4

Quoted 5 lines
kernel/configs/qemu-gdb.config new file +4 -0
@@ -0,0 +1,7 @@
+# Enable debug info for gdb
+# CONFIG_COMPILE_TEST is not set
+CONFIG_DEBUG_INFO=y
+CONFIG_GDB_SCRIPTS=y

Is this specifically for qemu or is this just good for debugging with GDB in general (eg, via JTAG)?

I haven't tried, and I don't have a JTAG so I could test it =/

Cheers,
Anders

#4 lore raw

Re: [RFC PATCH 1/3] config: provide a fragment to enable gdb for qemu

Quoted 16 lines · Anders Roxell
Quoted 5 lines · Mark Brown
Quoted 2 lines · Anders Roxell

Adding a fragment to make it easier to know what options is needed to build a kernel to get the that you can debug in qemu.

Quoted 8 lines

kernel/configs/qemu-gdb.config line 4

Quoted 5 lines
kernel/configs/qemu-gdb.config new file +4 -0
@@ -0,0 +1,7 @@
+# Enable debug info for gdb
+# CONFIG_COMPILE_TEST is not set
+CONFIG_DEBUG_INFO=y
+CONFIG_GDB_SCRIPTS=y

Is this specifically for qemu or is this just good for debugging with GDB in general (eg, via JTAG)?

Quoted 1 line

I haven't tried, and I don't have a JTAG so I could test it =/

The DEBUG_INFO=y and (as a dependency for that) CONFIG_COMPILE_TEST are definitely needed for all GDB operation. I would assume that the scripts also work with any other gdb environment, but haven't tried either.

For CONFIG_RANDOMIZE_BASE, I'm not actually sure if that helps or not. I think I originally suggested to Anders to turn that off when he was analyzing a bug, but I don't know if it helped or if it works just as well without that.

Arnd

#5 lore raw

Re: [RFC PATCH 1/3] config: provide a fragment to enable gdb for qemu

Quoted 11 lines · Arnd Bergmann
Quoted 6 lines · Anders Roxell
Quoted 2 lines · Mark Brown

Is this specifically for qemu or is this just good for debugging with GDB in general (eg, via JTAG)?

I haven't tried, and I don't have a JTAG so I could test it =/

The DEBUG_INFO=y and (as a dependency for that) CONFIG_COMPILE_TEST are definitely needed for all GDB operation. I would assume that the scripts also work with any other gdb environment, but haven't tried either.

I'm fairly sure the requirements are identical, though it has been quite some time since I tried and I don't have relevant hardware any more so can't confirm.

Quoted 4 lines

For CONFIG_RANDOMIZE_BASE, I'm not actually sure if that helps or not. I think I originally suggested to Anders to turn that off when he was analyzing a bug, but I don't know if it helped or if it works just as well without that.

Yeah, I'd think it'd be helpful to turn that off.

#6 lore raw

RFC PATCH 2/3 lib/ubsan: default UBSAN_ALIGNMENT to not set

In reply to Anders Roxell

When booting an allmodconfig kernel, there are a lot of false-positives. With a message like this 'UBSAN: Undefined behaviour in...' with a call trace that follows.

Reworked so that when building a allmodconfig kernel that turns everything into '=m' or '=y' will turn off UBSAN_ALIGNMENT.

---
 lib/Kconfig.ubsan | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
lib/Kconfig.ubsan +9 -5
index 98fa559ebd80..a2ae4a8e4fa6 100644
@@ -27,15 +27,19 @@ config UBSAN_SANITIZE_ALL
 	  Enabling this option will get kernel image size increased
 	  significantly.
 
-config UBSAN_ALIGNMENT
-	bool "Enable checking of pointers alignment"
+config UBSAN_NO_ALIGNMENT
+	bool "Disable checking of pointers alignment"
 	depends on UBSAN
-	default y if !HAVE_EFFICIENT_UNALIGNED_ACCESS
+	default y if HAVE_EFFICIENT_UNALIGNED_ACCESS
 	help
-	  This option enables detection of unaligned memory accesses.
-	  Enabling this option on architectures that support unaligned
+	  This option disables the check of unaligned memory accesses.
+	  This option should be used when building allmodconfig.
+	  Disabling this option on architectures that support unaligned
 	  accesses may produce a lot of false positives.
 
+config UBSAN_ALIGNMENT
+	def_bool !UBSAN_NO_ALIGNMENT
+
 config TEST_UBSAN
 	tristate "Module for testing for undefined behavior detection"
 	depends on m && UBSAN
Signature · 1 line
2.19.2
#7 lore raw

RFC PATCH 3/3 arm64: add a new config option KTEST_RUNNABLE

In reply to Anders Roxell

With this new config option, we can boot a allmodconfig kernel in qemu. Config options SERIAL_AMBA_PL011, SERIAL_AMBA_PL011_CONSOLE, UNIX needs to be enabled in order to get a console. Options like CPU_BIG_ENDIAN, CMDLINE_FORCE, CMDLINE_OVERRIDE and HVC_DCC needs to be disabled.

---
 arch/arm64/Kconfig      | 8 ++++++++
 drivers/tty/hvc/Kconfig | 1 +
 init/Kconfig            | 1 +
 3 files changed, 10 insertions(+)
arch/arm64/Kconfig +8 -0
index 1f52362f8d99..bb17ccb7bab2 100644
@@ -292,6 +292,12 @@ config ARCH_SUPPORTS_UPROBES
 config ARCH_PROC_KCORE_TEXT
 	def_bool y
 
+config KTEST_RUNNABLE
+	bool "Test build kernels that run in qemu for ktest"
+	select SERIAL_AMBA_PL011
+	select SERIAL_AMBA_PL011_CONSOLE
+	select UNIX
+
 source "arch/arm64/Kconfig.platforms"
 
 menu "Kernel Features"
@@ -773,6 +779,7 @@ config ARM64_PA_BITS
 
 config CPU_BIG_ENDIAN
        bool "Build big-endian kernel"
+	depends on !KTEST_RUNNABLE
        help
          Say Y if you plan on running a kernel in big-endian mode.
 
@@ -1381,6 +1388,7 @@ config CMDLINE
 
 config CMDLINE_FORCE
 	bool "Always use the default kernel command string"
+	depends on !KTEST_RUNNABLE
 	help
 	  Always use the default kernel command string, even if the boot
 	  loader passes other arguments to the kernel.
drivers/tty/hvc/Kconfig +1 -0
index 4293c172e120..44e23c2388bd 100644
@@ -82,6 +82,7 @@ config HVC_UDBG
 config HVC_DCC
        bool "ARM JTAG DCC console"
        depends on ARM || ARM64
+	depends on !KTEST_RUNNABLE
        select HVC_DRIVER
        help
          This console uses the JTAG DCC on ARM to create a console under the HVC
init/Kconfig +1 -0
index b633716e48f5..3ea5297b7305 100644
@@ -1844,6 +1844,7 @@ config CMDLINE_PREPEND
 config CMDLINE_OVERRIDE
 	bool "Built-in command line overrides boot loader arguments"
 	depends on CMDLINE_BOOL
+	depends on !KTEST_RUNNABLE
 	help
 	  Set this option to 'Y' to have the kernel ignore the boot loader
 	  command line, and use ONLY the built-in command line. In this case
Signature · 1 line
2.19.2
#8 lore raw

Re: [RFC PATCH 3/3] arm64: add a new config option KTEST_RUNNABLE

Quoted 4 lines · Anders Roxell

With this new config option, we can boot a allmodconfig kernel in qemu. Config options SERIAL_AMBA_PL011, SERIAL_AMBA_PL011_CONSOLE, UNIX needs to be enabled in order to get a console. Options like CPU_BIG_ENDIAN, CMDLINE_FORCE, CMDLINE_OVERRIDE and HVC_DCC needs to be disabled.

Does ktest really not run with BIG_ENDIAN?

arch/arm64/Kconfig config ARCH_SUPPORTS_UPROBES · line 299

Quoted 5 lines
arch/arm64/Kconfig +5 -0
+config KTEST_RUNNABLE
+	bool "Test build kernels that run in qemu for ktest"
+	select SERIAL_AMBA_PL011
+	select SERIAL_AMBA_PL011_CONSOLE
+	select UNIX

The opposite angle for my question on patch 1 I guess but is this really a generic thing for running ktest? It seems like it's specific to qemu (and other systems which have the PL011 as the console serial port).

reviewer
#9 lore raw

Re: [RFC PATCH 3/3] arm64: add a new config option KTEST_RUNNABLE

Quoted 9 lines · Mark Brown
Quoted 4 lines · Anders Roxell

With this new config option, we can boot a allmodconfig kernel in qemu. Config options SERIAL_AMBA_PL011, SERIAL_AMBA_PL011_CONSOLE, UNIX needs to be enabled in order to get a console. Options like CPU_BIG_ENDIAN, CMDLINE_FORCE, CMDLINE_OVERRIDE and HVC_DCC needs to be disabled.

Does ktest really not run with BIG_ENDIAN?

Quoted 9 lines

arch/arm64/Kconfig config ARCH_SUPPORTS_UPROBES · line 299

Quoted 5 lines
arch/arm64/Kconfig +5 -0
+config KTEST_RUNNABLE
+	bool "Test build kernels that run in qemu for ktest"
+	select SERIAL_AMBA_PL011
+	select SERIAL_AMBA_PL011_CONSOLE
+	select UNIX

The opposite angle for my question on patch 1 I guess but is this really a generic thing for running ktest? It seems like it's specific to qemu (and other systems which have the PL011 as the console serial port).

This is definitely platform-specific rather than ktest specific.

If I wanted to run ktest in a kvmtool VM, I would not need PL011 at all, since that uses 8250 and virtio-console.

Thanks,
Mark.

reviewer
#10 lore raw

Re: [RFC PATCH 3/3] arm64: add a new config option KTEST_RUNNABLE

In reply to Anders Roxell

Hi,

As a general thing, please Cc LAKML on patches for arm64.

Quoted 19 lines · Anders Roxell

With this new config option, we can boot a allmodconfig kernel in qemu. Config options SERIAL_AMBA_PL011, SERIAL_AMBA_PL011_CONSOLE, UNIX needs to be enabled in order to get a console. Options like CPU_BIG_ENDIAN, CMDLINE_FORCE, CMDLINE_OVERRIDE and HVC_DCC needs to be disabled.

---
 arch/arm64/Kconfig      | 8 ++++++++
 drivers/tty/hvc/Kconfig | 1 +
 init/Kconfig            | 1 +
 3 files changed, 10 insertions(+)
arch/arm64/Kconfig +0 -0
index 1f52362f8d99..bb17ccb7bab2 100644

arch/arm64/Kconfig config ARCH_SUPPORTS_UPROBES · line 300

Quoted 9 lines
arch/arm64/Kconfig +6 -0
@@ -292,6 +292,12 @@ config ARCH_SUPPORTS_UPROBES
 config ARCH_PROC_KCORE_TEXT
 	def_bool y
 
+config KTEST_RUNNABLE
+	bool "Test build kernels that run in qemu for ktest"
+	select SERIAL_AMBA_PL011
+	select SERIAL_AMBA_PL011_CONSOLE
+	select UNIX
+

As Mark Brown points out, the PL011 bits are platform-specific, and don't directly relate to ktest.

The UNIX part is simply because that can be built as a module.

Is it possible to use an allyesconfig rather than an allmodconfig? That would leave all relevant options built-in.

drivers/tty/hvc/Kconfig config HVC_UDBG · line 88

Quoted 12 lines
drivers/tty/hvc/Kconfig +1 -0
index 4293c172e120..44e23c2388bd 100644
@@ -82,6 +82,7 @@ config HVC_UDBG
 config HVC_DCC
        bool "ARM JTAG DCC console"
        depends on ARM || ARM64
+	depends on !KTEST_RUNNABLE
        select HVC_DRIVER
        help
          This console uses the JTAG DCC on ARM to create a console under the HVC

... this is just a hack around the DCC driver being dodgy.

We should fix that to only probe if explicitly requested at run-time via a command line argument.

Thanks,
Mark.

#11 lore raw

Re: [RFC PATCH 3/3] arm64: add a new config option KTEST_RUNNABLE

Quoted 2 lines · Mark Rutland

Is it possible to use an allyesconfig rather than an allmodconfig? That would leave all relevant options built-in.

The allyesconfig would make it more difficult to apply this approach to real hardware which is part of the goal here - the idea was to come up with a way of making runnable configurations which are likely to be usable with random userspace testsuites in order to avoid needing ever expanding combinations of builds.

reviewer
#12 lore raw

Re: [RFC PATCH 3/3] arm64: add a new config option KTEST_RUNNABLE

Quoted 10 lines · Mark Brown
Quoted 2 lines · Mark Rutland

Is it possible to use an allyesconfig rather than an allmodconfig? That would leave all relevant options built-in.

The allyesconfig would make it more difficult to apply this approach to real hardware which is part of the goal here - the idea was to come up with a way of making runnable configurations which are likely to be usable with random userspace testsuites in order to avoid needing ever expanding combinations of builds.

Ok.

Is it somehow possible to fuse defconfig with an allmodconfig, with defconfig's CONFIG_FOO=y taking precedence over allmodconfig's CONFIG_FOO=m?

IIUC, that would give you the necessary platform bits, at least for anything supported by defconfig. That would also happen to get CONFIG_UNIX=y, too.

Thanks,
Mark.