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-devel

[Xen-devel] [PATCH] mem_event: check capabilities only once

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] mem_event: check capabilities only once
From: Olaf Hering <olaf@xxxxxxxxx>
Date: Tue, 08 Nov 2011 18:33:51 +0100
Delivery-date: Tue, 08 Nov 2011 09:35:24 -0800
Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1320773643; l=2542; s=domk; d=aepfle.de; h=To:From:Date:Subject:Content-Transfer-Encoding:MIME-Version: Content-Type:X-RZG-CLASS-ID:X-RZG-AUTH; bh=07ZX4oKozbUdZuH2xUqI8eMeOaM=; b=LWzXRcH9DlSvg07DvgM5wJIG0qwmTaRHe7hIZ83HKxnybaSzakSB9boNgMN/4AGvZXa iztManv070hu6EfWAxyAYrlpQ7o+D/2hulbe2DXfQo3Xi7t1ALFIUHZqru2kxbAHPpZCB p/ODuFgjdjapQ26ZvDVVi2aRqTfn0a5KKqo=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.7.5
# HG changeset patch
# User Olaf Hering <olaf@xxxxxxxxx>
# Date 1320773602 -3600
# Node ID a7e49740fbfe3a4ec0a21186e2a4c579a30e0838
# Parent  c681dd5aecf3da3c6fd0e4d8a760a9cd18617033
mem_event: check capabilities only once

It is not required to check the system capabilities during every domctl.
Rearrange the code to check them only once.

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>

diff -r c681dd5aecf3 -r a7e49740fbfe xen/arch/x86/mm/mem_event.c
--- a/xen/arch/x86/mm/mem_event.c
+++ b/xen/arch/x86/mm/mem_event.c
@@ -253,32 +253,35 @@ int mem_event_domctl(struct domain *d, x
     case XEN_DOMCTL_MEM_EVENT_OP_PAGING:
     {
         struct mem_event_domain *med = &d->mem_paging;
-        struct p2m_domain *p2m = p2m_get_hostp2m(d);
-        rc = -ENODEV;
-        /* Only HAP is supported */
-        if ( !hap_enabled(d) )
-            break;
-
-        /* Currently only EPT is supported */
-        if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
-            break;
-
-        rc = -EXDEV;
-        /* Disallow paging in a PoD guest */
-        if ( p2m->pod.entry_count )
-            break;
+        rc = -EINVAL;
 
         switch( mec->op )
         {
         case XEN_DOMCTL_MEM_EVENT_OP_PAGING_ENABLE:
         {
+            struct p2m_domain *p2m = p2m_get_hostp2m(d);
+            rc = -ENODEV;
+            /* Only HAP is supported */
+            if ( !hap_enabled(d) )
+                break;
+
+            /* Currently only EPT is supported */
+            if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
+                break;
+
+            rc = -EXDEV;
+            /* Disallow paging in a PoD guest */
+            if ( p2m->pod.entry_count )
+                break;
+
             rc = mem_event_enable(d, mec, med);
         }
         break;
 
         case XEN_DOMCTL_MEM_EVENT_OP_PAGING_DISABLE:
         {
-            rc = mem_event_disable(med);
+            if ( med->ring_page )
+                rc = mem_event_disable(med);
         }
         break;
 
@@ -295,26 +298,29 @@ int mem_event_domctl(struct domain *d, x
     case XEN_DOMCTL_MEM_EVENT_OP_ACCESS: 
     {
         struct mem_event_domain *med = &d->mem_access;
-        rc = -ENODEV;
-        /* Only HAP is supported */
-        if ( !hap_enabled(d) )
-            break;
-
-        /* Currently only EPT is supported */
-        if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
-            break;
+        rc = -EINVAL;
 
         switch( mec->op )
         {
         case XEN_DOMCTL_MEM_EVENT_OP_ACCESS_ENABLE:
         {
+            rc = -ENODEV;
+            /* Only HAP is supported */
+            if ( !hap_enabled(d) )
+                break;
+
+            /* Currently only EPT is supported */
+            if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
+                break;
+
             rc = mem_event_enable(d, mec, med);
         }
         break;
 
         case XEN_DOMCTL_MEM_EVENT_OP_ACCESS_DISABLE:
         {
-            rc = mem_event_disable(&d->mem_access);
+            if ( med->ring_page )
+                rc = mem_event_disable(&d->mem_access);
         }
         break;
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] mem_event: check capabilities only once, Olaf Hering <=