WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] hvm_op: Clean up new mem_access and injec

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] hvm_op: Clean up new mem_access and inject_trap ops.
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Wed, 09 Feb 2011 06:50:31 -0800
Delivery-date: Wed, 09 Feb 2011 06:52:10 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir@xxxxxxx>
# Date 1297012877 0
# Node ID 93212e5c88f640ee4990db550fe9376eee86b47e
# Parent  1f588baf12424bf59c9fdf62c84ede45943693a2
hvm_op: Clean up new mem_access and inject_trap ops.

Firstly, they are only for use from privileged entities, so mark them
as usable only by code defining __XEN_TOOLS__.

Secondly, the check for must-not-operate-on-myself can be done more
cleanly.

Signed-off-by: Keir Fraser <keir@xxxxxxx>
---
 xen/arch/x86/hvm/hvm.c          |   21 ++++++++++++---------
 xen/include/public/hvm/hvm_op.h |    9 +++++++--
 2 files changed, 19 insertions(+), 11 deletions(-)

diff -r 1f588baf1242 -r 93212e5c88f6 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c    Sun Feb 06 17:10:31 2011 +0000
+++ b/xen/arch/x86/hvm/hvm.c    Sun Feb 06 17:21:17 2011 +0000
@@ -3542,12 +3542,13 @@ long do_hvm_op(unsigned long op, XEN_GUE
         if ( copy_from_guest(&a, arg, 1) )
             return -EFAULT;
 
-        if ( current->domain->domain_id == a.domid )
-            return -EPERM;
-
         rc = rcu_lock_target_domain_by_id(a.domid, &d);
         if ( rc != 0 )
             return rc;
+
+        rc = -EPERM;
+        if ( d == current->domain )
+            goto param_fail5;
 
         rc = -EINVAL;
         if ( !is_hvm_domain(d) )
@@ -3620,12 +3621,13 @@ long do_hvm_op(unsigned long op, XEN_GUE
         if ( copy_from_guest(&a, arg, 1) )
             return -EFAULT;
 
-        if ( current->domain->domain_id == a.domid )
-            return -EPERM;
-
         rc = rcu_lock_target_domain_by_id(a.domid, &d);
         if ( rc != 0 )
             return rc;
+
+        rc = -EPERM;
+        if ( d == current->domain )
+            goto param_fail6;
 
         rc = -EINVAL;
         if ( !is_hvm_domain(d) )
@@ -3721,12 +3723,13 @@ long do_hvm_op(unsigned long op, XEN_GUE
         if ( copy_from_guest(&tr, arg, 1 ) )
             return -EFAULT;
 
-        if ( current->domain->domain_id == tr.domid )
-            return -EPERM;
-
         rc = rcu_lock_target_domain_by_id(tr.domid, &d);
         if ( rc != 0 )
             return rc;
+
+        rc = -EPERM;
+        if ( d == current->domain )
+            goto param_fail8;
 
         rc = -EINVAL;
         if ( !is_hvm_domain(d) )
diff -r 1f588baf1242 -r 93212e5c88f6 xen/include/public/hvm/hvm_op.h
--- a/xen/include/public/hvm/hvm_op.h   Sun Feb 06 17:10:31 2011 +0000
+++ b/xen/include/public/hvm/hvm_op.h   Sun Feb 06 17:21:17 2011 +0000
@@ -158,6 +158,9 @@ typedef struct xen_hvm_xentrace xen_hvm_
 typedef struct xen_hvm_xentrace xen_hvm_xentrace_t;
 DEFINE_XEN_GUEST_HANDLE(xen_hvm_xentrace_t);
 
+/* Following tools-only interfaces may change in future. */
+#if defined(__XEN__) || defined(__XEN_TOOLS__)
+
 #define HVMOP_set_mem_access        12
 typedef enum {
     HVMMEM_access_n,
@@ -168,8 +171,8 @@ typedef enum {
     HVMMEM_access_rx,
     HVMMEM_access_wx,
     HVMMEM_access_rwx,
-    HVMMEM_access_rx2rw,       /* Page starts off as read-execute, but 
automatically change
-                               * to read-write on a write */
+    HVMMEM_access_rx2rw,       /* Page starts off as r-x, but automatically
+                                * change to r-w on a write */
     HVMMEM_access_default      /* Take the domain default */
 } hvmmem_access_t;
 /* Notify that a region of memory is to have specific access types */
@@ -222,4 +225,6 @@ typedef struct xen_hvm_inject_trap xen_h
 typedef struct xen_hvm_inject_trap xen_hvm_inject_trap_t;
 DEFINE_XEN_GUEST_HANDLE(xen_hvm_inject_trap_t);
 
+#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
+
 #endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] hvm_op: Clean up new mem_access and inject_trap ops., Xen patchbot-unstable <=