Received: by 10.213.65.68 with SMTP id h4csp430297imn; Tue, 13 Mar 2018 08:49:24 -0700 (PDT) X-Google-Smtp-Source: AG47ELtFADoQ1tRAW3+9bVtfJLzQczGlyX/hvxbo8/NIjoCu0kPQbyxPcObqkVBeZmto9ytpbIB+ X-Received: by 10.98.102.82 with SMTP id a79mr1080793pfc.138.1520956164259; Tue, 13 Mar 2018 08:49:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520956164; cv=none; d=google.com; s=arc-20160816; b=KwpSDv8S2vr/XRZd+XiHkS2Q+9VfKkU+ihyEv+ApVrkpwKut14yvwvfTf8Di/PeoOi YTFfSNDp9JrWgUJ9iJkRo4Y6MeeXUMGRNAAYXZv9D1UwRfHmWuVReFjXW9iAZIHaDxeM MbQCM27afhGgq7DDMT/iTtrY3Nx4jiV5Vg0XQ+n8hmLTnGYtfE2hW+aiz9lYuMNsPHQ2 XOCk1Ylp2iDC8K+j+9At+5Hu1dQXD6FTXzvxAqaqlC+Ci96M/m6ASZVhwXtHMnj8EC3R 03Xkv6M+5qqiL9qoAlzgo7HO9F4dlwD0FlkAgklNJQWP8O7q15xUpjCAjEG/Nljmkcao eP5A== 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=jqf0UZ2rjG7tIDo1sszvcXpQS/cRo9IkXEQDkXfZNPs=; b=gR5riL4CFftrbhf3ljeTePKgguUx46eSXPG0v1yYeya4qRd3VBfnWYXPszVSjEj8Ju 6Cq7mEZ4Nhkl5HpY0J1kOlwEJP2TNz9LpQeHJeqBHaqc3m/lO49D1MQPdckvaFOW8fng yQbpTYAW3gYRevRCQjk2TYa+8gP8D76w6NWT2Zth41GOwhR9Dbr4iz3xoaNdx80KaT1K LT+0yGkKgNPg3aPD1bH2aBxC9em4RWNlBlbLlM+HKy/wbJwy3QJr0233gJ9F7ZRUG4IU +oIRc8m+mphXx+XS4QNUBXLD8ZrrBkUBXPyt4DyECKYQpGmCvJf8L2dhyzKyO5U+sNea Qxtg== 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 q24-v6si293109pls.600.2018.03.13.08.49.09; Tue, 13 Mar 2018 08:49:24 -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 S935092AbeCMPqj (ORCPT + 99 others); Tue, 13 Mar 2018 11:46:39 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36854 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934445AbeCMPlX (ORCPT ); Tue, 13 Mar 2018 11:41:23 -0400 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3B03311F4; Tue, 13 Mar 2018 15:40:56 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Beulich , Thomas Gleixner , Andy Lutomirski , Borislav Petkov , Brian Gerst , Denys Vlasenko , "H. Peter Anvin" , Josh Poimboeuf , Kees Cook , Linus Torvalds , Peter Zijlstra , Ingo Molnar Subject: [PATCH 4.14 120/140] x86/asm: Improve how GEN_*_SUFFIXED_RMWcc() specify clobbers Date: Tue, 13 Mar 2018 16:25:23 +0100 Message-Id: <20180313152506.254661547@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152458.201155692@linuxfoundation.org> References: <20180313152458.201155692@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Beulich commit 700b7c5409c3e9da279fbea78cf28a78fbc176cd upstream. 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 Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/refcount.h | 4 ++-- arch/x86/include/asm/rmwcc.h | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) --- 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 --- 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 */