Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5047791ybi; Sat, 20 Jul 2019 11:42:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0NjCezdED8baAk59BCVi3UfH+oWLLnHD2DIwV9ElzEkYS53XEOOe3lg2Ke3hnaQ0pvxXn X-Received: by 2002:a17:902:a607:: with SMTP id u7mr64814357plq.43.1563648165323; Sat, 20 Jul 2019 11:42:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563648165; cv=none; d=google.com; s=arc-20160816; b=Qt+uDJb2qsVxqD/5llCYYCbkw1bMp1NRhbWa0gHbZ2DzsDTSwKECHTeYyh0p3tbUso subnpfVpqiGNPzq9Gq+y/p/FNfu8U5BtqNWH5F2qjxtLxn8YxnDwE7zN3xlh02LvSOGK xaMwHz3cJhwcKKbmu7qMWE6qCvWaLLIq4UNXJ7iMYI/jC/dc63XKODsihxxO31vD18br AGLa5xZD11uXVQ0/j5TzolyQTzmfk4cewg8lnMtjEn4h65Gquyv7A/X3fZpXBunGEQbS w2tT7O3eUxbO7OyLOG5NMAB4dymCuNr+HjQmmldsgb2OLZ5qysWhW5n9mLsplTI16jth 5QJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=stUFLP6ZXQdZ4eFWOHqV+ChcoB0qddVj5vFraMbOcH8=; b=0BbdUf/NSkskkx97rKtI4ZGR5ohYAyYJ5xUSQV2rZZ46nHIn2hT8yizL+aihYaLxSg UNEZj08d+nNiSkhONksa2GVMspxugQWN0C+t2qyoRp3ZswbNTR1X1KBxjcbk1CCq+Wq2 ks3tsNEp9Dg+jKKxy6KcGgkonE0YwCz/sfeRFSRPuSBIHBH908EMEFLpAmwQ+M4+iAji CmUoAI8gp+Nbrv/lC3ua48SnzNTkAqMsnDz1TL7UgtnWTXiVV4ODXT1Gpm5z6dZK08F4 /IFkqqDFrt593x4fds8A+x0khHKDYo5EukFJATnQkUv1+u9T5jH8oLS6QW/CPAqwHFRA x3gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ryf+H3Yp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d34si30774603pla.283.2019.07.20.11.42.29; Sat, 20 Jul 2019 11:42:45 -0700 (PDT) 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=@kernel.org header.s=default header.b=ryf+H3Yp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728313AbfGTMuJ (ORCPT + 99 others); Sat, 20 Jul 2019 08:50:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:51118 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728031AbfGTMuJ (ORCPT ); Sat, 20 Jul 2019 08:50:09 -0400 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AA2E62189E for ; Sat, 20 Jul 2019 12:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563627007; bh=EdVU4Hw1eX974wMmWXWMUwiXMEahDa5Q3bAuMh5PE/s=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ryf+H3YpGpwK9vtFRssVPY3YvnZ4uDTxv5pbQ7PFpJ3hc7yJ1FLY+qiMQ8igaaPTR IhEpkCfoeh8LW+izuRamsqm9InHY6BsqjQ1ArNab7LSqCA12djmqLbVajN60SxszDy KaDGRL2ffi7qM55iJegPU6G/g/Bby3g37BmVJuPg= Received: by mail-wm1-f51.google.com with SMTP id p74so31047248wme.4 for ; Sat, 20 Jul 2019 05:50:07 -0700 (PDT) X-Gm-Message-State: APjAAAUDEt/8n9+LddOfw6YdX4RdcktUdi9w9AXMh8Pq3ifmQ2By62V1 LjBwdUpBo6b0OYXHE1VHJdV2/Ch7usd4TWXvRH96Hw== X-Received: by 2002:a1c:a942:: with SMTP id s63mr52788532wme.76.1563627006058; Sat, 20 Jul 2019 05:50:06 -0700 (PDT) MIME-Version: 1.0 References: <20190711114054.406765395@infradead.org> <4c71e14d-3a32-c3bb-8e3b-6e5100853192@oracle.com> <97cdd0af-95cc-2583-dc19-129b20809110@oracle.com> <98e20ed8-4032-09b5-e852-9f21df5c237c@etsukata.com> In-Reply-To: <98e20ed8-4032-09b5-e852-9f21df5c237c@etsukata.com> From: Andy Lutomirski Date: Sat, 20 Jul 2019 05:49:53 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 0/6] Tracing vs CR2 To: Eiichi Tsukata Cc: Andy Lutomirski , Vegard Nossum , Peter Zijlstra , Thomas Gleixner , Borislav Petkov , Ingo Molnar , Steven Rostedt , Linus Torvalds , linux_lkml_grp@oracle.com, "H. Peter Anvin" , Dave Hansen , Juergen Gross , LKML , He Zhe , Joel Fernandes 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 On Fri, Jul 19, 2019 at 8:59 PM Eiichi Tsukata wrote: > > > On 2019/07/19 5:27, Andy Lutomirski wrote: > > Hi all- > > > > I suspect that a bunch of the bugs you're all finding boil down to: > > > > - Nested debug exceptions could corrupt the outer exception's DR6. > > - Nested debug exceptions in which *both* exceptions came from the > > kernel were probably all kinds of buggy > > - Data breakpoints in bad places in the kernel were bad news > > > > Could you give this not-quite-finished series a try? > > > > https://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git/ > > > > Though I'm still trying to find out other cases(other areas which could > be buggy if we set hw breakpoints), as far as I tested, there is > no problem so far. > > If I understand correctly, the call trace and the dr6 value will be: > > ==== > > debug() // dr6: 0xffff4ff0, user_mode: 1 > TRACE_IRQS_OFF > arch_stack_user_walk() > debug() // dr6: 0xffff4ff1 == 0xffff4ff0 | 0xffff0ff1 ... (*) > do_debug() > WARN_ON_ONCE > do_debug() // dr6: 0xffff0ff0(cleared in the above do_debug()) The dr6 register will indeed be cleared like this, but the dr6 variable should still be 0xffff4ff0. > > (*) : > > * The Intel SDM says: > > * > > * Certain debug exceptions may clear bits 0-3. The remaining > > * contents of the DR6 register are never cleared by the > > * processor. To avoid confusion in identifying debug > > * exceptions, debug handlers should clear the register before > > * returning to the interrupted task. > > ==== > > Note: printk() in do_debug() can cause infinite loop(printk() -> > irq_disable() -> do_debug() -> printk() ...), so printk_deferred() > was preferable. > Shouldn't that be fixed with my patches? It should only be able to recurse two deep: do_debug() from user mode can indeed trip breakpoints, but the next do_debug() will clear DR7 in paranoid_entry.