Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp737057rwb; Thu, 6 Oct 2022 03:59:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7xE0NZHYrN53fYoFjy5MD997Oryi5sy3xP/6vfe66vjH8ARv/3ETOcNfD+fCZ+249Mebbm X-Received: by 2002:a17:90a:1690:b0:20a:8f70:14bb with SMTP id o16-20020a17090a169000b0020a8f7014bbmr4624887pja.115.1665053980398; Thu, 06 Oct 2022 03:59:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665053980; cv=none; d=google.com; s=arc-20160816; b=S1/4prCOGY09VtKP/KM4U83PT0OSjmysBqP8I3SwRL0ZObyIEgAcW2+PDetnSZAT/a 6qRpUfMe3P6BJnIMD9lsbnFquMrrQypC7eoUMK2LUc3/CUVOdp2jmbHcoR2vB3evIo20 /htFlk9Fr6yJvqbCErV3I0PR25Myqdx/wEDqDLYZgpIRQZzkmKNHBJbypcdpWytTCF9g BprzEr5qDJvK5XapxGnPrl4kyG12Do3Gflg5TQGr77mQHaYy4LMdLTP1KihaATrf468a 9hmpHp07+59B6ojIuHn8QI1KVnUFHWdlQ4RZwAMPd9bKQogfz+e5pTu1i1DNoZt5LSIy YsXA== 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=lcoVVP4UBAeHXa1AlaKKg4V1dUTxVuSk/43bqaZVtHk=; b=MC6bH2paoz7YW5sqPpOKff30J8ryvNc9q/bsmcaEa/VXR9fcUzBnrVTvSO6A/QGLoJ 9CC7gq84QI48IWG5iayci4yFm+GEbaLXj1FiacSfc/iFJkperi3ZeStCn/NP6/ylMrLd ZBzLVZ+E+FQ7T5q4pQ9v7tPzDNrgg7XwRgG2lr7MblT3mDZd02BoWcfUrj7HUTDmRSy2 Oq79fGO3hUcHiIjmrP0P6gVw+F7/DEE6ZjQgv5Ko4ZsSxg/1yClcYniGd1IrlTKmxhN/ 9TyAyw1ucV3jOHBXLXLA4RN4B+Zt/D73KAU++sU6uXYFkBNbm60gD/g8IenGjp00RJ/s dS+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=miEGJUm4; 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 y19-20020aa78f33000000b0053e989053f9si9484003pfr.114.2022.10.06.03.59.28; Thu, 06 Oct 2022 03:59:40 -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=miEGJUm4; 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 S231356AbiJFK41 (ORCPT + 99 others); Thu, 6 Oct 2022 06:56:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230512AbiJFK40 (ORCPT ); Thu, 6 Oct 2022 06:56:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FA1098359; Thu, 6 Oct 2022 03:56:25 -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 ams.source.kernel.org (Postfix) with ESMTPS id 16E44B8206D; Thu, 6 Oct 2022 10:56:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB77EC43140; Thu, 6 Oct 2022 10:56:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665053782; bh=n1sONnyBy19nROIXw+eEDPEBq0RR7AXvCLWvs323kMg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=miEGJUm4FWmWmXjKNlKsxMKtRsvnrlQNwL4YenRVPxZepzsh5uVbFYjDns3vA5BGr j3A53GwtViyBSfJhc9i2gpkxIEmRqWRqxApmKgmd3ePr3+ru+S4pGKCvum1TqjCy3f V+WjyeCjdyIkgZIBfN03LASLuB+Bj9rqCufVtEgMz5A2QGaP8lcbOrkobfcOXi0i7Q djXW0C1m63i56so2GEqGNWdT2QdSvHCOllHoB61FEdHSWFDBbGBf7mUjXa/mrAS4hj Xwy3J96SZAn6ybv4j6V423iJ3kfjAujIOH4Vi3Rb3uOEzy1eNyus7NOquQDiHweZrQ Ge8XYaEQ9Cx3Q== Received: by mail-lf1-f50.google.com with SMTP id b2so2122534lfp.6; Thu, 06 Oct 2022 03:56:22 -0700 (PDT) X-Gm-Message-State: ACrzQf1ZyM8KXq+VMJC70nD2VTqDhSbBKeSllaqIdI8CDi8GPlznXuYZ jbadcemPjQ41nw+QDaZqMYuxTZ8+lUoPNkdpm58= X-Received: by 2002:ac2:4d1c:0:b0:4a2:4119:f647 with SMTP id r28-20020ac24d1c000000b004a24119f647mr1502331lfi.426.1665053780725; Thu, 06 Oct 2022 03:56:20 -0700 (PDT) MIME-Version: 1.0 References: <20220921145422.437618-1-ardb@kernel.org> <20220921145422.437618-3-ardb@kernel.org> In-Reply-To: From: Ard Biesheuvel Date: Thu, 6 Oct 2022 12:56:09 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 02/16] x86/compressed: efi-mixed: move 32-bit entrypoint code into .text section To: Borislav Petkov Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Dave Hansen , Michael Roth Content-Type: text/plain; charset="UTF-8" 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 On Thu, 6 Oct 2022 at 12:42, Borislav Petkov wrote: > > On Wed, Sep 21, 2022 at 04:54:08PM +0200, Ard Biesheuvel wrote: > > Move the code that stores the arguments passed to the EFI entrypoint > > into the .text section, so that it can be moved into a separate > > compilation unit in a subsequent patch. > > > > Signed-off-by: Ard Biesheuvel > > --- > > arch/x86/boot/compressed/head_64.S | 34 ++++++++++++-------- > > 1 file changed, 20 insertions(+), 14 deletions(-) > > > > diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S > > index d33f060900d2..1ba2fc2357e6 100644 > > --- a/arch/x86/boot/compressed/head_64.S > > +++ b/arch/x86/boot/compressed/head_64.S > > @@ -303,24 +303,28 @@ SYM_FUNC_START(efi32_stub_entry) > > popl %ecx > > popl %edx > > popl %esi > > + jmp efi32_entry > > +SYM_FUNC_END(efi32_stub_entry) > > > > + .text > > +SYM_FUNC_START_LOCAL(efi32_entry) > > call 1f > > -1: pop %ebp > > - subl $ rva(1b), %ebp > > - > > - movl %esi, rva(efi32_boot_args+8)(%ebp) > > -SYM_INNER_LABEL(efi32_pe_stub_entry, SYM_L_LOCAL) > > - movl %ecx, rva(efi32_boot_args)(%ebp) > > - movl %edx, rva(efi32_boot_args+4)(%ebp) > > - movb $0, rva(efi_is64)(%ebp) > > +1: pop %ebx > > I'm guessing according to the EFI mixed mode calling convention, %ebx is > not a live register which gets overwritten here...? > > Looking at efi32_pe_entry() from where this is called, %ebx looks live. > > What am I missing? > efi32_pe_entry() preserves and restores the caller's value of %ebx, because from there, we might actually return control to the firmware. The value it keeps in %ebx itself is not live when it jumps to efi32_entry - it stores its value into image_offset, which is reloaded from memory at a later point. efi32_stub_entry() is the 'EFI handover protocol' entry point, which cannot return to the firmware (and we discard the return address already) so %ebx can be clobbered.