Xen-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ed White <edmund.h.white@intel.com>
To: "Lengyel, Tamas" <tlengyel@novetta.com>
Cc: Ravi Sahita <ravi.sahita@intel.com>,
	Wei Liu <wei.liu2@citrix.com>,
	Razvan Cojocaru <rcojocaru@bitdefender.com>,
	Tim Deegan <tim@xen.org>, Ian Jackson <ian.jackson@eu.citrix.com>,
	Xen-devel <xen-devel@lists.xen.org>,
	Jan Beulich <jbeulich@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Daniel De Graaf <dgdegra@tycho.nsa.gov>
Subject: Re: [PATCH v2 09/12] x86/altp2m: add remaining support routines.
Date: Thu, 25 Jun 2015 16:10:23 -0700	[thread overview]
Message-ID: <558C8A5F.3020308@intel.com> (raw)
In-Reply-To: <CAD33N+69oJJrAd8u2eZMTJQ1euaoDJMpXABd5fhjvu5eS9byNA@mail.gmail.com>

On 06/25/2015 03:45 PM, Lengyel, Tamas wrote:
> On Thu, Jun 25, 2015 at 4:46 PM, Ed White <edmund.h.white@intel.com> wrote:
> 
>> On 06/25/2015 11:23 AM, Lengyel, Tamas wrote:
>>> On Thu, Jun 25, 2015 at 12:48 PM, Ed White <edmund.h.white@intel.com>
>> wrote:
>>>
>>>> On 06/25/2015 06:40 AM, Razvan Cojocaru wrote:
>>>>> On 06/25/2015 03:44 PM, Lengyel, Tamas wrote:
>>>>>> On Wed, Jun 24, 2015 at 2:06 PM, Ed White <edmund.h.white@intel.com
>>>>>> <mailto:edmund.h.white@intel.com>> wrote:
>>>>>>     On 06/24/2015 09:15 AM, Lengyel, Tamas wrote:
>>>>>>     >> +bool_t p2m_set_altp2m_mem_access(struct domain *d, uint16_t
>> idx,
>>>>>>     >> +                                 unsigned long pfn,
>>>> xenmem_access_t
>>>>>>     >> access)
>>>>>>     >> +{
>>>>>>     >>
>>>>>>     >
>>>>>>     > This function IMHO should be merged with p2m_set_mem_access and
>>>> should be
>>>>>>     > triggerable with the same memop (XENMEM_access_op) hypercall
>>>> instead of
>>>>>>     > introducing a new hvmop one.
>>>>>>
>>>>>>     I think we should vote on this. My view is that it makes
>>>>>>     XENMEM_access_op
>>>>>>     too complicated to use.
>>>>>>
>>>>>> The two functions are not very long and share enough code that it
>> would
>>>>>> justify merging. The only big change added is the copy from host->alt
>>>>>> when the entry doesn't exists in alt, and that itself is pretty self
>>>>>> contained. Let's see if we can get a third opinion on it..
>>>>>
>>>>> At first sight (I admit I'm rather late in the game and haven't had a
>>>>> chance to follow the series closely from the beginning), the two
>>>>> functions do seem to be mergeable (or at least the common code factored
>>>>> out in static helper functions).
>>>>>
>>>>> Also, if Ed's concern is that the libxc API would look unnatural if
>>>>> xc_set_mem_access() is used for both purposes, as far as I can tell the
>>>>> only difference could be a non-zero last altp2m parameter, so I agree
>>>>> with you that the less functions doing almost the same thing the better
>>>>> (I have been guilty of this in the past too, for example with my
>>>>> xc_enable_introspection() function ;) ).
>>>>>
>>>>> So I'd say, yes, if possible merge them.
>>>>
>>>> So here are my reasons why I don't think we should merge the hypercalls,
>>>> in more detail:
>>>>
>>>> Although the two hypercalls are similar, they are not identical. For one
>>>> thing, the existing hypercall can only be used cross-domain whereas the
>>>> altp2m one can be used cross-domain or intra-domain.
>>>
>>>
>>> Fair point, the use of rcu_lock_live_remote_domain_by_id in the memaccess
>>> memop handler precludes it working for the intra-domain case. However,
>> now
>>> that we have a valid use-case for it working when a domain applies
>>> restrictions on itself, it would be fine to change that to
>>> rcu_lock_domain_by_any_id. It has been just used as a sanity check. The
>>> code you are using in hvm.c could be abstracted as
>> p2m_altp2m_sanity_check:
>>> "!is_hvm_domain(d) || !hvm_altp2m_supported() || !d->arch.altp2m_active"
>>> and ran when the altp2m field is non-zero to catch buggy tools.
>>
>> Whether or not it's possible to merge the two isn't in dispute. The
>> question is which path results in the easiest to understand and
>> maintain outcome for users of the hypercalls and maintainers of
>> the implementation.
> 
> 
> If it turns out to be that merging the two is too big of a hassle, I would
> agree with Razvan, some code-deduplication would be fine instead of a
> complete merger. I still think it would be cleaner.
> 
> 
>> Having said that, I don't think your check
>> catches an attempt to place an intra-domain restriction on the
>> host p2m with altp2m active.
>>
> 
> The check above I copied from the existing code you do your hvm op. Do you
> explicitly check for that conditions somewhere else? Why not append it you
> need to restrict that condition?
> 

The existing altp2m HVM op can't operate on the host p2m, so I don't
need a check, which I think reinforces the point I'm trying to make:
the code in hvm.c will get spaghetti-like if we go down this route.

>>
>>>
>>>> Also, the existing
>>>> hypercall can be used to modify a range of pages and the new one can
>> only
>>>> modify a single page, and that is intentional.
>>>>
>>>
>>> Please elaborate on this.
>>
>> In order to keep the p2m's coherent and respect the primacy of the host
>> p2m, changes that occur in the host p2m can cause changes in altp2m's to
>> be lost. At the moment there is not even any notification that has
>> occurred, although that's something I'm working on. The minimum
>> *guaranteed* granularity of that type of altp2m invalidation is
>> an entire altp2m. The more pages you change in an altp2m, the more
>> chance there is of a collision causing an invalidation, so for this
>> version of altp2m we encourage as few changes as possible by requiring
>> a separate hypercall for each page modification.
>>
> 
>> Ed
>>
> 
> OK, but we could check for the condition where npages>1 and an altp2m is
> specified to return -EOPNOTSUPP. It could be documented in the exposed part
> of the API that with altp2m this is a restriction.
> 

See above.

Ed

  reply	other threads:[~2015-06-25 23:10 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-22 18:56 [PATCH v2 00/12] Alternate p2m: support multiple copies of host p2m Ed White
2015-06-22 18:56 ` [PATCH v2 01/12] VMX: VMFUNC and #VE definitions and detection Ed White
2015-06-24  8:45   ` Andrew Cooper
2015-06-22 18:56 ` [PATCH v2 02/12] VMX: implement suppress #VE Ed White
2015-06-24  9:35   ` Andrew Cooper
2015-06-29 14:20   ` George Dunlap
2015-06-29 14:31     ` Andrew Cooper
2015-06-29 15:03       ` George Dunlap
2015-06-29 16:21         ` Sahita, Ravi
2015-06-29 16:21         ` Ed White
2015-06-22 18:56 ` [PATCH v2 03/12] x86/HVM: Hardware alternate p2m support detection Ed White
2015-06-24  9:44   ` Andrew Cooper
2015-06-24 10:07     ` Jan Beulich
2015-06-22 18:56 ` [PATCH v2 04/12] x86/altp2m: basic data structures and support routines Ed White
2015-06-24 10:06   ` Andrew Cooper
2015-06-24 10:23     ` Jan Beulich
2015-06-24 17:20     ` Ed White
2015-06-24 10:29   ` Andrew Cooper
2015-06-24 11:14     ` Andrew Cooper
2015-06-26 21:17     ` Ed White
2015-06-27 19:25       ` Ed White
2015-06-29 13:00       ` Andrew Cooper
2015-06-29 16:23         ` Ed White
2015-06-24 14:44   ` Jan Beulich
2015-06-22 18:56 ` [PATCH v2 05/12] VMX/altp2m: add code to support EPTP switching and #VE Ed White
2015-06-24 11:59   ` Andrew Cooper
2015-06-24 17:31     ` Ed White
2015-06-24 17:40       ` Andrew Cooper
2015-06-22 18:56 ` [PATCH v2 06/12] VMX: add VMFUNC leaf 0 (EPTP switching) to emulator Ed White
2015-06-24 12:47   ` Andrew Cooper
2015-06-24 20:29     ` Ed White
2015-06-25  8:26       ` Jan Beulich
2015-06-24 14:26   ` Jan Beulich
2015-06-22 18:56 ` [PATCH v2 07/12] x86/altp2m: add control of suppress_ve Ed White
2015-06-24 13:05   ` Andrew Cooper
2015-06-24 14:38   ` Jan Beulich
2015-06-24 17:53     ` Ed White
2015-06-25  8:12       ` Jan Beulich
2015-06-25 16:36         ` Ed White
2015-06-26  6:04           ` Jan Beulich
2015-06-26 16:27             ` Ed White
2015-07-06 17:12               ` George Dunlap
2015-07-06 17:35                 ` Ed White
2015-07-06 18:29                   ` George Dunlap
2015-07-06 18:43                     ` Ed White
2015-07-07 10:10                       ` George Dunlap
2015-07-07 16:24                         ` Ed White
2015-07-07 17:33                           ` George Dunlap
2015-07-07 17:38                             ` Sahita, Ravi
2015-07-08  7:24                               ` Jan Beulich
2015-07-08 10:12                               ` Tim Deegan
2015-07-08 12:51                                 ` George Dunlap
2015-07-08  7:23                           ` Jan Beulich
2015-07-07  8:04                     ` Jan Beulich
2015-06-22 18:56 ` [PATCH v2 08/12] x86/altp2m: alternate p2m memory events Ed White
2015-06-24 13:09   ` Andrew Cooper
2015-06-24 16:01   ` Lengyel, Tamas
2015-06-24 18:02     ` Ed White
2015-06-22 18:56 ` [PATCH v2 09/12] x86/altp2m: add remaining support routines Ed White
2015-06-23 18:15   ` Lengyel, Tamas
2015-06-23 18:52     ` Ed White
2015-06-23 19:35       ` Lengyel, Tamas
2015-06-24 13:46   ` Andrew Cooper
2015-06-24 17:47     ` Ed White
2015-06-24 18:19       ` Andrew Cooper
2015-06-26 16:30         ` Ed White
2015-06-29 13:03           ` Andrew Cooper
2015-06-29 16:24             ` Ed White
2015-06-24 16:15   ` Lengyel, Tamas
2015-06-24 18:06     ` Ed White
2015-06-25  8:52       ` Ian Campbell
2015-06-25 16:27         ` Ed White
2015-06-25 12:44       ` Lengyel, Tamas
2015-06-25 13:40         ` Razvan Cojocaru
2015-06-25 16:48           ` Ed White
2015-06-25 17:39             ` Sahita, Ravi
2015-06-25 18:22             ` Razvan Cojocaru
2015-06-25 18:23             ` Lengyel, Tamas
2015-06-25 20:46               ` Ed White
2015-06-25 22:45                 ` Lengyel, Tamas
2015-06-25 23:10                   ` Ed White [this message]
2015-06-25  2:44   ` Lengyel, Tamas
2015-06-25 16:31     ` Ed White
2015-06-25 17:42       ` Lengyel, Tamas
2015-06-25 20:27         ` Ed White
2015-06-25 21:33           ` Lengyel, Tamas
2015-06-22 18:56 ` [PATCH v2 10/12] x86/altp2m: define and implement alternate p2m HVMOP types Ed White
2015-06-24 13:58   ` Andrew Cooper
2015-06-24 14:53   ` Jan Beulich
2015-06-22 18:56 ` [PATCH v2 11/12] x86/altp2m: Add altp2mhvm HVM domain parameter Ed White
2015-06-24 14:06   ` Andrew Cooper
2015-06-24 14:59   ` Jan Beulich
2015-06-24 17:57     ` Ed White
2015-06-24 18:08       ` Andrew Cooper
2015-06-25  8:34         ` Jan Beulich
2015-06-25  8:33       ` Jan Beulich
2015-06-22 18:56 ` [PATCH v2 12/12] x86/altp2m: XSM hooks for altp2m HVM ops Ed White
2015-06-26 19:24   ` Daniel De Graaf
2015-06-26 19:35     ` Ed White
2015-06-29 17:52       ` Daniel De Graaf
2015-06-29 17:55         ` Sahita, Ravi
2015-06-23 21:27 ` [PATCH v2 00/12] Alternate p2m: support multiple copies of host p2m Lengyel, Tamas
2015-06-23 22:25   ` Ed White
2015-06-24  5:39   ` Razvan Cojocaru
2015-06-24 13:32     ` Lengyel, Tamas
2015-06-24 13:37       ` Razvan Cojocaru
2015-06-24 16:43         ` Ed White
2015-06-24 21:34           ` Lengyel, Tamas
2015-06-24 22:02             ` Ed White
2015-06-24 22:45               ` Lengyel, Tamas
2015-06-24 22:55                 ` Ed White
2015-06-25  9:00                   ` Andrew Cooper
2015-06-25 16:38                     ` Ed White
2015-06-25 17:29                       ` Lengyel, Tamas
2015-06-25 20:34                         ` Ed White
2015-06-24 14:10 ` Andrew Cooper

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=558C8A5F.3020308@intel.com \
    --to=edmund.h.white@intel.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=ravi.sahita@intel.com \
    --cc=rcojocaru@bitdefender.com \
    --cc=tim@xen.org \
    --cc=tlengyel@novetta.com \
    --cc=wei.liu2@citrix.com \
    --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