From: "Jan Beulich" Subject: Re: [Patch v4 1/4] x86/stack: Refactor show_trace() Date: Wed, 20 Nov 2013 13:40:09 +0000 Message-ID: <528CC9C902000078001050CF@nat28.tlf.novell.com> References: <1384952982-1490-1-git-send-email-andrew.cooper3@citrix.com> <1384952982-1490-2-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Vj80o-0000IW-Ne for xen-devel@lists.xenproject.org; Wed, 20 Nov 2013 13:40:10 +0000 In-Reply-To: <1384952982-1490-2-git-send-email-andrew.cooper3@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: xen-devel , Tim Deegan List-Id: xen-devel@lists.xenproject.org >>> On 20.11.13 at 14:09, Andrew Cooper wrote: > +static void show_trace(const struct cpu_user_regs *regs) > +{ > + unsigned long *sp = ESP_BEFORE_EXCEPTION(regs); So you correctly made it a pointer here... > + > + printk("Xen call trace:\n"); > + > + /* > + * If RIP looks sensible, or the top of the stack doesn't, print RIP at > + * the top of the stack trace. > + */ > + if ( is_active_kernel_text(regs->rip) || > + !is_active_kernel_text(*sp) ) ... and de-reference it here ... > + printk(" [<%p>] %pS\n", _p(regs->rip), _p(regs->rip)); > + /* > + * Else RIP looks bad but the top of the stack looks good. Perhaps we > + * followed a wild function pointer? Lets assume the top of the stack is a > + * return address; print it and skip past so _show_trace() doesn't print > + * it again. > + */ > + else > + { > + printk(" [<%p>] %pS\n", _p(*sp), _p(*sp)); > + sp++; > + } > + > + _show_trace(*sp, regs->rbp); ... but then you now also de-reference it here? How did that end up producing sane stack dumps? Since one of the two _show_trace() variants wants a pointer here anyway, you would probably best switch its first argument and use the inverse casting in the other variant. Jan