diff options
author | Jacob Shin <jacob.shin@amd.com> | 2012-10-29 09:01:14 +0100 |
---|---|---|
committer | Jacob Shin <jacob.shin@amd.com> | 2012-10-29 09:01:14 +0100 |
commit | 62881b57c2dc5884c09ac98c70a2ae6c748bb42d (patch) | |
tree | 2da1e4646c67b411b16428d85d5ba8b00341ee3e | |
parent | 5eaf06aeebbf72abf12cf0f3ec2a39c055df8d44 (diff) | |
download | xen-62881b57c2dc5884c09ac98c70a2ae6c748bb42d.tar.gz xen-62881b57c2dc5884c09ac98c70a2ae6c748bb42d.tar.bz2 xen-62881b57c2dc5884c09ac98c70a2ae6c748bb42d.zip |
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>
Don't cast away const-ness. Use SS instead of CS to determine ring.
Special-case real and protected mode.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 26055:14e32621dbaf
xen-unstable date: Mon Oct 15 13:04:51 UTC 2012
-rw-r--r-- | xen/arch/x86/oprofile/xenoprof.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/xen/arch/x86/oprofile/xenoprof.c b/xen/arch/x86/oprofile/xenoprof.c index 0c1c7ab031..b926b19e6d 100644 --- a/xen/arch/x86/oprofile/xenoprof.c +++ b/xen/arch/x86/oprofile/xenoprof.c @@ -82,10 +82,21 @@ int xenoprofile_get_mode(struct vcpu *v, struct cpu_user_regs * const regs) if ( !guest_mode(regs) ) return 2; - if ( is_hvm_vcpu(v) ) - return ((regs->cs & 3) != 3); - - return guest_kernel_mode(v, regs); + if ( !is_hvm_vcpu(v) ) + return guest_kernel_mode(v, regs); + + switch ( hvm_guest_x86_mode(v) ) + { + struct segment_register ss; + + case 0: /* real mode */ + return 1; + case 1: /* vm86 mode */ + return 0; + default: + hvm_get_segment_register(v, x86_seg_ss, &ss); + return (ss.sel & 3) != 3; + } } /* |