* [PATCH v4 3/4] liveupdate: luo_session: include linux/mm.h for virt/phys translation
[not found] <20260807103714.33074-1-dongtai.guo@linux.dev>
@ 2026-08-07 10:37 ` George Guo
2026-08-07 10:37 ` [PATCH v4 4/4] selftests/kho: add LoongArch vmtest support George Guo
1 sibling, 0 replies; 2+ messages in thread
From: George Guo @ 2026-08-07 10:37 UTC (permalink / raw)
To: chenhuacai, rppt, pasha.tatashin, pratyush, shuah, ardb
Cc: guodongtai, kernel, graf, loongarch, linux-kernel, kexec,
linux-mm, linux-kselftest, linux-efi, Kexin Liu
From: George Guo <guodongtai@kylinos.cn>
luo_session.c calls virt_to_phys() and phys_to_virt(). On LoongArch with
CONFIG_KFENCE=y, these macros (in arch/loongarch/include/asm/io.h) expand
to offset_in_page() and page_address(), both declared in <linux/mm.h>.
Since luo_session.c only includes <linux/io.h>, the translation unit fails
to build with CONFIG_KFENCE=y:
asm/io.h: error: implicit declaration of function 'offset_in_page'
asm/io.h: error: implicit declaration of function 'page_address'
Add the missing include to fix these build errors.
Co-developed-by: Kexin Liu <liukexin@kylinos.cn>
Signed-off-by: Kexin Liu <liukexin@kylinos.cn>
Signed-off-by: George Guo <guodongtai@kylinos.cn>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
kernel/liveupdate/luo_session.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_session.c
index f38b5b18f3f8..31490ac7b63d 100644
--- a/kernel/liveupdate/luo_session.c
+++ b/kernel/liveupdate/luo_session.c
@@ -94,6 +94,7 @@
#include <linux/kho/abi/luo.h>
#include <linux/list.h>
#include <linux/liveupdate.h>
+#include <linux/mm.h>
#include <linux/mutex.h>
#include <linux/rwsem.h>
#include <linux/slab.h>
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH v4 4/4] selftests/kho: add LoongArch vmtest support
[not found] <20260807103714.33074-1-dongtai.guo@linux.dev>
2026-08-07 10:37 ` [PATCH v4 3/4] liveupdate: luo_session: include linux/mm.h for virt/phys translation George Guo
@ 2026-08-07 10:37 ` George Guo
1 sibling, 0 replies; 2+ messages in thread
From: George Guo @ 2026-08-07 10:37 UTC (permalink / raw)
To: chenhuacai, rppt, pasha.tatashin, pratyush, shuah, ardb
Cc: guodongtai, kernel, graf, loongarch, linux-kernel, kexec,
linux-mm, linux-kselftest, linux-efi, Kexin Liu
From: George Guo <guodongtai@kylinos.cn>
Add loongarch.conf to configure QEMU's LoongArch virtual machine (VM)
with a la464 CPU, enable the 8250 serial console, and set the kernel
image to vmlinux.efi. Extend vmtest.sh to recognise loongarch64 as a
supported target and map it to the 'loongarch' kernel arch name.
QEMU's LoongArch VM provides no ACPI tables and relies on FDT to
describe hardware. Without 'earlycon' on the kernel command line, the
FDT is not scanned for a console UART, no output reaches the console,
and vmtest.sh's console log stays empty causing the test to always
fail. Add 'earlycon' to KERNEL_CMDLINE in loongarch.conf.
QEMU's LoongArch VM has no i8042 PS/2 controller. When PNP detection
finds nothing, i8042_init() falls back to probing the ports directly.
On LoongArch the I/O ports are memory-mapped, and the i8042 port
addresses are not backed by any device on the VM, so i8042_flush() takes
a page fault and the kernel panics:
i8042: PNP: No PS/2 controller found.
i8042: Probing ports directly.
CPU 0 Unable to handle kernel paging request at virtual address ffff800000008064
ERA: i8042_flush+0x50/0x198
RA: i8042_init+0x2a8/0x35c
Kernel panic - not syncing: Attempted to kill init!
Disable SERIO_I8042 and its dependents (KEYBOARD_ATKBD, MOUSE_PS2) in
the QEMU_KCONFIG fragment to prevent the driver from being built.
All three options are scoped to loongarch.conf; no other architecture
is affected.
Wrap the QEMU invocation in run_qemu() with timeout(1) using a local
time limit so the test always terminates, even when QEMU does not exit
on its own. This is useful for every architecture; on LoongArch, for
example, QEMU provides no EFI runtime services and machine_restart()
falls through to an idle loop after kexec, so QEMU would never exit
otherwise.
Co-developed-by: Kexin Liu <liukexin@kylinos.cn>
Signed-off-by: Kexin Liu <liukexin@kylinos.cn>
Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
tools/testing/selftests/kho/loongarch.conf | 11 +++++++++++
tools/testing/selftests/kho/vmtest.sh | 22 +++++++++++++++-------
2 files changed, 26 insertions(+), 7 deletions(-)
create mode 100644 tools/testing/selftests/kho/loongarch.conf
diff --git a/tools/testing/selftests/kho/loongarch.conf b/tools/testing/selftests/kho/loongarch.conf
new file mode 100644
index 000000000000..e45fe1014cf3
--- /dev/null
+++ b/tools/testing/selftests/kho/loongarch.conf
@@ -0,0 +1,11 @@
+QEMU_CMD="qemu-system-loongarch64 -M virt -cpu la464"
+QEMU_KCONFIG="
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SPARSEMEM_MANUAL=y
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_MOUSE_PS2 is not set
+# CONFIG_SERIO_I8042 is not set
+"
+KERNEL_IMAGE="vmlinux.efi"
+KERNEL_CMDLINE="console=ttyS0 earlycon kho_scratch=16M,16M,16M"
diff --git a/tools/testing/selftests/kho/vmtest.sh b/tools/testing/selftests/kho/vmtest.sh
index 0014bd76e88d..de6aa59cf5a0 100755
--- a/tools/testing/selftests/kho/vmtest.sh
+++ b/tools/testing/selftests/kho/vmtest.sh
@@ -21,7 +21,7 @@ Options:
-d) path to the kernel build directory
-j) number of jobs for compilation, similar to -j in make
-t) run test for target_arch, requires CROSS_COMPILE set
- supported targets: aarch64, x86_64
+ supported targets: aarch64, x86_64, loongarch64
-h) display this help
EOF
}
@@ -111,12 +111,19 @@ function run_qemu() {
cmdline="$cmdline kho=on panic=-1"
- $qemu_cmd -m 1G -smp 2 -no-reboot -nographic -nodefaults \
- -accel kvm -accel hvf -accel tcg \
- -serial file:"$serial" \
- -append "$cmdline" \
- -kernel "$kernel" \
- -initrd "$initrd"
+ local qemu_args=(
+ -m 1G -smp 2 -no-reboot -nographic -nodefaults
+ -accel kvm -accel hvf -accel tcg
+ -serial file:"$serial"
+ -append "$cmdline"
+ -kernel "$kernel"
+ -initrd "$initrd"
+ )
+
+ # Bound the QEMU run so the test always terminates, even when QEMU
+ # does not exit on its own (e.g. no EFI runtime services after kexec).
+ local qemu_timeout=60
+ timeout "$qemu_timeout" $qemu_cmd "${qemu_args[@]}" || true
grep "KHO restore succeeded" "$serial" &> /dev/null || fail "KHO failed"
}
@@ -127,6 +134,7 @@ function target_to_arch() {
case $target in
aarch64) echo "arm64" ;;
x86_64) echo "x86" ;;
+ loongarch64) echo "loongarch" ;;
*) skip "architecture $target is not supported"
esac
}
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread