xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Jacob Shin <jacob.shin@amd.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] x86/xenoprof: Fix kernel/user mode detection for HVM
Date: Fri, 12 Oct 2012 11:11:14 -0500	[thread overview]
Message-ID: <20121012161114.GA21661@jshin-Toonie> (raw)

x86/xenoprof: Fix kernel/user mode detection for HVM

While trying oprofile under Xen, I noticed that HVM passive domain's kernel 
addresses were showing up as user application. It turns out under HVM 
get_cpu_user_regs()->cs contains 0x0000beef.

Signed-off-by: Jacob Shin <jacob.shin@amd.com>

diff -r e0e1350dfe9b xen/arch/x86/oprofile/xenoprof.c
--- a/xen/arch/x86/oprofile/xenoprof.c	Thu Oct 11 15:57:00 2012 +0100
+++ b/xen/arch/x86/oprofile/xenoprof.c	Fri Oct 12 10:48:37 2012 -0500
@@ -81,7 +81,11 @@ int xenoprofile_get_mode(const struct vc
         return 2;
 
     if ( is_hvm_vcpu(v) )
-        return ((regs->cs & 3) != 3);
+    {
+        struct segment_register cs;
+        hvm_get_segment_register((struct vcpu *)v, x86_seg_cs, &cs);
+        return ((cs.sel & 3) != 3);
+    }
 
     return guest_kernel_mode(v, regs);  
 }

             reply	other threads:[~2012-10-12 16:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-12 16:11 Jacob Shin [this message]
2012-10-15 11:51 ` [PATCH, v2] x86/xenoprof: fix kernel/user mode detection for HVM Jan Beulich
2012-10-15 12:09   ` Keir Fraser

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=20121012161114.GA21661@jshin-Toonie \
    --to=jacob.shin@amd.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).