diff options
author | Jacob Shin <jacob.shin@amd.com> | 2012-10-15 15:04:51 +0200 |
---|---|---|
committer | Jacob Shin <jacob.shin@amd.com> | 2012-10-15 15:04:51 +0200 |
commit | be522c694af0f39dcd22f01d3c9417ce38f97a99 (patch) | |
tree | 8f82726b8c15395f9a7ea392d2cee1b44ff5b81d /xen/arch/x86/oprofile | |
parent | cabea9d59f1783167a79fa7a550ced04b3506f3c (diff) | |
download | xen-be522c694af0f39dcd22f01d3c9417ce38f97a99.tar.gz xen-be522c694af0f39dcd22f01d3c9417ce38f97a99.tar.bz2 xen-be522c694af0f39dcd22f01d3c9417ce38f97a99.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>
Committed-by: Jan Beulich <jbeulich@suse.com>
Diffstat (limited to 'xen/arch/x86/oprofile')
-rw-r--r-- | xen/arch/x86/oprofile/xenoprof.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/xen/arch/x86/oprofile/xenoprof.c b/xen/arch/x86/oprofile/xenoprof.c index 160abac1bf..69476f2659 100644 --- a/xen/arch/x86/oprofile/xenoprof.c +++ b/xen/arch/x86/oprofile/xenoprof.c @@ -74,16 +74,26 @@ int compat_oprof_arch_counter(XEN_GUEST_HANDLE(void) arg) return 0; } -int xenoprofile_get_mode(const struct vcpu *v, - const struct cpu_user_regs *regs) +int xenoprofile_get_mode(struct vcpu *curr, const struct cpu_user_regs *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(curr) ) + return guest_kernel_mode(curr, regs); + + switch ( hvm_guest_x86_mode(curr) ) + { + struct segment_register ss; + + case 0: /* real mode */ + return 1; + case 1: /* vm86 mode */ + return 0; + default: + hvm_get_segment_register(curr, x86_seg_ss, &ss); + return (ss.sel & 3) != 3; + } } /* |