2 * Core of Xen paravirt_ops implementation.
4 * This file contains the xen_paravirt_ops structure itself, and the
6 * - privileged instructions
11 * Jeremy Fitzhardinge <jeremy@xensource.com>, XenSource Inc, 2007
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/smp.h>
17 #include <linux/preempt.h>
18 #include <linux/percpu.h>
19 #include <linux/delay.h>
20 #include <linux/start_kernel.h>
21 #include <linux/sched.h>
22 #include <linux/bootmem.h>
23 #include <linux/module.h>
25 #include <linux/page-flags.h>
26 #include <linux/highmem.h>
27 #include <linux/smp.h>
29 #include <xen/interface/xen.h>
30 #include <xen/interface/physdev.h>
31 #include <xen/interface/vcpu.h>
32 #include <xen/features.h>
35 #include <asm/paravirt.h>
37 #include <asm/xen/hypercall.h>
38 #include <asm/xen/hypervisor.h>
39 #include <asm/fixmap.h>
40 #include <asm/processor.h>
41 #include <asm/setup.h>
43 #include <asm/pgtable.h>
44 #include <asm/tlbflush.h>
48 #include "multicalls.h"
50 EXPORT_SYMBOL_GPL(hypercall_page);
52 DEFINE_PER_CPU(enum paravirt_lazy_mode, xen_lazy_mode);
54 DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu);
55 DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info);
56 DEFINE_PER_CPU(unsigned long, xen_cr3);
58 struct start_info *xen_start_info;
59 EXPORT_SYMBOL_GPL(xen_start_info);
61 void xen_vcpu_setup(int cpu)
63 per_cpu(xen_vcpu, cpu) = &HYPERVISOR_shared_info->vcpu_info[cpu];
66 static void __init xen_banner(void)
68 printk(KERN_INFO "Booting paravirtualized kernel on %s\n",
70 printk(KERN_INFO "Hypervisor signature: %s\n", xen_start_info->magic);
73 static void xen_cpuid(unsigned int *eax, unsigned int *ebx,
74 unsigned int *ecx, unsigned int *edx)
76 unsigned maskedx = ~0;
79 * Mask out inconvenient features, to try and disable as many
80 * unsupported kernel subsystems as possible.
83 maskedx = ~((1 << X86_FEATURE_APIC) | /* disable APIC */
84 (1 << X86_FEATURE_ACPI) | /* disable ACPI */
85 (1 << X86_FEATURE_ACC)); /* thermal monitoring */
87 asm(XEN_EMULATE_PREFIX "cpuid"
92 : "0" (*eax), "2" (*ecx));
96 static void xen_set_debugreg(int reg, unsigned long val)
98 HYPERVISOR_set_debugreg(reg, val);
101 static unsigned long xen_get_debugreg(int reg)
103 return HYPERVISOR_get_debugreg(reg);
106 static unsigned long xen_save_fl(void)
108 struct vcpu_info *vcpu;
112 vcpu = x86_read_percpu(xen_vcpu);
113 /* flag has opposite sense of mask */
114 flags = !vcpu->evtchn_upcall_mask;
117 /* convert to IF type flag
121 return (-flags) & X86_EFLAGS_IF;
124 static void xen_restore_fl(unsigned long flags)
126 struct vcpu_info *vcpu;
130 /* convert from IF type flag */
131 flags = !(flags & X86_EFLAGS_IF);
132 vcpu = x86_read_percpu(xen_vcpu);
133 vcpu->evtchn_upcall_mask = flags;
136 /* Unmask then check (avoid races). We're only protecting
137 against updates by this CPU, so there's no need for
138 anything stronger. */
141 if (unlikely(vcpu->evtchn_upcall_pending))
142 force_evtchn_callback();
145 preempt_enable_no_resched();
148 static void xen_irq_disable(void)
150 struct vcpu_info *vcpu;
152 vcpu = x86_read_percpu(xen_vcpu);
153 vcpu->evtchn_upcall_mask = 1;
154 preempt_enable_no_resched();
157 static void xen_irq_enable(void)
159 struct vcpu_info *vcpu;
162 vcpu = x86_read_percpu(xen_vcpu);
163 vcpu->evtchn_upcall_mask = 0;
165 /* Unmask then check (avoid races). We're only protecting
166 against updates by this CPU, so there's no need for
167 anything stronger. */
170 if (unlikely(vcpu->evtchn_upcall_pending))
171 force_evtchn_callback();
175 static void xen_safe_halt(void)
177 /* Blocking includes an implicit local_irq_enable(). */
178 if (HYPERVISOR_sched_op(SCHEDOP_block, 0) != 0)
182 static void xen_halt(void)
185 HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL);
190 static void xen_set_lazy_mode(enum paravirt_lazy_mode mode)
193 case PARAVIRT_LAZY_NONE:
194 BUG_ON(x86_read_percpu(xen_lazy_mode) == PARAVIRT_LAZY_NONE);
197 case PARAVIRT_LAZY_MMU:
198 case PARAVIRT_LAZY_CPU:
199 BUG_ON(x86_read_percpu(xen_lazy_mode) != PARAVIRT_LAZY_NONE);
202 case PARAVIRT_LAZY_FLUSH:
203 /* flush if necessary, but don't change state */
204 if (x86_read_percpu(xen_lazy_mode) != PARAVIRT_LAZY_NONE)
210 x86_write_percpu(xen_lazy_mode, mode);
213 static unsigned long xen_store_tr(void)
218 static void xen_set_ldt(const void *addr, unsigned entries)
220 unsigned long linear_addr = (unsigned long)addr;
221 struct mmuext_op *op;
222 struct multicall_space mcs = xen_mc_entry(sizeof(*op));
225 op->cmd = MMUEXT_SET_LDT;
227 /* ldt my be vmalloced, use arbitrary_virt_to_machine */
229 maddr = arbitrary_virt_to_machine((unsigned long)addr);
230 linear_addr = (unsigned long)maddr.maddr;
232 op->arg1.linear_addr = linear_addr;
233 op->arg2.nr_ents = entries;
235 MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF);
237 xen_mc_issue(PARAVIRT_LAZY_CPU);
240 static void xen_load_gdt(const struct Xgt_desc_struct *dtr)
242 unsigned long *frames;
243 unsigned long va = dtr->address;
244 unsigned int size = dtr->size + 1;
245 unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
247 struct multicall_space mcs;
249 /* A GDT can be up to 64k in size, which corresponds to 8192
250 8-byte entries, or 16 4k pages.. */
252 BUG_ON(size > 65536);
253 BUG_ON(va & ~PAGE_MASK);
255 mcs = xen_mc_entry(sizeof(*frames) * pages);
258 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
259 frames[f] = virt_to_mfn(va);
260 make_lowmem_page_readonly((void *)va);
263 MULTI_set_gdt(mcs.mc, frames, size / sizeof(struct desc_struct));
265 xen_mc_issue(PARAVIRT_LAZY_CPU);
268 static void load_TLS_descriptor(struct thread_struct *t,
269 unsigned int cpu, unsigned int i)
271 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
272 xmaddr_t maddr = virt_to_machine(&gdt[GDT_ENTRY_TLS_MIN+i]);
273 struct multicall_space mc = __xen_mc_entry(0);
275 MULTI_update_descriptor(mc.mc, maddr.maddr, t->tls_array[i]);
278 static void xen_load_tls(struct thread_struct *t, unsigned int cpu)
282 load_TLS_descriptor(t, cpu, 0);
283 load_TLS_descriptor(t, cpu, 1);
284 load_TLS_descriptor(t, cpu, 2);
286 xen_mc_issue(PARAVIRT_LAZY_CPU);
289 static void xen_write_ldt_entry(struct desc_struct *dt, int entrynum,
292 unsigned long lp = (unsigned long)&dt[entrynum];
293 xmaddr_t mach_lp = virt_to_machine(lp);
294 u64 entry = (u64)high << 32 | low;
297 if (HYPERVISOR_update_descriptor(mach_lp.maddr, entry))
301 static int cvt_gate_to_trap(int vector, u32 low, u32 high,
302 struct trap_info *info)
306 type = (high >> 8) & 0x1f;
307 dpl = (high >> 13) & 3;
309 if (type != 0xf && type != 0xe)
312 info->vector = vector;
313 info->address = (high & 0xffff0000) | (low & 0x0000ffff);
314 info->cs = low >> 16;
316 /* interrupt gates clear IF */
323 /* Locations of each CPU's IDT */
324 static DEFINE_PER_CPU(struct Xgt_desc_struct, idt_desc);
326 /* Set an IDT entry. If the entry is part of the current IDT, then
328 static void xen_write_idt_entry(struct desc_struct *dt, int entrynum,
332 int cpu = smp_processor_id();
333 unsigned long p = (unsigned long)&dt[entrynum];
334 unsigned long start = per_cpu(idt_desc, cpu).address;
335 unsigned long end = start + per_cpu(idt_desc, cpu).size + 1;
339 write_dt_entry(dt, entrynum, low, high);
341 if (p >= start && (p + 8) <= end) {
342 struct trap_info info[2];
346 if (cvt_gate_to_trap(entrynum, low, high, &info[0]))
347 if (HYPERVISOR_set_trap_table(info))
352 static void xen_convert_trap_info(const struct Xgt_desc_struct *desc,
353 struct trap_info *traps)
355 unsigned in, out, count;
357 count = (desc->size+1) / 8;
360 for (in = out = 0; in < count; in++) {
361 const u32 *entry = (u32 *)(desc->address + in * 8);
363 if (cvt_gate_to_trap(in, entry[0], entry[1], &traps[out]))
366 traps[out].address = 0;
369 void xen_copy_trap_info(struct trap_info *traps)
371 const struct Xgt_desc_struct *desc = &get_cpu_var(idt_desc);
373 xen_convert_trap_info(desc, traps);
375 put_cpu_var(idt_desc);
378 /* Load a new IDT into Xen. In principle this can be per-CPU, so we
379 hold a spinlock to protect the static traps[] array (static because
380 it avoids allocation, and saves stack space). */
381 static void xen_load_idt(const struct Xgt_desc_struct *desc)
383 static DEFINE_SPINLOCK(lock);
384 static struct trap_info traps[257];
385 int cpu = smp_processor_id();
387 per_cpu(idt_desc, cpu) = *desc;
391 xen_convert_trap_info(desc, traps);
394 if (HYPERVISOR_set_trap_table(traps))
400 /* Write a GDT descriptor entry. Ignore LDT descriptors, since
401 they're handled differently. */
402 static void xen_write_gdt_entry(struct desc_struct *dt, int entry,
405 switch ((high >> 8) & 0xff) {
412 xmaddr_t maddr = virt_to_machine(&dt[entry]);
413 u64 desc = (u64)high << 32 | low;
416 if (HYPERVISOR_update_descriptor(maddr.maddr, desc))
423 static void xen_load_esp0(struct tss_struct *tss,
424 struct thread_struct *thread)
426 struct multicall_space mcs = xen_mc_entry(0);
427 MULTI_stack_switch(mcs.mc, __KERNEL_DS, thread->esp0);
428 xen_mc_issue(PARAVIRT_LAZY_CPU);
431 static void xen_set_iopl_mask(unsigned mask)
433 struct physdev_set_iopl set_iopl;
435 /* Force the change at ring 0. */
436 set_iopl.iopl = (mask == 0) ? 1 : (mask >> 12) & 3;
437 HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
440 static void xen_io_delay(void)
444 #ifdef CONFIG_X86_LOCAL_APIC
445 static unsigned long xen_apic_read(unsigned long reg)
450 static void xen_apic_write(unsigned long reg, unsigned long val)
452 /* Warn to see if there's any stray references */
457 static void xen_flush_tlb(void)
461 op.cmd = MMUEXT_TLB_FLUSH_LOCAL;
462 if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF))
466 static void xen_flush_tlb_single(unsigned long addr)
470 op.cmd = MMUEXT_INVLPG_LOCAL;
471 op.arg1.linear_addr = addr & PAGE_MASK;
472 if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF))
476 static void xen_flush_tlb_others(const cpumask_t *cpus, struct mm_struct *mm,
480 cpumask_t cpumask = *cpus;
483 * A couple of (to be removed) sanity checks:
485 * - current CPU must not be in mask
486 * - mask must exist :)
488 BUG_ON(cpus_empty(cpumask));
489 BUG_ON(cpu_isset(smp_processor_id(), cpumask));
492 /* If a CPU which we ran on has gone down, OK. */
493 cpus_and(cpumask, cpumask, cpu_online_map);
494 if (cpus_empty(cpumask))
497 if (va == TLB_FLUSH_ALL) {
498 op.cmd = MMUEXT_TLB_FLUSH_MULTI;
499 op.arg2.vcpumask = (void *)cpus;
501 op.cmd = MMUEXT_INVLPG_MULTI;
502 op.arg1.linear_addr = va;
503 op.arg2.vcpumask = (void *)cpus;
506 if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF))
510 static unsigned long xen_read_cr2(void)
512 return x86_read_percpu(xen_vcpu)->arch.cr2;
515 static void xen_write_cr4(unsigned long cr4)
517 /* never allow TSC to be disabled */
518 native_write_cr4(cr4 & ~X86_CR4_TSD);
521 static unsigned long xen_read_cr3(void)
523 return x86_read_percpu(xen_cr3);
526 static void xen_write_cr3(unsigned long cr3)
528 if (cr3 == x86_read_percpu(xen_cr3)) {
529 /* just a simple tlb flush */
534 x86_write_percpu(xen_cr3, cr3);
538 struct mmuext_op *op;
539 struct multicall_space mcs = xen_mc_entry(sizeof(*op));
540 unsigned long mfn = pfn_to_mfn(PFN_DOWN(cr3));
543 op->cmd = MMUEXT_NEW_BASEPTR;
546 MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF);
548 xen_mc_issue(PARAVIRT_LAZY_CPU);
552 /* Early in boot, while setting up the initial pagetable, assume
553 everything is pinned. */
554 static __init void xen_alloc_pt_init(struct mm_struct *mm, u32 pfn)
556 BUG_ON(mem_map); /* should only be used early */
557 make_lowmem_page_readonly(__va(PFN_PHYS(pfn)));
560 /* This needs to make sure the new pte page is pinned iff its being
561 attached to a pinned pagetable. */
562 static void xen_alloc_pt(struct mm_struct *mm, u32 pfn)
564 struct page *page = pfn_to_page(pfn);
566 if (PagePinned(virt_to_page(mm->pgd))) {
569 if (!PageHighMem(page))
570 make_lowmem_page_readonly(__va(PFN_PHYS(pfn)));
572 /* make sure there are no stray mappings of
578 /* This should never happen until we're OK to use struct page */
579 static void xen_release_pt(u32 pfn)
581 struct page *page = pfn_to_page(pfn);
583 if (PagePinned(page)) {
584 if (!PageHighMem(page))
585 make_lowmem_page_readwrite(__va(PFN_PHYS(pfn)));
589 #ifdef CONFIG_HIGHPTE
590 static void *xen_kmap_atomic_pte(struct page *page, enum km_type type)
592 pgprot_t prot = PAGE_KERNEL;
594 if (PagePinned(page))
595 prot = PAGE_KERNEL_RO;
597 if (0 && PageHighMem(page))
598 printk("mapping highpte %lx type %d prot %s\n",
599 page_to_pfn(page), type,
600 (unsigned long)pgprot_val(prot) & _PAGE_RW ? "WRITE" : "READ");
602 return kmap_atomic_prot(page, type, prot);
606 static __init pte_t mask_rw_pte(pte_t *ptep, pte_t pte)
608 /* If there's an existing pte, then don't allow _PAGE_RW to be set */
609 if (pte_val_ma(*ptep) & _PAGE_PRESENT)
610 pte = __pte_ma(((pte_val_ma(*ptep) & _PAGE_RW) | ~_PAGE_RW) &
616 /* Init-time set_pte while constructing initial pagetables, which
617 doesn't allow RO pagetable pages to be remapped RW */
618 static __init void xen_set_pte_init(pte_t *ptep, pte_t pte)
620 pte = mask_rw_pte(ptep, pte);
622 xen_set_pte(ptep, pte);
625 static __init void xen_pagetable_setup_start(pgd_t *base)
627 pgd_t *xen_pgd = (pgd_t *)xen_start_info->pt_base;
629 /* special set_pte for pagetable initialization */
630 paravirt_ops.set_pte = xen_set_pte_init;
634 * copy top-level of Xen-supplied pagetable into place. For
635 * !PAE we can use this as-is, but for PAE it is a stand-in
636 * while we copy the pmd pages.
638 memcpy(base, xen_pgd, PTRS_PER_PGD * sizeof(pgd_t));
640 if (PTRS_PER_PMD > 1) {
643 * For PAE, need to allocate new pmds, rather than
644 * share Xen's, since Xen doesn't like pmd's being
645 * shared between address spaces.
647 for (i = 0; i < PTRS_PER_PGD; i++) {
648 if (pgd_val_ma(xen_pgd[i]) & _PAGE_PRESENT) {
649 pmd_t *pmd = (pmd_t *)alloc_bootmem_low_pages(PAGE_SIZE);
651 memcpy(pmd, (void *)pgd_page_vaddr(xen_pgd[i]),
654 make_lowmem_page_readonly(pmd);
656 set_pgd(&base[i], __pgd(1 + __pa(pmd)));
662 /* make sure zero_page is mapped RO so we can use it in pagetables */
663 make_lowmem_page_readonly(empty_zero_page);
664 make_lowmem_page_readonly(base);
666 * Switch to new pagetable. This is done before
667 * pagetable_init has done anything so that the new pages
668 * added to the table can be prepared properly for Xen.
670 xen_write_cr3(__pa(base));
673 static __init void xen_pagetable_setup_done(pgd_t *base)
675 /* This will work as long as patching hasn't happened yet
677 paravirt_ops.alloc_pt = xen_alloc_pt;
678 paravirt_ops.set_pte = xen_set_pte;
680 if (!xen_feature(XENFEAT_auto_translated_physmap)) {
682 * Create a mapping for the shared info page.
683 * Should be set_fixmap(), but shared_info is a machine
684 * address with no corresponding pseudo-phys address.
686 set_pte_mfn(fix_to_virt(FIX_PARAVIRT_BOOTMAP),
687 PFN_DOWN(xen_start_info->shared_info),
690 HYPERVISOR_shared_info =
691 (struct shared_info *)fix_to_virt(FIX_PARAVIRT_BOOTMAP);
694 HYPERVISOR_shared_info =
695 (struct shared_info *)__va(xen_start_info->shared_info);
697 /* Actually pin the pagetable down, but we can't set PG_pinned
698 yet because the page structures don't exist yet. */
701 #ifdef CONFIG_X86_PAE
702 op.cmd = MMUEXT_PIN_L3_TABLE;
704 op.cmd = MMUEXT_PIN_L3_TABLE;
706 op.arg1.mfn = pfn_to_mfn(PFN_DOWN(__pa(base)));
707 if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF))
711 xen_vcpu_setup(smp_processor_id());
714 static const struct paravirt_ops xen_paravirt_ops __initdata = {
715 .paravirt_enabled = 1,
716 .shared_kernel_pmd = 0,
719 .banner = xen_banner,
721 .patch = paravirt_patch_default,
723 .memory_setup = xen_memory_setup,
724 .arch_setup = xen_arch_setup,
725 .init_IRQ = xen_init_IRQ,
726 .post_allocator_init = xen_mark_init_mm_pinned,
728 .time_init = xen_time_init,
729 .set_wallclock = xen_set_wallclock,
730 .get_wallclock = xen_get_wallclock,
731 .get_cpu_khz = xen_cpu_khz,
732 .sched_clock = xen_sched_clock,
736 .set_debugreg = xen_set_debugreg,
737 .get_debugreg = xen_get_debugreg,
741 .read_cr0 = native_read_cr0,
742 .write_cr0 = native_write_cr0,
744 .read_cr2 = xen_read_cr2,
745 .write_cr2 = native_write_cr2,
747 .read_cr3 = xen_read_cr3,
748 .write_cr3 = xen_write_cr3,
750 .read_cr4 = native_read_cr4,
751 .read_cr4_safe = native_read_cr4_safe,
752 .write_cr4 = xen_write_cr4,
754 .save_fl = xen_save_fl,
755 .restore_fl = xen_restore_fl,
756 .irq_disable = xen_irq_disable,
757 .irq_enable = xen_irq_enable,
758 .safe_halt = xen_safe_halt,
760 .wbinvd = native_wbinvd,
762 .read_msr = native_read_msr_safe,
763 .write_msr = native_write_msr_safe,
764 .read_tsc = native_read_tsc,
765 .read_pmc = native_read_pmc,
767 .iret = (void *)&hypercall_page[__HYPERVISOR_iret],
768 .irq_enable_sysexit = NULL, /* never called */
770 .load_tr_desc = paravirt_nop,
771 .set_ldt = xen_set_ldt,
772 .load_gdt = xen_load_gdt,
773 .load_idt = xen_load_idt,
774 .load_tls = xen_load_tls,
776 .store_gdt = native_store_gdt,
777 .store_idt = native_store_idt,
778 .store_tr = xen_store_tr,
780 .write_ldt_entry = xen_write_ldt_entry,
781 .write_gdt_entry = xen_write_gdt_entry,
782 .write_idt_entry = xen_write_idt_entry,
783 .load_esp0 = xen_load_esp0,
785 .set_iopl_mask = xen_set_iopl_mask,
786 .io_delay = xen_io_delay,
788 #ifdef CONFIG_X86_LOCAL_APIC
789 .apic_write = xen_apic_write,
790 .apic_write_atomic = xen_apic_write,
791 .apic_read = xen_apic_read,
792 .setup_boot_clock = paravirt_nop,
793 .setup_secondary_clock = paravirt_nop,
794 .startup_ipi_hook = paravirt_nop,
797 .flush_tlb_user = xen_flush_tlb,
798 .flush_tlb_kernel = xen_flush_tlb,
799 .flush_tlb_single = xen_flush_tlb_single,
800 .flush_tlb_others = xen_flush_tlb_others,
802 .pte_update = paravirt_nop,
803 .pte_update_defer = paravirt_nop,
805 .pagetable_setup_start = xen_pagetable_setup_start,
806 .pagetable_setup_done = xen_pagetable_setup_done,
808 .alloc_pt = xen_alloc_pt_init,
809 .release_pt = xen_release_pt,
810 .alloc_pd = paravirt_nop,
811 .alloc_pd_clone = paravirt_nop,
812 .release_pd = paravirt_nop,
814 #ifdef CONFIG_HIGHPTE
815 .kmap_atomic_pte = xen_kmap_atomic_pte,
818 .set_pte = NULL, /* see xen_pagetable_setup_* */
819 .set_pte_at = xen_set_pte_at,
820 .set_pmd = xen_set_pmd,
822 .pte_val = xen_pte_val,
823 .pgd_val = xen_pgd_val,
825 .make_pte = xen_make_pte,
826 .make_pgd = xen_make_pgd,
828 #ifdef CONFIG_X86_PAE
829 .set_pte_atomic = xen_set_pte_atomic,
830 .set_pte_present = xen_set_pte_at,
831 .set_pud = xen_set_pud,
832 .pte_clear = xen_pte_clear,
833 .pmd_clear = xen_pmd_clear,
835 .make_pmd = xen_make_pmd,
836 .pmd_val = xen_pmd_val,
839 .activate_mm = xen_activate_mm,
840 .dup_mmap = xen_dup_mmap,
841 .exit_mmap = xen_exit_mmap,
843 .set_lazy_mode = xen_set_lazy_mode,
847 static const struct smp_ops xen_smp_ops __initdata = {
848 .smp_prepare_boot_cpu = xen_smp_prepare_boot_cpu,
849 .smp_prepare_cpus = xen_smp_prepare_cpus,
850 .cpu_up = xen_cpu_up,
851 .smp_cpus_done = xen_smp_cpus_done,
853 .smp_send_stop = xen_smp_send_stop,
854 .smp_send_reschedule = xen_smp_send_reschedule,
855 .smp_call_function_mask = xen_smp_call_function_mask,
857 #endif /* CONFIG_SMP */
859 /* First C function to be called on Xen boot */
860 asmlinkage void __init xen_start_kernel(void)
867 BUG_ON(memcmp(xen_start_info->magic, "xen-3.0", 7) != 0);
869 /* Install Xen paravirt ops */
870 paravirt_ops = xen_paravirt_ops;
872 smp_ops = xen_smp_ops;
875 xen_setup_features();
878 if (!xen_feature(XENFEAT_auto_translated_physmap))
879 phys_to_machine_mapping = (unsigned long *)xen_start_info->mfn_list;
881 pgd = (pgd_t *)xen_start_info->pt_base;
883 init_pg_tables_end = __pa(pgd) + xen_start_info->nr_pt_frames*PAGE_SIZE;
885 init_mm.pgd = pgd; /* use the Xen pagetables to start */
887 /* keep using Xen gdt for now; no urgent need to change it */
889 x86_write_percpu(xen_cr3, __pa(pgd));
892 paravirt_ops.kernel_rpl = 1;
893 if (xen_feature(XENFEAT_supervisor_mode_kernel))
894 paravirt_ops.kernel_rpl = 0;
896 /* set the limit of our address space */
897 reserve_top_address(-HYPERVISOR_VIRT_START + 2 * PAGE_SIZE);
899 /* set up basic CPUID stuff */
900 cpu_detect(&new_cpu_data);
901 new_cpu_data.hard_math = 1;
902 new_cpu_data.x86_capability[0] = cpuid_edx(1);
904 /* Poke various useful things into boot_params */
905 LOADER_TYPE = (9 << 4) | 0;
906 INITRD_START = xen_start_info->mod_start ? __pa(xen_start_info->mod_start) : 0;
907 INITRD_SIZE = xen_start_info->mod_len;
909 /* Start the world */