setup.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Machine specific setup for xen
  3. *
  4. * Jeremy Fitzhardinge <jeremy@xensource.com>, XenSource Inc, 2007
  5. */
  6. #include <linux/module.h>
  7. #include <linux/sched.h>
  8. #include <linux/mm.h>
  9. #include <linux/pm.h>
  10. #include <asm/elf.h>
  11. #include <asm/e820.h>
  12. #include <asm/setup.h>
  13. #include <asm/xen/hypervisor.h>
  14. #include <asm/xen/hypercall.h>
  15. #include <xen/interface/physdev.h>
  16. #include <xen/features.h>
  17. #include "xen-ops.h"
  18. #include "vdso.h"
  19. /* These are code, but not functions. Defined in entry.S */
  20. extern const char xen_hypervisor_callback[];
  21. extern const char xen_failsafe_callback[];
  22. unsigned long *phys_to_machine_mapping;
  23. EXPORT_SYMBOL(phys_to_machine_mapping);
  24. /**
  25. * machine_specific_memory_setup - Hook for machine specific memory setup.
  26. **/
  27. char * __init xen_memory_setup(void)
  28. {
  29. unsigned long max_pfn = xen_start_info->nr_pages;
  30. e820.nr_map = 0;
  31. add_memory_region(0, PFN_PHYS(max_pfn), E820_RAM);
  32. return "Xen";
  33. }
  34. static void xen_idle(void)
  35. {
  36. local_irq_disable();
  37. if (need_resched())
  38. local_irq_enable();
  39. else {
  40. current_thread_info()->status &= ~TS_POLLING;
  41. smp_mb__after_clear_bit();
  42. safe_halt();
  43. current_thread_info()->status |= TS_POLLING;
  44. }
  45. }
  46. /*
  47. * Set the bit indicating "nosegneg" library variants should be used.
  48. */
  49. static void fiddle_vdso(void)
  50. {
  51. extern u32 VDSO_NOTE_MASK; /* See ../kernel/vsyscall-note.S. */
  52. extern char vsyscall_int80_start;
  53. u32 *mask = (u32 *) ((unsigned long) &VDSO_NOTE_MASK - VDSO_PRELINK +
  54. &vsyscall_int80_start);
  55. *mask |= 1 << VDSO_NOTE_NONEGSEG_BIT;
  56. }
  57. void __init xen_arch_setup(void)
  58. {
  59. struct physdev_set_iopl set_iopl;
  60. int rc;
  61. HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
  62. HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
  63. if (!xen_feature(XENFEAT_auto_translated_physmap))
  64. HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_pae_extended_cr3);
  65. HYPERVISOR_set_callbacks(__KERNEL_CS, (unsigned long)xen_hypervisor_callback,
  66. __KERNEL_CS, (unsigned long)xen_failsafe_callback);
  67. set_iopl.iopl = 1;
  68. rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
  69. if (rc != 0)
  70. printk(KERN_INFO "physdev_op failed %d\n", rc);
  71. #ifdef CONFIG_ACPI
  72. if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
  73. printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
  74. disable_acpi();
  75. }
  76. #endif
  77. memcpy(boot_command_line, xen_start_info->cmd_line,
  78. MAX_GUEST_CMDLINE > COMMAND_LINE_SIZE ?
  79. COMMAND_LINE_SIZE : MAX_GUEST_CMDLINE);
  80. pm_idle = xen_idle;
  81. #ifdef CONFIG_SMP
  82. /* fill cpus_possible with all available cpus */
  83. xen_fill_possible_map();
  84. #endif
  85. paravirt_disable_iospace();
  86. fiddle_vdso();
  87. }