# HG changeset patch # User Keir Fraser # Date 1201614376 0 # Node ID 98c2665056ea4fe63e02c943536db686fcedc459 # Parent 193afcdb85b211d72f940e086397490ce72f06e6 x86, hvm: Add a per-domain parameter to specify shadow or hap. Signed-off-by: Xu Dongxiao Index: xen-3.2.1-testing/tools/python/xen/lowlevel/xc/xc.c =================================================================== --- xen-3.2.1-testing.orig/tools/python/xen/lowlevel/xc/xc.c +++ xen-3.2.1-testing/tools/python/xen/lowlevel/xc/xc.c @@ -97,16 +97,16 @@ static PyObject *pyxc_domain_create(XcOb PyObject *kwds) { uint32_t dom = 0, ssidref = 0, flags = 0; - int ret, i, hvm = 0; + int ret, i; PyObject *pyhandle = NULL; xen_domain_handle_t handle = { 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef }; - static char *kwd_list[] = { "domid", "ssidref", "handle", "hvm", NULL }; + static char *kwd_list[] = { "domid", "ssidref", "handle", "flags", NULL }; if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iiOi", kwd_list, - &dom, &ssidref, &pyhandle, &hvm)) + &dom, &ssidref, &pyhandle, &flags)) return NULL; if ( pyhandle != NULL ) @@ -124,9 +124,6 @@ static PyObject *pyxc_domain_create(XcOb } } - if ( hvm ) - flags |= XEN_DOMCTL_CDF_hvm_guest; - if ( (ret = xc_domain_create(self->xc_handle, ssidref, handle, flags, &dom)) < 0 ) return pyxc_error_to_exception(); Index: xen-3.2.1-testing/tools/python/xen/xend/XendConfig.py =================================================================== --- xen-3.2.1-testing.orig/tools/python/xen/xend/XendConfig.py +++ xen-3.2.1-testing/tools/python/xen/xend/XendConfig.py @@ -130,7 +130,7 @@ XENAPI_PLATFORM_CFG = [ 'acpi', 'apic', 'soundhw','stdvga', 'usb', 'usbdevice', 'vnc', 'vncconsole', 'vncdisplay', 'vnclisten', 'timer_mode', 'vncpasswd', 'vncunused', 'xauthority', 'pci', 'vhpt', - 'guest_os_type' ] + 'guest_os_type', 'hap'] # Xen API console 'other_config' keys. XENAPI_CONSOLE_OTHER_CFG = ['vncunused', 'vncdisplay', 'vnclisten', @@ -1588,3 +1588,6 @@ class XendConfig(dict): def image_type(self): stored_type = self['platform'].get('image_type') return stored_type or (self.is_hvm() and 'hvm' or 'linux') + + def is_hap(self): + return self['platform']['hap'] Index: xen-3.2.1-testing/tools/python/xen/xend/XendDomainInfo.py =================================================================== --- xen-3.2.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py +++ xen-3.2.1-testing/tools/python/xen/xend/XendDomainInfo.py @@ -1624,11 +1624,18 @@ class XendDomainInfo: @raise: VmError on error """ + hvm_bit_offset = 0 + + hap_bit_offset = 1 + log.debug('XendDomainInfo.constructDomain') self.shutdownStartTime = None hvm = self.info.is_hvm() + + hap = self.info.is_hap() + if hvm: info = xc.xeninfo() if 'hvm' not in info['xen_caps']: @@ -1654,7 +1661,7 @@ class XendDomainInfo: domid = 0, ssidref = ssidref, handle = uuid.fromString(self.info['uuid']), - hvm = int(hvm)) + flags = int((hvm << hvm_bit_offset) | (hap << hap_bit_offset))) except Exception, e: # may get here if due to ACM the operation is not permitted if security.on(): Index: xen-3.2.1-testing/tools/python/xen/xm/create.py =================================================================== --- xen-3.2.1-testing.orig/tools/python/xen/xm/create.py +++ xen-3.2.1-testing/tools/python/xen/xm/create.py @@ -521,6 +521,11 @@ gopts.var('on_xend_stop', val='ignore|sh - suspend: Domain is suspended; """) +gopts.var('hap', val='HAP', + fn=set_int, default=1, + use="""Hap status (0=hap is disabled; + 1=hap is enabled.""") + def err(msg): """Print an error to stderr and exit. """ @@ -724,7 +729,7 @@ def configure_hvm(config_image, vals): 'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'vnclisten', 'sdl', 'display', 'xauthority', 'rtc_timeoffset', 'monitor', 'acpi', 'apic', 'usb', 'usbdevice', 'keymap', 'pci', - 'guest_os_type'] + 'guest_os_type', 'hap'] for a in args: if a in vals.__dict__ and vals.__dict__[a] is not None: Index: xen-3.2.1-testing/tools/python/xen/xm/xenapi_create.py =================================================================== --- xen-3.2.1-testing.orig/tools/python/xen/xm/xenapi_create.py +++ xen-3.2.1-testing/tools/python/xen/xm/xenapi_create.py @@ -818,7 +818,7 @@ class sxp2xml: def extract_platform(self, image, document): - platform_keys = ['acpi', 'apic', 'pae', 'vhpt', 'timer_mode'] + platform_keys = ['acpi', 'apic', 'pae', 'vhpt', 'timer_mode', 'hap'] def extract_platform_key(key): platform = document.createElement("platform") Index: xen-3.2.1-testing/xen/arch/ia64/xen/domain.c =================================================================== --- xen-3.2.1-testing.orig/xen/arch/ia64/xen/domain.c +++ xen-3.2.1-testing/xen/arch/ia64/xen/domain.c @@ -550,7 +550,7 @@ static int opt_pervcpu_vhpt = 1; integer_param("pervcpu_vhpt", opt_pervcpu_vhpt); #endif -int arch_domain_create(struct domain *d) +int arch_domain_create(struct domain *d, unsigned int domcr_flags) { int i; Index: xen-3.2.1-testing/xen/arch/powerpc/domain.c =================================================================== --- xen-3.2.1-testing.orig/xen/arch/powerpc/domain.c +++ xen-3.2.1-testing/xen/arch/powerpc/domain.c @@ -76,7 +76,7 @@ unsigned long hypercall_create_continuat return XEN_MARK(op); } -int arch_domain_create(struct domain *d) +int arch_domain_create(struct domain *d, unsigned int domcr_flags) { if (d->domain_id == IDLE_DOMAIN_ID) { d->shared_info = (void *)alloc_xenheap_page(); Index: xen-3.2.1-testing/xen/arch/x86/domain.c =================================================================== --- xen-3.2.1-testing.orig/xen/arch/x86/domain.c +++ xen-3.2.1-testing/xen/arch/x86/domain.c @@ -436,7 +436,7 @@ void vcpu_destroy(struct vcpu *v) hvm_vcpu_destroy(v); } -int arch_domain_create(struct domain *d) +int arch_domain_create(struct domain *d, unsigned int domcr_flags) { #ifdef __x86_64__ struct page_info *pg; @@ -446,6 +446,11 @@ int arch_domain_create(struct domain *d) int vcpuid, pdpt_order, paging_initialised = 0; int rc = -ENOMEM; + d->arch.hvm_domain.hap_enabled = + is_hvm_domain(d) && + hvm_funcs.hap_supported && + (domcr_flags & DOMCRF_hap); + d->arch.relmem = RELMEM_not_started; INIT_LIST_HEAD(&d->arch.relmem_list); Index: xen-3.2.1-testing/xen/arch/x86/mm/paging.c =================================================================== --- xen-3.2.1-testing.orig/xen/arch/x86/mm/paging.c +++ xen-3.2.1-testing/xen/arch/x86/mm/paging.c @@ -28,7 +28,7 @@ #include #include -#define hap_enabled(d) (hvm_funcs.hap_supported && is_hvm_domain(d)) +#define hap_enabled(d) (is_hvm_domain(d) && (d)->arch.hvm_domain.hap_enabled) /* Printouts */ #define PAGING_PRINTK(_f, _a...) \ Index: xen-3.2.1-testing/xen/common/domain.c =================================================================== --- xen-3.2.1-testing.orig/xen/common/domain.c +++ xen-3.2.1-testing/xen/common/domain.c @@ -235,7 +235,7 @@ struct domain *domain_create( init_status |= INIT_gnttab; } - if ( arch_domain_create(d) != 0 ) + if ( arch_domain_create(d, domcr_flags) != 0 ) goto fail; init_status |= INIT_arch; Index: xen-3.2.1-testing/xen/common/domctl.c =================================================================== --- xen-3.2.1-testing.orig/xen/common/domctl.c +++ xen-3.2.1-testing/xen/common/domctl.c @@ -325,7 +325,8 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc ret = -EINVAL; if ( supervisor_mode_kernel || - (op->u.createdomain.flags & ~XEN_DOMCTL_CDF_hvm_guest) ) + (op->u.createdomain.flags & + ~(XEN_DOMCTL_CDF_hvm_guest | XEN_DOMCTL_CDF_hap)) ) break; dom = op->domain; @@ -355,6 +356,8 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc domcr_flags = 0; if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_hvm_guest ) domcr_flags |= DOMCRF_hvm; + if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_hap ) + domcr_flags |= DOMCRF_hap; ret = -ENOMEM; d = domain_create(dom, domcr_flags, op->u.createdomain.ssidref); Index: xen-3.2.1-testing/xen/include/asm-x86/hvm/domain.h =================================================================== --- xen-3.2.1-testing.orig/xen/include/asm-x86/hvm/domain.h +++ xen-3.2.1-testing/xen/include/asm-x86/hvm/domain.h @@ -73,6 +73,8 @@ struct hvm_domain { /* Pass-through */ struct hvm_iommu hvm_iommu; + + bool_t hap_enabled; }; #endif /* __ASM_X86_HVM_DOMAIN_H__ */ Index: xen-3.2.1-testing/xen/include/public/domctl.h =================================================================== --- xen-3.2.1-testing.orig/xen/include/public/domctl.h +++ xen-3.2.1-testing/xen/include/public/domctl.h @@ -53,6 +53,9 @@ struct xen_domctl_createdomain { /* Is this an HVM guest (as opposed to a PV guest)? */ #define _XEN_DOMCTL_CDF_hvm_guest 0 #define XEN_DOMCTL_CDF_hvm_guest (1U<<_XEN_DOMCTL_CDF_hvm_guest) + /* Use hardware-assisted paging if available? */ +#define _XEN_DOMCTL_CDF_hap 1 +#define XEN_DOMCTL_CDF_hap (1U<<_XEN_DOMCTL_CDF_hap) uint32_t flags; }; typedef struct xen_domctl_createdomain xen_domctl_createdomain_t; Index: xen-3.2.1-testing/xen/include/xen/domain.h =================================================================== --- xen-3.2.1-testing.orig/xen/include/xen/domain.h +++ xen-3.2.1-testing/xen/include/xen/domain.h @@ -40,7 +40,7 @@ void free_vcpu_struct(struct vcpu *v); int vcpu_initialise(struct vcpu *v); void vcpu_destroy(struct vcpu *v); -int arch_domain_create(struct domain *d); +int arch_domain_create(struct domain *d, unsigned int domcr_flags); void arch_domain_destroy(struct domain *d); Index: xen-3.2.1-testing/xen/include/xen/sched.h =================================================================== --- xen-3.2.1-testing.orig/xen/include/xen/sched.h +++ xen-3.2.1-testing/xen/include/xen/sched.h @@ -311,6 +311,8 @@ struct domain *domain_create( /* DOMCRF_hvm: Create an HVM domain, as opposed to a PV domain. */ #define _DOMCRF_hvm 0 #define DOMCRF_hvm (1U<<_DOMCRF_hvm) +#define _DOMCRF_hap 1 +#define DOMCRF_hap (1U<<_DOMCRF_hap) int construct_dom0( struct domain *d,