Received: by 10.223.185.116 with SMTP id b49csp3836113wrg; Mon, 19 Feb 2018 06:50:13 -0800 (PST) X-Google-Smtp-Source: AH8x224IML1Fd0J2rk19H6ncDhtOiYaVUzXt4a96PC/V7P1y0laWu/wozUSXUnWKt3kR+Q+rRCmb X-Received: by 10.167.130.12 with SMTP id k12mr14944431pfi.73.1519051813001; Mon, 19 Feb 2018 06:50:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519051812; cv=none; d=google.com; s=arc-20160816; b=0tXsik7BQPHGf899y4hg+lq0kzgS36YbBKIdIWFVxHTsXY91YhLfsPpkyIeOPehG6N AwIUzIQTIPupr7ZzDWehCH+LA6VSc9yE2hPnoL5Nv4plFf8PQK526TxpTQ28Bt3ZttjI 1nS6tGs5dS38K97qTckBBgiUBK274TLHeaT9F7RsVqeqAEF0MMmU9ceuki7jcFMGzm+i yi5e0OEwBLLKnnwD2p4w8dTkwXKYwHW3/7Kdmt/XN/UZpTUS/oibcGYLQcQuyuxu9w79 Q8H3INMmIq1j0rd0AbrjqibucnWKqYfu3DRePjsjtDcStOXFa6cTtY5duAFtlzwSpgoR pyMA== 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:subject:cc:to:from:date :message-id:arc-authentication-results; bh=OBnZmw3Y1yreq9hg107LpnNzyjB8dZ7FTAN29FUCLX4=; b=yEgnU+u231LCj6S7jiY6ra76WhOKsfftPAM2TyDowoQPoRpZJKIpGiY+1KyxZGwGDA BuX/cZjQs+X1Gfa8+Nin3n5HkoBKjAOFVUKoqYSUD51x6QGpKWXiuQS2RvnTeZgdzMwR FO/a4YGqtRhIKrNmuRFANB/jFgwjVIqs91fD+SZc2Gb64gCFtVDUe3N/nZttjmp4L0tH Lb/y7R1tK+sEKWMdpIGpevmzVHzyz2UkaBwv0bU1RNSLKB2FSVyRWrTTNp9O47e5kZRy QYJQp5F3Gb5w/Bl/TuA7/FOMoVzRpBtGizoZ/deHfBI4KrQZuDWy2hRFK0kXhLPRiiMy 2LFw== 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 az2-v6si4205619plb.370.2018.02.19.06.49.58; Mon, 19 Feb 2018 06:50:12 -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 S1753042AbeBSOtS convert rfc822-to-8bit (ORCPT + 99 others); Mon, 19 Feb 2018 09:49:18 -0500 Received: from prv-mh.provo.novell.com ([137.65.248.74]:50986 "EHLO prv-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752839AbeBSOtR (ORCPT ); Mon, 19 Feb 2018 09:49:17 -0500 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Mon, 19 Feb 2018 07:49:16 -0700 Message-Id: <5A8AF1F802000078001A91E1@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 18.0.0 Date: Mon, 19 Feb 2018 07:49:12 -0700 From: "Jan Beulich" To: , , Cc: , Subject: [PATCH] x86/asm: improve how GEN_*_SUFFIXED_RMWcc() specify clobbers Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8BIT Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Further more 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 Cc: Kees Cook --- arch/x86/include/asm/refcount.h | 4 ++-- arch/x86/include/asm/rmwcc.h | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) --- 4.16-rc2/arch/x86/include/asm/refcount.h +++ 4.16-rc2-x86-rmwcc-clobbers/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 --- 4.16-rc2/arch/x86/include/asm/rmwcc.h +++ 4.16-rc2-x86-rmwcc-clobbers/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 */