Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5824776rdb; Sun, 17 Sep 2023 14:21:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbCjQPFdzGAyugwYWT9edil1Knivvxm7IwNoy/BJtYnUzz+CRxfSTQhrA+uFOyYR+WEDim X-Received: by 2002:a05:6870:8456:b0:1ba:ddf2:417f with SMTP id n22-20020a056870845600b001baddf2417fmr9750621oak.2.1694985700680; Sun, 17 Sep 2023 14:21:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694985700; cv=none; d=google.com; s=arc-20160816; b=bcujxBcNIhxuwwa1RJ21d4XK3mBomMjIozfW+TqxtO5wr6+ALtwK30VKsFmag5OIxX iIIXgw064a1/QxatI9c3sk5s+Zw8orq7yF6DXUyLf9eLYsSzfSfn42M4/aHI4TYrQ1oG EccOH2vI441+CZSDng46ifnS52tpgTHGzLEjXC5U5v4bPu07dzRNWskkyr5RvgiudyZe qSBHsLMHIEPaErvlt2Yvr8vNN/+PccmfeKDDSEk2Ni/oiF2DUUgeR3eQ6SWT9g5WqkWK maKj+vXTS+ah4a/1k9by8FA7PcPfGIHcefCWrQZMHtsLD33uwUqBkNJM1hDbwStckFGX vmkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=kmbTHz0oxyRq0ilV2+qpm/m2KASgVKj0aN/6CNBu2n0=; fh=mh/EFXDyWz6SYA4qEbcbMgOZ07AT4DlRJonTEXgTb50=; b=z0Hnn5IPQdACJmTfKHBMTb0ReiQdBwl7IZljTeiQ5DFdq0GTc+vmQT6VHqpu1ct47d tHtCCQTyTQ9NYKrd/0F6uN1VClWdXiJplNhwOXPnAbV5u0Aw38xWIEKEytBw89aqNq3H 77HuvWoKp20Lh691iTayr5a8pewzP2eriVkZdbZcdYbXInLc9/llCQ9I3zemgd7aZa+L r98ol0ka3ARavBA7z5b0NkaFn2VX9x/2sY5SYY1tGfaBNW5VvWH44bdpndlC7nij2/Yk wXp0dJh9uVKebunRqfbtLVtRGgA3Ple9/vgoQr8ysf3zLMCds43pWq2p4H4LCnfU1HdT eSfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=EGp9U5jK; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id h38-20020a631226000000b0056950e1546asi6139594pgl.356.2023.09.17.14.21.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:21:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=EGp9U5jK; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id DF26381F3566; Sun, 17 Sep 2023 11:16:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238649AbjIQSNQ (ORCPT + 99 others); Sun, 17 Sep 2023 14:13:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238333AbjIQSNC (ORCPT ); Sun, 17 Sep 2023 14:13:02 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85B3B135; Sun, 17 Sep 2023 11:12:55 -0700 (PDT) Date: Sun, 17 Sep 2023 18:12:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694974372; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kmbTHz0oxyRq0ilV2+qpm/m2KASgVKj0aN/6CNBu2n0=; b=EGp9U5jKCdAnqeqoXL9HlPux59j3cMJpx4by/43tl/Jwa2jMUGzGB3SGFT3ZHhx6JU2MPl 8fqNtyWTvDp6UQK8ksaQKH1jyafi+HqmSKn9fC2icIJ0om341TJRUCVx9zMrM3eUqKS3g4 rwZ0WgoLHmRyUkWQU4Ycw6b0GcPrq3Y5wa7hFFPd9ocHX5UGnx8iTrab2dIGoKljd3UKfG b0zinTB4RV9eE0GjOKo/FbFweAjObjQbuP+bS1K2LadLzPIVBUo8Y6mIf2fOb6uVH8VOSp gaAT0ft0/pzC5X1QCfPQ2H1SmeBLBPCwjFgILLfjeU4iETKPOsGllbC54F2mMw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694974372; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kmbTHz0oxyRq0ilV2+qpm/m2KASgVKj0aN/6CNBu2n0=; b=Wy/mhCPoblq8Xhev5zkKx3LCwm5bfQ2slL5LHd//eG655iov3qoXRcclv80MbyEg3BJZtM SPvVF3qdXV40PqDQ== From: "tip-bot2 for Ard Biesheuvel" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/boot] x86/boot: Define setup size in linker script Cc: Ard Biesheuvel , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230915171623.655440-13-ardb@google.com> References: <20230915171623.655440-13-ardb@google.com> MIME-Version: 1.0 Message-ID: <169497437144.27769.10481980684639575351.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Sun, 17 Sep 2023 11:16:51 -0700 (PDT) The following commit has been merged into the x86/boot branch of tip: Commit-ID: 093ab258e3fb1d1d3afdfd4a69403d44ce90e360 Gitweb: https://git.kernel.org/tip/093ab258e3fb1d1d3afdfd4a69403d44ce90e360 Author: Ard Biesheuvel AuthorDate: Fri, 15 Sep 2023 17:16:27 Committer: Ingo Molnar CommitterDate: Sun, 17 Sep 2023 19:48:42 +02:00 x86/boot: Define setup size in linker script The setup block contains the real mode startup code that is used when booting from a legacy BIOS, along with the boot_params/setup_data that is used by legacy x86 bootloaders to pass the command line and initial ramdisk parameters, among other things. The setup block also contains the PE/COFF header of the entire combined image, which includes the compressed kernel image, the decompressor and the EFI stub. This PE header describes the layout of the executable image in memory, and currently, the fact that the setup block precedes it makes it rather fiddly to get the right values into the right place in the final image. Let's make things a bit easier by defining the setup_size in the linker script so it can be referenced from the asm code directly, rather than having to rely on the build tool to calculate it. For the time being, add 64 bytes of fixed padding for the .reloc and .compat sections - this will be removed in a subsequent patch after the PE/COFF header has been reorganized. This change has no impact on the resulting bzImage binary when configured with CONFIG_EFI_MIXED=y. Signed-off-by: Ard Biesheuvel Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20230915171623.655440-13-ardb@google.com --- arch/x86/boot/header.S | 2 +- arch/x86/boot/setup.ld | 4 ++++ arch/x86/boot/tools/build.c | 6 ------ 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S index 72744ba..06bd72a 100644 --- a/arch/x86/boot/header.S +++ b/arch/x86/boot/header.S @@ -231,7 +231,7 @@ sentinel: .byte 0xff, 0xff /* Used to detect broken loaders */ .globl hdr hdr: -setup_sects: .byte 0 /* Filled in by build.c */ + .byte setup_sects - 1 root_flags: .word ROOT_RDONLY syssize: .long 0 /* Filled in by build.c */ ram_size: .word 0 /* Obsolete */ diff --git a/arch/x86/boot/setup.ld b/arch/x86/boot/setup.ld index b11c45b..9bd5c1a 100644 --- a/arch/x86/boot/setup.ld +++ b/arch/x86/boot/setup.ld @@ -39,6 +39,10 @@ SECTIONS .signature : { setup_sig = .; LONG(0x5a5aaa55) + + /* Reserve some extra space for the reloc and compat sections */ + setup_size = ALIGN(ABSOLUTE(.) + 64, 512); + setup_sects = ABSOLUTE(setup_size / 512); } diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c index 0694975..745d64b 100644 --- a/arch/x86/boot/tools/build.c +++ b/arch/x86/boot/tools/build.c @@ -48,12 +48,7 @@ typedef unsigned int u32; u8 buf[SETUP_SECT_MAX*512]; #define PECOFF_RELOC_RESERVE 0x20 - -#ifdef CONFIG_EFI_MIXED #define PECOFF_COMPAT_RESERVE 0x20 -#else -#define PECOFF_COMPAT_RESERVE 0x0 -#endif static unsigned long efi_pe_entry; static unsigned long efi32_pe_entry; @@ -388,7 +383,6 @@ int main(int argc, char ** argv) #endif /* Patch the setup code with the appropriate size parameters */ - buf[0x1f1] = setup_sectors-1; put_unaligned_le32(sys_size, &buf[0x1f4]); update_pecoff_text(setup_sectors * 512, i + (sys_size * 16));