diff mbox series

[RFC,82/84] x86: deduplicate code a bit and fix an unmapping bug.

Message ID f4c05d048bbad24972874e978f4266abb32cdc3c.1569489002.git.hongyax@amazon.com (mailing list archive)
State New, archived
Headers show
Series Remove direct map from Xen | expand

Commit Message

Xia, Hongyan Sept. 26, 2019, 9:46 a.m. UTC
From: Hongyan Xia <hongyax@amazon.com>

Signed-off-by: Hongyan Xia <hongyax@amazon.com>
---
 xen/arch/x86/domain_page.c   | 28 +++++++++++-----------------
 xen/arch/x86/pv/dom0_build.c |  2 +-
 2 files changed, 12 insertions(+), 18 deletions(-)

Comments

Wei Liu Sept. 26, 2019, 3:48 p.m. UTC | #1
On Thu, Sep 26, 2019 at 10:46:45AM +0100, hongyax@amazon.com wrote:
> From: Hongyan Xia <hongyax@amazon.com>
>  void unmap_domain_page(const void *ptr)
> diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c
> index 1555a61b84..202edcaa17 100644
> --- a/xen/arch/x86/pv/dom0_build.c
> +++ b/xen/arch/x86/pv/dom0_build.c
> @@ -236,7 +236,7 @@ static __init void setup_pv_physmap(struct domain *d, unsigned long pgtbl_pfn,
>      if ( pl3e )
>          unmap_domain_page(pl3e);
>  
> -    //unmap_domain_page(l4start);
> +    unmap_domain_page(l4start);

Please fix the bug where it was introduced.

Wei.

>  }
>  
>  static struct page_info * __init alloc_chunk(struct domain *d,
> -- 
> 2.17.1
>
diff mbox series

Patch

diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c
index f606677ae6..782dd0650c 100644
--- a/xen/arch/x86/domain_page.c
+++ b/xen/arch/x86/domain_page.c
@@ -77,29 +77,16 @@  void *map_domain_page(mfn_t mfn)
     struct mapcache_domain *dcache;
     struct mapcache_vcpu *vcache;
     struct vcpu_maphash_entry *hashent;
+    void *ret;
 
     v = mapcache_current_vcpu();
     if ( !v )
-    {
-        void *ret;
-        pmap_lock();
-        ret = pmap_map(mfn);
-        pmap_unlock();
-        flush_tlb_one_local(ret);
-        return ret;
-    }
+        goto pmap;
 
     dcache = &v->domain->arch.mapcache;
     vcache = &v->arch.mapcache;
     if ( !dcache->inuse )
-    {
-        void *ret;
-        pmap_lock();
-        ret = pmap_map(mfn);
-        pmap_unlock();
-        flush_tlb_one_local(ret);
-        return ret;
-    }
+        goto pmap;
 
     perfc_incr(map_domain_page_count);
 
@@ -179,9 +166,16 @@  void *map_domain_page(mfn_t mfn)
 
     l1e_write(&MAPCACHE_L1ENT(idx), l1e_from_mfn(mfn, __PAGE_HYPERVISOR_RW));
 
- out:
+out:
     local_irq_restore(flags);
     return (void *)MAPCACHE_VIRT_START + pfn_to_paddr(idx);
+
+pmap:
+    pmap_lock();
+    ret = pmap_map(mfn);
+    pmap_unlock();
+    flush_tlb_one_local(ret);
+    return ret;
 }
 
 void unmap_domain_page(const void *ptr)
diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c
index 1555a61b84..202edcaa17 100644
--- a/xen/arch/x86/pv/dom0_build.c
+++ b/xen/arch/x86/pv/dom0_build.c
@@ -236,7 +236,7 @@  static __init void setup_pv_physmap(struct domain *d, unsigned long pgtbl_pfn,
     if ( pl3e )
         unmap_domain_page(pl3e);
 
-    //unmap_domain_page(l4start);
+    unmap_domain_page(l4start);
 }
 
 static struct page_info * __init alloc_chunk(struct domain *d,