ia64/xen-unstable

changeset 10129:810ad61870e8

New memory_op subops which return the apparent or actual physical address map.

The new subops return a memory map in e820 format. This will allow the
removal of some Xen special casing in the Linux port by using the same
code as native.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author Ian.Campbell@xensource.com
date Mon May 22 09:22:18 2006 +0100 (2006-05-22)
parents ebfa1046a81f
children d61211a6c273
files xen/arch/x86/mm.c xen/include/public/memory.h
line diff
     1.1 --- a/xen/arch/x86/mm.c	Mon May 22 09:21:58 2006 +0100
     1.2 +++ b/xen/arch/x86/mm.c	Mon May 22 09:22:18 2006 +0100
     1.3 @@ -2811,6 +2811,8 @@ long do_update_descriptor(u64 pa, u64 de
     1.4      return ret;
     1.5  }
     1.6  
     1.7 +typedef struct e820entry e820entry_t;
     1.8 +DEFINE_XEN_GUEST_HANDLE(e820entry_t);
     1.9  
    1.10  long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
    1.11  {
    1.12 @@ -2869,6 +2871,39 @@ long arch_memory_op(int op, XEN_GUEST_HA
    1.13          break;
    1.14      }
    1.15  
    1.16 +    case XENMEM_memory_map:
    1.17 +    {
    1.18 +        return -ENOSYS;
    1.19 +    }
    1.20 +
    1.21 +    case XENMEM_machine_memory_map:
    1.22 +    {
    1.23 +        struct xen_memory_map memmap;
    1.24 +        XEN_GUEST_HANDLE(e820entry_t) buffer;
    1.25 +        int count;
    1.26 +
    1.27 +        if ( !IS_PRIV(current->domain) )
    1.28 +            return -EINVAL;
    1.29 +
    1.30 +        if ( copy_from_guest(&memmap, arg, 1) )
    1.31 +            return -EFAULT;
    1.32 +        if ( memmap.nr_entries < e820.nr_map + 1 )
    1.33 +            return -EINVAL;
    1.34 +
    1.35 +        buffer = guest_handle_cast(memmap.buffer, e820entry_t);
    1.36 +
    1.37 +        count = min((unsigned int)e820.nr_map, memmap.nr_entries);
    1.38 +        if ( copy_to_guest(buffer, &e820.map[0], count) < 0 )
    1.39 +            return -EFAULT;
    1.40 +
    1.41 +        memmap.nr_entries = count;
    1.42 +
    1.43 +        if ( copy_to_guest(arg, &memmap, 1) )
    1.44 +            return -EFAULT;
    1.45 +
    1.46 +        return 0;
    1.47 +    }
    1.48 +
    1.49      default:
    1.50          return subarch_memory_op(op, arg);
    1.51      }
     2.1 --- a/xen/include/public/memory.h	Mon May 22 09:21:58 2006 +0100
     2.2 +++ b/xen/include/public/memory.h	Mon May 22 09:22:18 2006 +0100
     2.3 @@ -146,6 +146,34 @@ struct xen_translate_gpfn_list {
     2.4  typedef struct xen_translate_gpfn_list xen_translate_gpfn_list_t;
     2.5  DEFINE_XEN_GUEST_HANDLE(xen_translate_gpfn_list_t);
     2.6  
     2.7 +/*
     2.8 + * Returns the pseudo-physical memory map as it was when the domain
     2.9 + * was started.
    2.10 + */
    2.11 +#define XENMEM_memory_map           9
    2.12 +struct xen_memory_map {
    2.13 +    /*
    2.14 +     * On call the number of entries which can be stored in buffer. On
    2.15 +     * return the number of entries which have been stored in
    2.16 +     * buffer.
    2.17 +     */
    2.18 +    unsigned int nr_entries;
    2.19 +
    2.20 +    /*
    2.21 +     * Entries in the buffer are in the same format as returned by the
    2.22 +     * BIOS INT 0x15 EAX=0xE820 call.
    2.23 +     */
    2.24 +    XEN_GUEST_HANDLE(void) buffer;
    2.25 +};
    2.26 +typedef struct xen_memory_map xen_memory_map_t;
    2.27 +DEFINE_XEN_GUEST_HANDLE(xen_memory_map_t);
    2.28 +
    2.29 +/*
    2.30 + * Returns the real physical memory map. Passes the same structure as
    2.31 + * XENMEM_memory_map.
    2.32 + */
    2.33 +#define XENMEM_machine_memory_map	10
    2.34 +
    2.35  #endif /* __XEN_PUBLIC_MEMORY_H__ */
    2.36  
    2.37  /*