[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v3 2/2] x86/traps: widen condition for logging top-of-stack


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <JBeulich@xxxxxxxx>
  • Date: Mon, 15 Jul 2019 15:01:48 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=suse.com;dmarc=pass action=none header.from=suse.com;dkim=pass header.d=suse.com;arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t2cazIOyh7LE75lofnhmeJoVVzFQKabxaZbFI4PDVMw=; b=gkAjp7OAei9mrkmJBEp8NCm1OAv44w/BYudroEwIWbYBOvR22s8+bVl8U6HaZYfBx9BGOOEqe/WcBAYa7X0ccRilFcMIfmVDe3q4Ky9dTADo5v0QzLPTcgHHHsJ3oQLQG4LnoPcDVBY6EniEJnns5DJioXsLqsJyYs9HB7UMK0Oykm5ueXc83RatIR8TF01uphsMjz+FdubDC2rJB7E7ePWycAR/gJhc17vDwoRI491UIsrGFiOL8DdtASEEYuv9oDk0YH/0okE6skdCzgW34VVyGTVKuhAbugdqNY8AOWxNEehkblog155a4UfMHQeudBeKi268mGJBWxAILHn1kw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hofg3HTdXEFbsaPiGCcfJ0aZg00+43ksKZdHnx5GL2k1s3bt2+UMMQYG9U850Aglto+cXKO7HaKxyujiwtmLRKbdduOp5QkU4tvgdqIPpbDU1bkOvVu1DF2vei0gLXZB0YfMoA1v4vl6CLBBC55KhjDBkkz0nC3W7weDVGeSRQYE8SjaH00kzWfghdoFyi7tnPYsqibYHhoSGff0+gfe7wlCr5605vjR+i/IwE/D4B8NTwVsdehE9PXXGR0eJA4kivvlJT9kE7MMrQ47pYg3FMwN4Qd2phv8vN2kH/FUFUoCtt6ZtxJbLgRX/qXduy0lBih9xxHiRY6qvvVYIYha2g==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=JBeulich@xxxxxxxx;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Mon, 15 Jul 2019 15:02:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHVOx458UZbeIiSyUGxKqSxhGezcA==
  • Thread-topic: [PATCH v3 2/2] x86/traps: widen condition for logging top-of-stack

Despite -fno-omit-frame-pointer the compiler may omit the frame pointer,
often for relatively simple leaf functions. (To give a specific example,
the case I've run into this with is _pci_hide_device() and gcc 8.
Interestingly the even more simple neighboring iommu_has_feature() does
get a frame pointer set up, around just a single instruction. But this
may be a result of the size-of-asm() effects discussed elsewhere.)

Log the top-of-stack value if it looks valid _or_ if RIP looks invalid.

Also annotate all stack trace entries with a marker, to indicate their
origin:
R: register state
F: frame pointer based
S: raw stack contents

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v3: Tag stack entries consistently, but differently than in v2.
v2: Re-base over changes to earlier patch.

--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -433,7 +433,7 @@ static void _show_trace(unsigned long sp
      {
          addr = *stack++;
          if ( is_active_kernel_text(addr) )
-            printk("   [<%p>] %pS\n", _p(addr), _p(addr));
+            printk("   [<%p>] S %pS\n", _p(addr), _p(addr));
      }
  }
  
@@ -476,7 +476,7 @@ static void _show_trace(unsigned long sp
              addr  = frame[1];
          }
  
-        printk("   [<%p>] %pS\n", _p(addr), _p(addr));
+        printk("   [<%p>] F %pS\n", _p(addr), _p(addr));
  
          low = (unsigned long)&frame[2];
      }
@@ -505,21 +505,26 @@ static void show_trace(const struct cpu_
       */
      if ( is_active_kernel_text(regs->rip) ||
           !is_active_kernel_text(tos) )
-        printk("   [<%p>] %pS\n", _p(regs->rip), _p(regs->rip));
-    else if ( fault )
+        printk("   [<%p>] R %pS\n", _p(regs->rip), _p(regs->rip));
+
+    if ( fault )
      {
          printk("   [Fault on access]\n");
          return;
      }
+
      /*
-     * 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
+     * If RIP looks bad or the top of the stack looks good, log the top of
+     * stack as well.  Perhaps we followed a wild function pointer, or we're
+     * in a function without frame pointer, or in a function prologue before
+     * the frame pointer gets set up?  Let's assume the top of the stack is a
       * return address; print it and skip past so _show_trace() doesn't print
       * it again.
       */
-    else
+    if ( !is_active_kernel_text(regs->rip) ||
+         is_active_kernel_text(tos) )
      {
-        printk("   [<%p>] %pS\n", _p(tos), _p(tos));
+        printk("   [<%p>] S %pS\n", _p(tos), _p(tos));
          sp++;
      }
  

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.