linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: Julien Grall <julien.grall@citrix.com>, xen-devel@lists.xenproject.org
Cc: linux-fbdev@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	"Jiri Slaby" <jslaby@suse.com>,
	"Russell King" <linux@arm.linux.org.uk>,
	linux-scsi@vger.kernel.org, x86@kernel.org,
	"Tomi Valkeinen" <tomi.valkeinen@ti.com>,
	linux-input@vger.kernel.org,
	"Jean-Christophe Plagniol-Villard" <plagnioj@jcrosoft.com>,
	ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com,
	"James E.J. Bottomley" <JBottomley@odin.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>,
	linux-arm-kernel@lists.infradead.org,
	"Juergen Gross" <jgross@suse.com>,
	"Wei Liu" <wei.liu2@citrix.com>,
	"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	linux-kernel@vger.kernel.org,
	"David Vrabel" <david.vrabel@citrix.com>,
	netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 4/8] xen: Use the correctly the Xen memory terminologies
Date: Wed, 29 Jul 2015 10:14:47 -0400	[thread overview]
Message-ID: <55B8DFD7.6070107@oracle.com> (raw)
In-Reply-To: <55B8B846.2060103@citrix.com>

On 07/29/2015 07:25 AM, Julien Grall wrote:
> Hi Boris,
>
> On 28/07/15 20:12, Boris Ostrovsky wrote:
>> On 07/28/2015 11:02 AM, Julien Grall wrote:
>>> Based on include/xen/mm.h [1], Linux is mistakenly using MFN when GFN
>>> is meant, I suspect this is because the first support for Xen was for
>>> PV. This brough some misimplementation of helpers on ARM and make the
>>> developper confused the expected behavior.
>>>
>>> For instance, with pfn_to_mfn, we expect to get an MFN based on the name.
>>> Although, if we look at the implementation on x86, it's returning a GFN.
>>>
>>> For clarity and avoid new confusion, replace any reference of mfn into
>>> gnf in any helpers used by PV drivers.
>>
>>
>>
>>
>>> @@ -730,7 +730,7 @@ static void xen_do_pin(unsigned level, unsigned
>>> long pfn)
>>>        struct mmuext_op op;
>>>
>>>        op.cmd = level;
>>> -    op.arg1.mfn = pfn_to_mfn(pfn);
>>> +    op.arg1.mfn = pfn_to_gfn(pfn);
>>
>>
>> This looks slightly odd. It is correct but given that purpose of this
>> series is to make things more clear perhaps we can add another union
>> member (gfn) to mmuext_op.arg1?
>>
>> (Of course, the hypervisor will continue referring to mfn which could
>> still be confusing)
>
> This operation is only used for PV guests, right?
>
> IHMO re-introducing pfn_to_mfn for PV-guests only (i.e with a BUG_ON to
> ensure no usage for auto-translated guest) would be the best solution.
> It would avoid to have different name than the hypersivor one in the
> hypercall interface. It will also make clear that virt_to_machine & co
> is only PV specific.
>
> I though doing this but I preferred to defer it to x86 expert as my
> knowledge for x86 Xen is very limited. I don't know where it's more
> suitable to use MFN or GFN. I guess this file (mmu.c) is mostly PV specific?
>
> Would something like below fine for you?
>
> static inline unsigned long pfn_to_mfn(unsigned long pfn)
> {
> 	unsigned long mfn;
>
> 	BUG_ON(xen_feature(XENFEAT_auto_translated_physmap));
>
> 	mfn = __pfn_to_mfn(pfn);
> 	if (mfn != INVALID_P2M_ENTRY)
> 		mfn &= ~(FOREIGN_FRAME_BIT | IDENTITY_FRAME_BIT);
>
> 	return mfn;
> }
>
> static inline unsigned long pfn_to_gfn(unsigned long pfn)
> {
> 	if (xen_feature(XENFEAT_autotranslated_physmap))
> 		return pfn;
> 	else
> 		return pfn_to_mfn(pfn);
> }


But you'd still say 'op.arg1.mfn = pfn_to_gfn(pfn);' in xen_do_pin() 
i.e. assign GFN to MFN, right? That's what I was referring to.

(In general, I am not sure a guest should ever use 'mfn' as it is purely 
a hypervisor construct. Including p2m, which I think should really be 
p2g as this is what we use to figure out what to stick into page tables)

-boris


>
> Similar splitting would be done for gfn_to_pfn and mfn_to_pfn.
>
> Regards,
>

  reply	other threads:[~2015-07-29 14:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-28 15:02 [PATCH 0/8] Use correctly the Xen memory terminologies in Linux Julien Grall
2015-07-28 15:02 ` [PATCH 4/8] xen: Use the correctly the Xen memory terminologies Julien Grall
2015-07-28 17:16   ` [Xen-devel] " David Vrabel
2015-07-29 11:06     ` Julien Grall
2015-07-28 19:12   ` Boris Ostrovsky
2015-07-29 11:25     ` Julien Grall
2015-07-29 14:14       ` Boris Ostrovsky [this message]
2015-07-29 14:23         ` Julien Grall
2015-07-29 14:51           ` Boris Ostrovsky
2015-07-28 19:39   ` [Xen-devel] " Chris (Christopher) Brand
2015-07-29 11:27     ` Julien Grall
2015-07-29 10:13   ` Wei Liu
2015-07-29 11:35     ` [Xen-devel] " Julien Grall
2015-07-29 11:38       ` David Vrabel
2015-07-29 11:39       ` Wei Liu
2015-07-31 11:02   ` Stefano Stabellini
2015-07-28 21:06 ` [PATCH 0/8] Use correctly the Xen memory terminologies in Linux H. Peter Anvin
2015-07-28 21:12   ` [Xen-devel] " Andrew Cooper
2015-07-29 11:02 ` Julien Grall

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=55B8DFD7.6070107@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=JBottomley@odin.com \
    --cc=david.vrabel@citrix.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=ian.campbell@citrix.com \
    --cc=jgross@suse.com \
    --cc=jslaby@suse.com \
    --cc=julien.grall@citrix.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=plagnioj@jcrosoft.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tglx@linutronix.de \
    --cc=tomi.valkeinen@ti.com \
    --cc=wei.liu2@citrix.com \
    --cc=x86@kernel.org \
    --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).