All of lore.kernel.org
 help / color / mirror / Atom feed
From: George Dunlap <George.Dunlap@eu.citrix.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] Fix to xenoprof in compat mode
Date: Thu, 21 Feb 2008 11:19:50 +0000	[thread overview]
Message-ID: <47BD5E56.7050003@eu.citrix.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 736 bytes --]

The attached patch fixes xenoprof in compat mode (32-bit guest on a 
64-bit hypervisor).  Although xen/common/xenoprof.c uses the compat 
structure sizes, xen/arch/x86/oprofile/xenoprof.c does not.  The 
structures look the same, but the compat mode structure is packed, 
whereas the non-compat version has 64-bit values 64-bit aligned.  The 
result was that the performance counters are not properly set, and no 
trace events are generated.

The attached patch adds a function called compat_oprof_arch_counter() in 
xen/arch/x86/oprofile/xenoprof.c, which uses the correctly-sized 
structure.  In xen/common/compat/xenoprof.c, it adds a #define such that 
the compat version of do_xenoprof_op() will call the proper version.

 -George

[-- Attachment #2: xenoprof-compat-fix.patch --]
[-- Type: text/x-patch, Size: 2203 bytes --]

diff -r 26d236e3a6ea xen/arch/x86/oprofile/xenoprof.c
--- a/xen/arch/x86/oprofile/xenoprof.c	Tue Feb 19 14:16:09 2008 +0000
+++ b/xen/arch/x86/oprofile/xenoprof.c	Thu Feb 21 11:12:04 2008 +0000
@@ -11,6 +11,9 @@
 #include <xen/guest_access.h>
 #include <xen/sched.h>
 #include <public/xenoprof.h>
+#ifdef CONFIG_COMPAT
+#include <compat/xenoprof.h>
+#endif
 #include <asm/hvm/support.h>
 
 #include "op_counter.h"
@@ -35,6 +38,28 @@ int xenoprof_arch_counter(XEN_GUEST_HAND
     return 0;
 }
 
+#ifdef CONFIG_COMPAT
+int compat_oprof_arch_counter(XEN_GUEST_HANDLE(void) arg)
+{
+    struct compat_oprof_counter counter;
+
+    if ( copy_from_guest(&counter, arg, 1) )
+        return -EFAULT;
+
+    if ( counter.ind > OP_MAX_COUNTER )
+        return -E2BIG;
+
+    counter_config[counter.ind].count     = counter.count;
+    counter_config[counter.ind].enabled   = counter.enabled;
+    counter_config[counter.ind].event     = counter.event;
+    counter_config[counter.ind].kernel    = counter.kernel;
+    counter_config[counter.ind].user      = counter.user;
+    counter_config[counter.ind].unit_mask = counter.unit_mask;
+
+    return 0;
+}
+#endif
+
 int xenoprofile_get_mode(struct vcpu *v, struct cpu_user_regs * const regs)
 {
     if ( !guest_mode(regs) )
diff -r 26d236e3a6ea xen/common/compat/xenoprof.c
--- a/xen/common/compat/xenoprof.c	Tue Feb 19 14:16:09 2008 +0000
+++ b/xen/common/compat/xenoprof.c	Tue Feb 19 14:44:38 2008 +0000
@@ -14,6 +14,7 @@ CHECK_oprof_init;
 
 #define xenoprof_get_buffer compat_oprof_get_buffer
 #define xenoprof_op_get_buffer compat_oprof_op_get_buffer
+#define xenoprof_arch_counter compat_oprof_arch_counter
 
 #define xen_domid_t domid_t
 #define compat_domid_t domid_compat_t
diff -r 26d236e3a6ea xen/include/asm-x86/xenoprof.h
--- a/xen/include/asm-x86/xenoprof.h	Tue Feb 19 14:16:09 2008 +0000
+++ b/xen/include/asm-x86/xenoprof.h	Tue Feb 19 14:47:34 2008 +0000
@@ -41,6 +41,7 @@ int xenoprof_arch_init(int *num_events, 
 #define xenoprof_arch_release_counters()        nmi_release_counters()
 
 int xenoprof_arch_counter(XEN_GUEST_HANDLE(void) arg);
+int compat_oprof_arch_counter(XEN_GUEST_HANDLE(void) arg);
 
 struct vcpu;
 struct cpu_user_regs;

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2008-02-21 11:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47BD5E56.7050003@eu.citrix.com \
    --to=george.dunlap@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.