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/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, LOWMEMSIZE(), E820_RAM);
  33. add_memory_region(HIGH_MEMORY, PFN_PHYS(max_pfn)-HIGH_MEMORY, E820_RAM);
  34. return "Xen";
  35. }
  36. static void xen_idle(void)
  37. {
  38. local_irq_disable();
  39. if (need_resched())
  40. local_irq_enable();
  41. else {
  42. current_thread_info()->status &= ~TS_POLLING;
  43. smp_mb__after_clear_bit();
  44. safe_halt();
  45. current_thread_info()->status |= TS_POLLING;
  46. }
  47. }
  48. /*
  49. * Set the bit indicating "nosegneg" library variants should be used.
  50. */
  51. static void __init fiddle_vdso(void)
  52. {
  53. extern const char vdso32_default_start;
  54. u32 *mask = VDSO32_SYMBOL(&vdso32_default_start, NOTE_MASK);
  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. }