From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 632EBC127 for ; Wed, 13 Mar 2024 14:50:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710341421; cv=none; b=dmb3m076m2ehh8neF6/90afaRVmtTU8KQPnvATAG8jLHuVle7fuZnb8oYYigJmQVPdR28FZ5Rh2U4pgyd7Jem+GMRv4V3CioMpkeeF8am2HSpd/Nv2dxQ+ssAx8VyTkYN/B/bRzstO7feP5hGweW4IF6GPPzJXXAWMEccyoZoqU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710341421; c=relaxed/simple; bh=HqJP2tJnnjFC5qUAsQlb005JFa4xVBygYkojNPTCVhg=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QHezoKk2UzT3qFndzFlhIVQgHqzoZQdRqY9MHpgAX5u4nZ1K1Kx1LBFPGCLa+1Qfr90n5WP4SgkWB3f/uQOFkZBGY8dGLcqG6iq1w2xj4fnkSCojU4iwjPq5bCThfHweEHSLCBKGfetUsmSK9JAbxKQaAxGri5f4j1fTHL3OlHs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F39E7C433C7; Wed, 13 Mar 2024 14:50:19 +0000 (UTC) Date: Wed, 13 Mar 2024 10:52:28 -0400 From: Steven Rostedt To: Tatsuyuki Ishi Cc: Peter Zijlstra , Indu Bhagat , linux-toolchains@vger.kernel.org, daandemeyer@meta.com, andrii@kernel.org, kris.van.hees@oracle.com, elena.zannoni@oracle.com, nick.alcock@oracle.com Subject: Re: [POC 5/5] x86_64: invoke SFrame based stack tracer for user space Message-ID: <20240313105228.2a6bbd2f@gandalf.local.home> In-Reply-To: <4CDF4EB4-C8AF-43DB-88AB-DB4BB76995F2@gmail.com> References: <20230501200410.3973453-1-indu.bhagat@oracle.com> <20230501200410.3973453-6-indu.bhagat@oracle.com> <20230502105353.GO1597476@hirez.programming.kicks-ass.net> <20230502112720.0c0d011b@gandalf.local.home> <4CDF4EB4-C8AF-43DB-88AB-DB4BB76995F2@gmail.com> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-toolchains@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, 13 Mar 2024 22:37:26 +0800 Tatsuyuki Ishi wrote: =20 >=20 > Hi, just discovered this idea while looking for options to implement > in-kernel unwinding, and in our case, for Wine applications where > recompiling existing proprietary applications with frame pointers is not > feasible. >=20 > I looked a bit more into how deferring work from NMI could work, but it > looks like this might not be easy for now. For normal IRQs, we can call > task_work_add and irqentry_exit will handle it for us. But task works are > not triggered for NMI, and that=E2=80=99s likely because unmasking NMI re= quires > IRET on x86, so if the NMI comes in during user mode, then we need to > forge a kernel IRET frame to do non-NMI work. >=20 > Does the forging stuff sound feasible? Suggestions are also welcome. The simple answer is to call irq_work. That will trigger an interrupt when irqs are enabled again (returning from NMI and just before entering user space). The return from the irq_work can do the proper ptrace path. -- Steve