Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2458560ybf; Mon, 2 Mar 2020 09:03:37 -0800 (PST) X-Google-Smtp-Source: ADFU+vt8wNWxMPItlMD0s+8VI/WVOcIYEYlBRTnQtK+kwqi9iPUaA3+m7Ak9FtOVc8W2XSy0wioW X-Received: by 2002:aca:d68a:: with SMTP id n132mr75087oig.40.1583168616965; Mon, 02 Mar 2020 09:03:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583168616; cv=none; d=google.com; s=arc-20160816; b=IkOqxXmyp0CMFE4nxzg8GIyItGtE1d7/mcPtHp1ulrq1jWkVpGaGFvjJRF483GGYS5 vBPBERSuT1MF2EV14roZkS6y0NvkIWWcoj6nsJcBY05HPsf2xc7ehU1RGTg/LkL5d23l k713RzsbKL2T6whL/vGhQsoGB4pbyfHT6u+jQy+dIkW5FNS/pwnlrXeBmgrEKkBFRut5 qzxKvlgn6v6nifZSWY48hh20b/3OdYK1q+1hzu9OQexvpd/QYjFgzj8YM9EhGHme3zHX 9/7frnd0jJrUSw7xM/YmD1n2Qz4KhhGhD66R1K1w2gCp3eqDu0SdgzOQXA6jmXxuPSKL BUgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=z/s0AFZ+XxkV+eI3XGK5Ud6Mh7RjzKiJ4qxWDIVLNhw=; b=0a83Fxa8pPhBIRs5btSKgHQWP1mkFonJ78YHPcdoD8D0iyad6fqPBy5SKkGCYUSnXf oKHud3QpEkuA6D46CD/COooix7FTMSmIUj2AeY/wWCd68pBdD+uZiX8e5+C7i5yKjLl1 0vSEX/EC6XlBRXm3qkwkvJTXViRKtQAAJPw/axdpTdHcvCyGiYHsFKrrSjOhwMwFo8uN oRLeFdmXoTe6yB2F0hGXZ+bIXlBAu2VCrHXz1kqWW5HOJzyFTVdWM0ORP1LYdb6eCLL1 WRtNyHX3SpVGYt77Aarv5xcPsTHh8ml/zLY2AXPDcPSPlTa/RKgOAc2umGs+4c5787ix KAxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="qSAe/B1i"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l9si334503otd.134.2020.03.02.09.03.24; Mon, 02 Mar 2020 09:03:36 -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=fail header.i=@gmail.com header.s=20161025 header.b="qSAe/B1i"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727423AbgCBRCL (ORCPT + 99 others); Mon, 2 Mar 2020 12:02:11 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:43284 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726451AbgCBRCL (ORCPT ); Mon, 2 Mar 2020 12:02:11 -0500 Received: by mail-qk1-f196.google.com with SMTP id q18so313213qki.10; Mon, 02 Mar 2020 09:02:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=z/s0AFZ+XxkV+eI3XGK5Ud6Mh7RjzKiJ4qxWDIVLNhw=; b=qSAe/B1iUQEWVYG5vamIa+kD1MuBB+e7dR6ZdhDrv7YLSNdUtwOzCcRGM4C+LPDZG/ SvBTRXTs1lsSjSC7JgFfwUFoxHfqp6OuI3UNZXen2J3nPz7G+JaGDXkW7wLClC+959W6 lI0x5YwClURyDKxIXNp6awsrzAfHPOwmDINXg23NfYZQoyHiIxU/QunL3YTVo/h2IBuc C24ldEYVq/zBTgu+4B1yLCDrh3ewThjZ8kioNsHzHSqiUgS2Vh0vrxQ4KlP04v0m2MPC r0FwRAkBZtlk8kVGGuLueKcBCFrLza677jAwm+hjxViDJqf9LtxcZ/fi7tewgiECG3e4 dzDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=z/s0AFZ+XxkV+eI3XGK5Ud6Mh7RjzKiJ4qxWDIVLNhw=; b=VmgheZLZQEJcIrleGjk4qwj52vdHDbZXub6QpUGvCyVvbjmFey1Lv9yar8aIxqargF iEVGzZYNWI/dZJXy2bO3gEozWvNSPIMEE1dxLfwesUx5yWHy7xO6c44J7ag40IjIFpsf qu9hM2/0SHOz05VJSD/UD6CaCAZuy3ylXiOZMXkIVgJ3xTQ/3oYdF65xeDqMnotdcdWc 972sJtuK4XT6H608+NHtO12A/uFUWOZhio68A0wQs/gvqtnfrtIKKgXw6yMOYkLPrGw5 PJ6aUSbKi0eqm5GF39kf79EJv8nv2WVZEv23yiu+QhiBmmks5lpVs27WqCxkltmF4k5E gHxA== X-Gm-Message-State: ANhLgQ0SKTzZNQiJnfl2X+pEKFvErpo7n8rNlO+VYVb4KDj+B8BoDecK 8tg2ZEEwvXtboM0p5wx+ntI= X-Received: by 2002:a05:620a:1647:: with SMTP id c7mr259994qko.20.1583168527508; Mon, 02 Mar 2020 09:02:07 -0800 (PST) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id w2sm10554175qto.73.2020.03.02.09.02.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2020 09:02:06 -0800 (PST) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Mon, 2 Mar 2020 12:02:05 -0500 To: Ard Biesheuvel Cc: Arvind Sankar , linux-efi , the arch/x86 maintainers , Linux Kernel Mailing List Subject: Re: [PATCH 3/5] efi/x86: Make efi32_pe_entry more readable Message-ID: <20200302170205.GA2937123@rani.riverdale.lan> References: <20200301230436.2246909-1-nivedita@alum.mit.edu> <20200301230436.2246909-4-nivedita@alum.mit.edu> <20200302165359.GA2599505@rani.riverdale.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?