xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <Ian.Campbell@citrix.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: xen-devel@lists.xensource.com, tim@xen.org
Subject: Re: [PATCH v4 3/4] xen: implement guest_physmap_(un)pin_range
Date: Fri, 6 Sep 2013 17:12:07 +0100	[thread overview]
Message-ID: <1378483927.14745.155.camel@kazak.uk.xensource.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1309061700220.6397@kaball.uk.xensource.com>

On Fri, 2013-09-06 at 17:06 +0100, Stefano Stabellini wrote:
> On Mon, 19 Aug 2013, Ian Campbell wrote:
> > > +{
> > > +    lpae_t pte = *ptep;
> > > +    if ( pte.p2m.avail & P2M_DMA_PIN )
> > > +        return -EINVAL;
> > > +    pte.p2m.avail |= P2M_DMA_PIN;
> > 
> > I think test_and_set_bit would be better here and you should operate on
> > ptep directly IMHO rather than changing a copy and writing that. Might
> > require a pte_modified macro with the flushing stuff from write_pte.
> > 
> 
> Considering that ptep->p2m.avail is a bit-field and that
> test_and_set_bit operates on a unsigned long pointer (one cannot get a
> pointer to a bit-field), and considering that avail is at bit 55 > 32
> (we would need to take care of incrementing the pointer too),

No you don't, test_and_set_bit can cope with bitfields bigger than
wordsize.

All you would need is 
	#define P2M_DMA_PIN 54
	test_and_set_bit(P2M_DMA_PIN, &ptr.bits)

>  I think
> that it's not worth making this change because it would make the code
> far less readable.
> 
> In any case these two functions are called with the p2m lock held, so
> the current implementation should be safe. 

Ah, in that case you can do either as you wish.

Ian

  reply	other threads:[~2013-09-06 16:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-15 11:17 [PATCH v4 0/4] introduce XENMEM_exchange_and_pin and XENMEM_unpin Stefano Stabellini
2013-08-15 11:18 ` [PATCH v4 1/4] xen/arm: implement steal_page Stefano Stabellini
2013-08-19 16:20   ` Ian Campbell
2013-08-15 11:18 ` [PATCH v4 2/4] xen/arm: introduce a generic p2m walker and use it in p2m_lookup Stefano Stabellini
2013-08-19 16:30   ` Ian Campbell
2013-08-15 11:18 ` [PATCH v4 3/4] xen: implement guest_physmap_(un)pin_range Stefano Stabellini
2013-08-19 16:35   ` Ian Campbell
2013-09-06 16:06     ` Stefano Stabellini
2013-09-06 16:12       ` Ian Campbell [this message]
2013-08-15 11:18 ` [PATCH v4 4/4] xen: introduce XENMEM_exchange_and_pin and XENMEM_unpin Stefano Stabellini
2013-08-15 13:03   ` Jan Beulich
2013-09-06 17:55     ` Stefano Stabellini

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=1378483927.14745.155.camel@kazak.uk.xensource.com \
    --to=ian.campbell@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xensource.com \
    /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).