Received: by 10.213.65.68 with SMTP id h4csp459544imn; Tue, 13 Mar 2018 09:44:21 -0700 (PDT) X-Google-Smtp-Source: AG47ELv07J7wIE08fkb2epD2q9qHBzFBk63yJph61Q2qYdO4UOu8cKEby9CQJJ0emestT8SDmv1f X-Received: by 10.99.176.15 with SMTP id h15mr1004244pgf.448.1520959461319; Tue, 13 Mar 2018 09:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520959461; cv=none; d=google.com; s=arc-20160816; b=XQ1QCm5c1Yc1qslFpjkdkVg5FkTzGHTSlxJfJ97SdRLf1FIluKwKnkM6zp/L8xM8wM AFozzomtNDF1CEAj1OCL2POeAmBnS6D55XN6HikTIpYPr+FFEPlVPWzJ340AX0njtIAa Hab9K9Qi3G+gLyXS0+n3CVKG1UWidhLaLUL67dlOwVSJiJdxgaNXIe4oD/NyJFCI5UQh YixdxB722KWW6cwnn02oEZzMII4V1whBUj7EHzOSz/T+HsXBnG+re8De0JYqhlqeDa0j 7sj+uCqdaewGv/3bGPuImxwPqDP3o+JufQwTUtmDzyH4kRL/+wG7aWNbOXcNOxz3drih 6UgQ== 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=UdevRXmeojWHs71l3ho4dT+cTh2XzCoVwecOxAXhz1M=; b=aca6v/qNjssotLP8l8YpCmIm1nOwrLPaHBb6Y1+aVxs8NP0IgjNssQ4xg4VaJ9hIow 52fQ2UpmgDblkxEDYd7rrIqf1WFmHEJVYI9UdDuxybX2D4OjLKDwTfsfi3ovS+Y6kFsJ YmdxeW3jFVX+LYD/ovfSVQABvwRgklwOlaK1qPL6mJxqxl/vizU8LJty5p9U9UyDpNz6 1SW3iiFGEYwdnJ7cYPnj34/MZxHAb0ZKDJhNrsWzlBd68e/PCHxXPOJsRs7FiYhijxOK 0TNfYX9UnHUW6PXhCLPKKc7zT+rQsFBUE3q1P5YC5vd9VXjMQ2NoLr+Gk+zWCF4O48ek 914w== 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 j17si275295pga.495.2018.03.13.09.44.07; Tue, 13 Mar 2018 09:44:21 -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 S933347AbeCMPbd (ORCPT + 99 others); Tue, 13 Mar 2018 11:31:33 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59268 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933324AbeCMPb2 (ORCPT ); Tue, 13 Mar 2018 11:31:28 -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 D04F911EE; Tue, 13 Mar 2018 15:31:27 +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.15 085/146] x86/asm: Improve how GEN_*_SUFFIXED_RMWcc() specify clobbers Date: Tue, 13 Mar 2018 16:24:12 +0100 Message-Id: <20180313152327.356610432@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152320.439085687@linuxfoundation.org> References: <20180313152320.439085687@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.15-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 */