1 /*
2  * arch/arm/monitor.c
3  *
4  * Arch-specific monitor_op domctl handler.
5  *
6  * Copyright (c) 2016 Tamas K Lengyel (tamas.lengyel@zentific.com)
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public
10  * License v2 as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public
18  * License along with this program; If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include <xen/vm_event.h>
22 #include <xen/monitor.h>
23 #include <asm/monitor.h>
24 #include <asm/vm_event.h>
25 #include <public/vm_event.h>
26 
arch_monitor_domctl_event(struct domain * d,struct xen_domctl_monitor_op * mop)27 int arch_monitor_domctl_event(struct domain *d,
28                               struct xen_domctl_monitor_op *mop)
29 {
30     struct arch_domain *ad = &d->arch;
31     bool requested_status = (XEN_DOMCTL_MONITOR_OP_ENABLE == mop->op);
32 
33     switch ( mop->event )
34     {
35     case XEN_DOMCTL_MONITOR_EVENT_PRIVILEGED_CALL:
36     {
37         bool old_status = ad->monitor.privileged_call_enabled;
38 
39         if ( unlikely(old_status == requested_status) )
40             return -EEXIST;
41 
42         domain_pause(d);
43         ad->monitor.privileged_call_enabled = requested_status;
44         domain_unpause(d);
45         break;
46     }
47 
48     default:
49         /*
50          * Should not be reached unless arch_monitor_get_capabilities() is
51          * not properly implemented.
52          */
53         ASSERT_UNREACHABLE();
54         return -EOPNOTSUPP;
55     }
56 
57     return 0;
58 }
59 
monitor_smc(void)60 int monitor_smc(void)
61 {
62     vm_event_request_t req = {
63         .reason = VM_EVENT_REASON_PRIVILEGED_CALL
64     };
65 
66     return monitor_traps(current, 1, &req);
67 }
68 
69 /*
70  * Local variables:
71  * mode: C
72  * c-file-style: "BSD"
73  * c-basic-offset: 4
74  * indent-tabs-mode: nil
75  * End:
76  */
77