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=1796172004; b=tCewzH21yxcrkIeCdJVtV/7ynSRDdXckSRUo4MCP2wlJIdA5e7YJWT0Nu+j+PgCxf1go kiiNTxB5TXjw7thQbnCco5h/fmY9nMXIzgCD1wH4utg3gppij+hLcQlrEWAx8DNyV/Rds B3LafHoD3Uco7ottrR6fqewFMGPQOCL4EcDIE6bnVbn+EICCwDrHBWd/ctOwD8Fy62Qp8 W1Q5c6uzjCQ5AYzhnHOqBHosv5/K0/Ch5yQpyFr3RsZeGDk6H0rq6C5ci+JNx7VMy1321 Bsk6BNyWh0116Nv0D7+dQk82w9CIbPHs4tIqwMiguX2GhoCA0jxbjsIlrhXxBlKd8ag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796172004; 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=UFKapJAd8OXjvpXDrHoAKIOvmMgMAuotQcs6JcWDH6qBufUi6sZwW+pvDOgCxyRRT8bb BBfbrXVSMif58ZHPHbaZauODOC69bHuFw7RmyCsN6rNaVLje4QSTWla0C8F5WjxwGT9b2 99eCZzZBTfc9P15qRPUjx+in61udKRWXtROHA6Qea+dQ4f8UOWqzBH5fU/3dEQZ5xSyyc x8aA6bYZZa1fJH5zCL5do8ffbGGGCOi1nCudYEQKifiqihDZZxJ4Y+rj84gxRTF0odbwf Q0t4j221rVm45Av0GceA3rp8raXckayBdX/YCWrLfE+NmstKp20oJFC6t5c9WrKnJBA== 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 38F4B606A6B1 for ; Wed, 2 Dec 2026 00:40:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 38F4B606A6B1 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-5727b04b81eso7801124b6e.3 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=yQFshtukhZ3N6pB03Kq/fF4ZenRBKvdjidHFmeSAgstVVZQOlHgwLGzAe/qdH9gawZ mm35zGk/jZqbCtZsUtDuIUpgOVXwUpK+GAw1Aw7D9EBrKuJt71fYDMGvSV4Kpd37rwt4 7K8T3czW8N9ShOIcbTuqRiswgH+PflFS35U+tCoE07EHQYtMWy77mQjtpHcji7cRFusx eIcb1mNNJDI6eG3KM7O7FSjy/6wkZrnx+lGf9bXffjMOTRXCg2+pSVB1hQUqrzjDIKoT l3dkaPmUdfcKuZ2HvlcAT5Jzvbf9467vtVsJCADOXt2qArokHOPzsnpm1ymyWhFbGwC7 CmJg== X-Forwarded-Encrypted: i=1; AL+hErF+tqMkgFJiArRORoA1EtPQL8TlG79I8bLvl71Ex/sRU8qCHxhCpj6goq4AEdJ8wemiN/wJWIx9w1M=@vger.kernel.org X-Gm-Message-State: APuU4Z8CP9nLLyvFDzPXumavcHJyNLoADMuC632zAAhEqE/VGb/xXoR7 0uK7L76EipVveXFITI/FWoscOyDPzBVhgd/X1i44X7adjX3TwTrBpJXXOjMlV/6982XeHBTVFD3 ivW9TKM/oAYkvow== 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-pci@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