diff mbox series

[Xen-devel,v2,3/9] xen/x86: mem_sharing: Use copy_domain_page in __mem_sharing_unshare_page

Message ID 20171005174222.29161-4-julien.grall@linaro.org
State Accepted
Commit e6cccc721c58c5e260331050b68bdbd1b36c226d
Headers show
Series xen: Convert __page_to_mfn and __mfn_to_page to use typesafe MFN | expand

Commit Message

Julien Grall Oct. 5, 2017, 5:42 p.m. UTC
The function __mem_sharing_unshare_page contains an open-code version of
copy_domain_page. Use the function to simplify a bit the code.

At the same time replace _mfn(__page_to_mfn(...)) by page_to_mfn(...)
given that the file given already provides a typesafe version of page_to_mfn.

Signed-off-by: Julien Grall <julien.grall@linaro.org>

---

Cc: Tamas K Lengyel <tamas@tklengyel.com>
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>

    Changes in v2:
        - New patch
---
 xen/arch/x86/mm/mem_sharing.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Andrew Cooper Oct. 5, 2017, 5:49 p.m. UTC | #1
On 05/10/17 18:42, Julien Grall wrote:
> The function __mem_sharing_unshare_page contains an open-code version of
> copy_domain_page. Use the function to simplify a bit the code.
>
> At the same time replace _mfn(__page_to_mfn(...)) by page_to_mfn(...)
> given that the file given already provides a typesafe version of page_to_mfn.
>
> Signed-off-by: Julien Grall <julien.grall@linaro.org>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tamas K Lengyel Oct. 5, 2017, 5:52 p.m. UTC | #2
On Thu, Oct 5, 2017 at 11:42 AM, Julien Grall <julien.grall@linaro.org> wrote:
> The function __mem_sharing_unshare_page contains an open-code version of
> copy_domain_page. Use the function to simplify a bit the code.
>
> At the same time replace _mfn(__page_to_mfn(...)) by page_to_mfn(...)
> given that the file given already provides a typesafe version of page_to_mfn.
>
> Signed-off-by: Julien Grall <julien.grall@linaro.org>

Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
diff mbox series

Patch

diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
index b856028c02..6f4be95515 100644
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -1106,7 +1106,6 @@  int __mem_sharing_unshare_page(struct domain *d,
     p2m_type_t p2mt;
     mfn_t mfn;
     struct page_info *page, *old_page;
-    void *s, *t;
     int last_gfn;
     gfn_info_t *gfn_info = NULL;
    
@@ -1185,11 +1184,7 @@  int __mem_sharing_unshare_page(struct domain *d,
         return -ENOMEM;
     }
 
-    s = map_domain_page(_mfn(__page_to_mfn(old_page)));
-    t = map_domain_page(_mfn(__page_to_mfn(page)));
-    memcpy(t, s, PAGE_SIZE);
-    unmap_domain_page(s);
-    unmap_domain_page(t);
+    copy_domain_page(page_to_mfn(page), page_to_mfn(old_page));
 
     BUG_ON(set_shared_p2m_entry(d, gfn, page_to_mfn(page)));
     mem_sharing_gfn_destroy(old_page, d, gfn_info);