From owner-freebsd-dtrace@FreeBSD.ORG Mon Feb 24 03:08:43 2014 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D1AC1711 for ; Mon, 24 Feb 2014 03:08:43 +0000 (UTC) Received: from mail-ig0-x235.google.com (mail-ig0-x235.google.com [IPv6:2607:f8b0:4001:c05::235]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 9994A15CE for ; Mon, 24 Feb 2014 03:08:43 +0000 (UTC) Received: by mail-ig0-f181.google.com with SMTP id y6so3781913igj.2 for ; Sun, 23 Feb 2014 19:08:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=rDOEl+4OXTZ0yA+RCqaOYSpIhXeOUzS70vRh8BQPlqQ=; b=GLj5d5wrJT+OK27tc8GBZo9ZcqBxh8l3g1iukmQLYArvcNxKsrpJTkmCV2vE83n+g9 eQHCTyazXkDrBM0evEk7kt3/y+Gf5tYxobCGQDG/zy4f45diKyonouKqpkuhkVJez8gy x3rzUzfmYGxozyW+daf4U9VnmeIgsCDh8YbOZEM9mubR5loqY2djwMK52F31gOnQJojQ wlRDsWNgibj2WhuXW9ngC7mQ+shjS8h5uqJUYTT4FKMeR9VIsOihIE4DYahWIkkRUvyc Vy6nSbI9yRt7kxbXuMf0OJvgadx9bfY6rGV/JwJgOcqxTVpZlAl8lAcltWeKuIFCGpc5 pKAA== X-Received: by 10.43.137.5 with SMTP id im5mr12532258icc.55.1393211323084; Sun, 23 Feb 2014 19:08:43 -0800 (PST) Received: from raichu (198-84-185-216.cpe.teksavvy.com. [198.84.185.216]) by mx.google.com with ESMTPSA id m4sm22102437ige.0.2014.02.23.19.08.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Feb 2014 19:08:42 -0800 (PST) Sender: Mark Johnston Date: Sun, 23 Feb 2014 22:08:37 -0500 From: Mark Johnston To: freebsd-dtrace@freebsd.org Subject: [patch] enable interrupts before calling fasttrap handlers Message-ID: <20140224030837.GA2720@raichu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.22 (2013-10-16) X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Feb 2014 03:08:43 -0000 Hello, The patch here fixes a problem I've run into while doing some work on fasttrap: http://people.freebsd.org/~markj/patches/breakpoint_intr_enable.diff Specifically, we currently call fasttrap_pid_probe() with interrupts disabled because FreeBSD handles breakpoints through an interrupt gate and doesn't enable interrupts before calling trap(). The patch changes trap() on i386 and amd64 to enable interrupts after hitting a breakpoint if the trap came from usermode. fasttrap should only handle traps from user mode anyway, and the user mode handler for breakpoints already enables interrupts immediately, so the change shouldn't have any effect for breakpoints unrelated to DTrace. The problem with leaving interrupts disabled is that some pid provider probes require DTrace to modify userland memory in fasttrap_pid_probe(), i.e. by calling proc_rwmem() or copyout(). It turns out that this can cause nasty deadlocks if another thread attempts a TLB shootdown with the same pmap as that of the traced process. There are probably other issues as well, but this is the one that I've run into. Would anyone be able to review and/or test this diff? Thanks, -Mark