xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Pop <apop@bitdefender.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Tamas K Lengyel <tamas@tklengyel.com>,
	Wei Liu <wei.liu2@citrix.com>,
	Sergej Proskurin <proskurin@sec.in.tum.de>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] x86/altp2m: Allow setting the #VE info page for an arbitrary VCPU
Date: Mon, 27 Aug 2018 12:41:16 +0300	[thread overview]
Message-ID: <20180827094116.GC1307@hel> (raw)
In-Reply-To: <5B604D9C02000078001D96A6@prv1-mh.provo.novell.com>

On Tue, Jul 31, 2018 at 05:53:00AM -0600, Jan Beulich wrote:
> > +    struct vcpu *v;
> > +
> > +    dom = rcu_lock_domain_by_id(domain_id);
> > +
> > +    for_each_vcpu( dom, v )
> > +    {
> > +        if ( vcpu_id == v->vcpu_id )
> > +        {
> > +            rcu_unlock_domain(dom);
> > +            return v;
> > +        }
> > +    }
> 
> for_each_vcpu() looks excessive here - all you need is a bounds
> check and an access into d->vcpus[]. Together with the fact
> that your caller has already identified and locked d I wonder
> whether this helper is needed in the first place.
 
All right.  I'll remove it altogether.

> > @@ -4576,26 +4599,32 @@ static int do_altp2m_op(
> >  
> >      case HVMOP_altp2m_vcpu_enable_notify:
> >      {
> > -        struct vcpu *curr = current;
> > +        struct vcpu *v;
> >          p2m_type_t p2mt;
> >  
> > -        if ( a.u.enable_notify.pad || a.domain != DOMID_SELF ||
> > -             a.u.enable_notify.vcpu_id != curr->vcpu_id )
> > +        if ( a.u.enable_notify.pad )
> >          {
> >              rc = -EINVAL;
> >              break;
> >          }
> >  
> > -        if ( !gfn_eq(vcpu_altp2m(curr).veinfo_gfn, INVALID_GFN) ||
> > -             mfn_eq(get_gfn_query_unlocked(curr->domain,
> > +        v = __get_vcpu(a.domain, a.u.enable_notify.vcpu_id);
> > +        if ( !v )
> > +        {
> > +            rc = -EFAULT;
> 
> Hardly an appropriate error indicator for the condition.

I'll change it to -EINVAL.

> > +            break;
> > +        }
> > +
> > +        if ( !gfn_eq(vcpu_altp2m(v).veinfo_gfn, INVALID_GFN) ||
> > +             mfn_eq(get_gfn_query_unlocked(v->domain,
> >                      a.u.enable_notify.gfn, &p2mt), INVALID_MFN) )
> >          {
> >              rc = -EINVAL;
> >              break;
> >          }
> >  
> > -        vcpu_altp2m(curr).veinfo_gfn = _gfn(a.u.enable_notify.gfn);
> > -        altp2m_vcpu_update_vmfunc_ve(curr);
> > +        vcpu_altp2m(v).veinfo_gfn = _gfn(a.u.enable_notify.gfn);
> > +        altp2m_vcpu_update_vmfunc_ve(v);
> 
> I'd like you to outline in the description how you mean an external
> agent to coordinate the use of this GFN with the guest (and in
> particular without in-guest agent).

I'll try to clarify this.

Thank you!

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

      parent reply	other threads:[~2018-08-27  9:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-25 11:49 [PATCH] x86/altp2m: Allow setting the #VE info page for an arbitrary VCPU Adrian Pop
2018-07-31 11:53 ` Jan Beulich
2018-07-31 17:19   ` Tamas K Lengyel
2018-07-31 17:56     ` Razvan Cojocaru
2018-08-01  8:23     ` Jan Beulich
2018-08-01  8:30       ` Razvan Cojocaru
2018-08-01  8:38       ` Andrew Cooper
2018-08-01  9:14         ` Jan Beulich
2018-08-01  9:29           ` Andrew Cooper
2018-08-27  9:41   ` Adrian Pop [this message]

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=20180827094116.GC1307@hel \
    --to=apop@bitdefender.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=proskurin@sec.in.tum.de \
    --cc=tamas@tklengyel.com \
    --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 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).