Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2466544ybf; Mon, 2 Mar 2020 09:11:54 -0800 (PST) X-Google-Smtp-Source: ADFU+vs/g7SocXoWfcdDJrhs8/mQRiSpHMmuYia+wLFfhgZyf03JJJV3kIIwm5PJKhKoddQ314px X-Received: by 2002:a05:6830:1511:: with SMTP id k17mr140686otp.53.1583169114188; Mon, 02 Mar 2020 09:11:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583169114; cv=none; d=google.com; s=arc-20160816; b=L29A3uKIAa6M3OYcyI67aVWyFSpirWGSFlWKQSTMhAMRe0d1UsipS9hTSAkGg3njJG 2zLffOWruSvWNgU5niC+0pyU7OPRBb4Kr3ie8g8WRMWVh4REcJlhS8FXpcv2YvgyDOB6 4DUtOo/pdpXVS4Bf0gFyChCrJCvk9GV6VDz+rH21sG6rEkq8nUlpDWWM/jzfxbpqwiuC 2ZojrjgvRXsSFuCPRrN4WbUfa2dffc0gVQQFAm6aGkQB220IjMSexBCiHLQT2ZWBGQy8 uJrwHXwM5TSGktee6Pz5ZWsb2//Rk8J+otabog8IS65Pr203isby8r5EHNDUeBLqbHF3 Hl/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=caZPP6SSW8ctt3Cnx076uaX3Qbzg/qEgqAgX7tcEH0A=; b=YRw6Df+UUcPlExCNoiWMbHjWpWI4edDiqJ7ITzMhwO6dkaJkW1zwH6VgvTGt2L4xgd IluZ9zASscd3VtIWE/GtTe6p8zq35n9Tw+q6UmNBg5fHrdePgrZkQwcLLyj/nTy5dmWB t0z+Wk8XoZS8usbVtKrgK8il0isYrkTm2gAwOj6cmZM1Nwz+THF5I/yWtzkYa21kuU1t orDMDROWMuXY0Sk7PKy4MShIqtDF0wh7atCwiioUEcMDhB2rtvFec3QfmGkPWj5h9O9A I4tVNkKMsIXS4ZPRNn5N3vUrRaRNwxC9AIFjL8mDlj+L/EmPjw68+Gg0eGi9Jr3GAQh2 og3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sBlRkkgx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q131si6303886oig.203.2020.03.02.09.11.40; Mon, 02 Mar 2020 09:11:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sBlRkkgx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727439AbgCBRJt (ORCPT + 99 others); Mon, 2 Mar 2020 12:09:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:55134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727417AbgCBRJr (ORCPT ); Mon, 2 Mar 2020 12:09:47 -0500 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BD1F02465E for ; Mon, 2 Mar 2020 17:09:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583168986; bh=wOOJalJ6H53XXQk1DAauUesmJQFNORcTG2bDbS4jTOI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=sBlRkkgxt6D2/JozMgjWEI09F+LrMw1oMwtTu/eWsPxGikV+EZyIU832PuFwNMuZR EsEQ0Pid29Fz4t0caF+nnxrMfGseFnOZgerLycnpy+UDXCcgU55njWpdZgfiA1RUgZ 9bQ2Nm80zXEBPQbkvUVs1i1HKpv1GMSDUURHuJ5M= Received: by mail-wr1-f43.google.com with SMTP id y17so681748wrn.6 for ; Mon, 02 Mar 2020 09:09:45 -0800 (PST) X-Gm-Message-State: ANhLgQ3MDxcVL8FhPKvkw87CJvqtbRLXc824ATePsoHVlOQm3CcorH7+ D9kMaK5Yp99DRXm61i20iE/B2aLtfiX1pa+fD50ieQ== X-Received: by 2002:adf:e742:: with SMTP id c2mr563486wrn.262.1583168984232; Mon, 02 Mar 2020 09:09:44 -0800 (PST) MIME-Version: 1.0 References: <20200301230436.2246909-1-nivedita@alum.mit.edu> <20200301230436.2246909-4-nivedita@alum.mit.edu> <20200302165359.GA2599505@rani.riverdale.lan> <20200302170205.GA2937123@rani.riverdale.lan> In-Reply-To: <20200302170205.GA2937123@rani.riverdale.lan> From: Ard Biesheuvel Date: Mon, 2 Mar 2020 18:09:33 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/5] efi/x86: Make efi32_pe_entry more readable To: Arvind Sankar Cc: linux-efi , "the arch/x86 maintainers" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2 Mar 2020 at 18:02, Arvind Sankar wrote: > > On Mon, Mar 02, 2020 at 05:57:04PM +0100, Ard Biesheuvel wrote: > > On Mon, 2 Mar 2020 at 17:54, Arvind Sankar wrote: > > > > > > On Mon, Mar 02, 2020 at 08:49:17AM +0100, Ard Biesheuvel wrote: > > > > On Mon, 2 Mar 2020 at 00:04, Arvind Sankar wrote: > > > ... > > > > > call 1f > > > > > -1: pop %ebp > > > > > - subl $1b, %ebp > > > > > +1: pop %ebx > > > > > + subl $1b, %ebx > > > ... > > > > > > > > > > + movl %ebx, %ebp // startup_32 for efi32_pe_stub_entry > > > > > > > > The code that follows efi32_pe_stub_entry still expects the runtime > > > > displacement in %ebp, so we'll need to pass that in another way here. > > > > > > > > > jmp efi32_pe_stub_entry > > > > > > Didn't follow -- what do you mean by runtime displacement? > > > > > > efi32_pe_stub_entry expects the runtime address of startup_32 to be in > > > %ebp, but with the changes for keeping the frame pointer in %ebp, I > > > changed the runtime address to be in %ebx instead. Hence I added that > > > movl %ebx, %ebp to put it in %ebp just before calling efi32_pe_stub_entry. > > > That should be fine, no? > > > > But how does that work with: > > > > SYM_INNER_LABEL(efi32_pe_stub_entry, SYM_L_LOCAL) > > movl %ecx, efi32_boot_args(%ebp) > > movl %edx, efi32_boot_args+4(%ebp) > > movb $0, efi_is64(%ebp) > > > > > > ? > > Why wouldn't it work? Before this change, efi32_pe_entry set %ebp to > startup_32 (via the call/pop/sub sequence), so efi32_pe_stub_entry was > entered with %ebp == startup_32. > > After this change, the call/pop/sub sequence puts startup_32 into %ebx, > and then I copy it into %ebp just before branching to efi32_pe_stub_entry. > So everything should continue to work the same way as before? Ah ok, so the sequence call 1f 1: pop %ebp subl $1b, %ebp happens to produce the value of startup_32, which is obvious now that I think of it, but it wasn't before.