[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC PATCH 59/84] x86/pmap: break the loop in pmap APIs.



From: Hongyan Xia <hongyax@xxxxxxxxxx>

Modify the pmap PTEs directly. Using set/clear_fixmap() may result in
invocation loops.

Signed-off-by: Hongyan Xia <hongyax@xxxxxxxxxx>
---
 xen/arch/x86/pmap.c        | 11 ++++++++---
 xen/include/asm-x86/pmap.h |  2 +-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/pmap.c b/xen/arch/x86/pmap.c
index 4ae16b0212..93104d0b86 100644
--- a/xen/arch/x86/pmap.c
+++ b/xen/arch/x86/pmap.c
@@ -29,11 +29,12 @@ void pmap_unlock(void)
     spin_unlock(&lock);
 }
 
-void *pmap_map(struct page_info *page)
+void *pmap_map(mfn_t mfn)
 {
     unsigned int idx;
     void *linear = NULL;
     enum fixed_addresses slot;
+    l1_pgentry_t *pl1e;
 
     ASSERT(!in_irq());
     ASSERT(spin_is_locked(&lock));
@@ -47,7 +48,8 @@ void *pmap_map(struct page_info *page)
     slot = idx + FIX_PMAP_BEGIN;
     ASSERT(slot >= FIX_PMAP_BEGIN && slot <= FIX_PMAP_END);
 
-    set_fixmap(slot, mfn_x(page_to_mfn(page)));
+    pl1e = &l1_fixmap[L1_PAGETABLE_ENTRIES - 1 - slot];
+    l1e_write_atomic(pl1e, l1e_from_mfn(mfn, PAGE_HYPERVISOR));
     linear = (void *)__fix_to_virt(slot);
 
     return linear;
@@ -56,6 +58,7 @@ void *pmap_map(struct page_info *page)
 void pmap_unmap(void *p)
 {
     unsigned int idx;
+    l1_pgentry_t *pl1e;
     enum fixed_addresses slot = __virt_to_fix((unsigned long)p);
 
     ASSERT(!in_irq());
@@ -64,7 +67,9 @@ void pmap_unmap(void *p)
 
     idx = slot - FIX_PMAP_BEGIN;
     __clear_bit(idx, &inuse);
-    clear_fixmap(slot);
+
+    pl1e = &l1_fixmap[L1_PAGETABLE_ENTRIES - 1 - slot];
+    l1e_write_atomic(pl1e, l1e_from_mfn(_mfn(0), 0));
 }
 
 static void __maybe_unused build_assertions(void)
diff --git a/xen/include/asm-x86/pmap.h b/xen/include/asm-x86/pmap.h
index 42cd4c7793..feab1e9170 100644
--- a/xen/include/asm-x86/pmap.h
+++ b/xen/include/asm-x86/pmap.h
@@ -6,7 +6,7 @@
 
 void pmap_lock(void);
 void pmap_unlock(void);
-void *pmap_map(struct page_info *page);
+void *pmap_map(mfn_t mfn);
 void pmap_unmap(void *p);
 
 #endif /* __X86_PMAP_H__ */
-- 
2.17.1


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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.