Coverage Report

Created: 2017-10-25 09:10

/root/src/xen/xen/arch/x86/oprofile/xenoprof.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (C) 2005 Hewlett-Packard Co.
3
 * written by Aravind Menon & Jose Renato Santos
4
 *            (email: xenoprof@groups.hp.com)
5
 *
6
 * Copyright (c) 2006 Isaku Yamahata <yamahata at valinux co jp>
7
 *                    VA Linux Systems Japan K.K.
8
 * x86 specific part
9
 */
10
11
#include <xen/guest_access.h>
12
#include <xen/sched.h>
13
#include <xen/xenoprof.h>
14
#include <public/xenoprof.h>
15
#include <compat/xenoprof.h>
16
#include <asm/hvm/support.h>
17
18
#include "op_counter.h"
19
20
int xenoprof_arch_counter(XEN_GUEST_HANDLE_PARAM(void) arg)
21
0
{
22
0
    struct xenoprof_counter counter;
23
0
24
0
    if ( copy_from_guest(&counter, arg, 1) )
25
0
        return -EFAULT;
26
0
27
0
    if ( counter.ind >= OP_MAX_COUNTER )
28
0
        return -E2BIG;
29
0
30
0
    counter_config[counter.ind].count     = counter.count;
31
0
    counter_config[counter.ind].enabled   = counter.enabled;
32
0
    counter_config[counter.ind].event     = counter.event;
33
0
    counter_config[counter.ind].kernel    = counter.kernel;
34
0
    counter_config[counter.ind].user      = counter.user;
35
0
    counter_config[counter.ind].unit_mask = counter.unit_mask;
36
0
37
0
    return 0;
38
0
}
39
40
int xenoprof_arch_ibs_counter(XEN_GUEST_HANDLE_PARAM(void) arg)
41
0
{
42
0
    struct xenoprof_ibs_counter ibs_counter;
43
0
44
0
    if ( copy_from_guest(&ibs_counter, arg, 1) )
45
0
        return -EFAULT;
46
0
47
0
    ibs_config.op_enabled = ibs_counter.op_enabled;
48
0
    ibs_config.fetch_enabled = ibs_counter.fetch_enabled;
49
0
    ibs_config.max_cnt_fetch = ibs_counter.max_cnt_fetch;
50
0
    ibs_config.max_cnt_op = ibs_counter.max_cnt_op;
51
0
    ibs_config.rand_en = ibs_counter.rand_en;
52
0
    ibs_config.dispatched_ops = ibs_counter.dispatched_ops;
53
0
54
0
    return 0;
55
0
}
56
57
int compat_oprof_arch_counter(XEN_GUEST_HANDLE_PARAM(void) arg)
58
0
{
59
0
    struct compat_oprof_counter counter;
60
0
61
0
    if ( copy_from_guest(&counter, arg, 1) )
62
0
        return -EFAULT;
63
0
64
0
    if ( counter.ind >= OP_MAX_COUNTER )
65
0
        return -E2BIG;
66
0
67
0
    counter_config[counter.ind].count     = counter.count;
68
0
    counter_config[counter.ind].enabled   = counter.enabled;
69
0
    counter_config[counter.ind].event     = counter.event;
70
0
    counter_config[counter.ind].kernel    = counter.kernel;
71
0
    counter_config[counter.ind].user      = counter.user;
72
0
    counter_config[counter.ind].unit_mask = counter.unit_mask;
73
0
74
0
    return 0;
75
0
}
76
77
int xenoprofile_get_mode(struct vcpu *curr, const struct cpu_user_regs *regs)
78
0
{
79
0
    if ( !guest_mode(regs) )
80
0
        return 2;
81
0
82
0
    if ( !is_hvm_vcpu(curr) )
83
0
        return guest_kernel_mode(curr, regs);
84
0
85
0
    switch ( hvm_guest_x86_mode(curr) )
86
0
    {
87
0
    case 0: /* real mode */
88
0
        return 1;
89
0
    case 1: /* vm86 mode */
90
0
        return 0;
91
0
    default:
92
0
        return hvm_get_cpl(curr) != 3;
93
0
    }
94
0
}
95
96
/*
97
 * Local variables:
98
 * mode: C
99
 * c-file-style: "BSD"
100
 * c-basic-offset: 4
101
 * tab-width: 4
102
 * indent-tabs-mode: nil
103
 * End:
104
 */