vmm.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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/module.h>
  22. #include<asm/fpswa.h>
  23. #include "vcpu.h"
  24. MODULE_AUTHOR("Intel");
  25. MODULE_LICENSE("GPL");
  26. extern char kvm_ia64_ivt;
  27. extern fpswa_interface_t *vmm_fpswa_interface;
  28. struct kvm_vmm_info vmm_info = {
  29. .module = THIS_MODULE,
  30. .vmm_entry = vmm_entry,
  31. .tramp_entry = vmm_trampoline,
  32. .vmm_ivt = (unsigned long)&kvm_ia64_ivt,
  33. };
  34. static int __init kvm_vmm_init(void)
  35. {
  36. vmm_fpswa_interface = fpswa_interface;
  37. /*Register vmm data to kvm side*/
  38. return kvm_init(&vmm_info, 1024, THIS_MODULE);
  39. }
  40. static void __exit kvm_vmm_exit(void)
  41. {
  42. kvm_exit();
  43. return ;
  44. }
  45. void vmm_spin_lock(spinlock_t *lock)
  46. {
  47. _vmm_raw_spin_lock(lock);
  48. }
  49. void vmm_spin_unlock(spinlock_t *lock)
  50. {
  51. _vmm_raw_spin_unlock(lock);
  52. }
  53. static void vcpu_debug_exit(struct kvm_vcpu *vcpu)
  54. {
  55. struct exit_ctl_data *p = &vcpu->arch.exit_data;
  56. long psr;
  57. local_irq_save(psr);
  58. p->exit_reason = EXIT_REASON_DEBUG;
  59. vmm_transition(vcpu);
  60. local_irq_restore(psr);
  61. }
  62. asmlinkage int printk(const char *fmt, ...)
  63. {
  64. struct kvm_vcpu *vcpu = current_vcpu;
  65. va_list args;
  66. int r;
  67. memset(vcpu->arch.log_buf, 0, VMM_LOG_LEN);
  68. va_start(args, fmt);
  69. r = vsnprintf(vcpu->arch.log_buf, VMM_LOG_LEN, fmt, args);
  70. va_end(args);
  71. vcpu_debug_exit(vcpu);
  72. return r;
  73. }
  74. module_init(kvm_vmm_init)
  75. module_exit(kvm_vmm_exit)