Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4496670rdb; Fri, 15 Sep 2023 04:15:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETk9jdIWQMRWXwYX2pupvRejoao+xusQTbiUoQ4PCQJXmTsyQIqjm+rJTAc593rn3oMwLM X-Received: by 2002:a17:903:32cf:b0:1b8:8ff5:2cee with SMTP id i15-20020a17090332cf00b001b88ff52ceemr1461768plr.64.1694776553241; Fri, 15 Sep 2023 04:15:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694776553; cv=none; d=google.com; s=arc-20160816; b=bW+s9VUlQn7YN1CIVViSob+OW2fwlI2qu0ZmrBlRnznJd80xXKUzrmCofgdtekOrz4 gWzVttfaboAIhphn3M5not3tTpVSI3Q72UhhKsRtHSmgMa9xYbStiTnYpW40ttAiujpq U22J6m0KNXyR9LJYS/TWQceEOXi8f0HSpyP5ZTItl+p6RmKgJvL/XXOTciXmIQnvoAZ6 y/WXegE4OM2n5Oi9VrmKP8jcHacSbSuyigp0+nJ9Bm0mrrfkAhSM86y+XidzrfWz7Yj0 FAqkOgIFek8Y3pTjmWWRPyrwxoaS4XryosephUGX9lTU1Lf6IPHKmui9g2UjPSk88DG/ 5uWA== 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=SOPVTewIEsdJFEdGxeIXrxTA0ujLRVLPJN1kHfZ4fqc=; fh=mh/EFXDyWz6SYA4qEbcbMgOZ07AT4DlRJonTEXgTb50=; b=CfP5OGSLa9B3+a5SydecCJFlCpfRgPu9jEPtX89+1KHTcOUoIl45hj0f8LPHWKtQCN B5b12oFfax5x6wetUPdCeMy6LLBET2nKBGTlJpmnTr9N7eU6HAxWdvfhu9EwqyYV+Yk2 we+lcRgtMRcuKVVT7slpkNlk4MZyXmYf5vuOs1WcVlem6wrqScJLfuTwEm+BKOEDlX8W GTplHRVClfRkGNdwJqjXw7R1UjyrHL6WWwxn0sZS12tX+yjuM8h1oR8SHFFQ+fwGbKrC t112VFWZuK42U8wSVaQ/M1q/rkwqhKAyBz5nN8Ma7DKDDcoiELOH8ojj+Zoj/WGTuN4K 405w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=C07p3FS6; dkim=neutral (no key) header.i=@linutronix.de header.b=DQEgUkr7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id z16-20020a170902d55000b001bf095dfb7asi3277975plf.231.2023.09.15.04.15.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 04:15:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=C07p3FS6; dkim=neutral (no key) header.i=@linutronix.de header.b=DQEgUkr7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 1CEFD83B3627; Fri, 15 Sep 2023 02:38:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233117AbjIOJiN (ORCPT + 99 others); Fri, 15 Sep 2023 05:38:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233471AbjIOJiM (ORCPT ); Fri, 15 Sep 2023 05:38:12 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0693D210A; Fri, 15 Sep 2023 02:37:48 -0700 (PDT) Date: Fri, 15 Sep 2023 09:37:46 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694770666; 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=SOPVTewIEsdJFEdGxeIXrxTA0ujLRVLPJN1kHfZ4fqc=; b=C07p3FS6Q6cg7DFbkQCpwtH4JoozO7AQvOmfWYBFu6zbh/VOR0/EjuFBEJpJnITomY22pS yPS8GSpCVWkD2XEebFo24hY63r2GFYMZQ5QJ4GspsxAzFbw523DSz0gHm6Nt6i/S6SAPWn xlKnS+2sqszz3pN59+n3YWDZc+pewqdogN9gnitc0wSACCfs1o0X9RyBh4aJ2krubEOOkk z2AZB5RS/3MIj+uNSroqGjAN/+3iKvwe79tbruc6gMtZ8bGZcl5Wlrejfjwd4mBJVyjynP WSzewe6qzPtKfWfyihpMlyW2rtmZtl5pSNQJ16sWXrWVNW+HAynQ2v95XhjaKw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694770666; 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=SOPVTewIEsdJFEdGxeIXrxTA0ujLRVLPJN1kHfZ4fqc=; b=DQEgUkr7/pZLTpcEvXF5vBx0qHZmTGPh49AkU/8RInL/+NNSoh0+JusRvTFY7Rv6Lbn7rc vdpMRu3qlQdk1uDA== 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: <20230912090051.4014114-27-ardb@google.com> References: <20230912090051.4014114-27-ardb@google.com> MIME-Version: 1.0 Message-ID: <169477066609.27769.6739184359715822628.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.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Fri, 15 Sep 2023 02:38:13 -0700 (PDT) The following commit has been merged into the x86/boot branch of tip: Commit-ID: 988b52b207a9fe74c3699bda8c2256714926b94b Gitweb: https://git.kernel.org/tip/988b52b207a9fe74c3699bda8c2256714926b94b Author: Ard Biesheuvel AuthorDate: Tue, 12 Sep 2023 09:01:01 Committer: Ingo Molnar CommitterDate: Fri, 15 Sep 2023 11:18: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/20230912090051.4014114-27-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 6059f87..36011b2 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..f125f17 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 = ABSOLUTE(ALIGN(. + 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 10b0207..bcbae88 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 efi32_stub_entry; static unsigned long efi64_stub_entry; @@ -413,7 +408,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));