From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.200 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796172005; b=iDb8HaT8rYRK8GHZR0YWwsy1hZOvY5TTuzGy8V9bP3RlCN0LjNbmVlP/WI0Vs2qxTRlJ 6NZ/ls4WAM+VPll0DpBHPtBTcYr3clUA0aAHhu2lpTjl/gVq+hVUfounfZnbBpGYqnExN swifWP24sjT3G/ZKfkiADMulJki7fepCiyxWDB8FxPJmrIuFbTepn+i8Zg53SIBk34za+ 0+8i+VfYWRLXdzOnFKhbbiWtAcUvLhzZZSM44cvDk8+UCQu8vGT/sEUp/f+VN8YPnMu3R uThYV4tku3YzljDbvAPBV2chbTECYZOsZMDvmv6kLc0exPbjrSAn7ccKPSqe60rhjfQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796172005; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=FkSCXQuEjN72Qu59EVeItljnnT76TyuuverwwE+ysiE=; b=QdrfC1uroTAEvXBZT2ZYgdSsp30TgjXRj5zUfZPwFwZq4U9rHCXdjLaGoIoD7rOsSmFV MzdQ1xpJCRDpR7RpI+jteN54n4gspxtN9UaSlejUodMMRGzk0I6gwG9PlqLJYk5OU73ot /zANKXodAu7hL7EiAcVpq2g/OqvYGX0pLOYvqR8RuknUt0BkyQd5KUEVGHz2uzZwIozxn CDJWAdVuETEPbsfn9ykWgo0YILkWzRrJG1sBd4+FJmWvl3N/abthSJsRE1OWGCn+qxoJG Mc0bRYJCDw8qJEeTzBYzs+7gEuEBW1nOK+w5iWjU7o7qLmvFQZuNrvyiz/iQVRNcGXA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=mgbOQe5E; arc=none smtp.remote-ip=209.85.167.200 Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38EA7606A6B0 for ; Wed, 2 Dec 2026 00:40:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 38EA7606A6B0 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=mgbOQe5E Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-4ab8b4887d4so8739499b6e.1 for ; Tue, 01 Dec 2026 16:40:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796172003; x=1796776803; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=FkSCXQuEjN72Qu59EVeItljnnT76TyuuverwwE+ysiE=; b=mgbOQe5EK+FJ2vRhq4eGXnJQmKcL9mPHu2z1c9b1gc5SZh/KXboYU8Stw80RWzs1/r 6/tJFOxEeweAjaNMqPWcZP6+We2AWWr7eVoo7j6vTnO2TDj3QBnJyoj5NhTAnxBbtp+o 7ls+bV5sT1Yx4zJcepUTjvUPjmPtp54C77WpZMqNuFN/xRqXT3CwBDL5Mik9mwkR98eV m/S44P7NMEF1aKMwv5iE5ehqnJbAkFiL3XjL27rMkt77Bd/DI7Y54/frughepr1aeoTH X1r5TbnQMkCjCz3om35J+lwKPM9nNgiHbh9b6XRTM6xWH3GIPALmL3c16nrqbRhnevRm zYQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796172003; x=1796776803; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=FkSCXQuEjN72Qu59EVeItljnnT76TyuuverwwE+ysiE=; b=tmZnho+DI4eR8qDRRLrtcYtF/n2XC68K8of1/VWRovgBhS7W5xiQVc+erNRyZXGzAr T1fHnPsOoWN5d/OqE+sIXATESpGXNLrfrf5uRRDsXQySEQ6YEqCXXGm1gRmM+jwABOhM b8LJ7LHuhuqSNNBNSv4iWNgZPDz5fijEXLlU7x3DiWH5DQpP5dilP1nm33dsB5rxSkRb 8/l3n3LrqMi3HwFFKKH46EPUGIwazVAU+45x2aazrC+aVENwF6gws2vjzqwiM5XDIVvO 6nFHcAi9Y76H1FhSkT8hL4tppEWmSc7QVdL7hENP3eMiP81cMTx8AW2LN2sYckluc61X 1bIg== X-Forwarded-Encrypted: i=1; AL+hErFUzwF4llnw2MWr+gZtDLCWKFhSt5s+4yvs76K2VTqbSjhnlVj24WguVVCDx3Ap1OWFW1688HeYtLr9Qbc=@vger.kernel.org X-Gm-Message-State: APuU4Z9xMTngegeD5uN9Bc5ATta9zNGl63CintB9eXgoEtIJmYC2upbo eL1D3Phu2VFnmhmtBrqTnsnVkgMrcFTJlc3i7JSna+1yrDkuAL45PazZcsBkLFC5A9zWDnDDe3/ V/boPRjunRabiwQ== X-Received: from ilec9-n2.prod.google.com ([2002:a05:6e02:6149:20b0:550:20ce:9237]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6808:c40e:b0:571:76cb:b4d2 with SMTP id 5614622812f47-57a0b03eeabmr47147841b6e.38.1796172002960; Tue, 01 Dec 2026 16:40:02 -0800 (PST) Date: Wed, 2 Dec 2026 00:39:41 +0000 In-Reply-To: <20261202003955.3607156-1-dmatlack@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261202003955.3607156-1-dmatlack@google.com> X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261202003955.3607156-5-dmatlack@google.com> Subject: [PATCH 04/18] selftests/liveupdate: Support building the kexec tests against nolibc From: David Matlack To: kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-pci@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Albert Ou , Alexandre Ghiti , Alex Williamson , Bjorn Helgaas , David Matlack , Jacob Pan , Jason Gunthorpe , Josh Hilke , Lukas Wunner , Mike Rapoport , Palmer Dabbelt , Parav Pandit , Pasha Tatashin , Paul Walmsley , Pranjal Shrivastava , Pratyush Yadav , Samiullah Khawaja , Shuah Khan , Vipin Sharma Content-Type: text/plain; charset="UTF-8" Add a NOLIBC=1 mode to the liveupdate selftests Makefile, which builds the tests that run across kexec, and the init process that runs them in vmtest.sh's VMs, as static binaries against nolibc. vmtest.sh builds these binaries with its own compiler invocations today, and this mode will let it use the Makefile instead. The liveupdate test is not built in this mode since it uses the kselftest harness, which requires libc. make clean removes the binaries of both modes. Fix two warnings in init.c that show up now that it is built with -Wall: an unused variable, and status possibly being used uninitialized if waitpid() fails. Signed-off-by: David Matlack --- tools/testing/selftests/liveupdate/Makefile | 13 +++++++++++++ tools/testing/selftests/liveupdate/init.c | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/liveupdate/Makefile b/tools/testing/selftests/liveupdate/Makefile index 31517a07f531..df0567e8ca15 100644 --- a/tools/testing/selftests/liveupdate/Makefile +++ b/tools/testing/selftests/liveupdate/Makefile @@ -1,6 +1,13 @@ # SPDX-License-Identifier: GPL-2.0-only +# With NOLIBC=1, build the tests that run across kexec, and the init process +# that runs them, as static binaries against nolibc. vmtest.sh uses this to +# build the initrds for its VMs. +ifeq ($(NOLIBC),) TEST_GEN_PROGS += liveupdate +else +TEST_GEN_FILES += init +endif TEST_GEN_PROGS_EXTENDED += luo_kexec_simple TEST_GEN_PROGS_EXTENDED += luo_multi_session @@ -12,6 +19,9 @@ TEST_FILES += do_kexec.sh include ../lib.mk include lib/libliveupdate.mk +ifneq ($(NOLIBC),) +CFLAGS += -static -nostdlib -nostdinc -I$(top_srcdir)/tools/include/nolibc +endif CFLAGS += $(KHDR_INCLUDES) CFLAGS += -Wall -O2 -Wno-unused-function CFLAGS += -MD @@ -31,4 +41,7 @@ $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED): $(OUTPUT)/%: $(OUTPUT)/%.o $(LIBLI $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $< $(LIBLIVEUPDATE_O) $(LDLIBS) -o $@ EXTRA_CLEAN += $(TEST_O) +# Clean up the binaries of both modes regardless of NOLIBC. +EXTRA_CLEAN += $(OUTPUT)/liveupdate $(OUTPUT)/liveupdate.o $(OUTPUT)/liveupdate.d +EXTRA_CLEAN += $(OUTPUT)/init $(OUTPUT)/init.d EXTRA_CLEAN += $(TEST_DEP_FILES) diff --git a/tools/testing/selftests/liveupdate/init.c b/tools/testing/selftests/liveupdate/init.c index fb08bd58b9b9..824c9da2facf 100644 --- a/tools/testing/selftests/liveupdate/init.c +++ b/tools/testing/selftests/liveupdate/init.c @@ -115,7 +115,8 @@ static int run_test(int stage) _exit(1); } - waitpid(pid, &status, 0); + if (waitpid(pid, &status, 0) < 0) + return -1; return (WIFEXITED(status) && WEXITSTATUS(status) == 0) ? 0 : -1; } @@ -144,7 +145,6 @@ static int get_current_stage(void) int main(int argc, char *argv[]) { int current_stage; - int err; if (mount_filesystems()) goto err_reboot; -- 2.56.1.911.g883d8bcb20-goog