diff mbox series

[Xen-devel,v5,03/16] xen/arm: mm: Use gaddr_to_gfn rather than _gfn(paddr_to_pfn(...))

Message ID 20180314182009.14274-4-julien.grall@arm.com
State Superseded
Headers show
Series xen: Convert page_to_mfn and mfn_to_page to use typesafe MFN | expand

Commit Message

Julien Grall March 14, 2018, 6:19 p.m. UTC
From: Julien Grall <julien.grall@arm.com>

The construction _gfn(paddr_to_pfn(...)) can be simplified by using
gaddr_to_gfn.

Signed-off-by: Julien Grall <julien.grall@arm.com>

---
Cc: Stefano Stabellini <sstabellini@kernel.org>

    Changes in v4:
        - Patch added
---
 xen/arch/arm/mm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

George Dunlap March 15, 2018, 4:15 p.m. UTC | #1
On Wed, Mar 14, 2018 at 6:19 PM,  <julien.grall@arm.com> wrote:
> From: Julien Grall <julien.grall@arm.com>
>
> The construction _gfn(paddr_to_pfn(...)) can be simplified by using
> gaddr_to_gfn.
>
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Not sure if "simplified" is the right word here (and in the previous
patch); simplified implies fewer steps in the calculation, but it
looks like the steps so far are identical.  Using a macro rather than
hand-coding stuff is cleaner and more maintainable; don't think it
really needs to be justified.

In any case:

Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Julien Grall March 20, 2018, 8:33 a.m. UTC | #2
Hi George,

On 03/15/2018 04:15 PM, George Dunlap wrote:
> On Wed, Mar 14, 2018 at 6:19 PM,  <julien.grall@arm.com> wrote:
>> From: Julien Grall <julien.grall@arm.com>
>>
>> The construction _gfn(paddr_to_pfn(...)) can be simplified by using
>> gaddr_to_gfn.
>>
>> Signed-off-by: Julien Grall <julien.grall@arm.com>
> 
> Not sure if "simplified" is the right word here (and in the previous
> patch); simplified implies fewer steps in the calculation, but it
> looks like the steps so far are identical.  Using a macro rather than
> hand-coding stuff is cleaner and more maintainable; don't think it
> really needs to be justified.

I can drop the justification in both patches.

> 
> In any case:
> 
> Reviewed-by: George Dunlap <george.dunlap@citrix.com>

Thank you!

Cheers,
diff mbox series

Patch

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 3c328e2df5..9b77ab5f33 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -1436,7 +1436,7 @@  int create_grant_host_mapping(unsigned long addr, unsigned long frame,
     if ( flags & GNTMAP_readonly )
         t = p2m_grant_map_ro;
 
-    rc = guest_physmap_add_entry(current->domain, _gfn(addr >> PAGE_SHIFT),
+    rc = guest_physmap_add_entry(current->domain, gaddr_to_gfn(addr),
                                  _mfn(frame), 0, t);
 
     if ( rc )
@@ -1448,7 +1448,7 @@  int create_grant_host_mapping(unsigned long addr, unsigned long frame,
 int replace_grant_host_mapping(unsigned long addr, unsigned long mfn,
         unsigned long new_addr, unsigned int flags)
 {
-    gfn_t gfn = _gfn(addr >> PAGE_SHIFT);
+    gfn_t gfn = gaddr_to_gfn(addr);
     struct domain *d = current->domain;
     int rc;