Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp3778631rwj; Tue, 20 Dec 2022 01:34:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf46eHciYRrjVIuTfvwjJHuix8pJw9Ylwi2df8w775f0ghLZjdohfxSVjOX8nE02gO3CeC4L X-Received: by 2002:a17:906:859a:b0:7c1:4bb2:f62c with SMTP id v26-20020a170906859a00b007c14bb2f62cmr36989593ejx.40.1671528863011; Tue, 20 Dec 2022 01:34:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671528862; cv=none; d=google.com; s=arc-20160816; b=GD+vK+3PgmuKBGJkhCocE4CPZo4O6hYU9mwv9zWyDYfr4o6O7z5Qe5BGVHjmpA8ZUs psvpUOJpc6eCvNABMG3UZSazJKEZEZY11p/6eRP5YtfCnLgdKzfL+o4Cuw+Z1/pYpA0u 2cPohSyBb/r/sefG7Jeql8vCZ+Hy837cc3NI0FPUQ0GOhfx3hgqIvy6USTH7FRUB9SUT z/B8QKuLyYtLebUQeLK+2B5V08P5CzC1j8AC+DCD1tbScj+plioY0/McO++QJsAj9/fF ze5anT286KJw3xOTmYZ0BWIuQBCuQy4NCok/F312wMmmW2Ts7pfrljeVKMaNByB7JZY3 tE8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=tLmDBRcb5bG0HEu7y3TsRnCiz9YjM9HkYhGNTN9FxjU=; b=dHHHISw6284YNRBVI/Yz5THI96gzs3d6zvDs73gwx705evCg77w3UY4Iptb2lSJTTv 5R1Q0jIEjI5eUVfenb3WLyqQz9XM6Hd+T9wDRxca/E8iX9EL8qHEsAREwyPfnmUzHJWR nnL7n9TOsDX+/Cio404I4KXaNcCBr134kcBPgbv31WY+Lui1kqtuDIFH8RowdHbZh6d1 RuP9XcUdxo7Ea1pjLLYx72bJFveeGF9TbfmXjPOdHwUbAce1ABRx1/qw0iR5dG+pYNMa YWq3mz1N+Xagvy3XCDBaSHhJhi8MN+cqsUhn2PUusgODMkdLm/Ro3chDf9LfzuZvHYDS BETg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="A/Se8cRO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc9-20020a1709071c0900b0081a9c3ca4c4si6229304ejc.572.2022.12.20.01.34.06; Tue, 20 Dec 2022 01:34:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="A/Se8cRO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233148AbiLTJQN (ORCPT + 70 others); Tue, 20 Dec 2022 04:16:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbiLTJQI (ORCPT ); Tue, 20 Dec 2022 04:16:08 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDA8595B0; Tue, 20 Dec 2022 01:16:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=tLmDBRcb5bG0HEu7y3TsRnCiz9YjM9HkYhGNTN9FxjU=; b=A/Se8cRO5QDxTngZPZZNloMJWZ uG51t85sQf4iwVRFCoWyl8ikfeyiZM3Vgv0QNYJuzc+w8PVflica22xj70H3zxKCiMGqJViLp05vm Gnkx9booBqLDFkhSTABv3KtClAz/jDbyu/5NxI9JxD8/FqSk+nEnf8hwOljz0Pe2bQjkTM/eBOQSI 63x79IkuUnFd3Mx7FHGB8zdMCOegX52rCnCZYeo37zDrxY0WPEgEueHGHYFJ+H/YXct1ZeI/liAMh Xk5IzUT9PjbDhpr7m4z8JeFythoYJ7cQSLsTcEUc2nENMk4Cu6+REkmuqnIU5vxuFQfeOM7sp67aJ e9seskVA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1p7Yj2-001dqa-W5; Tue, 20 Dec 2022 09:15:53 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id DFB3E300023; Tue, 20 Dec 2022 10:15:41 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id C344A2C5F830D; Tue, 20 Dec 2022 10:15:41 +0100 (CET) Date: Tue, 20 Dec 2022 10:15:41 +0100 From: Peter Zijlstra To: Xin Li Cc: linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, andrew.cooper3@citrix.com, seanjc@google.com, pbonzini@redhat.com, ravi.v.shankar@intel.com Subject: Re: [RFC PATCH 18/32] x86/fred: add a debug fault entry stub for FRED Message-ID: References: <20221220063658.19271-1-xin3.li@intel.com> <20221220063658.19271-19-xin3.li@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221220063658.19271-19-xin3.li@intel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 19, 2022 at 10:36:44PM -0800, Xin Li wrote: > +static __always_inline void debug_kernel_common(struct pt_regs *regs, > + unsigned long dr6) > { > - /* > - * Disable breakpoints during exception handling; recursive exceptions > - * are exceedingly 'fun'. > - * > - * Since this function is NOKPROBE, and that also applies to > - * HW_BREAKPOINT_X, we can't hit a breakpoint before this (XXX except a > - * HW_BREAKPOINT_W on our stack) > - * > - * Entry text is excluded for HW_BP_X and cpu_entry_area, which > - * includes the entry stack is excluded for everything. > - */ > - unsigned long dr7 = local_db_save(); > - irqentry_state_t irq_state = irqentry_nmi_enter(regs); > instrumentation_begin(); > > /* > @@ -1062,7 +1050,8 @@ static __always_inline void exc_debug_kernel(struct pt_regs *regs, > * Catch SYSENTER with TF set and clear DR_STEP. If this hit a > * watchpoint at the same time then that will still be handled. > */ > - if ((dr6 & DR_STEP) && is_sysenter_singlestep(regs)) > + if (!cpu_feature_enabled(X86_FEATURE_FRED) && > + (dr6 & DR_STEP) && is_sysenter_singlestep(regs)) > dr6 &= ~DR_STEP; > > /* > @@ -1089,8 +1078,28 @@ static __always_inline void exc_debug_kernel(struct pt_regs *regs, > regs->flags &= ~X86_EFLAGS_TF; > out: > instrumentation_end(); > - irqentry_nmi_exit(regs, irq_state); > +} Why doesn't the FRED handler get to to use irqentry_nmi_{enter,exit}() ? > @@ -1179,6 +1188,24 @@ DEFINE_IDTENTRY_DEBUG_USER(exc_debug) > { > exc_debug_user(regs, debug_read_clear_dr6()); > } > + > +# ifdef CONFIG_X86_FRED > +DEFINE_FRED_HANDLER(fred_exc_debug) > +{ > + /* > + * The FRED debug information saved onto stack differs from > + * DR6 in both stickiness and polarity; it is exactly what > + * debug_read_clear_dr6() returns. > + */ > + unsigned long dr6 = fred_event_data(regs); > + > + if (user_mode(regs)) > + exc_debug_user(regs, dr6); > + else > + debug_kernel_common(regs, dr6); > +} > +# endif /* CONFIG_X86_FRED */