hypervisor.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /******************************************************************************
  2. * arch/ia64/xen/hypervisor.c
  3. *
  4. * Copyright (c) 2006 Isaku Yamahata <yamahata at valinux co jp>
  5. * VA Linux Systems Japan K.K.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. */
  22. #include <linux/efi.h>
  23. #include <asm/xen/hypervisor.h>
  24. #include <asm/xen/privop.h>
  25. #include "irq_xen.h"
  26. struct shared_info *HYPERVISOR_shared_info __read_mostly =
  27. (struct shared_info *)XSI_BASE;
  28. EXPORT_SYMBOL(HYPERVISOR_shared_info);
  29. DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu);
  30. struct start_info *xen_start_info;
  31. EXPORT_SYMBOL(xen_start_info);
  32. EXPORT_SYMBOL(xen_domain_type);
  33. EXPORT_SYMBOL(__hypercall);
  34. /* Stolen from arch/x86/xen/enlighten.c */
  35. /*
  36. * Flag to determine whether vcpu info placement is available on all
  37. * VCPUs. We assume it is to start with, and then set it to zero on
  38. * the first failure. This is because it can succeed on some VCPUs
  39. * and not others, since it can involve hypervisor memory allocation,
  40. * or because the guest failed to guarantee all the appropriate
  41. * constraints on all VCPUs (ie buffer can't cross a page boundary).
  42. *
  43. * Note that any particular CPU may be using a placed vcpu structure,
  44. * but we can only optimise if the all are.
  45. *
  46. * 0: not available, 1: available
  47. */
  48. static void __init xen_vcpu_setup(int cpu)
  49. {
  50. /*
  51. * WARNING:
  52. * before changing MAX_VIRT_CPUS,
  53. * check that shared_info fits on a page
  54. */
  55. BUILD_BUG_ON(sizeof(struct shared_info) > PAGE_SIZE);
  56. per_cpu(xen_vcpu, cpu) = &HYPERVISOR_shared_info->vcpu_info[cpu];
  57. }
  58. void __init xen_setup_vcpu_info_placement(void)
  59. {
  60. int cpu;
  61. for_each_possible_cpu(cpu)
  62. xen_vcpu_setup(cpu);
  63. }
  64. void __cpuinit
  65. xen_cpu_init(void)
  66. {
  67. xen_smp_intr_init();
  68. }
  69. /**************************************************************************
  70. * opt feature
  71. */
  72. void
  73. xen_ia64_enable_opt_feature(void)
  74. {
  75. /* Enable region 7 identity map optimizations in Xen */
  76. struct xen_ia64_opt_feature optf;
  77. optf.cmd = XEN_IA64_OPTF_IDENT_MAP_REG7;
  78. optf.on = XEN_IA64_OPTF_ON;
  79. optf.pgprot = pgprot_val(PAGE_KERNEL);
  80. optf.key = 0; /* No key on linux. */
  81. HYPERVISOR_opt_feature(&optf);
  82. }