setup.c 2.5 KB

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