From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757985AbdLRDhv (ORCPT ); Sun, 17 Dec 2017 22:37:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:1209 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757825AbdLRDhu (ORCPT ); Sun, 17 Dec 2017 22:37:50 -0500 Date: Sun, 17 Dec 2017 21:37:49 -0600 From: Josh Poimboeuf To: Jiri Slaby Cc: mingo@redhat.com, linux-kernel@vger.kernel.org, Thomas Gleixner , "H. Peter Anvin" , x86@kernel.org Subject: Re: [PATCH 1/2] x86/stacktrace: do not fail when regs on stack for ORC Message-ID: <20171218033749.ihpwkjh7qfnilj4s@treble> References: <20171130080325.24785-1-jslaby@suse.cz> <20171130195710.cu2lsa47kwnow2hi@treble> <73526a6b-5083-78f1-8f76-d5f3ac52f958@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <73526a6b-5083-78f1-8f76-d5f3ac52f958@suse.cz> User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 18 Dec 2017 03:37:50 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 14, 2017 at 10:58:35PM +0100, Jiri Slaby wrote: > On 11/30/2017, 08:57 PM, Josh Poimboeuf wrote: > > So with those changes in mind, how about something like this (plus > > comments)? > > > > for (unwind_start(&state, task, NULL, NULL); !unwind_done(&state); > > unwind_next_frame(&state)) { > > > > regs = unwind_get_entry_regs(&state); > > if (regs) { > > if (user_mode(regs)) > > goto success; > > > > if (IS_ENABLED(CONFIG_FRAME_POINTER)) > > return -EINVAL; > > } > > > > addr = unwind_get_return_address(&state); > > if (!addr) > > return -EINVAL; > > > > if (save_stack_address(trace, addr, false)) > > return -EINVAL; > > } > > > > return -EINVAL; > > Kthreads and idle tasks hit this error as they have no user regs on the > stack obviously :). Doh, sorry, I forgot about that. > > So making it: > if (!(task->flags & (PF_KTHREAD | PF_IDLE))) > return -EINVAL; > > works, but is not reliable now. So I believe, we cannot live without > unwind->error to differentiate between "unwind_done() == true" because: > * full stack unwound and the stack type is set to UNKNOWN > * unwinding failed and the stack type is set to UNKNOWN > > Or perhaps introduce stack type BOTTOM, NONE, or NOMORE meaning the > bottom of the stacks reached? Yeah, we'll need something... I need to think about it a little more. -- Josh