From: George Dunlap <george.dunlap@citrix.com>
To: Sergey Dyasli <sergey.dyasli@citrix.com>, xen-devel@lists.xen.org
Cc: Kevin Tian <kevin.tian@intel.com>,
Jun Nakajima <jun.nakajima@intel.com>,
George Dunlap <george.dunlap@eu.citrix.com>,
Andrew Cooper <Andrew.Cooper3@citrix.com>,
Tim Deegan <tim@xen.org>, Jan Beulich <jbeulich@suse.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Subject: Re: [PATCH v1 01/14] x86/np2m: refactor p2m_get_nestedp2m()
Date: Thu, 28 Sep 2017 15:00:44 +0100 [thread overview]
Message-ID: <27fbb9a9-507f-78f4-d44b-ae67b012294c@citrix.com> (raw)
In-Reply-To: <20170904081452.12960-2-sergey.dyasli@citrix.com>
On 09/04/2017 09:14 AM, Sergey Dyasli wrote:
> 1. Add a helper function assign_np2m()
> 2. Remove useless volatile
> 3. Update function's comment in the header
> 4. Minor style fixes ('\n' and d)
>
> Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
> ---
> xen/arch/x86/mm/p2m.c | 31 ++++++++++++++++++-------------
> xen/include/asm-x86/p2m.h | 6 +++---
> 2 files changed, 21 insertions(+), 16 deletions(-)
>
> diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
> index e8a57d118c..b8c8bba421 100644
> --- a/xen/arch/x86/mm/p2m.c
> +++ b/xen/arch/x86/mm/p2m.c
> @@ -1773,14 +1773,24 @@ p2m_flush_nestedp2m(struct domain *d)
> p2m_flush_table(d->arch.nested_p2m[i]);
> }
>
> +static void assign_np2m(struct vcpu *v, struct p2m_domain *p2m)
> +{
> + struct nestedvcpu *nv = &vcpu_nestedhvm(v);
> + struct domain *d = v->domain;
> +
> + /* Bring this np2m to the top of the LRU list */
> + p2m_getlru_nestedp2m(d, p2m);
> +
> + nv->nv_flushp2m = 0;
> + nv->nv_p2m = p2m;
> + cpumask_set_cpu(v->processor, p2m->dirty_cpumask);
> +}
> +
> struct p2m_domain *
> p2m_get_nestedp2m(struct vcpu *v, uint64_t np2m_base)
> {
> - /* Use volatile to prevent gcc to cache nv->nv_p2m in a cpu register as
> - * this may change within the loop by an other (v)cpu.
> - */
> - volatile struct nestedvcpu *nv = &vcpu_nestedhvm(v);
> - struct domain *d;
> + struct nestedvcpu *nv = &vcpu_nestedhvm(v);
> + struct domain *d = v->domain;
> struct p2m_domain *p2m;
>
> /* Mask out low bits; this avoids collisions with P2M_BASE_EADDR */
> @@ -1790,7 +1800,6 @@ p2m_get_nestedp2m(struct vcpu *v, uint64_t np2m_base)
> nv->nv_p2m = NULL;
> }
>
> - d = v->domain;
> nestedp2m_lock(d);
> p2m = nv->nv_p2m;
> if ( p2m )
> @@ -1798,15 +1807,13 @@ p2m_get_nestedp2m(struct vcpu *v, uint64_t np2m_base)
> p2m_lock(p2m);
> if ( p2m->np2m_base == np2m_base || p2m->np2m_base == P2M_BASE_EADDR )
> {
> - nv->nv_flushp2m = 0;
> - p2m_getlru_nestedp2m(d, p2m);
> - nv->nv_p2m = p2m;
> if ( p2m->np2m_base == P2M_BASE_EADDR )
> hvm_asid_flush_vcpu(v);
> p2m->np2m_base = np2m_base;
> - cpumask_set_cpu(v->processor, p2m->dirty_cpumask);
> + assign_np2m(v, p2m);
> p2m_unlock(p2m);
> nestedp2m_unlock(d);
> +
> return p2m;
> }
> p2m_unlock(p2m);
> @@ -1817,11 +1824,9 @@ p2m_get_nestedp2m(struct vcpu *v, uint64_t np2m_base)
> p2m = p2m_getlru_nestedp2m(d, NULL);
> p2m_flush_table(p2m);
> p2m_lock(p2m);
> - nv->nv_p2m = p2m;
> p2m->np2m_base = np2m_base;
> - nv->nv_flushp2m = 0;
> hvm_asid_flush_vcpu(v);
> - cpumask_set_cpu(v->processor, p2m->dirty_cpumask);
> + assign_np2m(v, p2m);
> p2m_unlock(p2m);
> nestedp2m_unlock(d);
>
> diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
> index 6395e8fd1d..9086bb35dc 100644
> --- a/xen/include/asm-x86/p2m.h
> +++ b/xen/include/asm-x86/p2m.h
> @@ -359,9 +359,9 @@ struct p2m_domain {
> /* get host p2m table */
> #define p2m_get_hostp2m(d) ((d)->arch.p2m)
>
> -/* Get p2m table (re)usable for specified np2m base.
> - * Automatically destroys and re-initializes a p2m if none found.
> - * If np2m_base == 0 then v->arch.hvm_vcpu.guest_cr[3] is used.
> +/*
> + * Assigns an np2m with the specified np2m_base to the specified vCPU
> + * and returns that np2m.
> */
> struct p2m_domain *p2m_get_nestedp2m(struct vcpu *v, uint64_t np2m_base);
>
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-09-28 14:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-04 8:14 [PATCH v1 00/14] Nested p2m: allow sharing between vCPUs Sergey Dyasli
2017-09-04 8:14 ` [PATCH v1 01/14] x86/np2m: refactor p2m_get_nestedp2m() Sergey Dyasli
2017-09-28 14:00 ` George Dunlap [this message]
2017-09-04 8:14 ` [PATCH v1 02/14] x86/np2m: add np2m_flush_base() Sergey Dyasli
2017-09-28 14:01 ` George Dunlap
2017-09-04 8:14 ` [PATCH v1 03/14] x86/vvmx: use np2m_flush_base() for INVEPT_SINGLE_CONTEXT Sergey Dyasli
2017-09-26 16:05 ` George Dunlap
2017-09-04 8:14 ` [PATCH v1 04/14] x86/np2m: remove np2m_base from p2m_get_nestedp2m() Sergey Dyasli
2017-09-26 16:06 ` George Dunlap
2017-09-04 8:14 ` [PATCH v1 05/14] x86/np2m: add np2m_generation Sergey Dyasli
2017-09-04 8:14 ` [PATCH v1 06/14] x86/np2m: add stale_np2m flag Sergey Dyasli
2017-09-04 8:14 ` [PATCH v1 07/14] x86/vvmx: restart nested vmentry in case of stale_np2m Sergey Dyasli
2017-09-29 10:53 ` George Dunlap
2017-09-29 13:39 ` Sergey Dyasli
2017-09-04 8:14 ` [PATCH v1 08/14] x86/np2m: add np2m_schedule() Sergey Dyasli
2017-09-04 8:14 ` [PATCH v1 09/14] x86/np2m: add p2m_get_nestedp2m_locked() Sergey Dyasli
2017-09-04 8:14 ` [PATCH v1 10/14] x86/np2m: improve nestedhvm_hap_nested_page_fault() Sergey Dyasli
2017-09-04 8:14 ` [PATCH v1 11/14] x86/np2m: implement sharing of np2m between vCPUs Sergey Dyasli
2017-09-04 8:14 ` [PATCH v1 12/14] x86/np2m: refactor p2m_get_nestedp2m_locked() Sergey Dyasli
2017-09-04 8:14 ` [PATCH v1 13/14] x86/np2m: add break to np2m_flush_eptp() Sergey Dyasli
2017-09-04 8:14 ` [PATCH v1 14/14] x86/vvmx: remove EPTP write from ept_handle_violation() Sergey Dyasli
2017-09-29 15:01 ` [PATCH v1 00/14] Nested p2m: allow sharing between vCPUs George Dunlap
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=27fbb9a9-507f-78f4-d44b-ae67b012294c@citrix.com \
--to=george.dunlap@citrix.com \
--cc=Andrew.Cooper3@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=george.dunlap@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=sergey.dyasli@citrix.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).