From patchwork Mon Dec 17 16:03:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 154011 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2640011ljp; Mon, 17 Dec 2018 08:11:00 -0800 (PST) X-Google-Smtp-Source: AFSGD/VjEjX4Pul1+LeGNkU2OKSq4/mvOEB6Prc9Ju5onCn00mxydHqdcJt9CEMah94uE6VN3ABG X-Received: by 2002:a63:a16:: with SMTP id 22mr12722843pgk.318.1545063059955; Mon, 17 Dec 2018 08:10:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545063059; cv=none; d=google.com; s=arc-20160816; b=Q5vXK4+CmPuG2y6djTh22ynaPl6K5YIJVtqptwsQzlFT7RhV2oMqF/mTHHHO7hS0ba Yr4QGNyUTfHEnzSnZfomu5MAapwyCeLZ0d4+Qcod4+zQzMjWKxhASPCzxhfBxIAQ6AQt 3wLvWXBXWB9pM70u573mtkRzLeEA1p9KAwnaDCehRVIUp2iyqL9xsT/m4bQCXcuVdp7I YPsK5GRwxCsCnbgU0vhLJjYAcwnj7+vAnnEzNtPHAk+u8OwBcnJd+uMzRjJjyH7dyq0J BYm6eH66f3NpQDgXmmrIWjp/WrWvAoSrOWY6AFuhZrgfCWggmqAXKgk50WcBnz1B24e6 17sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=1OFuCwKdWclDokp4HuH6tNSQ6qZ1JvrJw7BVa4cUhdc=; b=0MXVO2+gnLrLpMyJn1Zqe4nrPf/JIbP5erXZSYDQIQdF78TuBVwt8+PgGwUpA8VsYH 2MDoPDzLWl2ipVijVT9gns7CoHNh8MRFhpAf3D6UDzWZtkcTa40A3cLocWWejWKCdC/z nZzXv8iULBCZaIf3apeiJVhtEUHfDDzv2C0JEjBoHyimDiHwykSUfqOlzzcFnfBGrQ6o eK8KtejIACwgyIc1VxFeAOWpgag3cYGVcettbOrES0QQHchEbMWGePdy+/RhVWCBh8bS tv5jXqbYo5jak2eeyS4xjh7JJHbz+2pphUjNSZVoSw1Vdu77F3daZAb+eBQWr8vIAizn SmQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Aa5XnttE; 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 36si11346047pgt.213.2018.12.17.08.10.59; Mon, 17 Dec 2018 08:10:59 -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=@nifty.com header.s=dec2015msa header.b=Aa5XnttE; 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 S2388209AbeLQQK6 (ORCPT + 31 others); Mon, 17 Dec 2018 11:10:58 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:64878 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727841AbeLQQKy (ORCPT ); Mon, 17 Dec 2018 11:10:54 -0500 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-07.nifty.com with ESMTP id wBHG3bRe008119; Tue, 18 Dec 2018 01:03:40 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com wBHG3bRe008119 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1545062621; bh=1OFuCwKdWclDokp4HuH6tNSQ6qZ1JvrJw7BVa4cUhdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Aa5XnttEaP0u87mkoYRbDobvtL9zWX6FMR7V5pC4wzQSegovxMFNURtB0DPvIRwAT /qz1BwVUAj9dQ+hpXCO401fOoPGzDISU9OHQpWhSoxTx8DLVznFePYMiaxITsh035O /vJj0KZJZQNf0WRfT9crTwlzplyVDR6mv+34YtiRUdExcswaKwQgooU7y4iH9whNx+ f+his9eQTy8QimfffPkmCDaGeDleMiAqpLwSGmM21+Ve5SnjdFdWho3cCXNH49wTcg Wc7QbePYfUOBbXKvKOLNAUi2JRq9fwvGWE/D1SZo5peh10gd6DnQ1+s2zjF28HIC9v BagTcdX1sGEBA== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" Cc: Richard Biener , Segher Boessenkool , Peter Zijlstra , Juergen Gross , Josh Poimboeuf , Kees Cook , Linus Torvalds , Masahiro Yamada , linux-kernel@vger.kernel.org, Ard Biesheuvel , Nadav Amit Subject: [PATCH v3 01/12] Revert "x86/jump-labels: Macrofy inline assembly code to work around GCC inlining bugs" Date: Tue, 18 Dec 2018 01:03:16 +0900 Message-Id: <1545062607-8599-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> References: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This partially reverts commit 5bdcd510c2ac9efaf55c4cbd8d46421d8e2320cd. The in-kernel workarounds will be replaced with GCC's new "asm inline" syntax. Only the asm_volatile_goto parts were reverted. The other cleanups (removal of unneeded #error, replacement of STATIC_JUMP_IF_TRUE/FALSE with STATIC_JUMP_IF_NOP/JMP) are kept. Signed-off-by: Masahiro Yamada --- arch/x86/include/asm/jump_label.h | 22 +++++++++++++++++----- arch/x86/kernel/macros.S | 1 - 2 files changed, 17 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h index a5fb34f..cf88ebf 100644 --- a/arch/x86/include/asm/jump_label.h +++ b/arch/x86/include/asm/jump_label.h @@ -20,9 +20,15 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool branch) { - asm_volatile_goto("STATIC_BRANCH_NOP l_yes=\"%l[l_yes]\" key=\"%c0\" " - "branch=\"%c1\"" - : : "i" (key), "i" (branch) : : l_yes); + asm_volatile_goto("1:" + ".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t" + ".pushsection __jump_table, \"aw\" \n\t" + _ASM_ALIGN "\n\t" + ".long 1b - ., %l[l_yes] - . \n\t" + _ASM_PTR "%c0 + %c1 - .\n\t" + ".popsection \n\t" + : : "i" (key), "i" (branch) : : l_yes); + return false; l_yes: return true; @@ -30,8 +36,14 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch) { - asm_volatile_goto("STATIC_BRANCH_JMP l_yes=\"%l[l_yes]\" key=\"%c0\" " - "branch=\"%c1\"" + asm_volatile_goto("1:" + ".byte 0xe9\n\t .long %l[l_yes] - 2f\n\t" + "2:\n\t" + ".pushsection __jump_table, \"aw\" \n\t" + _ASM_ALIGN "\n\t" + ".long 1b - ., %l[l_yes] - . \n\t" + _ASM_PTR "%c0 + %c1 - .\n\t" + ".popsection \n\t" : : "i" (key), "i" (branch) : : l_yes); return false; diff --git a/arch/x86/kernel/macros.S b/arch/x86/kernel/macros.S index 161c950..bf8b9c9 100644 --- a/arch/x86/kernel/macros.S +++ b/arch/x86/kernel/macros.S @@ -13,4 +13,3 @@ #include #include #include -#include From patchwork Mon Dec 17 16:03:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 154007 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2636257ljp; Mon, 17 Dec 2018 08:08:00 -0800 (PST) X-Google-Smtp-Source: AFSGD/VS3nKGpZt+aok0f4VB4yDu1zMa+E0+hoIzdKFav70Qtu4D5BhgcbVltZ5rJQhFgwaBKBa/ X-Received: by 2002:a63:e40c:: with SMTP id a12mr12722992pgi.28.1545062880011; Mon, 17 Dec 2018 08:08:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545062880; cv=none; d=google.com; s=arc-20160816; b=BBliPhTc1tSQMK3Aw9fcH/mTmhMV4FBeFFOgNDJ4eRIm3xxGNSkufUr1r2dQ658VRo CcPqHAb5rZchy7HLDXU5sYeyCL4hzLlcMxDVEah08dW+Z2ANwGSruEKVJZJfottSJikj Q4sLRAXsZTRofCvnAxxdBvZxJ5/IEVQQnm/3X4osdv38TBk+hXHAhvcUQhLxSsrfvqz/ HfOKKugVEzzs+oh09bWXeYEgpXCLl0lJk5gZVKMo7bTUUwTYmw6WLlWqAygC2/oeQQei mE5p/E6jci6MqLFBNkT+4cTsF68og9205iEVPrpgMDmogbdSTVCi/Uywvj9obGgUSE0r L1vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=MJuvZVpe0PUrWwaBeLI0BXBLt8S1WA40UEFmOtxgUc0=; b=v/dZKGfPJwnqS2XFIghmncHu6oFUuNdFC0DwYr27VLqdzclS2JX+5lDILJporAKp3w dWqAIw1bOBBqhgVb1Cmm1pdaJ42uajf2J1orwCmnQJgE3RtsCIqJe9akLcBgMr5uwEvO DzezW54v0hL4x9gC8/TtnLRRQbw5idXsOxYlOw5g3+wCAEvjdiR0J+eDdlbGr8RF1qP7 X1HZ9t+6+/UjJn948PSbf3yWFLEhbuis+ufXS2GjD30uh2DY+NaDDwjWe/5JCKa8kFG+ YXt5B7JU76srCTqynLGA3qK1xK3tUBM1DOHoQfWsOUA4ZDoi12+i0j07o7ZF763Lvfku RaFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=XNvaAx4X; 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 j91si11622991pld.395.2018.12.17.08.07.59; Mon, 17 Dec 2018 08:07:59 -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=@nifty.com header.s=dec2015msa header.b=XNvaAx4X; 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 S2388172AbeLQQH5 (ORCPT + 31 others); Mon, 17 Dec 2018 11:07:57 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:61736 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbeLQQHz (ORCPT ); Mon, 17 Dec 2018 11:07:55 -0500 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-07.nifty.com with ESMTP id wBHG3bRf008119; Tue, 18 Dec 2018 01:03:42 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com wBHG3bRf008119 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1545062623; bh=MJuvZVpe0PUrWwaBeLI0BXBLt8S1WA40UEFmOtxgUc0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XNvaAx4Xn+c6F1dV+dq6w7wJ132UuTo+Z5IAcCLveUl+0eRwllBVcXd1T2uV6uebo iIGyVlywRojDwimX6EAC/cgQK1UHqnIvNvr/nJhdzIrdghLRfIjGpC69NF60jdfgZV QIVNAMje1aYvaxwMK5tB4hhDm3TI5hAQi0ujdgJxhU9TWPgpT/n6rwvbuQmqe2ysdK qjqG8fXGmkqtTHvZoFZOE9j+H0ZL3VSPU1n7qY2XURs0P5bqBY27JyMbmpmmkYlsOG iYbwozJIdfyS5xwCtYabBVGd06NCl7AyFAmkbURKfRfPn0fnm0aFzo1gwwofu+8Nnv WCHQqN6uH90jw== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" Cc: Richard Biener , Segher Boessenkool , Peter Zijlstra , Juergen Gross , Josh Poimboeuf , Kees Cook , Linus Torvalds , Masahiro Yamada , David Woodhouse , Alexei Starovoitov , linux-kernel@vger.kernel.org, Nadav Amit Subject: [PATCH v3 02/12] Revert "x86/cpufeature: Macrofy inline assembly code to work around GCC inlining bugs" Date: Tue, 18 Dec 2018 01:03:17 +0900 Message-Id: <1545062607-8599-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> References: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This reverts commit d5a581d84ae6b8a4a740464b80d8d9cf1e7947b2. The in-kernel workarounds will be replaced with GCC's new "asm inline" syntax. Signed-off-by: Masahiro Yamada --- arch/x86/include/asm/cpufeature.h | 82 +++++++++++++++++---------------------- arch/x86/kernel/macros.S | 1 - 2 files changed, 35 insertions(+), 48 deletions(-) -- 2.7.4 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index 7d44272..aced6c9 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -2,10 +2,10 @@ #ifndef _ASM_X86_CPUFEATURE_H #define _ASM_X86_CPUFEATURE_H -#ifdef __KERNEL__ -#ifndef __ASSEMBLY__ - #include + +#if defined(__KERNEL__) && !defined(__ASSEMBLY__) + #include #include @@ -161,10 +161,37 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit); */ static __always_inline __pure bool _static_cpu_has(u16 bit) { - asm_volatile_goto("STATIC_CPU_HAS bitnum=%[bitnum] " - "cap_byte=\"%[cap_byte]\" " - "feature=%P[feature] t_yes=%l[t_yes] " - "t_no=%l[t_no] always=%P[always]" + asm_volatile_goto("1: jmp 6f\n" + "2:\n" + ".skip -(((5f-4f) - (2b-1b)) > 0) * " + "((5f-4f) - (2b-1b)),0x90\n" + "3:\n" + ".section .altinstructions,\"a\"\n" + " .long 1b - .\n" /* src offset */ + " .long 4f - .\n" /* repl offset */ + " .word %P[always]\n" /* always replace */ + " .byte 3b - 1b\n" /* src len */ + " .byte 5f - 4f\n" /* repl len */ + " .byte 3b - 2b\n" /* pad len */ + ".previous\n" + ".section .altinstr_replacement,\"ax\"\n" + "4: jmp %l[t_no]\n" + "5:\n" + ".previous\n" + ".section .altinstructions,\"a\"\n" + " .long 1b - .\n" /* src offset */ + " .long 0\n" /* no replacement */ + " .word %P[feature]\n" /* feature bit */ + " .byte 3b - 1b\n" /* src len */ + " .byte 0\n" /* repl len */ + " .byte 0\n" /* pad len */ + ".previous\n" + ".section .altinstr_aux,\"ax\"\n" + "6:\n" + " testb %[bitnum],%[cap_byte]\n" + " jnz %l[t_yes]\n" + " jmp %l[t_no]\n" + ".previous\n" : : [feature] "i" (bit), [always] "i" (X86_FEATURE_ALWAYS), [bitnum] "i" (1 << (bit & 7)), @@ -199,44 +226,5 @@ static __always_inline __pure bool _static_cpu_has(u16 bit) #define CPU_FEATURE_TYPEVAL boot_cpu_data.x86_vendor, boot_cpu_data.x86, \ boot_cpu_data.x86_model -#else /* __ASSEMBLY__ */ - -.macro STATIC_CPU_HAS bitnum:req cap_byte:req feature:req t_yes:req t_no:req always:req -1: - jmp 6f -2: - .skip -(((5f-4f) - (2b-1b)) > 0) * ((5f-4f) - (2b-1b)),0x90 -3: - .section .altinstructions,"a" - .long 1b - . /* src offset */ - .long 4f - . /* repl offset */ - .word \always /* always replace */ - .byte 3b - 1b /* src len */ - .byte 5f - 4f /* repl len */ - .byte 3b - 2b /* pad len */ - .previous - .section .altinstr_replacement,"ax" -4: - jmp \t_no -5: - .previous - .section .altinstructions,"a" - .long 1b - . /* src offset */ - .long 0 /* no replacement */ - .word \feature /* feature bit */ - .byte 3b - 1b /* src len */ - .byte 0 /* repl len */ - .byte 0 /* pad len */ - .previous - .section .altinstr_aux,"ax" -6: - testb \bitnum,\cap_byte - jnz \t_yes - jmp \t_no - .previous -.endm - -#endif /* __ASSEMBLY__ */ - -#endif /* __KERNEL__ */ +#endif /* defined(__KERNEL__) && !defined(__ASSEMBLY__) */ #endif /* _ASM_X86_CPUFEATURE_H */ diff --git a/arch/x86/kernel/macros.S b/arch/x86/kernel/macros.S index bf8b9c9..7baa40d 100644 --- a/arch/x86/kernel/macros.S +++ b/arch/x86/kernel/macros.S @@ -12,4 +12,3 @@ #include #include #include -#include From patchwork Mon Dec 17 16:03:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 154015 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2640503ljp; Mon, 17 Dec 2018 08:11:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/VzKmljpO9PbT/9uT+QAWXSCTEVd8c7WVX1s7muqswUL5ZdG93g8+kMR8B8/Vb4NRbelRVS X-Received: by 2002:a63:b0a:: with SMTP id 10mr9497347pgl.423.1545063083866; Mon, 17 Dec 2018 08:11:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545063083; cv=none; d=google.com; s=arc-20160816; b=0OI1NIarWjBLcLKtiBNLre9UeXHBG1JIJNHd+zievBe+smLtuYXhJR0kIrTad1LyR7 +UwWt7a59rJO4qWHGOgVknyhDwpuzKXVr6hwiV0WxHx3GxDN5kfUSk43TkYt1lMwzrtH Lt2OU+PxYilXLErPcyxfnrZ/zuFlzc5Q6C60OfSvkbbvVNMMxY8anubpQ5OEHWr3+UCg ehbKaYtbo0pzXa9hdJ/vfRMvh6ZAkIHXyNZQcfc95dvTPhW6Bkyptqyf+83XDDNfh4C0 ByX4qCTUsbt2K0OcvdGbLy0B3GTOzA6JVyxee/MBLkAosXeE4ZGBV4N3dRNedplNDKOm Hl2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=kHNal4UmUGn0s8J+K0Ap+BknqWU9QPW2PO6e5dHn7Rg=; b=AkwIbxoyyhYkoLuQxfwKFgp031GvgvxnLCpvzNcZavdLB4/yqiIXbIhA821B127gvu USzpYMjdCPtxxRmtqI+8qJIb+RjsOeannJKHUjj4MxawKEUUvaRAa1hh7zUP0xV7IDKC 8tCZZCehJzgGuz9uVOoZ+ow20kbyXY4fJHPznPiRZzBcrhkJ3twjRN1ezp9x23IlDoXQ 1j9tNqm/HsnG8W12lPSohqRL889McdDFtqBGAHh83UrS/Qm/PDytYKGgBB+JYv/oW4TA ODduIXXcOgs3Bu7Xb4sdvyGKHOXmKMrXNxWDRizfka5JDPgg1K6fYucDb9YkcyTUoZw2 WAcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=iJkFFCqR; 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 j132si7406217pfc.84.2018.12.17.08.11.23; Mon, 17 Dec 2018 08:11:23 -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=@nifty.com header.s=dec2015msa header.b=iJkFFCqR; 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 S2388271AbeLQQLV (ORCPT + 31 others); Mon, 17 Dec 2018 11:11:21 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:65347 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727814AbeLQQLU (ORCPT ); Mon, 17 Dec 2018 11:11:20 -0500 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-07.nifty.com with ESMTP id wBHG3bRg008119; Tue, 18 Dec 2018 01:03:43 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com wBHG3bRg008119 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1545062624; bh=kHNal4UmUGn0s8J+K0Ap+BknqWU9QPW2PO6e5dHn7Rg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iJkFFCqRQUQzPzByJamvTnfzkMZR+YgIQ8wx4pAK+/4Xpfltk8zvFCcDzMPkZQjo7 q0/F/MaxrxLoNISMfqPGOIqm0wRTdAnbChtFjAePEzf7M2ilHDWVlwv7kqvQtsW3mO jUur5BGmid1l4aAtAfyWgqHq7IKUE31dm4afZp7k9ZONdM0WSmkAraWfG7eI2ej+xF KL3pcI3+Dh9n5UwvGwkQGN1xSqe4aWfXBN9ow+CTZDTVZIvSgMdZK+apdggdE5aCfe qgpx1EA7nqI0nAx/3693NhGpCR5o8VzZodmT9lX1Dub8P6AJXBUqwawajgz1TtowHw FSw+aH+nCx/lw== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" Cc: Richard Biener , Segher Boessenkool , Peter Zijlstra , Juergen Gross , Josh Poimboeuf , Kees Cook , Linus Torvalds , Masahiro Yamada , Yonghong Song , linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Nadav Amit , Jann Horn Subject: [PATCH v3 03/12] Revert "x86/extable: Macrofy inline assembly code to work around GCC inlining bugs" Date: Tue, 18 Dec 2018 01:03:18 +0900 Message-Id: <1545062607-8599-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> References: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This reverts commit 0474d5d9d2f7f3b11262f7bf87d0e7314ead9200. The in-kernel workarounds will be replaced with GCC's new "asm inline" syntax. Signed-off-by: Masahiro Yamada --- I blindly reverted here, but I will clean it up in a different way later. arch/x86/include/asm/asm.h | 53 +++++++++++++++++++++++++++++----------------- arch/x86/kernel/macros.S | 1 - 2 files changed, 33 insertions(+), 21 deletions(-) -- 2.7.4 diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h index 21b0867..6467757b 100644 --- a/arch/x86/include/asm/asm.h +++ b/arch/x86/include/asm/asm.h @@ -120,25 +120,12 @@ /* Exception table entry */ #ifdef __ASSEMBLY__ # define _ASM_EXTABLE_HANDLE(from, to, handler) \ - ASM_EXTABLE_HANDLE from to handler - -.macro ASM_EXTABLE_HANDLE from:req to:req handler:req - .pushsection "__ex_table","a" - .balign 4 - .long (\from) - . - .long (\to) - . - .long (\handler) - . + .pushsection "__ex_table","a" ; \ + .balign 4 ; \ + .long (from) - . ; \ + .long (to) - . ; \ + .long (handler) - . ; \ .popsection -.endm -#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) \ _ASM_EXTABLE_HANDLE(from, to, ex_handler_default) @@ -161,7 +148,6 @@ _ASM_PTR (entry); \ .popsection -#ifdef __ASSEMBLY__ .macro ALIGN_DESTINATION /* check for bad alignment of destination */ movl %edi,%ecx @@ -185,7 +171,34 @@ _ASM_EXTABLE_UA(100b, 103b) _ASM_EXTABLE_UA(101b, 103b) .endm -#endif /* __ASSEMBLY__ */ + +#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_UA(from, to) \ + _ASM_EXTABLE_HANDLE(from, to, ex_handler_uaccess) + +# 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 7baa40d..71d8b71 100644 --- a/arch/x86/kernel/macros.S +++ b/arch/x86/kernel/macros.S @@ -11,4 +11,3 @@ #include #include #include -#include From patchwork Mon Dec 17 16:03:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 154013 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2640223ljp; Mon, 17 Dec 2018 08:11:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vz+TIheQfEqYWSDho+1Brx9r37TkVT6vR01hZTiQTesr/tqgRBtL2Jnc5mVvHypp46dZwh X-Received: by 2002:a17:902:27a8:: with SMTP id d37mr13461055plb.182.1545063070047; Mon, 17 Dec 2018 08:11:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545063070; cv=none; d=google.com; s=arc-20160816; b=jghznraKI10oLNNzS2OOsFVz5DgRsEeO+bScrHGUFwc0gazQkR5eX0CCwHKtieHETw Hds9NyYzSx680q3y2I3FQMEzuDU7w97PHeIqVO3VJYjdka3ZSojkOl0gCnrMucgNM8oX tv0yon3W2N2I278Pea8OsXY5j9kTEiYn5W2QG7HcQhz70jcg2htPfL/xKHwAwpdF8mDo ha8YKKS0j8Pw/5/zT0hwWC2EsabfIrfVO8o5vFnlHLf2IYsCPN0aecRrtqko45jH8GeX 6baWFGJXJbJW1gP5paCa3OV1oJktQYbNPmGJaxj5XbvdWY0u46G0GKA6Ns0WyHx17TO0 7sBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=4SKjXoI2Jxb7F0Ixp5LIs9imyh9UsRJoHsSQtzSTnpI=; b=tyhbX8PRCtiFczsdYCqokpxlMvP1W4BD2e64SUo1k1/QKxn6rG4JTYBzb6sbIVl+no Waj3ZiwhNxXJa7cpOUMu/n6KGlzBZFmEsxwIJRy3lBM21njmBL8Xx8DOo/2nweyDz3HT tuDVIVdNA/NMhVNBBHNwLS5InKTafrjxCl7b2KFj9fsT5/3uRkUlkyDvsjY+dl3fMWeg 4Ti114+hUyv3QhfXP8CB6KRcyIvmx2Mw1PTFlXHDN9/kEV6P3fQTgO7GdKwHGh3Hyhu7 LuEZ4L87R+Ote2iMwXLQ9o7S6XdrFCMhSSVQNEiAzAlWa8Czbovv8+tcu57IUngb9iK0 FFMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Ob0D0mxV; 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 9si7573140pgn.524.2018.12.17.08.11.09; Mon, 17 Dec 2018 08:11:10 -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=@nifty.com header.s=dec2015msa header.b=Ob0D0mxV; 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 S2388165AbeLQQK5 (ORCPT + 31 others); Mon, 17 Dec 2018 11:10:57 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:64908 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387635AbeLQQK4 (ORCPT ); Mon, 17 Dec 2018 11:10:56 -0500 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-07.nifty.com with ESMTP id wBHG3bRh008119; Tue, 18 Dec 2018 01:03:45 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com wBHG3bRh008119 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1545062626; bh=4SKjXoI2Jxb7F0Ixp5LIs9imyh9UsRJoHsSQtzSTnpI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ob0D0mxV+BsEDq6V+1LAf0RhGlCEM1YU31zLHp3MSmuJpGmgessOc4JqsfHqmIRjy en0clOvcCoQLoQ1A8LHb9/MHkNZbg3iOmvogaWc1wZWPBHH+xXtiLpoB63U0a+qymH 7CBQFGfP9IiOOytKQNiXoKyTMMONZvypdX1TjswZx8VCg/Qdsj6t9Pw12PVUqQFEtM jdhzDyR+IJaDskeKs6Y6xs7I2nXm6mNzMOGs3a6eP6hi+w5+FOVxPHPv6PmNZJeK0O /np0CI0VSaaqALy7qf4Exg/OeLcoMyuIHPxXTXuGI4oeuOjdF6gLIGxF/MuQCBO9+h +oG/9cmWVEgHA== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" Cc: Richard Biener , Segher Boessenkool , Peter Zijlstra , Juergen Gross , Josh Poimboeuf , Kees Cook , Linus Torvalds , Masahiro Yamada , Nadav Amit , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Alok Kataria Subject: [PATCH v3 04/12] Revert "x86/paravirt: Work around GCC inlining bugs when compiling paravirt ops" Date: Tue, 18 Dec 2018 01:03:19 +0900 Message-Id: <1545062607-8599-5-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> References: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This reverts commit 494b5168f2de009eb80f198f668da374295098dd. The in-kernel workarounds will be replaced with GCC's new "asm inline" syntax. Signed-off-by: Masahiro Yamada --- arch/x86/include/asm/paravirt_types.h | 56 ++++++++++++++++++----------------- arch/x86/kernel/macros.S | 1 - 2 files changed, 29 insertions(+), 28 deletions(-) -- 2.7.4 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h index 26942ad..488c596 100644 --- a/arch/x86/include/asm/paravirt_types.h +++ b/arch/x86/include/asm/paravirt_types.h @@ -348,11 +348,23 @@ extern struct paravirt_patch_template pv_ops; #define paravirt_clobber(clobber) \ [paravirt_clobber] "i" (clobber) +/* + * Generate some code, and mark it as patchable by the + * apply_paravirt() alternate instruction patcher. + */ +#define _paravirt_alt(insn_string, type, clobber) \ + "771:\n\t" insn_string "\n" "772:\n" \ + ".pushsection .parainstructions,\"a\"\n" \ + _ASM_ALIGN "\n" \ + _ASM_PTR " 771b\n" \ + " .byte " type "\n" \ + " .byte 772b-771b\n" \ + " .short " clobber "\n" \ + ".popsection\n" + /* Generate patchable code, with the default asm parameters. */ -#define paravirt_call \ - "PARAVIRT_CALL type=\"%c[paravirt_typenum]\"" \ - " clobber=\"%c[paravirt_clobber]\"" \ - " pv_opptr=\"%c[paravirt_opptr]\";" +#define paravirt_alt(insn_string) \ + _paravirt_alt(insn_string, "%c[paravirt_typenum]", "%c[paravirt_clobber]") /* Simple instruction patching code. */ #define NATIVE_LABEL(a,x,b) "\n\t.globl " a #x "_" #b "\n" a #x "_" #b ":\n\t" @@ -373,6 +385,16 @@ unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len); int paravirt_disable_iospace(void); /* + * This generates an indirect call based on the operation type number. + * The type number, computed in PARAVIRT_PATCH, is derived from the + * offset into the paravirt_patch_template structure, and can therefore be + * freely converted back into a structure offset. + */ +#define PARAVIRT_CALL \ + ANNOTATE_RETPOLINE_SAFE \ + "call *%c[paravirt_opptr];" + +/* * These macros are intended to wrap calls through one of the paravirt * ops structs, so that they can be later identified and patched at * runtime. @@ -509,7 +531,7 @@ int paravirt_disable_iospace(void); /* since this condition will never hold */ \ if (sizeof(rettype) > sizeof(unsigned long)) { \ asm volatile(pre \ - paravirt_call \ + paravirt_alt(PARAVIRT_CALL) \ post \ : call_clbr, ASM_CALL_CONSTRAINT \ : paravirt_type(op), \ @@ -519,7 +541,7 @@ int paravirt_disable_iospace(void); __ret = (rettype)((((u64)__edx) << 32) | __eax); \ } else { \ asm volatile(pre \ - paravirt_call \ + paravirt_alt(PARAVIRT_CALL) \ post \ : call_clbr, ASM_CALL_CONSTRAINT \ : paravirt_type(op), \ @@ -546,7 +568,7 @@ int paravirt_disable_iospace(void); PVOP_VCALL_ARGS; \ PVOP_TEST_NULL(op); \ asm volatile(pre \ - paravirt_call \ + paravirt_alt(PARAVIRT_CALL) \ post \ : call_clbr, ASM_CALL_CONSTRAINT \ : paravirt_type(op), \ @@ -664,26 +686,6 @@ struct paravirt_patch_site { extern struct paravirt_patch_site __parainstructions[], __parainstructions_end[]; -#else /* __ASSEMBLY__ */ - -/* - * This generates an indirect call based on the operation type number. - * The type number, computed in PARAVIRT_PATCH, is derived from the - * offset into the paravirt_patch_template structure, and can therefore be - * freely converted back into a structure offset. - */ -.macro PARAVIRT_CALL type:req clobber:req pv_opptr:req -771: ANNOTATE_RETPOLINE_SAFE - call *\pv_opptr -772: .pushsection .parainstructions,"a" - _ASM_ALIGN - _ASM_PTR 771b - .byte \type - .byte 772b-771b - .short \clobber - .popsection -.endm - #endif /* __ASSEMBLY__ */ #endif /* _ASM_X86_PARAVIRT_TYPES_H */ diff --git a/arch/x86/kernel/macros.S b/arch/x86/kernel/macros.S index 71d8b71..66ccb8e 100644 --- a/arch/x86/kernel/macros.S +++ b/arch/x86/kernel/macros.S @@ -10,4 +10,3 @@ #include #include #include -#include From patchwork Mon Dec 17 16:03:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 154012 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2640068ljp; Mon, 17 Dec 2018 08:11:02 -0800 (PST) X-Google-Smtp-Source: AFSGD/WfqTwIvoqeQIUAcMSajpKADskRJpOTHNBurPQ+LqzSUS3W+EjLORbXhPhSer3i+uZ5qBQo X-Received: by 2002:a63:f901:: with SMTP id h1mr12617628pgi.154.1545063062790; Mon, 17 Dec 2018 08:11:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545063062; cv=none; d=google.com; s=arc-20160816; b=zOnTLRZkDy4DjdYMXHlS4sWgRkn6zoo3hzo+AkPOOm4f1VEcsMyDI8Tc8zg8oobCle wsivK29tNB7wx+aWCudAQJUo6d0itUC/439PfFpBGqcora8YLd/w1YmAF2lSLv6R5n9I PMeB9VOgh0UGEC5DzBTel4cWd60kBhw+75/Ld5TY9z1do7JYNvHNgm6Zk8Y47MmeVmnf AUlnoYCpwwTl/uXOq7sqpVnXGH/ouYTJkhoQa0YWkdaUlMr9VBBVoviOkuwKk/2uxY4S IQtC9cOC/PgbFwptvLYpA497nNDwfhSKCI7QyL+Fe0u6D5fA+rdv7Yxx4cDlczofArba L9lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=XsfYrfLZf85NxXPieKuHNNRf8I2glcI/qdIVKn3J7kY=; b=Fanpwv/KrFNGSAYf3F+IziusQ7Uh49EXNy6BqegABA5/k+7T2Hjwh044G9iryWMzur 815ZJGQvD5B3YnJ0G64PJgprvm+lEdoiD4+f6521IUYTw/Nk4Pq/ef54bPVa/LTsEH0l VbDnJ1FuchIvWHgQS18oPJQBcE0Y8sD5F4clwpmAkkmmxX1Ig4VM/0RRYXnjLFBMdgLY vPeUcBA3Q/b0LBFrfedVIqPhasgmON4wzec8g4MlhEWJvEzKzHOhQ3wiZo+jOe8f6kEP ty1G+Yt4nM4gqtY5nLC5LCfS8RF7p/etVKmubsbAIWPTq3RKmXW1gXdHdxkynDeyBtC5 zZjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=uutzTQnL; 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 z3si10744030pln.430.2018.12.17.08.11.02; Mon, 17 Dec 2018 08:11:02 -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=@nifty.com header.s=dec2015msa header.b=uutzTQnL; 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 S2388225AbeLQQLB (ORCPT + 31 others); Mon, 17 Dec 2018 11:11:01 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:64948 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388139AbeLQQK6 (ORCPT ); Mon, 17 Dec 2018 11:10:58 -0500 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-07.nifty.com with ESMTP id wBHG3bRi008119; Tue, 18 Dec 2018 01:03:46 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com wBHG3bRi008119 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1545062627; bh=XsfYrfLZf85NxXPieKuHNNRf8I2glcI/qdIVKn3J7kY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uutzTQnL21q2QZDhUPf4psTVjZy0+/QJsWpElxrBnOAhrsOagz/uEC7B7aeDv00O6 9SHdNTTXtKHH+VUv73W+oNC/qvPxtn+8/3kAY8f+NgtF/tpBS6oQzQRSrVCjvcvgFb Ma5Q39i+32vtzlNcj0yE1FXmDYzxe+Y5Pvdwp+uQsL442mm/e2uoVzYqZE/ybTNGHC BFO/SZf/Wd5aR/o/m0DC0ymv9/vIqtfK5+BgR25RMmJm3Mp5hFdAhIDjv84TnV+Dns PuP84ulppu9LzgGqTHGs9mquVTjSu9Ky20p5gav0SN/gV71qK+w4pBz2mRLBShB7An gg4m7RQvpWqtA== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" Cc: Richard Biener , Segher Boessenkool , Peter Zijlstra , Juergen Gross , Josh Poimboeuf , Kees Cook , Linus Torvalds , Masahiro Yamada , linux-arch@vger.kernel.org, Arnd Bergmann , linux-kernel@vger.kernel.org, Nadav Amit Subject: [PATCH v3 05/12] Revert "x86/bug: Macrofy the BUG table section handling, to work around GCC inlining bugs" Date: Tue, 18 Dec 2018 01:03:20 +0900 Message-Id: <1545062607-8599-6-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> References: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This reverts commit f81f8ad56fd1c7b99b2ed1c314527f7d9ac447c6. The in-kernel workarounds will be replaced with GCC's new "asm inline" syntax. Signed-off-by: Masahiro Yamada --- arch/x86/include/asm/bug.h | 98 ++++++++++++++++++++-------------------------- arch/x86/kernel/macros.S | 1 - include/asm-generic/bug.h | 8 ++-- 3 files changed, 46 insertions(+), 61 deletions(-) -- 2.7.4 diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h index 5090035..6804d66 100644 --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h @@ -4,8 +4,6 @@ #include -#ifndef __ASSEMBLY__ - /* * Despite that some emulators terminate on UD2, we use it for WARN(). * @@ -22,15 +20,53 @@ #define LEN_UD2 2 +#ifdef CONFIG_GENERIC_BUG + +#ifdef CONFIG_X86_32 +# define __BUG_REL(val) ".long " __stringify(val) +#else +# define __BUG_REL(val) ".long " __stringify(val) " - 2b" +#endif + +#ifdef CONFIG_DEBUG_BUGVERBOSE + +#define _BUG_FLAGS(ins, flags) \ +do { \ + asm volatile("1:\t" ins "\n" \ + ".pushsection __bug_table,\"aw\"\n" \ + "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ + "\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \ + "\t.word %c1" "\t# bug_entry::line\n" \ + "\t.word %c2" "\t# bug_entry::flags\n" \ + "\t.org 2b+%c3\n" \ + ".popsection" \ + : : "i" (__FILE__), "i" (__LINE__), \ + "i" (flags), \ + "i" (sizeof(struct bug_entry))); \ +} while (0) + +#else /* !CONFIG_DEBUG_BUGVERBOSE */ + #define _BUG_FLAGS(ins, flags) \ do { \ - asm volatile("ASM_BUG ins=\"" ins "\" file=%c0 line=%c1 " \ - "flags=%c2 size=%c3" \ - : : "i" (__FILE__), "i" (__LINE__), \ - "i" (flags), \ + asm volatile("1:\t" ins "\n" \ + ".pushsection __bug_table,\"aw\"\n" \ + "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ + "\t.word %c0" "\t# bug_entry::flags\n" \ + "\t.org 2b+%c1\n" \ + ".popsection" \ + : : "i" (flags), \ "i" (sizeof(struct bug_entry))); \ } while (0) +#endif /* CONFIG_DEBUG_BUGVERBOSE */ + +#else + +#define _BUG_FLAGS(ins, flags) asm volatile(ins) + +#endif /* CONFIG_GENERIC_BUG */ + #define HAVE_ARCH_BUG #define BUG() \ do { \ @@ -46,54 +82,4 @@ do { \ #include -#else /* __ASSEMBLY__ */ - -#ifdef CONFIG_GENERIC_BUG - -#ifdef CONFIG_X86_32 -.macro __BUG_REL val:req - .long \val -.endm -#else -.macro __BUG_REL val:req - .long \val - 2b -.endm -#endif - -#ifdef CONFIG_DEBUG_BUGVERBOSE - -.macro ASM_BUG ins:req file:req line:req flags:req size:req -1: \ins - .pushsection __bug_table,"aw" -2: __BUG_REL val=1b # bug_entry::bug_addr - __BUG_REL val=\file # bug_entry::file - .word \line # bug_entry::line - .word \flags # bug_entry::flags - .org 2b+\size - .popsection -.endm - -#else /* !CONFIG_DEBUG_BUGVERBOSE */ - -.macro ASM_BUG ins:req file:req line:req flags:req size:req -1: \ins - .pushsection __bug_table,"aw" -2: __BUG_REL val=1b # bug_entry::bug_addr - .word \flags # bug_entry::flags - .org 2b+\size - .popsection -.endm - -#endif /* CONFIG_DEBUG_BUGVERBOSE */ - -#else /* CONFIG_GENERIC_BUG */ - -.macro ASM_BUG ins:req file:req line:req flags:req size:req - \ins -.endm - -#endif /* CONFIG_GENERIC_BUG */ - -#endif /* __ASSEMBLY__ */ - #endif /* _ASM_X86_BUG_H */ diff --git a/arch/x86/kernel/macros.S b/arch/x86/kernel/macros.S index 66ccb8e..852487a 100644 --- a/arch/x86/kernel/macros.S +++ b/arch/x86/kernel/macros.S @@ -9,4 +9,3 @@ #include #include #include -#include diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index cdafa5e..20561a6 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h @@ -17,8 +17,10 @@ #ifndef __ASSEMBLY__ #include -struct bug_entry { +#ifdef CONFIG_BUG + #ifdef CONFIG_GENERIC_BUG +struct bug_entry { #ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS unsigned long bug_addr; #else @@ -33,10 +35,8 @@ struct bug_entry { unsigned short line; #endif unsigned short flags; -#endif /* CONFIG_GENERIC_BUG */ }; - -#ifdef CONFIG_BUG +#endif /* CONFIG_GENERIC_BUG */ /* * Don't use BUG() or BUG_ON() unless there's really no way out; one From patchwork Mon Dec 17 16:03:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 154014 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2640327ljp; Mon, 17 Dec 2018 08:11:14 -0800 (PST) X-Google-Smtp-Source: AFSGD/Uj6nWeymMdgGVDe3ZeGgWnW0BdQibVKYg7P2srJ43nZvfMkF7J1tLvCX1SN26dBdvyBa9Y X-Received: by 2002:a63:111c:: with SMTP id g28mr12552553pgl.85.1545063074430; Mon, 17 Dec 2018 08:11:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545063074; cv=none; d=google.com; s=arc-20160816; b=JqlatJKkdhHCyL6sfUGnHa69YYU1HbkV5qnA6HpPO90p5GT+5SiMpYaYLzmPppic/z Kv6MZ2IeMPwmbaVyZ/e5SxR4T3m1f0NDJGzc+vnvWBsbbaBe+nthuVXTs+pHKD8TdE8I WRNQuDQZHkbMBv+FyWuoy64gAxKkPBSo40PfM5e2k6WZ0Ie9r1EUdz2FpOSTfbIIm7nn wwv3E+i6MRZ9GWalh0OmLOZZqC1UVrJipgoxvwp5fjte1lHAhAvLV89aTo3HciM3iRoR cW4zPN7oXZpCoH6IHoY/Gz2KH/yeY+ezwNH9cW3MsuiidJIrNkPH528QvOjMqTKhedBg XuCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=dFD8Gwu+yAksuGT9Rgxw6GpB3bscgIYkgUVU4dNRgro=; b=IC0bRy0+IuLto7EgjANBMLQ3y3YdJdNrjvgBD0bh5aq45EEPSEGQlY9m0IlRh1NFDr ICOsqGGAkbJ/at+Y1GMZ2+cB32ZsimQLOxBk8Ew8HMnoOfq3lftN4EOMOzij5v43QS3M 5ol6Q0XcqhEWMMzN+RZCwxGPLx0MfBVziZt5NNhHFDrWeEnH127i90I0nBRC6OqfbqQ+ HF8S4LorHTs0OKtqWALgtwCNGABKAV6FNpm9/9FVlQJqkvfEtHuY6EaaOjbQJ/pIHhCF fw4E7mTwkqzZEqKCv7oqx9+mbrhwKjP8TWlygni9szDthvxJHqcjWeQOg+uMwbRyG9L5 NQ3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=c6TeJLgN; 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 l124si11528165pfl.284.2018.12.17.08.11.14; Mon, 17 Dec 2018 08:11:14 -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=@nifty.com header.s=dec2015msa header.b=c6TeJLgN; 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 S2388234AbeLQQLM (ORCPT + 31 others); Mon, 17 Dec 2018 11:11:12 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:65176 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726548AbeLQQLJ (ORCPT ); Mon, 17 Dec 2018 11:11:09 -0500 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-07.nifty.com with ESMTP id wBHG3bRj008119; Tue, 18 Dec 2018 01:03:47 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com wBHG3bRj008119 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1545062629; bh=dFD8Gwu+yAksuGT9Rgxw6GpB3bscgIYkgUVU4dNRgro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c6TeJLgNTA4bcMva8jdxX45ybV4vRZWXTAqdl67ttw7FPo3EjLPr48N+sGdg7zdFW 7Vrvy5bm3Hq7mjr9+GgUih0w0wXf/fgHbcPBQhDFLlD9y7fMhZdUn4XSagxch/OHq+ YYFPh4R/PygzJx4UeZrhWeni/GoU/2NYAB47PfaPP9Z9v6t2+4G4Czjz6sGBbPGkF2 bY3UhFLzExhQaJs4sao8TvaXQ7kDTBspHXqvxSFRgXAp6jU1ounhmLYaWLN+82FC2N s4C4K8e0ZovZlfYWYHYqkG7QGI5FYHQ+bBbS+SjygOV4oTkeyrWgNBP4Zg9kURcRek CZtA2Cc0Tx59g== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" Cc: Richard Biener , Segher Boessenkool , Peter Zijlstra , Juergen Gross , Josh Poimboeuf , Kees Cook , Linus Torvalds , Masahiro Yamada , David Woodhouse , linux-kernel@vger.kernel.org, Alexey Dobriyan , Nadav Amit Subject: [PATCH v3 06/12] Revert "x86/alternatives: Macrofy lock prefixes to work around GCC inlining bugs" Date: Tue, 18 Dec 2018 01:03:21 +0900 Message-Id: <1545062607-8599-7-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> References: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This reverts commit 77f48ec28e4ccff94d2e5f4260a83ac27a7f3099. The in-kernel workarounds will be replaced with GCC's new "asm inline" syntax. Signed-off-by: Masahiro Yamada --- I blindly reverted here, but I will clean it up in a different way later. arch/x86/include/asm/alternative-asm.h | 20 ++++++-------------- arch/x86/include/asm/alternative.h | 11 +++++++++-- arch/x86/kernel/macros.S | 1 - 3 files changed, 15 insertions(+), 17 deletions(-) -- 2.7.4 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h index 8e4ea39..31b627b 100644 --- a/arch/x86/include/asm/alternative-asm.h +++ b/arch/x86/include/asm/alternative-asm.h @@ -7,24 +7,16 @@ #include #ifdef CONFIG_SMP -.macro LOCK_PREFIX_HERE + .macro LOCK_PREFIX +672: lock .pushsection .smp_locks,"a" .balign 4 - .long 671f - . # offset + .long 672b - . .popsection -671: -.endm - -.macro LOCK_PREFIX insn:vararg - LOCK_PREFIX_HERE - lock \insn -.endm + .endm #else -.macro LOCK_PREFIX_HERE -.endm - -.macro LOCK_PREFIX insn:vararg -.endm + .macro LOCK_PREFIX + .endm #endif /* diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index d7faa16..4cd6a3b 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -31,8 +31,15 @@ */ #ifdef CONFIG_SMP -#define LOCK_PREFIX_HERE "LOCK_PREFIX_HERE\n\t" -#define LOCK_PREFIX "LOCK_PREFIX " +#define LOCK_PREFIX_HERE \ + ".pushsection .smp_locks,\"a\"\n" \ + ".balign 4\n" \ + ".long 671f - .\n" /* offset */ \ + ".popsection\n" \ + "671:" + +#define LOCK_PREFIX LOCK_PREFIX_HERE "\n\tlock; " + #else /* ! CONFIG_SMP */ #define LOCK_PREFIX_HERE "" #define LOCK_PREFIX "" diff --git a/arch/x86/kernel/macros.S b/arch/x86/kernel/macros.S index 852487a..f1fe1d5 100644 --- a/arch/x86/kernel/macros.S +++ b/arch/x86/kernel/macros.S @@ -8,4 +8,3 @@ #include #include -#include From patchwork Mon Dec 17 16:03:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 154017 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2640717ljp; Mon, 17 Dec 2018 08:11:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vieqj1agmtM7teIdvil67nwm8i1fbirWfeh59GQR2ma2OCQ0RUQ3m0H9NCiGLJ3+fmmkMu X-Received: by 2002:a63:ac46:: with SMTP id z6mr12617791pgn.162.1545063094406; Mon, 17 Dec 2018 08:11:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545063094; cv=none; d=google.com; s=arc-20160816; b=Vz60xdmjiX3w8xWC3rLAZOFTEVzYsmv9JNf5tuHAi+M7uAuAyC5/ClEZHtnWdtWb4s c4/Mt8yEc3bT8DYK0/XB77bPIjxUnPWplAi5TS9LrsL/MtjLIIKbgXUP3iOgPaur9y6O KcMEEKsiXSCt3o1vPN4K8Az0IeXej/8qwXjs6xOp0wMlZu62skdVb9laqGUpyHtp9iH2 lc86YQnxoxtXWlMfoyftCt/XVbgoNCQ4otja0LFsC7ig69jfbhWXWJGQZD6BooC0BCD7 sLdIPaFDhab28B60qrO5b6iVmn6OowMfBnsPZS4Gy4DT+bLnXPN3F+iF9Jne0JsxNusZ B5OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=Ncxd2084CDNaDsykqqCM0ja6cXudxZXMCOcG57w78u4=; b=h95ZTpEbnQ8hUnQvPOXdoc/6LjcMrAAlG/urZLzNYWmXkOA6EX892jxvp7ZgoVZi96 tA7YOt4K4/x9W+IosnbdOhLaUup3KpWd+TMb6hhbSsxzP3bgCBaqC+uUqqNDhXpDS50L M5wFlKP1kHrrRaniUCE3GFE1FgDz9EsQNKo4h/alXtoCaY0MyrR4EWAZdvt6pcOOp3xd bdVira37+YlV4QX/MSe79N4PCvQiqWc5E7kKGJyOUQe5WC21wPbSuP2m5ZxowIsBDmRA tU73MQ3OPKb7SZaSjlQWsnC6IXkZSR+aj575uQkJA5LhvMlrm6LLIsnE2AMH68XjMSmz UtqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=DQIWUNZW; 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 23si11551611pfk.287.2018.12.17.08.11.34; Mon, 17 Dec 2018 08:11:34 -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=@nifty.com header.s=dec2015msa header.b=DQIWUNZW; 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 S2388282AbeLQQLb (ORCPT + 31 others); Mon, 17 Dec 2018 11:11:31 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:65527 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727814AbeLQQL3 (ORCPT ); Mon, 17 Dec 2018 11:11:29 -0500 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-07.nifty.com with ESMTP id wBHG3bRk008119; Tue, 18 Dec 2018 01:03:49 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com wBHG3bRk008119 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1545062630; bh=Ncxd2084CDNaDsykqqCM0ja6cXudxZXMCOcG57w78u4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DQIWUNZWUM0NwJM0cC8xuPxPsCtjgGQrOYu0DQxt4dwzfD9gqV2PumQQLjS5Hdv+s 7SqvYKdfPxVwNVY5G5zZOU4DJu9pjCDqEAIrf0ZCujiw1Tj0KJIHd+SmmDciqGDFCU vTgNoLKduUZj06nE6KtwKilGdxKeZoA++dsBYDQ/FmxgPAtTRak4paxHyAR16ZBuJi bOLF0f4W8jBdVCngKy5RWgEYmvT1EGWqOhcBGw5hM3kC2kNFKl/YemVi86Kss+WLnz NajeEnKPi8COqXsk4a0GZe3CFgeRrHWnPtBlND5VrLwNU+sLQTt1UAw9zU1wMh69Mn XHnK8NelQmzOA== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" Cc: Richard Biener , Segher Boessenkool , Peter Zijlstra , Juergen Gross , Josh Poimboeuf , Kees Cook , Linus Torvalds , Masahiro Yamada , Alexey Dobriyan , linux-kernel@vger.kernel.org, Jan Beulich , Nadav Amit Subject: [PATCH v3 07/12] Revert "x86/refcount: Work around GCC inlining bug" Date: Tue, 18 Dec 2018 01:03:22 +0900 Message-Id: <1545062607-8599-8-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> References: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This reverts commit 9e1725b410594911cc5981b6c7b4cea4ec054ca8. The in-kernel workarounds will be replaced with GCC's new "asm inline" syntax. Resolved conflicts caused by 288e4521f0f6 ("x86/asm: 'Simplify' GEN_*_RMWcc() macros"). Signed-off-by: Masahiro Yamada --- arch/x86/include/asm/refcount.h | 81 +++++++++++++++++------------------------ arch/x86/kernel/macros.S | 1 - 2 files changed, 33 insertions(+), 49 deletions(-) -- 2.7.4 diff --git a/arch/x86/include/asm/refcount.h b/arch/x86/include/asm/refcount.h index a8b5e1e..dbaed55 100644 --- a/arch/x86/include/asm/refcount.h +++ b/arch/x86/include/asm/refcount.h @@ -4,41 +4,6 @@ * x86-specific implementation of refcount_t. Based on PAX_REFCOUNT from * PaX/grsecurity. */ - -#ifdef __ASSEMBLY__ - -#include -#include - -.macro REFCOUNT_EXCEPTION counter:req - .pushsection .text..refcount -111: lea \counter, %_ASM_CX -112: ud2 - ASM_UNREACHABLE - .popsection -113: _ASM_EXTABLE_REFCOUNT(112b, 113b) -.endm - -/* Trigger refcount exception if refcount result is negative. */ -.macro REFCOUNT_CHECK_LT_ZERO counter:req - js 111f - REFCOUNT_EXCEPTION counter="\counter" -.endm - -/* Trigger refcount exception if refcount result is zero or negative. */ -.macro REFCOUNT_CHECK_LE_ZERO counter:req - jz 111f - REFCOUNT_CHECK_LT_ZERO counter="\counter" -.endm - -/* Trigger refcount exception unconditionally. */ -.macro REFCOUNT_ERROR counter:req - jmp 111f - REFCOUNT_EXCEPTION counter="\counter" -.endm - -#else /* __ASSEMBLY__ */ - #include #include @@ -50,12 +15,35 @@ * central refcount exception. The fixup address for the exception points * back to the regular execution flow in .text. */ +#define _REFCOUNT_EXCEPTION \ + ".pushsection .text..refcount\n" \ + "111:\tlea %[var], %%" _ASM_CX "\n" \ + "112:\t" ASM_UD2 "\n" \ + ASM_UNREACHABLE \ + ".popsection\n" \ + "113:\n" \ + _ASM_EXTABLE_REFCOUNT(112b, 113b) + +/* Trigger refcount exception if refcount result is negative. */ +#define REFCOUNT_CHECK_LT_ZERO \ + "js 111f\n\t" \ + _REFCOUNT_EXCEPTION + +/* Trigger refcount exception if refcount result is zero or negative. */ +#define REFCOUNT_CHECK_LE_ZERO \ + "jz 111f\n\t" \ + REFCOUNT_CHECK_LT_ZERO + +/* Trigger refcount exception unconditionally. */ +#define REFCOUNT_ERROR \ + "jmp 111f\n\t" \ + _REFCOUNT_EXCEPTION static __always_inline void refcount_add(unsigned int i, refcount_t *r) { asm volatile(LOCK_PREFIX "addl %1,%0\n\t" - "REFCOUNT_CHECK_LT_ZERO counter=\"%[counter]\"" - : [counter] "+m" (r->refs.counter) + REFCOUNT_CHECK_LT_ZERO + : [var] "+m" (r->refs.counter) : "ir" (i) : "cc", "cx"); } @@ -63,32 +51,31 @@ static __always_inline void refcount_add(unsigned int i, refcount_t *r) static __always_inline void refcount_inc(refcount_t *r) { asm volatile(LOCK_PREFIX "incl %0\n\t" - "REFCOUNT_CHECK_LT_ZERO counter=\"%[counter]\"" - : [counter] "+m" (r->refs.counter) + REFCOUNT_CHECK_LT_ZERO + : [var] "+m" (r->refs.counter) : : "cc", "cx"); } static __always_inline void refcount_dec(refcount_t *r) { asm volatile(LOCK_PREFIX "decl %0\n\t" - "REFCOUNT_CHECK_LE_ZERO counter=\"%[counter]\"" - : [counter] "+m" (r->refs.counter) + REFCOUNT_CHECK_LE_ZERO + : [var] "+m" (r->refs.counter) : : "cc", "cx"); } static __always_inline __must_check bool refcount_sub_and_test(unsigned int i, refcount_t *r) { - return GEN_BINARY_SUFFIXED_RMWcc(LOCK_PREFIX "subl", - "REFCOUNT_CHECK_LT_ZERO counter=\"%[var]\"", + REFCOUNT_CHECK_LT_ZERO, r->refs.counter, e, "er", i, "cx"); } static __always_inline __must_check bool refcount_dec_and_test(refcount_t *r) { return GEN_UNARY_SUFFIXED_RMWcc(LOCK_PREFIX "decl", - "REFCOUNT_CHECK_LT_ZERO counter=\"%[var]\"", + REFCOUNT_CHECK_LT_ZERO, r->refs.counter, e, "cx"); } @@ -106,8 +93,8 @@ bool refcount_add_not_zero(unsigned int i, refcount_t *r) /* Did we try to increment from/to an undesirable state? */ if (unlikely(c < 0 || c == INT_MAX || result < c)) { - asm volatile("REFCOUNT_ERROR counter=\"%[counter]\"" - : : [counter] "m" (r->refs.counter) + asm volatile(REFCOUNT_ERROR + : : [var] "m" (r->refs.counter) : "cc", "cx"); break; } @@ -122,6 +109,4 @@ static __always_inline __must_check bool refcount_inc_not_zero(refcount_t *r) return refcount_add_not_zero(1, r); } -#endif /* __ASSEMBLY__ */ - #endif diff --git a/arch/x86/kernel/macros.S b/arch/x86/kernel/macros.S index f1fe1d5..cee28c3 100644 --- a/arch/x86/kernel/macros.S +++ b/arch/x86/kernel/macros.S @@ -7,4 +7,3 @@ */ #include -#include From patchwork Mon Dec 17 16:03:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 154009 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2636494ljp; Mon, 17 Dec 2018 08:08:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/VOXQlGN1I9Q9+59jIhebToPyFf9bpSohmaLohu+mW/h8pejmwR5xfar4eIOOxZBm7UwOis X-Received: by 2002:a63:d005:: with SMTP id z5mr12679531pgf.64.1545062890998; Mon, 17 Dec 2018 08:08:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545062890; cv=none; d=google.com; s=arc-20160816; b=DBn+cN2pcX4XG2hsFhT3uCLQPSa68yETnz5wi0Sn919lUdNxwFvuScGqce63PXtVNl EfKqIExduP6+Q+1vG9iry6vlvn/SyR2MdV6FW7Xu4kipJzVSpm48pSQtIPyZVSkwwK/J ajMVdc0CeQEBC4xs3vc7K6/rlZQKTNhPPyG+jVqh3DM2eHEVCYwRfvvfw1IZ4lYLX55X KbANbQZy6yoMroRS04f3RcXZVpC8gtoq+8egg2VO7IJU2S8tnaQloHt7JvYGLhj8NMj3 32+d1FouBRjhqzNnPTt7Iv0jMqFfazV0Vo/W4MtslV6dB4CTNLiMmV1SbMKcfBUywYmU /EuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=YEFM37VoP8iq6zt/Sfo/eyMOxoBwqOHgn1OHsnq/Cpg=; b=Yv+WUBJC3XBxxjq+saQUKBqKkzs1hSu8yQSyes++GZsHTiqoJIsMuP/ck93sDw5xIh z5Ug/x4b1FipXYe2xFcTQ+E2qO5VJR+8OVjxhGvx+OH27jCSs0QvilKjUxtn5sPo6Xzv lRZwIXGBn72dq5HUa+PwK7I12bY9VBMG38JtX0h9jlWu0fuoFqYOQMVpy1bW/fLwyWmr vN/9uzHfmwQVpUyRCxGgyBsD20l1RItmoxUjEKB5IALA5uh9KOUBKIASRz2MF9YI0IAy ABJuRHfmo0KU1hijZZvFwxYcDCZOp7YfeJPX9Y/I9VMiHYLV5SY4VMKyPE7cyowjIfDt tVFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=SZyRKTc2; 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 e22si11257229pge.479.2018.12.17.08.08.10; Mon, 17 Dec 2018 08:08:10 -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=@nifty.com header.s=dec2015msa header.b=SZyRKTc2; 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 S2388197AbeLQQII (ORCPT + 31 others); Mon, 17 Dec 2018 11:08:08 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:61926 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388037AbeLQQIF (ORCPT ); Mon, 17 Dec 2018 11:08:05 -0500 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-07.nifty.com with ESMTP id wBHG3bRl008119; Tue, 18 Dec 2018 01:03:50 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com wBHG3bRl008119 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1545062631; bh=YEFM37VoP8iq6zt/Sfo/eyMOxoBwqOHgn1OHsnq/Cpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SZyRKTc2cXrXSdD+byqOkkRXRbjEFecU2OrfzayHBhLpnlQmjrRR0X4d1rYdHi4Gw /zxv5vAt6rwxhcldHskdNvQBYucrTVRzueyL4ppQRbhSl4I64Q+fKzeawHK37OYDrA KQ8pfJXlpD/RFd5oLx+scOR/MiFCMMsJ9na7PqxrNBS0CCHYpRPbWPkkuO/bVvmalJ lUjPk4s1rlhnpfBCDp7VK2loB9lOiMRmI7u98ZN6Uk4MGyQ35OKUbZ/4sU3bHqmnkR J8g8lu5F7vELxXUPeqtzwgjsLdsL3ayHjA2F7or1g7LzFym8Lb9iuO8t/AWktmq91c UkRKkXTx9T43Q== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" Cc: Richard Biener , Segher Boessenkool , Peter Zijlstra , Juergen Gross , Josh Poimboeuf , Kees Cook , Linus Torvalds , Masahiro Yamada , Luc Van Oostenryck , linux-kernel@vger.kernel.org, linux-sparse@vger.kernel.org, Nadav Amit Subject: [PATCH v3 08/12] Revert "x86/objtool: Use asm macros to work around GCC inlining bugs" Date: Tue, 18 Dec 2018 01:03:23 +0900 Message-Id: <1545062607-8599-9-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> References: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This reverts commit c06c4d8090513f2974dfdbed2ac98634357ac475. The in-kernel workarounds will be replaced with GCC's new "asm inline" syntax. Signed-off-by: Masahiro Yamada --- arch/x86/kernel/macros.S | 2 -- include/linux/compiler.h | 56 +++++++++++------------------------------------- 2 files changed, 13 insertions(+), 45 deletions(-) -- 2.7.4 diff --git a/arch/x86/kernel/macros.S b/arch/x86/kernel/macros.S index cee28c3..cfc1c7d 100644 --- a/arch/x86/kernel/macros.S +++ b/arch/x86/kernel/macros.S @@ -5,5 +5,3 @@ * commonly used. The macros are precompiled into assmebly file which is later * assembled together with each compiled file. */ - -#include diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 06396c1..fc5004a 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -99,13 +99,22 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, * unique, to convince GCC not to merge duplicate inline asm statements. */ #define annotate_reachable() ({ \ - asm volatile("ANNOTATE_REACHABLE counter=%c0" \ - : : "i" (__COUNTER__)); \ + asm volatile("%c0:\n\t" \ + ".pushsection .discard.reachable\n\t" \ + ".long %c0b - .\n\t" \ + ".popsection\n\t" : : "i" (__COUNTER__)); \ }) #define annotate_unreachable() ({ \ - asm volatile("ANNOTATE_UNREACHABLE counter=%c0" \ - : : "i" (__COUNTER__)); \ + asm volatile("%c0:\n\t" \ + ".pushsection .discard.unreachable\n\t" \ + ".long %c0b - .\n\t" \ + ".popsection\n\t" : : "i" (__COUNTER__)); \ }) +#define ASM_UNREACHABLE \ + "999:\n\t" \ + ".pushsection .discard.unreachable\n\t" \ + ".long 999b - .\n\t" \ + ".popsection\n\t" #else #define annotate_reachable() #define annotate_unreachable() @@ -293,45 +302,6 @@ static inline void *offset_to_ptr(const int *off) return (void *)((unsigned long)off + *off); } -#else /* __ASSEMBLY__ */ - -#ifdef __KERNEL__ -#ifndef LINKER_SCRIPT - -#ifdef CONFIG_STACK_VALIDATION -.macro ANNOTATE_UNREACHABLE counter:req -\counter: - .pushsection .discard.unreachable - .long \counter\()b -. - .popsection -.endm - -.macro ANNOTATE_REACHABLE counter:req -\counter: - .pushsection .discard.reachable - .long \counter\()b -. - .popsection -.endm - -.macro ASM_UNREACHABLE -999: - .pushsection .discard.unreachable - .long 999b - . - .popsection -.endm -#else /* CONFIG_STACK_VALIDATION */ -.macro ANNOTATE_UNREACHABLE counter:req -.endm - -.macro ANNOTATE_REACHABLE counter:req -.endm - -.macro ASM_UNREACHABLE -.endm -#endif /* CONFIG_STACK_VALIDATION */ - -#endif /* LINKER_SCRIPT */ -#endif /* __KERNEL__ */ #endif /* __ASSEMBLY__ */ /* Compile time object size, -1 for unknown */ From patchwork Mon Dec 17 16:03:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 154020 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2653904ljp; Mon, 17 Dec 2018 08:22:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/VySjnp0GFbFGyHzo3avjuWaECKlfZ8MMsOcCQ/awnTqMTswRIIQR/BlACUrZteGf0chuvn X-Received: by 2002:a62:7c47:: with SMTP id x68mr13550117pfc.209.1545063746077; Mon, 17 Dec 2018 08:22:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545063746; cv=none; d=google.com; s=arc-20160816; b=va4XowWPrwms+epAMVhoMeQwgbKSmZLf56UZ19vNnkIvsD/veEHZKWOTyBsBNELdVa 5lk6fWkcrbT544n476SV+66VYrw+JhL41PeMqHGG4vFR1pkDIlaKcXttWBHNC8h97etJ 5ON36VFKmqvKLE0UUx30VK3Uclk1Ruz+FU1qy8pn9rZkxGO7ujA8aUsdcylyaaZ48k6P gJt/CFlhI7/MHxz5y4kAkME86ZUfKNsQbQZI2U75VXi2xZidKeRhBfHraVlTaNLW0kHJ QcS+vdZG+G8Plwi1MT1jSAEjdJ8XCTlOB02sHFiy79R4O+1ap/KDyfRzEvNv7tBVqi18 Fp4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=aE8w1NqgjkmgVSBM/qyCPbbjO7TRIj12O6ZaY8+0nvk=; b=t59rfqtMFgwdHpOKJVOVTBZwXWrwlxjJcgj0oTBpLaFKp+dFXVNMT9fVqNsbjRReVy tLgDbFi64cy/AFtPXNh+7+ntjmRLOuD+cKbyXd1jOgOhATivUdqEF97KMqzv/qKEF37A Y2ECdE3lfmOHbrpt1CmvmFVOPPqDILmXabTaa3zK3YHSyjKMc2njS2dj110ahI46gLGm 16Kk8vsO4eQzPhhIQrl0zoz0ksv1JajdE26W2+oL90sMEY/alRKmqO2tO6sg7txd1oil fAJ2PZoQUKmH3LuMjC2Nzc0lfKPs1F00SekIJT0iQfWUWtqfVvytLYypIsskm5Z0UAYF 2yxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=FVMM3bva; 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 w12si10676987pgl.122.2018.12.17.08.22.25; Mon, 17 Dec 2018 08:22:26 -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=@nifty.com header.s=dec2015msa header.b=FVMM3bva; 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 S2388164AbeLQQWY (ORCPT + 31 others); Mon, 17 Dec 2018 11:22:24 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:28169 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726657AbeLQQWX (ORCPT ); Mon, 17 Dec 2018 11:22:23 -0500 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-07.nifty.com with ESMTP id wBHG3bRm008119; Tue, 18 Dec 2018 01:03:52 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com wBHG3bRm008119 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1545062633; bh=aE8w1NqgjkmgVSBM/qyCPbbjO7TRIj12O6ZaY8+0nvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FVMM3bvablEfwC9sMJh0fK94pVwA5UoONl7LYqmkjBBy6mBnYx4klFaiV7vgKjIw5 H7QP+rNCMFJmeTQlyhy1irDQ223b0QdzkxusGECKA3izCOAvT9eXo4M4wioFAzeG5L HUh3fDSf1PJ+FBkiYBEDWIEjSFFNiMH+y32WUiSmx2nx/pJqGJMNUCsVduWRMUBOmr 72tr/dNyUEycSwFFBJKPqijE0dd0c83ofWnv89dJ1E2N4p4Fi1/5NBTHusapt0OBX0 Cn8jS010tzWT4wBiF8pVMbtQ6zLXS/21m1XMYOCLtMLg3ZeBnzYgUyCwmGma0eeKPZ f4zPjvk9n8O3Q== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" Cc: Richard Biener , Segher Boessenkool , Peter Zijlstra , Juergen Gross , Josh Poimboeuf , Kees Cook , Linus Torvalds , Masahiro Yamada , Logan Gunthorpe , Nadav Amit , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Michal Marek Subject: [PATCH v3 09/12] Revert "kbuild/Makefile: Prepare for using macros in inline assembly code to work around asm() related GCC inlining bugs" Date: Tue, 18 Dec 2018 01:03:24 +0900 Message-Id: <1545062607-8599-10-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> References: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This reverts commit 77b0bf55bc675233d22cd5df97605d516d64525e. A few days after the patch set applied, discussion started to solve the issue more elegantly with the help of compiler: https://lkml.org/lkml/2018/10/7/92 The new syntax "asm inline" was implemented by Segher Boessenkool, and now queued up for GCC 9. (People were positive even for back-porting it to older compilers). Since the in-kernel workarounds merged, some issues have been reported. The current urgent issue is distro packages for module building. More fundamentally, we cannot build external modules after 'make clean' because *.s files are globally removed. We could fix those in Makefiles, but I do not want to mess up the build system any more. Given that this issue will be solved in a cleaner way sooner or later, let's revert the in-kernel workarounds, and wait for GCC 9. Link: https://lkml.org/lkml/2018/11/15/467 Link: https://marc.info/?t=154212770600037&r=1&w=2 Reported-by: Sedat Dilek # deb/rpm package Signed-off-by: Masahiro Yamada Cc: Logan Gunthorpe Cc: Nadav Amit Cc: Segher Boessenkool --- Makefile | 9 ++------- arch/x86/Makefile | 7 ------- arch/x86/kernel/macros.S | 7 ------- scripts/Kbuild.include | 4 +--- scripts/mod/Makefile | 2 -- 5 files changed, 3 insertions(+), 26 deletions(-) delete mode 100644 arch/x86/kernel/macros.S -- 2.7.4 diff --git a/Makefile b/Makefile index 56d5270..885c74b 100644 --- a/Makefile +++ b/Makefile @@ -1081,7 +1081,7 @@ scripts: scripts_basic scripts_dtc asm-generic gcc-plugins $(autoksyms_h) # version.h and scripts_basic is processed / created. # Listed in dependency order -PHONY += prepare archprepare macroprepare prepare0 prepare1 prepare2 prepare3 +PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3 # prepare3 is used to check if we are building in a separate output directory, # and if so do: @@ -1104,9 +1104,7 @@ prepare2: prepare3 outputmakefile asm-generic prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h $(cmd_crmodverdir) -macroprepare: prepare1 archmacros - -archprepare: archheaders archscripts macroprepare scripts_basic +archprepare: archheaders archscripts prepare1 scripts_basic prepare0: archprepare gcc-plugins $(Q)$(MAKE) $(build)=. @@ -1174,9 +1172,6 @@ archheaders: PHONY += archscripts archscripts: -PHONY += archmacros -archmacros: - PHONY += __headers __headers: $(version_h) scripts_basic uapi-asm-generic archheaders archscripts $(Q)$(MAKE) $(build)=scripts build_unifdef diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 75ef499..85a66c4 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -232,13 +232,6 @@ archscripts: scripts_basic archheaders: $(Q)$(MAKE) $(build)=arch/x86/entry/syscalls all -archmacros: - $(Q)$(MAKE) $(build)=arch/x86/kernel arch/x86/kernel/macros.s - -ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s -export ASM_MACRO_FLAGS -KBUILD_CFLAGS += $(ASM_MACRO_FLAGS) - ### # Kernel objects diff --git a/arch/x86/kernel/macros.S b/arch/x86/kernel/macros.S deleted file mode 100644 index cfc1c7d..0000000 --- a/arch/x86/kernel/macros.S +++ /dev/null @@ -1,7 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ - -/* - * This file includes headers whose assembly part includes macros which are - * commonly used. The macros are precompiled into assmebly file which is later - * assembled together with each compiled file. - */ diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index bb01555..3d09844 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -115,9 +115,7 @@ __cc-option = $(call try-run,\ # Do not attempt to build with gcc plugins during cc-option tests. # (And this uses delayed resolution so the flags will be up to date.) -# In addition, do not include the asm macros which are built later. -CC_OPTION_FILTERED = $(GCC_PLUGINS_CFLAGS) $(ASM_MACRO_FLAGS) -CC_OPTION_CFLAGS = $(filter-out $(CC_OPTION_FILTERED),$(KBUILD_CFLAGS)) +CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) # cc-option # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile index a5b4af4..42c5d50 100644 --- a/scripts/mod/Makefile +++ b/scripts/mod/Makefile @@ -4,8 +4,6 @@ OBJECT_FILES_NON_STANDARD := y hostprogs-y := modpost mk_elfconfig always := $(hostprogs-y) empty.o -CFLAGS_REMOVE_empty.o := $(ASM_MACRO_FLAGS) - modpost-objs := modpost.o file2alias.o sumversion.o devicetable-offsets-file := devicetable-offsets.h From patchwork Mon Dec 17 16:03:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 154010 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2639949ljp; Mon, 17 Dec 2018 08:10:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/V16Eja0iFBhalg1tzt4ekcHfgcG/Hv5ru8KWe5AitTN34DPbmOrevY5VHo507VX8heW2Xl X-Received: by 2002:a62:5884:: with SMTP id m126mr13302413pfb.177.1545063056513; Mon, 17 Dec 2018 08:10:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545063056; cv=none; d=google.com; s=arc-20160816; b=XnVM9aJqwurjPPOoWOVgQDnWUOqNoNOb9dKBmu0CYfEKqpkO2PH3XLPL+u1HBQDQd0 jW3hIFOnlZtmMk7T3YuDQ+iFnRlKR9n9ghYkrcnQfpYKXkZ7KlHdBHv/78v5vMFdB+N/ TrIhrQ7ij7dBlghqMPQozJtG6785wmpfHiSieyKRfn0/KWph+f9eYLFd11fzWCYPE/yW 8m+2knAuvhBUXIqJ56+5xhIwNDsN5mVUyjfV/enDkW48pWkDJa4B12qp5eNNI26ysTA/ QgUoM0YgqwwvlKMO3F+wNoxyO8RFIftQ5oam+EJ74B/bYmDO9l6+9JIDLX9I1VhJcq5W S75g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=o/MEbJ3S1hhfmW2hGhchL96p7dT26gkeOJCbbt7ujYI=; b=nc37JK+jcYdKTNEm/9i7lXLvnysVlOuCzXPwffxwYUq01QMJ47jRa87WHCmjKw4bu7 va+gNSxlxKUuJMH6DoGPc4+nkHlhYNgSHTLJhlFW6QFMTBKrrbPMu+Su6YoM2Ai1LYNN k4PplzkZW4H+BbSoN8LPfx2a2L8mSRjrp3YqV+dYTN6BlJpefSGBSAqudcKKiSzVY2rs SDiokz9BLQ2kVg0YPM3mTsJj70kXlXa7wJDyucJ+XX5cYs2CMJOqH9LHEreC0J3mj8Cl GptoV1naQxQ5N+VIQBxswfe4MAZJBL3MYi8+65ubdqpGpC7vR1i3m303T745exHm7NXU 5hzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Eu9BMTHW; 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 36si11346047pgt.213.2018.12.17.08.10.55; Mon, 17 Dec 2018 08:10:56 -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=@nifty.com header.s=dec2015msa header.b=Eu9BMTHW; 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 S2388129AbeLQQKx (ORCPT + 31 others); Mon, 17 Dec 2018 11:10:53 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:64868 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387635AbeLQQKx (ORCPT ); Mon, 17 Dec 2018 11:10:53 -0500 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-07.nifty.com with ESMTP id wBHG3bRn008119; Tue, 18 Dec 2018 01:03:53 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com wBHG3bRn008119 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1545062634; bh=o/MEbJ3S1hhfmW2hGhchL96p7dT26gkeOJCbbt7ujYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Eu9BMTHWNTBFYlbJ5nxhDX/xlXN7gxMGDpvSFqfP9NsumwKw7Yu0/dNS1ahhxe2Up WGnthgiNa/dtN5WRTRgudM3l3m5zOok6fPxUX7znA4wSc1Vouu0rolq2Sw+e04JRYF Ht0zfpHHbtoij48qC16YZZwhlZAcBkDO83lVya+1eibEUfXgPhwwfEpMRwxuPxPsW/ nxRKhvZyBl8j54qtpQCYCpVSaODEY8L9nkIU0YF4jz7isFdTAhmlqMKMJEPbjN4fr/ h0ibKG7JxoxJtxvuWGdoLoE3cmHjTK6q64ds2WB94zH9Ud5XaVVSXKnY2xBxdUOtg4 c6Z/iCL7IKOXQ== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" Cc: Richard Biener , Segher Boessenkool , Peter Zijlstra , Juergen Gross , Josh Poimboeuf , Kees Cook , Linus Torvalds , Masahiro Yamada , Andrey Ryabinin , Andrew Morton , linux-kernel@vger.kernel.org Subject: [PATCH v3 10/12] linux/linkage: add ASM() macro to reduce duplication between C/ASM code Date: Tue, 18 Dec 2018 01:03:25 +0900 Message-Id: <1545062607-8599-11-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> References: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We often duplicate similar assembly code to use it from .c and .S files. The difference is mostly the presence of double quotes. So, here is a new macro ASM(). (We have similar approach for __ASM_FORM(), etc.) The usage is like this: #define MY_CODE \ ASM( .section ".text" )\ ASM( movl $1, %eax ) In C context, the preprocessor expands it into: ".section \".text\"" "\n\t" "movl $1, %eax" "\n\t" This is perfect for the use from the inline asm(...) in .c files. In assembly context, the preprocessor expands it into: .section ".text" ; movl $1, %eax ; This is fine for the use in .S files. I used double-expansion like __stringify() so that we can use macros in ASM(...). Signed-off-by: Masahiro Yamada --- include/linux/linkage.h | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.7.4 diff --git a/include/linux/linkage.h b/include/linux/linkage.h index 7c47b1a..80faeae 100644 --- a/include/linux/linkage.h +++ b/include/linux/linkage.h @@ -12,6 +12,14 @@ #define ASM_NL ; #endif +#ifdef __ASSEMBLY__ +#define _ASM(x...) x ASM_NL +#else +#define _ASM(x...) #x __stringify(\n\t) +#endif +/* Doing two levels allows macros to be used in ASM(...) */ +#define ASM(x...) _ASM(x) + #ifdef __cplusplus #define CPP_ASMLINKAGE extern "C" #else From patchwork Mon Dec 17 16:03:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 154016 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2640580ljp; Mon, 17 Dec 2018 08:11:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/WWlr7AqVQeVuUaUS6jo+IkEaqWUG32dtzMx1VygPaig6lSAHd0uLdN+kZymErfNIRVT3dl X-Received: by 2002:a63:f658:: with SMTP id u24mr12700490pgj.267.1545063087926; Mon, 17 Dec 2018 08:11:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545063087; cv=none; d=google.com; s=arc-20160816; b=ZGM4bmU3Qvv37orjGbTl7XCnOp6sxHRd50UQPVN67mGcL966cRzVnDBhzX9X9adGY3 57HhaIJ4eHgibHWEG0z0D/nI18SdBxKUSSBlL8iCIsuExv1JO9nXYcXYy/+xr8bGeBKi uhqImpart/rXSyxzuiIJmN8lRWJga6NVGNqszZYJUdWMtWaCPbY+2jayKzrFeB/h43Ex LnvhBKIF63BGHYxMWqtdzukqBvhQjRMcit/1C+7ynbOL3f0myxSvj+S0+/fY0/K76UUb JrLgVy01ifRnwPot0ggCGVpRKg10izAvRy0DToI06nPP6oOKS8Yxsd7IB8sLGEdE3W5W 67oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=9DcjqEmtpr1b4GO1cESJaDoe5JvvAOWZuwQM0QNgknw=; b=ij/rQd/SaDk9aiFx1F4p+3hYdYDD5hQXhb6dE4feSu/kwwpkKdFcVoKdXe6UbjaCnN J2cOFQG77WdItH8+Y2nGo62VBIRHuiPMj8+oBtJw6b1rSAuzt/Gj27HkumEwndN2ReGX asV59NM4QgQm9wlFO68ikvbPxXZm+hwXvKtl3Q0Kni7pSiLGL9v5J8nXMd2xLZk+K+Jy +UVUJonAVzm/BLzNwBE+gvfAA0CmSp2W/p69cNCAVo/1xSQD08TphN4hZBGWJRwcJDGH PCpiYCuSis8Iu74f8IF8eIsXtiWn6iBuS2asRT7hodNSh0YGPc5V0okVd6bQBwDPU+zx VW1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=UvhPspAD; 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 j132si7406217pfc.84.2018.12.17.08.11.27; Mon, 17 Dec 2018 08:11:27 -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=@nifty.com header.s=dec2015msa header.b=UvhPspAD; 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 S2388248AbeLQQLQ (ORCPT + 31 others); Mon, 17 Dec 2018 11:11:16 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:65246 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726548AbeLQQLP (ORCPT ); Mon, 17 Dec 2018 11:11:15 -0500 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-07.nifty.com with ESMTP id wBHG3bRo008119; Tue, 18 Dec 2018 01:03:55 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com wBHG3bRo008119 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1545062636; bh=9DcjqEmtpr1b4GO1cESJaDoe5JvvAOWZuwQM0QNgknw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UvhPspADlIzQrlh8fdDk3sHogE5Obsyfz5Xbk6iOPgw/3syRRNOCSUp+v19VRTYbF yv/kVKF3IUHFyNSDOJ2xSs0KWaU86eCCvr9CUYCBIvSyZzcF07hd1ucJYyYC398Cl1 1M9DVQPruecUvJvSJIn8udJzLRdtGxg8EG0fIBE+Ky5ycLNf6RZjzyjnk3Ffiih7B4 q3o8TRd+iEt8z8ioUyvkYjcykB12cGBUmCm/rVQQOHu9aUZzjJ2QeFJd524UPuUpCK LGSOU7Ya1VNHFcC0MRO5ecxjDetrFNH28Hkz3ZqrNXeJNrttOAPKI65WljADIlgOc0 7QehQi0VxnvoQ== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" Cc: Richard Biener , Segher Boessenkool , Peter Zijlstra , Juergen Gross , Josh Poimboeuf , Kees Cook , Linus Torvalds , Masahiro Yamada , David Woodhouse , linux-kernel@vger.kernel.org, Alexey Dobriyan , Nadav Amit Subject: [PATCH v3 11/12] x86/alternatives: consolidate LOCK_PREFIX macro Date: Tue, 18 Dec 2018 01:03:26 +0900 Message-Id: <1545062607-8599-12-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> References: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The LOCK_PREFIX is mostly used in inline asm, but also used by atomic64_cx8_32.S Let's unify the definition by using ASM() macro. This was previously cleaned up by 77f48ec28e4c ("x86/alternatives: Macrofy lock prefixes to work around GCC inlining bugs"). Now, I am refactoring the code without using the macros approach. The new header contains macros that can be used by C and assembly. Signed-off-by: Masahiro Yamada --- arch/x86/include/asm/alternative-asm.h | 14 +-------- arch/x86/include/asm/alternative-common.h | 47 +++++++++++++++++++++++++++++++ arch/x86/include/asm/alternative.h | 37 +----------------------- 3 files changed, 49 insertions(+), 49 deletions(-) create mode 100644 arch/x86/include/asm/alternative-common.h -- 2.7.4 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h index 31b627b..7425514 100644 --- a/arch/x86/include/asm/alternative-asm.h +++ b/arch/x86/include/asm/alternative-asm.h @@ -4,21 +4,9 @@ #ifdef __ASSEMBLY__ +#include #include -#ifdef CONFIG_SMP - .macro LOCK_PREFIX -672: lock - .pushsection .smp_locks,"a" - .balign 4 - .long 672b - . - .popsection - .endm -#else - .macro LOCK_PREFIX - .endm -#endif - /* * Issue one struct alt_instr descriptor entry (need to put it into * the section .altinstructions, see below). This entry contains diff --git a/arch/x86/include/asm/alternative-common.h b/arch/x86/include/asm/alternative-common.h new file mode 100644 index 0000000..ae0b58f --- /dev/null +++ b/arch/x86/include/asm/alternative-common.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_ALTERNATIVE_COMMON_H +#define _ASM_X86_ALTERNATIVE_COMMON_H + +#include + +/* + * Alternative inline assembly for SMP. + * + * The LOCK_PREFIX macro defined here replaces the LOCK and + * LOCK_PREFIX macros used everywhere in the source tree. + * + * SMP alternatives use the same data structures as the other + * alternatives and the X86_FEATURE_UP flag to indicate the case of a + * UP system running a SMP kernel. The existing apply_alternatives() + * works fine for patching a SMP kernel for UP. + * + * The SMP alternative tables can be kept after boot and contain both + * UP and SMP versions of the instructions to allow switching back to + * SMP at runtime, when hotplugging in a new CPU, which is especially + * useful in virtualized environments. + * + * The very common lock prefix is handled as special case in a + * separate table which is a pure address list without replacement ptr + * and size information. That keeps the table sizes small. + */ + +#include +#include + +#ifdef CONFIG_SMP + +#define LOCK_PREFIX_HERE \ +ASM( .pushsection .smp_locks,"a" )\ +ASM( .balign 4 )\ +ASM( .long 671f - . )\ +ASM( .popsection )\ +ASM( 671: ) + +#define LOCK_PREFIX LOCK_PREFIX_HERE ASM(lock) + +#else /* ! CONFIG_SMP */ +#define LOCK_PREFIX_HERE ASM() +#define LOCK_PREFIX ASM() +#endif + +#endif /* _ASM_X86_ALTERNATIVE_COMMON_H */ diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 4cd6a3b..157967c 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -7,44 +7,9 @@ #include #include #include +#include #include -/* - * Alternative inline assembly for SMP. - * - * The LOCK_PREFIX macro defined here replaces the LOCK and - * LOCK_PREFIX macros used everywhere in the source tree. - * - * SMP alternatives use the same data structures as the other - * alternatives and the X86_FEATURE_UP flag to indicate the case of a - * UP system running a SMP kernel. The existing apply_alternatives() - * works fine for patching a SMP kernel for UP. - * - * The SMP alternative tables can be kept after boot and contain both - * UP and SMP versions of the instructions to allow switching back to - * SMP at runtime, when hotplugging in a new CPU, which is especially - * useful in virtualized environments. - * - * The very common lock prefix is handled as special case in a - * separate table which is a pure address list without replacement ptr - * and size information. That keeps the table sizes small. - */ - -#ifdef CONFIG_SMP -#define LOCK_PREFIX_HERE \ - ".pushsection .smp_locks,\"a\"\n" \ - ".balign 4\n" \ - ".long 671f - .\n" /* offset */ \ - ".popsection\n" \ - "671:" - -#define LOCK_PREFIX LOCK_PREFIX_HERE "\n\tlock; " - -#else /* ! CONFIG_SMP */ -#define LOCK_PREFIX_HERE "" -#define LOCK_PREFIX "" -#endif - struct alt_instr { s32 instr_offset; /* original instruction */ s32 repl_offset; /* offset to replacement instruction */ From patchwork Mon Dec 17 16:03:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 154008 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2636414ljp; Mon, 17 Dec 2018 08:08:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/UXa5y5LUrMp6fo50XcXQXSvNOw6/XBBmBIt5tnmSxPX5c74oMeOGITJBEAQcEoRClAK4ti X-Received: by 2002:a63:9402:: with SMTP id m2mr12166256pge.93.1545062886933; Mon, 17 Dec 2018 08:08:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545062886; cv=none; d=google.com; s=arc-20160816; b=WzCMrm9xUqvQi5ZPcBLiURg373GE+09hIccI8N6FOh6jIlWstleMfOipxnaWRpkA9C xCAs2hvtE4zrhVGjr7ilyGXOe10mFPUdkuWpKWQ8BOKqjkY1ZJQkojUmU6KW0NPMQ1VO 1PIijYTyH0GFW0g53NCD/Py089Y9l0vLw+/mA3apYM3oqVH+xBVey01AE+nFd7OGWe/w BUuQqzEgljD73mc9Y/veFeR9l8MdNoIu8J2Mcki0tho+6GqiWnIpzjAgr+vB3JtcF6QQ QwAUrBdBSZN5h4VM4ixVNnD9uj4BUcgKSCB71X7Sgpcy3ULOqHRNObKAoFKNmG/DnWN+ Tx6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=x/KQxi9+ntHpo7b3spoLqqCNx8iz55GVWCoL7isyaps=; b=TGgfVzasXXzFFEP0bWoSDberQGTT3equxR12oXJ+XVjp2EVhf6hQfj5WLtRHuOm2dm C7at4W8nruayVfQfXRzZs/y8C20uXAGsl3/9TCSmF2suHJJ9OgwcD5Z9HalC93Qfp9tc hbbfKjI+wtxiaZzVDgWs97xDqzM1RAJARd6IfuIarp7i2INI90AZxMKOlWqZ9stMAwNy s7ITD5sAK3hKrPkLKhOlp3RT+mlkXE3R5aT3pGD0YsJ7OxaXc3Qe/5BiS2FFdxaX32uf GzVdUVirLW/qNlDqLWE3ovBwhFVIfrQUP2eQ4epQtZkrW+oXAUCQBnXVb40bKldAulfq hyDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=IZLqzfz7; 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 m19si10320539pls.437.2018.12.17.08.08.06; Mon, 17 Dec 2018 08:08:06 -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=@nifty.com header.s=dec2015msa header.b=IZLqzfz7; 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 S2388182AbeLQQIE (ORCPT + 31 others); Mon, 17 Dec 2018 11:08:04 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:61874 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbeLQQID (ORCPT ); Mon, 17 Dec 2018 11:08:03 -0500 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-07.nifty.com with ESMTP id wBHG3bRp008119; Tue, 18 Dec 2018 01:03:56 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com wBHG3bRp008119 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1545062637; bh=x/KQxi9+ntHpo7b3spoLqqCNx8iz55GVWCoL7isyaps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IZLqzfz7V0GW9pfJ5UnzRYH8Xk/+//PqcZXdl7IFAO+xhowqoQQGUH3nxlo6GDcBQ xne7Xpw0Zb+6d6K2pN4rQYZGc3b+FuATeCqlSw5BZ7QHitzhJkm5Uyjtnzps+LEyW+ 2RU62YXl9cXOK6ifslTv8DxzXKYtldWP4jTfkH5oYXkGkhnq9bMqLdtsSk4XW6k4Pu GBsULmDgm0qBYydXoAXR5h6e8M2aoNKxJIfXzKp8YSpxlsb5o0w/UFdxyQeX9H1Ics Nb+byTkTF08h80ANnleavUGFJPk8ekzh+WYVCWmfggwq2OBk7elg/+ZQSIl03miSbQ jKOu+gRqiOWDw== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" Cc: Richard Biener , Segher Boessenkool , Peter Zijlstra , Juergen Gross , Josh Poimboeuf , Kees Cook , Linus Torvalds , Masahiro Yamada , linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Nadav Amit , Jann Horn Subject: [PATCH v3 12/12] x86/asm: consolidate ASM_EXTABLE_* macros Date: Tue, 18 Dec 2018 01:03:27 +0900 Message-Id: <1545062607-8599-13-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> References: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org These macros are used by .c and .S files. Let's unify the definition by using ASM() macro. This was previously cleaned up by 0474d5d9d2f7 ("x86/extable: Macrofy inline assembly code to work around GCC inlining bugs"). Now, I am refactoring the code without using the macros approach. Signed-off-by: Masahiro Yamada --- arch/x86/include/asm/asm.h | 57 ++++++++++++---------------------------------- 1 file changed, 15 insertions(+), 42 deletions(-) -- 2.7.4 diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h index 6467757b..cff3b0a 100644 --- a/arch/x86/include/asm/asm.h +++ b/arch/x86/include/asm/asm.h @@ -118,36 +118,36 @@ #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 - -# define _ASM_EXTABLE(from, to) \ +#define _ASM_EXTABLE_HANDLE(from, to, handler) \ +ASM( .pushsection "__ex_table","a" ; )\ +ASM( .balign 4 ; )\ +ASM( .long (from) - . ; )\ +ASM( .long (to) - . ; )\ +ASM( .long (handler) - . ; )\ +ASM( .popsection ) + +#define _ASM_EXTABLE(from, to) \ _ASM_EXTABLE_HANDLE(from, to, ex_handler_default) -# define _ASM_EXTABLE_UA(from, to) \ +#define _ASM_EXTABLE_UA(from, to) \ _ASM_EXTABLE_HANDLE(from, to, ex_handler_uaccess) -# 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) -# define _ASM_NOKPROBE(entry) \ +#define _ASM_NOKPROBE(entry) \ .pushsection "_kprobe_blacklist","aw" ; \ _ASM_ALIGN ; \ _ASM_PTR (entry); \ .popsection +#ifdef __ASSEMBLY__ .macro ALIGN_DESTINATION /* check for bad alignment of destination */ movl %edi,%ecx @@ -173,34 +173,7 @@ .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_UA(from, to) \ - _ASM_EXTABLE_HANDLE(from, to, ex_handler_uaccess) - -# 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__ /* * This output constraint should be used for any inline asm which has a "call" * instruction. Otherwise the asm may be inserted before the frame pointer