xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Paul Durrant <paul.durrant@citrix.com>
Cc: xen-devel@lists.xenproject.org, Keir Fraser <keir@xen.org>,
	Jan Beulich <jbeulich@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>
Subject: Re: [PATCH 1/2] x86/hvm/viridian: keep APIC assist page mapped...
Date: Tue, 15 Mar 2016 19:20:01 -0400	[thread overview]
Message-ID: <20160315232001.GD29285@char.us.oracle.com> (raw)
In-Reply-To: <1458058456-7345-2-git-send-email-paul.durrant@citrix.com>

On Tue, Mar 15, 2016 at 04:14:15PM +0000, Paul Durrant wrote:
> ... for the lifetime of the domain.
> 
> If Xen is to make use of the APIC assist enlightenment then a persistent
> mapping needs to be kept, rather than the temporary one which is currently
> used only to initialize the page content.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> Cc: Keir Fraser <keir@xen.org>
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
>  xen/arch/x86/hvm/viridian.c        | 54 +++++++++++++++++++++++++++-----------
>  xen/include/asm-x86/hvm/viridian.h |  6 ++++-
>  2 files changed, 43 insertions(+), 17 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/viridian.c b/xen/arch/x86/hvm/viridian.c
> index 6bd844b..c779290 100644
> --- a/xen/arch/x86/hvm/viridian.c
> +++ b/xen/arch/x86/hvm/viridian.c
> @@ -163,7 +163,7 @@ static void dump_apic_assist(const struct vcpu *v)
>  {
>      const union viridian_apic_assist *aa;
>  
> -    aa = &v->arch.hvm_vcpu.viridian.apic_assist;
> +    aa = &v->arch.hvm_vcpu.viridian.apic_assist.msr;
>  
>      printk(XENLOG_G_INFO "%pv: VIRIDIAN APIC_ASSIST: enabled: %x pfn: %lx\n",
>             v, aa->fields.enabled, (unsigned long)aa->fields.pfn);
> @@ -217,9 +217,9 @@ static void enable_hypercall_page(struct domain *d)
>  static void initialize_apic_assist(struct vcpu *v)
>  {
>      struct domain *d = v->domain;
> -    unsigned long gmfn = v->arch.hvm_vcpu.viridian.apic_assist.fields.pfn;
> +    unsigned long gmfn = v->arch.hvm_vcpu.viridian.apic_assist.msr.fields.pfn;
>      struct page_info *page = get_page_from_gfn(d, gmfn, NULL, P2M_ALLOC);
> -    uint8_t *p;
> +    void *va;
>  
>      /*
>       * We don't yet make use of the APIC assist page but by setting
> @@ -231,21 +231,40 @@ static void initialize_apic_assist(struct vcpu *v)
>       * details of how Windows uses the page.
>       */
>  
> -    if ( !page || !get_page_type(page, PGT_writable_page) )
> +    if ( !page )
> +        return;
> +
> +    if ( !get_page_type(page, PGT_writable_page) )
>      {
> -        if ( page )
> -            put_page(page);
> -        gdprintk(XENLOG_WARNING, "Bad GMFN %lx (MFN %lx)\n", gmfn,
> -                 page ? page_to_mfn(page) : INVALID_MFN);
> +        put_page(page);

You don't want to report errors in case this goes south?

>          return;
>      }
>  
> -    p = __map_domain_page(page);
> +    va = __map_domain_page_global(page);
> +    if ( !va )
> +    {
> +        put_page_and_type(page);
> +        return;
> +    }
>  
> -    *(u32 *)p = 0;
> +    *(uint32_t *)va = 0;
>  
> -    unmap_domain_page(p);
> +    v->arch.hvm_vcpu.viridian.apic_assist.page = page;
> +    v->arch.hvm_vcpu.viridian.apic_assist.va = va;
> +}
> +
> +static void teardown_apic_assist(struct vcpu *v)
> +{
> +    struct page_info *page = v->arch.hvm_vcpu.viridian.apic_assist.page;
> +    void *va = v->arch.hvm_vcpu.viridian.apic_assist.va;
> +
> +    if ( !va )
> +        return;
> +
> +    v->arch.hvm_vcpu.viridian.apic_assist.va = NULL;
> +    v->arch.hvm_vcpu.viridian.apic_assist.page = NULL;
>  
> +    unmap_domain_page_global(va);
>      put_page_and_type(page);
>  }
>  
> @@ -374,9 +393,9 @@ int wrmsr_viridian_regs(uint32_t idx, uint64_t val)
>  
>      case VIRIDIAN_MSR_APIC_ASSIST:
>          perfc_incr(mshv_wrmsr_apic_msr);
> -        v->arch.hvm_vcpu.viridian.apic_assist.raw = val;
> +        v->arch.hvm_vcpu.viridian.apic_assist.msr.raw = val;
>          dump_apic_assist(v);
> -        if (v->arch.hvm_vcpu.viridian.apic_assist.fields.enabled)
> +        if ( v->arch.hvm_vcpu.viridian.apic_assist.msr.fields.enabled )
>              initialize_apic_assist(v);
>          break;
>  
> @@ -485,7 +504,7 @@ int rdmsr_viridian_regs(uint32_t idx, uint64_t *val)
>  
>      case VIRIDIAN_MSR_APIC_ASSIST:
>          perfc_incr(mshv_rdmsr_apic_msr);
> -        *val = v->arch.hvm_vcpu.viridian.apic_assist.raw;
> +        *val = v->arch.hvm_vcpu.viridian.apic_assist.msr.raw;
>          break;
>  
>      case VIRIDIAN_MSR_REFERENCE_TSC:
> @@ -530,6 +549,7 @@ int viridian_vcpu_init(struct vcpu *v)
>  void viridian_vcpu_deinit(struct vcpu *v)
>  {
>      free_cpumask_var(v->arch.hvm_vcpu.viridian.flush_cpumask);
> +    teardown_apic_assist(v);
>  }
>  
>  int viridian_hypercall(struct cpu_user_regs *regs)
> @@ -728,7 +748,7 @@ static int viridian_save_vcpu_ctxt(struct domain *d, hvm_domain_context_t *h)
>      for_each_vcpu( d, v ) {
>          struct hvm_viridian_vcpu_context ctxt;
>  
> -        ctxt.apic_assist = v->arch.hvm_vcpu.viridian.apic_assist.raw;
> +        ctxt.apic_assist = v->arch.hvm_vcpu.viridian.apic_assist.msr.raw;
>  
>          if ( hvm_save_entry(VIRIDIAN_VCPU, v->vcpu_id, h, &ctxt) != 0 )
>              return 1;
> @@ -754,7 +774,9 @@ static int viridian_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t *h)
>      if ( hvm_load_entry(VIRIDIAN_VCPU, h, &ctxt) != 0 )
>          return -EINVAL;
>  
> -    v->arch.hvm_vcpu.viridian.apic_assist.raw = ctxt.apic_assist;
> +    v->arch.hvm_vcpu.viridian.apic_assist.msr.raw = ctxt.apic_assist;
> +    if ( v->arch.hvm_vcpu.viridian.apic_assist.msr.fields.enabled )
> +        initialize_apic_assist(v);
>  
>      return 0;
>  }
> diff --git a/xen/include/asm-x86/hvm/viridian.h b/xen/include/asm-x86/hvm/viridian.h
> index 2eec85e..c60c113 100644
> --- a/xen/include/asm-x86/hvm/viridian.h
> +++ b/xen/include/asm-x86/hvm/viridian.h
> @@ -21,7 +21,11 @@ union viridian_apic_assist
>  
>  struct viridian_vcpu
>  {
> -    union viridian_apic_assist apic_assist;
> +    struct {
> +        union viridian_apic_assist msr;
> +        struct page_info *page;
> +        void *va;
> +    } apic_assist;
>      cpumask_var_t flush_cpumask;
>  };
>  
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2016-03-15 23:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-15 16:14 [PATCH 0/2] x86/hvm/viridian: APIC assist Paul Durrant
2016-03-15 16:14 ` [PATCH 1/2] x86/hvm/viridian: keep APIC assist page mapped Paul Durrant
2016-03-15 23:20   ` Konrad Rzeszutek Wilk [this message]
2016-03-16 14:46     ` Paul Durrant
2016-03-15 16:14 ` [PATCH 2/2] x86/hvm/viridian: Enable APIC assist enlightenment Paul Durrant
2016-03-15 23:18   ` Konrad Rzeszutek Wilk
2016-03-16 15:02     ` Paul Durrant
2016-03-16 16:28       ` Jan Beulich
2016-03-16 17:23         ` Paul Durrant
2016-03-17  8:12           ` 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=20160315232001.GD29285@char.us.oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=keir@xen.org \
    --cc=paul.durrant@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 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).