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

[Xen-devel] [PATCH RFC 25/44] x86/fixmap: Drop percpu fixmap range



The percpu fixmap range was introduced to allow opencoding of
map_domain_page() in the middle of a context switch.

The new implementation of map_domain_page() is safe to use in a context
switch, so drop the percpu fixmap infrastructure.

This removes the temporary build-time restriction on NR_CPUS.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/mm.c            |  6 ++----
 xen/arch/x86/pv/pt-shadow.c  | 15 ++++++---------
 xen/include/asm-x86/fixmap.h | 32 --------------------------------
 3 files changed, 8 insertions(+), 45 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 7c08807..d5c69c0 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -526,11 +526,9 @@ void do_write_ptbase(struct vcpu *v, bool tlb_maintenance)
         ASSERT(test_bit(_PGC_inuse_pgtable, &new_pg->count_info));
 
     /* Insert percpu mappings into the new pagetables. */
-    set_percpu_fixmap(cpu, PERCPU_FIXSLOT_LINEAR,
-                      l1e_from_paddr(new_cr3, __PAGE_HYPERVISOR_RW));
-    new_l4t = percpu_fix_to_virt(cpu, PERCPU_FIXSLOT_LINEAR);
+    new_l4t = map_domain_page(maddr_to_mfn(new_cr3));
     new_l4t[l4_table_offset(PERCPU_LINEAR_START)] = percpu_mappings;
-    barrier();
+    unmap_domain_page(new_l4t);
 
     /* If the new cr3 has a short directmap, report so before switching... */
     if ( !new_extd_directmap )
diff --git a/xen/arch/x86/pv/pt-shadow.c b/xen/arch/x86/pv/pt-shadow.c
index 46c7b86..33cb303 100644
--- a/xen/arch/x86/pv/pt-shadow.c
+++ b/xen/arch/x86/pv/pt-shadow.c
@@ -22,7 +22,6 @@
 #include <xen/mm.h>
 #include <xen/numa.h>
 
-#include <asm/fixmap.h>
 #include <asm/pv/pt-shadow.h>
 
 /*
@@ -163,13 +162,11 @@ unsigned long pt_maybe_shadow(struct vcpu *v)
         unsigned int slot = l4_table_offset(PERCPU_LINEAR_START);
         l4_pgentry_t *l4t, *vcpu_l4t;
 
-        set_percpu_fixmap(cpu, PERCPU_FIXSLOT_SHADOW,
-                          l1e_from_paddr(new_cr3, __PAGE_HYPERVISOR_RO));
         ptsh->shadowing = new_cr3;
         local_irq_restore(flags);
 
         l4t = ptsh->shadow_l4_va;
-        vcpu_l4t = percpu_fix_to_virt(cpu, PERCPU_FIXSLOT_SHADOW);
+        vcpu_l4t = map_domain_page(maddr_to_mfn(new_cr3));
 
         /*
          * Careful!  When context switching between two vcpus, both of which
@@ -183,6 +180,8 @@ unsigned long pt_maybe_shadow(struct vcpu *v)
                sizeof(*l4t) * slot);
         memcpy(&l4t[slot + 1], &vcpu_l4t[slot + 1],
                sizeof(*l4t) * (L4_PAGETABLE_ENTRIES - (slot + 1)));
+
+        unmap_domain_page(vcpu_l4t);
     }
 
     return ptsh->shadow_l4;
@@ -219,13 +218,11 @@ static void _pt_shadow_ipi(void *arg)
 
     case PTSH_IPI_WRITE:
         l4t = ptsh->shadow_l4_va;
-
-        /* Reuse the mapping established in pt_maybe_shadow(). */
-        ASSERT(l1e_get_paddr(*percpu_fixmap_l1e(cpu, PERCPU_FIXSLOT_SHADOW)) ==
-               maddr);
-        vcpu_l4t = percpu_fix_to_virt(cpu, PERCPU_FIXSLOT_SHADOW);
+        vcpu_l4t = map_domain_page(maddr_to_mfn(maddr));
 
         l4t[info->slot] = vcpu_l4t[info->slot];
+
+        unmap_domain_page(vcpu_l4t);
         break;
 
     default:
diff --git a/xen/include/asm-x86/fixmap.h b/xen/include/asm-x86/fixmap.h
index c1b3bda..89bf6cb 100644
--- a/xen/include/asm-x86/fixmap.h
+++ b/xen/include/asm-x86/fixmap.h
@@ -27,10 +27,6 @@
 #include <asm/msi.h>
 #include <acpi/apei.h>
 
-#define NR_PERCPU_SLOTS 2
-#define PERCPU_FIXSLOT_SHADOW 0
-#define PERCPU_FIXSLOT_LINEAR 1
-
 /*
  * Here we define all the compile-time 'special' virtual
  * addresses. The point is to have a constant address at
@@ -49,8 +45,6 @@ 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,
@@ -93,32 +87,6 @@ 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®.