All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Levon <levon@movementarian.org>
To: xen-devel@lists.xensource.com
Subject: [PATCH] shared_info size and padding fixes
Date: Wed, 9 Aug 2006 22:05:28 +0100	[thread overview]
Message-ID: <20060809210528.GA31314@totally.trollied.org> (raw)


# HG changeset patch
# User john.levon@sun.com
# Date 1155157246 -3600
# Node ID e24df0e22cdfe6daaa0d4d40c88e13c0427a1515
# Parent  b60ea69932b1a4d10c3aae945a1ce1aa160c689b
sizeof(shared_info_t) can change even in compatible hypervisor versions.
Add a clear warning about this, and fix the few places relying on it.
In addition, add some padding to arch_shared_info, to allow future
additions to the structure without breaking known offsets of members
following it in the shared info.

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

diff -r b60ea69932b1 -r e24df0e22cdf 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	Wed Aug 09 22:00:46 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 e24df0e22cdf 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	Wed Aug 09 22:00:46 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 e24df0e22cdf 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	Wed Aug 09 22:00:46 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 e24df0e22cdf xen/arch/ia64/asm-offsets.c
--- a/xen/arch/ia64/asm-offsets.c	Wed Aug 09 18:04:20 2006 +0100
+++ b/xen/arch/ia64/asm-offsets.c	Wed Aug 09 22:00:46 2006 +0100
@@ -31,7 +31,6 @@ void foo(void)
 	DEFINE(IA64_SWITCH_STACK_SIZE, sizeof (struct switch_stack));
 	DEFINE(IA64_CPU_SIZE, sizeof (struct cpuinfo_ia64));
 	DEFINE(UNW_FRAME_INFO_SIZE, sizeof (struct unw_frame_info));
-	DEFINE(SHARED_INFO_SIZE, sizeof (struct shared_info));
 
 	BLANK();
 	DEFINE(IA64_MCA_CPU_INIT_STACK_OFFSET, offsetof (struct ia64_mca_cpu, init_stack));
diff -r b60ea69932b1 -r e24df0e22cdf xen/include/public/arch-ia64.h
--- a/xen/include/public/arch-ia64.h	Wed Aug 09 18:04:20 2006 +0100
+++ b/xen/include/public/arch-ia64.h	Wed Aug 09 22:00:46 2006 +0100
@@ -297,6 +297,8 @@ struct arch_shared_info {
 
     /* Interrupt vector for event channel.  */
     int evtchn_vector;
+
+    uint64_t pad[32];
 };
 typedef struct arch_shared_info arch_shared_info_t;
 
diff -r b60ea69932b1 -r e24df0e22cdf xen/include/public/arch-powerpc.h
--- a/xen/include/public/arch-powerpc.h	Wed Aug 09 18:04:20 2006 +0100
+++ b/xen/include/public/arch-powerpc.h	Wed Aug 09 22:00:46 2006 +0100
@@ -107,6 +107,7 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_conte
 DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
 
 struct arch_shared_info {
+    uint64_t pad[32];
 };
 
 struct arch_vcpu_info {
diff -r b60ea69932b1 -r e24df0e22cdf xen/include/public/arch-x86_32.h
--- a/xen/include/public/arch-x86_32.h	Wed Aug 09 18:04:20 2006 +0100
+++ b/xen/include/public/arch-x86_32.h	Wed Aug 09 22:00:46 2006 +0100
@@ -191,6 +191,7 @@ struct arch_shared_info {
     /* Frame containing list of mfns containing list of mfns containing p2m. */
     xen_pfn_t     pfn_to_mfn_frame_list_list;
     unsigned long nmi_reason;
+    uint64_t pad[32];
 };
 typedef struct arch_shared_info arch_shared_info_t;
 
diff -r b60ea69932b1 -r e24df0e22cdf xen/include/public/arch-x86_64.h
--- a/xen/include/public/arch-x86_64.h	Wed Aug 09 18:04:20 2006 +0100
+++ b/xen/include/public/arch-x86_64.h	Wed Aug 09 22:00:46 2006 +0100
@@ -261,6 +261,7 @@ struct arch_shared_info {
     /* Frame containing list of mfns containing list of mfns containing p2m. */
     xen_pfn_t     pfn_to_mfn_frame_list_list;
     unsigned long nmi_reason;
+    uint64_t pad[32];
 };
 typedef struct arch_shared_info arch_shared_info_t;
 
diff -r b60ea69932b1 -r e24df0e22cdf 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	Wed Aug 09 22:00:46 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];

             reply	other threads:[~2006-08-09 21:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-09 21:05 John Levon [this message]
2006-08-10  8:03 ` [PATCH] shared_info size and padding fixes Tristan Gingold
2006-08-10  8:31   ` Jan Beulich
2006-08-10  8:42     ` Tristan Gingold
2006-08-10  8:33 ` Jan Beulich
2006-08-10 12:13   ` John Levon
2006-08-10 13:29     ` Keir Fraser
2006-08-10 13:34       ` John Levon
2006-08-11 13:30       ` John Levon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060809210528.GA31314@totally.trollied.org \
    --to=levon@movementarian.org \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.