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

[Xen-devel] [PATCH RFC 12/44] x86/fixmap: Temporarily add a percpu fixmap range



This is required to implement an opencoded version of map_domain_page() during
context switch.  It must fit within l1_fixmap[], which imposes an upper limit
on the NR_CPUS.

The limit is currently 509, but will be lifted after later changes.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/include/asm-x86/fixmap.h | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/xen/include/asm-x86/fixmap.h b/xen/include/asm-x86/fixmap.h
index 89bf6cb..d46939a 100644
--- a/xen/include/asm-x86/fixmap.h
+++ b/xen/include/asm-x86/fixmap.h
@@ -27,6 +27,8 @@
 #include <asm/msi.h>
 #include <acpi/apei.h>
 
+#define NR_PERCPU_SLOTS 1
+
 /*
  * Here we define all the compile-time 'special' virtual
  * addresses. The point is to have a constant address at
@@ -45,6 +47,8 @@ enum fixed_addresses {
     FIX_COM_BEGIN,
     FIX_COM_END,
     FIX_EHCI_DBGP,
+    FIX_PERCPU_BEGIN,
+    FIX_PERCPU_END = FIX_PERCPU_BEGIN + (NR_CPUS - 1) * NR_PERCPU_SLOTS,
     /* Everything else should go further down. */
     FIX_APIC_BASE,
     FIX_IO_APIC_BASE_0,
@@ -87,6 +91,32 @@ static inline unsigned long virt_to_fix(const unsigned long 
vaddr)
     return __virt_to_fix(vaddr);
 }
 
+static inline void *percpu_fix_to_virt(unsigned int cpu, unsigned int slot)
+{
+    return (void *)fix_to_virt(FIX_PERCPU_BEGIN + (slot * NR_CPUS) + cpu);
+}
+
+static inline l1_pgentry_t *percpu_fixmap_l1e(unsigned int cpu, unsigned int 
slot)
+{
+    BUILD_BUG_ON(FIX_PERCPU_END >= L1_PAGETABLE_ENTRIES);
+
+    return &l1_fixmap[l1_table_offset((unsigned long)percpu_fix_to_virt(cpu, 
slot))];
+}
+
+static inline void set_percpu_fixmap(unsigned int cpu, unsigned int slot, 
l1_pgentry_t l1e)
+{
+    l1_pgentry_t *pl1e = percpu_fixmap_l1e(cpu, slot);
+
+    if ( l1e_get_intpte(*pl1e) != l1e_get_intpte(l1e) )
+    {
+        *pl1e = l1e;
+
+        __asm__ __volatile__ ( "invlpg %0"
+                               :: "m" (*(char *)percpu_fix_to_virt(cpu, slot))
+                               : "memory" );
+    }
+}
+
 #endif /* __ASSEMBLY__ */
 
 #endif
-- 
2.1.4


_______________________________________________
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®.