#ifdef CONFIG_HIGHMEM
 
 #include <uapi/asm/page.h>
-#include <asm/kmap_types.h>
+#include <asm/kmap_size.h>
+
+#define FIXMAP_SIZE            PGDIR_SIZE
+#define PKMAP_SIZE             PGDIR_SIZE
 
 /* start after vmalloc area */
 #define FIXMAP_BASE            (PAGE_OFFSET - FIXMAP_SIZE - PKMAP_SIZE)
-#define FIXMAP_SIZE            PGDIR_SIZE      /* only 1 PGD worth */
-#define KM_TYPE_NR             ((FIXMAP_SIZE >> PAGE_SHIFT)/NR_CPUS)
-#define FIXMAP_ADDR(nr)                (FIXMAP_BASE + ((nr) << PAGE_SHIFT))
+
+#define FIX_KMAP_SLOTS         (KM_MAX_IDX * NR_CPUS)
+#define FIX_KMAP_BEGIN         (0UL)
+#define FIX_KMAP_END           ((FIX_KMAP_BEGIN + FIX_KMAP_SLOTS) - 1)
+
+#define FIXADDR_TOP            (FIXMAP_BASE + (FIX_KMAP_END << PAGE_SHIFT))
+
+/*
+ * This should be converted to the asm-generic version, but of course this
+ * is needlessly different from all other architectures. Sigh - tglx
+ */
+#define __fix_to_virt(x)       (FIXADDR_TOP - ((x) << PAGE_SHIFT))
+#define __virt_to_fix(x)       (((FIXADDR_TOP - ((x) & PAGE_MASK))) >> PAGE_SHIFT)
 
 /* start after fixmap area */
 #define PKMAP_BASE             (FIXMAP_BASE + FIXMAP_SIZE)
-#define PKMAP_SIZE             PGDIR_SIZE
 #define LAST_PKMAP             (PKMAP_SIZE >> PAGE_SHIFT)
 #define LAST_PKMAP_MASK                (LAST_PKMAP - 1)
 #define PKMAP_ADDR(nr)         (PKMAP_BASE + ((nr) << PAGE_SHIFT))
 
 extern void kmap_init(void);
 
+#define arch_kmap_local_post_unmap(vaddr)                      \
+       local_flush_tlb_kernel_range(vaddr, vaddr + PAGE_SIZE)
+
 static inline void flush_cache_kmaps(void)
 {
        flush_cache_all();
 }
-
 #endif
 
 #endif
 
  *   This means each only has 1 PGDIR_SIZE worth of kvaddr mappings, which means
  *   2M of kvaddr space for typical config (8K page and 11:8:13 traversal split)
  *
- * - fixmap anyhow needs a limited number of mappings. So 2M kvaddr == 256 PTE
- *   slots across NR_CPUS would be more than sufficient (generic code defines
- *   KM_TYPE_NR as 20).
+ * - The fixed KMAP slots for kmap_local/atomic() require KM_MAX_IDX slots per
+ *   CPU. So the number of CPUs sharing a single PTE page is limited.
  *
  * - pkmap being preemptible, in theory could do with more than 256 concurrent
  *   mappings. However, generic pkmap code: map_new_virtual(), doesn't traverse
  */
 
 extern pte_t * pkmap_page_table;
-static pte_t * fixmap_page_table;
-
-void *kmap_atomic_high_prot(struct page *page, pgprot_t prot)
-{
-       int idx, cpu_idx;
-       unsigned long vaddr;
-
-       cpu_idx = kmap_atomic_idx_push();
-       idx = cpu_idx + KM_TYPE_NR * smp_processor_id();
-       vaddr = FIXMAP_ADDR(idx);
-
-       set_pte_at(&init_mm, vaddr, fixmap_page_table + idx,
-                  mk_pte(page, prot));
-
-       return (void *)vaddr;
-}
-EXPORT_SYMBOL(kmap_atomic_high_prot);
-
-void kunmap_atomic_high(void *kv)
-{
-       unsigned long kvaddr = (unsigned long)kv;
-
-       if (kvaddr >= FIXMAP_BASE && kvaddr < (FIXMAP_BASE + FIXMAP_SIZE)) {
-
-               /*
-                * Because preemption is disabled, this vaddr can be associated
-                * with the current allocated index.
-                * But in case of multiple live kmap_atomic(), it still relies on
-                * callers to unmap in right order.
-                */
-               int cpu_idx = kmap_atomic_idx();
-               int idx = cpu_idx + KM_TYPE_NR * smp_processor_id();
-
-               WARN_ON(kvaddr != FIXMAP_ADDR(idx));
-
-               pte_clear(&init_mm, kvaddr, fixmap_page_table + idx);
-               local_flush_tlb_kernel_range(kvaddr, kvaddr + PAGE_SIZE);
-
-               kmap_atomic_idx_pop();
-       }
-}
-EXPORT_SYMBOL(kunmap_atomic_high);
 
 static noinline pte_t * __init alloc_kmap_pgtable(unsigned long kvaddr)
 {
 {
        /* Due to recursive include hell, we can't do this in processor.h */
        BUILD_BUG_ON(PAGE_OFFSET < (VMALLOC_END + FIXMAP_SIZE + PKMAP_SIZE));
+       BUILD_BUG_ON(LAST_PKMAP > PTRS_PER_PTE);
+       BUILD_BUG_ON(FIX_KMAP_SLOTS > PTRS_PER_PTE);
 
-       BUILD_BUG_ON(KM_TYPE_NR > PTRS_PER_PTE);
        pkmap_page_table = alloc_kmap_pgtable(PKMAP_BASE);
-
-       BUILD_BUG_ON(LAST_PKMAP > PTRS_PER_PTE);
-       fixmap_page_table = alloc_kmap_pgtable(FIXMAP_BASE);
+       alloc_kmap_pgtable(FIXMAP_BASE);
 }