Xiantao Zhang | bb46fb4 | 2008-04-01 14:49:24 +0800 | [diff] [blame] | 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 | |
| 22 | |
Xiantao Zhang | 5e2be19 | 2008-11-21 10:46:12 +0800 | [diff] [blame^] | 23 | #include<linux/kernel.h> |
Xiantao Zhang | bb46fb4 | 2008-04-01 14:49:24 +0800 | [diff] [blame] | 24 | #include<linux/module.h> |
| 25 | #include<asm/fpswa.h> |
| 26 | |
| 27 | #include "vcpu.h" |
| 28 | |
| 29 | MODULE_AUTHOR("Intel"); |
| 30 | MODULE_LICENSE("GPL"); |
| 31 | |
| 32 | extern char kvm_ia64_ivt; |
| 33 | extern fpswa_interface_t *vmm_fpswa_interface; |
| 34 | |
| 35 | struct kvm_vmm_info vmm_info = { |
| 36 | .module = THIS_MODULE, |
| 37 | .vmm_entry = vmm_entry, |
| 38 | .tramp_entry = vmm_trampoline, |
| 39 | .vmm_ivt = (unsigned long)&kvm_ia64_ivt, |
| 40 | }; |
| 41 | |
| 42 | static int __init kvm_vmm_init(void) |
| 43 | { |
| 44 | |
| 45 | vmm_fpswa_interface = fpswa_interface; |
| 46 | |
| 47 | /*Register vmm data to kvm side*/ |
| 48 | return kvm_init(&vmm_info, 1024, THIS_MODULE); |
| 49 | } |
| 50 | |
| 51 | static void __exit kvm_vmm_exit(void) |
| 52 | { |
| 53 | kvm_exit(); |
| 54 | return ; |
| 55 | } |
| 56 | |
| 57 | void vmm_spin_lock(spinlock_t *lock) |
| 58 | { |
| 59 | _vmm_raw_spin_lock(lock); |
| 60 | } |
| 61 | |
| 62 | void vmm_spin_unlock(spinlock_t *lock) |
| 63 | { |
| 64 | _vmm_raw_spin_unlock(lock); |
| 65 | } |
Xiantao Zhang | 7d63797 | 2008-11-21 20:58:11 +0800 | [diff] [blame] | 66 | |
| 67 | static void vcpu_debug_exit(struct kvm_vcpu *vcpu) |
| 68 | { |
| 69 | struct exit_ctl_data *p = &vcpu->arch.exit_data; |
| 70 | long psr; |
| 71 | |
| 72 | local_irq_save(psr); |
| 73 | p->exit_reason = EXIT_REASON_DEBUG; |
| 74 | vmm_transition(vcpu); |
| 75 | local_irq_restore(psr); |
| 76 | } |
| 77 | |
| 78 | asmlinkage int printk(const char *fmt, ...) |
| 79 | { |
| 80 | struct kvm_vcpu *vcpu = current_vcpu; |
| 81 | va_list args; |
| 82 | int r; |
| 83 | |
| 84 | memset(vcpu->arch.log_buf, 0, VMM_LOG_LEN); |
| 85 | va_start(args, fmt); |
| 86 | r = vsnprintf(vcpu->arch.log_buf, VMM_LOG_LEN, fmt, args); |
| 87 | va_end(args); |
| 88 | vcpu_debug_exit(vcpu); |
| 89 | return r; |
| 90 | } |
| 91 | |
Xiantao Zhang | bb46fb4 | 2008-04-01 14:49:24 +0800 | [diff] [blame] | 92 | module_init(kvm_vmm_init) |
| 93 | module_exit(kvm_vmm_exit) |