Received: by 10.223.185.116 with SMTP id b49csp1037647wrg; Wed, 14 Feb 2018 10:37:03 -0800 (PST) X-Google-Smtp-Source: AH8x225pgKf7L6nXWwhVJ6VOc3yvWe3dgQyACD4tpgrRYqv+7YXJHobCURGMI1X+7Mm7FPYTg597 X-Received: by 2002:a17:902:5382:: with SMTP id c2-v6mr90766pli.102.1518633423886; Wed, 14 Feb 2018 10:37:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518633423; cv=none; d=google.com; s=arc-20160816; b=kSuLe33/3zD9BA/RUDj0+epGa7MSCxbB8yno3/B2mOIbBmpwKn6NhLuerBGKaMV2vm znWVdhj4XGfMU4kNAJqskJ2OVD7O090cuKb7HCc8MWt4Btoi9Cukorz5ozOPe2j19HLg dNi2y9fQOKHpQoZTPnUw/5LKtezHeKAJjEhVeThZmvzPN7Kpigo4wO5n43dnV6fPp1b5 GtopB+prKDB6jO2XCNb1HDPMFI6CoUICyCwbP66bKyNDlU7RjFiOIairA7piBOzyTS5E rNN971mWCqIDhjpCbYvl303GjXg31dP5nu0mN5qIrd8zdvB0FqHhDfJQn47dmbmGnje8 r0mg== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=tojWybfacnVwh+ml68cg/SdPcaz8mZcV+QY6ppn9nxw=; b=aasxxoFStY9Rdd2IiLqFYHoGkCouCK7OjzPPEaxa1QkUHxz746s2dWxOUQ+O4isa5o nnv9zF3aGry0a1jgW0vgY/IUNSwA27DDuYP+TEoAGBOz4fw+1oF/YOudFXOEIMogTbHh xoKL7Bmbn20KQ7U2QnGSdqX8abXfH45DiWIG5y2CB+yaRrNS7Pyrx19lcDCrzeEqTR2U xwGoywt3pmbbE7vKyOx8N6Dlm+UV6n93C+vQCJaGRpLoey91aw1l8QPp1A8R8t/pGuaa 2iIbMDjK+MFduxnZVs8gkWuAEvYePgfsZtWI/roqf7gQ/FYymh0YIhUu3Qq9KYLGY/Ik Cbqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=V/gvom81; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l64si3483071pfi.388.2018.02.14.10.36.48; Wed, 14 Feb 2018 10:37:03 -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=@gmail.com header.s=20161025 header.b=V/gvom81; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162167AbeBNSgI (ORCPT + 99 others); Wed, 14 Feb 2018 13:36:08 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:41560 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162106AbeBNSgH (ORCPT ); Wed, 14 Feb 2018 13:36:07 -0500 Received: by mail-io0-f193.google.com with SMTP id f4so26188433ioh.8 for ; Wed, 14 Feb 2018 10:36:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=tojWybfacnVwh+ml68cg/SdPcaz8mZcV+QY6ppn9nxw=; b=V/gvom81i6bN38/fGmip4LblnwT3AWVyAvm58ItcgcwpZBJmdGWMdlPp7QOefPOCWB Xr5QUEp2EB1QtzgKnfyJ4O++JIb2+PYQAqcW/gGcy7TDk/7JWRyZMAyypCazIsTwbpgc Toemtcvx80itpqs7T6r5Ajuu5CTABlpVAQ1xccQJTsTMfq41dJgSeYYXoZGBWFc/GtE7 Iy7I0KKgEnSnIZZsGIVrPlDgh/lLli6/Mf88KZfvyH4k48bo638gx6Yosa4VPjkvnDuR ZottTDr9CxKMsnwC9FEdK8wYAy8ggjW90kmYliyPgU9D022cE1KDk14a1Tf+NLEvWGpB fiJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=tojWybfacnVwh+ml68cg/SdPcaz8mZcV+QY6ppn9nxw=; b=UqXAZkYE1oNSnAkwjHyVOJtrTAkEejKuLX5Ul3CKAmRNQpGjql9euxLhEaOuxGVi0N AdFkNwG39KKf7H1atOxapm2z8+0i/DbCnJUTX42bxV7bvNSamlYiJt2YooHn6ZbZVrfZ jNF9Q+QUn7f9WVwo5wYD+lCgGkvIWxu9x0RKY0gql2Zy/xyU/dueCEEA/oV67GtQpjA0 PkpbPpK0jnlKymozIBQP29Oenhbe2joL4iUKPGkd40nlG4fxVvIHDyPr3K9cQU48rYSk GX8ntEpBXetj6e30BZtKIl3xGmGZuye8/SxFkz0OYGLdn/fnHn7ZJjBiJUdMQNOkmA5j k+Ww== X-Gm-Message-State: APf1xPAyRIVzXmOfSjLWL9P44Na488B1V1Rk/dIwXqtRqpTEFR+z8b64 7WHmDvaqdBPtqi5sJfatvBA+Xp4CtgbcRjZ/nw== X-Received: by 10.107.172.130 with SMTP id v124mr139853ioe.301.1518633366653; Wed, 14 Feb 2018 10:36:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.118.212 with HTTP; Wed, 14 Feb 2018 10:36:06 -0800 (PST) In-Reply-To: <20180214182113.27247-3-linux@dominikbrodowski.net> References: <20180214182113.27247-1-linux@dominikbrodowski.net> <20180214182113.27247-3-linux@dominikbrodowski.net> From: Brian Gerst Date: Wed, 14 Feb 2018 13:36:06 -0500 Message-ID: Subject: Re: [RFC PATCH 2/4] x86/entry/64: move ENTER_IRQ_STACK from interrupt macro to helper function To: Dominik Brodowski Cc: Linux Kernel Mailing List , Ingo Molnar , "the arch/x86 maintainers" , Linus Torvalds , Andy Lutomirski , Andi Kleen , Thomas Gleixner , "Williams, Dan J" 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 Wed, Feb 14, 2018 at 1:21 PM, Dominik Brodowski wrote: > Moving the switch to IRQ stack from the interrupt macro to the helper > function requires some trickery: All ENTER_IRQ_STACK really cares about > is where the "original" stack -- meaning the GP registers etc. -- is > stored. Therefore, we need to offset the stored RSP value by 8 whenever > ENTER_IRQ_STACK is called from within a function. In such cases, and > after switching to the IRQ stack, we need to push the "original" return > address (i.e. the return address from the call to the interrupt entry > function) to the IRQ stack. > > This trickery allows us to carve another 1k from the text size: > > text data bss dec hex filename > 17905 0 0 17905 45f1 entry_64.o-orig > 16897 0 0 16897 4201 entry_64.o > > Signed-off-by: Dominik Brodowski > --- > arch/x86/entry/entry_64.S | 53 +++++++++++++++++++++++++++++++---------------- > 1 file changed, 35 insertions(+), 18 deletions(-) > > diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S > index de8a0da0d347..3046b12a1acb 100644 > --- a/arch/x86/entry/entry_64.S > +++ b/arch/x86/entry/entry_64.S > @@ -449,10 +449,18 @@ END(irq_entries_start) > * > * The invariant is that, if irq_count != -1, then the IRQ stack is in use. > */ > -.macro ENTER_IRQ_STACK regs=1 old_rsp > +.macro ENTER_IRQ_STACK regs=1 old_rsp save_ret=0 > DEBUG_ENTRY_ASSERT_IRQS_OFF > movq %rsp, \old_rsp > > + .if \save_ret > + /* > + * If save_ret is set, the original stack contains one additional > + * entry -- the return address. > + */ > + addq $8, \old_rsp > + .endif Combine the mov and add into leaq 8(%rsp), \old_rsp. -- Brian Gerst