Received: by 10.223.185.116 with SMTP id b49csp1319139wrg; Wed, 14 Feb 2018 15:20:11 -0800 (PST) X-Google-Smtp-Source: AH8x227+62/V47qjgzKSCqYu48FEtdEDzXbjyTnWJx5MKMp/O0/YmKhParc16yIcDgf8gE9+wbMN X-Received: by 2002:a17:902:5a4a:: with SMTP id f10-v6mr601236plm.308.1518650411743; Wed, 14 Feb 2018 15:20:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518650411; cv=none; d=google.com; s=arc-20160816; b=BO+6MPDU6qowmVLwNLpoVNELdHyRV85us51radTKqKpYaC694d/YkrzbbSAJNy+tBH YXp/tyABLYKkxvTmuX0YLdncnvH1cP73186PHrs3g00G50zfRJzo+GFFKUswYNfFdwZ5 Qdmunpt693Jn7hKdTbVTXeYh3nk/mCSVtFkloSF+rQZm/HJjH85Zafq1mC/9FO8bHryO c+IVQ2YY7YvNg5iXe8ECXu6lG/zpbRW3z7bM/koAPLMqJ4fsEgfRbisINOG/on5AIt1u x4JDw/HKTrLimM+IgxjN2g0V2uN+DTD/8gn0cp3uCa09ai7A8b3+xBbOMn6JNKzR+ilz fQHQ== 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=1SwuEWA2hvOw1Y0so759mwoLmGJOuGPs6w48OtIYyOU=; b=VWChNauJLvVGZFnoyq6RhOrOXLysAI8VYcn5YngTgn9J4JgZjQ+sDladgnYg8r1uJq /islIdmAfZve9OHlSfIs4S69gHYtwjHt/3BqZprWbnOHnpd/j7qCzd9gvkkFIyVAgDMl RqFSWN+5UtTGmWBGHbekHtle3Dv6Vn2uPlxAv7K6HtO/bpMV8WF7lubHVrmHOp+8hBz1 fl5Tenj0dQQ3Gzen2eFVckahHJN1Qr5eae8hVCdapH6V4Y9JhFjyIySRfKRsEicZH+fI 5pPTG/JJdtBQEsnpJLn1APXJjZo5OwaoBo/AcnfUfJ87R7JobmaOzTxd6i/3yDTmxTu6 kfGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=t3DNE3AY; 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 v14si1850881pgq.604.2018.02.14.15.19.57; Wed, 14 Feb 2018 15:20:11 -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=@gmail.com header.s=20161025 header.b=t3DNE3AY; 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 S1032022AbeBNXTK (ORCPT + 99 others); Wed, 14 Feb 2018 18:19:10 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:54091 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031971AbeBNXTI (ORCPT ); Wed, 14 Feb 2018 18:19:08 -0500 Received: by mail-wm0-f65.google.com with SMTP id t74so25751925wme.3; Wed, 14 Feb 2018 15:19:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=1SwuEWA2hvOw1Y0so759mwoLmGJOuGPs6w48OtIYyOU=; b=t3DNE3AYOQcdccONJieksw0GM1gayQBz1Fo7tx2FNQPdiuS350NZCTM0uQ4h2jFR+J UREzOXwUjRy/rW9jrj73xV4TeAI/1KVpLzFSk2oMfPs8XIoXIhxoXo10toHxG2lY46tm OG7KKXLqBmD9DMtpgAT3ftvjNJySeaxTJB1OLI8vMIlW2fBhtH7hbihX4nL59W9w1iWy Dt5NM9/Fb1rIpn7sCJofBp8ChzQrokuBm3/zjrdoHvFE0+hcnpz3q9S8FZgsSfak8efW MIQlUMfoHsydk/9KRf3GtlA7NPWa/ECuePiJma6DWS8NixqO9rzcNMZkrMJK6YEkRURz oKEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=1SwuEWA2hvOw1Y0so759mwoLmGJOuGPs6w48OtIYyOU=; b=SmgoJn5Xd/ACyjpIF+cBnzzNfkPPU9c4Ot0T5rwtOmWzUEy5HDMH9ebP8N+9iuRV6x 0QW/4ZU8hhcYmyxrXNHRvYyfURuj/bpW/J5SzRiNuJ8xa+nnG0m8jJMlFOlbE3bU/jb2 4lAHGm+gzTly/8jw2qYuZVDJuffqkUmYRePOd3TXWkvjJJHNhHhY4pP9szPdJWfb+vLo noYTojfnxGsqmX8mUDje7yOrFFGfrKyYPjmPNo55Vz2Ljmq3PO/ZkYrFt/dSl4tw1Coo mIsMslvxyoXJEJxgr48aX2PCVi0doTnMmVrguEXPAz/+uoP+puxSJw+477f8EpsB+1m2 fTtw== X-Gm-Message-State: APf1xPCQeywCzpd6RKHQTGn5A3heqSAvWF4D0Cr9rfvTYHvGANHTYbAj JkEXnrJ6UhUobSN1bGBnD8E= X-Received: by 10.28.73.2 with SMTP id w2mr437356wma.129.1518650347540; Wed, 14 Feb 2018 15:19:07 -0800 (PST) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id 63sm14306393wms.46.2018.02.14.15.19.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2018 15:19:06 -0800 (PST) Date: Thu, 15 Feb 2018 00:19:04 +0100 From: Ingo Molnar To: Tim Chen Cc: Peter Zijlstra , Dave Hansen , 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, Borislav Petkov , Arjan van de Ven Subject: Re: [tip:x86/pti] x86/speculation: Use IBRS if available before calling into firmware Message-ID: <20180214231904.ww46gjnytbx3jqef@gmail.com> References: <1518362359-1005-1-git-send-email-dwmw@amazon.co.uk> <20180212102211.cdrrqqd4hdw7xu5y@gmail.com> <20180212165835.GO25181@hirez.programming.kicks-ass.net> <20180213075540.3lkikkpgjoe6ocjk@gmail.com> <5c3ba123-abbe-f153-7b75-a89d31d25c72@linux.intel.com> <20180214085614.GT25181@hirez.programming.kicks-ass.net> <1fd7c8ef-a50c-53d8-7159-d992e669c2f2@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1fd7c8ef-a50c-53d8-7159-d992e669c2f2@linux.intel.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Tim Chen wrote: > On 02/14/2018 12:56 AM, Peter Zijlstra wrote: > > > > > At the very least this must disable and re-enable preemption, such that > > we guarantee we inc/dec the same counter. ISTR some firmware calls (EFI) > > actually are preemptible so that wouldn't work. > > > > Further, consider: > > > > this_cpu_inc_return() // 0->1 > > > > this_cpu_inc_return() // 1->2 > > call_broken_arse_firmware() > > this_cpu_dec_return() // 2->1 > > > > wrmsr(SPEC_CTRL, IBRS); > > > > /* from dodgy firmware crap */ > > > > this_cpu_dec_return() // 1->0 > > wrmsr(SPEC_CTRL, 0); > > > > How about the following patch. These fragile complications of the interface should now be unnecessary, as the only driver that called firmware from NMI callbacks (hpwdt.c) is going to remove those firmware callbacks in the near future - solving the problem at the source. Thanks, Ingo