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

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


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Fri, 23 Apr 2021 14:35:09 +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=cZe+cT31ELMpAI5wRhUxQJ32tZ0HEcPvLlt0pK2KRTk=; b=N5u4ZVhyGZzdstP/svaWUWS03zMFSXsIRe8KC3yPb4QuxPgSeJUMY1siZaiqX8pI5h6KYBWAZolo993SOie1uBmAVl4x0DidpIsvyn6i+J87EeSlSdnM+AujxQR3dbcJfn9bcJ3gtYPUMxaPc9xz8ln4Xue5b13HidNLoA3kXx3MxAiDQToBiuOXolvTOBtrOjzqYqmiotzsREzQ2oRpajMM+DtIWABBypIT1/UPY+5HOm+oivY37U255hx8HITwxhtmjciAax8PrDSzrxCFqHKpWrQyiaPw94VgnhB1z7czlNZD+6MWc+9jv7OitiftRDv0s6glvbVEkaMpGHwsSw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NEpLnxMYh6/SqAIc5xjHz6Lb8x+hbRsTcec2RoWLhX9Kh0v1Grl1R1IIdEYAEw/N0s4FeI7ocvunqB4YgaOrnYJey5tIsyfgjuR5c62qLnI+ENeEH9FPc6Dwh9YFMWXIsFkC6NgK2qhorASz+JThSvUpTT+2F65PPtc9GgEAMVVQw4WiV1J3VxKsvAAP3rpiLEiccG38aFADKLcTOBdErnnA7oAX5RNIpZz1EqKEEQB3M4Yv4X0II7XwZUXP6GRFl2nBkabqI2zhL8OPkfDN7yN92XehPykkcN6eao2ItobmcUouJTU9a8vt6wk0FU01uaJDml9ZyaqLAblKXdx+cA==
  • Authentication-results: esa3.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 12:36:07 +0000
  • Ironport-hdrordr: A9a23:x0sl/KFZrKi0mKgkpLqFs5HXdLJzesId70hD6mlaY3VuE/Cwvc aogfgdyFvIkz4XQn4tgpStP6OHTHPa+/dOkOwsFJ2lWxTrv3btEZF64eLZsl/dMgD36+I178 ddWodkDtmYNzdHpOLbxCX9LNo62tmA98mT6dv263t2VwllZ+VBwm5Ce2KmO3Z7TgVHGpY1fa D0jqArmxOadWkKdcP+P3EZXoH41rr2vaj7ah0LDQNP0njssRqU7tfBfSSw71M1SDVU2444/W zEiQDix6mqvv2h0DDd0nLe9Jhas8vaxtxPLsqKjcQeNzP24zzCWK1RH5uYsjgzoPKm9VYtl/ jBqxotJN5L8H/KcnqrrRaF4XiH7AoT
  • Ironport-sdr: 8Y1ulFjG6P7RoyBPt9OTBxbZMIz88jgJG+wLykEt2BDn6lY0LNXVmK8mpN1jWffJkDnyNSVGkf Zxo+uTuUGfNeSgRbNIvxvKAhfKo5gTvRYoJke5rBf7oAfn55ngMjZUZzHMwnc6d8nsFZ1HXD2x 3mav5d2v4XZtSczExCUWRiycsKBOLBT5QM7RLqKDDPNCr9sfbHD2wuTqhOyotocKsaYnVm5rKI 30r/NWtwR2GeutEgvCoYf9k4gcwT5PZTyDH8BMSmn1cGDQMBz6IILvKs4wJ5uV/ovwmjAszTg2 abk=
  • 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.

Reported-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Just build tested. Note sure I'm missing something, since using the
compat layer here was IMO much more complicated than just using the
raw accessors.
---
 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®.