vmm.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * vmm.c: vmm module interface with kvm module
  3. *
  4. * Copyright (c) 2007, Intel Corporation.
  5. *
  6. * Xiantao Zhang (xiantao.zhang@intel.com)
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms and conditions of the GNU General Public License,
  10. * version 2, as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along with
  18. * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  19. * Place - Suite 330, Boston, MA 02111-1307 USA.
  20. */
  21. #include<linux/kernel.h>
  22. #include<linux/module.h>
  23. #include<asm/fpswa.h>
  24. #include "vcpu.h"
  25. MODULE_AUTHOR("Intel");
  26. MODULE_LICENSE("GPL");
  27. extern char kvm_ia64_ivt;
  28. extern fpswa_interface_t *vmm_fpswa_interface;
  29. struct kvm_vmm_info vmm_info = {
  30. .module = THIS_MODULE,
  31. .vmm_entry = vmm_entry,
  32. .tramp_entry = vmm_trampoline,
  33. .vmm_ivt = (unsigned long)&kvm_ia64_ivt,
  34. };
  35. static int __init kvm_vmm_init(void)
  36. {
  37. vmm_fpswa_interface = fpswa_interface;
  38. /*Register vmm data to kvm side*/
  39. return kvm_init(&vmm_info, 1024, THIS_MODULE);
  40. }
  41. static void __exit kvm_vmm_exit(void)
  42. {
  43. kvm_exit();
  44. return ;
  45. }
  46. void vmm_spin_lock(spinlock_t *lock)
  47. {
  48. _vmm_raw_spin_lock(lock);
  49. }
  50. void vmm_spin_unlock(spinlock_t *lock)
  51. {
  52. _vmm_raw_spin_unlock(lock);
  53. }
  54. static void vcpu_debug_exit(struct kvm_vcpu *vcpu)
  55. {
  56. struct exit_ctl_data *p = &vcpu->arch.exit_data;
  57. long psr;
  58. local_irq_save(psr);
  59. p->exit_reason = EXIT_REASON_DEBUG;
  60. vmm_transition(vcpu);
  61. local_irq_restore(psr);
  62. }
  63. asmlinkage int printk(const char *fmt, ...)
  64. {
  65. struct kvm_vcpu *vcpu = current_vcpu;
  66. va_list args;
  67. int r;
  68. memset(vcpu->arch.log_buf, 0, VMM_LOG_LEN);
  69. va_start(args, fmt);
  70. r = vsnprintf(vcpu->arch.log_buf, VMM_LOG_LEN, fmt, args);
  71. va_end(args);
  72. vcpu_debug_exit(vcpu);
  73. return r;
  74. }
  75. module_init(kvm_vmm_init)
  76. module_exit(kvm_vmm_exit)