All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tamas K Lengyel <tamas@tklengyel.com>
To: Alexandru Isaila <aisaila@bitdefender.com>
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	Razvan Cojocaru <rcojocaru@bitdefender.com>,
	Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH v2] x86/mm: Add mem access rights to NPT
Date: Tue, 19 Jun 2018 08:22:47 -0600	[thread overview]
Message-ID: <CABfawhnxFyv5jU6hXFdFbjttWcu5HfqhQT1jeFm5aOpLVfZHng@mail.gmail.com> (raw)
In-Reply-To: <1529396084.4608.5.camel@bitdefender.com>

On Tue, Jun 19, 2018 at 2:14 AM Alexandru Stefan ISAILA
<aisaila@bitdefender.com> wrote:
>
> On Lu, 2018-06-18 at 09:39 -0600, Tamas K Lengyel wrote:
> > On Mon, Jun 18, 2018 at 9:19 AM Alexandru Isaila
> > <aisaila@bitdefender.com> wrote:
> > >
> > >
> > > +static p2m_access_t p2m_get_access(struct p2m_domain *p2m,
> > > unsigned long gfn)
> > > +{
> > > +    void *ptr;
> > > +
> > > +    ptr = radix_tree_lookup(&p2m->mem_access_settings, gfn);
> > > +    if ( !ptr )
> > > +        return p2m_access_rwx;
> > > +    else
> > > +        return radix_tree_ptr_to_int(ptr);
> > > +}
> > > +
> > > +static void p2m_set_access(struct p2m_domain *p2m, unsigned long
> > > gfn,
> > > +                                      p2m_access_t a)
> > > +{
> > > +    int rc;
> > > +
> > Shouldn't there be some locking around the radix tree operations
> > here?
> > If not, why not?
> The lock is in the p2m_set_mem_access() so that one entry is set at a
> time. The radix tree operations are similar to the ones on ARM but if
> we missed something I will appreciate the help in correcting the issue.

There are calls to this function that are not from p2m_set_mem_access
though, so I just wanted to make sure that each of those call-sites
already has a lock in place. Perhaps a comment to this function should
make that clear that a caller has to perform its own locking, the
function as-is doesn't do that. Or perhaps an ASSERT would be even
better if possible?

Thanks,
Tamas

> >
> > >
> > > +    if ( p2m_access_rwx == a )
> > > +        radix_tree_delete(&p2m->mem_access_settings, gfn);
> > > +
> > > +    rc = radix_tree_insert(&p2m->mem_access_settings, gfn,
> > > +                           radix_tree_int_to_ptr(a));
> > > +    if ( rc == -EEXIST )
> > > +        /* If a setting already exists, change it to the new one
> > > */
> > > +        radix_tree_replace_slot(
> > > +            radix_tree_lookup_slot(
> > > +                &p2m->mem_access_settings, gfn),
> > > +            radix_tree_int_to_ptr(a));
> > > +}
> > > +
>
> ________________________
> This email was scanned by Bitdefender

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

  reply	other threads:[~2018-06-19 14:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-18 15:17 [PATCH v2] x86/mm: Add mem access rights to NPT Alexandru Isaila
2018-06-18 15:39 ` Tamas K Lengyel
2018-06-19  8:14   ` Alexandru Stefan ISAILA
2018-06-19 14:22     ` Tamas K Lengyel [this message]
2018-06-22 15:51 ` Jan Beulich
2018-06-28 14:10   ` Alexandru Stefan ISAILA
2018-06-28 14:40     ` Jan Beulich
2018-06-28 14:53       ` Alexandru Stefan ISAILA
2018-06-28 14:58         ` Razvan Cojocaru
2018-06-29  6:17           ` Jan Beulich
2018-06-29  6:13         ` Jan Beulich
2018-06-29  8:42           ` Alexandru Stefan ISAILA
2018-06-29  9:38             ` Jan Beulich
2018-06-29 16:42               ` Tamas K Lengyel
2018-07-02  6:37                 ` Jan Beulich
2018-07-02  8:01                   ` Alexandru Stefan ISAILA
2018-07-02  8:20                     ` Jan Beulich
2018-06-28 16:29       ` Tamas K Lengyel

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=CABfawhnxFyv5jU6hXFdFbjttWcu5HfqhQT1jeFm5aOpLVfZHng@mail.gmail.com \
    --to=tamas@tklengyel.com \
    --cc=aisaila@bitdefender.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=rcojocaru@bitdefender.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 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.