aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/lguest/boot.c
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>2009-04-07 16:34:16 -0400
committerJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>2009-04-07 16:34:16 -0400
commit38f4b8c0da01ae7cd9b93386842ce272d6fde9ab (patch)
tree3c8c52201aac038094bfea7efdd0984a8f62045e /arch/x86/lguest/boot.c
parenta811454027352c762e0d5bba1b1d8f7d26bf96ae (diff)
parent8e2c4f2844c0e8dcdfe312e5f2204854ca8532c6 (diff)
Merge commit 'origin/master' into for-linus/xen/master
* commit 'origin/master': (4825 commits) Fix build errors due to CONFIG_BRANCH_TRACER=y parport: Use the PCI IRQ if offered tty: jsm cleanups Adjust path to gpio headers KGDB_SERIAL_CONSOLE check for module Change KCONFIG name tty: Blackin CTS/RTS Change hardware flow control from poll to interrupt driven Add support for the MAX3100 SPI UART. lanana: assign a device name and numbering for MAX3100 serqt: initial clean up pass for tty side tty: Use the generic RS485 ioctl on CRIS tty: Correct inline types for tty_driver_kref_get() splice: fix deadlock in splicing to file nilfs2: support nanosecond timestamp nilfs2: introduce secondary super block nilfs2: simplify handling of active state of segments nilfs2: mark minor flag for checkpoint created by internal operation nilfs2: clean up sketch file nilfs2: super block operations fix endian bug ... Conflicts: arch/x86/include/asm/thread_info.h arch/x86/lguest/boot.c drivers/xen/manage.c
Diffstat (limited to 'arch/x86/lguest/boot.c')
-rw-r--r--arch/x86/lguest/boot.c94
1 files changed, 57 insertions, 37 deletions
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index 5287081b3567..5ab239711cc2 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -107,7 +107,7 @@ static void async_hcall(unsigned long call, unsigned long arg1,
107 local_irq_save(flags); 107 local_irq_save(flags);
108 if (lguest_data.hcall_status[next_call] != 0xFF) { 108 if (lguest_data.hcall_status[next_call] != 0xFF) {
109 /* Table full, so do normal hcall which will flush table. */ 109 /* Table full, so do normal hcall which will flush table. */
110 hcall(call, arg1, arg2, arg3); 110 kvm_hypercall3(call, arg1, arg2, arg3);
111 } else { 111 } else {
112 lguest_data.hcalls[next_call].arg0 = call; 112 lguest_data.hcalls[next_call].arg0 = call;
113 lguest_data.hcalls[next_call].arg1 = arg1; 113 lguest_data.hcalls[next_call].arg1 = arg1;
@@ -134,13 +134,32 @@ static void async_hcall(unsigned long call, unsigned long arg1,
134 * 134 *
135 * So, when we're in lazy mode, we call async_hcall() to store the call for 135 * So, when we're in lazy mode, we call async_hcall() to store the call for
136 * future processing: */ 136 * future processing: */
137static void lazy_hcall(unsigned long call, 137static void lazy_hcall1(unsigned long call,
138 unsigned long arg1)
139{
140 if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_NONE)
141 kvm_hypercall1(call, arg1);
142 else
143 async_hcall(call, arg1, 0, 0);
144}
145
146static void lazy_hcall2(unsigned long call,
147 unsigned long arg1,
148 unsigned long arg2)
149{
150 if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_NONE)
151 kvm_hypercall2(call, arg1, arg2);
152 else
153 async_hcall(call, arg1, arg2, 0);
154}
155
156static void lazy_hcall3(unsigned long call,
138 unsigned long arg1, 157 unsigned long arg1,
139 unsigned long arg2, 158 unsigned long arg2,
140 unsigned long arg3) 159 unsigned long arg3)
141{ 160{
142 if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_NONE) 161 if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_NONE)
143 hcall(call, arg1, arg2, arg3); 162 kvm_hypercall3(call, arg1, arg2, arg3);
144 else 163 else
145 async_hcall(call, arg1, arg2, arg3); 164 async_hcall(call, arg1, arg2, arg3);
146} 165}
@@ -155,7 +174,7 @@ static void lguest_leave_lazy_mmu_mode(void)
155 174
156static void lguest_end_context_switch(struct task_struct *next) 175static void lguest_end_context_switch(struct task_struct *next)
157{ 176{
158 hcall(LHCALL_FLUSH_ASYNC, 0, 0, 0); 177 kvm_hypercall0(LHCALL_FLUSH_ASYNC);
159 paravirt_end_context_switch(next); 178 paravirt_end_context_switch(next);
160} 179}
161 180
@@ -235,7 +254,7 @@ static void lguest_write_idt_entry(gate_desc *dt,
235 /* Keep the local copy up to date. */ 254 /* Keep the local copy up to date. */
236 native_write_idt_entry(dt, entrynum, g); 255 native_write_idt_entry(dt, entrynum, g);
237 /* Tell Host about this new entry. */ 256 /* Tell Host about this new entry. */
238 hcall(LHCALL_LOAD_IDT_ENTRY, entrynum, desc[0], desc[1]); 257 kvm_hypercall3(LHCALL_LOAD_IDT_ENTRY, entrynum, desc[0], desc[1]);
239} 258}
240 259
241/* Changing to a different IDT is very rare: we keep the IDT up-to-date every 260/* Changing to a different IDT is very rare: we keep the IDT up-to-date every
@@ -247,7 +266,7 @@ static void lguest_load_idt(const struct desc_ptr *desc)
247 struct desc_struct *idt = (void *)desc->address; 266 struct desc_struct *idt = (void *)desc->address;
248 267
249 for (i = 0; i < (desc->size+1)/8; i++) 268 for (i = 0; i < (desc->size+1)/8; i++)
250 hcall(LHCALL_LOAD_IDT_ENTRY, i, idt[i].a, idt[i].b); 269 kvm_hypercall3(LHCALL_LOAD_IDT_ENTRY, i, idt[i].a, idt[i].b);
251} 270}
252 271
253/* 272/*
@@ -267,8 +286,8 @@ static void lguest_load_idt(const struct desc_ptr *desc)
267 */ 286 */
268static void lguest_load_gdt(const struct desc_ptr *desc) 287static void lguest_load_gdt(const struct desc_ptr *desc)
269{ 288{
270 BUG_ON((desc->size+1)/8 != GDT_ENTRIES); 289 BUG_ON((desc->size + 1) / 8 != GDT_ENTRIES);
271 hcall(LHCALL_LOAD_GDT, __pa(desc->address), GDT_ENTRIES, 0); 290 kvm_hypercall2(LHCALL_LOAD_GDT, __pa(desc->address), GDT_ENTRIES);
272} 291}
273 292
274/* For a single GDT entry which changes, we do the lazy thing: alter our GDT, 293/* For a single GDT entry which changes, we do the lazy thing: alter our GDT,
@@ -278,7 +297,7 @@ static void lguest_write_gdt_entry(struct desc_struct *dt, int entrynum,
278 const void *desc, int type) 297 const void *desc, int type)
279{ 298{
280 native_write_gdt_entry(dt, entrynum, desc, type); 299 native_write_gdt_entry(dt, entrynum, desc, type);
281 hcall(LHCALL_LOAD_GDT, __pa(dt), GDT_ENTRIES, 0); 300 kvm_hypercall2(LHCALL_LOAD_GDT, __pa(dt), GDT_ENTRIES);
282} 301}
283 302
284/* OK, I lied. There are three "thread local storage" GDT entries which change 303/* OK, I lied. There are three "thread local storage" GDT entries which change
@@ -290,7 +309,7 @@ static void lguest_load_tls(struct thread_struct *t, unsigned int cpu)
290 * can't handle us removing entries we're currently using. So we clear 309 * can't handle us removing entries we're currently using. So we clear
291 * the GS register here: if it's needed it'll be reloaded anyway. */ 310 * the GS register here: if it's needed it'll be reloaded anyway. */
292 lazy_load_gs(0); 311 lazy_load_gs(0);
293 lazy_hcall(LHCALL_LOAD_TLS, __pa(&t->tls_array), cpu, 0); 312 lazy_hcall2(LHCALL_LOAD_TLS, __pa(&t->tls_array), cpu);
294} 313}
295 314
296/*G:038 That's enough excitement for now, back to ploughing through each of 315/*G:038 That's enough excitement for now, back to ploughing through each of
@@ -388,7 +407,7 @@ static void lguest_cpuid(unsigned int *ax, unsigned int *bx,
388static unsigned long current_cr0; 407static unsigned long current_cr0;
389static void lguest_write_cr0(unsigned long val) 408static void lguest_write_cr0(unsigned long val)
390{ 409{
391 lazy_hcall(LHCALL_TS, val & X86_CR0_TS, 0, 0); 410 lazy_hcall1(LHCALL_TS, val & X86_CR0_TS);
392 current_cr0 = val; 411 current_cr0 = val;
393} 412}
394 413
@@ -402,7 +421,7 @@ static unsigned long lguest_read_cr0(void)
402 * the vowels have been optimized out. */ 421 * the vowels have been optimized out. */
403static void lguest_clts(void) 422static void lguest_clts(void)
404{ 423{
405 lazy_hcall(LHCALL_TS, 0, 0, 0); 424 lazy_hcall1(LHCALL_TS, 0);
406 current_cr0 &= ~X86_CR0_TS; 425 current_cr0 &= ~X86_CR0_TS;
407} 426}
408 427
@@ -424,7 +443,7 @@ static bool cr3_changed = false;
424static void lguest_write_cr3(unsigned long cr3) 443static void lguest_write_cr3(unsigned long cr3)
425{ 444{
426 lguest_data.pgdir = cr3; 445 lguest_data.pgdir = cr3;
427 lazy_hcall(LHCALL_NEW_PGTABLE, cr3, 0, 0); 446 lazy_hcall1(LHCALL_NEW_PGTABLE, cr3);
428 cr3_changed = true; 447 cr3_changed = true;
429} 448}
430 449
@@ -496,11 +515,17 @@ static void lguest_write_cr4(unsigned long val)
496 * into a process' address space. We set the entry then tell the Host the 515 * into a process' address space. We set the entry then tell the Host the
497 * toplevel and address this corresponds to. The Guest uses one pagetable per 516 * toplevel and address this corresponds to. The Guest uses one pagetable per
498 * process, so we need to tell the Host which one we're changing (mm->pgd). */ 517 * process, so we need to tell the Host which one we're changing (mm->pgd). */
518static void lguest_pte_update(struct mm_struct *mm, unsigned long addr,
519 pte_t *ptep)
520{
521 lazy_hcall3(LHCALL_SET_PTE, __pa(mm->pgd), addr, ptep->pte_low);
522}
523
499static void lguest_set_pte_at(struct mm_struct *mm, unsigned long addr, 524static void lguest_set_pte_at(struct mm_struct *mm, unsigned long addr,
500 pte_t *ptep, pte_t pteval) 525 pte_t *ptep, pte_t pteval)
501{ 526{
502 *ptep = pteval; 527 *ptep = pteval;
503 lazy_hcall(LHCALL_SET_PTE, __pa(mm->pgd), addr, pteval.pte_low); 528 lguest_pte_update(mm, addr, ptep);
504} 529}
505 530
506/* The Guest calls this to set a top-level entry. Again, we set the entry then 531/* The Guest calls this to set a top-level entry. Again, we set the entry then
@@ -509,8 +534,8 @@ static void lguest_set_pte_at(struct mm_struct *mm, unsigned long addr,
509static void lguest_set_pmd(pmd_t *pmdp, pmd_t pmdval) 534static void lguest_set_pmd(pmd_t *pmdp, pmd_t pmdval)
510{ 535{
511 *pmdp = pmdval; 536 *pmdp = pmdval;
512 lazy_hcall(LHCALL_SET_PMD, __pa(pmdp)&PAGE_MASK, 537 lazy_hcall2(LHCALL_SET_PMD, __pa(pmdp) & PAGE_MASK,
513 (__pa(pmdp)&(PAGE_SIZE-1))/4, 0); 538 (__pa(pmdp) & (PAGE_SIZE - 1)) / 4);
514} 539}
515 540
516/* There are a couple of legacy places where the kernel sets a PTE, but we 541/* There are a couple of legacy places where the kernel sets a PTE, but we
@@ -526,7 +551,7 @@ static void lguest_set_pte(pte_t *ptep, pte_t pteval)
526{ 551{
527 *ptep = pteval; 552 *ptep = pteval;
528 if (cr3_changed) 553 if (cr3_changed)
529 lazy_hcall(LHCALL_FLUSH_TLB, 1, 0, 0); 554 lazy_hcall1(LHCALL_FLUSH_TLB, 1);
530} 555}
531 556
532/* Unfortunately for Lguest, the pv_mmu_ops for page tables were based on 557/* Unfortunately for Lguest, the pv_mmu_ops for page tables were based on
@@ -542,7 +567,7 @@ static void lguest_set_pte(pte_t *ptep, pte_t pteval)
542static void lguest_flush_tlb_single(unsigned long addr) 567static void lguest_flush_tlb_single(unsigned long addr)
543{ 568{
544 /* Simply set it to zero: if it was not, it will fault back in. */ 569 /* Simply set it to zero: if it was not, it will fault back in. */
545 lazy_hcall(LHCALL_SET_PTE, lguest_data.pgdir, addr, 0); 570 lazy_hcall3(LHCALL_SET_PTE, lguest_data.pgdir, addr, 0);
546} 571}
547 572
548/* This is what happens after the Guest has removed a large number of entries. 573/* This is what happens after the Guest has removed a large number of entries.
@@ -550,7 +575,7 @@ static void lguest_flush_tlb_single(unsigned long addr)
550 * have changed, ie. virtual addresses below PAGE_OFFSET. */ 575 * have changed, ie. virtual addresses below PAGE_OFFSET. */
551static void lguest_flush_tlb_user(void) 576static void lguest_flush_tlb_user(void)
552{ 577{
553 lazy_hcall(LHCALL_FLUSH_TLB, 0, 0, 0); 578 lazy_hcall1(LHCALL_FLUSH_TLB, 0);
554} 579}
555 580
556/* This is called when the kernel page tables have changed. That's not very 581/* This is called when the kernel page tables have changed. That's not very
@@ -558,7 +583,7 @@ static void lguest_flush_tlb_user(void)
558 * slow), so it's worth separating this from the user flushing above. */ 583 * slow), so it's worth separating this from the user flushing above. */
559static void lguest_flush_tlb_kernel(void) 584static void lguest_flush_tlb_kernel(void)
560{ 585{
561 lazy_hcall(LHCALL_FLUSH_TLB, 1, 0, 0); 586 lazy_hcall1(LHCALL_FLUSH_TLB, 1);
562} 587}
563 588
564/* 589/*
@@ -695,7 +720,7 @@ static int lguest_clockevent_set_next_event(unsigned long delta,
695 } 720 }
696 721
697 /* Please wake us this far in the future. */ 722 /* Please wake us this far in the future. */
698 hcall(LHCALL_SET_CLOCKEVENT, delta, 0, 0); 723 kvm_hypercall1(LHCALL_SET_CLOCKEVENT, delta);
699 return 0; 724 return 0;
700} 725}
701 726
@@ -706,7 +731,7 @@ static void lguest_clockevent_set_mode(enum clock_event_mode mode,
706 case CLOCK_EVT_MODE_UNUSED: 731 case CLOCK_EVT_MODE_UNUSED:
707 case CLOCK_EVT_MODE_SHUTDOWN: 732 case CLOCK_EVT_MODE_SHUTDOWN:
708 /* A 0 argument shuts the clock down. */ 733 /* A 0 argument shuts the clock down. */
709 hcall(LHCALL_SET_CLOCKEVENT, 0, 0, 0); 734 kvm_hypercall0(LHCALL_SET_CLOCKEVENT);
710 break; 735 break;
711 case CLOCK_EVT_MODE_ONESHOT: 736 case CLOCK_EVT_MODE_ONESHOT:
712 /* This is what we expect. */ 737 /* This is what we expect. */
@@ -781,8 +806,8 @@ static void lguest_time_init(void)
781static void lguest_load_sp0(struct tss_struct *tss, 806static void lguest_load_sp0(struct tss_struct *tss,
782 struct thread_struct *thread) 807 struct thread_struct *thread)
783{ 808{
784 lazy_hcall(LHCALL_SET_STACK, __KERNEL_DS|0x1, thread->sp0, 809 lazy_hcall3(LHCALL_SET_STACK, __KERNEL_DS | 0x1, thread->sp0,
785 THREAD_SIZE/PAGE_SIZE); 810 THREAD_SIZE / PAGE_SIZE);
786} 811}
787 812
788/* Let's just say, I wouldn't do debugging under a Guest. */ 813/* Let's just say, I wouldn't do debugging under a Guest. */
@@ -855,7 +880,7 @@ static void set_lguest_basic_apic_ops(void)
855/* STOP! Until an interrupt comes in. */ 880/* STOP! Until an interrupt comes in. */
856static void lguest_safe_halt(void) 881static void lguest_safe_halt(void)
857{ 882{
858 hcall(LHCALL_HALT, 0, 0, 0); 883 kvm_hypercall0(LHCALL_HALT);
859} 884}
860 885
861/* The SHUTDOWN hypercall takes a string to describe what's happening, and 886/* The SHUTDOWN hypercall takes a string to describe what's happening, and
@@ -865,7 +890,8 @@ static void lguest_safe_halt(void)
865 * rather than virtual addresses, so we use __pa() here. */ 890 * rather than virtual addresses, so we use __pa() here. */
866static void lguest_power_off(void) 891static void lguest_power_off(void)
867{ 892{
868 hcall(LHCALL_SHUTDOWN, __pa("Power down"), LGUEST_SHUTDOWN_POWEROFF, 0); 893 kvm_hypercall2(LHCALL_SHUTDOWN, __pa("Power down"),
894 LGUEST_SHUTDOWN_POWEROFF);
869} 895}
870 896
871/* 897/*
@@ -875,7 +901,7 @@ static void lguest_power_off(void)
875 */ 901 */
876static int lguest_panic(struct notifier_block *nb, unsigned long l, void *p) 902static int lguest_panic(struct notifier_block *nb, unsigned long l, void *p)
877{ 903{
878 hcall(LHCALL_SHUTDOWN, __pa(p), LGUEST_SHUTDOWN_POWEROFF, 0); 904 kvm_hypercall2(LHCALL_SHUTDOWN, __pa(p), LGUEST_SHUTDOWN_POWEROFF);
879 /* The hcall won't return, but to keep gcc happy, we're "done". */ 905 /* The hcall won't return, but to keep gcc happy, we're "done". */
880 return NOTIFY_DONE; 906 return NOTIFY_DONE;
881} 907}
@@ -916,7 +942,7 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
916 len = sizeof(scratch) - 1; 942 len = sizeof(scratch) - 1;
917 scratch[len] = '\0'; 943 scratch[len] = '\0';
918 memcpy(scratch, buf, len); 944 memcpy(scratch, buf, len);
919 hcall(LHCALL_NOTIFY, __pa(scratch), 0, 0); 945 kvm_hypercall1(LHCALL_NOTIFY, __pa(scratch));
920 946
921 /* This routine returns the number of bytes actually written. */ 947 /* This routine returns the number of bytes actually written. */
922 return len; 948 return len;
@@ -926,7 +952,7 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
926 * Launcher to reboot us. */ 952 * Launcher to reboot us. */
927static void lguest_restart(char *reason) 953static void lguest_restart(char *reason)
928{ 954{
929 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0); 955 kvm_hypercall2(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART);
930} 956}
931 957
932/*G:050 958/*G:050
@@ -1046,6 +1072,8 @@ __init void lguest_init(void)
1046 pv_mmu_ops.read_cr3 = lguest_read_cr3; 1072 pv_mmu_ops.read_cr3 = lguest_read_cr3;
1047 pv_mmu_ops.lazy_mode.enter = paravirt_enter_lazy_mmu; 1073 pv_mmu_ops.lazy_mode.enter = paravirt_enter_lazy_mmu;
1048 pv_mmu_ops.lazy_mode.leave = lguest_leave_lazy_mmu_mode; 1074 pv_mmu_ops.lazy_mode.leave = lguest_leave_lazy_mmu_mode;
1075 pv_mmu_ops.pte_update = lguest_pte_update;
1076 pv_mmu_ops.pte_update_defer = lguest_pte_update;
1049 1077
1050#ifdef CONFIG_X86_LOCAL_APIC 1078#ifdef CONFIG_X86_LOCAL_APIC
1051 /* apic read/write intercepts */ 1079 /* apic read/write intercepts */
@@ -1064,14 +1092,6 @@ __init void lguest_init(void)
1064 * lguest_init() where the rest of the fairly chaotic boot setup 1092 * lguest_init() where the rest of the fairly chaotic boot setup
1065 * occurs. */ 1093 * occurs. */
1066 1094
1067 /* The native boot code sets up initial page tables immediately after
1068 * the kernel itself, and sets init_pg_tables_end so they're not
1069 * clobbered. The Launcher places our initial pagetables somewhere at
1070 * the top of our physical memory, so we don't need extra space: set
1071 * init_pg_tables_end to the end of the kernel. */
1072 init_pg_tables_start = __pa(pg0);
1073 init_pg_tables_end = __pa(pg0);
1074
1075 /* As described in head_32.S, we map the first 128M of memory. */ 1095 /* As described in head_32.S, we map the first 128M of memory. */
1076 max_pfn_mapped = (128*1024*1024) >> PAGE_SHIFT; 1096 max_pfn_mapped = (128*1024*1024) >> PAGE_SHIFT;
1077 1097