ia64/xen-unstable

changeset 9103:4dd325c1d87d

A few changes to the new 'guest handle' interface:

DEFINE_GUEST_HANDLE -> define_guest_handle

GUEST_HANDLE -> guest_handle

New __define_guest_handle allows handle name different from
encapsulated type's name (useful for awkward typenames).

Got rid of xen_ulong, now use guest_handle(ulong).

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Mar 02 14:43:24 2006 +0100 (2006-03-02)
parents e639d53330ba
children cfbf7332d616
files xen/arch/x86/mm.c xen/arch/x86/x86_32/mm.c xen/arch/x86/x86_64/mm.c xen/common/memory.c xen/include/asm-x86/mm.h xen/include/public/memory.h xen/include/public/xen.h xen/include/xen/guest_access.h xen/include/xen/sched.h
line diff
     1.1 --- a/xen/arch/x86/mm.c	Thu Mar 02 11:41:48 2006 +0100
     1.2 +++ b/xen/arch/x86/mm.c	Thu Mar 02 14:43:24 2006 +0100
     1.3 @@ -2788,7 +2788,7 @@ long do_update_descriptor(u64 pa, u64 de
     1.4  }
     1.5  
     1.6  
     1.7 -long arch_memory_op(int op, GUEST_HANDLE(void) arg)
     1.8 +long arch_memory_op(int op, guest_handle(void) arg)
     1.9  {
    1.10      struct xen_reserved_phys_area xrpa;
    1.11      unsigned long pfn;
     2.1 --- a/xen/arch/x86/x86_32/mm.c	Thu Mar 02 11:41:48 2006 +0100
     2.2 +++ b/xen/arch/x86/x86_32/mm.c	Thu Mar 02 14:43:24 2006 +0100
     2.3 @@ -192,7 +192,7 @@ void subarch_init_memory(struct domain *
     2.4      }
     2.5  }
     2.6  
     2.7 -long subarch_memory_op(int op, GUEST_HANDLE(void) arg)
     2.8 +long subarch_memory_op(int op, guest_handle(void) arg)
     2.9  {
    2.10      struct xen_machphys_mfn_list xmml;
    2.11      unsigned long mfn;
     3.1 --- a/xen/arch/x86/x86_64/mm.c	Thu Mar 02 11:41:48 2006 +0100
     3.2 +++ b/xen/arch/x86/x86_64/mm.c	Thu Mar 02 14:43:24 2006 +0100
     3.3 @@ -183,7 +183,7 @@ void subarch_init_memory(struct domain *
     3.4      }
     3.5  }
     3.6  
     3.7 -long subarch_memory_op(int op, GUEST_HANDLE(void) arg)
     3.8 +long subarch_memory_op(int op, guest_handle(void) arg)
     3.9  {
    3.10      struct xen_machphys_mfn_list xmml;
    3.11      l3_pgentry_t l3e;
     4.1 --- a/xen/common/memory.c	Thu Mar 02 11:41:48 2006 +0100
     4.2 +++ b/xen/common/memory.c	Thu Mar 02 14:43:24 2006 +0100
     4.3 @@ -31,7 +31,7 @@
     4.4  static long
     4.5  increase_reservation(
     4.6      struct domain *d, 
     4.7 -    GUEST_HANDLE(xen_ulong) extent_list,
     4.8 +    guest_handle(ulong) extent_list,
     4.9      unsigned int   nr_extents,
    4.10      unsigned int   extent_order,
    4.11      unsigned int   flags,
    4.12 @@ -80,7 +80,7 @@ increase_reservation(
    4.13  static long
    4.14  populate_physmap(
    4.15      struct domain *d, 
    4.16 -    GUEST_HANDLE(xen_ulong) extent_list,
    4.17 +    guest_handle(ulong) extent_list,
    4.18      unsigned int  nr_extents,
    4.19      unsigned int  extent_order,
    4.20      unsigned int  flags,
    4.21 @@ -141,7 +141,7 @@ populate_physmap(
    4.22  static long
    4.23  decrease_reservation(
    4.24      struct domain *d,
    4.25 -    GUEST_HANDLE(xen_ulong) extent_list,
    4.26 +    guest_handle(ulong) extent_list,
    4.27      unsigned int   nr_extents,
    4.28      unsigned int   extent_order,
    4.29      unsigned int   flags,
    4.30 @@ -198,7 +198,7 @@ decrease_reservation(
    4.31  
    4.32  static long
    4.33  translate_gpfn_list(
    4.34 -    GUEST_HANDLE(xen_translate_gpfn_list_t) uop, unsigned long *progress)
    4.35 +    guest_handle(xen_translate_gpfn_list_t) uop, unsigned long *progress)
    4.36  {
    4.37      struct xen_translate_gpfn_list op;
    4.38      unsigned long i, gpfn, mfn;
    4.39 @@ -257,7 +257,7 @@ translate_gpfn_list(
    4.40      return 0;
    4.41  }
    4.42  
    4.43 -long do_memory_op(unsigned long cmd, GUEST_HANDLE(void) arg)
    4.44 +long do_memory_op(unsigned long cmd, guest_handle(void) arg)
    4.45  {
    4.46      struct domain *d;
    4.47      int rc, op, flags = 0, preempted = 0;
     5.1 --- a/xen/include/asm-x86/mm.h	Thu Mar 02 11:41:48 2006 +0100
     5.2 +++ b/xen/include/asm-x86/mm.h	Thu Mar 02 14:43:24 2006 +0100
     5.3 @@ -380,7 +380,7 @@ void propagate_page_fault(unsigned long 
     5.4  int __sync_lazy_execstate(void);
     5.5  
     5.6  /* Arch-specific portion of memory_op hypercall. */
     5.7 -long arch_memory_op(int op, GUEST_HANDLE(void) arg);
     5.8 -long subarch_memory_op(int op, GUEST_HANDLE(void) arg);
     5.9 +long arch_memory_op(int op, guest_handle(void) arg);
    5.10 +long subarch_memory_op(int op, guest_handle(void) arg);
    5.11  
    5.12  #endif /* __ASM_X86_MM_H__ */
     6.1 --- a/xen/include/public/memory.h	Thu Mar 02 11:41:48 2006 +0100
     6.2 +++ b/xen/include/public/memory.h	Thu Mar 02 14:43:24 2006 +0100
     6.3 @@ -29,7 +29,7 @@ typedef struct xen_memory_reservation {
     6.4       *   OUT: GMFN bases of extents that were allocated
     6.5       *   (NB. This command also updates the mach_to_phys translation table)
     6.6       */
     6.7 -    GUEST_HANDLE(xen_ulong) extent_start;
     6.8 +    guest_handle(ulong) extent_start;
     6.9  
    6.10      /* Number of extents, and size/alignment of each (2^extent_order pages). */
    6.11      unsigned long  nr_extents;
    6.12 @@ -50,7 +50,7 @@ typedef struct xen_memory_reservation {
    6.13      domid_t        domid;
    6.14  
    6.15  } xen_memory_reservation_t;
    6.16 -DEFINE_GUEST_HANDLE(xen_memory_reservation_t);
    6.17 +define_guest_handle(xen_memory_reservation_t);
    6.18  
    6.19  /*
    6.20   * Returns the maximum machine frame number of mapped RAM in this system.
    6.21 @@ -86,7 +86,7 @@ typedef struct xen_machphys_mfn_list {
    6.22       * any large discontiguities in the machine address space, 2MB gaps in
    6.23       * the machphys table will be represented by an MFN base of zero.
    6.24       */
    6.25 -    GUEST_HANDLE(xen_ulong) extent_start;
    6.26 +    guest_handle(ulong) extent_start;
    6.27  
    6.28      /*
    6.29       * Number of extents written to the above array. This will be smaller
    6.30 @@ -94,7 +94,7 @@ typedef struct xen_machphys_mfn_list {
    6.31       */
    6.32      unsigned int nr_extents;
    6.33  } xen_machphys_mfn_list_t;
    6.34 -DEFINE_GUEST_HANDLE(xen_machphys_mfn_list_t);
    6.35 +define_guest_handle(xen_machphys_mfn_list_t);
    6.36  
    6.37  /*
    6.38   * Returns the base and size of the specified reserved 'RAM hole' in the
    6.39 @@ -115,7 +115,7 @@ typedef struct xen_reserved_phys_area {
    6.40      /* Base and size of the specified reserved area. */
    6.41      unsigned long first_gpfn, nr_gpfns;
    6.42  } xen_reserved_phys_area_t;
    6.43 -DEFINE_GUEST_HANDLE(xen_reserved_phys_area_t);
    6.44 +define_guest_handle(xen_reserved_phys_area_t);
    6.45  
    6.46  /*
    6.47   * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error
    6.48 @@ -130,15 +130,15 @@ typedef struct xen_translate_gpfn_list {
    6.49      unsigned long nr_gpfns;
    6.50  
    6.51      /* List of GPFNs to translate. */
    6.52 -    GUEST_HANDLE(xen_ulong) gpfn_list;
    6.53 +    guest_handle(ulong) gpfn_list;
    6.54  
    6.55      /*
    6.56       * Output list to contain MFN translations. May be the same as the input
    6.57       * list (in which case each input GPFN is overwritten with the output MFN).
    6.58       */
    6.59 -    GUEST_HANDLE(xen_ulong) mfn_list;
    6.60 +    guest_handle(ulong) mfn_list;
    6.61  } xen_translate_gpfn_list_t;
    6.62 -DEFINE_GUEST_HANDLE(xen_translate_gpfn_list_t);
    6.63 +define_guest_handle(xen_translate_gpfn_list_t);
    6.64  
    6.65  #endif /* __XEN_PUBLIC_MEMORY_H__ */
    6.66  
     7.1 --- a/xen/include/public/xen.h	Thu Mar 02 11:41:48 2006 +0100
     7.2 +++ b/xen/include/public/xen.h	Thu Mar 02 14:43:24 2006 +0100
     7.3 @@ -10,19 +10,25 @@
     7.4  #define __XEN_PUBLIC_XEN_H__
     7.5  
     7.6  #ifdef __XEN__
     7.7 -#define DEFINE_GUEST_HANDLE(type) struct __guest_handle_ ## type { type *p; }
     7.8 -#define GUEST_HANDLE(type)        struct __guest_handle_ ## type
     7.9 +#define __define_guest_handle(name, type) \
    7.10 +    typedef struct { type *p; } __guest_handle_ ## name
    7.11  #else
    7.12 -#define DEFINE_GUEST_HANDLE(type)
    7.13 -#define GUEST_HANDLE(type)        type *
    7.14 +#define __define_guest_handle(name, type) \
    7.15 +    typedef type * __guest_handle_ ## name
    7.16  #endif
    7.17  
    7.18 +#define define_guest_handle(name) __define_guest_handle(name, name)
    7.19 +#define guest_handle(name)        __guest_handle_ ## name
    7.20 +
    7.21  #ifndef __ASSEMBLY__
    7.22 -/* Guest handle for unsigned long pointer. Define a name with no whitespace. */
    7.23 -typedef unsigned long xen_ulong;
    7.24 -DEFINE_GUEST_HANDLE(xen_ulong);
    7.25 -/* Guest handle for arbitrary-type pointer (void *). */
    7.26 -DEFINE_GUEST_HANDLE(void);
    7.27 +/* Guest handles for primitive C types. */
    7.28 +__define_guest_handle(uchar, unsigned char);
    7.29 +__define_guest_handle(uint,  unsigned int);
    7.30 +__define_guest_handle(ulong, unsigned long);
    7.31 +define_guest_handle(char);
    7.32 +define_guest_handle(int);
    7.33 +define_guest_handle(long);
    7.34 +define_guest_handle(void);
    7.35  #endif
    7.36  
    7.37  #if defined(__i386__)
     8.1 --- a/xen/include/xen/guest_access.h	Thu Mar 02 11:41:48 2006 +0100
     8.2 +++ b/xen/include/xen/guest_access.h	Thu Mar 02 14:43:24 2006 +0100
     8.3 @@ -18,7 +18,7 @@
     8.4  /* Cast a guest handle to the specified type of handle. */
     8.5  #define guest_handle_cast(hnd, type) ({         \
     8.6      type *_x = (hnd).p;                         \
     8.7 -    (GUEST_HANDLE(type)) { _x };                \
     8.8 +    (guest_handle(type)) { _x };                \
     8.9  })
    8.10  
    8.11  /*
     9.1 --- a/xen/include/xen/sched.h	Thu Mar 02 11:41:48 2006 +0100
     9.2 +++ b/xen/include/xen/sched.h	Thu Mar 02 14:43:24 2006 +0100
     9.3 @@ -311,7 +311,7 @@ void startup_cpu_idle_loop(void);
     9.4   *  'i' [unsigned] {char, int}
     9.5   *  'l' [unsigned] long
     9.6   *  'p' pointer (foo *)
     9.7 - *  'h' guest handle (GUEST_HANDLE(foo))
     9.8 + *  'h' guest handle (guest_handle(foo))
     9.9   */
    9.10  unsigned long hypercall_create_continuation(
    9.11      unsigned int op, const char *format, ...);