All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/monitor: Disallow setting mem_access_emulate_each_rep when vm_event is NULL
@ 2016-04-08  7:10 Razvan Cojocaru
  2016-04-08  7:16 ` Razvan Cojocaru
  0 siblings, 1 reply; 4+ messages in thread
From: Razvan Cojocaru @ 2016-04-08  7:10 UTC (permalink / raw)
  To: xen-devel; +Cc: andrew.cooper3, keir, Razvan Cojocaru, jbeulich

It is meaningless (and potentially dangerous - see hvmemul_virtual_to_linear())
to set mem_access_emulate_each_rep before xc_monitor_enable() (which allocates
vcpu->arch.vm_event) has been called, so return an error from the
XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP hypercall when that is the case.

Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
---
 xen/include/asm-x86/monitor.h | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/xen/include/asm-x86/monitor.h b/xen/include/asm-x86/monitor.h
index 0954b59..0544836 100644
--- a/xen/include/asm-x86/monitor.h
+++ b/xen/include/asm-x86/monitor.h
@@ -35,11 +35,22 @@ int arch_monitor_domctl_op(struct domain *d, struct xen_domctl_monitor_op *mop)
     switch ( mop->op )
     {
     case XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP:
+    {
+        bool_t value = !!mop->event;
         domain_pause(d);
-        d->arch.mem_access_emulate_each_rep = !!mop->event;
+        /*
+         * Enabling emulate_each_rep without a vm_event subscriber
+         * is meaningless.
+         */
+        if ( !d->vcpu || !d->vcpu[0]->arch.vm_event )
+        {
+            domain_unpause(d);
+            return -EINVAL;
+        }
+        d->arch.mem_access_emulate_each_rep = value;
         domain_unpause(d);
         break;
-
+    }
     default:
         return -EOPNOTSUPP;
     }
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-04-08  8:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-08  7:10 [PATCH] x86/monitor: Disallow setting mem_access_emulate_each_rep when vm_event is NULL Razvan Cojocaru
2016-04-08  7:16 ` Razvan Cojocaru
2016-04-08  8:17   ` Andrew Cooper
2016-04-08  8:29     ` Razvan Cojocaru

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.