changeset:   24269:2cbc53a24683
user:        Olaf Hering <olaf@aepfle.de>
date:        Wed Nov 30 07:08:53 2011 -0800
files:       xen/arch/x86/hvm/hvm.c xen/arch/x86/mm/mem_event.c xen/arch/x86/mm/mem_sharing.c xen/arch/x86/mm/p2m.c xen/common/domain.c xen/include/xen/sched.h
description:
mem_event: move mem_event_domain out of struct domain

An upcoming change may increase the size of mem_event_domain. The result
is a build failure because struct domain gets larger than a page.
Allocate the room for the three mem_event_domain members at runtime.

v2:
 - remove mem_ prefix from members of new struct

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Keir Fraser <keir@xen.org>


---
 xen/arch/x86/hvm/hvm.c        |    4 ++--
 xen/arch/x86/mm/mem_event.c   |    6 +++---
 xen/arch/x86/mm/mem_sharing.c |    6 +++---
 xen/arch/x86/mm/p2m.c         |   18 +++++++++---------
 xen/common/domain.c           |    5 +++++
 xen/include/xen/sched.h       |   18 ++++++++++++------
 6 files changed, 34 insertions(+), 23 deletions(-)

Index: xen-4.1.3-testing/xen/arch/x86/hvm/hvm.c
===================================================================
--- xen-4.1.3-testing.orig/xen/arch/x86/hvm/hvm.c
+++ xen-4.1.3-testing/xen/arch/x86/hvm/hvm.c
@@ -3920,7 +3920,7 @@ static int hvm_memory_event_traps(long p
     if ( (p & HVMPME_onchangeonly) && (value == old) )
         return 1;
     
-    rc = mem_event_check_ring(d, &d->mem_access);
+    rc = mem_event_check_ring(d, &d->mem_event->access);
     if ( rc )
         return rc;
     
@@ -3943,7 +3943,7 @@ static int hvm_memory_event_traps(long p
         req.gla_valid = 1;
     }
     
-    mem_event_put_request(d, &d->mem_access, &req);
+    mem_event_put_request(d, &d->mem_event->access, &req);
     
     return 1;
 }
Index: xen-4.1.3-testing/xen/arch/x86/mm/mem_event.c
===================================================================
--- xen-4.1.3-testing.orig/xen/arch/x86/mm/mem_event.c
+++ xen-4.1.3-testing/xen/arch/x86/mm/mem_event.c
@@ -252,7 +252,7 @@ int mem_event_domctl(struct domain *d, x
     {
     case XEN_DOMCTL_MEM_EVENT_OP_PAGING:
     {
-        struct mem_event_domain *med = &d->mem_paging;
+        struct mem_event_domain *med = &d->mem_event->paging;
         rc = -EINVAL;
 
         switch( mec->op )
@@ -297,7 +297,7 @@ int mem_event_domctl(struct domain *d, x
 
     case XEN_DOMCTL_MEM_EVENT_OP_ACCESS: 
     {
-        struct mem_event_domain *med = &d->mem_access;
+        struct mem_event_domain *med = &d->mem_event->access;
         rc = -EINVAL;
 
         switch( mec->op )
@@ -320,7 +320,7 @@ int mem_event_domctl(struct domain *d, x
         case XEN_DOMCTL_MEM_EVENT_OP_ACCESS_DISABLE:
         {
             if ( med->ring_page )
-                rc = mem_event_disable(&d->mem_access);
+                rc = mem_event_disable(med);
         }
         break;
 
Index: xen-4.1.3-testing/xen/arch/x86/mm/mem_sharing.c
===================================================================
--- xen-4.1.3-testing.orig/xen/arch/x86/mm/mem_sharing.c
+++ xen-4.1.3-testing/xen/arch/x86/mm/mem_sharing.c
@@ -322,12 +322,12 @@ static struct page_info* mem_sharing_all
         req.flags |= MEM_EVENT_FLAG_VCPU_PAUSED;
     }
 
-    if(mem_event_check_ring(d, &d->mem_share)) return page;
+    if(mem_event_check_ring(d, &d->mem_event->share)) return page;
 
     req.gfn = gfn;
     req.p2mt = p2m_ram_shared;
     req.vcpu_id = v->vcpu_id;
-    mem_event_put_request(d, &d->mem_share, &req);
+    mem_event_put_request(d, &d->mem_event->share, &req);
 
     return page;
 }
@@ -342,7 +342,7 @@ int mem_sharing_sharing_resume(struct do
     mem_event_response_t rsp;
 
     /* Get request off the ring */
-    mem_event_get_response(&d->mem_share, &rsp);
+    mem_event_get_response(&d->mem_event->share, &rsp);
 
     /* Unpause domain/vcpu */
     if( rsp.flags & MEM_EVENT_FLAG_VCPU_PAUSED )
Index: xen-4.1.3-testing/xen/arch/x86/mm/p2m.c
===================================================================
--- xen-4.1.3-testing.orig/xen/arch/x86/mm/p2m.c
+++ xen-4.1.3-testing/xen/arch/x86/mm/p2m.c
@@ -2998,7 +2998,7 @@ void p2m_mem_paging_drop_page(struct p2m
     struct domain *d = p2m->domain;
 
     /* Check that there's space on the ring for this request */
-    if ( mem_event_check_ring(d, &d->mem_paging) == 0)
+    if ( mem_event_check_ring(d, &d->mem_event->paging) == 0)
     {
         /* Send release notification to pager */
         memset(&req, 0, sizeof(req));
@@ -3006,7 +3006,7 @@ void p2m_mem_paging_drop_page(struct p2m
         req.gfn = gfn;
         req.vcpu_id = v->vcpu_id;
 
-        mem_event_put_request(d, &d->mem_paging, &req);
+        mem_event_put_request(d, &d->mem_event->paging, &req);
     }
 }
 
@@ -3041,7 +3041,7 @@ void p2m_mem_paging_populate(struct p2m_
     struct domain *d = p2m->domain;
 
     /* Check that there's space on the ring for this request */
-    if ( mem_event_check_ring(d, &d->mem_paging) )
+    if ( mem_event_check_ring(d, &d->mem_event->paging) )
         return;
 
     memset(&req, 0, sizeof(req));
@@ -3072,7 +3072,7 @@ void p2m_mem_paging_populate(struct p2m_
     else if ( p2mt != p2m_ram_paging_out && p2mt != p2m_ram_paged )
     {
         /* gfn is already on its way back and vcpu is not paused */
-        mem_event_put_req_producers(&d->mem_paging);
+        mem_event_put_req_producers(&d->mem_event->paging);
         return;
     }
 
@@ -3081,7 +3081,7 @@ void p2m_mem_paging_populate(struct p2m_
     req.p2mt = p2mt;
     req.vcpu_id = v->vcpu_id;
 
-    mem_event_put_request(d, &d->mem_paging, &req);
+    mem_event_put_request(d, &d->mem_event->paging, &req);
 }
 
 /**
@@ -3159,7 +3159,7 @@ void p2m_mem_paging_resume(struct p2m_do
     mfn_t mfn;
 
     /* Pull the response off the ring */
-    mem_event_get_response(&d->mem_paging, &rsp);
+    mem_event_get_response(&d->mem_event->paging, &rsp);
 
     /* Fix p2m entry if the page was not dropped */
     if ( !(rsp.flags & MEM_EVENT_FLAG_DROP_PAGE) )
@@ -3212,7 +3212,7 @@ void p2m_mem_access_check(paddr_t gpa, b
     p2m_unlock(p2m);
 
     /* Otherwise, check if there is a memory event listener, and send the message along */
-    res = mem_event_check_ring(d, &d->mem_access);
+    res = mem_event_check_ring(d, &d->mem_event->access);
     if ( res < 0 ) 
     {
         /* No listener */
@@ -3256,7 +3256,7 @@ void p2m_mem_access_check(paddr_t gpa, b
     
     req.vcpu_id = v->vcpu_id;
 
-    mem_event_put_request(d, &d->mem_access, &req);
+    mem_event_put_request(d, &d->mem_event->access, &req);
 
     /* VCPU paused, mem event request sent */
 }
@@ -3266,7 +3266,7 @@ void p2m_mem_access_resume(struct p2m_do
     struct domain *d = p2m->domain;
     mem_event_response_t rsp;
 
-    mem_event_get_response(&d->mem_access, &rsp);
+    mem_event_get_response(&d->mem_event->access, &rsp);
 
     /* Unpause domain */
     if ( rsp.flags & MEM_EVENT_FLAG_VCPU_PAUSED )
Index: xen-4.1.3-testing/xen/common/domain.c
===================================================================
--- xen-4.1.3-testing.orig/xen/common/domain.c
+++ xen-4.1.3-testing/xen/common/domain.c
@@ -298,6 +298,10 @@ struct domain *domain_create(
         init_status |= INIT_gnttab;
 
         poolid = 0;
+
+        d->mem_event = xzalloc(struct mem_event_per_domain);
+        if ( !d->mem_event )
+            goto fail;
     }
 
     if ( arch_domain_create(d, domcr_flags) != 0 )
@@ -329,6 +333,7 @@ struct domain *domain_create(
  fail:
     d->is_dying = DOMDYING_dead;
     atomic_set(&d->refcnt, DOMAIN_DESTROYED);
+    xfree(d->mem_event);
     if ( init_status & INIT_arch )
         arch_domain_destroy(d);
     if ( init_status & INIT_gnttab )
Index: xen-4.1.3-testing/xen/include/xen/sched.h
===================================================================
--- xen-4.1.3-testing.orig/xen/include/xen/sched.h
+++ xen-4.1.3-testing/xen/include/xen/sched.h
@@ -201,6 +201,16 @@ struct mem_event_domain
     int xen_port;
 };
 
+struct mem_event_per_domain
+{
+    /* Memory sharing support */
+    struct mem_event_domain share;
+    /* Memory paging support */
+    struct mem_event_domain paging;
+    /* Memory access support */
+    struct mem_event_domain access;
+};
+
 struct domain
 {
     domid_t          domain_id;
@@ -327,12 +337,8 @@ struct domain
     /* Non-migratable and non-restoreable? */
     bool_t disable_migrate;
 
-    /* Memory sharing support */
-    struct mem_event_domain mem_share;
-    /* Memory paging support */
-    struct mem_event_domain mem_paging;
-    /* Memory access support */
-    struct mem_event_domain mem_access;
+    /* Various mem_events */
+    struct mem_event_per_domain *mem_event;
 
     /* Currently computed from union of all vcpu cpu-affinity masks. */
     nodemask_t node_affinity;
