Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1323722pxa; Thu, 20 Aug 2020 08:23:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaJH3Dn637HiArwguhoX2dhlUug0dOgviqYPxuJ3gznSt+OP73yjTNPaquxduWzuBBDzdQ X-Received: by 2002:a17:907:2067:: with SMTP id qp7mr3709440ejb.378.1597936988568; Thu, 20 Aug 2020 08:23:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597936988; cv=none; d=google.com; s=arc-20160816; b=vRb1C86ALUujMJ46wD9S6Iu4Td2EjLim5xS1PKk7RVtf6063GkQfsy0xYvMm2Ukiz5 +tbSnnIyoJtoDCsyZR2SVpj5v6LzeVZuAOjJNsmvTWRAKFMTxT0HSALvp3J+Fh5Kmkac 6Hq3Ung3ymaVkNeGcOIuGMO8z6Ki2Ec1AntSClHSe+smLtwbCxdYLMaplAZg8uqzvnu8 V+cgUBaCgfCvMT706t1r8qegBPll/o0pyRBqUD9Ed1d83oMusuN4I5QuD1bNOmGUbf6Q Cq8tulNd610lPj99iS02PQCBexzRKgxiq+ZxEM7/tt1mWKP2MBDrw9J6Jw7xYBo9uWzV F9Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=WO117o7rJcvrbn+tJaLD6rskyy5H89U6ereeOLtJe1c=; b=L+9x/8YoWCoMJcq72bOvsetLfLScnRbHAHefVsVG1+g+SkUuGKmF7MMveaY3EXfdcx dblAyfsrH2xHlS09q9JaKh1b9D8qGMXA3u0Hjkq6hflGtt8Xa+mSn0O+AJs0h0cEEWZM Wj6EZ00bVTJpvKsbEaMnr/pg69mB5S5ZGEnljcl5JP+w8WCPxu/RWyaGjeKcZh0Tm1/G aLnKGx66kAXCrq8NbJh0Y+s5TNsD/wH1ZZfOZDfQrBWjkr2/0ozN1GI4L9f+fmOhN12x yfzDoiF91VOAAnw6YP8XpKAiOg5fu+lk7hGbMJ/IxAqzW+qWknQdaayjXi2lZU5DSp66 sp+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=CdQPS5aH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l7si1462431edn.510.2020.08.20.08.22.44; Thu, 20 Aug 2020 08:23:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=CdQPS5aH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728648AbgHTPVx (ORCPT + 99 others); Thu, 20 Aug 2020 11:21:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726852AbgHTPVw (ORCPT ); Thu, 20 Aug 2020 11:21:52 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A500C061385 for ; Thu, 20 Aug 2020 08:21:52 -0700 (PDT) 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=WO117o7rJcvrbn+tJaLD6rskyy5H89U6ereeOLtJe1c=; b=CdQPS5aHR7EtJZbvyYojM200RK Oog4l+FWkvps1fksUvEm2LgpR8YoCNcGlaZ7ahdVeikJxopfqkNGCTKwbbDa0xO7fSURL6vdQVyIV GuTi0blZ33rKqdURzQq2jg4gdfXT03Bsy9zqMQoYYfC0ruwfmA3Q2Wv3Kzk1MktcCffSaNoSo8CWN y4UNc3bH35nfRVz+0Xp422bGg9aWyde/ukgOTbYJaqcJxxaseiFStDfHtsqM6ubv3zp929BzXsPKH a2Mn9KUzg+MJLWdetibJ938MrojI2GRnPohlrWp4y78KUX2QZUPjpiuJMZZfk7MER3nZCFgnHwLO+ E8rxPj9A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8mNN-000654-0z; Thu, 20 Aug 2020 15:21:13 +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 F3C16302526; Thu, 20 Aug 2020 17:21:11 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id DD97A21296C3B; Thu, 20 Aug 2020 17:21:11 +0200 (CEST) Date: Thu, 20 Aug 2020 17:21:11 +0200 From: peterz@infradead.org To: Josh Poimboeuf Cc: Brian Gerst , the arch/x86 maintainers , Linux Kernel Mailing List , Kyle Huey , Alexandre Chartre , Robert O'Callahan , "Paul E. McKenney" , Frederic Weisbecker , Paolo Bonzini , Sean Christopherson , Masami Hiramatsu , Petr Mladek , Steven Rostedt , Joel Fernandes , Boris Ostrovsky , Juergen Gross , Andy Lutomirski Subject: Re: [RFC][PATCH 4/7] x86/debug: Move historical SYSENTER junk into exc_debug_kernel() Message-ID: <20200820152111.GC1362448@hirez.programming.kicks-ass.net> References: <20200820103832.486877479@infradead.org> <20200820104905.294802764@infradead.org> <20200820150841.GB1362448@hirez.programming.kicks-ass.net> <20200820151659.b7q7hspe5zsf46eg@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200820151659.b7q7hspe5zsf46eg@treble> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 20, 2020 at 10:16:59AM -0500, Josh Poimboeuf wrote: > On Thu, Aug 20, 2020 at 05:08:41PM +0200, peterz@infradead.org wrote: > > On Thu, Aug 20, 2020 at 10:45:12AM -0400, Brian Gerst wrote: > > > On Thu, Aug 20, 2020 at 6:53 AM Peter Zijlstra wrote: > > > > > > > > > > > > Signed-off-by: Peter Zijlstra (Intel) > > > > --- > > > > arch/x86/kernel/traps.c | 24 ++++++++++++------------ > > > > 1 file changed, 12 insertions(+), 12 deletions(-) > > > > > > > > --- a/arch/x86/kernel/traps.c > > > > +++ b/arch/x86/kernel/traps.c > > > > @@ -820,18 +820,6 @@ static void handle_debug(struct pt_regs > > > > goto out; > > > > } > > > > > > > > - if (WARN_ON_ONCE((dr6 & DR_STEP) && !user_mode(regs))) { > > > > - /* > > > > - * Historical junk that used to handle SYSENTER single-stepping. > > > > - * This should be unreachable now. If we survive for a while > > > > - * without anyone hitting this warning, we'll turn this into > > > > - * an oops. > > > > - */ > > > > - tsk->thread.debugreg6 &= ~DR_STEP; > > > > - set_tsk_thread_flag(tsk, TIF_SINGLESTEP); > > > > - regs->flags &= ~X86_EFLAGS_TF; > > > > - } > > > > - > > > > si_code = get_si_code(tsk->thread.debugreg6); > > > > if (tsk->thread.debugreg6 & (DR_STEP | DR_TRAP_BITS) || user_icebp) > > > > send_sigtrap(regs, 0, si_code); > > > > @@ -874,6 +862,18 @@ static __always_inline void exc_debug_ke > > > > if (kprobe_debug_handler(regs)) > > > > goto out; > > > > > > > > + if (WARN_ON_ONCE(dr6 & DR_STEP)) { > > > > + /* > > > > + * Historical junk that used to handle SYSENTER single-stepping. > > > > + * This should be unreachable now. If we survive for a while > > > > + * without anyone hitting this warning, we'll turn this into > > > > + * an oops. > > > > + */ > > > > + dr6 &= ~DR_STEP; > > > > + set_thread_flag(TIF_SINGLESTEP); > > > > + regs->flags &= ~X86_EFLAGS_TF; > > > > + } > > > > + > > > > handle_debug(regs, dr6, false); > > > > > > > > out: > > > > > > Can this be removed or changed to a BUG()? The warning has been there > > > since 2016 and nobody has apparently complained about it. > > > > Something like: > > > > /* > > * The kernel doesn't do TF outside of Kprobes, so if we get > > * here, something's fishy. > > */ > > BUG_ON(dr6 & DR_STEP); > > > > ? > > What about kernel debuggers like kgdb and qemu gdb? qemu-gdb stub should eat the event before it lands in the guest, kgdb should eat it through the notifier. Thank you! Because that means I got the order wrong :/