ia64/xen-unstable

changeset 7959:ff18a169e866

Update the memory_op() hypercall. Add two new subcommands, to
query a domain's current and maximum memory reservation. Also,
XENMEM_maximum_ram_page now returns the max_page directly,
rather than writing through a passed-in pointer.

Also, disable PAE in the default config (accidentally checked
in two changesets ago).

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Nov 21 16:56:39 2005 +0100 (2005-11-21)
parents bdab22f56efe
children dd50b17dc60f
files Config.mk linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c tools/libxc/xc_private.c tools/libxc/xg_save_restore.h xen/common/memory.c xen/include/public/memory.h
line diff
     1.1 --- a/Config.mk	Mon Nov 21 16:40:16 2005 +0100
     1.2 +++ b/Config.mk	Mon Nov 21 16:56:39 2005 +0100
     1.3 @@ -3,7 +3,7 @@
     1.4  # Currently supported architectures: x86_32, x86_64
     1.5  XEN_COMPILE_ARCH    ?= $(shell uname -m | sed -e s/i.86/x86_32/)
     1.6  XEN_TARGET_ARCH     ?= $(XEN_COMPILE_ARCH)
     1.7 -XEN_TARGET_X86_PAE  ?= y
     1.8 +XEN_TARGET_X86_PAE  ?= n
     1.9  
    1.10  # Tools to run on system hosting the build
    1.11  HOSTCC     = gcc
     2.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c	Mon Nov 21 16:40:16 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c	Mon Nov 21 16:56:39 2005 +0100
     2.3 @@ -178,6 +178,8 @@ swiotlb_init_with_default_size (size_t d
     2.4  void
     2.5  swiotlb_init(void)
     2.6  {
     2.7 +	long ram_end;
     2.8 +
     2.9  	/* The user can forcibly enable swiotlb. */
    2.10  	if (swiotlb_force)
    2.11  		swiotlb = 1;
    2.12 @@ -187,9 +189,7 @@ swiotlb_init(void)
    2.13           * which we take to mean more than 2GB.
    2.14           */
    2.15  	if (xen_start_info->flags & SIF_INITDOMAIN) {
    2.16 -		unsigned long ram_end;
    2.17 -		if (HYPERVISOR_memory_op(XENMEM_maximum_ram_page, &ram_end))
    2.18 -			BUG();
    2.19 +		ram_end = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
    2.20  		if (ram_end > 0x7ffff)
    2.21  			swiotlb = 1;
    2.22  	}
     3.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c	Mon Nov 21 16:40:16 2005 +0100
     3.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c	Mon Nov 21 16:56:39 2005 +0100
     3.3 @@ -586,7 +586,7 @@ void __init e820_reserve_resources(void)
     3.4  	free_bootmem(__pa(map), PAGE_SIZE);
     3.5  
     3.6  	if (!found) {
     3.7 -		HYPERVISOR_memory_op(XENMEM_maximum_ram_page, &gapstart);
     3.8 +		gapstart = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
     3.9  		gapstart = (gapstart << PAGE_SHIFT) + 1024*1024;
    3.10  		printk(KERN_ERR "PCI: Warning: Cannot find a gap in the 32bit address range\n"
    3.11  		       KERN_ERR "PCI: Unassigned devices with 32bit resource registers may break!\n");
     4.1 --- a/tools/libxc/xc_private.c	Mon Nov 21 16:40:16 2005 +0100
     4.2 +++ b/tools/libxc/xc_private.c	Mon Nov 21 16:56:39 2005 +0100
     4.3 @@ -214,13 +214,6 @@ int xc_memory_op(int xc_handle,
     4.4              goto out1;
     4.5          }
     4.6          break;
     4.7 -    case XENMEM_maximum_ram_page:
     4.8 -        if ( mlock(arg, sizeof(unsigned long)) != 0 )
     4.9 -        {
    4.10 -            PERROR("Could not mlock");
    4.11 -            goto out1;
    4.12 -        }
    4.13 -        break;
    4.14      }
    4.15  
    4.16      ret = do_xen_hypercall(xc_handle, &hypercall);
    4.17 @@ -234,9 +227,6 @@ int xc_memory_op(int xc_handle,
    4.18              safe_munlock(reservation->extent_start,
    4.19                           reservation->nr_extents * sizeof(unsigned long));
    4.20          break;
    4.21 -    case XENMEM_maximum_ram_page:
    4.22 -        safe_munlock(arg, sizeof(unsigned long));
    4.23 -        break;
    4.24      }
    4.25  
    4.26   out1:
     5.1 --- a/tools/libxc/xg_save_restore.h	Mon Nov 21 16:40:16 2005 +0100
     5.2 +++ b/tools/libxc/xg_save_restore.h	Mon Nov 21 16:56:39 2005 +0100
     5.3 @@ -64,7 +64,6 @@ static int get_platform_info(int xc_hand
     5.4  { 
     5.5      xen_capabilities_info_t xen_caps = "";
     5.6      xen_platform_parameters_t xen_params;
     5.7 -    
     5.8  
     5.9      if (xc_version(xc_handle, XENVER_platform_parameters, &xen_params) != 0)
    5.10          return 0;
    5.11 @@ -72,8 +71,7 @@ static int get_platform_info(int xc_hand
    5.12      if (xc_version(xc_handle, XENVER_capabilities, &xen_caps) != 0)
    5.13          return 0;
    5.14  
    5.15 -    if (xc_memory_op(xc_handle, XENMEM_maximum_ram_page, max_mfn) != 0)
    5.16 -        return 0; 
    5.17 +    *max_mfn = xc_memory_op(xc_handle, XENMEM_maximum_ram_page, NULL);
    5.18      
    5.19      *hvirt_start = xen_params.virt_start;
    5.20  
     6.1 --- a/xen/common/memory.c	Mon Nov 21 16:40:16 2005 +0100
     6.2 +++ b/xen/common/memory.c	Mon Nov 21 16:56:39 2005 +0100
     6.3 @@ -136,6 +136,7 @@ long do_memory_op(int cmd, void *arg)
     6.4      struct domain *d;
     6.5      int rc, start_extent, op, flags = 0, preempted = 0;
     6.6      struct xen_memory_reservation reservation;
     6.7 +    domid_t domid;
     6.8  
     6.9      op = cmd & ((1 << START_EXTENT_SHIFT) - 1);
    6.10  
    6.11 @@ -191,9 +192,26 @@ long do_memory_op(int cmd, void *arg)
    6.12          break;
    6.13  
    6.14      case XENMEM_maximum_ram_page:
    6.15 -        if ( put_user(max_page, (unsigned long *)arg) )
    6.16 +        rc = max_page;
    6.17 +        break;
    6.18 +
    6.19 +    case XENMEM_current_reservation:
    6.20 +    case XENMEM_maximum_reservation:
    6.21 +        if ( get_user(domid, (domid_t *)arg) )
    6.22              return -EFAULT;
    6.23 -        rc = 0;
    6.24 +
    6.25 +        if ( likely((domid = (unsigned long)arg) == DOMID_SELF) )
    6.26 +            d = current->domain;
    6.27 +        else if ( !IS_PRIV(current->domain) )
    6.28 +            return -EPERM;
    6.29 +        else if ( (d = find_domain_by_id(domid)) == NULL )
    6.30 +            return -ESRCH;
    6.31 +
    6.32 +        rc = (op == XENMEM_current_reservation) ? d->tot_pages : d->max_pages;
    6.33 +
    6.34 +        if ( unlikely(domid != DOMID_SELF) )
    6.35 +            put_domain(d);
    6.36 +
    6.37          break;
    6.38  
    6.39      default:
     7.1 --- a/xen/include/public/memory.h	Mon Nov 21 16:40:16 2005 +0100
     7.2 +++ b/xen/include/public/memory.h	Mon Nov 21 16:56:39 2005 +0100
     7.3 @@ -9,15 +9,13 @@
     7.4  #ifndef __XEN_PUBLIC_MEMORY_H__
     7.5  #define __XEN_PUBLIC_MEMORY_H__
     7.6  
     7.7 -/* arg == addr of struct xen_memory_reservation. */
     7.8 +/*
     7.9 + * Increase or decrease the specified domain's memory reservation. Returns a
    7.10 + * -ve errcode on failure, or the # extents successfully allocated or freed.
    7.11 + * arg == addr of struct xen_memory_reservation.
    7.12 + */
    7.13  #define XENMEM_increase_reservation 0
    7.14 -
    7.15 -/* arg == addr of struct xen_memory_reservation. */
    7.16  #define XENMEM_decrease_reservation 1
    7.17 -
    7.18 -/* arg == addr of unsigned long. */
    7.19 -#define XENMEM_maximum_ram_page     2
    7.20 -
    7.21  typedef struct xen_memory_reservation {
    7.22  
    7.23      /*
    7.24 @@ -47,6 +45,21 @@ typedef struct xen_memory_reservation {
    7.25  
    7.26  } xen_memory_reservation_t;
    7.27  
    7.28 +/*
    7.29 + * Returns the maximum machine frame number of mapped RAM in this system.
    7.30 + * This command always succeeds (it never returns an error code).
    7.31 + * arg == NULL.
    7.32 + */
    7.33 +#define XENMEM_maximum_ram_page     2
    7.34 +
    7.35 +/*
    7.36 + * Returns the current or maximum memory reservation, in pages, of the
    7.37 + * specified domain (may be DOMID_SELF). Returns -ve errcode on failure.
    7.38 + * arg == addr of domid_t.
    7.39 + */
    7.40 +#define XENMEM_current_reservation  3
    7.41 +#define XENMEM_maximum_reservation  4
    7.42 +
    7.43  #endif /* __XEN_PUBLIC_MEMORY_H__ */
    7.44  
    7.45  /*