debuggers.hg

changeset 16969:98c2665056ea

x86, hvm: Add a per-domain parameter to specify shadow or hap.
Signed-off-by: Xu Dongxiao <dongxiao.xu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jan 29 13:46:16 2008 +0000 (2008-01-29)
parents 193afcdb85b2
children 04e24b9dcc16
files tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/XendConfig.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/create.py tools/python/xen/xm/xenapi_create.py xen/arch/ia64/xen/domain.c xen/arch/powerpc/domain.c xen/arch/x86/domain.c xen/arch/x86/mm/p2m.c xen/arch/x86/mm/paging.c xen/common/domain.c xen/common/domctl.c xen/include/asm-x86/hvm/domain.h xen/include/public/domctl.h xen/include/xen/domain.h xen/include/xen/sched.h
line diff
     1.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Tue Jan 29 11:50:30 2008 +0000
     1.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Tue Jan 29 13:46:16 2008 +0000
     1.3 @@ -97,18 +97,17 @@ static PyObject *pyxc_domain_create(XcOb
     1.4                                      PyObject *kwds)
     1.5  {
     1.6      uint32_t dom = 0, ssidref = 0, flags = 0, target = 0;
     1.7 -    int      ret, i, hvm = 0;
     1.8 +    int      ret, i;
     1.9      PyObject *pyhandle = NULL;
    1.10      xen_domain_handle_t handle = { 
    1.11          0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef,
    1.12          0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef };
    1.13  
    1.14 -    static char *kwd_list[] = { "domid", "ssidref", "handle", "hvm", "target", NULL };
    1.15 +    static char *kwd_list[] = { "domid", "ssidref", "handle", "flags", "target", NULL };
    1.16  
    1.17      if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iiOii", kwd_list,
    1.18 -				      &dom, &ssidref, &pyhandle, &hvm, &target))
    1.19 +				      &dom, &ssidref, &pyhandle, &flags, &target))
    1.20          return NULL;
    1.21 -
    1.22      if ( pyhandle != NULL )
    1.23      {
    1.24          if ( !PyList_Check(pyhandle) || 
    1.25 @@ -124,9 +123,6 @@ static PyObject *pyxc_domain_create(XcOb
    1.26          }
    1.27      }
    1.28  
    1.29 -    if ( hvm )
    1.30 -        flags |= XEN_DOMCTL_CDF_hvm_guest;
    1.31 -
    1.32      if ( (ret = xc_domain_create(self->xc_handle, ssidref,
    1.33                                   handle, flags, &dom)) < 0 )
    1.34          return pyxc_error_to_exception();
     2.1 --- a/tools/python/xen/xend/XendConfig.py	Tue Jan 29 11:50:30 2008 +0000
     2.2 +++ b/tools/python/xen/xend/XendConfig.py	Tue Jan 29 13:46:16 2008 +0000
     2.3 @@ -130,7 +130,7 @@ XENAPI_PLATFORM_CFG = [ 'acpi', 'apic', 
     2.4                          'soundhw','stdvga', 'usb', 'usbdevice', 'vnc',
     2.5                          'vncconsole', 'vncdisplay', 'vnclisten', 'timer_mode',
     2.6                          'vncpasswd', 'vncunused', 'xauthority', 'pci', 'vhpt',
     2.7 -                        'guest_os_type' ]
     2.8 +                        'guest_os_type', 'hap']
     2.9  
    2.10  # Xen API console 'other_config' keys.
    2.11  XENAPI_CONSOLE_OTHER_CFG = ['vncunused', 'vncdisplay', 'vnclisten',
    2.12 @@ -1593,3 +1593,6 @@ class XendConfig(dict):
    2.13      def image_type(self):
    2.14          stored_type = self['platform'].get('image_type')
    2.15          return stored_type or (self.is_hvm() and 'hvm' or 'linux')
    2.16 +
    2.17 +    def is_hap(self):
    2.18 +        return self['platform']['hap']
     3.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Jan 29 11:50:30 2008 +0000
     3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Jan 29 13:46:16 2008 +0000
     3.3 @@ -1626,11 +1626,18 @@ class XendDomainInfo:
     3.4          @raise: VmError on error
     3.5          """
     3.6  
     3.7 +        hvm_bit_offset = 0
     3.8 +
     3.9 +        hap_bit_offset = 1
    3.10 +
    3.11          log.debug('XendDomainInfo.constructDomain')
    3.12  
    3.13          self.shutdownStartTime = None
    3.14  
    3.15          hvm = self.info.is_hvm()
    3.16 +
    3.17 +        hap = self.info.is_hap()
    3.18 +
    3.19          if hvm:
    3.20              info = xc.xeninfo()
    3.21              if 'hvm' not in info['xen_caps']:
    3.22 @@ -1656,7 +1663,7 @@ class XendDomainInfo:
    3.23                  domid = 0,
    3.24                  ssidref = ssidref,
    3.25                  handle = uuid.fromString(self.info['uuid']),
    3.26 -                hvm = int(hvm),
    3.27 +                flags = int((hvm << hvm_bit_offset) | (hap << hap_bit_offset)),
    3.28                  target = self.info.target())
    3.29          except Exception, e:
    3.30              # may get here if due to ACM the operation is not permitted
     4.1 --- a/tools/python/xen/xm/create.py	Tue Jan 29 11:50:30 2008 +0000
     4.2 +++ b/tools/python/xen/xm/create.py	Tue Jan 29 13:46:16 2008 +0000
     4.3 @@ -525,6 +525,11 @@ gopts.var('target', val='TARGET',
     4.4            fn=set_int, default=0,
     4.5            use="Set domain target.")
     4.6  
     4.7 +gopts.var('hap', val='HAP',
     4.8 +          fn=set_int, default=1,
     4.9 +          use="""Hap status (0=hap is disabled;
    4.10 +          1=hap is enabled.""")
    4.11 +
    4.12  def err(msg):
    4.13      """Print an error to stderr and exit.
    4.14      """
    4.15 @@ -728,7 +733,7 @@ def configure_hvm(config_image, vals):
    4.16               'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'vnclisten',
    4.17               'sdl', 'display', 'xauthority', 'rtc_timeoffset', 'monitor',
    4.18               'acpi', 'apic', 'usb', 'usbdevice', 'keymap', 'pci',
    4.19 -             'guest_os_type']
    4.20 +             'guest_os_type', 'hap']
    4.21  
    4.22      for a in args:
    4.23          if a in vals.__dict__ and vals.__dict__[a] is not None:
     5.1 --- a/tools/python/xen/xm/xenapi_create.py	Tue Jan 29 11:50:30 2008 +0000
     5.2 +++ b/tools/python/xen/xm/xenapi_create.py	Tue Jan 29 13:46:16 2008 +0000
     5.3 @@ -818,7 +818,7 @@ class sxp2xml:
     5.4  
     5.5  
     5.6      def extract_platform(self, image, document):
     5.7 -        platform_keys = ['acpi', 'apic', 'pae', 'vhpt', 'timer_mode']
     5.8 +        platform_keys = ['acpi', 'apic', 'pae', 'vhpt', 'timer_mode', 'hap']
     5.9  
    5.10          def extract_platform_key(key):
    5.11              platform = document.createElement("platform")
     6.1 --- a/xen/arch/ia64/xen/domain.c	Tue Jan 29 11:50:30 2008 +0000
     6.2 +++ b/xen/arch/ia64/xen/domain.c	Tue Jan 29 13:46:16 2008 +0000
     6.3 @@ -559,7 +559,7 @@ static int opt_pervcpu_vhpt = 1;
     6.4  integer_param("pervcpu_vhpt", opt_pervcpu_vhpt);
     6.5  #endif
     6.6  
     6.7 -int arch_domain_create(struct domain *d)
     6.8 +int arch_domain_create(struct domain *d, unsigned int domcr_flags)
     6.9  {
    6.10  	int i;
    6.11  	struct page_info *page = NULL;
     7.1 --- a/xen/arch/powerpc/domain.c	Tue Jan 29 11:50:30 2008 +0000
     7.2 +++ b/xen/arch/powerpc/domain.c	Tue Jan 29 13:46:16 2008 +0000
     7.3 @@ -76,7 +76,7 @@ unsigned long hypercall_create_continuat
     7.4      return XEN_MARK(op);
     7.5  }
     7.6  
     7.7 -int arch_domain_create(struct domain *d)
     7.8 +int arch_domain_create(struct domain *d, unsigned int domcr_flags)
     7.9  {
    7.10      if (d->domain_id == IDLE_DOMAIN_ID) {
    7.11          d->shared_info = (void *)alloc_xenheap_page();
     8.1 --- a/xen/arch/x86/domain.c	Tue Jan 29 11:50:30 2008 +0000
     8.2 +++ b/xen/arch/x86/domain.c	Tue Jan 29 13:46:16 2008 +0000
     8.3 @@ -435,7 +435,7 @@ void vcpu_destroy(struct vcpu *v)
     8.4          hvm_vcpu_destroy(v);
     8.5  }
     8.6  
     8.7 -int arch_domain_create(struct domain *d)
     8.8 +int arch_domain_create(struct domain *d, unsigned int domcr_flags)
     8.9  {
    8.10  #ifdef __x86_64__
    8.11      struct page_info *pg;
    8.12 @@ -445,6 +445,11 @@ int arch_domain_create(struct domain *d)
    8.13      int vcpuid, pdpt_order, paging_initialised = 0;
    8.14      int rc = -ENOMEM;
    8.15  
    8.16 +    d->arch.hvm_domain.hap_enabled =
    8.17 +        is_hvm_domain(d) &&
    8.18 +        hvm_funcs.hap_supported &&
    8.19 +        (domcr_flags & DOMCRF_hap);
    8.20 +
    8.21      d->arch.relmem = RELMEM_not_started;
    8.22      INIT_LIST_HEAD(&d->arch.relmem_list);
    8.23  
     9.1 --- a/xen/arch/x86/mm/p2m.c	Tue Jan 29 11:50:30 2008 +0000
     9.2 +++ b/xen/arch/x86/mm/p2m.c	Tue Jan 29 13:46:16 2008 +0000
     9.3 @@ -710,7 +710,8 @@ guest_physmap_add_entry(struct domain *d
     9.4      {
     9.5          if ( !test_and_set_bool(d->arch.hvm_domain.amd_npt_4gb_warning) )
     9.6              dprintk(XENLOG_WARNING, "Dom%d failed to populate memory beyond"
     9.7 -                    " 4GB: remove 'hap' Xen boot parameter.\n",
     9.8 +                    " 4GB: specify 'nohap' Xen boot parameter, or 'hap=0' "
     9.9 +                    "domain config option.\n",
    9.10                      d->domain_id);
    9.11          return -EINVAL;
    9.12      }
    10.1 --- a/xen/arch/x86/mm/paging.c	Tue Jan 29 11:50:30 2008 +0000
    10.2 +++ b/xen/arch/x86/mm/paging.c	Tue Jan 29 13:46:16 2008 +0000
    10.3 @@ -28,7 +28,7 @@
    10.4  #include <asm/guest_access.h>
    10.5  #include <xsm/xsm.h>
    10.6  
    10.7 -#define hap_enabled(d) (hvm_funcs.hap_supported && is_hvm_domain(d))
    10.8 +#define hap_enabled(d) (is_hvm_domain(d) && (d)->arch.hvm_domain.hap_enabled)
    10.9  
   10.10  /* Printouts */
   10.11  #define PAGING_PRINTK(_f, _a...)                                     \
    11.1 --- a/xen/common/domain.c	Tue Jan 29 11:50:30 2008 +0000
    11.2 +++ b/xen/common/domain.c	Tue Jan 29 13:46:16 2008 +0000
    11.3 @@ -217,7 +217,7 @@ struct domain *domain_create(
    11.4          init_status |= INIT_gnttab;
    11.5      }
    11.6  
    11.7 -    if ( arch_domain_create(d) != 0 )
    11.8 +    if ( arch_domain_create(d, domcr_flags) != 0 )
    11.9          goto fail;
   11.10      init_status |= INIT_arch;
   11.11  
    12.1 --- a/xen/common/domctl.c	Tue Jan 29 11:50:30 2008 +0000
    12.2 +++ b/xen/common/domctl.c	Tue Jan 29 13:46:16 2008 +0000
    12.3 @@ -338,7 +338,8 @@ resumedomain_out:
    12.4  
    12.5          ret = -EINVAL;
    12.6          if ( supervisor_mode_kernel ||
    12.7 -             (op->u.createdomain.flags & ~XEN_DOMCTL_CDF_hvm_guest) )
    12.8 +             (op->u.createdomain.flags &
    12.9 +             ~(XEN_DOMCTL_CDF_hvm_guest | XEN_DOMCTL_CDF_hap)) )
   12.10              break;
   12.11  
   12.12          dom = op->domain;
   12.13 @@ -368,6 +369,8 @@ resumedomain_out:
   12.14          domcr_flags = 0;
   12.15          if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_hvm_guest )
   12.16              domcr_flags |= DOMCRF_hvm;
   12.17 +        if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_hap )
   12.18 +            domcr_flags |= DOMCRF_hap;
   12.19  
   12.20          ret = -ENOMEM;
   12.21          d = domain_create(dom, domcr_flags, op->u.createdomain.ssidref);
    13.1 --- a/xen/include/asm-x86/hvm/domain.h	Tue Jan 29 11:50:30 2008 +0000
    13.2 +++ b/xen/include/asm-x86/hvm/domain.h	Tue Jan 29 13:46:16 2008 +0000
    13.3 @@ -77,7 +77,7 @@ struct hvm_domain {
    13.4  #if CONFIG_PAGING_LEVELS == 3
    13.5      bool_t                 amd_npt_4gb_warning;
    13.6  #endif
    13.7 -
    13.8 +    bool_t                 hap_enabled;
    13.9      bool_t                 qemu_mapcache_invalidate;
   13.10  };
   13.11  
    14.1 --- a/xen/include/public/domctl.h	Tue Jan 29 11:50:30 2008 +0000
    14.2 +++ b/xen/include/public/domctl.h	Tue Jan 29 13:46:16 2008 +0000
    14.3 @@ -53,6 +53,9 @@ struct xen_domctl_createdomain {
    14.4   /* Is this an HVM guest (as opposed to a PV guest)? */
    14.5  #define _XEN_DOMCTL_CDF_hvm_guest 0
    14.6  #define XEN_DOMCTL_CDF_hvm_guest  (1U<<_XEN_DOMCTL_CDF_hvm_guest)
    14.7 + /* Use hardware-assisted paging if available? */
    14.8 +#define _XEN_DOMCTL_CDF_hap       1
    14.9 +#define XEN_DOMCTL_CDF_hap        (1U<<_XEN_DOMCTL_CDF_hap)
   14.10      uint32_t flags;
   14.11  };
   14.12  typedef struct xen_domctl_createdomain xen_domctl_createdomain_t;
    15.1 --- a/xen/include/xen/domain.h	Tue Jan 29 11:50:30 2008 +0000
    15.2 +++ b/xen/include/xen/domain.h	Tue Jan 29 13:46:16 2008 +0000
    15.3 @@ -40,7 +40,7 @@ void free_vcpu_struct(struct vcpu *v);
    15.4  int  vcpu_initialise(struct vcpu *v);
    15.5  void vcpu_destroy(struct vcpu *v);
    15.6  
    15.7 -int arch_domain_create(struct domain *d);
    15.8 +int arch_domain_create(struct domain *d, unsigned int domcr_flags);
    15.9  
   15.10  void arch_domain_destroy(struct domain *d);
   15.11  
    16.1 --- a/xen/include/xen/sched.h	Tue Jan 29 11:50:30 2008 +0000
    16.2 +++ b/xen/include/xen/sched.h	Tue Jan 29 13:46:16 2008 +0000
    16.3 @@ -311,6 +311,8 @@ struct domain *domain_create(
    16.4   /* DOMCRF_hvm: Create an HVM domain, as opposed to a PV domain. */
    16.5  #define _DOMCRF_hvm 0
    16.6  #define DOMCRF_hvm  (1U<<_DOMCRF_hvm)
    16.7 +#define _DOMCRF_hap 1
    16.8 +#define DOMCRF_hap  (1U<<_DOMCRF_hap)
    16.9  
   16.10  int construct_dom0(
   16.11      struct domain *d,