Received: by 10.223.185.116 with SMTP id b49csp2178333wrg; Mon, 12 Feb 2018 05:44:41 -0800 (PST) X-Google-Smtp-Source: AH8x224RKxK31R80UmrITlrbmLRbL3pbIP4PI38Gh40z8GuP2ITxR3DQVprD70i6foHwL0Lpnsav X-Received: by 2002:a17:902:ba84:: with SMTP id k4-v6mr10620060pls.116.1518443081051; Mon, 12 Feb 2018 05:44:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518443081; cv=none; d=google.com; s=arc-20160816; b=Y1jYunJQ74BB6Ds/iaZQ7dKZ3nMOFn1rjxG63VWYCMIuLBhA0U4u5G1OJCheCuSXG4 Lq7XnBYJyqLex/skMMiyRtRls8T6JqWqTBNogSMxgArktBA/I48p7Mdpzp7TBaIS80Yx rEe8btL53kX0AQyij+6+Ah+XahqVUR7sWl9xUyeyyHvDwKBWwHKPELWEfA48OTmRjK1z MxymzHMmHh1yW0KsDOiUMnsRgstVmMg07Kr2gBbIorU4WsXcv3nEtQhsh7k8ZfXJJlkv fSUvWdOARjdR43jzqac3a5LEw+tEaV4yVTvFgLpWmtSdajzmsn0fH/yuIN1Ax3my9o+j jMGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=5w8NXnRPEVhTBiRtRaCsG+ho1DIEekQBmcGD1j9McK4=; b=Q8KY7b/dIU6qPKZJALbd0AhpAxVywI9sMnjQSX4oLeUg9Fih6SH7SiO4/4Gmlzdp36 YRlwfOmjwK2wPguaN1YpWA0nPQtHIkEz2+APfDAhzHNxqtiKyCyeOeC0Q47kJzHgybrO 1xcCl2uJtQdYMHko0boYtJ4HCHw3tNQJVZN5jF/iwDCxxWGoMW+l1crHNnA+YrHGvLm8 4dsfHijOfR5PNcX2d4TMJSSk3coLyJV5JQD8fmP0PHUBl5wwqLvwPk+qQP329a8XRjGE QwNUgjMzLVPmTdhHiixfovw/IRRChI4rIcJ+d5165uoVGfzqRtPLrcFUw1TIzByvMIPe yMrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=NSlY+MNB; 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 g6-v6si2781735plj.159.2018.02.12.05.44.26; Mon, 12 Feb 2018 05:44:41 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=NSlY+MNB; 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 S934550AbeBLM3D (ORCPT + 99 others); Mon, 12 Feb 2018 07:29:03 -0500 Received: from merlin.infradead.org ([205.233.59.134]:45088 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933001AbeBLM3B (ORCPT ); Mon, 12 Feb 2018 07:29:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5w8NXnRPEVhTBiRtRaCsG+ho1DIEekQBmcGD1j9McK4=; b=NSlY+MNBIcVyFa22tTltlTK32 V1JfPuY6O/BoEgvNMrENvpP9G4x8Mi6fnmG+G3pGxxypqsMlRtYVGyqirAby9MwHCabBGtV9hJtpY VpbJvTndvkIcHq+SfJTQv0Rrch0pmdqeZFwn2SDUs2QnDXYgOwVrYaPVAY5sxRxa3rBXjLRVaOU7k 9sYlkwZy6lOloB77N/mV3Z3llIPnpr2rsoRt8XNaO+hfzzyaJ/EjD1A+Ei9PPOteNFYQcYxDo89ZD d4oWDVeWa/lWNFaNTxJCkHFwgYBqzSE/kUwJGvGYthW9tiASaOJGmYkAJcJRoycV6qSM9yqIWNXbR D9Kem24zQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1elDE5-00035i-PX; Mon, 12 Feb 2018 12:28:54 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 8191720207CB8; Mon, 12 Feb 2018 13:28:52 +0100 (CET) Date: Mon, 12 Feb 2018 13:28:52 +0100 From: Peter Zijlstra To: Ingo Molnar Cc: hpa@zytor.com, tglx@linutronix.de, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, dwmw@amazon.co.uk, linux-tip-commits@vger.kernel.org, Dave Hansen , Borislav Petkov , Arjan van de Ven Subject: Re: [tip:x86/pti] x86/speculation: Use IBRS if available before calling into firmware Message-ID: <20180212122852.GH25235@hirez.programming.kicks-ass.net> References: <1518362359-1005-1-git-send-email-dwmw@amazon.co.uk> <20180212102211.cdrrqqd4hdw7xu5y@gmail.com> <20180212115002.GI25181@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180212115002.GI25181@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 12, 2018 at 12:50:02PM +0100, Peter Zijlstra wrote: > On Mon, Feb 12, 2018 at 11:22:11AM +0100, Ingo Molnar wrote: > > > +static inline void firmware_restrict_branch_speculation_start(void) > > > +{ > > > + alternative_msr_write(MSR_IA32_SPEC_CTRL, SPEC_CTRL_IBRS, > > > + X86_FEATURE_USE_IBRS_FW); > > > +} > > > + > > > +static inline void firmware_restrict_branch_speculation_end(void) > > > +{ > > > + alternative_msr_write(MSR_IA32_SPEC_CTRL, 0, > > > + X86_FEATURE_USE_IBRS_FW); > > > > BTW., there's a detail that only occurred to me today, this enabling/disabling > > sequence is not NMI safe, and it might be called from NMI context: > > Wait, we're doing firmware from NMI? That sounds like a _REALLY_ bad > idea. Argh, its that stupid watchdog driver again.. Not only does it call firmware, it also uses (!raw) spinlock.