From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424029AbcFHTjG (ORCPT ); Wed, 8 Jun 2016 15:39:06 -0400 Received: from mga01.intel.com ([192.55.52.88]:26382 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423802AbcFHTi5 (ORCPT ); Wed, 8 Jun 2016 15:38:57 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,440,1459839600"; d="scan'208";a="998050608" From: "H. Peter Anvin" To: Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Linux Kernel Mailing List Cc: Andy Lutomirski , Borislav Petkov Subject: [PATCH v2 04/10] x86, asm: define CC_SET() and CC_OUT() macros Date: Wed, 8 Jun 2016 12:38:40 -0700 Message-Id: <1465414726-197858-5-git-send-email-hpa@linux.intel.com> X-Mailer: git-send-email 2.7.3.0.11.gd79db92 In-Reply-To: <1465414726-197858-1-git-send-email-hpa@linux.intel.com> References: <1465414726-197858-1-git-send-email-hpa@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "H. Peter Anvin" The CC_SET() and CC_OUT() macros can be used together to take advantage of the new __GCC_ASM_FLAG_OUTPUTS__ feature in gcc 6+ while remaining backwards compatible. CC_SET() generates a SET instruction on older compilers; CC_OUT() makes sure the output is received in the correct variable. Signed-off-by: H. Peter Anvin Reviewed-by: Andy Lutomirski Reviewed-by: Borislav Petkov Acked-by: Peter Zijlstra (Intel) --- arch/x86/include/asm/asm.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h index f5063b6..7acb51c 100644 --- a/arch/x86/include/asm/asm.h +++ b/arch/x86/include/asm/asm.h @@ -42,6 +42,18 @@ #define _ASM_SI __ASM_REG(si) #define _ASM_DI __ASM_REG(di) +/* + * Macros to generate condition code outputs from inline assembly, + * The output operand must be type "bool". + */ +#ifdef __GCC_ASM_FLAG_OUTPUTS__ +# define CC_SET(c) "\n\t/* output condition code " #c "*/\n" +# define CC_OUT(c) "=@cc" #c +#else +# define CC_SET(c) "\n\tset" #c " %[_cc_" #c "]\n" +# define CC_OUT(c) [_cc_ ## c] "=qm" +#endif + /* Exception table entry */ #ifdef __ASSEMBLY__ # define _ASM_EXTABLE_HANDLE(from, to, handler) \ -- 2.7.3.0.11.gd79db92