Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp333039rdb; Sat, 19 Aug 2023 03:53:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzLEDSyRSgPgP3knXxKYEo1SRKtG6r41ln3nikBk1n24mM7jsY46lC/xc+xBL54Yd/2I1v X-Received: by 2002:a17:903:24f:b0:1b8:4e00:96b with SMTP id j15-20020a170903024f00b001b84e00096bmr2122719plh.9.1692442379736; Sat, 19 Aug 2023 03:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692442379; cv=none; d=google.com; s=arc-20160816; b=tQBdN7GLZg5HPdcgypkaD2Blv11fB2TkHYO2vIHL8+kBmPgtt32nq+VPvGa6dqZVtU Jp8ouZmgOtnGTE5oM3OoexWfkr9MyDTvkUtqWSKZgAzS0uvWHjjhWVormRM+xuxa9B/H pKOaGWePUa1Bc4bglMWSsnatHSAUM81EmLNJEB9Stv9vx34TA9hPEUJzS//45Ohtyhxj F7MXagvTIGW7vM1MVftsAT5R87mpuawBdv0FPVoa0tQ/hMOgW5nSVMr6/z918h7Q1ay5 2MMv3Dbu3TnyukpvXvCDXOA9rYm2yDXND2WfAbwtUmdUpg3YQvReJBxeDkmXTpd+Tgl5 S7qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9dOtuH9H7MwhCXwQuf+990jtH/iwab4iwj17t3PCVRo=; fh=2K0cnVWNN/lSoXOQ2Jt2UifFp/1e7O4elwn57wGf9gU=; b=km0+mtKgxYZZ3WKoqf33qor7nvsje2LLdRcTJP9fOmWTG74SHLxwcWzSJCGM99sRkp wer/qcb3qhVyG1MKEdzC+C7mCsjxNCKeiUrWDq08EEyVbZxTDwLYJ/0X2wQ5wO5U62ul Ko/83EqSn0vhb12Im3p1jLN1eicl/j3SSBjeQFiYVJvuw6qC6PcyMxwj0xOEQ3j4aNZH CiqTofyveLvf4bJUtxhecluuSktH88oRvg4pDEv3pPzQXBlcCbfxtBYoq1ENdLTqwich erzQ8byaIhDtPwogfWE/iLcZV+hu9Y+uLHkHKuR1IiHEV5QLthGlC2uxlCn0TJF3xyeo ERcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EXcjGDYg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q8-20020a170902a3c800b001beeb49d890si3198160plb.185.2023.08.19.03.52.46; Sat, 19 Aug 2023 03:52:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EXcjGDYg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377300AbjHRNpz (ORCPT + 99 others); Fri, 18 Aug 2023 09:45:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377274AbjHRNpX (ORCPT ); Fri, 18 Aug 2023 09:45:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 415C93C2F; Fri, 18 Aug 2023 06:45:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CFA1666DF3; Fri, 18 Aug 2023 13:45:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A6ABC433C9; Fri, 18 Aug 2023 13:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692366311; bh=7IcFenlYVGAMFMpSXq5CG+YnsHh0HQ4d1FXSlrsrYKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EXcjGDYgaKCgo5SWQiGZLD9qyb8AmfkxHy14VQKc+OcCdHtYDMcKlB9hFsMRI32vd cSrzgfWrauShBUASjt6hVP2HCEZAAsWFdTW+CW53dmBqcLdKOBi7Bwtqgo6SMD82Ds 6/t88t+HnfB4HHXmIntOfjMlwcZgWubpbcu+/mnwZIImm4lb3tjdAOC1Ulu3h1HAqk VRQo0qGt7YhWlC8/xjy5uJvBfPr9R9Eo3SFLsqY1VPw+/GOJ/15NNoEEVLMBZOFTYV 7ChO8MfK5q9glgmRjLct+BZbS3whsPCfoJHe49n6HcbShP+1+rBHCZE8Tvs8Q5BW2P Cd6heUAGZ8b7w== From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel , Evgeniy Baskov , Borislav Petkov , Dave Hansen , Ingo Molnar , Thomas Gleixner , Peter Jones , Matthew Garrett , Gerd Hoffmann , Kees Cook , "H. Peter Anvin" , =?UTF-8?q?Marvin=20H=C3=A4user?= Subject: [PATCH 09/17] x86/boot: Set EFI handover offset directly in header asm Date: Fri, 18 Aug 2023 15:44:14 +0200 Message-Id: <20230818134422.380032-10-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230818134422.380032-1-ardb@kernel.org> References: <20230818134422.380032-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3237; i=ardb@kernel.org; h=from:subject; bh=7IcFenlYVGAMFMpSXq5CG+YnsHh0HQ4d1FXSlrsrYKU=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIeV+6bKJXtFVTB4nHper/+d1zFza8XDPvJWu4rvm6GeKf dCdc96ho5SFQYyDQVZMkUVg9t93O09PlKp1niULM4eVCWQIAxenAEyk9y8jw82XWmfXnlulXdKm KPl3x+N57LbppitWLP3klVfS/K3fwoSRYfmSE5HVFfK7ks54sxzedy5bnn/VpupzNWa59twN31J vsgEA X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The offsets of the EFI handover entrypoints are available to the assembler when constructing the header, so there is no need to set them from the build tool afterwards. Signed-off-by: Ard Biesheuvel --- arch/x86/boot/header.S | 18 ++++++++++++++- arch/x86/boot/tools/build.c | 24 -------------------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S index 5575d0f06bab1918..72744ba440f6ea09 100644 --- a/arch/x86/boot/header.S +++ b/arch/x86/boot/header.S @@ -524,8 +524,24 @@ pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr # define INIT_SIZE VO_INIT_SIZE #endif + .macro __handover_offset +#ifndef CONFIG_EFI_HANDOVER_PROTOCOL + .long 0 +#elif !defined(CONFIG_X86_64) + .long ZO_efi32_stub_entry +#else + /* Yes, this is really how we defined it :( */ + .long ZO_efi64_stub_entry - 0x200 +#ifdef CONFIG_EFI_MIXED + .if ZO_efi32_stub_entry != ZO_efi64_stub_entry - 0x200 + .error "32-bit and 64-bit EFI entry points do not match" + .endif +#endif +#endif + .endm + init_size: .long INIT_SIZE # kernel initialization size -handover_offset: .long 0 # Filled in by build.c +handover_offset: __handover_offset kernel_info_offset: .long ZO_kernel_info # End of setup header ##################################################### diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c index 14ef13fe7ab021e7..06949754316458ce 100644 --- a/arch/x86/boot/tools/build.c +++ b/arch/x86/boot/tools/build.c @@ -55,8 +55,6 @@ u8 buf[SETUP_SECT_MAX*512]; #define PECOFF_COMPAT_RESERVE 0x0 #endif -static unsigned long efi32_stub_entry; -static unsigned long efi64_stub_entry; static unsigned long efi_pe_entry; static unsigned long efi32_pe_entry; static unsigned long _end; @@ -265,31 +263,12 @@ static void efi_stub_defaults(void) #endif } -static void efi_stub_entry_update(void) -{ - unsigned long addr = efi32_stub_entry; - -#ifdef CONFIG_EFI_HANDOVER_PROTOCOL -#ifdef CONFIG_X86_64 - /* Yes, this is really how we defined it :( */ - addr = efi64_stub_entry - 0x200; -#endif - -#ifdef CONFIG_EFI_MIXED - if (efi32_stub_entry != addr) - die("32-bit and 64-bit EFI entry points do not match\n"); -#endif -#endif - put_unaligned_le32(addr, &buf[0x264]); -} - #else static inline void update_pecoff_setup_and_reloc(unsigned int size) {} static inline void update_pecoff_text(unsigned int text_start, unsigned int file_sz) {} static inline void efi_stub_defaults(void) {} -static inline void efi_stub_entry_update(void) {} static inline int reserve_pecoff_reloc_section(int c) { @@ -332,8 +311,6 @@ static void parse_zoffset(char *fname) p = (char *)buf; while (p && *p) { - PARSE_ZOFS(p, efi32_stub_entry); - PARSE_ZOFS(p, efi64_stub_entry); PARSE_ZOFS(p, efi_pe_entry); PARSE_ZOFS(p, efi32_pe_entry); PARSE_ZOFS(p, _end); @@ -416,7 +393,6 @@ int main(int argc, char ** argv) update_pecoff_text(setup_sectors * 512, i + (sys_size * 16)); - efi_stub_entry_update(); crc = partial_crc32(buf, i, crc); if (fwrite(buf, 1, i, dest) != i) -- 2.39.2