Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp538324pxb; Thu, 26 Aug 2021 08:39:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHa0i3xdnvM7wvTU9+gWJpmiWJ0B/UB3BoSGi8VchavMqdyFNvl30LpydLCxAeSwrMEreW X-Received: by 2002:a17:906:4fd6:: with SMTP id i22mr5009704ejw.92.1629992395315; Thu, 26 Aug 2021 08:39:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629992395; cv=none; d=google.com; s=arc-20160816; b=snn/H0olexkVHCAdQDcYGTGfAZ8MUf/cnPFVqcpGcijj4FHAeKarZDEB4hk7Gh0ReG 6IsOEkc2yQs+6U59s+b8xarpXc9G6F2VQIdBpEqirvvDB9RTb233a51vKppQxLgG9nRC f0Dp9bzsmR3Cuem6KVPXBLiOcRWLicqS66QalkTjIo1Uh2WwpfmQvg68Wp7425qe15mE 9WitsbLgNykA3HDxet0KxdTwZUterPs9VOBNyphqJ2kxfYyOxD2IA2iJ41TtI7arh3n0 nXWh6Y2tAtw3vEaPiwfNEgIzyH1t6KuhI944vL5WiDGIC/TXRwnZhx1KTCuMVfMO6dgo ctRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Jm7T/M66AzeAhOL+ybpi6sZfMuezw0CvVSwLf3X8HnA=; b=feTunQ/CsfJU8O8xUz1wSLNJVMQceyXa3M9U5qyYVizk8QhN2u4piTpGPfV4RJXWhG wI0mzKtBCBTaAYf0VtllqRGDQ+ONkka7mRqJlasTNTzf54qrTb95YcFpjKdVoJGV+r7c w51mBs90/RDFcAi5kiZz3N7Qf3LRWpraZ826tYdbgpiw2/6QgsRcAOXm78s4wF9ntZ2q vFn8tyhKA4E3r1k7Xz5tTLAIv1d9A5Mrt799Ayl1OKr+EJI163+y+TvPnWzU8rocYATW YXB/IiB5yFSTz+DiBU/N/7McBNQniOLWtfnr05p+Nm25oWXmBkz5yrz28WqIeGcC7AWl r4ag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m26si3394589edq.156.2021.08.26.08.39.27; Thu, 26 Aug 2021 08:39:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242954AbhHZPiN (ORCPT + 99 others); Thu, 26 Aug 2021 11:38:13 -0400 Received: from gate.crashing.org ([63.228.1.57]:41638 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242926AbhHZPiM (ORCPT ); Thu, 26 Aug 2021 11:38:12 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 17QFUnw3025834; Thu, 26 Aug 2021 10:30:49 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 17QFUmZn025833; Thu, 26 Aug 2021 10:30:48 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Thu, 26 Aug 2021 10:30:48 -0500 From: Segher Boessenkool To: Nicholas Piggin Cc: Benjamin Herrenschmidt , Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Paul Mackerras Subject: Re: [PATCH v2 1/2] powerpc/bug: Remove specific powerpc BUG_ON() and WARN_ON() on PPC32 Message-ID: <20210826153048.GD1583@gate.crashing.org> References: <1628834356.pr4zgn1xf1.astroid@bobo.none> <20210818150653.GJ1583@gate.crashing.org> <1629946707.f6ptz0tgle.astroid@bobo.none> <20210826124901.GY1583@gate.crashing.org> <1629983260.5jkx2jf0y8.astroid@bobo.none> <20210826143708.GC1583@gate.crashing.org> <1629989540.drlhb24t2w.astroid@bobo.none> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1629989540.drlhb24t2w.astroid@bobo.none> User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 27, 2021 at 01:04:36AM +1000, Nicholas Piggin wrote: > Excerpts from Segher Boessenkool's message of August 27, 2021 12:37 am: > >> No, they are all dispatched and issue to the BRU for execution. It's > >> trivial to construct a test of a lot of not taken branches in a row > >> and time a loop of it to see it executes at 1 cycle per branch. > > > > (s/dispatched/issued/) > > ? Dispatch is from decode to the issue queues. Issue is from there to execution units. Dispatch is in-order, issue is not. > >> How could it validate prediction without issuing? It wouldn't know when > >> sources are ready. > > > > In the backend. But that is just how it worked on older cores :-/ > > Okay. I don't know about older cores than POWER9. Backend would normally > include execution though. > Only other place you could do it if you don't > issue/exec would be after it goes back in order, like completion. You do not have to do the verification in-order: the insn cannot finish until it is no longer speculative, that takes care of all ordering needed. > But that would be horrible for mispredict penalty. See the previous point. Also, any insn known to be mispredicted can be flushed immediately anyway. > >> >> The first problem seems like the show stopper though. AFAIKS it would > >> >> need a special builtin support that does something to create the table > >> >> entry, or a guarantee that we could put an inline asm right after the > >> >> builtin as a recognized pattern and that would give us the instruction > >> >> following the trap. > >> > > >> > I'm not quite sure what this means. Can't you always just put a > >> > > >> > bla: asm(""); > >> > > >> > in there, and use the address of "bla"? > >> > >> Not AFAIKS. Put it where? > > > > After wherever you want to know the address after. You will have to > > make sure they stay together somehow. > > I still don't follow. some_thing_you_want_to_know_the_address_after_let_us_call_it_A; empty_asm_that_we_can_take_the_address_of_known_as_B; You have to make sure the compiler keeps A and B together, does not insert anything between them, does put them in the assembler output in the same fragment, etc. > If you could give a built in that put a label at the address of the trap > instruction that could be used later by inline asm then that could work > too: > > __builtin_labeled_trap("1:"); > asm (" .section __bug_table,\"aw\" \n\t" > "2: .4byte 1b - 2b \n\t" > " .previous"); How could a compiler do anything like that?! Segher