linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Mike Rapoport <rppt@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 Alexander Graf <graf@amazon.com>,
	Changyuan Lyu <changyuanl@google.com>,
	 Pasha Tatashin <pasha.tatashin@soleen.com>,
	Pratyush Yadav <pratyush@kernel.org>,
	 Shuah Khan <shuah@kernel.org>,
	kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
	 linux-kselftest@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] kho: add test for kexec handover
Date: Thu, 31 Jul 2025 23:27:07 +0200	[thread overview]
Message-ID: <c54e6f3f-64b9-408e-9668-e96664f52f27@t-8ch.de> (raw)
In-Reply-To: <20250727083733.2590139-1-rppt@kernel.org>

Hi Mike,

On 2025-07-27 11:37:33+0300, Mike Rapoport wrote:
> From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
> 
> Testing kexec handover requires a kernel driver that will generate some
> data and preserve it with KHO on the first boot and then restore that
> data and verify it was preserved properly after kexec.
> 
> To facilitate such test, along with the kernel driver responsible for
> data generation, preservation and restoration add a script that runs a
> kernel in a VM with a minimal /init. The /init enables KHO, loads a
> kernel image for kexec and runs kexec reboot. After the boot of the
> kexeced kernel, the driver verifies that the data was properly
> preserved.
> 
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

(...)

> --- /dev/null
> +++ b/tools/testing/selftests/kho/init.c
> @@ -0,0 +1,100 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#ifndef NOLIBC

This is not necessary anymore, nolibc now provides these headers.
You can keep it if you want, though.

> +#include <errno.h>
> +#include <stdio.h>
> +#include <unistd.h>
> +#include <fcntl.h>
> +#include <syscall.h>

This should be <sys/syscall.h>.

> +#include <sys/mount.h>
> +#include <sys/reboot.h>
> +#endif
> +

(...)

> --- /dev/null
> +++ b/tools/testing/selftests/kho/vmtest.sh
> @@ -0,0 +1,183 @@

(...)

> +
> +function mkinitrd() {
> +	local kernel=$1
> +
> +	mkdir -p "$initrd_dir"/{dev,debugfs,proc}
> +	sudo mknod "$initrd_dir/dev/console" c 5 1

You could generate the initrd with usr/gen_init_cpio or
usr/gen_initramfs.sh which would remove the need to use sudo.
Especially as I think the mknod should fail if $TMP is mounted 'nodev'.

> +
> +	"$CROSS_COMPILE"gcc -s -static -Os -nostdinc -I"$headers_dir/include" \
> +			-fno-asynchronous-unwind-tables -fno-ident -nostdlib \
> +			-include "$test_dir/../../../include/nolibc/nolibc.h" \

If you drop the #ifdef NOLIBC, use '-I "$test_dir/../../../include/nolibc/'
here instead. Or better, $kernel_dir/tools/include/nolibc/.

> +			-o "$initrd_dir/init" "$test_dir/init.c" \
> +
> +	cp "$kernel" "$initrd_dir/kernel"
> +
> +	pushd "$initrd_dir" &>/dev/null
> +	find . | cpio -H newc --create > "$initrd" 2>/dev/null
> +	popd &>/dev/null
> +}

(...)


Thomas


      reply	other threads:[~2025-07-31 21:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-27  8:37 Mike Rapoport
2025-07-31 21:27 ` Thomas Weißschuh [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c54e6f3f-64b9-408e-9668-e96664f52f27@t-8ch.de \
    --to=linux@weissschuh.net \
    --cc=akpm@linux-foundation.org \
    --cc=changyuanl@google.com \
    --cc=graf@amazon.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pasha.tatashin@soleen.com \
    --cc=pratyush@kernel.org \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox