From: Mukesh Rathor <mukesh.rathor@oracle.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: "Xen-devel@lists.xensource.com" <Xen-devel@lists.xensource.com>,
Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: Re: [PATCH v1 7/8]: PVH privcmd changes
Date: Mon, 8 Oct 2012 12:10:59 -0700 [thread overview]
Message-ID: <20121008121059.60094d43@mantra.us.oracle.com> (raw)
In-Reply-To: <1349688102.18008.34.camel@zakaz.uk.xensource.com>
On Mon, 8 Oct 2012 10:21:42 +0100
Ian Campbell <Ian.Campbell@citrix.com> wrote:
> On Fri, 2012-10-05 at 22:22 +0100, Mukesh Rathor wrote:
> > On Fri, 5 Oct 2012 10:21:18 +0100
> > Ian Campbell <Ian.Campbell@citrix.com> wrote:
> >
> > > On Thu, 2012-10-04 at 19:20 +0100, Mukesh Rathor wrote:
> > > > On Thu, 4 Oct 2012 09:50:42 +0100
> > > > Ian Campbell <Ian.Campbell@citrix.com> wrote:
> > > >
> > > > >
> > > > > Won't that break because on the second call you will pass in
> > > > > the freshly allocated pointer and overwrite the exiting
> > > > > (useful) one with it?
> > > >
> > > > No, for xlate, I just check for NULL. I didn't think it was big
> > > > deal to special case xlate in this case. We got so many if
> > > > xlate cases already thru the code. It leaves the semantics easy
> > > > to understand: NULL == avail. 1 == locked PV. PTR == Locked
> > > > PVH. I'll add a comment this time :).
> > >
> > > The transition from NULL => Locked PVH still needs to be done
> > > atomically and without clobbering any existing non-NULL value,
> > > otherwise it doesn't actually protect against multiple mappings
> > > like it is supposed to.
>
> > Ok, changed it to, and tested it:
> >
> > static int privcmd_enforce_singleshot_mapping(struct vm_area_struct
> > *vma) {
> > if (xen_feature(XENFEAT_auto_translated_physmap)) {
> > int sz = sizeof(vma->vm_private_data);
> > return (!__cmpxchg(&vma->vm_private_data, NULL,
> > NULL, sz));
>
> Passing NULL for both old and new values can't be right, can it? Did
> you test with something which tries to map twice?
well, if it's already set to pointer, then __cmpxchg would leave the ptr
alone and return it. The function would then return false which would
fail the api. OTOH, if it's NULL, it would continue and get set later.
> Also using cmpxchg instead of __cmpxchg includes the sizeof bit for
> you automatically and IIRC Coding-Style doesn't like () around return
> values.
>
> So, I think you want:
> return !cmpxchg(&vma->vm_private_data, NULL, 1);
This would work also, and is prob better than to special condition
xlated.
thanks
Mukesh
next prev parent reply other threads:[~2012-10-08 19:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-21 19:21 [PATCH v1 7/8]: PVH privcmd changes Mukesh Rathor
2012-09-24 14:24 ` Stefano Stabellini
2012-09-25 13:44 ` Ian Campbell
2012-09-26 1:28 ` Mukesh Rathor
2012-09-26 13:13 ` Konrad Rzeszutek Wilk
2012-09-25 13:46 ` Ian Campbell
2012-10-02 10:54 ` Stefano Stabellini
2012-10-03 13:21 ` Ian Campbell
2012-10-03 22:31 ` Mukesh Rathor
2012-10-04 8:50 ` Ian Campbell
2012-10-04 18:20 ` Mukesh Rathor
2012-10-05 9:21 ` Ian Campbell
2012-10-05 17:34 ` Mukesh Rathor
2012-10-05 21:22 ` Mukesh Rathor
2012-10-08 9:21 ` Ian Campbell
2012-10-08 19:10 ` Mukesh Rathor [this message]
2012-10-08 19:26 ` Ian Campbell
2012-10-08 20:46 ` Mukesh Rathor
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=20121008121059.60094d43@mantra.us.oracle.com \
--to=mukesh.rathor@oracle.com \
--cc=Ian.Campbell@citrix.com \
--cc=Stefano.Stabellini@eu.citrix.com \
--cc=Xen-devel@lists.xensource.com \
--cc=konrad.wilk@oracle.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).