From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 39282 invoked by alias); 8 Jan 2018 14:07:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 39270 invoked by uid 89); 8 Jan 2018 14:07:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.4 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS,T_RP_MATCHES_RCVD,URIBL_BLACK autolearn=ham version=3.3.2 spammy= X-HELO: foss.arm.com Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 08 Jan 2018 14:07:05 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 922501529; Mon, 8 Jan 2018 06:07:03 -0800 (PST) Received: from e105689-lin.cambridge.arm.com (e105689-lin.cambridge.arm.com [10.2.207.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E5A4D3F318; Mon, 8 Jan 2018 06:07:02 -0800 (PST) Subject: Re: [PATCH 1/3] [builtins] Generic support for __builtin_load_no_speculate() To: Bill Schmidt Cc: gcc-patches@gcc.gnu.org References: <3f3375cf241d099400b7f90c7c6e42c2e140734c.1515072356.git.Richard.Earnshaw@arm.com> <95C2CF86-A0AF-4FF4-B4AD-C723D2502D08@linux.vnet.ibm.com> From: "Richard Earnshaw (lists)" Message-ID: Date: Mon, 08 Jan 2018 14:19:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <95C2CF86-A0AF-4FF4-B4AD-C723D2502D08@linux.vnet.ibm.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2018-01/txt/msg00483.txt.bz2 On 08/01/18 02:20, Bill Schmidt wrote: > Hi Richard, > > Unfortunately, I don't see any way that this will be useful for the ppc targets. We don't > have a way to force resolution of a condition prior to continuing speculation, so this > will just introduce another comparison that we would speculate past. For our mitigation > we will have to introduce an instruction that halts all speculation at that point, and place > it in front of all dangerous loads. I wish it were otherwise. So can't you make the builtin expand to (in pseudo code): if (bounds_check) { __asm ("barrier"); result = *ptr; } else result = failval; R. > > Thanks, > Bill > >> On Jan 4, 2018, at 7:58 AM, Richard Earnshaw wrote: >> >> >> This patch adds generic support for the new builtin >> __builtin_load_no_speculate. It provides the overloading of the >> different access sizes and a default fall-back expansion for targets >> that do not support a mechanism for inhibiting speculation. >> >> * builtin_types.def (BT_FN_I1_CONST_VPTR_CONST_VPTR_CONST_VPTR_VAR): >> New builtin type signature. >> (BT_FN_I2_CONST_VPTR_CONST_VPTR_CONST_VPTR_VAR): Likewise. >> (BT_FN_I4_CONST_VPTR_CONST_VPTR_CONST_VPTR_VAR): Likewise. >> (BT_FN_I8_CONST_VPTR_CONST_VPTR_CONST_VPTR_VAR): Likewise. >> (BT_FN_I16_CONST_VPTR_CONST_VPTR_CONST_VPTR_VAR): Likewise. >> * builtins.def (BUILT_IN_LOAD_NO_SPECULATE_N): New builtin. >> (BUILT_IN_LOAD_NO_SPECULATE_1): Likewise. >> (BUILT_IN_LOAD_NO_SPECULATE_2): Likewise. >> (BUILT_IN_LOAD_NO_SPECULATE_4): Likewise. >> (BUILT_IN_LOAD_NO_SPECULATE_8): Likewise. >> (BUILT_IN_LOAD_NO_SPECULATE_16): Likewise. >> * target.def (inhibit_load_speculation): New hook. >> * doc/tm.texi.in (TARGET_INHIBIT_LOAD_SPECULATION): Add to >> documentation. >> * doc/tm.texi: Regenerated. >> * doc/cpp.texi: Document __HAVE_LOAD_NO_SPECULATE. >> * doc/extend.texi: Document __builtin_load_no_speculate. >> * c-family/c-common.c (load_no_speculate_resolve_size): New function. >> (load_no_speculate_resolve_params): New function. >> (load_no_speculate_resolve_return): New function. >> (resolve_overloaded_builtin): Handle overloading >> __builtin_load_no_speculate. >> * builtins.c (expand_load_no_speculate): New function. >> (expand_builtin): Handle new no-speculation builtins. >> * targhooks.h (default_inhibit_load_speculation): Declare. >> * targhooks.c (default_inhibit_load_speculation): New function. >> --- >> gcc/builtin-types.def | 16 +++++ >> gcc/builtins.c | 99 ++++++++++++++++++++++++++ >> gcc/builtins.def | 22 ++++++ >> gcc/c-family/c-common.c | 164 ++++++++++++++++++++++++++++++++++++++++++++ >> gcc/c-family/c-cppbuiltin.c | 5 +- >> gcc/doc/cpp.texi | 4 ++ >> gcc/doc/extend.texi | 53 ++++++++++++++ >> gcc/doc/tm.texi | 6 ++ >> gcc/doc/tm.texi.in | 2 + >> gcc/target.def | 20 ++++++ >> gcc/targhooks.c | 69 +++++++++++++++++++ >> gcc/targhooks.h | 3 + >> 12 files changed, 462 insertions(+), 1 deletion(-) >> >> <0001-builtins-Generic-support-for-__builtin_load_no_specu.patch> >