From: Adrian Pop <apop@bitdefender.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
Wei Liu <wei.liu2@citrix.com>,
Razvan Cojocaru <rcojocaru@bitdefender.com>,
George Dunlap <George.Dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
Julien Grall <julien.grall@arm.com>,
tamas@tklengyel.com, xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] x86/altp2m: Add a subop for obtaining the mem access of a page
Date: Wed, 4 Jul 2018 15:20:45 +0300 [thread overview]
Message-ID: <20180704122045.GA3652@hel> (raw)
In-Reply-To: <5B36529202000078001CF466@prv1-mh.provo.novell.com>
On Fri, Jun 29, 2018 at 09:38:58AM -0600, Jan Beulich wrote:
> >>> On 28.06.18 at 15:00, <apop@bitdefender.com> wrote:
> > @@ -4666,6 +4667,23 @@ static int do_altp2m_op(
> > }
> > break;
> >
> > + case HVMOP_altp2m_get_mem_access:
> > + if ( a.u.mem_access.pad )
> > + rc = -EINVAL;
> > + else
> > + {
> > + xenmem_access_t access;
> > +
> > + rc = p2m_get_mem_access(d, _gfn(a.u.mem_access.gfn), &access,
> > + a.u.mem_access.view);
> > + if ( !rc )
> > + {
> > + a.u.mem_access.hvmmem_access = access;
> > + rc = __copy_to_guest(arg, &a, 1) ? -EFAULT : 0;
>
> __copy_field_to_guest()? Or wait, no, the function argument is still a
> handle of void.
I'll then leave the __copy_to_guest() in place as it is for now.
> And then - here we are again: Is it reasonable to permit a domain inquiring
> for itself?
Yes, this is a questionable aspect of altp2m that warrants further
discussion. I'll resend a version with the other problems addressed to
have them out of the way.
> > --- a/xen/arch/x86/mm/mem_access.c
> > +++ b/xen/arch/x86/mm/mem_access.c
> > @@ -32,17 +32,10 @@
> >
> > #include "mm-locks.h"
> >
> > -/*
> > - * 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)
> > +static int p2m_access_to_xenmem_access(struct p2m_domain *p2m,
>
> This is not even p2m code - why the p2m_ prefix?
There's indeed no reason for this to have the p2m_ prefix. Will remove
it.
> > @@ -458,11 +462,41 @@ long p2m_set_mem_access_multi(struct domain *d,
> > return rc;
> > }
> >
> > -int p2m_get_mem_access(struct domain *d, gfn_t gfn, xenmem_access_t *access)
> > +int p2m_get_mem_access(struct domain *d, gfn_t gfn, xenmem_access_t *access,
> > + unsigned int altp2m_idx)
> > {
> > - struct p2m_domain *p2m = p2m_get_hostp2m(d);
> > + struct p2m_domain *host_p2m = p2m_get_hostp2m(d);
> > + struct p2m_domain *ap2m = NULL;
> > + struct p2m_domain *p2m;
> > + p2m_access_t a;
> > + p2m_type_t t;
> > + mfn_t mfn;
> > +
> > + if ( altp2m_idx )
> > + {
> > + if ( altp2m_idx >= MAX_ALTP2M ||
> > + d->arch.altp2m_eptp[altp2m_idx] == mfn_x(INVALID_MFN) )
> > + return -EINVAL;
> > +
> > + p2m = ap2m = d->arch.altp2m_p2m[altp2m_idx];
> > + }
> > + else
> > + p2m = host_p2m;
> > +
> > + p2m_read_lock(host_p2m);
> > + if (ap2m)
>
> Missing blanks (also below).
All right.
> > + p2m_read_lock(ap2m);
> > +
> > + mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL, NULL);
> > +
> > + if (ap2m)
> > + p2m_read_unlock(ap2m);
> > + p2m_read_unlock(host_p2m);
> > +
> > + if ( mfn_eq(mfn, INVALID_MFN) )
> > + return -ESRCH;
> >
> > - return _p2m_get_mem_access(p2m, gfn, access);
> > + return p2m_access_to_xenmem_access(p2m, a, access);
>
> I'm confused: Why does p2m_get_mem_access() not use its helper
> function p2m_get_mem_access() (which you retain) anymore? I
> guess the description is a little too terse. It might also have helped
> if some of the mechanical preparation steps were broken out.
Ok, I'll fix this and attempt to provide more information with the
commit message.
Thank you!
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-07-04 12:20 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-28 13:00 [PATCH] x86/altp2m: Add a subop for obtaining the mem access of a page Adrian Pop
2018-06-29 15:38 ` Jan Beulich
2018-06-29 16:39 ` Razvan Cojocaru
2018-07-02 6:34 ` Jan Beulich
2018-07-02 11:14 ` Razvan Cojocaru
2018-07-04 19:16 ` Tamas K Lengyel
2018-07-04 14:05 ` George Dunlap
2018-07-04 15:38 ` Jan Beulich
2018-07-04 16:44 ` George Dunlap
2018-07-05 8:31 ` Jan Beulich
2018-07-05 14:35 ` Tamas K Lengyel
2018-07-05 15:21 ` Razvan Cojocaru
2018-07-05 16:45 ` Tamas K Lengyel
2018-07-06 8:56 ` Razvan Cojocaru
2018-07-06 16:52 ` Tamas K Lengyel
2018-07-09 11:04 ` George Dunlap
2018-07-09 11:18 ` Razvan Cojocaru
2018-07-09 11:46 ` George Dunlap
2018-07-09 11:53 ` Razvan Cojocaru
2018-07-09 14:48 ` George Dunlap
2018-07-09 14:50 ` Sergej Proskurin
2018-07-10 0:27 ` Tamas K Lengyel
2018-07-04 12:20 ` Adrian Pop [this message]
2018-07-04 13:20 ` Adrian Pop
2018-07-04 15:36 ` Jan Beulich
2018-07-02 11:01 ` Julien Grall
2018-07-04 12:22 ` Adrian Pop
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=20180704122045.GA3652@hel \
--to=apop@bitdefender.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=julien.grall@arm.com \
--cc=rcojocaru@bitdefender.com \
--cc=sstabellini@kernel.org \
--cc=tamas@tklengyel.com \
--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.