Skip to contentSkip to conversation

x86/paravirt/xen: Add set_fixmap pv_mmu_ops

PATCH In review Jeremy Fitzhardinge 1 participant 1 message Jun 17, 2008

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 4/4 x86/paravirt/xen: Add set_fixmap pv_mmu_ops

Adds the logic necessary to map by mfn rather than pfn when we set up fixmaps to point to IO space.

---

arch/x86/kernel/paravirt.c |    2 ++
arch/x86/mm/pgtable.c      |    9 +++++++--
arch/x86/xen/enlighten.c   |   29 +++++++++++++++++++++++++++++
include/asm-x86/fixmap.h   |   14 ++++++++++++--
include/asm-x86/paravirt.h |   13 +++++++++++++
5 files changed, 63 insertions(+), 4 deletions(-)

===================================================================

arch/x86/kernel/paravirt.c +0 -0
@@ -429,6 +429,8 @@

.enter = paravirt_nop,
.leave = paravirt_nop,
},
+
+ .set_fixmap = native_set_fixmap,
};

EXPORT_SYMBOL_GPL(pv_time_ops);

arch/x86/mm/pgtable.c +0 -0

===================================================================

arch/x86/mm/pgtable.c +0 -0
@@ -277,7 +277,7 @@
 

int fixmaps_set;

-void __set_fixmap (enum fixed_addresses idx, unsigned long phys, pgprot_t flags) +void __native_set_fixmap(enum fixed_addresses idx, pte_t pte)

{
	unsigned long address = __fix_to_virt(idx);

@@ -285,6 +285,11 @@

		BUG();
		return;
	}
-	set_pte_vaddr(address, pfn_pte(phys >> PAGE_SHIFT, flags));
+	set_pte_vaddr(address, pte);
	fixmaps_set++;
}

+
+void native_set_fixmap(enum fixed_addresses idx, unsigned long phys, pgprot_t flags) +{
+ __native_set_fixmap(idx, pfn_pte(phys >> PAGE_SHIFT, flags));
+}

arch/x86/xen/enlighten.c +0 -0

===================================================================

arch/x86/xen/enlighten.c +0 -0
@@ -1013,6 +1013,33 @@
	return ret;
}

+static void xen_set_fixmap(unsigned idx, unsigned long phys, pgprot_t prot) +{
+ pte_t pte;
+
+ phys >>= PAGE_SHIFT;
+
+ switch (idx) {
+ case FIX_BTMAP_END ... FIX_BTMAP_BEGIN:
+#ifdef CONFIG_X86_F00F_BUG
+ case FIX_F00F_IDT:
+#endif
+ case FIX_WP_TEST:
+ case FIX_VDSO:
+#ifdef CONFIG_X86_LOCAL_APIC
+ case FIX_APIC_BASE: /* maps dummy local APIC */
+#endif
+ pte = pfn_pte(phys, prot);
+ break;
+
+ default:
+ pte = mfn_pte(phys, prot);
+ break;
+ }
+
+ __native_set_fixmap(idx, pte);
+}
+

static const struct pv_info xen_info __initdata = {
	.paravirt_enabled = 1,
	.shared_kernel_pmd = 0,

@@ -1171,6 +1198,8 @@
.enter = paravirt_enter_lazy_mmu,
.leave = xen_leave_lazy,
},
+
+ .set_fixmap = xen_set_fixmap,
};

#ifdef CONFIG_SMP

include/asm-x86/fixmap.h +0 -0

===================================================================

include/asm-x86/fixmap.h +0 -0
@@ -9,8 +9,18 @@
 

extern int fixmaps_set;

-extern void __set_fixmap(enum fixed_addresses idx,
- unsigned long phys, pgprot_t flags);
+void __native_set_fixmap(enum fixed_addresses idx, pte_t pte); +void native_set_fixmap(enum fixed_addresses idx,
+ unsigned long phys, pgprot_t flags);
+
+#ifndef CONFIG_PARAVIRT
+static inline void __set_fixmap(enum fixed_addresses idx,
+ unsigned long phys, pgprot_t flags)
+{
+ native_set_fixmap(idx, phys, flags);
+}
+#endif
+
#define set_fixmap(idx, phys) \
__set_fixmap(idx, phys, PAGE_KERNEL)

include/asm-x86/paravirt.h +0 -0

===================================================================

include/asm-x86/paravirt.h +0 -0
@@ -287,6 +287,13 @@

#endif

	struct pv_lazy_ops lazy_mode;

+
+ /* dom0 ops */
+
+ /* Sometimes the physical address is a pfn, and sometimes its
+ an mfn. We can tell which is which from the index. */
+ void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
+ unsigned long phys, pgprot_t flags);
};

/* This contains all the paravirt structures: we get a convenient @@ -1318,6 +1325,12 @@

	}
}

+static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
+ unsigned long phys, pgprot_t flags)
+{
+ pv_mmu_ops.set_fixmap(idx, phys, flags);
+}
+
void _paravirt_nop(void);
#define paravirt_nop ((void *)_paravirt_nop)