direct-io.hg

changeset 13630:e0291e3ed603

32-on-64: New set_address_size domctl for switching to compat mode.
From: Gerd Hoffmann <kraxel@suse.de>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@localhost.localdomain
date Fri Jan 26 13:27:01 2007 +0000 (2007-01-26)
parents 2f8a7e5fd8ba
children 16f7f5ac80ed
files tools/libxc/xc_dom_boot.c xen/arch/x86/domctl.c xen/include/public/domctl.h
line diff
     1.1 --- a/tools/libxc/xc_dom_boot.c	Fri Jan 26 10:10:12 2007 +0000
     1.2 +++ b/tools/libxc/xc_dom_boot.c	Fri Jan 26 13:27:01 2007 +0000
     1.3 @@ -91,37 +91,33 @@ static int clear_page(struct xc_dom_imag
     1.4  
     1.5  static int x86_compat(int xc, domid_t domid, char *guest_type)
     1.6  {
     1.7 -#ifdef XEN_DOMCTL_set_compat
     1.8      static const struct {
     1.9  	char           *guest;
    1.10 -	unsigned long  cmd;
    1.11 +	uint32_t        size;
    1.12      } types[] = {
    1.13 -	{ "xen-3.0-x86_32p", XEN_DOMCTL_set_compat },
    1.14 -	{ "xen-3.0-x86_64",  XEN_DOMCTL_set_native },
    1.15 +	{ "xen-3.0-x86_32p", 32 },
    1.16 +	{ "xen-3.0-x86_64",  64 },
    1.17      };
    1.18      DECLARE_DOMCTL;
    1.19      int i,rc;
    1.20  
    1.21      memset(&domctl, 0, sizeof(domctl));
    1.22      domctl.domain = domid;
    1.23 +    domctl.cmd    = XEN_DOMCTL_set_address_size;
    1.24      for (i = 0; i < sizeof(types)/sizeof(types[0]); i++)
    1.25  	if (0 == strcmp(types[i].guest, guest_type))
    1.26 -	    domctl.cmd = types[i].cmd;
    1.27 -    if (0 == domctl.cmd)
    1.28 +	    domctl.u.address_size.size = types[i].size;
    1.29 +    if (0 == domctl.u.address_size.size)
    1.30  	/* nothing to do */
    1.31  	return 0;
    1.32  
    1.33 -    xc_dom_printf("%s: guest %s, cmd %d\n", __FUNCTION__,
    1.34 -		  guest_type, domctl.cmd);
    1.35 +    xc_dom_printf("%s: guest %s, address size %" PRId32 "\n", __FUNCTION__,
    1.36 +		  guest_type, domctl.u.address_size.size);
    1.37      rc = do_domctl(xc, &domctl);
    1.38      if (0 != rc)
    1.39  	xc_dom_printf("%s: warning: failed (rc=%d)\n",
    1.40  		      __FUNCTION__, rc);
    1.41      return rc;
    1.42 -#else
    1.43 -    xc_dom_printf("%s: compiled without compat/native switching\n", __FUNCTION__);
    1.44 -    return 0;
    1.45 -#endif /* XEN_DOMCTL_set_compat */
    1.46  }
    1.47  
    1.48  
     2.1 --- a/xen/arch/x86/domctl.c	Fri Jan 26 10:10:12 2007 +0000
     2.2 +++ b/xen/arch/x86/domctl.c	Fri Jan 26 13:27:01 2007 +0000
     2.3 @@ -354,6 +354,46 @@ long arch_do_domctl(
     2.4      }
     2.5      break;
     2.6  
     2.7 +    case XEN_DOMCTL_set_address_size:
     2.8 +    {
     2.9 +        struct domain *d;
    2.10 +
    2.11 +        ret = -ESRCH;
    2.12 +        if ( (d = find_domain_by_id(domctl->domain)) == NULL )
    2.13 +            break;
    2.14 +
    2.15 +        switch ( domctl->u.address_size.size )
    2.16 +        {
    2.17 +#ifdef CONFIG_COMPAT
    2.18 +        case 32:
    2.19 +            ret = switch_compat(d);
    2.20 +            break;
    2.21 +        case 64:
    2.22 +            ret = switch_native(d);
    2.23 +            break;
    2.24 +#endif
    2.25 +        default:
    2.26 +            ret = (domctl->u.address_size.size == BITS_PER_LONG) ? 0 : -EINVAL;
    2.27 +            break;
    2.28 +        }
    2.29 +
    2.30 +        put_domain(d);
    2.31 +    }
    2.32 +
    2.33 +    case XEN_DOMCTL_get_address_size:
    2.34 +    {
    2.35 +        struct domain *d;
    2.36 +
    2.37 +        ret = -ESRCH;
    2.38 +        if ( (d = find_domain_by_id(domctl->domain)) == NULL )
    2.39 +            break;
    2.40 +
    2.41 +        domctl->u.address_size.size = BITS_PER_GUEST_LONG(d);
    2.42 +
    2.43 +        ret = 0;
    2.44 +        put_domain(d);
    2.45 +    }
    2.46 +
    2.47      default:
    2.48          ret = -ENOSYS;
    2.49          break;
     3.1 --- a/xen/include/public/domctl.h	Fri Jan 26 10:10:12 2007 +0000
     3.2 +++ b/xen/include/public/domctl.h	Fri Jan 26 13:27:01 2007 +0000
     3.3 @@ -401,6 +401,13 @@ typedef struct xen_domctl_hvmcontext {
     3.4  } xen_domctl_hvmcontext_t;
     3.5  DEFINE_XEN_GUEST_HANDLE(xen_domctl_hvmcontext_t);
     3.6  
     3.7 +#define XEN_DOMCTL_set_address_size 35
     3.8 +#define XEN_DOMCTL_get_address_size 36
     3.9 +typedef struct xen_domctl_address_size {
    3.10 +    uint32_t size;
    3.11 +} xen_domctl_address_size_t;
    3.12 +DEFINE_XEN_GUEST_HANDLE(xen_domctl_address_size_t);
    3.13 +
    3.14  #define XEN_DOMCTL_real_mode_area     26
    3.15  struct xen_domctl_real_mode_area {
    3.16      uint32_t log; /* log2 of Real Mode Area size */
    3.17 @@ -435,6 +442,7 @@ struct xen_domctl {
    3.18          struct xen_domctl_settimeoffset     settimeoffset;
    3.19          struct xen_domctl_real_mode_area    real_mode_area;
    3.20          struct xen_domctl_hvmcontext        hvmcontext;
    3.21 +        struct xen_domctl_address_size      address_size;
    3.22          uint8_t                             pad[128];
    3.23      } u;
    3.24  };