Received: by 10.223.185.116 with SMTP id b49csp468399wrg; Tue, 20 Feb 2018 02:28:33 -0800 (PST) X-Google-Smtp-Source: AH8x224x/LXz15QpfmiwUjUVwL6iHOb5wcqu6tQwjo55sOEEiySYCDoiQBTCl8Ix06t7CSP7s0ss X-Received: by 2002:a17:902:22e:: with SMTP id 43-v6mr17169578plc.384.1519122513759; Tue, 20 Feb 2018 02:28:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519122513; cv=none; d=google.com; s=arc-20160816; b=dP0Zwirmf6bSsNb2AJmJ362+UTlU5nyuMQxL9kyiLjNx2EZwka0Z21B/tLBgu/2pXb U1dSqTyYu31qfNO4hGaydF3HRFqOc1aFMuO49eY78EFF7RfV2AXszjCaiTrAO002ZEHm Yq2HOZTKmwYWGv0Yweix2MRgAdLk6wSDPZANtUBnaVdsw2HH+xoKvJT3mLBtfd5xgEJE I/RDjDm2/PCwqJXu8k50AV5qX9dTuGD4JsIghwhKsvm8E/lIooqLf6U31Oi1r/wfRqZM htJW3TIiOVOmbTP6JJvsct0xRiacP+oC5Hdz43OHNBiXoShCKSyeFTL9Vmhd5F+24t/8 kcVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=xpmiRCkrwE6N1lOe5l5L3miT2QhKbHlEDbjnkZ/Gq+I=; b=Z9LhFtxJSUMak6VUfXj5WuA8IYsC0SIeTW8+KU3sf38khcdf0YqoiNE+J+jsoahiIW U4Yui+unRfzIA08vVEGhCS/7PAq64PoMrsX0gJ1qGKmVV6AKj/L6Xf87D1K5PfBox2kS 9S5PldTDoCFBo7pm3QR+SM5hnaUPh3qVNTPcl5Wkdmqr5/cSGtgnc88rMoYxfz9HWVEf HADV0BlFnCZdS2lHHXJ/8zGePzieh4sDHVs7dWzpQWCr1V+n6tU4UScu2Q7JWDT4etKl Q5/toy1baK/Cjc0YxXRt60S9At59KR2avBFjGA803L7yZNEo0i0lxUoku/2PclIY7jna glxg== 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 6si7940722pgf.474.2018.02.20.02.28.18; Tue, 20 Feb 2018 02:28:33 -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; 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 S1751506AbeBTK1Q (ORCPT + 99 others); Tue, 20 Feb 2018 05:27:16 -0500 Received: from terminus.zytor.com ([198.137.202.136]:53315 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751052AbeBTK1O (ORCPT ); Tue, 20 Feb 2018 05:27:14 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w1KAQaMj019860; Tue, 20 Feb 2018 02:26:36 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w1KAQZCN019857; Tue, 20 Feb 2018 02:26:35 -0800 Date: Tue, 20 Feb 2018 02:26:35 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Jan Beulich Message-ID: Cc: dvlasenk@redhat.com, keescook@chromium.org, torvalds@linux-foundation.org, peterz@infradead.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, bp@alien8.de, jpoimboe@redhat.com, brgerst@gmail.com, luto@kernel.org, jbeulich@suse.com, hpa@zytor.com, mingo@kernel.org, JBeulich@suse.com Reply-To: mingo@kernel.org, jbeulich@suse.com, hpa@zytor.com, JBeulich@suse.com, luto@kernel.org, brgerst@gmail.com, bp@alien8.de, linux-kernel@vger.kernel.org, jpoimboe@redhat.com, dvlasenk@redhat.com, keescook@chromium.org, tglx@linutronix.de, peterz@infradead.org, torvalds@linux-foundation.org In-Reply-To: <5A8AF1F802000078001A91E1@prv-mh.provo.novell.com> References: <5A8AF1F802000078001A91E1@prv-mh.provo.novell.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/pti] x86/asm: Improve how GEN_*_SUFFIXED_RMWcc() specify clobbers Git-Commit-ID: 700b7c5409c3e9da279fbea78cf28a78fbc176cd X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 700b7c5409c3e9da279fbea78cf28a78fbc176cd Gitweb: https://git.kernel.org/tip/700b7c5409c3e9da279fbea78cf28a78fbc176cd Author: Jan Beulich AuthorDate: Mon, 19 Feb 2018 07:49:12 -0700 Committer: Ingo Molnar CommitDate: Tue, 20 Feb 2018 09:33:39 +0100 x86/asm: Improve how GEN_*_SUFFIXED_RMWcc() specify clobbers Commit: df3405245a ("x86/asm: Add suffix macro for GEN_*_RMWcc()") ... introduced "suffix" RMWcc operations, adding bogus clobber specifiers: For one, on x86 there's no point explicitly clobbering "cc". In fact, with GCC properly fixed, this results in an overlap being detected by the compiler between outputs and clobbers. Furthermore it seems bad practice to me to have clobber specification and use of the clobbered register(s) disconnected - it should rather be at the invocation place of that GEN_{UN,BIN}ARY_SUFFIXED_RMWcc() macros that the clobber is specified which this particular invocation needs. Drop the "cc" clobber altogether and move the "cx" one to refcount.h. Signed-off-by: Jan Beulich Acked-by: Thomas Gleixner Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Josh Poimboeuf Cc: Kees Cook Cc: Linus Torvalds Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/5A8AF1F802000078001A91E1@prv-mh.provo.novell.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/refcount.h | 4 ++-- arch/x86/include/asm/rmwcc.h | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/x86/include/asm/refcount.h b/arch/x86/include/asm/refcount.h index 4e44250..d651711 100644 --- a/arch/x86/include/asm/refcount.h +++ b/arch/x86/include/asm/refcount.h @@ -67,13 +67,13 @@ static __always_inline __must_check bool refcount_sub_and_test(unsigned int i, refcount_t *r) { GEN_BINARY_SUFFIXED_RMWcc(LOCK_PREFIX "subl", REFCOUNT_CHECK_LT_ZERO, - r->refs.counter, "er", i, "%0", e); + r->refs.counter, "er", i, "%0", e, "cx"); } static __always_inline __must_check bool refcount_dec_and_test(refcount_t *r) { GEN_UNARY_SUFFIXED_RMWcc(LOCK_PREFIX "decl", REFCOUNT_CHECK_LT_ZERO, - r->refs.counter, "%0", e); + r->refs.counter, "%0", e, "cx"); } static __always_inline __must_check diff --git a/arch/x86/include/asm/rmwcc.h b/arch/x86/include/asm/rmwcc.h index f91c365..4914a3e 100644 --- a/arch/x86/include/asm/rmwcc.h +++ b/arch/x86/include/asm/rmwcc.h @@ -2,8 +2,7 @@ #ifndef _ASM_X86_RMWcc #define _ASM_X86_RMWcc -#define __CLOBBERS_MEM "memory" -#define __CLOBBERS_MEM_CC_CX "memory", "cc", "cx" +#define __CLOBBERS_MEM(clb...) "memory", ## clb #if !defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(CC_HAVE_ASM_GOTO) @@ -40,18 +39,19 @@ do { \ #endif /* defined(__GCC_ASM_FLAG_OUTPUTS__) || !defined(CC_HAVE_ASM_GOTO) */ #define GEN_UNARY_RMWcc(op, var, arg0, cc) \ - __GEN_RMWcc(op " " arg0, var, cc, __CLOBBERS_MEM) + __GEN_RMWcc(op " " arg0, var, cc, __CLOBBERS_MEM()) -#define GEN_UNARY_SUFFIXED_RMWcc(op, suffix, var, arg0, cc) \ +#define GEN_UNARY_SUFFIXED_RMWcc(op, suffix, var, arg0, cc, clobbers...)\ __GEN_RMWcc(op " " arg0 "\n\t" suffix, var, cc, \ - __CLOBBERS_MEM_CC_CX) + __CLOBBERS_MEM(clobbers)) #define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \ __GEN_RMWcc(op __BINARY_RMWcc_ARG arg0, var, cc, \ - __CLOBBERS_MEM, vcon (val)) + __CLOBBERS_MEM(), vcon (val)) -#define GEN_BINARY_SUFFIXED_RMWcc(op, suffix, var, vcon, val, arg0, cc) \ +#define GEN_BINARY_SUFFIXED_RMWcc(op, suffix, var, vcon, val, arg0, cc, \ + clobbers...) \ __GEN_RMWcc(op __BINARY_RMWcc_ARG arg0 "\n\t" suffix, var, cc, \ - __CLOBBERS_MEM_CC_CX, vcon (val)) + __CLOBBERS_MEM(clobbers), vcon (val)) #endif /* _ASM_X86_RMWcc */