Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1105423imm; Fri, 22 Jun 2018 10:23:56 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJCct8KcxU/dhXnuKEWNAF5hadCSTm2r11lRhxxvZL8zFwnCqerdWHtSMZjNegaaU6ppdZY X-Received: by 2002:a17:902:1121:: with SMTP id d30-v6mr2614784pla.247.1529688236637; Fri, 22 Jun 2018 10:23:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529688236; cv=none; d=google.com; s=arc-20160816; b=fHAEdVFkBE8Oj8L8UhqbKa4bTQtbpY86EbsTRJ1CR/1fvlgeD/UCyO/3JwxP8n7sKr M2SLbIipTQDOxs2p+URVDa3oK/oxaxWDVPhPxK7tTCo6lEl0ptKu1seGJqY8FpzqLQzF 6+Ey6shrlHsA91dfD/u8EXYAwxg5b6axgWWtDERdsumIVG+WrbRZdtTPufjP05V+1QgI +ok3RIb6k2cEd0cJwj3pXv9G5CUG4qZUJaDsk1iU51fNmg9qsK7h5yeZXTLI3d3HKM/B J+ycy2iy9PatW15c/AlOtHMu+WGhx00Uc8VMKVnTiSYCnEYlG5kEJgiBYXb86rijBnZL quaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=mBxPQYV4zXqCNe8qWyWenkbZC6XdaCi4DgP3I+aBYIs=; b=bxeJtSkhWX82LgK3D3GYKDwEWJW0sp8WSN+m/woG0VaBgQY1m3nOnRA8lsMNTPCi0v Wx/SdEF5zIdWHmNEARtOfOubngvMk5EoetBDLgyfUU5JzuXHMK2wN40Cj60XbD8ZMQ7z YTeXWDIZW/Y9I2G/FqmBGKbSbuhjMyjSlp2GOwULJRL/BEo0gQQ+W47LApejw6BAd8sG 3mDn8wQFUvAN05Jolafra0WZZFr6zhljG9OEPi6RfC4FipRCDm9NV501e9M+Ncc1G9q3 i/e6aaJ3q8RRkCmQf8nYqGKIgFVhKBBfr5KlrqN7sb/LT0VlHsgeWNrl8+vVaZb+Rb7b 6WWw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d20-v6si5346725pgb.682.2018.06.22.10.23.39; Fri, 22 Jun 2018 10:23:56 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934019AbeFVRWr (ORCPT + 99 others); Fri, 22 Jun 2018 13:22:47 -0400 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:17636 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933900AbeFVRWp (ORCPT ); Fri, 22 Jun 2018 13:22:45 -0400 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Fri, 22 Jun 2018 10:22:05 -0700 Received: from sc2-haas01-esx0118.eng.vmware.com (sc2-haas01-esx0118.eng.vmware.com [10.172.44.118]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 2851C405E7; Fri, 22 Jun 2018 10:22:42 -0700 (PDT) From: Nadav Amit To: , CC: Nadav Amit , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Josh Poimboeuf Subject: [PATCH v6 7/9] x86: extable: use macros instead of inline assembly Date: Fri, 22 Jun 2018 10:22:10 -0700 Message-ID: <20180622172212.199633-8-namit@vmware.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180622172212.199633-1-namit@vmware.com> References: <20180622172212.199633-1-namit@vmware.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: None (EX13-EDG-OU-001.vmware.com: namit@vmware.com does not designate permitted sender hosts) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use assembly macros for exception-tables and call them from inline assembly. This not only makes the code more readable and allows to avoid the duplicate implementation, but also improves compilation decision, specifically inline decisions which GCC base on the number of new lines in inline assembly. text data bss dec hex filename 18162555 10226288 2957312 31346155 1de4deb ./vmlinux before 18162879 10226256 2957312 31346447 1de4f0f ./vmlinux after (+292) This allows to inline functions such as nested_vmx_exit_reflected(), set_segment_reg(), __copy_xstate_to_user(). Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x86@kernel.org Cc: Josh Poimboeuf Acked-by: Peter Zijlstra (Intel) Signed-off-by: Nadav Amit --- arch/x86/include/asm/asm.h | 61 +++++++++++++++++--------------------- arch/x86/kernel/macros.S | 1 + 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h index 219faaec51df..30bc1b0058ef 100644 --- a/arch/x86/include/asm/asm.h +++ b/arch/x86/include/asm/asm.h @@ -58,28 +58,44 @@ # define CC_OUT(c) [_cc_ ## c] "=qm" #endif -/* Exception table entry */ #ifdef __ASSEMBLY__ # define _ASM_EXTABLE_HANDLE(from, to, handler) \ - .pushsection "__ex_table","a" ; \ - .balign 4 ; \ - .long (from) - . ; \ - .long (to) - . ; \ - .long (handler) - . ; \ - .popsection + ASM_EXTABLE_HANDLE from to handler + +#else /* __ASSEMBLY__ */ + +# define _ASM_EXTABLE_HANDLE(from, to, handler) \ + "ASM_EXTABLE_HANDLE from=" #from " to=" #to \ + " handler=\"" #handler "\"\n\t" + +/* For C file, we already have NOKPROBE_SYMBOL macro */ + +#endif /* __ASSEMBLY__ */ -# define _ASM_EXTABLE(from, to) \ +#define _ASM_EXTABLE(from, to) \ _ASM_EXTABLE_HANDLE(from, to, ex_handler_default) -# define _ASM_EXTABLE_FAULT(from, to) \ +#define _ASM_EXTABLE_FAULT(from, to) \ _ASM_EXTABLE_HANDLE(from, to, ex_handler_fault) -# define _ASM_EXTABLE_EX(from, to) \ +#define _ASM_EXTABLE_EX(from, to) \ _ASM_EXTABLE_HANDLE(from, to, ex_handler_ext) -# define _ASM_EXTABLE_REFCOUNT(from, to) \ +#define _ASM_EXTABLE_REFCOUNT(from, to) \ _ASM_EXTABLE_HANDLE(from, to, ex_handler_refcount) +/* Exception table entry */ +#ifdef __ASSEMBLY__ + +.macro ASM_EXTABLE_HANDLE from:req to:req handler:req + .pushsection "__ex_table","a" + .balign 4 + .long (\from) - . + .long (\to) - . + .long (\handler) - . + .popsection +.endm + # define _ASM_NOKPROBE(entry) \ .pushsection "_kprobe_blacklist","aw" ; \ _ASM_ALIGN ; \ @@ -110,29 +126,6 @@ _ASM_EXTABLE(101b,103b) .endm -#else -# define _EXPAND_EXTABLE_HANDLE(x) #x -# define _ASM_EXTABLE_HANDLE(from, to, handler) \ - " .pushsection \"__ex_table\",\"a\"\n" \ - " .balign 4\n" \ - " .long (" #from ") - .\n" \ - " .long (" #to ") - .\n" \ - " .long (" _EXPAND_EXTABLE_HANDLE(handler) ") - .\n" \ - " .popsection\n" - -# define _ASM_EXTABLE(from, to) \ - _ASM_EXTABLE_HANDLE(from, to, ex_handler_default) - -# define _ASM_EXTABLE_FAULT(from, to) \ - _ASM_EXTABLE_HANDLE(from, to, ex_handler_fault) - -# define _ASM_EXTABLE_EX(from, to) \ - _ASM_EXTABLE_HANDLE(from, to, ex_handler_ext) - -# define _ASM_EXTABLE_REFCOUNT(from, to) \ - _ASM_EXTABLE_HANDLE(from, to, ex_handler_refcount) - -/* For C file, we already have NOKPROBE_SYMBOL macro */ #endif #ifndef __ASSEMBLY__ diff --git a/arch/x86/kernel/macros.S b/arch/x86/kernel/macros.S index 71d8b716b111..7baa40d5bf16 100644 --- a/arch/x86/kernel/macros.S +++ b/arch/x86/kernel/macros.S @@ -11,3 +11,4 @@ #include #include #include +#include -- 2.17.1