xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: Jan Beulich <JBeulich@suse.com>
Cc: Tim Deegan <tim@xen.org>, Kevin Tian <kevin.tian@intel.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	Jun Nakajima <jun.nakajima@intel.com>,
	Razvan Cojocaru <rcojocaru@bitdefender.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	xen-devel@lists.xen.org, Julien Grall <julien.grall@arm.com>,
	Paul Durrant <paul.durrant@citrix.com>,
	Tamas K Lengyel <tamas@tklengyel.com>,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
	Shane Wang <shane.wang@intel.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Gang Wei <gang.wei@intel.com>
Subject: Re: [PATCH v3 for-next 0/4] xen: Convert __page_to_mfn and _mfn_to_page to use typesafe MFN
Date: Thu, 9 Nov 2017 15:20:41 +0000	[thread overview]
Message-ID: <c693e2c7-9031-40a6-c2fb-0953daca098f@linaro.org> (raw)
In-Reply-To: <5A006739020000780018C8F1@prv-mh.provo.novell.com>

Hi Jan,

On 06/11/17 12:44, Jan Beulich wrote:
>>>> On 06.11.17 at 13:16, <julien.grall@linaro.org> wrote:
> 
>>
>> On 06/11/17 12:11, Jan Beulich wrote:
>>>>>> On 06.11.17 at 12:47, <julien.grall@linaro.org> wrote:
>>>> Hi Jan,
>>>>
>>>> On 06/11/17 11:37, Jan Beulich wrote:
>>>>>>>> On 01.11.17 at 15:03, <julien.grall@linaro.org> wrote:
>>>>>> Most of the users of page_to_mfn and mfn_to_page are either overriding
>>>>>> the macros to make them work with mfn_t or use mfn_x/_mfn becaue the rest
>>>>>> of the function use mfn_t.
>>>>>>
>>>>>> So I think it is time to make __page_to_mfn and __mfn_to_page using typesafe
>>>>>> MFN.
>>>>>
>>>>> I have to admit that I still find the overall goal confusing: Afaict
>>>>> the double-underscore-prefixed versions exist only to allow
>>>>> easily overriding the non-prefixed ones. Hence the first and
>>>>> foremost goal ought to be to convert everyone to using the
>>>>> non-prefixed versions. Files wanting to avoid the typed forms
>>>>> could then continue to use / be switched to the prefixed ones.
>>>>>
>>>>> What you're doing here is producing a mess: The prefixed
>>>>> versions should never have been touched in the first place.
>>>>> And iirc this was discussed before, with the suggestion to use
>>>>> overrides (for the non-prefixed versions) to limit overall patch
>>>>> size.
>>>>
>>>> At the end of the discussion in the previous version, you were happy
>>>> with the modification done here (see [1]).
>>>
>>>   From the angle looked at it back then I indeed was, but I'm looking
>>> at this from a slightly different angle now with the reply above.
>>>
>>>> Overall, I think this is an improvement compare to what we have today.
>>>> Because we enforce the use of MFN typesafe by default. The developer
>>>> would have to override the helpers if he wants to to use the
>>>> non-typesafe version.
>>>>
>>>> With your suggestion here, you would just keep the override around even
>>>> when they are not necessary. They will have to be dropped at some point,
>>>> so why not now?
>>>
>>> Why would we keep the overrides in place once no longer needed?
>>> All I'm asking for is that the double-underscore prefixed macros be
>>> left alone, and the non-prefixed versions be converted to be
>>> type-safe by default (with the option to override). That'll allow the
>>> prefixed variants to go way altogether once all code was switched
>>> to typesafe, no longer requiring any overrides.
>>
>> If you left the double-underscore alone, then you can't convert headers
>> using them to typesafe. This is because they can't use the non-prefixed
>> version as they may be override.
>>
>> So what you are suggesting here is will avoid converting those headers
>> until someone step up and finish to convert all the source to MFN
>> typesafe. Personally, I find quite silly to have to delay that...
> 
> Hmm, I see your point, but if we went the route you suggest,
> what would be the steps to reach the ultimate result I've
> described (the prefixed variants gone)? I seems to me that
> this would require touching a lot of code a second time that is
> being touched now, or is going to be touched as further
> conversion happens.

We would indeed need to modify the headers to use 
page_to_mfn/mfn_to_page instead of __page_to_mfn/__mfn_to_page. Those 
headers are:
	- asm-arm/mm.h
	- xen/domain_page.h
	- asm-x86/mm.h
	- asm-x86/page.h
	- asm-x86/p2m.h

I had a look at the files that needs to convert. It seems there are few 
files with page_to_mfn/mfn_to_page re-defined but no callers:
	- arch/x86/mm/hap/nested_hap.c
	- arch/x86/mm/p2m-pt.c
	- arch/x86/pv/traps.c
	- arch/x86/pv/mm.c
	- arch/x86/pv/iret.c

Those can be fixed now. That leave the following files:
	- arch/x86/mm/p2m-ept.c
		In that file, the override prevents all the caller to use the 
construction mfn_to_page(_mfn(...)) as it mostly deals with hardware.
	- arch/x86/x86_64/mm.c
		This is could be done without too much trouble.
	- arch/x86/pv/dom0_build.c
		It would need a bit of rework to get the code MFN typesafe in a neat way.
	- drivers/passthrough/amd/iommu_map.c
		It would need a bit of rework to get the code MFN typesafe in a neat way.
	- common/trace.c
		I think it should be ok. Though I am bit surprised to see uint32_t 
been used for MFN...
	- common/memory.c
		It would need a bit of rework to get the code MFN typesafe in a neat way.
	- common/page_alloc.c
		This is could be done without too much trouble.
	- common/grant_table.c
		It would need a bit of rework to get the code MFN typesafe in a neat way.

Cheers,

-- 
Julien Grall

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

  reply	other threads:[~2017-11-09 15:20 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-01 14:03 [PATCH v3 for-next 0/4] xen: Convert __page_to_mfn and _mfn_to_page to use typesafe MFN Julien Grall
2017-11-01 14:03 ` [PATCH v3 for-next 1/4] xen/arm: domain_build: Clean-up insert_11_bank Julien Grall
2017-12-11 23:25   ` Stefano Stabellini
2017-11-01 14:03 ` [PATCH v3 for-next 2/4] xen/arm32: mm: Rework is_xen_heap_page to avoid nameclash Julien Grall
2017-12-11 23:25   ` Stefano Stabellini
2017-11-01 14:03 ` [PATCH v3 for-next 3/4] xen/tmem: Convert the file common/tmem_xen.c to use typesafe MFN Julien Grall
2017-11-01 18:54   ` Konrad Rzeszutek Wilk
2017-11-02 15:18     ` Julien Grall
2017-11-01 14:03 ` [PATCH v3 for-next 4/4] xen: Convert __page_to_mfn and __mfn_to_page " Julien Grall
2017-11-01 15:35   ` Paul Durrant
2017-11-01 15:43   ` Razvan Cojocaru
2017-11-01 18:38   ` Boris Ostrovsky
2017-11-02  2:52   ` Tian, Kevin
2017-11-02  8:35   ` Tim Deegan
2017-12-11 23:36   ` Stefano Stabellini
2017-11-06 11:37 ` [PATCH v3 for-next 0/4] xen: Convert __page_to_mfn and _mfn_to_page " Jan Beulich
2017-11-06 11:47   ` Julien Grall
2017-11-06 12:11     ` Jan Beulich
2017-11-06 12:16       ` Julien Grall
2017-11-06 12:44         ` Jan Beulich
2017-11-09 15:20           ` Julien Grall [this message]
2017-11-09 15:36             ` Jan Beulich
2017-11-09 15:39               ` Julien Grall
2017-11-09 15:47                 ` Jan Beulich
2017-11-09 15:48                   ` Julien Grall
2017-11-09 16:12                     ` Jan Beulich
2017-12-11 23:37                       ` Stefano Stabellini
2017-12-11 23:53                         ` 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=c693e2c7-9031-40a6-c2fb-0953daca098f@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=gang.wei@intel.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=julien.grall@arm.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=konrad.wilk@oracle.com \
    --cc=paul.durrant@citrix.com \
    --cc=rcojocaru@bitdefender.com \
    --cc=shane.wang@intel.com \
    --cc=sstabellini@kernel.org \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=tamas@tklengyel.com \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.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 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).