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

[PATCH v2] x86/oprofile: remove compat accessors usage from backtrace


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Fri, 23 Apr 2021 16:37:55 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=zV2St4kky+YwNOuHc+Xr4vZeI7pvLrjmyZ2S6WWsBF0=; b=Arsl8yJqZQDPA/yE/ZIBvu5zZN/1q8SdM4Nk/XnV1IjAbHNFcEph8UKuLYmB2sC2tzYLWQy32FE2hwo93FVaqgfSTcctIEW92jlZ6zLnS6xsDVfdDT6Y4U5U7oMQcXKcBvhfpVqJ0VrdiGlxEstmkaDZermcYPO1Zm9/IVPni3GYXTIXf3ZoGOsM1dJkdvoRkljQH/j/N2VL8UnY3eHQkXBlKRzKI1cY/c5ISKpWDApnHrCqqIsj5OCTmtfX6ZmVMfaPgYYzUnSL81IBfHa4RHqFYF+nfhZF4VrywnkU04rr1SRSZpKCnoz3o3hlxQcMmXXbdz9EXml8m1gKxpM/Wg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QUxRFm7d5ePcDJgnq8Y9Giej7agqBuzmCMN0Rti3MBXn9XOICHpxV4f3GQG15UgIugRSNScbRwDWUsWIuajWMr/cmmPkL/lKcDs6z16IYMFGN+eY3yD3f7mIbUo3VQuHM54WOd7DovGn+1yVcfatRV5ZShjjop8vlSIQjhy3sEE/QW4ZeIxdoXQhhKkGCopXUZIqYgQHmfKxi0eCC8lydwrHSIQ6djb0MzXg9ESaT8bSpBecwTXwBoCyh4qXmJr24SMuAOX3YKOF0Pg1VHytiPkCMRGA/VfbNI6aQia9HyyBsFmYND1FWOgaupfd0ZFuB6zQkuA5XOYXWJF3UkexGw==
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 23 Apr 2021 14:38:16 +0000
  • Ironport-hdrordr: A9a23:CI57QaDDqy6tyc3lHekv55DYdL4zR+YMi2QD/UZ3VBBTb4ikh9 mj9c5rtiPcpRQwfDUbmd6GMLSdWn+0z/VIyKQYILvKZmPbkUSlIIxo5YHhhx3McheOkdJ1+r xnd8FFZOHYKFhhkILH5xOlGMwr29mN/MmT9IPj5lNMaS0vVK169Qd+DW+gcnFeYAVdH5I2GN 69y6N8ygaIQngcYsSlCnRtZYGqm/TxmJ3rehIcbiRXjTWmtj+w7a6/Lh7w5HgjeglSyrQv+3 WtqW3Ez5ik2svU9jbsk0va75FtlMH6yt1FJOHksLl2FgnR
  • Ironport-sdr: KWY7P3Imu+Cvo6UO6nA+Oxdftr2/3m4mDUfqJ95slGE8+emu/O8aHi0t4fxh22ZSjM6qFWk/hI SAIGyqsFZp33VxYp9qNSBGIRprhsmW9a0WKlST+sO6+6fecHrhElRHV8V0d0EswePIARDKoiTy 1RgWJBCYGJ7xNEqcGVfFxnTWauNmgWxPEF2XUshKcjjls+ti2gUkydlWt94iOuBMk/jwFzCeD0 /cr57CGheoprLZif+0zw5FTm8G5sP4IaoVUgW6U5CjHlQhp3q9m0W46eYZ0L/91HRgimf20CMJ LAQ=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Remove the unneeded usage of the compat layer to copy frame pointers
from guest address space. Instead just use raw_copy_from_guest.

While there drop the checks for the accessibility of one struct
frame_head beyond the current one: it's not clear why it's needed and
all the hypnoses point to dropping such check being harmless. The
worse that could happen is that a failure happens later if data past
frame_head is attempted to be fetched, albeit I'm not able to spot any
such access.

Also drop the explicit truncation of the head pointer in the 32bit
case as all callers already pass a zero extended value. The first
value being rsp from the guest registers, and further calls will use
ebp from frame_head_32bit struct.

Reported-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
Changes since v2:
 - Expand commit message.
---
 xen/arch/x86/oprofile/backtrace.c | 26 +++-----------------------
 1 file changed, 3 insertions(+), 23 deletions(-)

diff --git a/xen/arch/x86/oprofile/backtrace.c 
b/xen/arch/x86/oprofile/backtrace.c
index bd5d1b0f6ce..45f7fb65fa2 100644
--- a/xen/arch/x86/oprofile/backtrace.c
+++ b/xen/arch/x86/oprofile/backtrace.c
@@ -20,7 +20,6 @@ struct __packed frame_head {
     unsigned long ret;
 };
 typedef struct frame_head frame_head_t;
-DEFINE_XEN_GUEST_HANDLE(frame_head_t);
 
 struct __packed frame_head_32bit {
     uint32_t ebp;
@@ -43,7 +42,6 @@ dump_hypervisor_backtrace(struct vcpu *vcpu, const struct 
frame_head *head,
     return head->ebp;
 }
 
-#ifdef CONFIG_COMPAT
 static inline int is_32bit_vcpu(struct vcpu *vcpu)
 {
     if (is_hvm_vcpu(vcpu))
@@ -51,7 +49,6 @@ static inline int is_32bit_vcpu(struct vcpu *vcpu)
     else
         return is_pv_32bit_vcpu(vcpu);
 }
-#endif
 
 static struct frame_head *
 dump_guest_backtrace(struct vcpu *vcpu, const struct frame_head *head,
@@ -59,34 +56,17 @@ dump_guest_backtrace(struct vcpu *vcpu, const struct 
frame_head *head,
 {
     frame_head_t bufhead;
 
-#ifdef CONFIG_COMPAT
     if ( is_32bit_vcpu(vcpu) )
     {
-        DEFINE_COMPAT_HANDLE(frame_head32_t);
-        __compat_handle_const_frame_head32_t guest_head =
-            { .c = (unsigned long)head };
         frame_head32_t bufhead32;
 
-        /* Also check accessibility of one struct frame_head beyond */
-        if (!compat_handle_okay(guest_head, 2))
-            return 0;
-        if (__copy_from_compat(&bufhead32, guest_head, 1))
+        if (raw_copy_from_guest(&bufhead32, head, sizeof(bufhead32)))
             return 0;
         bufhead.ebp = (struct frame_head *)(unsigned long)bufhead32.ebp;
         bufhead.ret = bufhead32.ret;
     }
-    else
-#endif
-    {
-        XEN_GUEST_HANDLE_PARAM(const_frame_head_t) guest_head =
-            const_guest_handle_from_ptr(head, frame_head_t);
-
-        /* Also check accessibility of one struct frame_head beyond */
-        if (!guest_handle_okay(guest_head, 2))
-            return 0;
-        if (__copy_from_guest(&bufhead, guest_head, 1))
-            return 0;
-    }
+    else if (raw_copy_from_guest(&bufhead, head, sizeof(bufhead)))
+        return 0;
     
     if (!xenoprof_add_trace(vcpu, bufhead.ret, mode))
         return 0;
-- 
2.30.1




 


Rackspace

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