diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-17 14:10:11 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-17 14:10:11 -0400 |
commit | fb9fc395174138983a49f2da982ed14caabbe741 (patch) | |
tree | 5d5d3643ee6853a899205613da272cc343fdc1a4 /arch/x86/xen/enlighten.c | |
parent | 0eafaae84e21ac033815cc9f33c3ae889cd7ccfe (diff) | |
parent | ace2e92e193126711cb3a83a3752b2c5b8396950 (diff) |
Merge branch 'xen-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen
* 'xen-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen:
xfs: eagerly remove vmap mappings to avoid upsetting Xen
xen: add some debug output for failed multicalls
xen: fix incorrect vcpu_register_vcpu_info hypercall argument
xen: ask the hypervisor how much space it needs reserved
xen: lock pte pages while pinning/unpinning
xen: deal with stale cr3 values when unpinning pagetables
xen: add batch completion callbacks
xen: yield to IPI target if necessary
Clean up duplicate includes in arch/i386/xen/
remove dead code in pgtable_cache_init
paravirt: clean up lazy mode handling
paravirt: refactor struct paravirt_ops into smaller pv_*_ops
Diffstat (limited to 'arch/x86/xen/enlighten.c')
-rw-r--r-- | arch/x86/xen/enlighten.c | 233 |
1 files changed, 142 insertions, 91 deletions
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 493a083f6886..94c39aaf695f 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/mm.h> | 25 | #include <linux/mm.h> |
26 | #include <linux/page-flags.h> | 26 | #include <linux/page-flags.h> |
27 | #include <linux/highmem.h> | 27 | #include <linux/highmem.h> |
28 | #include <linux/smp.h> | ||
29 | 28 | ||
30 | #include <xen/interface/xen.h> | 29 | #include <xen/interface/xen.h> |
31 | #include <xen/interface/physdev.h> | 30 | #include <xen/interface/physdev.h> |
@@ -52,11 +51,25 @@ | |||
52 | 51 | ||
53 | EXPORT_SYMBOL_GPL(hypercall_page); | 52 | EXPORT_SYMBOL_GPL(hypercall_page); |
54 | 53 | ||
55 | DEFINE_PER_CPU(enum paravirt_lazy_mode, xen_lazy_mode); | ||
56 | |||
57 | DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu); | 54 | DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu); |
58 | DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info); | 55 | DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info); |
59 | DEFINE_PER_CPU(unsigned long, xen_cr3); | 56 | |
57 | /* | ||
58 | * Note about cr3 (pagetable base) values: | ||
59 | * | ||
60 | * xen_cr3 contains the current logical cr3 value; it contains the | ||
61 | * last set cr3. This may not be the current effective cr3, because | ||
62 | * its update may be being lazily deferred. However, a vcpu looking | ||
63 | * at its own cr3 can use this value knowing that it everything will | ||
64 | * be self-consistent. | ||
65 | * | ||
66 | * xen_current_cr3 contains the actual vcpu cr3; it is set once the | ||
67 | * hypercall to set the vcpu cr3 is complete (so it may be a little | ||
68 | * out of date, but it will never be set early). If one vcpu is | ||
69 | * looking at another vcpu's cr3 value, it should use this variable. | ||
70 | */ | ||
71 | DEFINE_PER_CPU(unsigned long, xen_cr3); /* cr3 stored as physaddr */ | ||
72 | DEFINE_PER_CPU(unsigned long, xen_current_cr3); /* actual vcpu cr3 */ | ||
60 | 73 | ||
61 | struct start_info *xen_start_info; | 74 | struct start_info *xen_start_info; |
62 | EXPORT_SYMBOL_GPL(xen_start_info); | 75 | EXPORT_SYMBOL_GPL(xen_start_info); |
@@ -100,7 +113,7 @@ static void __init xen_vcpu_setup(int cpu) | |||
100 | info.mfn = virt_to_mfn(vcpup); | 113 | info.mfn = virt_to_mfn(vcpup); |
101 | info.offset = offset_in_page(vcpup); | 114 | info.offset = offset_in_page(vcpup); |
102 | 115 | ||
103 | printk(KERN_DEBUG "trying to map vcpu_info %d at %p, mfn %x, offset %d\n", | 116 | printk(KERN_DEBUG "trying to map vcpu_info %d at %p, mfn %llx, offset %d\n", |
104 | cpu, vcpup, info.mfn, info.offset); | 117 | cpu, vcpup, info.mfn, info.offset); |
105 | 118 | ||
106 | /* Check to see if the hypervisor will put the vcpu_info | 119 | /* Check to see if the hypervisor will put the vcpu_info |
@@ -124,7 +137,7 @@ static void __init xen_vcpu_setup(int cpu) | |||
124 | static void __init xen_banner(void) | 137 | static void __init xen_banner(void) |
125 | { | 138 | { |
126 | printk(KERN_INFO "Booting paravirtualized kernel on %s\n", | 139 | printk(KERN_INFO "Booting paravirtualized kernel on %s\n", |
127 | paravirt_ops.name); | 140 | pv_info.name); |
128 | printk(KERN_INFO "Hypervisor signature: %s\n", xen_start_info->magic); | 141 | printk(KERN_INFO "Hypervisor signature: %s\n", xen_start_info->magic); |
129 | } | 142 | } |
130 | 143 | ||
@@ -249,29 +262,10 @@ static void xen_halt(void) | |||
249 | xen_safe_halt(); | 262 | xen_safe_halt(); |
250 | } | 263 | } |
251 | 264 | ||
252 | static void xen_set_lazy_mode(enum paravirt_lazy_mode mode) | 265 | static void xen_leave_lazy(void) |
253 | { | 266 | { |
254 | BUG_ON(preemptible()); | 267 | paravirt_leave_lazy(paravirt_get_lazy_mode()); |
255 | |||
256 | switch (mode) { | ||
257 | case PARAVIRT_LAZY_NONE: | ||
258 | BUG_ON(x86_read_percpu(xen_lazy_mode) == PARAVIRT_LAZY_NONE); | ||
259 | break; | ||
260 | |||
261 | case PARAVIRT_LAZY_MMU: | ||
262 | case PARAVIRT_LAZY_CPU: | ||
263 | BUG_ON(x86_read_percpu(xen_lazy_mode) != PARAVIRT_LAZY_NONE); | ||
264 | break; | ||
265 | |||
266 | case PARAVIRT_LAZY_FLUSH: | ||
267 | /* flush if necessary, but don't change state */ | ||
268 | if (x86_read_percpu(xen_lazy_mode) != PARAVIRT_LAZY_NONE) | ||
269 | xen_mc_flush(); | ||
270 | return; | ||
271 | } | ||
272 | |||
273 | xen_mc_flush(); | 268 | xen_mc_flush(); |
274 | x86_write_percpu(xen_lazy_mode, mode); | ||
275 | } | 269 | } |
276 | 270 | ||
277 | static unsigned long xen_store_tr(void) | 271 | static unsigned long xen_store_tr(void) |
@@ -358,7 +352,7 @@ static void xen_load_tls(struct thread_struct *t, unsigned int cpu) | |||
358 | * loaded properly. This will go away as soon as Xen has been | 352 | * loaded properly. This will go away as soon as Xen has been |
359 | * modified to not save/restore %gs for normal hypercalls. | 353 | * modified to not save/restore %gs for normal hypercalls. |
360 | */ | 354 | */ |
361 | if (xen_get_lazy_mode() == PARAVIRT_LAZY_CPU) | 355 | if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_CPU) |
362 | loadsegment(gs, 0); | 356 | loadsegment(gs, 0); |
363 | } | 357 | } |
364 | 358 | ||
@@ -632,32 +626,36 @@ static unsigned long xen_read_cr3(void) | |||
632 | return x86_read_percpu(xen_cr3); | 626 | return x86_read_percpu(xen_cr3); |
633 | } | 627 | } |
634 | 628 | ||
629 | static void set_current_cr3(void *v) | ||
630 | { | ||
631 | x86_write_percpu(xen_current_cr3, (unsigned long)v); | ||
632 | } | ||
633 | |||
635 | static void xen_write_cr3(unsigned long cr3) | 634 | static void xen_write_cr3(unsigned long cr3) |
636 | { | 635 | { |
636 | struct mmuext_op *op; | ||
637 | struct multicall_space mcs; | ||
638 | unsigned long mfn = pfn_to_mfn(PFN_DOWN(cr3)); | ||
639 | |||
637 | BUG_ON(preemptible()); | 640 | BUG_ON(preemptible()); |
638 | 641 | ||
639 | if (cr3 == x86_read_percpu(xen_cr3)) { | 642 | mcs = xen_mc_entry(sizeof(*op)); /* disables interrupts */ |
640 | /* just a simple tlb flush */ | ||
641 | xen_flush_tlb(); | ||
642 | return; | ||
643 | } | ||
644 | 643 | ||
644 | /* Update while interrupts are disabled, so its atomic with | ||
645 | respect to ipis */ | ||
645 | x86_write_percpu(xen_cr3, cr3); | 646 | x86_write_percpu(xen_cr3, cr3); |
646 | 647 | ||
648 | op = mcs.args; | ||
649 | op->cmd = MMUEXT_NEW_BASEPTR; | ||
650 | op->arg1.mfn = mfn; | ||
647 | 651 | ||
648 | { | 652 | MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); |
649 | struct mmuext_op *op; | ||
650 | struct multicall_space mcs = xen_mc_entry(sizeof(*op)); | ||
651 | unsigned long mfn = pfn_to_mfn(PFN_DOWN(cr3)); | ||
652 | |||
653 | op = mcs.args; | ||
654 | op->cmd = MMUEXT_NEW_BASEPTR; | ||
655 | op->arg1.mfn = mfn; | ||
656 | 653 | ||
657 | MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); | 654 | /* Update xen_update_cr3 once the batch has actually |
655 | been submitted. */ | ||
656 | xen_mc_callback(set_current_cr3, (void *)cr3); | ||
658 | 657 | ||
659 | xen_mc_issue(PARAVIRT_LAZY_CPU); | 658 | xen_mc_issue(PARAVIRT_LAZY_CPU); /* interrupts restored */ |
660 | } | ||
661 | } | 659 | } |
662 | 660 | ||
663 | /* Early in boot, while setting up the initial pagetable, assume | 661 | /* Early in boot, while setting up the initial pagetable, assume |
@@ -668,6 +666,15 @@ static __init void xen_alloc_pt_init(struct mm_struct *mm, u32 pfn) | |||
668 | make_lowmem_page_readonly(__va(PFN_PHYS(pfn))); | 666 | make_lowmem_page_readonly(__va(PFN_PHYS(pfn))); |
669 | } | 667 | } |
670 | 668 | ||
669 | static void pin_pagetable_pfn(unsigned level, unsigned long pfn) | ||
670 | { | ||
671 | struct mmuext_op op; | ||
672 | op.cmd = level; | ||
673 | op.arg1.mfn = pfn_to_mfn(pfn); | ||
674 | if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF)) | ||
675 | BUG(); | ||
676 | } | ||
677 | |||
671 | /* This needs to make sure the new pte page is pinned iff its being | 678 | /* This needs to make sure the new pte page is pinned iff its being |
672 | attached to a pinned pagetable. */ | 679 | attached to a pinned pagetable. */ |
673 | static void xen_alloc_pt(struct mm_struct *mm, u32 pfn) | 680 | static void xen_alloc_pt(struct mm_struct *mm, u32 pfn) |
@@ -677,9 +684,10 @@ static void xen_alloc_pt(struct mm_struct *mm, u32 pfn) | |||
677 | if (PagePinned(virt_to_page(mm->pgd))) { | 684 | if (PagePinned(virt_to_page(mm->pgd))) { |
678 | SetPagePinned(page); | 685 | SetPagePinned(page); |
679 | 686 | ||
680 | if (!PageHighMem(page)) | 687 | if (!PageHighMem(page)) { |
681 | make_lowmem_page_readonly(__va(PFN_PHYS(pfn))); | 688 | make_lowmem_page_readonly(__va(PFN_PHYS(pfn))); |
682 | else | 689 | pin_pagetable_pfn(MMUEXT_PIN_L1_TABLE, pfn); |
690 | } else | ||
683 | /* make sure there are no stray mappings of | 691 | /* make sure there are no stray mappings of |
684 | this page */ | 692 | this page */ |
685 | kmap_flush_unused(); | 693 | kmap_flush_unused(); |
@@ -692,8 +700,10 @@ static void xen_release_pt(u32 pfn) | |||
692 | struct page *page = pfn_to_page(pfn); | 700 | struct page *page = pfn_to_page(pfn); |
693 | 701 | ||
694 | if (PagePinned(page)) { | 702 | if (PagePinned(page)) { |
695 | if (!PageHighMem(page)) | 703 | if (!PageHighMem(page)) { |
704 | pin_pagetable_pfn(MMUEXT_UNPIN_TABLE, pfn); | ||
696 | make_lowmem_page_readwrite(__va(PFN_PHYS(pfn))); | 705 | make_lowmem_page_readwrite(__va(PFN_PHYS(pfn))); |
706 | } | ||
697 | } | 707 | } |
698 | } | 708 | } |
699 | 709 | ||
@@ -738,7 +748,7 @@ static __init void xen_pagetable_setup_start(pgd_t *base) | |||
738 | pgd_t *xen_pgd = (pgd_t *)xen_start_info->pt_base; | 748 | pgd_t *xen_pgd = (pgd_t *)xen_start_info->pt_base; |
739 | 749 | ||
740 | /* special set_pte for pagetable initialization */ | 750 | /* special set_pte for pagetable initialization */ |
741 | paravirt_ops.set_pte = xen_set_pte_init; | 751 | pv_mmu_ops.set_pte = xen_set_pte_init; |
742 | 752 | ||
743 | init_mm.pgd = base; | 753 | init_mm.pgd = base; |
744 | /* | 754 | /* |
@@ -785,8 +795,8 @@ static __init void xen_pagetable_setup_done(pgd_t *base) | |||
785 | { | 795 | { |
786 | /* This will work as long as patching hasn't happened yet | 796 | /* This will work as long as patching hasn't happened yet |
787 | (which it hasn't) */ | 797 | (which it hasn't) */ |
788 | paravirt_ops.alloc_pt = xen_alloc_pt; | 798 | pv_mmu_ops.alloc_pt = xen_alloc_pt; |
789 | paravirt_ops.set_pte = xen_set_pte; | 799 | pv_mmu_ops.set_pte = xen_set_pte; |
790 | 800 | ||
791 | if (!xen_feature(XENFEAT_auto_translated_physmap)) { | 801 | if (!xen_feature(XENFEAT_auto_translated_physmap)) { |
792 | /* | 802 | /* |
@@ -808,15 +818,15 @@ static __init void xen_pagetable_setup_done(pgd_t *base) | |||
808 | /* Actually pin the pagetable down, but we can't set PG_pinned | 818 | /* Actually pin the pagetable down, but we can't set PG_pinned |
809 | yet because the page structures don't exist yet. */ | 819 | yet because the page structures don't exist yet. */ |
810 | { | 820 | { |
811 | struct mmuext_op op; | 821 | unsigned level; |
822 | |||
812 | #ifdef CONFIG_X86_PAE | 823 | #ifdef CONFIG_X86_PAE |
813 | op.cmd = MMUEXT_PIN_L3_TABLE; | 824 | level = MMUEXT_PIN_L3_TABLE; |
814 | #else | 825 | #else |
815 | op.cmd = MMUEXT_PIN_L3_TABLE; | 826 | level = MMUEXT_PIN_L2_TABLE; |
816 | #endif | 827 | #endif |
817 | op.arg1.mfn = pfn_to_mfn(PFN_DOWN(__pa(base))); | 828 | |
818 | if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF)) | 829 | pin_pagetable_pfn(level, PFN_DOWN(__pa(base))); |
819 | BUG(); | ||
820 | } | 830 | } |
821 | } | 831 | } |
822 | 832 | ||
@@ -833,12 +843,12 @@ void __init xen_setup_vcpu_info_placement(void) | |||
833 | if (have_vcpu_info_placement) { | 843 | if (have_vcpu_info_placement) { |
834 | printk(KERN_INFO "Xen: using vcpu_info placement\n"); | 844 | printk(KERN_INFO "Xen: using vcpu_info placement\n"); |
835 | 845 | ||
836 | paravirt_ops.save_fl = xen_save_fl_direct; | 846 | pv_irq_ops.save_fl = xen_save_fl_direct; |
837 | paravirt_ops.restore_fl = xen_restore_fl_direct; | 847 | pv_irq_ops.restore_fl = xen_restore_fl_direct; |
838 | paravirt_ops.irq_disable = xen_irq_disable_direct; | 848 | pv_irq_ops.irq_disable = xen_irq_disable_direct; |
839 | paravirt_ops.irq_enable = xen_irq_enable_direct; | 849 | pv_irq_ops.irq_enable = xen_irq_enable_direct; |
840 | paravirt_ops.read_cr2 = xen_read_cr2_direct; | 850 | pv_mmu_ops.read_cr2 = xen_read_cr2_direct; |
841 | paravirt_ops.iret = xen_iret_direct; | 851 | pv_cpu_ops.iret = xen_iret_direct; |
842 | } | 852 | } |
843 | } | 853 | } |
844 | 854 | ||
@@ -850,8 +860,8 @@ static unsigned xen_patch(u8 type, u16 clobbers, void *insnbuf, | |||
850 | 860 | ||
851 | start = end = reloc = NULL; | 861 | start = end = reloc = NULL; |
852 | 862 | ||
853 | #define SITE(x) \ | 863 | #define SITE(op, x) \ |
854 | case PARAVIRT_PATCH(x): \ | 864 | case PARAVIRT_PATCH(op.x): \ |
855 | if (have_vcpu_info_placement) { \ | 865 | if (have_vcpu_info_placement) { \ |
856 | start = (char *)xen_##x##_direct; \ | 866 | start = (char *)xen_##x##_direct; \ |
857 | end = xen_##x##_direct_end; \ | 867 | end = xen_##x##_direct_end; \ |
@@ -860,10 +870,10 @@ static unsigned xen_patch(u8 type, u16 clobbers, void *insnbuf, | |||
860 | goto patch_site | 870 | goto patch_site |
861 | 871 | ||
862 | switch (type) { | 872 | switch (type) { |
863 | SITE(irq_enable); | 873 | SITE(pv_irq_ops, irq_enable); |
864 | SITE(irq_disable); | 874 | SITE(pv_irq_ops, irq_disable); |
865 | SITE(save_fl); | 875 | SITE(pv_irq_ops, save_fl); |
866 | SITE(restore_fl); | 876 | SITE(pv_irq_ops, restore_fl); |
867 | #undef SITE | 877 | #undef SITE |
868 | 878 | ||
869 | patch_site: | 879 | patch_site: |
@@ -895,26 +905,32 @@ static unsigned xen_patch(u8 type, u16 clobbers, void *insnbuf, | |||
895 | return ret; | 905 | return ret; |
896 | } | 906 | } |
897 | 907 | ||
898 | static const struct paravirt_ops xen_paravirt_ops __initdata = { | 908 | static const struct pv_info xen_info __initdata = { |
899 | .paravirt_enabled = 1, | 909 | .paravirt_enabled = 1, |
900 | .shared_kernel_pmd = 0, | 910 | .shared_kernel_pmd = 0, |
901 | 911 | ||
902 | .name = "Xen", | 912 | .name = "Xen", |
903 | .banner = xen_banner, | 913 | }; |
904 | 914 | ||
915 | static const struct pv_init_ops xen_init_ops __initdata = { | ||
905 | .patch = xen_patch, | 916 | .patch = xen_patch, |
906 | 917 | ||
918 | .banner = xen_banner, | ||
907 | .memory_setup = xen_memory_setup, | 919 | .memory_setup = xen_memory_setup, |
908 | .arch_setup = xen_arch_setup, | 920 | .arch_setup = xen_arch_setup, |
909 | .init_IRQ = xen_init_IRQ, | ||
910 | .post_allocator_init = xen_mark_init_mm_pinned, | 921 | .post_allocator_init = xen_mark_init_mm_pinned, |
922 | }; | ||
911 | 923 | ||
924 | static const struct pv_time_ops xen_time_ops __initdata = { | ||
912 | .time_init = xen_time_init, | 925 | .time_init = xen_time_init, |
926 | |||
913 | .set_wallclock = xen_set_wallclock, | 927 | .set_wallclock = xen_set_wallclock, |
914 | .get_wallclock = xen_get_wallclock, | 928 | .get_wallclock = xen_get_wallclock, |
915 | .get_cpu_khz = xen_cpu_khz, | 929 | .get_cpu_khz = xen_cpu_khz, |
916 | .sched_clock = xen_sched_clock, | 930 | .sched_clock = xen_sched_clock, |
931 | }; | ||
917 | 932 | ||
933 | static const struct pv_cpu_ops xen_cpu_ops __initdata = { | ||
918 | .cpuid = xen_cpuid, | 934 | .cpuid = xen_cpuid, |
919 | 935 | ||
920 | .set_debugreg = xen_set_debugreg, | 936 | .set_debugreg = xen_set_debugreg, |
@@ -925,22 +941,10 @@ static const struct paravirt_ops xen_paravirt_ops __initdata = { | |||
925 | .read_cr0 = native_read_cr0, | 941 | .read_cr0 = native_read_cr0, |
926 | .write_cr0 = native_write_cr0, | 942 | .write_cr0 = native_write_cr0, |
927 | 943 | ||
928 | .read_cr2 = xen_read_cr2, | ||
929 | .write_cr2 = xen_write_cr2, | ||
930 | |||
931 | .read_cr3 = xen_read_cr3, | ||
932 | .write_cr3 = xen_write_cr3, | ||
933 | |||
934 | .read_cr4 = native_read_cr4, | 944 | .read_cr4 = native_read_cr4, |
935 | .read_cr4_safe = native_read_cr4_safe, | 945 | .read_cr4_safe = native_read_cr4_safe, |
936 | .write_cr4 = xen_write_cr4, | 946 | .write_cr4 = xen_write_cr4, |
937 | 947 | ||
938 | .save_fl = xen_save_fl, | ||
939 | .restore_fl = xen_restore_fl, | ||
940 | .irq_disable = xen_irq_disable, | ||
941 | .irq_enable = xen_irq_enable, | ||
942 | .safe_halt = xen_safe_halt, | ||
943 | .halt = xen_halt, | ||
944 | .wbinvd = native_wbinvd, | 948 | .wbinvd = native_wbinvd, |
945 | 949 | ||
946 | .read_msr = native_read_msr_safe, | 950 | .read_msr = native_read_msr_safe, |
@@ -969,6 +973,23 @@ static const struct paravirt_ops xen_paravirt_ops __initdata = { | |||
969 | .set_iopl_mask = xen_set_iopl_mask, | 973 | .set_iopl_mask = xen_set_iopl_mask, |
970 | .io_delay = xen_io_delay, | 974 | .io_delay = xen_io_delay, |
971 | 975 | ||
976 | .lazy_mode = { | ||
977 | .enter = paravirt_enter_lazy_cpu, | ||
978 | .leave = xen_leave_lazy, | ||
979 | }, | ||
980 | }; | ||
981 | |||
982 | static const struct pv_irq_ops xen_irq_ops __initdata = { | ||
983 | .init_IRQ = xen_init_IRQ, | ||
984 | .save_fl = xen_save_fl, | ||
985 | .restore_fl = xen_restore_fl, | ||
986 | .irq_disable = xen_irq_disable, | ||
987 | .irq_enable = xen_irq_enable, | ||
988 | .safe_halt = xen_safe_halt, | ||
989 | .halt = xen_halt, | ||
990 | }; | ||
991 | |||
992 | static const struct pv_apic_ops xen_apic_ops __initdata = { | ||
972 | #ifdef CONFIG_X86_LOCAL_APIC | 993 | #ifdef CONFIG_X86_LOCAL_APIC |
973 | .apic_write = xen_apic_write, | 994 | .apic_write = xen_apic_write, |
974 | .apic_write_atomic = xen_apic_write, | 995 | .apic_write_atomic = xen_apic_write, |
@@ -977,6 +998,17 @@ static const struct paravirt_ops xen_paravirt_ops __initdata = { | |||
977 | .setup_secondary_clock = paravirt_nop, | 998 | .setup_secondary_clock = paravirt_nop, |
978 | .startup_ipi_hook = paravirt_nop, | 999 | .startup_ipi_hook = paravirt_nop, |
979 | #endif | 1000 | #endif |
1001 | }; | ||
1002 | |||
1003 | static const struct pv_mmu_ops xen_mmu_ops __initdata = { | ||
1004 | .pagetable_setup_start = xen_pagetable_setup_start, | ||
1005 | .pagetable_setup_done = xen_pagetable_setup_done, | ||
1006 | |||
1007 | .read_cr2 = xen_read_cr2, | ||
1008 | .write_cr2 = xen_write_cr2, | ||
1009 | |||
1010 | .read_cr3 = xen_read_cr3, | ||
1011 | .write_cr3 = xen_write_cr3, | ||
980 | 1012 | ||
981 | .flush_tlb_user = xen_flush_tlb, | 1013 | .flush_tlb_user = xen_flush_tlb, |
982 | .flush_tlb_kernel = xen_flush_tlb, | 1014 | .flush_tlb_kernel = xen_flush_tlb, |
@@ -986,9 +1018,6 @@ static const struct paravirt_ops xen_paravirt_ops __initdata = { | |||
986 | .pte_update = paravirt_nop, | 1018 | .pte_update = paravirt_nop, |
987 | .pte_update_defer = paravirt_nop, | 1019 | .pte_update_defer = paravirt_nop, |
988 | 1020 | ||
989 | .pagetable_setup_start = xen_pagetable_setup_start, | ||
990 | .pagetable_setup_done = xen_pagetable_setup_done, | ||
991 | |||
992 | .alloc_pt = xen_alloc_pt_init, | 1021 | .alloc_pt = xen_alloc_pt_init, |
993 | .release_pt = xen_release_pt, | 1022 | .release_pt = xen_release_pt, |
994 | .alloc_pd = paravirt_nop, | 1023 | .alloc_pd = paravirt_nop, |
@@ -1024,7 +1053,10 @@ static const struct paravirt_ops xen_paravirt_ops __initdata = { | |||
1024 | .dup_mmap = xen_dup_mmap, | 1053 | .dup_mmap = xen_dup_mmap, |
1025 | .exit_mmap = xen_exit_mmap, | 1054 | .exit_mmap = xen_exit_mmap, |
1026 | 1055 | ||
1027 | .set_lazy_mode = xen_set_lazy_mode, | 1056 | .lazy_mode = { |
1057 | .enter = paravirt_enter_lazy_mmu, | ||
1058 | .leave = xen_leave_lazy, | ||
1059 | }, | ||
1028 | }; | 1060 | }; |
1029 | 1061 | ||
1030 | #ifdef CONFIG_SMP | 1062 | #ifdef CONFIG_SMP |
@@ -1080,6 +1112,17 @@ static const struct machine_ops __initdata xen_machine_ops = { | |||
1080 | }; | 1112 | }; |
1081 | 1113 | ||
1082 | 1114 | ||
1115 | static void __init xen_reserve_top(void) | ||
1116 | { | ||
1117 | unsigned long top = HYPERVISOR_VIRT_START; | ||
1118 | struct xen_platform_parameters pp; | ||
1119 | |||
1120 | if (HYPERVISOR_xen_version(XENVER_platform_parameters, &pp) == 0) | ||
1121 | top = pp.virt_start; | ||
1122 | |||
1123 | reserve_top_address(-top + 2 * PAGE_SIZE); | ||
1124 | } | ||
1125 | |||
1083 | /* First C function to be called on Xen boot */ | 1126 | /* First C function to be called on Xen boot */ |
1084 | asmlinkage void __init xen_start_kernel(void) | 1127 | asmlinkage void __init xen_start_kernel(void) |
1085 | { | 1128 | { |
@@ -1091,7 +1134,14 @@ asmlinkage void __init xen_start_kernel(void) | |||
1091 | BUG_ON(memcmp(xen_start_info->magic, "xen-3.0", 7) != 0); | 1134 | BUG_ON(memcmp(xen_start_info->magic, "xen-3.0", 7) != 0); |
1092 | 1135 | ||
1093 | /* Install Xen paravirt ops */ | 1136 | /* Install Xen paravirt ops */ |
1094 | paravirt_ops = xen_paravirt_ops; | 1137 | pv_info = xen_info; |
1138 | pv_init_ops = xen_init_ops; | ||
1139 | pv_time_ops = xen_time_ops; | ||
1140 | pv_cpu_ops = xen_cpu_ops; | ||
1141 | pv_irq_ops = xen_irq_ops; | ||
1142 | pv_apic_ops = xen_apic_ops; | ||
1143 | pv_mmu_ops = xen_mmu_ops; | ||
1144 | |||
1095 | machine_ops = xen_machine_ops; | 1145 | machine_ops = xen_machine_ops; |
1096 | 1146 | ||
1097 | #ifdef CONFIG_SMP | 1147 | #ifdef CONFIG_SMP |
@@ -1113,6 +1163,7 @@ asmlinkage void __init xen_start_kernel(void) | |||
1113 | /* keep using Xen gdt for now; no urgent need to change it */ | 1163 | /* keep using Xen gdt for now; no urgent need to change it */ |
1114 | 1164 | ||
1115 | x86_write_percpu(xen_cr3, __pa(pgd)); | 1165 | x86_write_percpu(xen_cr3, __pa(pgd)); |
1166 | x86_write_percpu(xen_current_cr3, __pa(pgd)); | ||
1116 | 1167 | ||
1117 | #ifdef CONFIG_SMP | 1168 | #ifdef CONFIG_SMP |
1118 | /* Don't do the full vcpu_info placement stuff until we have a | 1169 | /* Don't do the full vcpu_info placement stuff until we have a |
@@ -1124,12 +1175,12 @@ asmlinkage void __init xen_start_kernel(void) | |||
1124 | xen_setup_vcpu_info_placement(); | 1175 | xen_setup_vcpu_info_placement(); |
1125 | #endif | 1176 | #endif |
1126 | 1177 | ||
1127 | paravirt_ops.kernel_rpl = 1; | 1178 | pv_info.kernel_rpl = 1; |
1128 | if (xen_feature(XENFEAT_supervisor_mode_kernel)) | 1179 | if (xen_feature(XENFEAT_supervisor_mode_kernel)) |
1129 | paravirt_ops.kernel_rpl = 0; | 1180 | pv_info.kernel_rpl = 0; |
1130 | 1181 | ||
1131 | /* set the limit of our address space */ | 1182 | /* set the limit of our address space */ |
1132 | reserve_top_address(-HYPERVISOR_VIRT_START + 2 * PAGE_SIZE); | 1183 | xen_reserve_top(); |
1133 | 1184 | ||
1134 | /* set up basic CPUID stuff */ | 1185 | /* set up basic CPUID stuff */ |
1135 | cpu_detect(&new_cpu_data); | 1186 | cpu_detect(&new_cpu_data); |