[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 1/2] x86/mem_access: Add a helper function for memaccess conversion



On Thu, Jul 5, 2018 at 4:44 AM Adrian Pop <apop@xxxxxxxxxxxxxxx> wrote:
>
> The p2m_access_to_xenmem_access() converts a p2m_access_t to a
> xenmem_access_t.  It is complementary to xenmem_access_to_p2m_access().
> It is currently only used by _p2m_get_mem_access().
>
> Signed-off-by: Adrian Pop <apop@xxxxxxxxxxxxxxx>
> ---
>  xen/arch/x86/mm/mem_access.c | 41 +++++++++++++++++++++---------------
>  1 file changed, 24 insertions(+), 17 deletions(-)
>
> diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
> index c0cd0174cf..e75ff0c735 100644
> --- a/xen/arch/x86/mm/mem_access.c
> +++ b/xen/arch/x86/mm/mem_access.c
> @@ -33,16 +33,12 @@
>  #include "mm-locks.h"
>
>  /*
> - * Get access type for a gfn.
> - * If gfn == INVALID_GFN, gets the default access type.
> + * Convert a p2m_access_t to a xenmem_access_t.
>   */
> -static int _p2m_get_mem_access(struct p2m_domain *p2m, gfn_t gfn,
> -                               xenmem_access_t *access)
> +static int p2m_access_to_xenmem_access(struct p2m_domain *p2m,
> +                                       p2m_access_t paccess,
> +                                       xenmem_access_t *xaccess)
>  {
> -    p2m_type_t t;
> -    p2m_access_t a;
> -    mfn_t mfn;
> -
>      static const xenmem_access_t memaccess[] = {
>  #define ACCESS(ac) [p2m_access_##ac] = XENMEM_access_##ac
>              ACCESS(n),
> @@ -58,12 +54,27 @@ static int _p2m_get_mem_access(struct p2m_domain *p2m, 
> gfn_t gfn,
>  #undef ACCESS
>      };
>
> +    if ( (unsigned int)paccess >= ARRAY_SIZE(memaccess) )
> +        return -ERANGE;
> +
> +    *xaccess = memaccess[paccess];
> +    return 0;
> +}
> +
> +/*
> + * Get access type for a gfn.
> + * If gfn == INVALID_GFN, gets the default access type.
> + */
> +static int _p2m_get_mem_access(struct p2m_domain *p2m, gfn_t gfn,
> +                               xenmem_access_t *access)
> +{
> +    p2m_type_t t;
> +    p2m_access_t a;
> +    mfn_t mfn;
> +
>      /* If request to get default access. */
>      if ( gfn_eq(gfn, INVALID_GFN) )
> -    {
> -        *access = memaccess[p2m->default_access];
> -        return 0;
> -    }
> +        return p2m_access_to_xenmem_access(p2m, p2m->default_access, access);
>
>      gfn_lock(p2m, gfn, 0);
>      mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL, NULL);
> @@ -72,11 +83,7 @@ static int _p2m_get_mem_access(struct p2m_domain *p2m, 
> gfn_t gfn,
>      if ( mfn_eq(mfn, INVALID_MFN) )
>          return -ESRCH;
>
> -    if ( (unsigned int)a >= ARRAY_SIZE(memaccess) )
> -        return -ERANGE;
> -
> -    *access =  memaccess[a];
> -    return 0;
> +    return access_to_xenmem_access(p2m, a, access);

Shouldn't this be p2m_access_to_xenmem_access? Did you compile check
this patch before sending?

>  }
>
>  bool p2m_mem_access_emulate_check(struct vcpu *v,
> --
> 2.17.0

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.