Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2044032imm; Mon, 16 Jul 2018 00:47:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpct316sSffbmDJaGJIWT01ETqAhzf7mlWG2nQwPO7tq0WJhRfH9RKn/TlfkgOd6Fnci3IGk X-Received: by 2002:a62:6a01:: with SMTP id f1-v6mr17103863pfc.156.1531727229892; Mon, 16 Jul 2018 00:47:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531727229; cv=none; d=google.com; s=arc-20160816; b=TBGHr79JkFZ+iwzXStLCoNVhQd3NXbfh7YUOpuAkDHlD2Pgmm5RztuYC1Rz0Ewr2xF ZZhSC6ODst6lmMSBbcQebWJD0YE6BZcZ6BDo0mogsxibfyrvnxY+7uTlzfnFoZg4RMLT y6IWXH/1fTOn/vdUw2Cp3PS6goa6Y6D61A4dbMickkpW0iS7h3V5EfS+BfP9CcejHWor PAlBDt4f0w1Wz5d56NHFkCpY1xnvVChLmbbGoiSFqIYCS4byAqoLfDF2A2luptVQb/z2 ylmeQ4rw3kzPg7wSfUlYnqHeZiwQBZvjwRr/xq5NTsfO6LkJL3RBVZzHqdK1wRYiZjHe wuvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=5Vl8TjY9H6MLin7hv3S7QdbPLUCjUOOdywXIccFaXg0=; b=03Dw+HN36spHhF7GDbB5uzYaWfLnFkashNjbhlrLY1ubzWyc8t09vEVKF7sNOeG7b1 J8qRHA8ZNBQBGoPYelVonSfWODkbkW5L7iMDVUnadQNrGs6RtLIXXLIekO/KFzZmvtun gy9AxkueAooDfHu0wc3nDZlMYIAHJrpDIPiPG5Ch8tly/4ILX1LZFHQFVOTbFovT9lEK vojXDtwh0niXY8h3xPGOiBqf5UAaP6HBcsT9F5acY8GJh+QkMVIryjgkls0LVnxoi+u7 /GCWeuE217RpbzX+F4MWUXcxhmwbX8LVkTuPv3RE2n7/x/rtsJQnvDJWHHBHxT6Ve5VJ pKdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f8-v6si30674230plb.381.2018.07.16.00.46.55; Mon, 16 Jul 2018 00:47:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389712AbeGPIMC (ORCPT + 99 others); Mon, 16 Jul 2018 04:12:02 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50972 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388975AbeGPIMB (ORCPT ); Mon, 16 Jul 2018 04:12:01 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3C42ECEA; Mon, 16 Jul 2018 07:45:44 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "H. Peter Anvin" , Borislav Petkov , Andy Lutomirski , Borislav Petkov , Brian Gerst , Denys Vlasenko , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , "Srivatsa S. Bhat" , "Matt Helsley (VMware)" , Alexey Makhalov , Bo Gan Subject: [PATCH 4.4 24/43] x86/cpufeature: Get rid of the non-asm goto variant Date: Mon, 16 Jul 2018 09:36:29 +0200 Message-Id: <20180716073514.490563926@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180716073511.796555857@linuxfoundation.org> References: <20180716073511.796555857@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Borislav Petkov commit a362bf9f5e7dd659b96d01382da7b855f4e5a7a1 upstream I can simply quote hpa from the mail: "Get rid of the non-asm goto variant and just fall back to dynamic if asm goto is unavailable. It doesn't make any sense, really, if it is supposed to be safe, and by now the asm goto-capable gcc is in more wide use. (Originally the gcc 3.x fallback to pure dynamic didn't exist, either.)" Booy, am I lazy. Cleanup the whole CC_HAVE_ASM_GOTO ifdeffery too, while at it. Suggested-by: H. Peter Anvin Signed-off-by: Borislav Petkov Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20160127084325.GB30712@pd.tnic Signed-off-by: Ingo Molnar Signed-off-by: Srivatsa S. Bhat Reviewed-by: Matt Helsley (VMware) Reviewed-by: Alexey Makhalov Reviewed-by: Bo Gan Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/cpufeature.h | 49 +++----------------------------------- 1 file changed, 5 insertions(+), 44 deletions(-) --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -131,17 +131,16 @@ extern const char * const x86_bug_flags[ * fast paths and boot_cpu_has() otherwise! */ -#if __GNUC__ >= 4 && defined(CONFIG_X86_FAST_FEATURE_TESTS) +#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_X86_FAST_FEATURE_TESTS) extern bool __static_cpu_has(u16 bit); /* * Static testing of CPU features. Used the same as boot_cpu_has(). - * These are only valid after alternatives have run, but will statically - * patch the target code for additional performance. + * These will statically patch the target code for additional + * performance. */ static __always_inline __pure bool _static_cpu_has(u16 bit) { -#ifdef CC_HAVE_ASM_GOTO asm_volatile_goto("1: jmp %l[t_dynamic]\n" "2:\n" ".skip -(((5f-4f) - (2b-1b)) > 0) * " @@ -174,45 +173,6 @@ static __always_inline __pure bool _stat return false; t_dynamic: return __static_cpu_has(bit); -#else - u8 flag; - /* Open-coded due to __stringify() in ALTERNATIVE() */ - asm volatile("1: movb $2,%0\n" - "2:\n" - ".section .altinstructions,\"a\"\n" - " .long 1b - .\n" /* src offset */ - " .long 3f - .\n" /* repl offset */ - " .word %P2\n" /* always replace */ - " .byte 2b - 1b\n" /* source len */ - " .byte 4f - 3f\n" /* replacement len */ - " .byte 0\n" /* pad len */ - ".previous\n" - ".section .discard,\"aw\",@progbits\n" - " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */ - ".previous\n" - ".section .altinstr_replacement,\"ax\"\n" - "3: movb $0,%0\n" - "4:\n" - ".previous\n" - ".section .altinstructions,\"a\"\n" - " .long 1b - .\n" /* src offset */ - " .long 5f - .\n" /* repl offset */ - " .word %P1\n" /* feature bit */ - " .byte 4b - 3b\n" /* src len */ - " .byte 6f - 5f\n" /* repl len */ - " .byte 0\n" /* pad len */ - ".previous\n" - ".section .discard,\"aw\",@progbits\n" - " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */ - ".previous\n" - ".section .altinstr_replacement,\"ax\"\n" - "5: movb $1,%0\n" - "6:\n" - ".previous\n" - : "=qm" (flag) - : "i" (bit), "i" (X86_FEATURE_ALWAYS)); - return (flag == 2 ? __static_cpu_has(bit) : flag); -#endif /* CC_HAVE_ASM_GOTO */ } #define static_cpu_has(bit) \ @@ -223,7 +183,8 @@ static __always_inline __pure bool _stat ) #else /* - * gcc 3.x is too stupid to do the static test; fall back to dynamic. + * Fall back to dynamic for gcc versions which don't support asm goto. Should be + * a minority now anyway. */ #define static_cpu_has(bit) boot_cpu_has(bit) #endif