Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp79649ybf; Wed, 26 Feb 2020 09:09:59 -0800 (PST) X-Google-Smtp-Source: APXvYqwz4mU6OpaVtrogTW/p1xfV+uNUJPTktd/4z6IWa9/jW7/Ei1+otWag2cd1Wl6jNdd3oK3V X-Received: by 2002:a05:6808:2cd:: with SMTP id a13mr3565oid.82.1582736998967; Wed, 26 Feb 2020 09:09:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582736998; cv=none; d=google.com; s=arc-20160816; b=rzgthy9zzdFonvtMWMhDXl+YVRg9L/sHvRIS05s5JqSWBzebsjDx++7qpZ/UQv72uV EVXY0IiZ5cQQlBi+zEPIFIS0rkQzPUpRy3CxEWymvS/ZtQ7oVc0aBCwZusYr4CmX8vtC a3r672Jd12zkVoB9+FVHOhUjRW4tzvfLxTAJ1bv/FTLvXI1H8bJYUSrKKgrnYT4COxX4 Nibb00GCME6uCxQwsyf9/U4wk33ulavOSBC/XM/Jf4K+81v0+6JygsaSlNWHgygELchB vhcUlOBA2yG2Ywmg5wvMGDBrp3WM2WVINKQxBkyK+50A6vgv4PyvrLr1WxCsJDcVh7B9 4iuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:in-reply-to:cc:references:message-id :date:subject:mime-version:from:content-transfer-encoding :dkim-signature; bh=UBPrvXy09WZpAcWcslRLri/oOngl129nsy3OuzEGs0Y=; b=t/dlVtUNzEr1gh4DnRyOhWHas0nS/2+7y+rTXGh431GINwQCnrptrfTKlr4h6j+vNz xxySXdzvvWx640OntrfXov8vdYomoV4uNXZfYfXTrSYFoeg/J4v3vL4RyfN4gK31uQSU yRWSmAWjcfX5V9S+7zlWFnGHt0ahHxehcpw9r52DQswD3Wfh4/Ofjs095Oi9fMm1slLh TT98toFGx09HT2yjg5TwvJU5ydA+82hpEynriKmP/L1AKUDiXxn8BdS3x8NEGT9EuugJ MhkOWNk2HI5VUneWh7CkCar0Sp2kVz11CsamyRbVfau6y2GHy69XpnBPQ8Q1soAYJEhB A15g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b="vWy/JeKO"; 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 s11si93808otr.14.2020.02.26.09.09.45; Wed, 26 Feb 2020 09:09:58 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b="vWy/JeKO"; 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 S1727993AbgBZRJk (ORCPT + 99 others); Wed, 26 Feb 2020 12:09:40 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:35735 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727240AbgBZRJk (ORCPT ); Wed, 26 Feb 2020 12:09:40 -0500 Received: by mail-pj1-f68.google.com with SMTP id q39so1519765pjc.0 for ; Wed, 26 Feb 2020 09:09:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=UBPrvXy09WZpAcWcslRLri/oOngl129nsy3OuzEGs0Y=; b=vWy/JeKOLLoMqtMRIE2O/CazBBrBpE5ZnXSzbU/4I0TCllMI+v/wBiYRlYlSUYnut6 YihqkXFpovtq6VZn1vFOaj/vJEwlYciM1OZda8xrDduqp6kYYBxB5kK/57XMljMOnGni 2XLmJRqKnjgxTWVwCsKtOGDNjGC2j3giEweMzlyYbJIwINX+fx+LU1iRrSJ2LCrNFhTl NQUPZKGdDyhzGr3Uz6oM29HE2oXzvEku6jm6qZWXVPQVDBQ4wBNYfRZ+dkTLO3LfEKqH P++cQnX43RoIpgDSIgHw8NPeF3B65vk+UX0fmvt4WkAILHbVYUlCBEKSb0M3dJnOdGj0 FaXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=UBPrvXy09WZpAcWcslRLri/oOngl129nsy3OuzEGs0Y=; b=UIfhFAeKcIaMC1iE2q6+M1D/1PQ3eZpGWHN0DHTOPHe9oC+TC2chUsjms9tY1QtQrM 8vgirY2KuZLeH1peEpmb+2J0TrN1XdYOrdCTeRav7cw0SjqhnbVPJg0kaaoefuT1seca O4O8ex5S40nFRAW8jNNbIABz/ZGaJDaYFd87/CamOgYbUBZpzhQDC0A1F7gnsmn/JjHR EO5wVURFzpt8eP9UkT9LN/dv7t9rLGwTXYZnjGo1BmhKu9bOcycQz6jpRQ3TFJhnhHID 5XadytGI9WeMLtAvmU0AR87ytlw01Ho4B+U3vEmYMx8Dp/6/nOrVUkvzH7vYC9c9QVwu FXgQ== X-Gm-Message-State: APjAAAVaIm+95T13zRhnSyVs8qzpw17MXcJcqIAe2Zlw83VlBj+Ot2Yg EPmx5GWcnXvzbh1yMg1Vbgfdsg== X-Received: by 2002:a17:90a:f0d1:: with SMTP id fa17mr79752pjb.90.1582736978968; Wed, 26 Feb 2020 09:09:38 -0800 (PST) Received: from ?IPv6:2600:1010:b069:8a27:ddd9:92ea:d62b:8a52? ([2600:1010:b069:8a27:ddd9:92ea:d62b:8a52]) by smtp.gmail.com with ESMTPSA id gx18sm3529920pjb.8.2020.02.26.09.09.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Feb 2020 09:09:38 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [patch 13/16] x86/entry: Move irqflags and context tracking to C for simple idtentries Date: Wed, 26 Feb 2020 09:09:34 -0800 Message-Id: <2A899107-5AB8-4907-8AF2-31154A2E0A98@amacapital.net> References: <20200226170534.GA6075@lenoir> Cc: Peter Zijlstra , Thomas Gleixner , LKML , x86@kernel.org, Steven Rostedt , Brian Gerst , Juergen Gross , Paolo Bonzini , Arnd Bergmann In-Reply-To: <20200226170534.GA6075@lenoir> To: Frederic Weisbecker X-Mailer: iPhone Mail (17D50) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Feb 26, 2020, at 9:05 AM, Frederic Weisbecker wro= te: >=20 > =EF=BB=BFOn 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: >>>=20 >>> --- a/arch/x86/include/asm/idtentry.h >>> +++ b/arch/x86/include/asm/idtentry.h >>> @@ -7,14 +7,31 @@ >>>=20 >>> #ifndef __ASSEMBLY__ >>>=20 >>> +#ifdef CONFIG_CONTEXT_TRACKING >>> +static __always_inline void enter_from_user_context(void) >>> +{ >>> + CT_WARN_ON(ct_state() !=3D 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(); >>> } >>=20 >> So: >>=20 >> asm_exc_int3 >> exc_int3 >> idtentry_enter() >> enter_from_user_context >> if (context_tracking_enabled()) >>=20 >> poke_int3_handler(); >>=20 >> Is, AFAICT, completely buggered. >>=20 >> You can't have a static_branch before the poke_int3_handler that deals >> with text_poke. >=20 > #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.=