Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp772220pxa; Wed, 19 Aug 2020 14:39:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQE5Msz7gnDHYUdhWZg7LMzOmzguJZVMxm/BeTzYi4iZdoIRi4r8q7UIlQQUhcmkbO91q3 X-Received: by 2002:a17:906:5f8f:: with SMTP id a15mr307807eju.291.1597873146085; Wed, 19 Aug 2020 14:39:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597873146; cv=none; d=google.com; s=arc-20160816; b=RsARJqmj65KO7aHFAhc1b7wh/0XMB2/VC3hJBI0SYhn9/W9v3VXw7MC3ef41eOZK3d XIMVAQWZ/3NEPJ4YEA3pXLokBdY0wPXqrQe5ulxsLcWYHe2lPBDNJP3uoKFJVOupRF5t BdxMdguazDcBE0w8c0MF23FS/E+SUwv5T6B9iBayS6mJv3gvwaGx3WdDVBQljoPSnGxP xyBlFF9/CWK3pboR46/38wpnjUzFdEpqx2I4QYRuwgEBg3AHGmpMFmlB4N5ci0+Wf8+X 7nKanmgk96VsYlSmQ6ypGErbRzBE0zEAVPoy6zgjYnOIUQEWE0Thrn8MWYSYgKrKfn5E SXtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=UaMTQzQR/2iD7LYG3TBB/MsacjZTmGqhqlIGfP/7qyQ=; b=n0sS/d7qRpaWKxOHTyZL2WytuzAnDpExIYZEIdt+Bb7qK+YLTIR/C6LQFrM52LDaew BKG9z0iW5G3sFR4GDQhTsfJVgNNE5/eKDqtZQIgLaWYaM9HnORrJh46ssPA5xP6BZe4J rdajZhqsYhA7XZoc+a9k+4AA18CZaiE1HoAlqjqFaUH8NqKIMdRfaOzMbuQKxYpi/XPX fAtH2SwDve3xRi5jcOGAwcbq7xG+2DRzJlfLQ067mtLP5fdK5zPLOIRhqC/GYa8UXyvX e1WRVx0JFPLH/sif+Vj9DwXOHoS3ztEP1PXkHGMb/s881ZEMI3Y7oIBf3toNkgd+dVUb k+Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=gVPk5wRJ; 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 e24si130539eds.212.2020.08.19.14.38.42; Wed, 19 Aug 2020 14:39:06 -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=gVPk5wRJ; 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 S1726700AbgHSVgR (ORCPT + 99 others); Wed, 19 Aug 2020 17:36:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726466AbgHSVgP (ORCPT ); Wed, 19 Aug 2020 17:36:15 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78ED3C061757 for ; Wed, 19 Aug 2020 14:36:15 -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=UaMTQzQR/2iD7LYG3TBB/MsacjZTmGqhqlIGfP/7qyQ=; b=gVPk5wRJ1OVpBU+UO4Nn99K2Py wKgQ8yNJ7e9p1Qs9SjO7zHIcoclTqoW4XqIwgbqx9e4oIGwtRUYeV71ZnUiER4vVB+PKimW0Oqxof x3nra9YZl7BkRxUku+kMz+cv3X2DzPkYPmEQ7wQDfQsThDkkpTNnyLrt/5qTKV8xsYcg0cX0BRykf hMoCE30BHD+mXBDJknaesJnDE+QhXTuTjoezkszkrpXVbItMlboKC0HGBKhA4e5HDiS6d+c+lZcMT 8o1Dia4T2to7XWZTKbWu29UCyZ4p85u2eka9AuqlO9k2TOZf3yyNV+m9w/NDnOoEu837bmg1jEJB5 hB1Ablfw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8Vk9-0001Za-Ei; Wed, 19 Aug 2020 21:35:38 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id D8EAD980C9E; Wed, 19 Aug 2020 23:35:34 +0200 (CEST) Date: Wed, 19 Aug 2020 23:35:34 +0200 From: Peter Zijlstra To: Kyle Huey Cc: Thomas Gleixner , Alexandre Chartre , Andy Lutomirski , Robert O'Callahan , LKML , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "Paul E. McKenney" , Frederic Weisbecker , Paolo Bonzini , Sean Christopherson , Masami Hiramatsu , Petr Mladek , Steven Rostedt , Joel Fernandes , Boris Ostrovsky , Juergen Gross , Brian Gerst , Mathieu Desnoyers , Josh Poimboeuf , Will Deacon Subject: Re: [REGRESSION 5.8] x86/entry: DR0 break-on-write not working Message-ID: <20200819213534.GQ3982@worktop.programming.kicks-ass.net> References: <20200819184149.GH2674@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 19, 2020 at 12:28:16PM -0700, Kyle Huey wrote: > > I'm guess that is not the expected outcome, is that the same failure you > > saw? > > Yes. Is status also 0x4d00 for you? Indeed. > The program is expected to complete with no assertions firing. When I comment out the break-on-exec test, the break-on-write test succeeds. When I add a few printk()'s to our #DB handler (6) the program will magically work again. I'm not much for ptrace(), but are we sure the test program is well behaved? The below also always works.. --- /* -*- Mode: C; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ #include #include #include #include #include #include #include #include #include #include #include /** * Print the printf-like arguments to stdout as atomic-ly as we can * manage. Async-signal-safe. Does not flush stdio buffers (doing so * isn't signal safe). */ __attribute__((format(printf, 1, 2))) inline static int atomic_printf( const char* fmt, ...) { va_list args; char buf[1024]; int len; va_start(args, fmt); len = vsnprintf(buf, sizeof(buf) - 1, fmt, args); va_end(args); return write(STDOUT_FILENO, buf, len); } /** * Write |str| on its own line to stdout as atomic-ly as we can * manage. Async-signal-safe. Does not flush stdio buffers (doing so * isn't signal safe). */ inline static int atomic_puts(const char* str) { return atomic_printf("%s\n", str); } inline static int check_cond(int cond) { if (!cond) { atomic_printf("FAILED: errno=%d (%s)\n", errno, strerror(errno)); } return cond; } #define test_assert(cond) assert("FAILED: !" && check_cond(cond)) #define NEW_VALUE 0xabcdef static void breakpoint(void) {} static char watch_var; int main(void) { pid_t child; int status; int pipe_fds[2]; test_assert(0 == pipe(pipe_fds)); if (0 == (child = fork())) { char ch; read(pipe_fds[0], &ch, 1); breakpoint(); watch_var = 1; return 77; } test_assert(0 == ptrace(PTRACE_ATTACH, child, NULL, NULL)); test_assert(child == waitpid(child, &status, 0)); test_assert(status == ((SIGSTOP << 8) | 0x7f)); test_assert(1 == write(pipe_fds[1], "x", 1)); test_assert(0 == ptrace(PTRACE_POKEUSER, child, (void*)offsetof(struct user, u_debugreg[0]), (void*)breakpoint)); test_assert(0 == ptrace(PTRACE_POKEUSER, child, (void*)offsetof(struct user, u_debugreg[1]), &watch_var)); test_assert(0 == ptrace(PTRACE_POKEUSER, child, (void*)offsetof(struct user, u_debugreg[7]), (void*)0x100005)); test_assert(0 == ptrace(PTRACE_CONT, child, NULL, NULL)); test_assert(child == waitpid(child, &status, 0)); test_assert(status == ((SIGTRAP << 8) | 0x7f)); test_assert(0x1 == ptrace(PTRACE_PEEKUSER, child, (void*)offsetof(struct user, u_debugreg[6]))); test_assert(0 == ptrace(PTRACE_CONT, child, NULL, NULL)); test_assert(child == waitpid(child, &status, 0)); test_assert(status == ((SIGTRAP << 8) | 0x7f)); test_assert(0x2 == ptrace(PTRACE_PEEKUSER, child, (void*)offsetof(struct user, u_debugreg[6]))); test_assert(0 == ptrace(PTRACE_DETACH, child, NULL, NULL)); test_assert(child == waitpid(child, &status, 0)); test_assert(WIFEXITED(status)); test_assert(WEXITSTATUS(status) == 77); atomic_puts("EXIT-SUCCESS"); return 0; }