Return-Path: Received: from mail-pl0-x232.google.com ([2607:f8b0:400e:c01::232]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1fQavK-00028a-Ec for speck@linutronix.de; Wed, 06 Jun 2018 18:04:34 +0200 Received: by mail-pl0-x232.google.com with SMTP id w17-v6so4098926pll.9 for ; Wed, 06 Jun 2018 09:04:34 -0700 (PDT) Received: from i7.lan (c-73-11-52-149.hsd1.or.comcast.net. [73.11.52.149]) by smtp.gmail.com with ESMTPSA id t17-v6sm35948860pfj.75.2018.06.06.09.04.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jun 2018 09:04:26 -0700 (PDT) Sender: Linus Torvalds Date: Wed, 6 Jun 2018 09:04:25 -0700 (PDT) From: Linus Torvalds Subject: [MODERATED] Re: ARCH_CAPABILITIES note In-Reply-To: <5f898d80-b66a-7933-d348-c733a2b888e8@linux.intel.com> Message-ID: References: <0eca849b-fd6b-e42f-6c83-3c930d644bba@redhat.com> <3b6d8d03-945e-4efc-7baa-a7ecedfd2366@linux.intel.com> <51a5e275-67c2-5638-21e9-a3992ba1de0b@redhat.com> <5f898d80-b66a-7933-d348-c733a2b888e8@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Wed, 6 Jun 2018, speck for Dave Hansen wrote: > > From my perspective, the speculative LFENCE only has an impact on the > loads in that _particular_ speculative execution path. It has no > defined impact on the retired execution path, or *other* speculation > paths that can occur. > > The processor could easily speculate into an LFENCE, decide it does not > want to go down that speculative path, and restart speculating elsewhere > as if it had never seen the LFENCE. .. and no, I don't know of anything that *guarantees* that the lfence in the retpoline sequence effectively ends up always serializing execution as if it was in the non-speculative sequence. The retpoline code sequence is obviously designed to always get to the lfence, with the exceptions being: (a) cpu's that don't speculate or don't have an RSB at all (but then retpoline wouldn't be used) (b) interrupt at just the right point messing up the RSB that retpoline sets up (but then the interrupt itself is a serializing event) So I think we can basically agree on the lfence being "started". But your worry is what if the lfence was in the next cacheline, and wasn't even fetched or didn't get far enough in the pipeline to wait for anything before the mis-predict was noticed and the "ret" continues at the target? At that point, I don't think it's obvious that we couldn't have other speculation still outstanding. So I agree that it's a worry. We can only ask Intel architects. Linus