From nobody Sun Oct 5 03:35:57 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F5832DC33B; Mon, 11 Aug 2025 08:25:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754900737; cv=none; b=cyHVlZk8YBXl9DNZh9Js6iOj+m0RLzLGLqcL9ZpT9KAlDsP3/LHuEW/8wRgd3Cs8TH1Yp/eho5zJK2dZRD+U+pGxSrdrTaIIlTseDTXIGx8v7pMfX4L9whfBB/M8OdLtR4pukOAXs4uG3ZnSwMUDo5QwtVKeLQok0d4Nc9TWdg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754900737; c=relaxed/simple; bh=x9yDF0ETg1DZV483jmCAS7zdZyJxfX8QtrhsIOYLE3w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PICFhfeTCy1Ln0bqEFCLyR5h/RFstlNi6GvmL5aATvsgCzVTTjiJ6jI9pKOPs2lCqlLCZELi+j5xrXLcioajcr2/gRYK4lP/4sgsycEokoxp0xjJOll2WPSqXxa4AsSjcf+LRVJ8y5tAWTd5PtUJG3lXmlaZYrFPeZoTR5C91Ro= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=J+xamGjR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="J+xamGjR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0AADC4CEF8; Mon, 11 Aug 2025 08:25:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754900737; bh=x9yDF0ETg1DZV483jmCAS7zdZyJxfX8QtrhsIOYLE3w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J+xamGjRj0qBZ8f+MKHSAySNijepwnYwt5H+o27/gEbgnXE3KQltdcbB0iHOqwdja e3uxwJ+w5yxH41yVobpeGbK+tifeiohOed1kRfcIgZnRmaI0/zJph8jQ5jZVoQmEeA SF8HdzQuD9/keUQlz5XLJhcPyyioXMA19Oobp3ATZm0iBRUf4g+5zifCSJpt16V6ae aZW1oBggKLDmPu7m2OsuFxhT2HtyISgt7vOI/0pde2gNl2gwyV7EtRwVfP6dGR1CnN VBZIFHyuTocPG+JYnv9+2PApCwJFsdR/g/PfEDfrLK1MTZdRF9ha1opuD5ix9iZ9en HgZmIqifpPCkg== From: Mike Rapoport To: Andrew Morton Cc: Alexander Graf , Baoquan He , Changyuan Lyu , Mike Rapoport , Pasha Tatashin , Pratyush Yadav , Shuah Khan , =?UTF-8?q?Thomas=20Wei=DFschuh?= , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 3/3] selftest/kho: update generation of initrd Date: Mon, 11 Aug 2025 11:25:10 +0300 Message-ID: <20250811082510.4154080-4-rppt@kernel.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250811082510.4154080-1-rppt@kernel.org> References: <20250811082510.4154080-1-rppt@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: "Mike Rapoport (Microsoft)" Use nolibc include directory rather than include a cumulative nolibc.h on the compiler command line and replace use of 'sudo cpio' with usr/gen_init_cpio. While on it fix spelling of KHO_FINALIZE Suggested-by: Thomas Wei=C3=9Fschuh Signed-off-by: Mike Rapoport (Microsoft) --- tools/testing/selftests/kho/init.c | 13 ++++--------- tools/testing/selftests/kho/vmtest.sh | 28 ++++++++++++++------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/tools/testing/selftests/kho/init.c b/tools/testing/selftests/k= ho/init.c index 8034e24c6bf6..6d9e91d55d68 100644 --- a/tools/testing/selftests/kho/init.c +++ b/tools/testing/selftests/kho/init.c @@ -1,22 +1,17 @@ // SPDX-License-Identifier: GPL-2.0 =20 -#ifndef NOLIBC -#include #include #include #include -#include +#include #include #include -#endif +#include =20 /* from arch/x86/include/asm/setup.h */ #define COMMAND_LINE_SIZE 2048 =20 -/* from include/linux/kexex.h */ -#define KEXEC_FILE_NO_INITRAMFS 0x00000004 - -#define KHO_FINILIZE "/debugfs/kho/out/finalize" +#define KHO_FINALIZE "/debugfs/kho/out/finalize" #define KERNEL_IMAGE "/kernel" =20 static int mount_filesystems(void) @@ -32,7 +27,7 @@ static int kho_enable(void) const char enable[] =3D "1"; int fd; =20 - fd =3D open(KHO_FINILIZE, O_RDWR); + fd =3D open(KHO_FINALIZE, O_RDWR); if (fd < 0) return -1; =20 diff --git a/tools/testing/selftests/kho/vmtest.sh b/tools/testing/selftest= s/kho/vmtest.sh index ec70a17bd476..3f6c17166846 100755 --- a/tools/testing/selftests/kho/vmtest.sh +++ b/tools/testing/selftests/kho/vmtest.sh @@ -10,7 +10,6 @@ kernel_dir=3D$(realpath "$test_dir/../../../..") =20 tmp_dir=3D$(mktemp -d /tmp/kho-test.XXXXXXXX) headers_dir=3D"$tmp_dir/usr" -initrd_dir=3D"$tmp_dir/initrd" initrd=3D"$tmp_dir/initrd.cpio" =20 source "$test_dir/../kselftest/ktap_helpers.sh" @@ -81,19 +80,22 @@ EOF function mkinitrd() { local kernel=3D$1 =20 - mkdir -p "$initrd_dir"/{dev,debugfs,proc} - sudo mknod "$initrd_dir/dev/console" c 5 1 - - "$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" \ - -o "$initrd_dir/init" "$test_dir/init.c" \ - - cp "$kernel" "$initrd_dir/kernel" + "$CROSS_COMPILE"gcc -s -static -Os -nostdinc -nostdlib \ + -fno-asynchronous-unwind-tables -fno-ident \ + -I "$headers_dir/include" \ + -I "$kernel_dir/tools/include/nolibc" \ + -o "$tmp_dir/init" "$test_dir/init.c" + + cat > "$tmp_dir/cpio_list" </dev/null - find . | cpio -H newc --create > "$initrd" 2>/dev/null - popd &>/dev/null + "$build_dir/usr/gen_init_cpio" "$tmp_dir/cpio_list" > "$initrd" } =20 function run_qemu() { --=20 2.47.2