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