Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp515538rdf; Tue, 21 Nov 2023 08:37:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+tzWpRncyaFjNrEe3cu+Q/Vllm2aAz9FEv5b5qVYtSQ2oSaO7nF5VW9IKNgGe6RKc56BW X-Received: by 2002:a17:902:c40e:b0:1cc:2094:52af with SMTP id k14-20020a170902c40e00b001cc209452afmr9083974plk.52.1700584645531; Tue, 21 Nov 2023 08:37:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700584645; cv=none; d=google.com; s=arc-20160816; b=BeKsWDyFYm4aevh0rVuvXqRdlYGxFP45PwQoGVlEkYcSWAccbCyPoOA+nMaID0arph hvSuYN4a61BM6UkvyheILpMdG5uko6Ei9XzBQNabS9Nzaj/XYyWQijt/wZlBUqCnQl3E 4i1QOBV2w3kyXVeHuqnUDvsocQ8SliecQI2c7EbizQPxUzwDl5eI7YVBOkWCPsQU5lh+ 5Y2PdpQOA4l20cHtpV1d9WUb44xwo6+z98ww8zdF0sJ4Zs7HSNK8WdYvotHum/xvNZoi vGG0Ynk7Kw1rW1eyDU42jg4qX+wc/6n7Zs/CvPI3HXLpKfgLAKozaNJSYRX7xeQj1SkS GGCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=7CBdb/j/cWoTsjKOWidB9rwyi3aWKqU2gckF0DJQ4lY=; fh=v+MK8JcJraam+JmG4iAhcPz1WGh8JvsQBa00opeS23k=; b=TVtewC6oN4yeUNNl4oNYkhnvCgiRwbn7Exf5O0xavVm5a5Xw76L2yJe6fyBtf9X3k6 OcMQB/Fgl9EGz+n0JTwFXzVeiFxC+eNJDB0m+YKiSKsbwe5x/JOf6WzDNAYM+BbI5e1l UqFQJWT1jSYdE4aAYpXsvruTIsEOKQ4q579a9UpMvN3FvFR0C7XGYfvmTILrCHv1Hh90 gGCy9lEh/IQ8YcQhOnooUVa8f3dwx20NCMcX3uQbGIvzVP1k2wWVnl11Rqg9bvqjsGVP +ist0JVdBux8pERuuAUwISk0sYszG/PxUfKle3BygT6IMkLtGNmAeKsznkvadVTGeEUD lhlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="o/cCR2Wv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id n14-20020a170903110e00b001c747cafce9si10772143plh.231.2023.11.21.08.37.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 08:37:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="o/cCR2Wv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 65E3880C4783; Tue, 21 Nov 2023 08:36:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233767AbjKUQfv (ORCPT + 99 others); Tue, 21 Nov 2023 11:35:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233066AbjKUQfq (ORCPT ); Tue, 21 Nov 2023 11:35:46 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4EBE191 for ; Tue, 21 Nov 2023 08:35:42 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8ABB6C433D9; Tue, 21 Nov 2023 16:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700584542; bh=jwL03/K8YeD2jnmP6ZZpSn8RsDsIl0wx5YcIiq9/kBQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=o/cCR2Wv6DY8Q+Bq6b9PspN6JJ6/f7prp3yUBZOtiHiXJwBMlDEuzSHhKtYDyBqKR B6lI7NvWbuGrp9IkvZyyxBhUPSFiBBMmB/DP+USJlYXzgttwAT79LmGoRkQOV4x+TN f+1xE+VybJXRn5emR0dxJ/Sd+/IIbtGkkpHl70ZqyG1phOpYpc4+cPPArKAcf4yXd2 /RDjpY2RTiB43vFpasMZTahEeO+kRCRFASFkLnk3KQbAjWxrZhhXDjpJgvrO2IShAs bD/14zR8yPcHnRQvqswOlMWhBznjFkkwpe2IaCNHAa9gl/Yjzx6ifbi4+HQlIQS/FP JYV33mT6VfSsw== Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2c876e44157so38606381fa.2; Tue, 21 Nov 2023 08:35:42 -0800 (PST) X-Gm-Message-State: AOJu0YwdkBYuNEbCdUYddPiYJkdD1KbeC1d8+KBhV+AGPnQPUk0ewKJW 5wOOxS/IptSCSa+sMCQJ/a3iW8+g91WyoW4D8dY= X-Received: by 2002:a2e:9101:0:b0:2c5:32b:28fa with SMTP id m1-20020a2e9101000000b002c5032b28famr9662302ljg.30.1700584540586; Tue, 21 Nov 2023 08:35:40 -0800 (PST) MIME-Version: 1.0 References: <20231119053234.2367621-1-masahiroy@kernel.org> In-Reply-To: <20231119053234.2367621-1-masahiroy@kernel.org> From: Ard Biesheuvel Date: Tue, 21 Nov 2023 11:35:29 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] arm64: add dependency between vmlinuz.efi and Image To: Masahiro Yamada Cc: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Simon Glass Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 21 Nov 2023 08:36:31 -0800 (PST) On Sun, 19 Nov 2023 at 00:32, Masahiro Yamada wrote: > > A common issue in Makefile is a race in parallel building. > > You need to be careful to prevent multiple threads from writing to the > same file simultaneously. > > Commit 3939f3345050 ("ARM: 8418/1: add boot image dependencies to not > generate invalid images") addressed such a bad scenario. > > A similar symptom occurs with the following command: > > $ make -j$(nproc) ARCH=arm64 Image vmlinuz.efi > [ snip ] > SORTTAB vmlinux > OBJCOPY arch/arm64/boot/Image > OBJCOPY arch/arm64/boot/Image > AS arch/arm64/boot/zboot-header.o > PAD arch/arm64/boot/vmlinux.bin > GZIP arch/arm64/boot/vmlinuz > OBJCOPY arch/arm64/boot/vmlinuz.o > LD arch/arm64/boot/vmlinuz.efi.elf > OBJCOPY arch/arm64/boot/vmlinuz.efi > > The log "OBJCOPY arch/arm64/boot/Image" is displayed twice. > > It indicates that two threads simultaneously enter arch/arm64/boot/ > and write to arch/arm64/boot/Image. > > It occasionally leads to a build failure: > > $ make -j$(nproc) ARCH=arm64 Image vmlinuz.efi > [ snip ] > SORTTAB vmlinux > OBJCOPY arch/arm64/boot/Image > PAD arch/arm64/boot/vmlinux.bin > truncate: Invalid number: 'arch/arm64/boot/vmlinux.bin' > make[2]: *** [drivers/firmware/efi/libstub/Makefile.zboot:13: > arch/arm64/boot/vmlinux.bin] Error 1 > make[2]: *** Deleting file 'arch/arm64/boot/vmlinux.bin' > make[1]: *** [arch/arm64/Makefile:163: vmlinuz.efi] Error 2 > make[1]: *** Waiting for unfinished jobs.... > make: *** [Makefile:234: __sub-make] Error 2 > > vmlinuz.efi depends on Image, but such a dependency is not specified > in arch/arm64/Makefile. > To clarify, this dependency /is/ specified in arch/arm64/boot/Makefile, which is consumed by explicit make invocations from arch/arm64/Makefile, and these may end up racing with each other. > Signed-off-by: Masahiro Yamada Acked-by: Ard Biesheuvel > --- > > arch/arm64/Makefile | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile > index 4a1ad3248c2d..47ecc4cff9d2 100644 > --- a/arch/arm64/Makefile > +++ b/arch/arm64/Makefile > @@ -158,7 +158,7 @@ endif > > all: $(notdir $(KBUILD_IMAGE)) > > - > +vmlinuz.efi: Image > Image vmlinuz.efi: vmlinux > $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ > > -- > 2.40.1 >