Received: by 10.223.148.5 with SMTP id 5csp6163735wrq; Wed, 17 Jan 2018 10:13:04 -0800 (PST) X-Google-Smtp-Source: ACJfBosf8rJSkoPdB1/ana2Tco5eFVrWze6qHXzyj2rlTN/628Ul9lxRDxKECvwKohgnKkNmrsW+ X-Received: by 10.84.130.100 with SMTP id 91mr42656402plc.185.1516212784299; Wed, 17 Jan 2018 10:13:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516212784; cv=none; d=google.com; s=arc-20160816; b=Vql5OQwXW202tFDP9+qF/DV1lrbBVBuv+W6pIKcxW6cj5UMvp378N6aBCE3km1TcY0 C8Aq/0tkoqMeOgQsyTyoDhydkuG65RLi8J2Bkvxtbcg/kC/lnVxCvicoD4PdzmOfYODz semf6eBZXapQA+D0wYzScWlQgzV4WSzdCtbwo209quQcSIC6ANyUWod0+KuAS+m5hz74 3PJMnmjI386JSDn5SMhrUO86NnaXfW0smKlRuSkfmSKNqQ9erBTrqGXlzPshOl1pPeQ4 RB6A/zNGsrUWN10n/QRZpRB+UfEZyNM3HIlq/bhVykRcSkJbXAOYojyZRcFcX6ajE/IW hSqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=cEPpjSPrD/mzp7kuxNj6YMgcYOxZYt6RnJPOW1skOEw=; b=vuU8Wzcc1PYmeUvIB7NGsVPucLGpFRAjHY+wJ/s16tBF6QmlUamVH7nUbO5VAJc3PA qpipuZ4eIVawnEyZPv1oZDeJjefhMh0t5for/SNof/2dPc70vSdV3nbTyl+NFlLwmSOg ONfagNRtEbwK4Z9SjsBcwgeKRfMe6Pj8z9ZDqouIGAY/ZnzfAgzaFUxC12ssjid2iF65 l4E8WIBMTIl4d+fx+8L4wnTNjGqoaQhv4r2le/EJODgDkmTxQpX5CxYDQOq/EI2/iGy/ LNRxGMh8+sFfKC397IBscboHmEuOJtJ4oRZLs+4oE3k/nN6oYBZiEMc7MQZur4j/E5ac S4Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=G8AJji03; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11si4724973pls.631.2018.01.17.10.12.50; Wed, 17 Jan 2018 10:13:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=G8AJji03; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754418AbeAQSMN (ORCPT + 99 others); Wed, 17 Jan 2018 13:12:13 -0500 Received: from mail-ot0-f193.google.com ([74.125.82.193]:42774 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752807AbeAQSMI (ORCPT ); Wed, 17 Jan 2018 13:12:08 -0500 Received: by mail-ot0-f193.google.com with SMTP id s3so17632778otc.9 for ; Wed, 17 Jan 2018 10:12:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=cEPpjSPrD/mzp7kuxNj6YMgcYOxZYt6RnJPOW1skOEw=; b=G8AJji03/O6ARfipXJBsNbGDyT9MsccO9yIut5j055W04QVANJN/nFQWFOBJ70zIhY CWRZb/WAaYKx1uhGnLiCy4ESBJZ5yoxJu1t2WAwEfGNAEcGlrB7/2htMk2tMMXQIYFjy RwP/2fudsETfzaXXFtGm8dfL+R77lpXgIMjD7kG+z49uE1/qDGkfglhqfP/jD6WXHMLs 0XK+wUWgQNKQnEvLPPACbpWbrB1BDzoCnrSerJpDOCuKAgcTxrb2QuIqBjn+i8N/B2SV k28s7Uo56r1vehpaYAkaePzm1UCVmhQORN/HSZLIWWT24u0kycv/0oYfpmiUGhH2Gk9M Gtcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=cEPpjSPrD/mzp7kuxNj6YMgcYOxZYt6RnJPOW1skOEw=; b=iisvZLNcDgiOx/plgefE78YpW7GYwnkV4J2fVI9TyUK6kC7Fuq7J54EDMgsYWwtmBU 769ZtEfPXLqc0Wnx29Zx5XOkgjDBfipBmhLGIM6m6vnqpDfNvIyfRHO/0iFkG2qFbAoF B2SH+jQImDdtEPaEfuJJ0ry4yn1vqGZVOPrHpiw+n5PMHgv0nhh1qGz2XQDvl1k6t26O IvqSdDtuUjMShGpt03UefzumAqwuPN+k9L1C+gJC1wCs00wfAeaW2MI0ylLgFaMNrg+N FQ9D7Rs8nuHw0i4UWo8H6pX9l0H4a49uIfTBqmjzJhS8BIuspFZz+u4v/gheg7e94FbV HHBA== X-Gm-Message-State: AKwxytfwfRN+JKezvOWg7VJr4CucBBYuBp6ELCrr1KNFOkhpRHkP7QOn rvMPeL0lOaOUXsbBU9CQLLfRP7Yr5Jqr46YJMr/ljQ== X-Received: by 10.157.0.102 with SMTP id 93mr1637135ota.175.1516212727385; Wed, 17 Jan 2018 10:12:07 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.59.70 with HTTP; Wed, 17 Jan 2018 10:12:06 -0800 (PST) In-Reply-To: References: <151586744180.5820.13215059696964205856.stgit@dwillia2-desk3.amr.corp.intel.com> <151586748981.5820.14559543798744763404.stgit@dwillia2-desk3.amr.corp.intel.com> <20180117062800.GU13338@ZenIV.linux.org.uk> From: Dan Williams Date: Wed, 17 Jan 2018 10:12:06 -0800 Message-ID: Subject: Re: [PATCH v3 8/9] x86: use __uaccess_begin_nospec and ASM_IFENCE in get_user paths To: Al Viro Cc: Linus Torvalds , Linux Kernel Mailing List , linux-arch@vger.kernel.org, Andi Kleen , Kees Cook , kernel-hardening@lists.openwall.com, Greg Kroah-Hartman , "the arch/x86 maintainers" , Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner , Andrew Morton , Alan Cox Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 16, 2018 at 10:50 PM, Dan Williams wrote: > On Tue, Jan 16, 2018 at 10:28 PM, Al Viro wrote: [..] >> Anything that open-codes copy_from_user() that way is *ALREADY* fucked if >> it cares about the overhead - recent x86 boxen will have slowdown from >> hell on stac()/clac() pairs. Anything like that on a hot path is already >> deep in trouble and needs to be found and fixed. What drivers would those >> be? > > So I took a closer look and the pattern is not copy_from_user it's > more like __get_user + write-to-hardware loops. If the performance is > already expected to be bad for those then perhaps an lfence each loop > iteration won't be much worse. It's still a waste because the lfence > is only needed once after the access_ok. > >> We don't have that many __get_user() users left outside of arch/* >> anymore... Given the concern of having something easy to backport first I think we should start with lfence in __uaccess_begin(). Any deeper changes to the access_ok() + __get_user calling convention can build on top of that baseline.