Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1796644lqp; Mon, 15 Apr 2024 19:08:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUOUxlxvnMWhbVsI6fPVv72GQFKwqMTYJQlFXTvnH7mJmV0YQCoGa0aZg0etPSgV3agKLzHScgtTl0lpfFTmROGR4+DjRxs/3iM8qv0+g== X-Google-Smtp-Source: AGHT+IHHg2Z4lgBqk8mLRjcK/+PFQQLKPmQ/RQvjlDrrCOjW4exPgq0F/AobopLg8V3f2muRXreS X-Received: by 2002:a17:902:7c15:b0:1e1:6850:f628 with SMTP id x21-20020a1709027c1500b001e16850f628mr8858196pll.62.1713233315306; Mon, 15 Apr 2024 19:08:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713233315; cv=pass; d=google.com; s=arc-20160816; b=m5GSM5KFb9/J5YuTFs/7+otYTZum2EaCaQxNn8J5taPnQ8ToNERm0jsEnOcoUS2Rpv ToNZdGWAUnnv1zzQLnMiTozuDk2zSdMYGHvXZ5flrK9SYjX2K28hRBAfoe5lUK7DoeSu tr9VpBEPeOvfK63HQarvqxFxCWvnWNc3ZighwoXGC6ZpipuHxj3ufyOHbHPx5FhFBb2B Sjx/NiL6dJNE/YZ6m13HkLfOHgKjm8CyBKei3j1PPJn8pai7KbuMDhCHIKra9VB6Mrrj k4HJrRLYPcdGbjO0D5gVnzbd0yzPOmW4padMch7y9yitgt/DItSzav8FJslbGRTs8+h3 YS5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=9K95D3nDpGZ+n8v9ow7yRXDyUbknyraQfjvoWuoVjP0=; fh=EwD1YapWwf4taWOz96r4NJj8Ori5BQbaBElvywZ+Qo0=; b=fg0b69BRKOnx1UBxOdTbLn834bbbju9SfoLRY/tohMa/nHFaMhWgTWs/32XWeIhtqi lB51Qms6Luee/6oRLiwkDzRuNLeJBvBtrsYgao+euYA74wty3hjw/tN+qdcDipAR7n5N loTLnD4JHqO5X48h5h0fxPoM+bAwoxE6y+bJNyF4/0TdurGuCpe2vx5/QWTjTXmNHklk GSUr5O5oRITa2dYz4Ddzto0GGxh83prcfWpCceifdy6HEeSuldi8AxHxSWPquY16foMn ZMkwTRyLku5xDEy4EPmvnp4Or0ZVOnm4tpcAU271a0dZHBHzqgNEte+zCd/eAMYMFpJC XhiQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ox0pdq59; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-146098-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146098-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x5-20020a170902a38500b001e587993faasi7363898pla.626.2024.04.15.19.08.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 19:08:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146098-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ox0pdq59; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-146098-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146098-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E190328252C for ; Tue, 16 Apr 2024 02:08:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5A24EAD5; Tue, 16 Apr 2024 02:08:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ox0pdq59" 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 D2A8A8F5A; Tue, 16 Apr 2024 02:08:26 +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=1713233306; cv=none; b=qRPszWGZc2NzdUomLtBpgC7V5uzBPW5sEs4Btk9mBd1y1NI3zn7ilnzfJoWA2WGuY6wYhDm9OcNdTndVksNZ4jzYK8BtO3R3ItrAdog3l501O37X5KiZalEHrtYO2K+v784hkbkr4oflcfcsz+OgHujErztGi0U7KDxnqPlNjqg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713233306; c=relaxed/simple; bh=VhAfUesBXIj5iQJjWVdk62eijlIt6xnT4JPcmMlBOCg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=eWhXwpxhiUpUbvac2AC7zGa7je0tLARyUrREMVDAyQPGvj4uLlGnnmqmRqS3Y5gO2N0DtsjCrfOJALxrF0b8BveDdnF5kS2rTPfue+6sQUKSH6F4XpzDt7GkjoKzFmBDwdOARewQPxD8nSyoSXm2VfFG8mhqO8lnLmaGuzPjFhM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ox0pdq59; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E5ACC4AF08; Tue, 16 Apr 2024 02:08:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713233306; bh=VhAfUesBXIj5iQJjWVdk62eijlIt6xnT4JPcmMlBOCg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Ox0pdq591S2K5TAaKiWyCXXIFihPzLZvfqLORNG2uZZHOYzxjQWBl3hMwQr0YdEZ0 xUhcaGrKSJ75ODL2KKBR1kjjmE3WaoMrj7xhV07QpqJ7gbo+cQTPSr+rOQKQV9q4WC p9gaJK/aIBU55qGUDGXvFn6CHTH43sNQT5Vf5T6Lu/egzWTJE2BeWqM3SzlZe8pLVu uRKkoowOqxpSo9PLAIA5SR5gdAyYAB35i3qZ7jXZJhTKFjWO9nTtOGZ9uD3nDPk1u2 r/1nL8cwpjwAoT0/QhvQaQ9Zzm7aGIv3nMgAR4nQgmYvnnU6BPAXyWLdaEY19byUYA ARxmKPBOPg9Ww== Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2da63269e75so21475311fa.1; Mon, 15 Apr 2024 19:08:26 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCVgfNDolAhFodh7BJE9GImn9dl5NzQuOkZYQyj8VoPNCa0kfy/x/VQ//0T83hyQZwj7iw6NxFClUm7IvOoU9QECS/xahAK+rhT/68x3 X-Gm-Message-State: AOJu0YwsMZxxCLOepcgkvcznVbycGezXy1Ven5IVv4iORsd3eoppkl9l wlp0dIK98GwlPT3JtecxnHxxhXr7M6jmtvJSHCeHP8QgATFAwvKHIacZO4uymOuZCFcTVT7xUtp /2gNw4WvcDKDrlLvUdlAgiGD86FI= X-Received: by 2002:a2e:8758:0:b0:2d8:3bef:129 with SMTP id q24-20020a2e8758000000b002d83bef0129mr8357927ljj.10.1713233304895; Mon, 15 Apr 2024 19:08:24 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240414174139.3001175-1-masahiroy@kernel.org> In-Reply-To: <20240414174139.3001175-1-masahiroy@kernel.org> From: Masahiro Yamada Date: Tue, 16 Apr 2024 11:07:48 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] kbuild: buildtar: add comments about inconsistent package generation To: linux-kbuild@vger.kernel.org Cc: Albert Ou , Nathan Chancellor , Nicolas Schier , Palmer Dabbelt , Paul Walmsley , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Apr 15, 2024 at 2:42=E2=80=AFAM Masahiro Yamada wrote: > > scripts/package/buildtar checks some kernel packages, and copies the > first image found. This may potentially produce an inconsistent (and > possibly wrong) package. > > For instance, the for-loop for arm64 checks Image.{bz2,gz,lz4,lzma,lzo}, > and vmlinuz.efi, then copies the first image found, which might be a > stale image. > > When CONFIG_EFI_ZBOOT is enabled in the pristine source tree, > 'make ARCH=3Darm64 tar-pkg' will build and copy vmlinuz.efi. This is the > expected behavior. > > If you build the kernel with CONFIG_EFI_ZBOOT, Image.gz will be created, The correct sentence is If you build the kernel with CONFIG_EFI_ZBOOT disabled, ... > which will remain in the build directory unless you clean it. Even if > CONFIG_EFI_ZBOOT is turned on later, 'make ARCH=3Darm64 tar-pkg' will cop= y > stale Image.gz instead of the latest vmlinuz.efi, as Image.gz takes > precedence over vmlinuz.efi. > > In summary, the code "[ -f ... ] && cp" does not consistently produce > the desired outcome. > > The other package scripts are deterministic; scripts/package/mkdebian, > for example, chooses a copied kernel image based on CONFIG options. > > I removed [ -f ... ] checks from x86, alpha, parisc, and the default > because they have a single kernel image to copy. If it is missing, it > should be an error. > > I did not modify the code for mips, arm64, riscv. Instead, I left some > comments. Eventually, someone may fix the code, or at the very least, > it may discourage the copy-pasting of incorrect code. > > Signed-off-by: Masahiro Yamada > --- > > scripts/package/buildtar | 16 ++++++++++++---- > 1 file changed, 12 insertions(+), 4 deletions(-) > > diff --git a/scripts/package/buildtar b/scripts/package/buildtar > index 72c91a1b832f..ed8d9b496305 100755 > --- a/scripts/package/buildtar > +++ b/scripts/package/buildtar > @@ -53,18 +53,24 @@ cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux= -${KERNELRELEASE}" > # > # Install arch-specific kernel image(s) > # > +# Note: > +# mips, arm64, and riscv copy the first image found. This may not prod= uce > +# the desired outcome because it may pick up a stale file remaining in= the > +# build tree. > +# > case "${ARCH}" in > x86|i386|x86_64) > - [ -f "${objtree}/arch/x86/boot/bzImage" ] && cp -v -- "${= objtree}/arch/x86/boot/bzImage" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" > + cp -v -- "${objtree}/arch/x86/boot/bzImage" "${tmpdir}/bo= ot/vmlinuz-${KERNELRELEASE}" > ;; > alpha) > - [ -f "${objtree}/arch/alpha/boot/vmlinux.gz" ] && cp -v -= - "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdir}/boot/vmlinuz-${KERNELR= ELEASE}" > + cp -v -- "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdi= r}/boot/vmlinuz-${KERNELRELEASE}" > ;; > parisc*) > - [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "$= {tmpdir}/boot/vmlinux-${KERNELRELEASE}" > + cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-${KERN= ELRELEASE}" > [ -f "${objtree}/lifimage" ] && cp -v -- "${objtree}/lifi= mage" "${tmpdir}/boot/lifimage-${KERNELRELEASE}" > ;; > mips) > + # Please note the following code may copy a stale file. > if [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.bin= " ]; then > cp -v -- "${objtree}/arch/mips/boot/compressed/vm= linux.bin" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" > elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.e= coff" ]; then > @@ -86,6 +92,7 @@ case "${ARCH}" in > fi > ;; > arm64) > + # Please note the following code may copy a stale file. > for i in Image.bz2 Image.gz Image.lz4 Image.lzma Image.lz= o vmlinuz.efi ; do > if [ -f "${objtree}/arch/arm64/boot/${i}" ] ; the= n > cp -v -- "${objtree}/arch/arm64/boot/${i}= " "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" > @@ -94,6 +101,7 @@ case "${ARCH}" in > done > ;; > riscv) > + # Please note the following code may copy a stale file. > for i in Image.bz2 Image.gz Image; do > if [ -f "${objtree}/arch/riscv/boot/${i}" ] ; the= n > cp -v -- "${objtree}/arch/riscv/boot/${i}= " "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" > @@ -102,7 +110,7 @@ case "${ARCH}" in > done > ;; > *) > - [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "$= {tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}" > + cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild= -${KERNELRELEASE}" > echo "" >&2 > echo '** ** ** WARNING ** ** **' >&2 > echo "" >&2 > -- > 2.40.1 > -- Best Regards Masahiro Yamada