xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: George Dunlap <george.dunlap@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Keir Fraser <keir@xen.org>
Subject: Re: [PATCH v2 4/5] x86/mm: build map_domain_gfn() just once
Date: Mon, 26 Oct 2015 14:58:36 +0000	[thread overview]
Message-ID: <562E3F9C.2020404@citrix.com> (raw)
In-Reply-To: <562E221402000078000AE8AB@prv-mh.provo.novell.com>

On 26/10/15 11:52, Jan Beulich wrote:
> It doesn't depend on GUEST_PAGING_LEVELS. Moving the function to p2m.c
> at once allows a bogus #define/#include pair to be removed from
> hap/nested_ept.c.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> v2: To ensure no dependency on GUEST_PAGING_LEVELS, move the function
>     to p2m.c.

Acked-by:  George Dunlap <george.dunlap@citrix.com>

> 
> --- a/xen/arch/x86/mm/guest_walk.c
> +++ b/xen/arch/x86/mm/guest_walk.c
> @@ -88,46 +88,6 @@ static uint32_t set_ad_bits(void *guest_
>      return 0;
>  }
>  
> -/* If the map is non-NULL, we leave this function having 
> - * acquired an extra ref on mfn_to_page(*mfn) */
> -void *map_domain_gfn(struct p2m_domain *p2m, gfn_t gfn, mfn_t *mfn,
> -                     p2m_type_t *p2mt, p2m_query_t q, uint32_t *rc)
> -{
> -    struct page_info *page;
> -    void *map;
> -
> -    /* Translate the gfn, unsharing if shared */
> -    page = get_page_from_gfn_p2m(p2m->domain, p2m, gfn_x(gfn), p2mt, NULL,
> -                                 q);
> -    if ( p2m_is_paging(*p2mt) )
> -    {
> -        ASSERT(p2m_is_hostp2m(p2m));
> -        if ( page )
> -            put_page(page);
> -        p2m_mem_paging_populate(p2m->domain, gfn_x(gfn));
> -        *rc = _PAGE_PAGED;
> -        return NULL;
> -    }
> -    if ( p2m_is_shared(*p2mt) )
> -    {
> -        if ( page )
> -            put_page(page);
> -        *rc = _PAGE_SHARED;
> -        return NULL;
> -    }
> -    if ( !page )
> -    {
> -        *rc |= _PAGE_PRESENT;
> -        return NULL;
> -    }
> -    *mfn = _mfn(page_to_mfn(page));
> -    ASSERT(mfn_valid(mfn_x(*mfn)));
> -
> -    map = map_domain_page(*mfn);
> -    return map;
> -}
> -
> -
>  /* Walk the guest pagetables, after the manner of a hardware walker. */
>  /* Because the walk is essentially random, it can cause a deadlock 
>   * warning in the p2m locking code. Highly unlikely this is an actual
> --- a/xen/arch/x86/mm/hap/nested_ept.c
> +++ b/xen/arch/x86/mm/hap/nested_ept.c
> @@ -34,10 +34,6 @@
>  #include <asm/hvm/vmx/vmx.h>
>  #include <asm/hvm/vmx/vvmx.h>
>  
> -/* EPT always use 4-level paging structure */
> -#define GUEST_PAGING_LEVELS 4
> -#include <asm/guest_pt.h>
> -
>  /* Must reserved bits in all level entries  */
>  #define EPT_MUST_RSV_BITS (((1ull << PADDR_BITS) - 1) & \
>                             ~((1ull << paddr_bits) - 1))
> --- a/xen/arch/x86/mm/p2m.c
> +++ b/xen/arch/x86/mm/p2m.c
> @@ -2053,6 +2053,44 @@ unsigned long paging_gva_to_gfn(struct v
>      return hostmode->gva_to_gfn(v, hostp2m, va, pfec);
>  }
>  
> +/*
> + * If the map is non-NULL, we leave this function having
> + * acquired an extra ref on mfn_to_page(*mfn).
> + */
> +void *map_domain_gfn(struct p2m_domain *p2m, gfn_t gfn, mfn_t *mfn,
> +                     p2m_type_t *p2mt, p2m_query_t q, uint32_t *rc)
> +{
> +    struct page_info *page;
> +
> +    /* Translate the gfn, unsharing if shared. */
> +    page = get_page_from_gfn_p2m(p2m->domain, p2m, gfn_x(gfn), p2mt, NULL, q);
> +    if ( p2m_is_paging(*p2mt) )
> +    {
> +        ASSERT(p2m_is_hostp2m(p2m));
> +        if ( page )
> +            put_page(page);
> +        p2m_mem_paging_populate(p2m->domain, gfn_x(gfn));
> +        *rc = _PAGE_PAGED;
> +        return NULL;
> +    }
> +    if ( p2m_is_shared(*p2mt) )
> +    {
> +        if ( page )
> +            put_page(page);
> +        *rc = _PAGE_SHARED;
> +        return NULL;
> +    }
> +    if ( !page )
> +    {
> +        *rc |= _PAGE_PRESENT;
> +        return NULL;
> +    }
> +    *mfn = page_to_mfn(page);
> +    ASSERT(mfn_valid(*mfn));
> +
> +    return map_domain_page(*mfn);
> +}
> +
>  int map_mmio_regions(struct domain *d,
>                       unsigned long start_gfn,
>                       unsigned long nr,
> --- a/xen/include/asm-x86/guest_pt.h
> +++ b/xen/include/asm-x86/guest_pt.h
> @@ -305,10 +305,6 @@ guest_walk_to_page_order(walk_t *gw)
>  #define GPT_RENAME2(_n, _l) _n ## _ ## _l ## _levels
>  #define GPT_RENAME(_n, _l) GPT_RENAME2(_n, _l)
>  #define guest_walk_tables GPT_RENAME(guest_walk_tables, GUEST_PAGING_LEVELS)
> -#define map_domain_gfn GPT_RENAME(map_domain_gfn, GUEST_PAGING_LEVELS)
> -
> -void *map_domain_gfn(struct p2m_domain *p2m, gfn_t gfn, mfn_t *mfn,
> -                     p2m_type_t *p2mt, p2m_query_t q, uint32_t *rc);
>  
>  extern uint32_t 
>  guest_walk_tables(struct vcpu *v, struct p2m_domain *p2m, unsigned long va,
> --- a/xen/include/asm-x86/p2m.h
> +++ b/xen/include/asm-x86/p2m.h
> @@ -680,6 +680,9 @@ int p2m_set_entry(struct p2m_domain *p2m
>  /* Set up function pointers for PT implementation: only for use by p2m code */
>  extern void p2m_pt_init(struct p2m_domain *p2m);
>  
> +void *map_domain_gfn(struct p2m_domain *p2m, gfn_t gfn, mfn_t *mfn,
> +                     p2m_type_t *p2mt, p2m_query_t q, uint32_t *rc);
> +
>  /* Debugging and auditing of the P2M code? */
>  #ifndef NDEBUG
>  #define P2M_AUDIT     1
> 
> 

  parent reply	other threads:[~2015-10-26 14:59 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-26 10:47 [PATCH v2 0/5] disambiguate symbol names (part 2) Jan Beulich
2015-10-26 11:49 ` [PATCH v2 1/5] symbols: prefix static symbols with their source file names Jan Beulich
2015-10-28 12:55   ` Andrew Cooper
2015-10-28 13:25     ` Jan Beulich
2015-10-28 13:42       ` Andrew Cooper
2015-10-28 14:29         ` Jan Beulich
2015-11-02 13:47   ` Ian Campbell
2015-11-02 13:55     ` Jan Beulich
2015-11-02 14:54       ` Ian Campbell
2015-11-02 14:58         ` Jan Beulich
2015-11-02 15:11           ` Ian Campbell
2015-10-26 11:50 ` [PATCH v2 2/5] compat: enforce distinguishable file names in symbol table Jan Beulich
2015-10-28 13:08   ` Andrew Cooper
2015-11-02 15:20   ` Ian Campbell
2015-11-02 16:11     ` Jan Beulich
2015-11-03 12:22       ` Ian Campbell
2015-11-03 12:50         ` Jan Beulich
2015-11-03 13:39           ` Ian Campbell
2015-11-03 15:31             ` Jan Beulich
2015-11-03 15:42               ` Ian Campbell
2015-10-26 11:51 ` [PATCH v2 3/5] x86/mm: override stored file names for multiply built sources Jan Beulich
2015-10-26 12:52   ` Andrew Cooper
2015-10-26 14:34   ` Martin Pohlack
2015-10-26 14:57     ` George Dunlap
2015-10-26 15:12       ` Jan Beulich
2015-10-26 16:27   ` George Dunlap
2015-10-26 11:52 ` [PATCH v2 4/5] x86/mm: build map_domain_gfn() just once Jan Beulich
2015-10-26 12:52   ` Andrew Cooper
2015-10-26 14:58   ` George Dunlap [this message]
2015-10-26 11:53 ` [PATCH v2 5/5] x86/mm: only a single instance of gw_page_flags[] is needed Jan Beulich
2015-10-26 14:59   ` 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=562E3F9C.2020404@citrix.com \
    --to=george.dunlap@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=keir@xen.org \
    --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).