setup.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. /* These are code, but not functions. Defined in entry.S */
  19. extern const char xen_hypervisor_callback[];
  20. extern const char xen_failsafe_callback[];
  21. unsigned long *phys_to_machine_mapping;
  22. EXPORT_SYMBOL(phys_to_machine_mapping);
  23. /**
  24. * machine_specific_memory_setup - Hook for machine specific memory setup.
  25. **/
  26. char * __init xen_memory_setup(void)
  27. {
  28. unsigned long max_pfn = xen_start_info->nr_pages;
  29. e820.nr_map = 0;
  30. add_memory_region(0, PFN_PHYS(max_pfn), E820_RAM);
  31. return "Xen";
  32. }
  33. static void xen_idle(void)
  34. {
  35. local_irq_disable();
  36. if (need_resched())
  37. local_irq_enable();
  38. else {
  39. current_thread_info()->status &= ~TS_POLLING;
  40. smp_mb__after_clear_bit();
  41. safe_halt();
  42. current_thread_info()->status |= TS_POLLING;
  43. }
  44. }
  45. void __init xen_arch_setup(void)
  46. {
  47. struct physdev_set_iopl set_iopl;
  48. int rc;
  49. HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
  50. HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
  51. if (!xen_feature(XENFEAT_auto_translated_physmap))
  52. HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_pae_extended_cr3);
  53. HYPERVISOR_set_callbacks(__KERNEL_CS, (unsigned long)xen_hypervisor_callback,
  54. __KERNEL_CS, (unsigned long)xen_failsafe_callback);
  55. set_iopl.iopl = 1;
  56. rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
  57. if (rc != 0)
  58. printk(KERN_INFO "physdev_op failed %d\n", rc);
  59. #ifdef CONFIG_ACPI
  60. if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
  61. printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
  62. disable_acpi();
  63. }
  64. #endif
  65. memcpy(boot_command_line, xen_start_info->cmd_line,
  66. MAX_GUEST_CMDLINE > COMMAND_LINE_SIZE ?
  67. COMMAND_LINE_SIZE : MAX_GUEST_CMDLINE);
  68. pm_idle = xen_idle;
  69. #ifdef CONFIG_SMP
  70. /* fill cpus_possible with all available cpus */
  71. xen_fill_possible_map();
  72. #endif
  73. paravirt_disable_iospace();
  74. }