From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78402C43461 for ; Wed, 2 Sep 2020 15:41:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 54A0920829 for ; Wed, 2 Sep 2020 15:41:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="g7CdvOFo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727915AbgIBPkz (ORCPT ); Wed, 2 Sep 2020 11:40:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727820AbgIBNrT (ORCPT ); Wed, 2 Sep 2020 09:47:19 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4013C061263 for ; Wed, 2 Sep 2020 06:38:44 -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=foTURamxtEN9X3i0RjfHeLtNA5SSGcsEY9liioF14Wk=; b=g7CdvOFoB5l+sMrGzEDaFenhFG abw+JZw+S+JydSBs+4XB9iwIDOuTD/hSh+YycwtjIcrJlVxvoTgJ+RsvT/gOGrZF8VAM8A0J2DD3n O5ABZZy3NFyrb2KbvYjPxk+EsRW0sOyPQe6uVy5qGTupytO/xWlK9zXsTvcRbZ2PfOsIRvBaCu9dz GVu/WA/uLIFzOU3GsWGmm4qJAnwxZblwhFshDOvuFCTW1+uR/0ITDbpYmIspBfhqK+wmUoN1n92wV +zMVQu0lFXTqGh//2OWPdOZke0d0b96Uffhn+OTDEn2zMcXG/3pO0Tgt/E+ZdglJnwf74fPaIlgRd +9MqbcaA==; 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 1kDSxp-0003ZQ-IE; Wed, 02 Sep 2020 13:38: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 CD1AA3059DD; Wed, 2 Sep 2020 15:38:11 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id B880E29A82C1F; Wed, 2 Sep 2020 15:38:11 +0200 (CEST) Message-ID: <20200902133200.786888252@infradead.org> User-Agent: quilt/0.66 Date: Wed, 02 Sep 2020 15:25:52 +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 , Daniel Thompson , Peter Zijlstra Subject: [PATCH 03/13] x86/debug: Sync BTF earlier References: <20200902132549.496605622@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 Move the BTF sync near the DR6 load, as this will be the only common code guaranteed to run on every #DB. Signed-off-by: Peter Zijlstra (Intel) Acked-by: Andy Lutomirski --- arch/x86/kernel/traps.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -749,6 +749,13 @@ static __always_inline unsigned long deb /* Filter out all the reserved bits which are preset to 1 */ dr6 &= ~DR6_RESERVED; + /* + * The SDM says "The processor clears the BTF flag when it + * generates a debug exception." Clear TIF_BLOCKSTEP to keep + * TIF_BLOCKSTEP in sync with the hardware BTF flag. + */ + clear_thread_flag(TIF_BLOCKSTEP); + return dr6; } @@ -783,13 +790,6 @@ static void handle_debug(struct pt_regs int si_code; /* - * The SDM says "The processor clears the BTF flag when it - * generates a debug exception." Clear TIF_BLOCKSTEP to keep - * TIF_BLOCKSTEP in sync with the hardware BTF flag. - */ - clear_thread_flag(TIF_BLOCKSTEP); - - /* * If DR6 is zero, no point in trying to handle it. The kernel is * not using INT1. */