/root/src/xen/xen/include/asm/monitor.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * include/asm-x86/monitor.h |
3 | | * |
4 | | * Arch-specific monitor_op domctl handler. |
5 | | * |
6 | | * Copyright (c) 2015 Tamas K Lengyel (tamas@tklengyel.com) |
7 | | * Copyright (c) 2016, Bitdefender S.R.L. |
8 | | * |
9 | | * This program is free software; you can redistribute it and/or |
10 | | * modify it under the terms of the GNU General Public |
11 | | * License v2 as published by the Free Software Foundation. |
12 | | * |
13 | | * This program is distributed in the hope that it will be useful, |
14 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | | * General Public License for more details. |
17 | | * |
18 | | * You should have received a copy of the GNU General Public |
19 | | * License along with this program; If not, see <http://www.gnu.org/licenses/>. |
20 | | */ |
21 | | |
22 | | #ifndef __ASM_X86_MONITOR_H__ |
23 | | #define __ASM_X86_MONITOR_H__ |
24 | | |
25 | | #include <xen/sched.h> |
26 | | |
27 | 11.4k | #define monitor_ctrlreg_bitmask(ctrlreg_index) (1U << (ctrlreg_index)) |
28 | | |
29 | | struct monitor_msr_bitmap { |
30 | | DECLARE_BITMAP(low, 8192); |
31 | | DECLARE_BITMAP(hypervisor, 8192); |
32 | | DECLARE_BITMAP(high, 8192); |
33 | | }; |
34 | | |
35 | | static inline |
36 | | void arch_monitor_allow_userspace(struct domain *d, bool allow_userspace) |
37 | 0 | { |
38 | 0 | d->arch.monitor.guest_request_userspace_enabled = allow_userspace; |
39 | 0 | } Unexecuted instantiation: vmx.c:arch_monitor_allow_userspace Unexecuted instantiation: vmcs.c:arch_monitor_allow_userspace Unexecuted instantiation: hvm.c:arch_monitor_allow_userspace Unexecuted instantiation: vm_event.c:arch_monitor_allow_userspace Unexecuted instantiation: monitor.c:arch_monitor_allow_userspace |
40 | | |
41 | | static inline |
42 | | int arch_monitor_domctl_op(struct domain *d, struct xen_domctl_monitor_op *mop) |
43 | 0 | { |
44 | 0 | int rc = 0; |
45 | 0 |
|
46 | 0 | switch ( mop->op ) |
47 | 0 | { |
48 | 0 | case XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP: |
49 | 0 | domain_pause(d); |
50 | 0 | /* |
51 | 0 | * Enabling mem_access_emulate_each_rep without a vm_event subscriber |
52 | 0 | * is meaningless. |
53 | 0 | */ |
54 | 0 | if ( d->max_vcpus && d->vcpu[0] && d->vcpu[0]->arch.vm_event ) |
55 | 0 | d->arch.mem_access_emulate_each_rep = !!mop->event; |
56 | 0 | else |
57 | 0 | rc = -EINVAL; |
58 | 0 |
|
59 | 0 | domain_unpause(d); |
60 | 0 | break; |
61 | 0 |
|
62 | 0 | default: |
63 | 0 | rc = -EOPNOTSUPP; |
64 | 0 | } |
65 | 0 |
|
66 | 0 | return rc; |
67 | 0 | } Unexecuted instantiation: monitor.c:arch_monitor_domctl_op Unexecuted instantiation: vm_event.c:arch_monitor_domctl_op Unexecuted instantiation: hvm.c:arch_monitor_domctl_op Unexecuted instantiation: vmcs.c:arch_monitor_domctl_op Unexecuted instantiation: vmx.c:arch_monitor_domctl_op |
68 | | |
69 | | static inline uint32_t arch_monitor_get_capabilities(struct domain *d) |
70 | 0 | { |
71 | 0 | uint32_t capabilities = 0; |
72 | 0 |
|
73 | 0 | /* |
74 | 0 | * At the moment only Intel HVM domains are supported. However, event |
75 | 0 | * delivery could be extended to AMD and PV domains. |
76 | 0 | */ |
77 | 0 | if ( !is_hvm_domain(d) || !cpu_has_vmx ) |
78 | 0 | return capabilities; |
79 | 0 |
|
80 | 0 | capabilities = (1U << XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG) | |
81 | 0 | (1U << XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR) | |
82 | 0 | (1U << XEN_DOMCTL_MONITOR_EVENT_SOFTWARE_BREAKPOINT) | |
83 | 0 | (1U << XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST) | |
84 | 0 | (1U << XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION) | |
85 | 0 | (1U << XEN_DOMCTL_MONITOR_EVENT_CPUID) | |
86 | 0 | (1U << XEN_DOMCTL_MONITOR_EVENT_INTERRUPT) | |
87 | 0 | (1U << XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED); |
88 | 0 |
|
89 | 0 | /* Since we know this is on VMX, we can just call the hvm func */ |
90 | 0 | if ( hvm_is_singlestep_supported() ) |
91 | 0 | capabilities |= (1U << XEN_DOMCTL_MONITOR_EVENT_SINGLESTEP); |
92 | 0 |
|
93 | 0 | if ( hvm_funcs.set_descriptor_access_exiting ) |
94 | 0 | capabilities |= (1U << XEN_DOMCTL_MONITOR_EVENT_DESC_ACCESS); |
95 | 0 |
|
96 | 0 | return capabilities; |
97 | 0 | } Unexecuted instantiation: vmx.c:arch_monitor_get_capabilities Unexecuted instantiation: vmcs.c:arch_monitor_get_capabilities Unexecuted instantiation: hvm.c:arch_monitor_get_capabilities Unexecuted instantiation: vm_event.c:arch_monitor_get_capabilities Unexecuted instantiation: monitor.c:arch_monitor_get_capabilities |
98 | | |
99 | | int arch_monitor_domctl_event(struct domain *d, |
100 | | struct xen_domctl_monitor_op *mop); |
101 | | |
102 | | int arch_monitor_init_domain(struct domain *d); |
103 | | |
104 | | void arch_monitor_cleanup_domain(struct domain *d); |
105 | | |
106 | | bool monitored_msr(const struct domain *d, u32 msr); |
107 | | |
108 | | #endif /* __ASM_X86_MONITOR_H__ */ |