From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032044AbeBNXTK (ORCPT ); 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 X-Google-Smtp-Source: AH8x224tBvMTi85j+zH/KY697GAklXNO7fkDZJzsR6Wk2uX20opQrgidp9GDRNtCRP6NXnDjexhWzQ== 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 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