Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751232AbeADXAc (ORCPT + 1 other); Thu, 4 Jan 2018 18:00:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36470 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751029AbeADXAb (ORCPT ); Thu, 4 Jan 2018 18:00:31 -0500 Date: Fri, 5 Jan 2018 00:00:29 +0100 From: Andrea Arcangeli To: Peter Zijlstra Cc: Tim Chen , Thomas Gleixner , Andy Lutomirski , Linus Torvalds , Greg KH , Dave Hansen , Andi Kleen , Arjan Van De Ven , linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/7] x86/idle: Disable IBRS entering idle and enable it on wakeup Message-ID: <20180104230029.GZ13348@redhat.com> References: <50b92931dd3cd403d60e69533f5583bbdbbb88d0.1515086770.git.tim.c.chen@linux.intel.com> <20180104224731.GE32035@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180104224731.GE32035@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.9.2 (2017-12-15) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 04 Jan 2018 23:00:31 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Thu, Jan 04, 2018 at 11:47:31PM +0100, Peter Zijlstra wrote: > Argh.. no. Who is calling this with IRQs enabled? And why can't we frob > the MSR with IRQs enabled? That comment doesn't seem to explain > anything. Why we can't is easy to explain, the irq handler would run in such case and that isn't using save paranoid, it relies on KERNEL_CS and it assumes IBRS already set. The irqs_disabled() check can be dropped if you do enough verification that it never happens. Initially it wasn't obvious the irq disabled invariant would be always enforced from the multitude of callers it has (and that varies on different codebases). I didn't want to deal with such an occurrence and risk even more trouble. Later I did the verifications and I dropped the irqs_disabled() too. It should be possible to drop it but it generally doesn't hurt to start more obviously safe and optimize it later.