From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: ACJfBot55zAd1PJSqWuPGqMNjJ/LBTYcJ+PJw6R3x5eJEBeNACNtW8+o+TCfRhYKNooiZWUxrjrj ARC-Seal: i=1; a=rsa-sha256; t=1516334611; cv=none; d=google.com; s=arc-20160816; b=IXkti5gVfhTUbaPX0dTPQKU+vjkN67aPiEhwbo3Vqth96XiFwWSLhzw0xuI8YNDEg9 0jXN3eTJPEteQ80/uXC1lcEWvxbSa1DJDZC/mvuDgDzqihlun124zf4TaycwghOZnoAD DpIYMV2mWhXDuJPud0Z5kvTA5KdiPrQOTfGz6D1rweLP4SZzSvzl/6xXX7iPB/pPr9ki V2CGkj1jvHCKHPD9/XW03NZJTsTMmofI+zzqXp2bm26IrTdoYiFJcw6RoIjx+Z8mPHoY e3lRzGDeFVp9TKjhIQDi/0gvnATbwVEUe/J9HGy5onthAV8Sz2XnR534ib/HqAJlDcO6 ubnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:arc-authentication-results; bh=KWu2yOUDQTPqCcHLPW5YP+alloKkuPpThvbkiqytM3o=; b=Lame1P9Paa/or8bURmHH+wAxP7yqqxVsRFWYSPD3X4HBv6h+HbiR8ov2l7r0hGAe+i UvWK7gOKoInyfh/7mZ/FGE7AlhA0PELafp221YRRwZva4yW0szvlSb5FRL9JJ6p+kcTt TwQ4dKpwJn0Tlhd/RMq04NzJuyYxt1IjPGfNjqslaXbkFw+FnuJk+MqGmlnskv/G0Yek z4KVOGEEz0mdaDMOnNdZjLhR8yYe+nMZy55g9So6rTX85cqZCIooBN+Py0QkYfPxQUwt alqqJHQLEg782qmCJ5ezBnhUKzGxHc/fRUp22J9KCJwNeYt8PCSq0L/cWV/Z8vDOaHqd tieA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of caf@la.guarana.org designates 173.254.219.205 as permitted sender) smtp.mailfrom=caf@la.guarana.org Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of caf@la.guarana.org designates 173.254.219.205 as permitted sender) smtp.mailfrom=caf@la.guarana.org Date: Thu, 18 Jan 2018 23:03:29 -0500 From: Kevin Easton To: Tim Chen Cc: Peter Zijlstra , David Woodhouse , Thomas Gleixner , Josh Poimboeuf , linux-kernel@vger.kernel.org, Dave Hansen , Ashok Raj , Andy Lutomirski , Linus Torvalds , Greg KH , Andrea Arcangeli , Andi Kleen , Arjan Van De Ven , Dan Williams , Paolo Bonzini , Jun Nakajima , Asit Mallick , Jason Baron Subject: Re: [PATCH 30/35] x86/speculation: Use Indirect Branch Prediction Barrier in context switch Message-ID: <20180119040329.GA21544@la.guarana.org> References: <20180118134800.711245485@infradead.org> <20180118140153.257709600@infradead.org> <3a3c86d1-d15a-ec98-a9c0-e7a43f5c9cc5@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3a3c86d1-d15a-ec98-a9c0-e7a43f5c9cc5@linux.intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcSW1wb3J0YW50Ig==?= X-GMAIL-THRID: =?utf-8?q?1589979186687852310?= X-GMAIL-MSGID: =?utf-8?q?1589992082016353177?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Thu, Jan 18, 2018 at 04:38:32PM -0800, Tim Chen wrote: > On 01/18/2018 05:48 AM, Peter Zijlstra wrote: > > > >+ /* > >+ * Avoid user/user BTB poisoning by flushing the branch predictor > >+ * when switching between processes. This stops one process from > >+ * doing spectre-v2 attacks on another process's data. > >+ */ > >+ indirect_branch_prediction_barrier(); > >+ > > Some optimizations can be done here to avoid overhead in barrier call. > > For example, don't do the barrier if prev and next mm are > the same. If the two process trust each other, or the new process > already have rights to look into the previous process, > the barrier could be skipped. Isn't it the other way around with the BTB poisoning? previous is potentially attacking next, so the barrier can be avoided only if previous is allowed to ptrace next? - Kevin