Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 13 Aug 2018 21:41:43 -0000 Received: from mail-pl0-x22e.google.com ([2607:f8b0:400e:c01::22e]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1fpKar-0006mS-Gd for speck@linutronix.de; Mon, 13 Aug 2018 23:41:41 +0200 Received: by mail-pl0-x22e.google.com with SMTP id f6-v6so7439820plo.1 for ; Mon, 13 Aug 2018 14:41:41 -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 g5-v6sm21906919pfh.63.2018.08.13.14.41.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Aug 2018 14:41:33 -0700 (PDT) Sender: Linus Torvalds Date: Mon, 13 Aug 2018 14:41:31 -0700 (PDT) From: Linus Torvalds Subject: [MODERATED] Re: Cache load gadgets In-Reply-To: <20180813212359.ertbf2axk64eog5l@treble> Message-ID: References: <1533736415.3615.64.camel@infradead.org> <20180808145316.GX4238@tassilo.jf.intel.com> <20180808153429.quokqzwwvnripsdj@treble> <20180813151727.GA15539@char.us.oracle.com> <20180813172303.5d3umkf3ciqrkz5b@treble> <20180813185922.GE5606@kroah.com> <20180813195404.es23nco6ydyorlyi@treble> <20180813204859.udixjnld4v33n4q4@treble> <20180813212359.ertbf2axk64eog5l@treble> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Mon, 13 Aug 2018, speck for Josh Poimboeuf wrote: > > Ok, so I think the two discussions got mixed up a bit and I > misunderstood your point. The patch which was posted earlier was a > Spectre v1 fix, but I believe it was suggested that it has a higher > priority because of L1TF. Actually, no. The patch that was posted earlier (although maybe there were multiple ones and I'm only remembering one) was *not* a spectre-v1 fix, it was literally just a "don't speculatively fill cacheline using a user-supplied index" fix. Noiw, it used the same "nonspec" helpers that the spectre-v1 fixes do use, so it *looks* the same, but it didn't actually have the required indirection through memory to turn the loaded cacheline into a data leak. Unless I read the patch wrong, and/or mis-reemember. So it _looked_ like "spectre-v1", but it was really just a "cachelines get filled by various things". Note that some of those things that fill cachelines we don't have any control over. Do you know how the L2 -> L1 prefetch logic works? There are literally papers about improving dependent load performance by having logic that makes a prefetcher kick in when you see a value being loaded that *looks* like a pointer. Seriously - this is things like the memory subsystem doing cache prefetching on its own (with no instructions - just based on earlier patterns and the size of the load that it can see) based on what kind of data it sees being loaded from memory, _just_in_case_ it's a pointer. Is that just an academic paper? Maybe. And maybe not. I don't know. My point is, for all we know, the hardware will prefetch things just because we load an 8-byte value from user space. Maybe the value is actuall just a bitmap, but if user space *crafts* it to look like a kernel pointer, and resources are idle, and maybe the prefetch logic kicks in and we'll be populating cachelines. No, I don't actually think Intel or AMD do that. But it's literally possible. Filling caches down speculative paths is going to happen everywhere. > Taking L1TF out of the equation, it sounds like you have no objections > to the Spectre v1 fixes. We will continue doing those... The real Spectre-v1 ones where we have a "load a speculative value from memory, then use that value as an index to load/store another value, so that people can figuyre out the first speculative value" by all means. So the "full spectre-v1" case we should very much strive to fix. It's the "half-spectre" that I think is a dead end because just loading a cacheline can happen so many ways. Linus