# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# 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 <dongxiao.xu@xxxxxxxxx>
---
tools/python/xen/lowlevel/xc/xc.c | 12 ++++--------
tools/python/xen/xend/XendConfig.py | 5 ++++-
tools/python/xen/xend/XendDomainInfo.py | 9 ++++++++-
tools/python/xen/xm/create.py | 7 ++++++-
tools/python/xen/xm/xenapi_create.py | 2 +-
xen/arch/ia64/xen/domain.c | 2 +-
xen/arch/powerpc/domain.c | 2 +-
xen/arch/x86/domain.c | 7 ++++++-
xen/arch/x86/mm/p2m.c | 3 ++-
xen/arch/x86/mm/paging.c | 2 +-
xen/common/domain.c | 2 +-
xen/common/domctl.c | 5 ++++-
xen/include/asm-x86/hvm/domain.h | 2 +-
xen/include/public/domctl.h | 3 +++
xen/include/xen/domain.h | 2 +-
xen/include/xen/sched.h | 2 ++
16 files changed, 46 insertions(+), 21 deletions(-)
diff -r 193afcdb85b2 -r 98c2665056ea tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Tue Jan 29 11:50:30 2008 +0000
+++ b/tools/python/xen/lowlevel/xc/xc.c Tue Jan 29 13:46:16 2008 +0000
@@ -97,18 +97,17 @@ static PyObject *pyxc_domain_create(XcOb
PyObject *kwds)
{
uint32_t dom = 0, ssidref = 0, flags = 0, target = 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", "target",
NULL };
+ static char *kwd_list[] = { "domid", "ssidref", "handle", "flags",
"target", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iiOii", kwd_list,
- &dom, &ssidref, &pyhandle, &hvm, &target))
- return NULL;
-
+ &dom, &ssidref, &pyhandle, &flags,
&target))
+ return NULL;
if ( pyhandle != NULL )
{
if ( !PyList_Check(pyhandle) ||
@@ -123,9 +122,6 @@ static PyObject *pyxc_domain_create(XcOb
handle[i] = (uint8_t)PyInt_AsLong(p);
}
}
-
- if ( hvm )
- flags |= XEN_DOMCTL_CDF_hvm_guest;
if ( (ret = xc_domain_create(self->xc_handle, ssidref,
handle, flags, &dom)) < 0 )
diff -r 193afcdb85b2 -r 98c2665056ea tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py Tue Jan 29 11:50:30 2008 +0000
+++ b/tools/python/xen/xend/XendConfig.py Tue Jan 29 13:46:16 2008 +0000
@@ -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',
@@ -1593,3 +1593,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']
diff -r 193afcdb85b2 -r 98c2665056ea tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Tue Jan 29 11:50:30 2008 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py Tue Jan 29 13:46:16 2008 +0000
@@ -1626,11 +1626,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']:
@@ -1656,7 +1663,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)),
target = self.info.target())
except Exception, e:
# may get here if due to ACM the operation is not permitted
diff -r 193afcdb85b2 -r 98c2665056ea tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py Tue Jan 29 11:50:30 2008 +0000
+++ b/tools/python/xen/xm/create.py Tue Jan 29 13:46:16 2008 +0000
@@ -524,6 +524,11 @@ gopts.var('target', val='TARGET',
gopts.var('target', val='TARGET',
fn=set_int, default=0,
use="Set domain target.")
+
+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.
@@ -728,7 +733,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:
diff -r 193afcdb85b2 -r 98c2665056ea tools/python/xen/xm/xenapi_create.py
--- a/tools/python/xen/xm/xenapi_create.py Tue Jan 29 11:50:30 2008 +0000
+++ b/tools/python/xen/xm/xenapi_create.py Tue Jan 29 13:46:16 2008 +0000
@@ -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")
diff -r 193afcdb85b2 -r 98c2665056ea xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c Tue Jan 29 11:50:30 2008 +0000
+++ b/xen/arch/ia64/xen/domain.c Tue Jan 29 13:46:16 2008 +0000
@@ -559,7 +559,7 @@ integer_param("pervcpu_vhpt", opt_pervcp
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;
struct page_info *page = NULL;
diff -r 193afcdb85b2 -r 98c2665056ea xen/arch/powerpc/domain.c
--- a/xen/arch/powerpc/domain.c Tue Jan 29 11:50:30 2008 +0000
+++ b/xen/arch/powerpc/domain.c Tue Jan 29 13:46:16 2008 +0000
@@ -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();
diff -r 193afcdb85b2 -r 98c2665056ea xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c Tue Jan 29 11:50:30 2008 +0000
+++ b/xen/arch/x86/domain.c Tue Jan 29 13:46:16 2008 +0000
@@ -435,7 +435,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;
@@ -444,6 +444,11 @@ int arch_domain_create(struct domain *d)
l1_pgentry_t gdt_l1e;
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);
diff -r 193afcdb85b2 -r 98c2665056ea xen/arch/x86/mm/p2m.c
--- a/xen/arch/x86/mm/p2m.c Tue Jan 29 11:50:30 2008 +0000
+++ b/xen/arch/x86/mm/p2m.c Tue Jan 29 13:46:16 2008 +0000
@@ -710,7 +710,8 @@ guest_physmap_add_entry(struct domain *d
{
if ( !test_and_set_bool(d->arch.hvm_domain.amd_npt_4gb_warning) )
dprintk(XENLOG_WARNING, "Dom%d failed to populate memory beyond"
- " 4GB: remove 'hap' Xen boot parameter.\n",
+ " 4GB: specify 'nohap' Xen boot parameter, or 'hap=0' "
+ "domain config option.\n",
d->domain_id);
return -EINVAL;
}
diff -r 193afcdb85b2 -r 98c2665056ea xen/arch/x86/mm/paging.c
--- a/xen/arch/x86/mm/paging.c Tue Jan 29 11:50:30 2008 +0000
+++ b/xen/arch/x86/mm/paging.c Tue Jan 29 13:46:16 2008 +0000
@@ -28,7 +28,7 @@
#include <asm/guest_access.h>
#include <xsm/xsm.h>
-#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...) \
diff -r 193afcdb85b2 -r 98c2665056ea xen/common/domain.c
--- a/xen/common/domain.c Tue Jan 29 11:50:30 2008 +0000
+++ b/xen/common/domain.c Tue Jan 29 13:46:16 2008 +0000
@@ -217,7 +217,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;
diff -r 193afcdb85b2 -r 98c2665056ea xen/common/domctl.c
--- a/xen/common/domctl.c Tue Jan 29 11:50:30 2008 +0000
+++ b/xen/common/domctl.c Tue Jan 29 13:46:16 2008 +0000
@@ -338,7 +338,8 @@ resumedomain_out:
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;
@@ -368,6 +369,8 @@ resumedomain_out:
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);
diff -r 193afcdb85b2 -r 98c2665056ea xen/include/asm-x86/hvm/domain.h
--- a/xen/include/asm-x86/hvm/domain.h Tue Jan 29 11:50:30 2008 +0000
+++ b/xen/include/asm-x86/hvm/domain.h Tue Jan 29 13:46:16 2008 +0000
@@ -77,7 +77,7 @@ struct hvm_domain {
#if CONFIG_PAGING_LEVELS == 3
bool_t amd_npt_4gb_warning;
#endif
-
+ bool_t hap_enabled;
bool_t qemu_mapcache_invalidate;
};
diff -r 193afcdb85b2 -r 98c2665056ea xen/include/public/domctl.h
--- a/xen/include/public/domctl.h Tue Jan 29 11:50:30 2008 +0000
+++ b/xen/include/public/domctl.h Tue Jan 29 13:46:16 2008 +0000
@@ -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;
diff -r 193afcdb85b2 -r 98c2665056ea xen/include/xen/domain.h
--- a/xen/include/xen/domain.h Tue Jan 29 11:50:30 2008 +0000
+++ b/xen/include/xen/domain.h Tue Jan 29 13:46:16 2008 +0000
@@ -40,7 +40,7 @@ int vcpu_initialise(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);
diff -r 193afcdb85b2 -r 98c2665056ea xen/include/xen/sched.h
--- a/xen/include/xen/sched.h Tue Jan 29 11:50:30 2008 +0000
+++ b/xen/include/xen/sched.h Tue Jan 29 13:46:16 2008 +0000
@@ -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,
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|