All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel De Graaf <dgdegra@tycho.nsa.gov>
To: Jan Beulich <JBeulich@suse.com>
Cc: keir@xen.org, Ian.Campbell@citrix.com, xen-devel@lists.xen.org
Subject: Re: [PATCH 7/9] xen: use domid check in is_hardware_domain
Date: Fri, 12 Apr 2013 10:11:27 -0400	[thread overview]
Message-ID: <5168160F.1030300@tycho.nsa.gov> (raw)
In-Reply-To: <5167DB5B02000078000CCA9F@nat28.tlf.novell.com>

On 04/12/2013 04:00 AM, Jan Beulich wrote:
>>>> On 11.04.13 at 22:13, Daniel De Graaf <dgdegra@tycho.nsa.gov> wrote:
>> Instead of checking is_privileged to determine if a domain should
>> control the hardware, check that the domain_id is equal to zero (which
>> is currently the only domain for which is_privileged is true).  This
>> allows other places where domain_id is checked for zero to be replaced
>> with is_hardware_domain.
>
> Isn't this moving in the wrong direction? I.e. wouldn't you rather
> want to see the domid == 0 checks go away, rather than replacing
> the ->is_privileged one in is_hardware_domain()?

I don't have a strong opinion on the difference between (domid == 0) and
->is_privileged; I chose domid == 0 in part because more of the changes
I was making were already comparing domid, and in part because it makes
changing "0" to a variable hardware domain ID simpler. (I have working
patches that do this, but they aren't yet ready for upstreaming).

Either way it is done, some of the code paths controlled by this check
can only be allowed to one Linux domain at a time - the PCI accesses in
traps.c are the most obvious example of this, since multiple Linux domains
will all try to access the PCI config space and step on one another.

>> --- a/xen/common/cpupool.c
>> +++ b/xen/common/cpupool.c
>> @@ -546,13 +546,16 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op)
>>       {
>>           struct domain *d;
>>
>> -        ret = -EINVAL;
>> -        if ( op->domid == 0 )
>> -            break;
>>           ret = -ESRCH;
>>           d = rcu_lock_domain_by_id(op->domid);
>>           if ( d == NULL )
>>               break;
>> +        if ( is_hardware_domain(d) )
>
> Here this is surely wrong - the operation has nothing to do with
> hardware control. This would need something like is_control_domain().
>
> Which puts under question the earlier changes in this series: Wouldn't
> you be better of having is_control_domain() resolving to
> ->is_privileged and is_hardware_domain() resolving to domid == 0
> (for the time being), and use the two according to the respective
> contexts?

That is what I was aiming for, but with is_control_domain not needed due to
every occurrence being covered by an XSM hook. I assumed that the reason
this sysctl was not allowed on dom0 was to avoid moving the possibly-pinned
hardware domain's CPUs; should this instead be rcu_lock_remote_domain_by_id
to avoid a domain moving itself, or is there another reason why a control
domain's cpupool should not be changed?

>> +        {
>> +            ret = -EINVAL;
>> +            rcu_unlock_domain(d);
>> +            break;
>> +        }
>>           if ( d->cpupool == NULL )
>>           {
>>               ret = -EINVAL;
>> --- a/xen/common/domain.c
>> +++ b/xen/common/domain.c
>> @@ -235,7 +235,7 @@ struct domain *domain_create(
>>       if ( domcr_flags & DOMCRF_hvm )
>>           d->is_hvm = 1;
>>
>> -    if ( domid == 0 )
>> +    if ( is_hardware_domain(d) )
>
> And this one isn't hardware related either. While the subsequent ones
> both are.
>
> Jan

I had assumed this one was hardware related: we can't migrate the hardware
domain and pinning its vcpus makes sense for things like MSRs or frequency
control by that domain. I don't see any reason to pin the vcpus of a control
domain, and while I doubt it is useful to migrate it, there is no reason to
forbid migration unlike the hardware domain.


-- 
Daniel De Graaf
National Security Agency

  reply	other threads:[~2013-04-12 14:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-11 20:13 [PATCH v2 0/9] Rename/remove IS_PRIV Daniel De Graaf
2013-04-11 20:13 ` [PATCH 1/9] xen/arch/x86: remove IS_PRIV access check bypasses Daniel De Graaf
2013-04-11 20:13 ` [PATCH 2/9] xen/xsm: add hooks for claim Daniel De Graaf
2013-04-11 20:13 ` [PATCH 3/9] hvm: convert access check for nested HVM to XSM Daniel De Graaf
2013-04-11 20:13 ` [PATCH 4/9] xen/arch/x86: remove IS_PRIV_FOR references Daniel De Graaf
2013-04-11 20:13 ` [PATCH 5/9] xen/arch/arm: remove rcu_lock_target_domain_by_id Daniel De Graaf
2013-04-11 20:13 ` [PATCH 6/9] xen: rename IS_PRIV to is_hardware_domain Daniel De Graaf
2013-04-11 20:13 ` [PATCH 7/9] xen: use domid check in is_hardware_domain Daniel De Graaf
2013-04-12  8:00   ` Jan Beulich
2013-04-12 14:11     ` Daniel De Graaf [this message]
2013-04-12 14:45       ` Jan Beulich
2013-04-11 20:13 ` [PATCH 8/9] xen/arch/x86: use is_hardware_domain instead of domid == 0 Daniel De Graaf
2013-04-12  8:07   ` Jan Beulich
2013-04-12 14:24     ` Daniel De Graaf
2013-04-12 14:49       ` Jan Beulich
2013-04-12 15:41         ` Keir Fraser
2013-04-12 15:49           ` Ian Campbell
2013-04-12 16:48             ` Andrew Cooper
2013-04-12 16:50               ` Andrew Cooper
2013-04-11 20:13 ` [PATCH 9/9] IOMMU: " Daniel De Graaf
2013-04-12  8:17 ` [PATCH v2 0/9] Rename/remove IS_PRIV 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=5168160F.1030300@tycho.nsa.gov \
    --to=dgdegra@tycho.nsa.gov \
    --cc=Ian.Campbell@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=keir@xen.org \
    --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 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.