All of lore.kernel.org
 help / color / mirror / Atom feed
From: julien.grall@arm.com
To: xen-devel@lists.xen.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Julien Grall <julien.grall@arm.com>,
	Jan Beulich <jbeulich@suse.com>
Subject: [PATCH v5 15/16] xen/x86: Switch mfn_to_page in x86_64/mm.c to use typesafe MFN
Date: Wed, 14 Mar 2018 18:20:08 +0000	[thread overview]
Message-ID: <20180314182009.14274-16-julien.grall@arm.com> (raw)
In-Reply-To: <20180314182009.14274-1-julien.grall@arm.com>

From: Julien Grall <julien.grall@arm.com>

Other than _mfn(0) -> INVALID_MFN, no functional change intendend.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Jan Beulich <jbeulich@suse.com>

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

    Changes in v5:
        - Use INVALID_MFN instead of _mfn(0)

    Changes in v4:
        - Patch added
---
 xen/arch/x86/x86_64/mm.c | 46 ++++++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c
index e03250bcdd..a54e2c9be4 100644
--- a/xen/arch/x86/x86_64/mm.c
+++ b/xen/arch/x86/x86_64/mm.c
@@ -43,6 +43,8 @@ asm(".file \"" __FILE__ "\"");
 /* Override macros from asm/page.h to make them work with mfn_t */
 #undef page_to_mfn
 #define page_to_mfn(pg) _mfn(__page_to_mfn(pg))
+#undef mfn_to_page
+#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn))
 
 unsigned int __read_mostly m2p_compat_vstart = __HYPERVISOR_COMPAT_VIRT_START;
 
@@ -160,7 +162,8 @@ static int m2p_mapped(unsigned long spfn)
 
 static int share_hotadd_m2p_table(struct mem_hotadd_info *info)
 {
-    unsigned long i, n, v, m2p_start_mfn = 0;
+    unsigned long i, n, v;
+    mfn_t m2p_start_mfn = INVALID_MFN;
     l3_pgentry_t l3e;
     l2_pgentry_t l2e;
 
@@ -180,15 +183,16 @@ static int share_hotadd_m2p_table(struct mem_hotadd_info *info)
             l2e = l3e_to_l2e(l3e)[l2_table_offset(v)];
             if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) )
                 continue;
-            m2p_start_mfn = l2e_get_pfn(l2e);
+            m2p_start_mfn = l2e_get_mfn(l2e);
         }
         else
             continue;
 
         for ( i = 0; i < n; i++ )
         {
-            struct page_info *page = mfn_to_page(m2p_start_mfn + i);
-            if (hotadd_mem_valid(m2p_start_mfn + i, info))
+            struct page_info *page = mfn_to_page(mfn_add(m2p_start_mfn, i));
+
+            if ( hotadd_mem_valid(mfn_x(mfn_add(m2p_start_mfn, i)), info) )
                 share_xen_page_with_privileged_guests(page, XENSHARE_readonly);
         }
     }
@@ -204,12 +208,13 @@ static int share_hotadd_m2p_table(struct mem_hotadd_info *info)
         l2e = l3e_to_l2e(l3e)[l2_table_offset(v)];
         if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) )
             continue;
-        m2p_start_mfn = l2e_get_pfn(l2e);
+        m2p_start_mfn = l2e_get_mfn(l2e);
 
         for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ )
         {
-            struct page_info *page = mfn_to_page(m2p_start_mfn + i);
-            if (hotadd_mem_valid(m2p_start_mfn + i, info))
+            struct page_info *page = mfn_to_page(mfn_add(m2p_start_mfn, i));
+
+            if ( hotadd_mem_valid(mfn_x(mfn_add(m2p_start_mfn, i)), info) )
                 share_xen_page_with_privileged_guests(page, XENSHARE_readonly);
         }
     }
@@ -720,10 +725,10 @@ static void cleanup_frame_table(struct mem_hotadd_info *info)
     unsigned long sva, eva;
     l3_pgentry_t l3e;
     l2_pgentry_t l2e;
-    unsigned long spfn, epfn;
+    mfn_t spfn, epfn;
 
-    spfn = info->spfn;
-    epfn = info->epfn;
+    spfn = _mfn(info->spfn);
+    epfn = _mfn(info->epfn);
 
     sva = (unsigned long)mfn_to_page(spfn);
     eva = (unsigned long)mfn_to_page(epfn);
@@ -795,16 +800,17 @@ static int setup_frametable_chunk(void *start, void *end,
 
 static int extend_frame_table(struct mem_hotadd_info *info)
 {
-    unsigned long cidx, nidx, eidx, spfn, epfn;
+    unsigned long cidx, nidx, eidx;
+    mfn_t spfn, epfn;
 
-    spfn = info->spfn;
-    epfn = info->epfn;
+    spfn = _mfn(info->spfn);
+    epfn = _mfn(info->epfn);
 
-    eidx = (pfn_to_pdx(epfn) + PDX_GROUP_COUNT - 1) / PDX_GROUP_COUNT;
-    nidx = cidx = pfn_to_pdx(spfn)/PDX_GROUP_COUNT;
+    eidx = (mfn_to_pdx(epfn) + PDX_GROUP_COUNT - 1) / PDX_GROUP_COUNT;
+    nidx = cidx = mfn_to_pdx(spfn)/PDX_GROUP_COUNT;
 
-    ASSERT( pfn_to_pdx(epfn) <= (DIRECTMAP_SIZE >> PAGE_SHIFT) &&
-            pfn_to_pdx(epfn) <= FRAMETABLE_NR );
+    ASSERT( mfn_to_pdx(epfn) <= (DIRECTMAP_SIZE >> PAGE_SHIFT) &&
+            mfn_to_pdx(epfn) <= FRAMETABLE_NR );
 
     if ( test_bit(cidx, pdx_group_valid) )
         cidx = find_next_zero_bit(pdx_group_valid, eidx, cidx);
@@ -866,7 +872,7 @@ void __init subarch_init_memory(void)
 
         for ( i = 0; i < n; i++ )
         {
-            struct page_info *page = mfn_to_page(m2p_start_mfn + i);
+            struct page_info *page = mfn_to_page(_mfn(m2p_start_mfn + i));
             share_xen_page_with_privileged_guests(page, XENSHARE_readonly);
         }
     }
@@ -886,7 +892,7 @@ void __init subarch_init_memory(void)
 
         for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ )
         {
-            struct page_info *page = mfn_to_page(m2p_start_mfn + i);
+            struct page_info *page = mfn_to_page(_mfn(m2p_start_mfn + i));
             share_xen_page_with_privileged_guests(page, XENSHARE_readonly);
         }
     }
@@ -1274,7 +1280,7 @@ static int transfer_pages_to_heap(struct mem_hotadd_info *info)
      */
     for (i = info->spfn; i < info->cur; i++)
     {
-        pg = mfn_to_page(i);
+        pg = mfn_to_page(_mfn(i));
         pg->count_info = PGC_state_inuse;
     }
 
-- 
2.11.0


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

  parent reply	other threads:[~2018-03-14 18:20 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-14 18:19 [PATCH v5 00/16] xen: Convert page_to_mfn and mfn_to_page to use typesafe MFN julien.grall
2018-03-14 18:19 ` [PATCH v5 01/16] x86/mm: skip incrementing mfn if it is not a valid mfn julien.grall
2018-03-14 18:31   ` Andrew Cooper
2018-03-15  7:52     ` Jan Beulich
2018-03-15 12:16       ` Andrew Cooper
2018-03-15 16:06         ` George Dunlap
2018-03-15  7:49   ` Jan Beulich
2018-03-15 15:05     ` Julien Grall
2018-03-14 18:19 ` [PATCH v5 02/16] xen/arm: setup: use maddr_to_mfn rather than _mfn(paddr_to_pfn(...)) julien.grall
2018-03-15 16:10   ` George Dunlap
2018-03-14 18:19 ` [PATCH v5 03/16] xen/arm: mm: Use gaddr_to_gfn rather than _gfn(paddr_to_pfn(...)) julien.grall
2018-03-15 16:15   ` George Dunlap
2018-03-20  8:33     ` Julien Grall
2018-03-14 18:19 ` [PATCH v5 04/16] xen/arm: mm: Remove unused M2P code julien.grall
2018-03-15  7:20   ` Alan Robinson
2018-03-20  8:34     ` Julien Grall
2018-03-15 16:25   ` George Dunlap
2018-03-20  9:09     ` Julien Grall
2018-03-14 18:19 ` [PATCH v5 05/16] xen/arm: mm: Remove unused relinquish_shared_pages julien.grall
2018-03-15 16:28   ` George Dunlap
2018-03-14 18:19 ` [PATCH v5 06/16] xen/x86: Remove unused override of page_to_mfn/mfn_to_page julien.grall
2018-03-14 18:20 ` [PATCH v5 07/16] xen/x86: mm: Switch x86/mm.c to use typesafe for virt_to_mfn julien.grall
2018-03-15 16:36   ` George Dunlap
2018-03-20  9:12     ` Julien Grall
2018-03-14 18:20 ` [PATCH v5 08/16] xen/mm: Drop the parameter mfn from populate_pt_range julien.grall
2018-03-14 18:34   ` Andrew Cooper
2018-03-15 11:08   ` Wei Liu
2018-03-15 16:39   ` George Dunlap
2018-03-14 18:20 ` [PATCH v5 09/16] xen/pdx: Introduce helper to convert MFN <-> PDX julien.grall
2018-03-14 18:34   ` Andrew Cooper
2018-03-14 18:20 ` [PATCH v5 10/16] xen/mm: Switch map_pages_to_xen to use MFN typesafe julien.grall
2018-03-14 18:40   ` Andrew Cooper
2018-03-15 11:08   ` Wei Liu
2018-03-15 16:50   ` George Dunlap
2018-03-15 16:53     ` Julien Grall
2018-03-15 18:12       ` George Dunlap
2018-03-14 18:20 ` [PATCH v5 11/16] xen/mm: Switch some of page_alloc.c to typesafe MFN julien.grall
2018-03-15 17:02   ` George Dunlap
2018-03-15 18:07     ` Julien Grall
2018-03-14 18:20 ` [PATCH v5 12/16] xen/mm: Switch common/memory.c to use " julien.grall
2018-03-15  8:06   ` Jan Beulich
2018-03-15 15:03     ` Julien Grall
2018-03-15 15:51       ` Jan Beulich
2018-03-14 18:20 ` [PATCH v5 13/16] xen/grant: Switch {create, replace}_grant_p2m_mapping to " julien.grall
2018-03-14 18:20 ` [PATCH v5 14/16] xen/grant: Switch common/grant_table.c to use " julien.grall
2018-03-15  8:14   ` Jan Beulich
2018-03-20  9:30     ` Julien Grall
2018-03-15 11:09   ` Wei Liu
2018-03-14 18:20 ` julien.grall [this message]
2018-03-15  8:15   ` [PATCH v5 15/16] xen/x86: Switch mfn_to_page in x86_64/mm.c " Jan Beulich
2018-03-14 18:20 ` [PATCH v5 16/16] xen: Convert page_to_mfn and mfn_to_page " julien.grall
2018-03-15  8:18   ` Jan Beulich
2018-03-15 18:09   ` George Dunlap

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=20180314182009.14274-16-julien.grall@arm.com \
    --to=julien.grall@arm.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.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 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.