From patchwork Mon May 8 07:03:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 90979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1965693vqo; Mon, 8 May 2023 00:12:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6VJXisiqbPPH59NwGH3D6VyRVYzL19g4jeVMOwx/wrIb6ToILWe32cohaKsM1eOm3SVNfh X-Received: by 2002:a17:902:c943:b0:1a9:2a9e:30a8 with SMTP id i3-20020a170902c94300b001a92a9e30a8mr18933019pla.9.1683529961678; Mon, 08 May 2023 00:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683529961; cv=none; d=google.com; s=arc-20160816; b=t9CH0TqoyBADUrC410B/v2IoTl5TAQvrv9peL/HyiTFv+ta3UWXisI6v4l0CPuFNMI x9ReYlg/0VV/TFKIvco/HPHUeUaMzgbyQNoMAWrI45Z9gbuXkiUHInJQ7QcIDKoWjxA6 Sr0d/RyG9vd1yQwN7eGj5FpXWJSeTl8ZgLlQRTB+HLhAwuH/nziXihSXrFckgwcaTaoc sRXiU0zV6mlhEhrNXglvdWhonwegc4TjUmRARijNgDkfPuETTkXJb/zWczOUIobpI9jm nV55CGkVA/jN/4mVF2Tw16Kr6S4TQ0eQeb/n7mTLcj4g431WFXC+SlNt71PNpZfCviZe ZHhg== 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=3PCdVDmWl2706NLJp78PUjS8hcba+zL0K6n/RPjz4Og=; b=cL5opR+byMRkTLoLzsIgHC51NTFuTOwttVDb0AquBfi15hV43zdgmbSqb6cDfT2v66 x3z5a3WAoXk7DKc5Ti1wtnjzwm3+I55EL1820WrDBGrXi18lIZMSu3oVOCwxuUQZDAcp AdDCowQ0QSmT2bpTpJXeHsHi3nFhJfqzfK8xjRsmH8WtOC1YFkPh/s1c9CpmZbgKNT9D L4npRc7ATrcvXV+cHhj/Ws4gWPN0xAWfaWTD8J4Ff37BJcBtDHL0qeOSsGlQ9hi9o3y4 BBNiEfIeZJuaP4Le4EWpEQZ3pK+IebTvswXYDFPpvdBg8vJTPR6JKCZkx9uhKP4Lknvu T4Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uf9hBgxs; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o19-20020a17090ad25300b0023d22d0f0fdsi12308070pjw.19.2023.05.08.00.12.25; Mon, 08 May 2023 00:12:41 -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=uf9hBgxs; 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 S233363AbjEHHG2 (ORCPT + 99 others); Mon, 8 May 2023 03:06:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233251AbjEHHFo (ORCPT ); Mon, 8 May 2023 03:05:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 447441A130; Mon, 8 May 2023 00:05:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5200561F9A; Mon, 8 May 2023 07:05:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00AB2C4339E; Mon, 8 May 2023 07:05:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683529504; bh=KZW/tFXMGGOj2MJEPl8J+2P+ukf3gwy/b1cibtTCM2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uf9hBgxspbXNuKRQ9B4q9XpoSMSLjSdoiefyJe+4fLr53ld0LEmyMir5tgEUB+8HO ihtNDLO99Om+BN0l2EIaNTf28T38A89nuurh4Gq3ZO3PSnmnqo/ZkhanANhpiL6Lv9 VnANpc7xZKswhVu5JOXoEFrli2SWP33nVNvKuJEu4U9fHphQwbNSJroipu138ygFdl TLvsrMCWbbwAtB3gMlal2hivCmn0Gg3d+4q0UTVIBYt0bC9L2EAD/JexgStlSV55P4 TCGcfpc95pAelaMk0qrm9VKUEWJvD0uL/5EDqRU4UAg/NkbHdY+2yz/52L2sKz39LD I0wHIywDBkyfg== From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel , Evgeniy Baskov , Borislav Petkov , Andy Lutomirski , Dave Hansen , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Alexey Khoroshilov , Peter Jones , Gerd Hoffmann , Dave Young , Mario Limonciello , Kees Cook , Tom Lendacky , "Kirill A . Shutemov" , Linus Torvalds Subject: [PATCH v2 20/20] x86: decompressor: Avoid magic offsets for EFI handover entrypoint Date: Mon, 8 May 2023 09:03:30 +0200 Message-Id: <20230508070330.582131-21-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230508070330.582131-1-ardb@kernel.org> References: <20230508070330.582131-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1804; i=ardb@kernel.org; h=from:subject; bh=KZW/tFXMGGOj2MJEPl8J+2P+ukf3gwy/b1cibtTCM2Y=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JISVi3qGjnOc+6p4w7IvRl16U8PaWTNCHn46utT2aORHdY S+ytyzuKGVhEONgkBVTZBGY/ffdztMTpWqdZ8nCzGFlAhnCwMUpABORXMXw39s9e6/ke4FMA8+V s61Wbzs+zTLtwNnHa0ULH04/23lGnI/hr0BX3XSPOGfOzRmrq3Y6v3kzfRLr0od2gr6O1vvU25t DWQA= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765309113138396271?= X-GMAIL-MSGID: =?utf-8?q?1765309113138396271?= The special EFI handover protocol entrypoint offset wrt to the startup_XX address is described in struct boot_params as handover_offset, so that the special Linux/x86 aware EFI loader can find it there. When mixed mode is enabled, this single field has to describe this offset for both the 32-bit and 64-bit entrypoints, so their respective relative offsets have to be identical. Currently, we use hard-coded fixed offsets to ensure this, but the only requirement is that the entrypoints are 0x200 bytes apart, and this only matters when EFI mixed mode is configured to begin with. So just set the required offset directly. This could potentially result in a build error if the 32-bit startup code is much smaller than the 64-bit code but this is currently far from the case, and easily fixed when that situation does arise. Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/head_64.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index b7599cbbd2ea1136..72780644a2272af8 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S @@ -282,7 +282,6 @@ SYM_FUNC_START(startup_32) SYM_FUNC_END(startup_32) #if IS_ENABLED(CONFIG_EFI_MIXED) && IS_ENABLED(CONFIG_EFI_HANDOVER_PROTOCOL) - .org 0x190 SYM_FUNC_START(efi32_stub_entry) add $0x4, %esp /* Discard return address */ popl %ecx @@ -455,7 +454,9 @@ SYM_CODE_START(startup_64) SYM_CODE_END(startup_64) #ifdef CONFIG_EFI_HANDOVER_PROTOCOL - .org 0x390 +#ifdef CONFIG_EFI_MIXED + .org efi32_stub_entry + 0x200 +#endif SYM_FUNC_START(efi64_stub_entry) and $~0xf, %rsp /* realign the stack */ call efi_handover_entry