From: Julien Grall <julien.grall@arm.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: xen-devel@lists.xenproject.org, Jan Beulich <JBeulich@suse.com>,
Andrew Cooper <andrew.cooper3@citrix.com>
Subject: Re: [PATCH for-next 1/9] xen/arm: Use mfn_to_pdx instead of pfn_to_pdx when possible
Date: Wed, 17 Apr 2019 18:07:51 +0100 [thread overview]
Message-ID: <02478ff8-d1e2-abe1-74a5-ca72ab87f154@arm.com> (raw)
In-Reply-To: <c3e5008c-7dd2-61b5-bec1-287b310a471c@arm.com>
(+ Andrew and Jan)
On 15/04/2019 23:42, Julien Grall wrote:
> Hi,
>
> On 4/15/19 11:25 PM, Stefano Stabellini wrote:
>> On Mon, 15 Apr 2019, Julien Grall wrote:
>>> Hi,
>>>
>>> On 4/15/19 10:55 PM, Stefano Stabellini wrote:
>>>> On Mon, 18 Feb 2019, Julien Grall wrote:
>>>>> mfn_to_pdx adds more safety than pfn_to_pdx. Replace all but on place in
>>>>> the Arm code to use the former.
>>>>
>>>> This is good but maybe we can go even further.
>>>>
>>>> You should also be able to replace one call site of pfn_to_pdx in
>>>> mfn_valid and the one in maddr_to_virt. Something like this:
>>>>
>>>>
>>>> diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h
>>>> index eafa26f..b3455ea 100644
>>>> --- a/xen/include/asm-arm/mm.h
>>>> +++ b/xen/include/asm-arm/mm.h
>>>> @@ -209,7 +209,7 @@ static inline void __iomem *ioremap_wc(paddr_t start,
>>>> size_t len)
>>>> /* XXX -- account for base */
>>>> #define mfn_valid(mfn) ({
>>>> \
>>>> unsigned long __m_f_n = mfn_x(mfn);
>>>> \
>>>> - likely(pfn_to_pdx(__m_f_n) >= frametable_base_pdx &&
>>>> __mfn_valid(__m_f_n)); \
>>>> + likely(mfn_to_pdx(mfn) >= frametable_base_pdx && __mfn_valid(__m_f_n));
>>>> \
>>>
>>> This is quite undesirable, you will end up to evaluate mfn twice here.
I have been looking at making __mfn_valid(...) typesafe. While it compiles
on Arm, I have a build error on x86:
In file included from /home/julieng/works/xen/xen/include/asm/x86_64/page.h:47:0,
from /home/julieng/works/xen/xen/include/asm/page.h:23,
from /home/julieng/works/xen/xen/include/asm/current.h:12,
from /home/julieng/works/xen/xen/include/asm/smp.h:10,
from /home/julieng/works/xen/xen/include/xen/smp.h:4,
from /home/julieng/works/xen/xen/include/xen/perfc.h:7,
from x86_64/asm-offsets.c:8:
/home/julieng/works/xen/xen/include/xen/pdx.h:24:18: error: unknown type name ‘mfn_t’
bool __mfn_valid(mfn_t mfn);
^~~~~
In file included from /home/julieng/works/xen/xen/include/xen/config.h:13:0,
from <command-line>:0:
/home/julieng/works/xen/xen/include/asm/mm.h: In function ‘get_page_from_mfn’:
/home/julieng/works/xen/xen/include/asm/page.h:262:29: error: implicit declaration of function ‘__mfn_valid’ [-Werror=implicit-function-declaration]
#define mfn_valid(mfn) __mfn_valid(mfn)
^
/home/julieng/works/xen/xen/include/xen/compiler.h:11:43: note: in definition of macro ‘unlikely’
#define unlikely(x) __builtin_expect(!!(x),0)
We get away on Arm because mfn_valid is implemented in mm.h. On x86 it is implemented
in page.h. I am quite impressed we never had build failure in common code until now...
Anyway, it is not the first time I see build error when trying to make the code using
typesafe gfn/mfn. The headers dependency are quite messy in general.
Andrew, Jan do you have a suggestion how to process on the x86 side?
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
WARNING: multiple messages have this Message-ID (diff)
From: Julien Grall <julien.grall@arm.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: xen-devel@lists.xenproject.org, Jan Beulich <JBeulich@suse.com>,
Andrew Cooper <andrew.cooper3@citrix.com>
Subject: Re: [Xen-devel] [PATCH for-next 1/9] xen/arm: Use mfn_to_pdx instead of pfn_to_pdx when possible
Date: Wed, 17 Apr 2019 18:07:51 +0100 [thread overview]
Message-ID: <02478ff8-d1e2-abe1-74a5-ca72ab87f154@arm.com> (raw)
Message-ID: <20190417170751.xRGOlHxAac53wKu4Ox_HjR3aYq3VKLn5RSP9knKrshI@z> (raw)
In-Reply-To: <c3e5008c-7dd2-61b5-bec1-287b310a471c@arm.com>
(+ Andrew and Jan)
On 15/04/2019 23:42, Julien Grall wrote:
> Hi,
>
> On 4/15/19 11:25 PM, Stefano Stabellini wrote:
>> On Mon, 15 Apr 2019, Julien Grall wrote:
>>> Hi,
>>>
>>> On 4/15/19 10:55 PM, Stefano Stabellini wrote:
>>>> On Mon, 18 Feb 2019, Julien Grall wrote:
>>>>> mfn_to_pdx adds more safety than pfn_to_pdx. Replace all but on place in
>>>>> the Arm code to use the former.
>>>>
>>>> This is good but maybe we can go even further.
>>>>
>>>> You should also be able to replace one call site of pfn_to_pdx in
>>>> mfn_valid and the one in maddr_to_virt. Something like this:
>>>>
>>>>
>>>> diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h
>>>> index eafa26f..b3455ea 100644
>>>> --- a/xen/include/asm-arm/mm.h
>>>> +++ b/xen/include/asm-arm/mm.h
>>>> @@ -209,7 +209,7 @@ static inline void __iomem *ioremap_wc(paddr_t start,
>>>> size_t len)
>>>> /* XXX -- account for base */
>>>> #define mfn_valid(mfn) ({
>>>> \
>>>> unsigned long __m_f_n = mfn_x(mfn);
>>>> \
>>>> - likely(pfn_to_pdx(__m_f_n) >= frametable_base_pdx &&
>>>> __mfn_valid(__m_f_n)); \
>>>> + likely(mfn_to_pdx(mfn) >= frametable_base_pdx && __mfn_valid(__m_f_n));
>>>> \
>>>
>>> This is quite undesirable, you will end up to evaluate mfn twice here.
I have been looking at making __mfn_valid(...) typesafe. While it compiles
on Arm, I have a build error on x86:
In file included from /home/julieng/works/xen/xen/include/asm/x86_64/page.h:47:0,
from /home/julieng/works/xen/xen/include/asm/page.h:23,
from /home/julieng/works/xen/xen/include/asm/current.h:12,
from /home/julieng/works/xen/xen/include/asm/smp.h:10,
from /home/julieng/works/xen/xen/include/xen/smp.h:4,
from /home/julieng/works/xen/xen/include/xen/perfc.h:7,
from x86_64/asm-offsets.c:8:
/home/julieng/works/xen/xen/include/xen/pdx.h:24:18: error: unknown type name ‘mfn_t’
bool __mfn_valid(mfn_t mfn);
^~~~~
In file included from /home/julieng/works/xen/xen/include/xen/config.h:13:0,
from <command-line>:0:
/home/julieng/works/xen/xen/include/asm/mm.h: In function ‘get_page_from_mfn’:
/home/julieng/works/xen/xen/include/asm/page.h:262:29: error: implicit declaration of function ‘__mfn_valid’ [-Werror=implicit-function-declaration]
#define mfn_valid(mfn) __mfn_valid(mfn)
^
/home/julieng/works/xen/xen/include/xen/compiler.h:11:43: note: in definition of macro ‘unlikely’
#define unlikely(x) __builtin_expect(!!(x),0)
We get away on Arm because mfn_valid is implemented in mm.h. On x86 it is implemented
in page.h. I am quite impressed we never had build failure in common code until now...
Anyway, it is not the first time I see build error when trying to make the code using
typesafe gfn/mfn. The headers dependency are quite messy in general.
Andrew, Jan do you have a suggestion how to process on the x86 side?
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-04-17 17:07 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-18 11:35 [PATCH for-next 0/9] xen/arm: Properly disable M2P on Arm Julien Grall
2019-02-18 11:35 ` [PATCH for-next 1/9] xen/arm: Use mfn_to_pdx instead of pfn_to_pdx when possible Julien Grall
2019-04-15 21:55 ` Stefano Stabellini
2019-04-15 21:55 ` [Xen-devel] " Stefano Stabellini
2019-04-15 22:03 ` Julien Grall
2019-04-15 22:03 ` [Xen-devel] " Julien Grall
2019-04-15 22:25 ` Stefano Stabellini
2019-04-15 22:25 ` [Xen-devel] " Stefano Stabellini
2019-04-15 22:42 ` Julien Grall
2019-04-15 22:42 ` [Xen-devel] " Julien Grall
2019-04-17 17:07 ` Julien Grall [this message]
2019-04-17 17:07 ` Julien Grall
2019-04-25 11:20 ` Jan Beulich
2019-04-25 11:20 ` [Xen-devel] " Jan Beulich
2019-04-29 16:30 ` Julien Grall
2019-04-29 16:30 ` [Xen-devel] " Julien Grall
2019-02-18 11:35 ` [PATCH for-next 2/9] xen/x86: Constify the parameter "d" in mfn_to_mfn Julien Grall
2019-03-13 14:40 ` Jan Beulich
2019-02-18 11:35 ` [PATCH for-next 3/9] xen/x86: Use mfn_to_gfn rather than mfn_to_gmfn Julien Grall
2019-03-13 14:45 ` Jan Beulich
2019-03-13 15:13 ` Julien Grall
2019-02-18 11:35 ` [PATCH for-next 4/9] xen/grant-table: Make arch specific macros typesafe Julien Grall
2019-03-13 14:51 ` Jan Beulich
2019-04-15 22:03 ` Stefano Stabellini
2019-04-15 22:03 ` [Xen-devel] " Stefano Stabellini
2019-04-15 22:07 ` Julien Grall
2019-04-15 22:07 ` [Xen-devel] " Julien Grall
2019-02-18 11:35 ` [PATCH for-next 5/9] xen: Convert hotplug page function to use typesafe MFN Julien Grall
2019-03-13 14:57 ` Jan Beulich
2019-03-13 16:26 ` Julien Grall
2019-02-18 11:35 ` [PATCH for-next 6/9] xen: Convert is_xen_fixed_mfn " Julien Grall
2019-03-13 14:58 ` Jan Beulich
2019-04-15 22:05 ` Stefano Stabellini
2019-04-15 22:05 ` [Xen-devel] " Stefano Stabellini
2019-02-18 11:35 ` [PATCH for-next 7/9] xen: Convert is_xen_heap_mfn " Julien Grall
2019-03-13 15:04 ` Jan Beulich
2019-03-13 17:24 ` Julien Grall
2019-03-14 7:52 ` Jan Beulich
2019-03-14 10:12 ` Julien Grall
2019-03-14 10:14 ` Andrew Cooper
2019-03-14 10:19 ` Julien Grall
2019-03-14 11:47 ` Jan Beulich
2019-03-14 12:18 ` Andrew Cooper
2019-04-15 22:08 ` Stefano Stabellini
2019-04-15 22:08 ` [Xen-devel] " Stefano Stabellini
2019-02-18 11:35 ` [PATCH for-next 8/9] xen: Introduce HAS_M2P config and use to protect mfn_to_gmfn call Julien Grall
2019-03-13 15:20 ` Jan Beulich
2019-03-13 17:30 ` Julien Grall
2019-03-14 7:55 ` Jan Beulich
2019-04-17 17:42 ` Julien Grall
2019-04-17 17:42 ` [Xen-devel] " Julien Grall
2019-04-18 11:46 ` Wei Liu
2019-04-18 11:46 ` [Xen-devel] " Wei Liu
2019-04-18 15:09 ` Julien Grall
2019-04-18 15:09 ` [Xen-devel] " Julien Grall
2019-04-24 15:28 ` Julien Grall
2019-04-24 15:28 ` [Xen-devel] " Julien Grall
2019-04-25 10:03 ` Wei Liu
2019-04-25 10:03 ` [Xen-devel] " Wei Liu
2019-04-15 22:17 ` Stefano Stabellini
2019-04-15 22:17 ` [Xen-devel] " Stefano Stabellini
2019-04-25 10:06 ` Jan Beulich
2019-04-25 10:06 ` [Xen-devel] " Jan Beulich
2019-02-18 11:36 ` [PATCH for-next 9/9] xen: Remove mfn_to_gmfn macro Julien Grall
2019-03-13 15:22 ` Jan Beulich
2019-03-13 15:24 ` Julien Grall
2019-03-13 15:40 ` Jan Beulich
2019-03-13 15:48 ` Julien Grall
2019-03-13 15:59 ` Jan Beulich
2019-03-13 17:34 ` Andrew Cooper
2019-03-13 17:42 ` Julien Grall
2019-03-13 18:41 ` Andrew Cooper
2019-03-14 8:05 ` Jan Beulich
2019-03-14 7:59 ` Jan Beulich
2019-05-07 14:35 ` Julien Grall
2019-05-07 14:35 ` [Xen-devel] " Julien Grall
2019-04-15 22:19 ` Stefano Stabellini
2019-04-15 22:19 ` [Xen-devel] " 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=02478ff8-d1e2-abe1-74a5-ca72ab87f154@arm.com \
--to=julien.grall@arm.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=sstabellini@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 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.