|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH for-next v3 06/12] x86/domain: push some code down to hvm_domain_initialise
On Wed, May 31, 2017 at 07:06:08PM +0100, Wei Liu wrote:
> On Wed, Apr 26, 2017 at 04:54:51PM +0100, Wei Liu wrote:
> > We want to have a single entry point to initialise hvm guest. To do
> > this, the setting of hap_enabled and creation of the per domain mappings
> > is deferred, but that's not a problem.
> >
> > No functional change.
> >
> > Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
> > Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> > ---
> > v3: update commit message
> >
> > v2:
> > 1. reorder things to avoid rename labels
> > 2. add config to hvm_domain_initialise
> >
> > Cc: Jan Beulich <jbeulich@xxxxxxxx>
> > Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> > ---
> > xen/arch/x86/domain.c | 14 +++-----------
> > xen/arch/x86/hvm/hvm.c | 11 ++++++++++-
> > xen/include/asm-x86/hvm/hvm.h | 3 ++-
> > 3 files changed, 15 insertions(+), 13 deletions(-)
> >
> > diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
> > index cea80803a5..80775a0362 100644
> > --- a/xen/arch/x86/domain.c
> > +++ b/xen/arch/x86/domain.c
> > @@ -598,16 +598,8 @@ int arch_domain_create(struct domain *d, unsigned int
> > domcr_flags,
> > d->arch.emulation_flags = emflags;
> > }
> >
> > - if ( is_hvm_domain(d) )
> > - {
> > - d->arch.hvm_domain.hap_enabled =
> > - hvm_funcs.hap_supported && (domcr_flags & DOMCRF_hap);
>
> paging_domain_init calls hap_enabled. hap_enabled uses
> d->arch.hvm_domain.hap_enabled to determine if it should call hap_init.
>
> We can't call hvm_domain_initialise before paging_domain_init because
> it needs paging to be initialised.
>
> So I can't push setting this field to hvm_domain_initialise.
>
> If you think there is a better way to clean this up please let me know.
And the new patch.
---8<---
From 63a4595004550e485793c11fed363e6f7417a3bb Mon Sep 17 00:00:00 2001
From: Wei Liu <wei.liu2@xxxxxxxxxx>
Date: Mon, 24 Apr 2017 19:00:35 +0100
Subject: [PATCH] x86/domain: push per-domain mapping creation down to
hvm_domain_initialise
We want to have a single entry point to initialise hvm guest. Push
the per-domain mapping creation down to hvm_domain_initialise.
We can't move setting hap_enabled yet because that field needs to be
set before paging initialisation. Document that.
While at it, supply hvm_domain_initialise with more arguments. Though
they aren't used yet, they might be required in the future.
Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
xen/arch/x86/domain.c | 19 ++++++++-----------
xen/arch/x86/hvm/hvm.c | 9 ++++++++-
xen/include/asm-x86/hvm/hvm.h | 3 ++-
3 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 06c46f9c49..1c572bafb0 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -598,16 +598,8 @@ int arch_domain_create(struct domain *d, unsigned int
domcr_flags,
d->arch.emulation_flags = emflags;
}
- if ( is_hvm_domain(d) )
- {
- d->arch.hvm_domain.hap_enabled =
- hvm_funcs.hap_supported && (domcr_flags & DOMCRF_hap);
-
- rc = create_perdomain_mapping(d, PERDOMAIN_VIRT_START, 0, NULL, NULL);
- }
- else if ( is_idle_domain(d) )
- rc = 0;
- else
+ rc = 0; /* HVM and idle domain */
+ if ( is_pv_domain(d) )
{
d->arch.pv_domain.gdt_ldt_l1tab =
alloc_xenheap_pages(0, MEMF_node(domain_to_node(d)));
@@ -635,6 +627,11 @@ int arch_domain_create(struct domain *d, unsigned int
domcr_flags,
HYPERVISOR_COMPAT_VIRT_START(d) =
is_pv_domain(d) ? __HYPERVISOR_COMPAT_VIRT_START : ~0u;
+ /* Need to determine if HAP is enabled before initialising paging */
+ if ( is_hvm_domain(d) )
+ d->arch.hvm_domain.hap_enabled =
+ hvm_funcs.hap_supported && (domcr_flags & DOMCRF_hap);
+
if ( !is_idle_domain(d) )
{
if ( (rc = paging_domain_init(d, domcr_flags)) != 0 )
@@ -674,7 +671,7 @@ int arch_domain_create(struct domain *d, unsigned int
domcr_flags,
if ( is_hvm_domain(d) )
{
- if ( (rc = hvm_domain_initialise(d)) != 0 )
+ if ( (rc = hvm_domain_initialise(d, domcr_flags, config)) != 0 )
goto fail;
}
else
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 273bcff9ba..f3c25aded6 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -536,7 +536,8 @@ static int hvm_print_line(
return X86EMUL_OKAY;
}
-int hvm_domain_initialise(struct domain *d)
+int hvm_domain_initialise(struct domain *d, unsigned long domcr_flags,
+ struct xen_arch_domainconfig *config)
{
unsigned int nr_gsis;
int rc;
@@ -554,6 +555,10 @@ int hvm_domain_initialise(struct domain *d)
INIT_LIST_HEAD(&d->arch.hvm_domain.write_map.list);
INIT_LIST_HEAD(&d->arch.hvm_domain.g2m_ioport_list);
+ rc = create_perdomain_mapping(d, PERDOMAIN_VIRT_START, 0, NULL, NULL);
+ if ( rc )
+ goto fail;
+
hvm_init_cacheattr_region_list(d);
rc = paging_enable(d, PG_refcounts|PG_translate|PG_external);
@@ -637,6 +642,8 @@ int hvm_domain_initialise(struct domain *d)
xfree(d->arch.hvm_domain.irq);
fail0:
hvm_destroy_cacheattr_region_list(d);
+ destroy_perdomain_mapping(d, PERDOMAIN_VIRT_START, 0);
+ fail:
return rc;
}
diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h
index 7a85b2e3b5..b687e03dce 100644
--- a/xen/include/asm-x86/hvm/hvm.h
+++ b/xen/include/asm-x86/hvm/hvm.h
@@ -236,7 +236,8 @@ extern s8 hvm_port80_allowed;
extern const struct hvm_function_table *start_svm(void);
extern const struct hvm_function_table *start_vmx(void);
-int hvm_domain_initialise(struct domain *d);
+int hvm_domain_initialise(struct domain *d, unsigned long domcr_flags,
+ struct xen_arch_domainconfig *config);
void hvm_domain_relinquish_resources(struct domain *d);
void hvm_domain_destroy(struct domain *d);
void hvm_domain_soft_reset(struct domain *d);
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |