Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755228AbeAMSwA (ORCPT + 1 other); Sat, 13 Jan 2018 13:52:00 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:39790 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753386AbeAMSvz (ORCPT ); Sat, 13 Jan 2018 13:51:55 -0500 X-Google-Smtp-Source: ACJfBotIHHba3Ja0l4rpyyYuIe4o0ZCAYGs1Yzf2DF1bNiWZZcMmUMcWC9fa6KOCF1NS7yfDul9HP9AfuOZkX4Ne6Ps= MIME-Version: 1.0 In-Reply-To: References: <151571798296.27429.7166552848688034184.stgit@dwillia2-desk3.amr.corp.intel.com> From: Linus Torvalds Date: Sat, 13 Jan 2018 10:51:53 -0800 X-Google-Sender-Auth: nXfOWr2kCNtSfyLHLid4oq0tr8k Message-ID: Subject: Re: [PATCH v2 00/19] prevent bounds-check bypass via speculative execution To: Tony Luck Cc: Dan Williams , Linux Kernel Mailing List , Mark Rutland , kernel-hardening@lists.openwall.com, Peter Zijlstra , Alan Cox , Will Deacon , Alexei Starovoitov , Solomon Peachy , "H. Peter Anvin" , Christian Lamparter , Elena Reshetova , "linux-arch@vger.kernel.org" , Andi Kleen , "James E.J. Bottomley" , Linux SCSI List , Jonathan Corbet , "the arch/x86 maintainers" , Russell King , Ingo Molnar , Catalin Marinas , Alexey Kuznetsov , Linux Media Mailing List , Tom Lendacky , Kees Cook , Jan Kara , Al Viro , qla2xxx-upstream@qlogic.com, Thomas Gleixner , Mauro Carvalho Chehab , Kalle Valo , Alan Cox , "Martin K. Petersen" , Hideaki YOSHIFUJI , Greg KH , Linux Wireless List , "Eric W. Biederman" , Network Development , Andrew Morton , "David S. Miller" , Laurent Pinchart Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Fri, Jan 12, 2018 at 4:15 PM, Tony Luck wrote: > > Here there isn't any reason for speculation. The core has the > value of 'x' in a register and the upper bound encoded into the > "cmp" instruction. Both are right there, no waiting, no speculation. So this is an argument I haven't seen before (although it was brought up in private long ago), but that is very relevant: the actual scope and depth of speculation. Your argument basically depends on just what gets speculated, and on the _actual_ order of execution. So your argument depends on "the uarch will actually run the code in order if there are no events that block the pipeline". Or at least it depends on a certain latency of the killing of any OoO execution being low enough that the cache access doesn't even begin. I realize that that is very much a particular microarchitectural detail, but it's actually a *big* deal. Do we have a set of rules for what is not a worry, simply because the speculated accesses get killed early enough? Apparently "test a register value against a constant" is good enough, assuming that register is also needed for the address of the access. Linus