Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4624454ybv; Wed, 26 Feb 2020 00:07:39 -0800 (PST) X-Google-Smtp-Source: APXvYqxkUfmUPrpHYM/eUZO3qdmfkfIjoKtbB5QLrQUI3n9HfGEQ56cuuP0AYs6gh6rn3aOBBGgf X-Received: by 2002:aca:d03:: with SMTP id 3mr2134072oin.69.1582704459143; Wed, 26 Feb 2020 00:07:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582704459; cv=none; d=google.com; s=arc-20160816; b=tlYv7cmqNKkM4j4o5Txu40WrSv/sjX/m0YzTZoq7x4lx3odM8M3z2VMJjFqQaU7UD6 j5+K6nFHmSNPAemIwo3XxuHroAmVJceVJTZbr9j+Jfgd0U0Xdnx26tvJ42OAY2A8IDfw Ntqbd9BTA2t+/fonCaZDcojh7prrM7eeZQtJBjnFhU9b5xJLdV0jB18HTTDYFiDg1o1Y 1ly/MoFnoAjq/RjzlNUidsESmVdDIXNg5BUg7V5Cxs/nlT2vQa1omOtNQQlXMC3EX+YJ rXZoIYhfBpyVCS19hE55i1mGBdNszd32N58bv096kxzNHl+Ze0FnvSvCyQHDgJ5qcT/z ENXw== 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; bh=ByKqs5RS8oVptfO5+UU1Er07nuxy8TMvTUVvNbxzm6A=; b=rJl7c9XqhBRPo1G+RFVPdVqLxhesX3NoJZR840iuBh0jE0gCZa637Iw2FO/jflxjv1 7i5XKD9BUTqYNFNdH0OjbAsWaowhfjWnIyIuMAlvJyalQu9GjOICClgTloDJ2rGu6f+I OXMJvFQhy3MMOVU6mAIT2ywB+Y6qXVxwJOekkJJtdCLvNP0x8MNZv0p/fQ0MXwODvCCi BOnq+/tIkNeqfKF8zkIHqkJX7g+IySLzXudtSgQZhIPfmU0RzIrGiLU/EpyoErN2puHr m9BICH9F/j7W8Z1+pMIQwKMDefSS+Q+rEorCvXncGmjMt39AFfwx0E4m/1rTmgOZePEg vsow== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=PApiq7Wh; 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 t22si1051010oth.211.2020.02.26.00.07.26; Wed, 26 Feb 2020 00:07:39 -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=PApiq7Wh; 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 S1727359AbgBZIFz (ORCPT + 99 others); Wed, 26 Feb 2020 03:05:55 -0500 Received: from merlin.infradead.org ([205.233.59.134]:38904 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727129AbgBZIFz (ORCPT ); Wed, 26 Feb 2020 03:05:55 -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; bh=ByKqs5RS8oVptfO5+UU1Er07nuxy8TMvTUVvNbxzm6A=; b=PApiq7WhmnjBBZAPe8x1FZW158 EdwNaWEjNKrxU4tG/fRUWVUcb5ibaNqzUDYU2Fk/o+99ZYaW4hB3vSw39py727qVQCmD/zOk6k/Db n3rCsINt0mg8IieM1T9mSTQ4VsjaEndJSDLUKT+E4B5Umvl5/FAlUIS7qi1Gt7AoRXzgqPoDBYc5c NzCOB/3QqdT024JJ6ZAXycL8JsWLHAUo35Z2e53EzfRLV9Y3dQriRJ1ahACVDXr4tkt4g19yLwYk/ T4zv5sOt+ksNijh9u+/8GR9nIr3bBD3Y7RPd4eXEZkWLS6DKs/uskogf1Uc/J+1G27zLgNS0CYgMi 3JAT3WsA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6rhN-0007Dg-T3; Wed, 26 Feb 2020 08:05:42 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 9D519300478; Wed, 26 Feb 2020 09:03:43 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id EAB93203E18D3; Wed, 26 Feb 2020 09:05:38 +0100 (CET) Date: Wed, 26 Feb 2020 09:05:38 +0100 From: Peter Zijlstra To: Thomas Gleixner Cc: LKML , x86@kernel.org, Steven Rostedt , Brian Gerst , Juergen Gross , Paolo Bonzini , Arnd Bergmann Subject: Re: [patch 13/16] x86/entry: Move irqflags and context tracking to C for simple idtentries Message-ID: <20200226080538.GO18400@hirez.programming.kicks-ass.net> References: <20200225223321.231477305@linutronix.de> <20200225224145.444611199@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200225224145.444611199@linutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 25, 2020 at 11:33:34PM +0100, Thomas Gleixner wrote: > --- a/arch/x86/include/asm/idtentry.h > +++ b/arch/x86/include/asm/idtentry.h > @@ -7,14 +7,31 @@ > > #ifndef __ASSEMBLY__ > > +#ifdef CONFIG_CONTEXT_TRACKING > +static __always_inline void enter_from_user_context(void) > +{ > + CT_WARN_ON(ct_state() != CONTEXT_USER); > + user_exit_irqoff(); > +} > +#else > +static __always_inline void enter_from_user_context(void) { } > +#endif > + > /** > * idtentry_enter - Handle state tracking on idtentry > * @regs: Pointer to pt_regs of interrupted context > * > - * Place holder for now. > + * Invokes: > + * - The hardirq tracer to keep the state consistent as low level ASM > + * entry disabled interrupts. > + * > + * - Context tracking if the exception hit user mode > */ > static __always_inline void idtentry_enter(struct pt_regs *regs) > { > + trace_hardirqs_off(); > + if (user_mode(regs)) > + enter_from_user_context(); > } So: asm_exc_int3 exc_int3 idtentry_enter() enter_from_user_context if (context_tracking_enabled()) poke_int3_handler(); Is, AFAICT, completely buggered. You can't have a static_branch before the poke_int3_handler that deals with text_poke.