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

Re: [Xen-devel] [PATCH] shared_info size and padding fixes

To: Keir Fraser <Keir.Fraser@xxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] shared_info size and padding fixes
From: John Levon <levon@xxxxxxxxxxxxxxxxx>
Date: Fri, 11 Aug 2006 14:30:00 +0100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx, Jan Beulich <jbeulich@xxxxxxxxxx>
Delivery-date: Fri, 11 Aug 2006 06:30:26 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <C100F345.BBF%Keir.Fraser@xxxxxxxxxxxx>
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/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20060810121348.GA24928@xxxxxxxxxxxxxxxxxxxx> <C100F345.BBF%Keir.Fraser@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.9i
On Thu, Aug 10, 2006 at 02:29:25PM +0100, Keir Fraser wrote:

> Your patch looked fine, by the way, except that adding padding to every
> arch-specific portion of shared info seems unnecessary.

On the presumption that silence means no, here's a patch without the
padding. I sincerely hope whoever next changes these structures
remembers the padding!

regards
john

# HG changeset patch
# User levon@xxxxxxxxxxxxxxxxx
# Date 1155298435 -3600
# Node ID 43cc94ddfa1c31b1c0d288344ec3147fd61180e5
# Parent  b60ea69932b1a4d10c3aae945a1ce1aa160c689b
Add a clear warning that shared_info_t can change in size even in
compatible ABI revisions. Fix a few places relying on its size.

Signed-off-by: John Levon <john.levon@xxxxxxx>

diff -r b60ea69932b1 -r 43cc94ddfa1c tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c        Wed Aug 09 18:04:20 2006 +0100
+++ b/tools/libxc/xc_hvm_build.c        Fri Aug 11 13:13:55 2006 +0100
@@ -304,7 +304,7 @@ static int setup_guest(int xc_handle,
               xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE,
               shared_info_frame)) == 0 )
         goto error_out;
-    memset(shared_info, 0, sizeof(shared_info_t));
+    memset(shared_info, 0, PAGE_SIZE);
     /* Mask all upcalls... */
     for ( i = 0; i < MAX_VIRT_CPUS; i++ )
         shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
diff -r b60ea69932b1 -r 43cc94ddfa1c tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Wed Aug 09 18:04:20 2006 +0100
+++ b/tools/libxc/xc_linux_build.c      Fri Aug 11 13:13:55 2006 +0100
@@ -593,7 +593,7 @@ static int setup_guest(int xc_handle,
         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, shared_info_frame);
     printf("shared_info = %p, err=%s frame=%lx\n",
            shared_info, strerror (errno), shared_info_frame);
-    //memset(shared_info, 0, sizeof(shared_info_t));
+    //memset(shared_info, 0, PAGE_SIZE);
     /* Mask all upcalls... */
     for ( i = 0; i < MAX_VIRT_CPUS; i++ )
         shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
@@ -1064,7 +1064,7 @@ static int setup_guest(int xc_handle,
     /* shared_info page starts its life empty. */
     shared_info = xc_map_foreign_range(
         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, shared_info_frame);
-    memset(shared_info, 0, sizeof(shared_info_t));
+    memset(shared_info, 0, PAGE_SIZE);
     /* Mask all upcalls... */
     for ( i = 0; i < MAX_VIRT_CPUS; i++ )
         shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
diff -r b60ea69932b1 -r 43cc94ddfa1c tools/libxc/xc_linux_restore.c
--- a/tools/libxc/xc_linux_restore.c    Wed Aug 09 18:04:20 2006 +0100
+++ b/tools/libxc/xc_linux_restore.c    Fri Aug 11 13:13:55 2006 +0100
@@ -737,7 +737,7 @@ int xc_linux_restore(int xc_handle, int 
     /* Copy saved contents of shared-info page. No checking needed. */
     page = xc_map_foreign_range(
         xc_handle, dom, PAGE_SIZE, PROT_WRITE, shared_info_frame);
-    memcpy(page, shared_info, sizeof(shared_info_t));
+    memcpy(page, shared_info, PAGE_SIZE);
     munmap(page, PAGE_SIZE);
 
     /* Uncanonicalise the pfn-to-mfn table frame-number list. */
diff -r b60ea69932b1 -r 43cc94ddfa1c xen/include/public/xen.h
--- a/xen/include/public/xen.h  Wed Aug 09 18:04:20 2006 +0100
+++ b/xen/include/public/xen.h  Fri Aug 11 13:13:55 2006 +0100
@@ -376,7 +376,11 @@ typedef struct vcpu_info vcpu_info_t;
 
 /*
  * Xen/kernel shared data -- pointer provided in start_info.
- * NB. We expect that this struct is smaller than a page.
+ *
+ * This structure is defined to be both smaller than a page, and the
+ * only data on the page, but may vary in actual size even within
+ * compatible Xen versions; domains should never rely on the actual
+ * size of this structure.
  */
 struct shared_info {
     struct vcpu_info vcpu_info[MAX_VIRT_CPUS];

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