Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932275AbeAIEVN (ORCPT + 1 other); Mon, 8 Jan 2018 23:21:13 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:41536 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756720AbeAIEVK (ORCPT ); Mon, 8 Jan 2018 23:21:10 -0500 X-Google-Smtp-Source: ACJfBouy7rAP3xm4+jZuz+A1hvRpPdwEvqH8PguKiXlfrI6YQvmyKxsvRwFCRJTqh15RqF/d2/PbUPo17TCfGsuijq8= MIME-Version: 1.0 In-Reply-To: References: <151520099201.32271.4677179499894422956.stgit@dwillia2-desk3.amr.corp.intel.com> <151520108080.32271.16420298348259030860.stgit@dwillia2-desk3.amr.corp.intel.com> <87lgh7n2tf.fsf@xmission.com> From: Linus Torvalds Date: Mon, 8 Jan 2018 20:21:09 -0800 X-Google-Sender-Auth: ZtN2uxBplZflsO4ttgkd-0fSIts Message-ID: Subject: Re: [PATCH 16/18] net: mpls: prevent bounds-check bypass via speculative execution To: Dan Williams Cc: "Eric W. Biederman" , Linux Kernel Mailing List , linux-arch@vger.kernel.org, Peter Zijlstra , Netdev , Greg KH , Thomas Gleixner , "David S. Miller" , Elena Reshetova , Alan Cox 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 Mon, Jan 8, 2018 at 8:13 PM, Linus Torvalds wrote: > > # carry will be clear if idx >= max > cmpq %idx,%max Bah. Other way around. cmpq %max,%idx I'm a moron. > # mask will be clear if carry was clear, ~0 otherwise > sbbq %mask,%mask > > to generate mask directly. I might have screwed that up. Worth perhaps trying? More importantly, worth _testing_ and fixing my hand-waving "asm like this" crap. But I do think that simple two-instruction cmpq/sbbq sequence could get it right in just two trivial ALU instructions. Linus