From: Keir Fraser Subject: Re: [PATCH] x86: slightly improve stack trace on debug builds Date: Tue, 25 Sep 2012 18:06:17 +0100 Message-ID: References: <5061F5D7020000780009DC03@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5061F5D7020000780009DC03@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: xen-devel List-Id: xen-devel@lists.xenproject.org On 25/09/2012 17:20, "Jan Beulich" wrote: >> /* >> * If RIP is not valid hypervisor code then someone may have called into >> * oblivion. Peek to see if they left a return address at top of stack. >> */ >> addr = (!is_current_kernel_text(regs->eip) && >> (ESP_BEFORE_EXCEPTION(regs) >= low) && >> (ESP_BEFORE_EXCEPTION(regs) < high) && >> is_current_kernel_text(*ESP_BEFORE_EXCEPTION(regs))) >> ? *ESP_BEFORE_EXCEPTION(regs) : regs->eip; > > Checking against "low" is pointless, as that one is guaranteed > lower than the stack pointer (unless the stack pointer was within > 16 bytes from NULL). Checking against "high" is almost pointless > too, as there's only a very small range where %rsp could have > been to make that check fail (plus the 2 slots offset wouldn't be > right in this special case, i.e. we could get a false negative here), > and it wouldn't help preventing eventual #PF on the deref (since > "high" and the possible window above are on the same page). Ah of course low and high are derived from ESP_BEFORE_EXCEPTION... Okay, then my extra checks are quite pointless as you say. Please leave them out when you re-spin your patch. Thanks, Keir