Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp87449ybf; Wed, 26 Feb 2020 09:17:49 -0800 (PST) X-Google-Smtp-Source: APXvYqw8MnLxyZw0Ph7z2L4W1Xnkptva503a20YNvr/ShlEmW8Ix0JskK9gIhWidHENyJpWZe+kk X-Received: by 2002:a05:6830:22f2:: with SMTP id t18mr4053235otc.290.1582737469195; Wed, 26 Feb 2020 09:17:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582737469; cv=none; d=google.com; s=arc-20160816; b=zpeFXEEzIfL/vtHrVaXu300gXwOAle8Z0c1zaQvqCnGxxvVJ9Jr5+gR3+QgLImm+MK Ng2Hsl+MjNnSM/8EtOyxMfILneLfsWNiSiipm6bcSVqh70X+1ZNOsQSuzS/RKPhLiGPU I+9ZjxJAT+4EnrlrYymB/dAJFug+Hge1dUS4PkgwilXBdHvdBg5HaK2F7MOElNzEGhCy DplgDOZusrr65AYeklgzwb63BUCMsUPLWOgpxN1uRDtOX6Fpkyrp8hE+aDG2NexAmX6f 3FrfbyMmxRSqsU9JTltAEpSQY9RTsmlGdpJymOPQnwxQzM4uJpRhcWS8SxPrq8wtmTr4 ujCw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GS4Nhvl+ofCsRD0qbwSgaqEakpHzFyhjYil4b7P7dMc=; b=IJ73ljx1oVx/NX8Xd3qWn6RASZRXTgJpztHCsAmvbhjIikSNzU7ep4BhRf9U6BIWXq dsOfoj/DPYPIZt43VulXjMUHSmCL8xNaKoAWzHjwAviluDKC+yQ9jJDjydb0gZ4Cm6AF dVh1q8vUArVDndYe2nylJtJGviy8UxKm2SHI7ls9+kFTe3T6+FcpDD+3KG9DwjFmPeW0 nCq81kxUhwIusZp0svE0nE5cI3/0quSDWsFmE+DvhuJeERI8cOqP1Seqbx7bIJK+V6Cx NJiP9y5UUm9uMsuyIcYCG5jptq1MzKbdaGqtJRO3phR6RUQJRyXMCZnZ/d2uwZpTWl40 mHVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xGt9lOvc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10si83964otp.310.2020.02.26.09.17.37; Wed, 26 Feb 2020 09:17:49 -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=pass header.i=@kernel.org header.s=default header.b=xGt9lOvc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726561AbgBZRRJ (ORCPT + 99 others); Wed, 26 Feb 2020 12:17:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:43854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726151AbgBZRRJ (ORCPT ); Wed, 26 Feb 2020 12:17:09 -0500 Received: from localhost (lfbn-ncy-1-985-231.w90-101.abo.wanadoo.fr [90.101.63.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1D6A6206E6; Wed, 26 Feb 2020 17:17:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582737428; bh=jVCA3JmCA3VCj0DKgVLl8KD4KCd9P0F6bDnSIe2izGY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xGt9lOvcpXmAaLm+7beD81Z0ylCkkKWyArrJGvm073sX4q+Ec/EPsDiQiuq/Fc9Nu s+JvJW82du58fX0ni8Qv5/gLDhaMYybW0Mxiwqepr7yuE2YYO0AhUpzFxAOiPaSpuG DHjyjiaekpw6f/IbnlwJJsX+VryUaYrLbTakK4fQ= Date: Wed, 26 Feb 2020 18:17:06 +0100 From: Frederic Weisbecker To: Andy Lutomirski Cc: Peter Zijlstra , Thomas Gleixner , 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: <20200226171705.GC6075@lenoir> References: <20200226170534.GA6075@lenoir> <2A899107-5AB8-4907-8AF2-31154A2E0A98@amacapital.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2A899107-5AB8-4907-8AF2-31154A2E0A98@amacapital.net> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 26, 2020 at 09:09:34AM -0800, Andy Lutomirski wrote: > > > > On Feb 26, 2020, at 9:05 AM, Frederic Weisbecker wrote: > > > > On Wed, Feb 26, 2020 at 09:05:38AM +0100, Peter Zijlstra wrote: > >>> 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. > > > > #BP is treated like an NMI in your patchset IIRC? > > In that case and since that implies we can't schedule, we can remove > > the call to context tracking there once we have nmi_enter()/nmi_exit() > > called unconditionally. > > int3 from user mode can send signals. This has better be able to schedule by the time it hits prepare_exit_to_usermode. Oh right...