Received: by 10.213.65.68 with SMTP id h4csp517693imn; Fri, 16 Mar 2018 10:10:01 -0700 (PDT) X-Google-Smtp-Source: AG47ELsMXs7/5nwrVlrQwlvTeGUrI1NL2DDbvyilh83ZD8asP5zcZ93ROQJUAB9lJqTPGhaufN70 X-Received: by 2002:a17:902:6789:: with SMTP id g9-v6mr2922554plk.167.1521220201023; Fri, 16 Mar 2018 10:10:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521220200; cv=none; d=google.com; s=arc-20160816; b=pDWjKQyy9FaYd+Wk2Hcrv4ETanIGD///hJah0W36fJQe3IMY1kYuVO9z9Wms9U+I34 XkT7APzXWyWR02A1IiMOw+jNzoSVzpyOIcNnSOgHhBlkSImjF7yDQpeEBdd33zChuelq fk8+96G0Ge7fCCnmsOX0suNXyjv67DndBZ3MxAht7rBlRjnNax1qLtNtIuP9ewh6oXV0 TVeJqrUlBF6dIrOW2Y57XAFMP3TSQMKUGKQgNScHAhBeqA/BFtjIWgm7HbjI8S8odD+M UyRMxSgSHpVJ8ImixWGb6UER3IkvuBmFBy+M0HDjs9sILXgm20DTHhllHQeU3mxv2iX/ UNFw== 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:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:dkim-signature:arc-authentication-results; bh=ff570FfFXpMZV+/82QxBSoLjAB3IKqWSlgFxdzvHNtY=; b=yd9QUYv60HV+6APt0tiSt4sI/i6fiU7DSZWV9Z8OOHjbkAiFtXp412DFEdU48h2zwj qhBY0oa6tDbpwXGFME7zB0e4uA8PPj1cBtl+9xq/ZrV/hbVQj5OPlgVy+8WupV3AR3C6 OMTNAkSRrZjKfNZsgpUOZv+Sdg2WiSJZl7vVjKwOwg8FIQfNI9IR4ZSdclFNO5ERm/0n YdSsluYVaMMn47MKJyaDweIZ1oZNS8MSeuMXW8a00DgyQpWnK7shryBBsQQPImIkSmRH DBdiXDTbBqn9+CT5xPg20QpWFCiS1FlhwYwIzuqLNpZjjHi0DFsOwhyxp1jhbjlXsLzv 6uRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=RI5+8VuY; dkim=fail header.i=@linux-foundation.org header.s=google header.b=gl2zCaVR; 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 s2-v6si5729082plq.674.2018.03.16.10.09.46; Fri, 16 Mar 2018 10:10:00 -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=fail header.i=@gmail.com header.s=20161025 header.b=RI5+8VuY; dkim=fail header.i=@linux-foundation.org header.s=google header.b=gl2zCaVR; 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 S1753823AbeCPRIm (ORCPT + 99 others); Fri, 16 Mar 2018 13:08:42 -0400 Received: from mail-it0-f44.google.com ([209.85.214.44]:54640 "EHLO mail-it0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752829AbeCPRIi (ORCPT ); Fri, 16 Mar 2018 13:08:38 -0400 Received: by mail-it0-f44.google.com with SMTP id w3-v6so2915665itc.4 for ; Fri, 16 Mar 2018 10:08:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=ff570FfFXpMZV+/82QxBSoLjAB3IKqWSlgFxdzvHNtY=; b=RI5+8VuYFduUh670zj1DuU4gX5w2zdThw+rQ2ZhXOmnwdAG/Npqul0sUMLMHYmcljw 3pbTXQGShvXTZVfzSzUY3ZrKbboWlGTp3mWU0oPlhD4aQUnIbmWgvRA2jaTWX9UdPhYi 75fGanXBKQGpyU8J5g8x5eWzHmyRF/jG+MsjTkbnPWVFQblMf4I01cDCEVHC53cfXZXw 6+Qzg+XLZbaPX9WWUWbaPAJdRZEw35agfwTlMO9J8U7fzlLiG3LMq9cETTVmRxa/qLws /jJAP0oacg/0siRR7O+NQSNxHoCuMLYscWOQ9X/HmvWwIzt28qtmxTRrwgOvNovP1aGB MbRQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=ff570FfFXpMZV+/82QxBSoLjAB3IKqWSlgFxdzvHNtY=; b=gl2zCaVR8vjvCYlUBDwgaHLHOAgq5iap1ozHJBP63WHOSxniGlTED0z0ko/8WXgQj5 FdEoVvmu7NlzgaaNX3nYQndhP1dJCu4VYNHCGfroxDXe+ShtReUGjWze6rH9mivyVCJu 7ilXLIybdf9Ihz3GE12eowTQVJA1KAY77C98E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=ff570FfFXpMZV+/82QxBSoLjAB3IKqWSlgFxdzvHNtY=; b=mx9wmRD91QYTkEbb/KZedFG08n6V9PcCkjAgk1w+QEY/TSYTZAf640u0jD12SfwORt mFnvrN0MKZAtl3JJVbB/L1GQczlUQebxQ0Sj8oAKUuYJ6O31gZN83AO6WOP6ffyY75g0 2s6d9C5RQWmLD4ptuvF9smeSy/sbLMXMGycpQHSRrDvDheKXWd6fjVb6mYwYRgnIIv4m Ai5cl5EofChHrkXWThoeAFs6Ky0PG1l2bSuM+Ee3ejv3uo/XCRdXNHfBCQiyyDfP48ZT 2s4hOD0IlAtpDdmO8XaOodLbvpkBdUD7qLwyTvh37U65wdCk8dLHC1KP9bR9nIX/48/x RdAw== X-Gm-Message-State: AElRT7GubuHdhNI/6aqgUzt5QQsNbLaGujBR0D27xeLC+Ef1njOfQE8/ FeMUo7o7DEvLbhn6PLsXOc5mSm+bJGY0LUFs5WE= X-Received: by 2002:a24:fec7:: with SMTP id w190-v6mr3086744ith.108.1521220117963; Fri, 16 Mar 2018 10:08:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.135.221 with HTTP; Fri, 16 Mar 2018 10:08:37 -0700 (PDT) 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> From: Linus Torvalds Date: Fri, 16 Mar 2018 10:08:37 -0700 X-Google-Sender-Auth: N0Nnk7CjhwB43UvIMC3yMRLWujw Message-ID: Subject: Re: [PATCH RFC rebase 3/9] powerpc/64: Use barrier_nospec in syscall entry To: =?UTF-8?Q?Michal_Such=C3=A1nek?= Cc: Nicholas Piggin , Kate Stewart , Madhavan Srinivasan , Mahesh Salgaonkar , Al Viro , Paul Mackerras , Michael Neuling , "Bryant G. Ly" , "Naveen N. Rao" , Daniel Axtens , =?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 , ppc-dev , "Tobin C. Harding" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 16, 2018 at 2:15 AM, Michal Such=C3=A1nek w= rote: > > As far as I understand barriers they separate code before the barrier > and code after the barrier. Almost certainly not. Even if you were to do an expensive serialization before the branch, the branch will still predict after the serialization. The thing is, it doesn't make sense to insert a barrier before a conditional branch for Spectre mitigation. The problem is not that the data isn't ready for the branch - the problem is that the branch is predicted _regardless_ of the data. Sure, some micro-architecture might not predict branches at all if they have a stable conditional, so a barrier _can_ make sense. But fundamentally, good branch prediction - in order to be optimal - has to happen before instructions have even been parsed, much less things like "stable conditional register state" having been decided on. You'll want to do I$ prefetching etc. So the problem is that even if the data is ready, the branch will be predicted according to some unrelated historical data, and a barrier to make the branch conditional be stable is pointless. A barrier *after* the branch, making sure that you don't actually start executing instructions past it (even if you might have predicted and fetched stuff past it) *if* you have mis-predicted the previous branch, is what a sane architecture would specify. Of course, on x86, we mostly tried to avoid branch prediction being the critical problem and having to have barriers by just making it an address generation dependency instead. That should presumably work on powerpc too, since address generation is part of the memory ordering definition. But obviously a microarchitecture *could* end up speculating and just redoing even for memory ordering, and maybe the ppc architects prefer the barrier since they are already used to crazy and not very well architected barriers elsewhere. Linus