All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Cc: Keir Fraser <keir@xen.org>, Wei Liu <wei.liu2@citrix.com>,
	Tim Deegan <tim@xen.org>
Subject: Re: [PATCH 2/2] x86/HVM: cache attribute pinning adjustments
Date: Thu, 3 Mar 2016 11:03:43 +0000	[thread overview]
Message-ID: <56D81A0F.4080602@citrix.com> (raw)
In-Reply-To: <56D820A402000078000D8BAC@prv-mh.provo.novell.com>

On 03/03/16 10:31, Jan Beulich wrote:
> - call hvm_get_mem_pinned_cacheattr() for RAM ranges only (requires
>   some re-ordering in epte_get_entry_emt(), to fully handle all MMIO
>   aspects first) - it's documented to be intended for RAM only
> - remove unnecessary indirection for hvm_get_mem_pinned_cacheattr()'s
>   return of the type
> - make hvm_set_mem_pinned_cacheattr() return an error on bad domain
>   kind or obviously bad GFN range
> - also avoid cache flush on EPT when removing a UC- range
> - other code structure adjustments without intended functional change

Reviewing would be far easier if these code structure changes were in a
different patch.  In particular, half the changes to
epte_get_entry_emt() appear to just be reordering the direct_mmio check
in order to drop an ASSERT(), but I am not quite sure, given the
complexity of the change.

> @@ -587,20 +578,21 @@ static void free_pinned_cacheattr_entry(
>      xfree(container_of(rcu, struct hvm_mem_pinned_cacheattr_range, rcu));
>  }
>  
> -int32_t hvm_set_mem_pinned_cacheattr(
> -    struct domain *d,
> -    uint64_t gfn_start,
> -    uint64_t gfn_end,
> -    uint32_t  type)
> +int hvm_set_mem_pinned_cacheattr(struct domain *d, uint64_t gfn_start,
> +                                 uint64_t gfn_end, uint32_t type)
>  {
>      struct hvm_mem_pinned_cacheattr_range *range;
>      int rc = 1;
>  
> -    if ( !is_hvm_domain(d) || gfn_end < gfn_start )
> -        return 0;
> +    if ( !is_hvm_domain(d) )
> +        return -EOPNOTSUPP;

You introduce an asymmetry between set and get here, both in terms of
the checks (hvm vs hvm_container), and assert vs plain failure.  Why is
this?

I would suggest ASSERT(is_hvm_domain(d)) in both cases.

> --- a/xen/include/asm-x86/hvm/cacheattr.h
> +++ b/xen/include/asm-x86/hvm/cacheattr.h
> @@ -1,29 +1,23 @@
>  #ifndef __HVM_CACHEATTR_H__
>  #define __HVM_CACHEATTR_H__
>  
> -void hvm_init_cacheattr_region_list(
> -    struct domain *d);
> -void hvm_destroy_cacheattr_region_list(
> -    struct domain *d);
> +#include <xen/types.h>
> +
> +struct domain;
> +void hvm_init_cacheattr_region_list(struct domain *d);
> +void hvm_destroy_cacheattr_region_list(struct domain *d);
>  
>  /*
>   * To see guest_fn is in the pinned range or not,
> - * if yes, return 1, and set type to value in this range
> - * if no,  return 0, setting type to ~0
> - * if ambiguous, return -1, setting type to ~0 (possible only for order > 0)
> + * if yes, return the (non-negative) type
> + * if no or ambiguous, return a negative error code
>   */
> -int hvm_get_mem_pinned_cacheattr(
> -    struct domain *d,
> -    uint64_t guest_fn,
> -    unsigned int order,
> -    uint32_t *type);
> +int hvm_get_mem_pinned_cacheattr(struct domain *d, uint64_t guest_fn,
> +                                 unsigned int order);

fn, being the usual abbreviation for function, makes this confusing to
read.  As it is already changing, could we change the parameter name to
gfn or guest_frame to be more consistent?  (Perhaps even start using
gfn_t if you are feeing keen).

~Andrew

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

  reply	other threads:[~2016-03-03 11:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-03  9:54 [PATCH 0/2] x86: more XSA-154 follow-ups Jan Beulich
2016-03-03 10:31 ` [PATCH 1/2] x86: use "unsigned int" for cache attribute values Jan Beulich
2016-03-03 10:36   ` Andrew Cooper
2016-03-03 10:31 ` [PATCH 2/2] x86/HVM: cache attribute pinning adjustments Jan Beulich
2016-03-03 11:03   ` Andrew Cooper [this message]
2016-03-03 12:10     ` Wei Liu
2016-03-03 12:12       ` Andrew Cooper
2016-03-03 12:19         ` Wei Liu
2016-03-03 12:46         ` Jan Beulich
2016-03-03 12:41     ` 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=56D81A0F.4080602@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=keir@xen.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@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.