diff mbox series

[Xen-devel,v4,07/16] xen/x86: mm: Switch x86/mm.c to use typesafe for virt_to_mfn

Message ID 20180221140259.29360-8-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 Feb. 21, 2018, 2:02 p.m. UTC
No functional change intended.

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

---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>

    Changes in v4:
        - Patch added
---
 xen/arch/x86/mm.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

Comments

Jan Beulich March 2, 2018, 2:45 p.m. UTC | #1
>>> On 21.02.18 at 15:02, <julien.grall@arm.com> wrote:
> No functional change intended.
> 
> Signed-off Julien Grall <julien.grall@arm.com>

Acked-by: Jan Beulich <jbeulich@suse.com>
with one remark:

> @@ -5545,8 +5547,7 @@ static void __memguard_change_range(void *p, unsigned long l, int guard)
>      if ( guard )
>          flags &= ~_PAGE_PRESENT;
>  
> -    map_pages_to_xen(
> -        _p, virt_to_maddr(p) >> PAGE_SHIFT, _l >> PAGE_SHIFT, flags);
> +    map_pages_to_xen(_p, mfn_x(virt_to_mfn(p)), _l >> PAGE_SHIFT, flags);

Would have been nice if this was switched to PFN_DOWN() instead
of the open coded shift right away.

Jan
Julien Grall March 2, 2018, 2:46 p.m. UTC | #2
Hi Jan,

On 02/03/18 14:45, Jan Beulich wrote:
>>>> On 21.02.18 at 15:02, <julien.grall@arm.com> wrote:
>> No functional change intended.
>>
>> Signed-off Julien Grall <julien.grall@arm.com>
> 
> Acked-by: Jan Beulich <jbeulich@suse.com>
> with one remark:
> 
>> @@ -5545,8 +5547,7 @@ static void __memguard_change_range(void *p, unsigned long l, int guard)
>>       if ( guard )
>>           flags &= ~_PAGE_PRESENT;
>>   
>> -    map_pages_to_xen(
>> -        _p, virt_to_maddr(p) >> PAGE_SHIFT, _l >> PAGE_SHIFT, flags);
>> +    map_pages_to_xen(_p, mfn_x(virt_to_mfn(p)), _l >> PAGE_SHIFT, flags);
> 
> Would have been nice if this was switched to PFN_DOWN() instead
> of the open coded shift right away.

I can do that.

Cheers,
diff mbox series

Patch

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index e1f089be14..eba1afaa31 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -135,6 +135,8 @@ 
 #define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn))
 #undef page_to_mfn
 #define page_to_mfn(pg) _mfn(__page_to_mfn(pg))
+#undef virt_to_mfn
+#define virt_to_mfn(v) _mfn(__virt_to_mfn(v))
 
 /* Mapping of the fixmap space needed early. */
 l1_pgentry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE)
@@ -380,7 +382,7 @@  void __init arch_init_memory(void)
                         l3tab[i] = l3idle[i];
                     for ( ; i < L3_PAGETABLE_ENTRIES; ++i )
                         l3tab[i] = l3e_empty();
-                    split_l4e = l4e_from_pfn(virt_to_mfn(l3tab),
+                    split_l4e = l4e_from_mfn(virt_to_mfn(l3tab),
                                              __PAGE_HYPERVISOR_RW);
                 }
                 else
@@ -4159,7 +4161,7 @@  int xenmem_add_to_physmap_one(
     {
         case XENMAPSPACE_shared_info:
             if ( idx == 0 )
-                mfn = _mfn(virt_to_mfn(d->shared_info));
+                mfn = virt_to_mfn(d->shared_info);
             break;
         case XENMAPSPACE_grant_table:
             rc = gnttab_map_frame(d, idx, gpfn, &mfn);
@@ -4783,7 +4785,7 @@  int map_pages_to_xen(
             if ( (l3e_get_flags(*pl3e) & _PAGE_PRESENT) &&
                  (l3e_get_flags(*pl3e) & _PAGE_PSE) )
             {
-                l3e_write_atomic(pl3e, l3e_from_pfn(virt_to_mfn(pl2e),
+                l3e_write_atomic(pl3e, l3e_from_mfn(virt_to_mfn(pl2e),
                                                     __PAGE_HYPERVISOR));
                 pl2e = NULL;
             }
@@ -4879,7 +4881,7 @@  int map_pages_to_xen(
                 if ( (l2e_get_flags(*pl2e) & _PAGE_PRESENT) &&
                      (l2e_get_flags(*pl2e) & _PAGE_PSE) )
                 {
-                    l2e_write_atomic(pl2e, l2e_from_pfn(virt_to_mfn(pl1e),
+                    l2e_write_atomic(pl2e, l2e_from_mfn(virt_to_mfn(pl1e),
                                                         __PAGE_HYPERVISOR));
                     pl1e = NULL;
                 }
@@ -5087,7 +5089,7 @@  int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf)
             if ( (l3e_get_flags(*pl3e) & _PAGE_PRESENT) &&
                  (l3e_get_flags(*pl3e) & _PAGE_PSE) )
             {
-                l3e_write_atomic(pl3e, l3e_from_pfn(virt_to_mfn(pl2e),
+                l3e_write_atomic(pl3e, l3e_from_mfn(virt_to_mfn(pl2e),
                                                     __PAGE_HYPERVISOR));
                 pl2e = NULL;
             }
@@ -5141,7 +5143,7 @@  int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf)
                 if ( (l2e_get_flags(*pl2e) & _PAGE_PRESENT) &&
                      (l2e_get_flags(*pl2e) & _PAGE_PSE) )
                 {
-                    l2e_write_atomic(pl2e, l2e_from_pfn(virt_to_mfn(pl1e),
+                    l2e_write_atomic(pl2e, l2e_from_mfn(virt_to_mfn(pl1e),
                                                         __PAGE_HYPERVISOR));
                     pl1e = NULL;
                 }
@@ -5545,8 +5547,7 @@  static void __memguard_change_range(void *p, unsigned long l, int guard)
     if ( guard )
         flags &= ~_PAGE_PRESENT;
 
-    map_pages_to_xen(
-        _p, virt_to_maddr(p) >> PAGE_SHIFT, _l >> PAGE_SHIFT, flags);
+    map_pages_to_xen(_p, mfn_x(virt_to_mfn(p)), _l >> PAGE_SHIFT, flags);
 }
 
 void memguard_guard_range(void *p, unsigned long l)