Received: by 10.213.65.68 with SMTP id h4csp389803imn; Fri, 16 Mar 2018 06:24:36 -0700 (PDT) X-Google-Smtp-Source: AG47ELt/80GvzfmKR7ftuUVYmt5FKDyXM3eHk5cT8Y0SNSYT+MJNvAsCnCMJpI0g+PVXvEBB5Fm1 X-Received: by 10.98.238.2 with SMTP id e2mr1614314pfi.68.1521206676435; Fri, 16 Mar 2018 06:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521206676; cv=none; d=google.com; s=arc-20160816; b=ozKIgZtxrJJFcdFtg0qWgpDSEgXuq9KPSfdwxpspnP3V9pAUJC7gQPc7aXxo3beQ1a rzl2xF1gDa1tTw3DOTWhgKHUj8QcSzJtZa442NPA3h5EPkTDZdBdbl6Sg0dqzvYrrmY9 yZWOqAt9bcl/trJrIVff/jm+4MPnp5phM+3kz88mbOu76lNjUfNxpz22Z51WZLatxtMn mDKF/ok2eQ0r9AmeyUfJbUoR8P+vr+BGmifv40cSAped8AEu/ZVcTpTJHGp/ghKjp+o7 ZrzAieUs6oTkIRPI6gUpgObyhqkppUV7nblPdX5rfBme/abMtwsscwUH+p+2T/CdSDXW VGRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:arc-authentication-results; bh=f4U1pyPtgHUugBrNByrr2/BnWmmCn2HoUkKpGyce8Qg=; b=LeplNB+MfOz7ZWdcWcfgmRPy3CoyZPBDRBieyFkpvYbcnjgSqdQyiF/h/R4g+A364r zSMLx+NTN4Eb0r6H5J7iD14twGWl4qs8HgLx0xp9hQxKfw1Zc1CGOQcTgsZYXjuZdy0l C3XBlnPUTMv8y64tJ2BLONlXj0Th8OMHC2FybPbIZogrIPY55nZfd4fIQyeZ6jENx8JG WyPdQnf9JbPARg5TObq3pdHu8t3BJ9qVJu7N3nQJpTrdvTNCIrMlaNn1ObOVf7HuBcwZ C+hxg0pWP5Bj608Ilhm/Oy5Uuq6LD77dXzUPT0pOad2gFRIQccEaiFc1SzZo9/b3iMpa JMlQ== ARC-Authentication-Results: i=1; mx.google.com; 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 a6-v6si5846423pll.406.2018.03.16.06.24.21; Fri, 16 Mar 2018 06:24:36 -0700 (PDT) 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; 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 S1752657AbeCPNXJ (ORCPT + 99 others); Fri, 16 Mar 2018 09:23:09 -0400 Received: from ozlabs.org ([103.22.144.67]:53433 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751448AbeCPNXI (ORCPT ); Fri, 16 Mar 2018 09:23:08 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 402mNh40kKz9sPk; Sat, 17 Mar 2018 00:23:00 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au From: Michael Ellerman To: Linus Torvalds , Michal Suchanek Cc: Kate Stewart , Madhavan Srinivasan , Mahesh Salgaonkar , Paul Mackerras , Michael Neuling , "Bryant G. Ly" , "Naveen N. Rao" , Daniel Axtens , Nicholas Piggin , =?utf-8?Q?C=C3=A9dric?= Le Goater , David Gibson , Greg Kroah-Hartman , Linux Kernel Mailing List , Sergey Senozhatsky , Masami Hiramatsu , Andrew Donnellan , Philippe Ombredanne , Joe Perches , Oliver O'Halloran , Andrew Morton , "Tobin C. Harding" , ppc-dev , Al Viro Subject: Re: [PATCH RFC rebase 2/9] powerpc: Use barrier_nospec in copy_from_user In-Reply-To: References: <20180313200108.GA4082@hirez.programming.kicks-ass.net> <32268431948dc1a32264a98a76d41d71ae7536b3.1521141122.git.msuchanek@suse.de> Date: Sat, 17 Mar 2018 00:22:54 +1100 Message-ID: <87605wi28h.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Linus Torvalds writes: > On Thu, Mar 15, 2018 at 12:15 PM, Michal Suchanek wrote: >> This is based on x86 patch doing the same. >> >> Signed-off-by: Michal Suchanek >> --- >> --- a/arch/powerpc/include/asm/uaccess.h >> +++ b/arch/powerpc/include/asm/uaccess.h >> @@ -258,8 +259,10 @@ do { \ >> long __gu_err = -EFAULT; \ >> unsigned long __gu_val = 0; \ >> const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ >> + int can_access = access_ok(VERIFY_READ, __gu_addr, (size)); \ >> might_fault(); \ >> - if (access_ok(VERIFY_READ, __gu_addr, (size))) \ >> + barrier_nospec(); \ >> + if (can_access) \ >> __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ >> (x) = (__force __typeof__(*(ptr)))__gu_val; \ >> __gu_err; \ > > Is the above really correct? The barrier is *before* the conditional > branch that might be mis-predicted. > > I don't know how the ppc barrier works, but that sounds completely bogus. Yeah it should be after the branch. I don't have a formal spec for the barrier yet, it should be defined in a hopefully soon to be released revision of the ISA. But the gist is it will stall execution until any older branches are no longer speculating. It doesn't order any two arbitrary instructions, such as a comparison and a branch, which I suspect is how Michal was interpreting it. cheers