Skip to content

Commit

Permalink
x86/paravirt/xen: add set_fixmap pv_mmu_ops
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Jeremy Fitzhardinge authored and Ingo Molnar committed Jun 20, 2008
1 parent d494a96 commit aeaaa59
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 deletions.
2 changes: 2 additions & 0 deletions arch/x86/kernel/paravirt.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ struct pv_mmu_ops pv_mmu_ops = {
.enter = paravirt_nop,
.leave = paravirt_nop,
},

.set_fixmap = native_set_fixmap,
};

EXPORT_SYMBOL_GPL(pv_time_ops);
Expand Down
9 changes: 7 additions & 2 deletions arch/x86/mm/pgtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,19 @@ int ptep_clear_flush_young(struct vm_area_struct *vma,

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);

if (idx >= __end_of_fixed_addresses) {
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));
}
29 changes: 29 additions & 0 deletions arch/x86/xen/enlighten.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,33 @@ static unsigned xen_patch(u8 type, u16 clobbers, void *insnbuf,
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,
Expand Down Expand Up @@ -1112,6 +1139,8 @@ static const struct pv_mmu_ops xen_mmu_ops __initdata = {
.enter = paravirt_enter_lazy_mmu,
.leave = xen_leave_lazy,
},

.set_fixmap = xen_set_fixmap,
};

#ifdef CONFIG_SMP
Expand Down
14 changes: 12 additions & 2 deletions include/asm-x86/fixmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
13 changes: 13 additions & 0 deletions include/asm-x86/paravirt.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ struct pv_mmu_ops {
#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
Expand Down Expand Up @@ -1252,6 +1259,12 @@ static inline void arch_flush_lazy_mmu_mode(void)
}
}

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)

Expand Down

0 comments on commit aeaaa59

Please sign in to comment.