From: Jacob Shin Subject: [PATCH] x86/xenoprof: Fix kernel/user mode detection for HVM Date: Fri, 12 Oct 2012 11:11:14 -0500 Message-ID: <20121012161114.GA21661@jshin-Toonie> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org 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 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); }