Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1144664pxa; Thu, 20 Aug 2020 03:54:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNlmm7PCXtRftAw0G3INqts4bidEDZf/LtmPO0T+Bwhy0FnGu+ihnyr1xnL7OqXoWuG83a X-Received: by 2002:a17:906:6146:: with SMTP id p6mr2704305ejl.211.1597920892933; Thu, 20 Aug 2020 03:54:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597920892; cv=none; d=google.com; s=arc-20160816; b=L716dhkVRLRPo5ZTKfRCHtEaPtCDPpLEBzS6Iw4XfXHYBsK7zaq3soF73YIT1myjZn o3qjD5sBde6Ag0efRUBvgjVwpY3Lw34ROtzIB4zp4declOPmfYdll5P2HRHVtLWjwJCl 3JioUfnAa5J8zGvMqylubK341qHtEa1UW+aMFoCGltGRk34M6SVrniqafIoVmjIQCYQE PgHZkqzNSq3SWKZUkrIC4xeAor50GhxjG8UtBFblNq4Uszq3s1xew7/d3O4q7PTc6A6y dc8eq6LTMmUq82T6ZX990PyIhcosh2CGXHqIOy7sw3nZTQYUlu7JHfRSbVzwGliGKzwv pshg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:subject:cc:to :from:date:user-agent:message-id:dkim-signature; bh=XScWW+VDxJfM3kZOnRAy8sSy8A+dFKOXsHQbSKIdGYU=; b=ix+NdZxZaGsbEseWoWd6jxkaI/eTEaW07uVOw6mWLD3+bw+us8V0rTm+1fdni8tPuE +x4AVtYhbEB51yd01Juq3oq+sjLnTdS9HxBcRYvofntjAm1xOPMBeNPuLAuMOhcs/TUE Y3baY/PUXfgiLtXRwCJFBZ4cFx17MZdZ1GQOSxkmjKOHKJyU1I3127WIr8WKEyrybkt+ cM1pduMdw2xddUJRCmojVAJfi750m9AtAJfULLgYVdRU6zpCwbtCch2T6dfz54bf3apD /nRw6DCsMsnURjEJhOkOYX6WAJ8tRW7+oWVv1HSBk9gERz/SQdaBubSjkMj+6ASpGJV3 IFHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=RjT7Y8jm; 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 q5si944490ejz.248.2020.08.20.03.54.28; Thu, 20 Aug 2020 03:54:52 -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=RjT7Y8jm; 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 S1730857AbgHTKxz (ORCPT + 99 others); Thu, 20 Aug 2020 06:53:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731220AbgHTKxh (ORCPT ); Thu, 20 Aug 2020 06:53:37 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79F11C061388 for ; Thu, 20 Aug 2020 03:53:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=XScWW+VDxJfM3kZOnRAy8sSy8A+dFKOXsHQbSKIdGYU=; b=RjT7Y8jm720oCr/g1lYdpD3QA1 +/0XGKh0HCOt96nSsLowTfWV1cQs/R0mKeVp5ElIi7FvVX8u/crvSGFPzsxSr6il32k0kj+lHSe1R /1EUfixm/E/2v+/wPnQcEXXPrU1kF0ymcjUuI4iIdNbLriaZ78/ektkic96heEugPV5GPoUef7PkL ifudZiLuahGwtmyBqITvAPj7edZjIRXnK5IyTmnDqyUqM1oJn2zkgZNt0qVoWhqavjOyZIXwbefFn DOnyPExROWs9iFzMVEP9gHcZuvJtKPEngk/nA/wG3ZiXH7fbrE0DXfqfIwb4CE033O5hvCvB8eel2 4Ime/BDg==; 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 1k8iBU-0007Xr-Ux; Thu, 20 Aug 2020 10:52:50 +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 5E0BA306099; Thu, 20 Aug 2020 12:52:36 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 492D32C38827E; Thu, 20 Aug 2020 12:52:36 +0200 (CEST) Message-ID: <20200820104905.294802764@infradead.org> User-Agent: quilt/0.66 Date: Thu, 20 Aug 2020 12:38:36 +0200 From: Peter Zijlstra To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, 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 , Brian Gerst , Andy Lutomirski , Josh Poimboeuf , Peter Zijlstra Subject: [RFC][PATCH 4/7] x86/debug: Move historical SYSENTER junk into exc_debug_kernel() References: <20200820103832.486877479@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: