ia64/xen-unstable

changeset 11090:0340e579f065

[XEN] Add a warning about changeable size of shared_info structure.

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>
author kaf24@localhost.localdomain
date Sat Aug 12 16:18:08 2006 +0100 (2006-08-12)
parents 9900884577de
children befab551b0e1
files tools/libxc/xc_hvm_build.c tools/libxc/xc_linux_build.c tools/libxc/xc_linux_restore.c xen/include/public/arch-ia64.h xen/include/public/arch-powerpc.h xen/include/public/arch-x86_32.h xen/include/public/arch-x86_64.h xen/include/public/xen.h
line diff
     1.1 --- a/tools/libxc/xc_hvm_build.c	Sat Aug 12 15:58:52 2006 +0100
     1.2 +++ b/tools/libxc/xc_hvm_build.c	Sat Aug 12 16:18:08 2006 +0100
     1.3 @@ -303,7 +303,7 @@ static int setup_guest(int xc_handle,
     1.4                xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE,
     1.5                shared_info_frame)) == 0 )
     1.6          goto error_out;
     1.7 -    memset(shared_info, 0, sizeof(shared_info_t));
     1.8 +    memset(shared_info, 0, PAGE_SIZE);
     1.9      /* Mask all upcalls... */
    1.10      for ( i = 0; i < MAX_VIRT_CPUS; i++ )
    1.11          shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
     2.1 --- a/tools/libxc/xc_linux_build.c	Sat Aug 12 15:58:52 2006 +0100
     2.2 +++ b/tools/libxc/xc_linux_build.c	Sat Aug 12 16:18:08 2006 +0100
     2.3 @@ -593,7 +593,7 @@ static int setup_guest(int xc_handle,
     2.4          xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, shared_info_frame);
     2.5      printf("shared_info = %p, err=%s frame=%lx\n",
     2.6             shared_info, strerror (errno), shared_info_frame);
     2.7 -    //memset(shared_info, 0, sizeof(shared_info_t));
     2.8 +    //memset(shared_info, 0, PAGE_SIZE);
     2.9      /* Mask all upcalls... */
    2.10      for ( i = 0; i < MAX_VIRT_CPUS; i++ )
    2.11          shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
    2.12 @@ -1064,7 +1064,7 @@ static int setup_guest(int xc_handle,
    2.13      /* shared_info page starts its life empty. */
    2.14      shared_info = xc_map_foreign_range(
    2.15          xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, shared_info_frame);
    2.16 -    memset(shared_info, 0, sizeof(shared_info_t));
    2.17 +    memset(shared_info, 0, PAGE_SIZE);
    2.18      /* Mask all upcalls... */
    2.19      for ( i = 0; i < MAX_VIRT_CPUS; i++ )
    2.20          shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
     3.1 --- a/tools/libxc/xc_linux_restore.c	Sat Aug 12 15:58:52 2006 +0100
     3.2 +++ b/tools/libxc/xc_linux_restore.c	Sat Aug 12 16:18:08 2006 +0100
     3.3 @@ -737,7 +737,7 @@ int xc_linux_restore(int xc_handle, int 
     3.4      /* Copy saved contents of shared-info page. No checking needed. */
     3.5      page = xc_map_foreign_range(
     3.6          xc_handle, dom, PAGE_SIZE, PROT_WRITE, shared_info_frame);
     3.7 -    memcpy(page, shared_info, sizeof(shared_info_t));
     3.8 +    memcpy(page, shared_info, PAGE_SIZE);
     3.9      munmap(page, PAGE_SIZE);
    3.10  
    3.11      /* Uncanonicalise the pfn-to-mfn table frame-number list. */
     4.1 --- a/xen/include/public/arch-ia64.h	Sat Aug 12 15:58:52 2006 +0100
     4.2 +++ b/xen/include/public/arch-ia64.h	Sat Aug 12 16:18:08 2006 +0100
     4.3 @@ -297,6 +297,8 @@ struct arch_shared_info {
     4.4  
     4.5      /* Interrupt vector for event channel.  */
     4.6      int evtchn_vector;
     4.7 +
     4.8 +    uint64_t pad[32];
     4.9  };
    4.10  typedef struct arch_shared_info arch_shared_info_t;
    4.11  
     5.1 --- a/xen/include/public/arch-powerpc.h	Sat Aug 12 15:58:52 2006 +0100
     5.2 +++ b/xen/include/public/arch-powerpc.h	Sat Aug 12 16:18:08 2006 +0100
     5.3 @@ -107,6 +107,7 @@ typedef struct vcpu_guest_context vcpu_g
     5.4  DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
     5.5  
     5.6  struct arch_shared_info {
     5.7 +    uint64_t pad[32];
     5.8  };
     5.9  
    5.10  struct arch_vcpu_info {
     6.1 --- a/xen/include/public/arch-x86_32.h	Sat Aug 12 15:58:52 2006 +0100
     6.2 +++ b/xen/include/public/arch-x86_32.h	Sat Aug 12 16:18:08 2006 +0100
     6.3 @@ -191,6 +191,7 @@ struct arch_shared_info {
     6.4      /* Frame containing list of mfns containing list of mfns containing p2m. */
     6.5      xen_pfn_t     pfn_to_mfn_frame_list_list;
     6.6      unsigned long nmi_reason;
     6.7 +    uint64_t pad[32];
     6.8  };
     6.9  typedef struct arch_shared_info arch_shared_info_t;
    6.10  
     7.1 --- a/xen/include/public/arch-x86_64.h	Sat Aug 12 15:58:52 2006 +0100
     7.2 +++ b/xen/include/public/arch-x86_64.h	Sat Aug 12 16:18:08 2006 +0100
     7.3 @@ -261,6 +261,7 @@ struct arch_shared_info {
     7.4      /* Frame containing list of mfns containing list of mfns containing p2m. */
     7.5      xen_pfn_t     pfn_to_mfn_frame_list_list;
     7.6      unsigned long nmi_reason;
     7.7 +    uint64_t pad[32];
     7.8  };
     7.9  typedef struct arch_shared_info arch_shared_info_t;
    7.10  
     8.1 --- a/xen/include/public/xen.h	Sat Aug 12 15:58:52 2006 +0100
     8.2 +++ b/xen/include/public/xen.h	Sat Aug 12 16:18:08 2006 +0100
     8.3 @@ -376,7 +376,11 @@ typedef struct vcpu_info vcpu_info_t;
     8.4  
     8.5  /*
     8.6   * Xen/kernel shared data -- pointer provided in start_info.
     8.7 - * NB. We expect that this struct is smaller than a page.
     8.8 + *
     8.9 + * This structure is defined to be both smaller than a page, and the
    8.10 + * only data on the shared page, but may vary in actual size even within
    8.11 + * compatible Xen versions; guests should not rely on the size
    8.12 + * of this structure remaining constant.
    8.13   */
    8.14  struct shared_info {
    8.15      struct vcpu_info vcpu_info[MAX_VIRT_CPUS];