All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: AndrewCooper <andrew.cooper3@citrix.com>,
	Wei Liu <wei.liu2@citrix.com>,
	Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH for-next v3 06/12] x86/domain: push some code down to hvm_domain_initialise
Date: Thu, 1 Jun 2017 12:42:10 +0100	[thread overview]
Message-ID: <20170601114210.pesjs3ob6vzkmrcz@citrix.com> (raw)
In-Reply-To: <59301463020000780015EAB8@prv-mh.provo.novell.com>

On Thu, Jun 01, 2017 at 05:19:31AM -0600, Jan Beulich wrote:
> >>> On 01.06.17 at 13:10, <wei.liu2@citrix.com> wrote:
> > @@ -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 )
> 
> But wouldn't the addition then better go into this subsequent if()?
> 

Sure.

---8<---
From da8e98fb5c35c21ed718bd725d0b66433a7d88ea Mon Sep 17 00:00:00 2001
From: Wei Liu <wei.liu2@citrix.com>
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@citrix.com>
---
 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..0f9222487f 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)));
@@ -637,6 +629,11 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
 
     if ( !is_idle_domain(d) )
     {
+        /* 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 ( (rc = paging_domain_init(d, domcr_flags)) != 0 )
             goto fail;
         paging_initialised = 1;
@@ -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@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-06-01 11:42 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-26 15:54 [PATCH for-next v3 00/12] x86: refactor x86/domain.c Wei Liu
2017-04-26 15:54 ` [PATCH for-next v3 01/12] x86/mm: make free_perdomain_mappings idempotent Wei Liu
2017-04-27 10:40   ` George Dunlap
2017-04-26 15:54 ` [PATCH for-next v3 02/12] x86/domain: provide pv_{create, destroy}_gdt_ldt_l1tab and use them Wei Liu
2017-04-28  8:39   ` Jan Beulich
2017-04-26 15:54 ` [PATCH for-next v3 03/12] x86/domain: make release_compact_l4 NULL tolerant Wei Liu
2017-04-26 15:54 ` [PATCH for-next v3 04/12] x86/domain: factor out pv_vcpu_destroy Wei Liu
2017-04-26 15:54 ` [PATCH for-next v3 05/12] x86/domain: factor out pv_vcpu_initialise Wei Liu
2017-04-28  8:41   ` Jan Beulich
2017-04-26 15:54 ` [PATCH for-next v3 06/12] x86/domain: push some code down to hvm_domain_initialise Wei Liu
2017-05-31 18:06   ` Wei Liu
2017-06-01 11:10     ` Wei Liu
2017-06-01 11:19       ` Jan Beulich
2017-06-01 11:42         ` Wei Liu [this message]
2017-04-26 15:54 ` [PATCH for-next v3 07/12] x86/domain: factor out pv_domain_destroy Wei Liu
2017-04-28  8:41   ` Jan Beulich
2017-04-26 15:54 ` [PATCH for-next v3 08/12] x86/domain: factor out pv_domain_initialise Wei Liu
2017-04-26 15:54 ` [PATCH for-next v3 09/12] x86/domain: move PV specific code to pv/domain.c Wei Liu
2017-04-28  8:47   ` Jan Beulich
2017-04-28 10:54     ` Wei Liu
2017-04-28 12:24       ` Jan Beulich
2017-04-28 12:54         ` Wei Liu
2017-04-26 15:54 ` [PATCH for-next v3 10/12] x86/domain: move HVM specific code to hvm/domain.c Wei Liu
2017-04-26 15:54 ` [PATCH for-next v3 11/12] x86/pv/domain: clean up setup_compat_l4 Wei Liu
2017-04-28  8:49   ` Jan Beulich
2017-04-26 15:54 ` [PATCH for-next v3 12/12] x86/pv/domain: clean up switch_compat Wei Liu
2017-04-28  8:51   ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170601114210.pesjs3ob6vzkmrcz@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.