[PATCH 0/4] kunit: Add support for LoongArch

3 views
Skip to first unread message

Thomas Weißschuh

unread,
Oct 14, 2024, 7:36:58 AM10/14/24
to Huacai Chen, WANG Xuerui, Jiaxun Yang, Brendan Higgins, David Gow, Rae Moar, loon...@lists.linux.dev, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, kuni...@googlegroups.com, Thomas Weißschuh
Enable LoongArch support in kunit.

Example:

$ ./tools/testing/kunit/kunit.py run --arch=loongarch --cross_compile=$CROSS_COMPILE
[13:32:45] Configuring KUnit Kernel ...
[13:32:45] Building KUnit Kernel ...
Populating config with:
$ make ARCH=loongarch olddefconfig CROSS_COMPILE=$CROSS_COMPILE
Building with:
$ make all compile_commands.json ARCH=loongarch --jobs=8 CROSS_COMPILE=$CROSS_COMPILE
[13:32:48] Starting KUnit Kernel (1/1)...
[13:32:48] ============================================================
Running tests with:
$ qemu-system-loongarch64 -nodefaults -m 1024 -kernel .kunit/arch/loongarch/boot/vmlinux.elf -append 'kunit.enable=1 console=ttyS0 kunit_shutdown=poweroff' -no-reboot -nographic -serial stdio -machine virt -device pvpanic-pci -cpu max

...

[13:33:14] ============================================================
[13:33:14] Testing complete. Ran 493 tests: passed: 453, skipped: 40
[13:33:14] Elapsed time: 28.862s total, 0.002s configuring, 2.526s building, 26.302s running


Signed-off-by: Thomas Weißschuh <thomas.w...@linutronix.de>
---
Thomas Weißschuh (4):
LoongArch: Don't crash in stack_top() for tasks without vDSO
kunit: qemu_configs: add LoongArch config
kunit: tool: Allow overriding the shutdown mode from qemu config
kunit: qemu_configs: loongarch: Enable shutdown

arch/loongarch/kernel/process.c | 16 +++++++++-------
tools/testing/kunit/kunit_kernel.py | 4 +++-
tools/testing/kunit/qemu_configs/loongarch.py | 19 +++++++++++++++++++
3 files changed, 31 insertions(+), 8 deletions(-)
---
base-commit: 6485cf5ea253d40d507cd71253c9568c5470cd27
change-id: 20241014-kunit-loongarch-98a5b756e818

Best regards,
--
Thomas Weißschuh <thomas.w...@linutronix.de>

Thomas Weißschuh

unread,
Oct 14, 2024, 7:36:58 AM10/14/24
to Huacai Chen, WANG Xuerui, Jiaxun Yang, Brendan Higgins, David Gow, Rae Moar, loon...@lists.linux.dev, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, kuni...@googlegroups.com, Thomas Weißschuh
Not all platforms support machine reboot.
If it a proper reboot is not supported the machine will hang.
Allow the QEMU configuration to override the necessary shutdown mode for
the specific system under test.

Signed-off-by: Thomas Weißschuh <thomas.w...@linutronix.de>
---
tools/testing/kunit/kunit_kernel.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py
index 61931c4926fd6645f2c62dd13f9842a432ec4167..e76d7894b6c5195ece49f0d8c7ac35130df428a9 100644
--- a/tools/testing/kunit/kunit_kernel.py
+++ b/tools/testing/kunit/kunit_kernel.py
@@ -105,7 +105,9 @@ class LinuxSourceTreeOperationsQemu(LinuxSourceTreeOperations):
self._kconfig = qemu_arch_params.kconfig
self._qemu_arch = qemu_arch_params.qemu_arch
self._kernel_path = qemu_arch_params.kernel_path
- self._kernel_command_line = qemu_arch_params.kernel_command_line + ' kunit_shutdown=reboot'
+ self._kernel_command_line = qemu_arch_params.kernel_command_line
+ if 'kunit_shutdown=' not in self._kernel_command_line:
+ self._kernel_command_line += ' kunit_shutdown=reboot'
self._extra_qemu_params = qemu_arch_params.extra_qemu_params
self._serial = qemu_arch_params.serial


--
2.47.0

Thomas Weißschuh

unread,
Oct 14, 2024, 7:36:59 AM10/14/24
to Huacai Chen, WANG Xuerui, Jiaxun Yang, Brendan Higgins, David Gow, Rae Moar, loon...@lists.linux.dev, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, kuni...@googlegroups.com, Thomas Weißschuh
QEMU for LoongArch does not yet support shutdown/restart through ACPI.
Use the pvpanic driver to enable shutdowns.
This requires 9.1.0 for shutdown support in pvpanic, but that is the
requirement of kunit on LoongArch anyways.

Signed-off-by: Thomas Weißschuh <thomas.w...@linutronix.de>
---
tools/testing/kunit/qemu_configs/loongarch.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/testing/kunit/qemu_configs/loongarch.py b/tools/testing/kunit/qemu_configs/loongarch.py
index e7bb7c07819677dfdefac012821a732555813cae..1d2b780fbd5c0bde20aa6a5cd1217d0b3b443a93 100644
--- a/tools/testing/kunit/qemu_configs/loongarch.py
+++ b/tools/testing/kunit/qemu_configs/loongarch.py
@@ -4,13 +4,16 @@ QEMU_ARCH = QemuArchParams(linux_arch='loongarch',
kconfig='''
CONFIG_EFI_STUB=n
CONFIG_PCI_HOST_GENERIC=y
+CONFIG_PVPANIC=y
+CONFIG_PVPANIC_PCI=y
CONFIG_SERIAL_8250=y
CONFIG_SERIAL_8250_CONSOLE=y
CONFIG_SERIAL_OF_PLATFORM=y
''',
qemu_arch='loongarch64',
kernel_path='arch/loongarch/boot/vmlinux.elf',
- kernel_command_line='console=ttyS0',
+ kernel_command_line='console=ttyS0 kunit_shutdown=poweroff',
extra_qemu_params=[
'-machine', 'virt',
+ '-device', 'pvpanic-pci',
'-cpu', 'max',])

--
2.47.0

maobibo

unread,
Oct 15, 2024, 3:32:01 AM10/15/24
to Thomas Weißschuh, Huacai Chen, WANG Xuerui, Jiaxun Yang, Brendan Higgins, David Gow, Rae Moar, loon...@lists.linux.dev, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, kuni...@googlegroups.com
Reviewed-by: Bibo Mao <mao...@loongson.cn>

David Gow

unread,
Oct 17, 2024, 3:24:32 AM10/17/24
to Thomas Weißschuh, Huacai Chen, WANG Xuerui, Jiaxun Yang, Brendan Higgins, Rae Moar, loon...@lists.linux.dev, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, kuni...@googlegroups.com
On Mon, 14 Oct 2024 at 19:37, Thomas Weißschuh
<thomas.w...@linutronix.de> wrote:
>
> Not all platforms support machine reboot.
> If it a proper reboot is not supported the machine will hang.
> Allow the QEMU configuration to override the necessary shutdown mode for
> the specific system under test.
>
> Signed-off-by: Thomas Weißschuh <thomas.w...@linutronix.de>
> ---

I suspect there's a cleaner way of doing this, but it'd involve
changing all of the architectures over, so this looks good for now.

Reviewed-by: David Gow <davi...@google.com>

Cheers,
-- David


> tools/testing/kunit/kunit_kernel.py | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py
> index 61931c4926fd6645f2c62dd13f9842a432ec4167..e76d7894b6c5195ece49f0d8c7ac35130df428a9 100644
> --- a/tools/testing/kunit/kunit_kernel.py
> +++ b/tools/testing/kunit/kunit_kernel.py
> @@ -105,7 +105,9 @@ class LinuxSourceTreeOperationsQemu(LinuxSourceTreeOperations):
> self._kconfig = qemu_arch_params.kconfig
> self._qemu_arch = qemu_arch_params.qemu_arch
> self._kernel_path = qemu_arch_params.kernel_path
> - self._kernel_command_line = qemu_arch_params.kernel_command_line + ' kunit_shutdown=reboot'
> + self._kernel_command_line = qemu_arch_params.kernel_command_line
> + if 'kunit_shutdown=' not in self._kernel_command_line:
> + self._kernel_command_line += ' kunit_shutdown=reboot'
> self._extra_qemu_params = qemu_arch_params.extra_qemu_params
> self._serial = qemu_arch_params.serial
>
>
> --
> 2.47.0
>
> --
> You received this message because you are subscribed to the Google Groups "KUnit Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kunit-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/20241014-kunit-loongarch-v1-3-1699b2ad6099%40linutronix.de.

David Gow

unread,
Oct 17, 2024, 3:25:18 AM10/17/24
to Thomas Weißschuh, Huacai Chen, WANG Xuerui, Jiaxun Yang, Brendan Higgins, Rae Moar, loon...@lists.linux.dev, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, kuni...@googlegroups.com
On Mon, 14 Oct 2024 at 19:37, Thomas Weißschuh
<thomas.w...@linutronix.de> wrote:
>
> QEMU for LoongArch does not yet support shutdown/restart through ACPI.
> Use the pvpanic driver to enable shutdowns.
> This requires 9.1.0 for shutdown support in pvpanic, but that is the
> requirement of kunit on LoongArch anyways.
>
> Signed-off-by: Thomas Weißschuh <thomas.w...@linutronix.de>
> ---

Looks fine to me.
Reply all
Reply to author
Forward
0 new messages