@@ -40,6 +40,7 @@ obj-y += device.o
obj-y += decode.o
obj-y += processor.o
obj-y += smc.o
+obj-y += monitor.o
#obj-bin-y += ....o
@@ -22,7 +22,7 @@
#include <xen/errno.h>
#include <xen/guest_access.h>
#include <xen/sched.h>
-#include <xen/vm_event.h>
+#include <xen/monitor.h>
#include <xsm/xsm.h>
@@ -75,7 +75,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
case HVMOP_guest_request_vm_event:
if ( guest_handle_is_null(arg) )
- vm_event_monitor_guest_request();
+ monitor_guest_request();
else
rc = -EINVAL;
break;
new file mode 100644
@@ -0,0 +1,48 @@
+/*
+ * arch/arm/monitor.c
+ *
+ * Arch-specific monitor_op domctl handler.
+ *
+ * Copyright (c) 2015-2016 Tamas K Lengyel (tamas@tklengyel.com)
+ * Copyright (c) 2016, Bitdefender S.R.L.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License v2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <asm/vm_event.h>
+#include <public/vm_event.h>
+
+void monitor_guest_request(void)
+{
+ struct vcpu *curr = current;
+ struct domain *d = curr->domain;
+
+ if ( d->monitor.guest_request_enabled )
+ {
+ vm_event_request_t req = {
+ .reason = VM_EVENT_REASON_GUEST_REQUEST,
+ .vcpu_id = curr->vcpu_id,
+ };
+
+ vm_event_monitor_traps(curr, d->monitor.guest_request_sync, &req);
+ }
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
@@ -47,6 +47,7 @@ bool_t hvm_event_cr(unsigned int index, unsigned long value, unsigned long old)
.u.write_ctrlreg.old_value = old
};
+ vm_event_fill_regs(&req);
vm_event_monitor_traps(curr, sync, &req);
return 1;
}
@@ -68,6 +69,7 @@ void hvm_event_msr(unsigned int msr, uint64_t value)
.u.mov_to_msr.value = value,
};
+ vm_event_fill_regs(&req);
vm_event_monitor_traps(curr, 1, &req);
}
}
@@ -115,6 +117,7 @@ int hvm_event_breakpoint(unsigned long rip,
}
req.vcpu_id = curr->vcpu_id;
+ vm_event_fill_regs(&req);
return vm_event_monitor_traps(curr, 1, &req);
}
@@ -37,6 +37,7 @@
#include <xen/mem_access.h>
#include <xen/rangeset.h>
#include <xen/vm_event.h>
+#include <xen/monitor.h>
#include <asm/shadow.h>
#include <asm/hap.h>
#include <asm/current.h>
@@ -5695,7 +5696,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
case HVMOP_guest_request_vm_event:
if ( guest_handle_is_null(arg) )
- vm_event_monitor_guest_request();
+ monitor_guest_request();
else
rc = -EINVAL;
break;
@@ -20,6 +20,7 @@
*/
#include <asm/monitor.h>
+#include <asm/vm_event.h>
#include <public/vm_event.h>
int arch_monitor_domctl_event(struct domain *d,
@@ -136,6 +137,23 @@ int arch_monitor_domctl_event(struct domain *d,
return 0;
}
+void monitor_guest_request(void)
+{
+ struct vcpu *curr = current;
+ struct domain *d = curr->domain;
+
+ if ( d->monitor.guest_request_enabled )
+ {
+ vm_event_request_t req = {
+ .reason = VM_EVENT_REASON_GUEST_REQUEST,
+ .vcpu_id = curr->vcpu_id,
+ };
+
+ vm_event_fill_regs(&req);
+ vm_event_monitor_traps(curr, d->monitor.guest_request_sync, &req);
+ }
+}
+
/*
* Local variables:
* mode: C
@@ -818,28 +818,11 @@ int vm_event_monitor_traps(struct vcpu *v, uint8_t sync,
req->altp2m_idx = altp2m_vcpu_idx(v);
}
- vm_event_fill_regs(req);
vm_event_put_request(d, &d->vm_event->monitor, req);
return 1;
}
-void vm_event_monitor_guest_request(void)
-{
- struct vcpu *curr = current;
- struct domain *d = curr->domain;
-
- if ( d->monitor.guest_request_enabled )
- {
- vm_event_request_t req = {
- .reason = VM_EVENT_REASON_GUEST_REQUEST,
- .vcpu_id = curr->vcpu_id,
- };
-
- vm_event_monitor_traps(curr, d->monitor.guest_request_sync, &req);
- }
-}
-
/*
* Local variables:
* mode: C
@@ -26,5 +26,6 @@ struct domain;
struct xen_domctl_monitor_op;
int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *op);
+void monitor_guest_request(void);
#endif /* __XEN_MONITOR_H__ */
@@ -81,8 +81,6 @@ void vm_event_vcpu_unpause(struct vcpu *v);
int vm_event_monitor_traps(struct vcpu *v, uint8_t sync,
vm_event_request_t *req);
-void vm_event_monitor_guest_request(void);
-
#endif /* __VM_EVENT_H__ */
The prototype of vm_event_fill_regs will differ on x86 and ARM so in this patch we move components from common to arch-specific that use this function. As part of this patch we rename and relocate vm_event_monitor_guest_request as monitor_guest_request from vm_event to monitor. Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com> --- Cc: Stefano Stabellini <sstabellini@kernel.org> Cc: Julien Grall <julien.grall@arm.com> Cc: Jan Beulich <jbeulich@suse.com> Cc: Andrew Cooper <andrew.cooper3@citrix.com> Cc: Razvan Cojocaru <rcojocaru@bitdefender.com> --- xen/arch/arm/Makefile | 1 + xen/arch/arm/hvm.c | 4 ++-- xen/arch/arm/monitor.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/x86/hvm/event.c | 3 +++ xen/arch/x86/hvm/hvm.c | 3 ++- xen/arch/x86/monitor.c | 18 +++++++++++++++++ xen/common/vm_event.c | 17 ---------------- xen/include/xen/monitor.h | 1 + xen/include/xen/vm_event.h | 2 -- 9 files changed, 75 insertions(+), 22 deletions(-) create mode 100644 xen/arch/arm/monitor.c