Received: by 10.213.65.68 with SMTP id h4csp304549imn; Fri, 16 Mar 2018 03:48:19 -0700 (PDT) X-Google-Smtp-Source: AG47ELv5ndCrzw4QOhoe+oaj3hErKumdILKTRqt4wu0HIPMEE6U1OqasaNuprQKpNwugtIsT99aG X-Received: by 2002:a17:902:71cf:: with SMTP id t15-v6mr1633922plm.107.1521197299274; Fri, 16 Mar 2018 03:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521197299; cv=none; d=google.com; s=arc-20160816; b=es5+J+MY1Il5Kye6IDpljZrDuj+2+VQ273bICjD9FVFU2Ih8BZtdp1lcRwU1+AqaBz UtU4UBnnppmzFeQGpj8GgvDhF49lDF5zv1oi6yMISsl+5Zafsy/CCczPKFP9vBvowXti 7G/vQ2PixKTWjHSUYuOVCHi8lg5E11clUlv2bJuND76YevaMpJKadQeHuXVvyLYe9WZ3 gm+z8VAevsuXQ9523IWyYwUCafKMMNcCjkZObpqRQMHdsIepR2Z7WHmLkseNhHErsiO1 WgSFSu322UplIS2VumAnj2mGTR2vWFKQHTGFMVHfcYTb6EOyc5Hd/sHPLeAL2L34qYV6 s3QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature:arc-authentication-results; bh=8ghE8scXNG2/dd7skHSeWsqCt3RYcflaZVfDfqQgixs=; b=fIctk0ybqycIhqABzcLv30T3MthCwQosbQcdcHyAxmfXQvVarPb9wY6Uu1gSd5gkIO SJw9rTiXo+WHdPT54ZcwC2vFBZ1fhHES3huOExsK14RXUFbCVWPVxaQPTUBYqtqOoHgU /gLHFeh5kU26ZfbUDKOFizG5905U5heWi06WoSU7+Jn3hfwV9dBBcUfHNJ+pYLhRtCji YEXOmoQUyX2+tkvrGR8sm7rnc1M2J1NgAvY8QyHYSLdnaC2MsCaIqbdKt79cbJ3gCACW PoGqZSZciH7z84PewLd5UmOlOb3aLWkiwYGpVrEEqZ513YHjV3ss1DBQMvhskOtNUGju kmJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SrHu3Kcx; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z9-v6si5901628plo.2.2018.03.16.03.48.04; Fri, 16 Mar 2018 03:48:19 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SrHu3Kcx; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753181AbeCPKrI (ORCPT + 99 others); Fri, 16 Mar 2018 06:47:08 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:43220 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751310AbeCPKrG (ORCPT ); Fri, 16 Mar 2018 06:47:06 -0400 Received: by mail-pl0-f66.google.com with SMTP id f23-v6so5653710plr.10 for ; Fri, 16 Mar 2018 03:47:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=8ghE8scXNG2/dd7skHSeWsqCt3RYcflaZVfDfqQgixs=; b=SrHu3Kcx74kTnnbPM+FzHT5ua/6kGXuRP+wiKiFMKEBEWYUiDJ8h/PXnzTok4tkL55 XzKTM3gj/Zk9/BnNWGP5o7RtJEdLPJgCAB21RZ3DJug+ww8Lo9Lb1KAemX9ntuuPQ7ai k3H/+F8WFZn92LIB1JfO3OAgK/9C8WuPZwIIs1+kelpB5WB/5YUZxpSa7tWktH5yfPNw k8wqqtKnliTu4/T8N8d9aSspoFMfPZFZDYw4EYWNd4LUg+wHsQLsznJ0iS4ArKD7Nn6l ubiCoq9hE95CS+Sg4dZ7w4LC+J7cnZ0CFLUkkyzM9OJaDSh20HXeqAzD9rHfY6XcuywA GHhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=8ghE8scXNG2/dd7skHSeWsqCt3RYcflaZVfDfqQgixs=; b=A+s00PTnnLdPRETs08vCXNzu9RRq3Zpxbq9ZH3DRxMJNWBh+T2j42gitx5h0kRiWW4 Ry87lAczwa6zIUsaJJ7cHa2puNLmh4PmtBi2PBBNug1IQjvI+tN3POJ07Yrx9U/xK96l nXfgQACi7UXCdE5N9Vp+AmzPYKU6KN2LolVb3Gra+2gNPYmuf5AalJuJi3911S+tHM8+ cfpqPubvulFRRFIukc8cAN5SMdmfkmi4pKQGSmpwDqPUziZeaVjZy8Ho5Rl0cGmkf7z/ ueGTg9JSb1zbUeBuiTSpEnlMKZo2alq4shqHoJKLy7VSwaxNN+mTcRkyFoAPk/2mCvOm snDw== X-Gm-Message-State: AElRT7FK8a2aYUKR3W4R5Hi1O3d/hwbxDiMAMrLlUIZ4noSwm0L/jcAL VibJ+/3ZT4v95M0pHTtwZCc= X-Received: by 2002:a17:902:2f:: with SMTP id 44-v6mr1608572pla.187.1521197226201; Fri, 16 Mar 2018 03:47:06 -0700 (PDT) Received: from roar.ozlabs.ibm.com (115-64-218-172.tpgi.com.au. [115.64.218.172]) by smtp.gmail.com with ESMTPSA id m18sm12687554pgu.51.2018.03.16.03.46.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 16 Mar 2018 03:47:05 -0700 (PDT) Date: Fri, 16 Mar 2018 20:46:47 +1000 From: Nicholas Piggin To: Michal =?UTF-8?B?U3VjaMOhbmVr?= Cc: Kate Stewart , Madhavan Srinivasan , Mahesh Salgaonkar , Al Viro , Paul Mackerras , Michael Neuling , "Bryant G. Ly" , "Naveen N. Rao" , Daniel Axtens , =?UTF-8?B?Q8OpZHJpYw==?= Le Goater , David Gibson , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Sergey Senozhatsky , Masami Hiramatsu , Andrew Donnellan , Philippe Ombredanne , Joe Perches , Oliver O'Halloran , Andrew Morton , linuxppc-dev@lists.ozlabs.org, "Tobin C. Harding" , Anton Blanchard , Michael Ellerman Subject: Re: [PATCH RFC rebase 3/9] powerpc/64: Use barrier_nospec in syscall entry Message-ID: <20180316204647.68417bc5@roar.ozlabs.ibm.com> In-Reply-To: <20180316101549.31238bdf@naga.suse.cz> References: <20180313200108.GA4082@hirez.programming.kicks-ass.net> <20180316151823.2f28d5ea@roar.ozlabs.ibm.com> <20180316101549.31238bdf@naga.suse.cz> Organization: IBM X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 16 Mar 2018 10:15:49 +0100 Michal Suchánek wrote: > Hello, > > On Fri, 16 Mar 2018 15:18:23 +1000 > Nicholas Piggin wrote: > > > On Thu, 15 Mar 2018 20:15:52 +0100 > > Michal Suchanek wrote: > > > > > On powerpc syscall entry is done in assembly so patch in an explicit > > > barrier_nospec. > > > > Same comment as Linus for this -- the barriers are before the branch > > here, so is it possible the branch instruction can be speculative > > while the index is used to load the syscall table? > > As far as I understand barriers they separate code before the barrier > and code after the barrier. > > So inserting barrier_nospec after cmpldi means that the result of the > cmpldi has to be known before any instruction following barrier_nospec > that depends on the result can be executed. > > In many cases it is useful to put the barrier after a branch. It allows > the compiler to speculate on the computed value at compile time and if > it is constrained optimize out the branch. It may also result in the > need to include many barriers and less readable code. > > However, you have probably knowledge of the powerpc implementation of > the barrier so if the semantic is actually different then please > enlighten me. I actually don't. I'm assuming we should be able to say that no previous instruction is speculative when a subsequent one is executed. But the branch instruction itself that is speculated, not the compare. Usually even if all sources are ready, the pipeline may take in some cycles after a branch, before that branch can finish executing and squash speculation if it was wrong. Perhaps there is only a couple of cycles of instructions that get a chance to reach execution units and disturb any caches, but still there could be some window and I don't think we would have architectural gurantees on that. I'll try to ask around and see if there's any documentation we can give you yet. Thanks, Nick