blob: f0b9cac824145709c570a3994b2dceaf089b32e3 [file] [log] [blame]
Xiantao Zhangbb46fb42008-04-01 14:49:24 +08001/*
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 Zhang5e2be192008-11-21 10:46:12 +080023#include<linux/kernel.h>
Xiantao Zhangbb46fb42008-04-01 14:49:24 +080024#include<linux/module.h>
25#include<asm/fpswa.h>
26
27#include "vcpu.h"
28
29MODULE_AUTHOR("Intel");
30MODULE_LICENSE("GPL");
31
32extern char kvm_ia64_ivt;
Jes Sorensen0b5d7a22009-02-25 10:38:55 -060033extern char kvm_asm_mov_from_ar;
34extern char kvm_asm_mov_from_ar_sn2;
Xiantao Zhangbb46fb42008-04-01 14:49:24 +080035extern fpswa_interface_t *vmm_fpswa_interface;
36
Xiantao Zhang9f7d5bb2008-11-21 17:16:07 +080037long vmm_sanity = 1;
38
Xiantao Zhangbb46fb42008-04-01 14:49:24 +080039struct kvm_vmm_info vmm_info = {
Jes Sorensen0b5d7a22009-02-25 10:38:55 -060040 .module = THIS_MODULE,
41 .vmm_entry = vmm_entry,
42 .tramp_entry = vmm_trampoline,
43 .vmm_ivt = (unsigned long)&kvm_ia64_ivt,
44 .patch_mov_ar = (unsigned long)&kvm_asm_mov_from_ar,
45 .patch_mov_ar_sn2 = (unsigned long)&kvm_asm_mov_from_ar_sn2,
Xiantao Zhangbb46fb42008-04-01 14:49:24 +080046};
47
48static int __init kvm_vmm_init(void)
49{
50
51 vmm_fpswa_interface = fpswa_interface;
52
53 /*Register vmm data to kvm side*/
Avi Kivity0ee75be2010-04-28 15:39:01 +030054 return kvm_init(&vmm_info, 1024, 0, THIS_MODULE);
Xiantao Zhangbb46fb42008-04-01 14:49:24 +080055}
56
57static void __exit kvm_vmm_exit(void)
58{
59 kvm_exit();
60 return ;
61}
62
Luck, Tonya662b812009-12-17 17:05:03 -080063void vmm_spin_lock(vmm_spinlock_t *lock)
Xiantao Zhangbb46fb42008-04-01 14:49:24 +080064{
65 _vmm_raw_spin_lock(lock);
66}
67
Luck, Tonya662b812009-12-17 17:05:03 -080068void vmm_spin_unlock(vmm_spinlock_t *lock)
Xiantao Zhangbb46fb42008-04-01 14:49:24 +080069{
70 _vmm_raw_spin_unlock(lock);
71}
Xiantao Zhang7d637972008-11-21 20:58:11 +080072
73static void vcpu_debug_exit(struct kvm_vcpu *vcpu)
74{
75 struct exit_ctl_data *p = &vcpu->arch.exit_data;
76 long psr;
77
78 local_irq_save(psr);
79 p->exit_reason = EXIT_REASON_DEBUG;
80 vmm_transition(vcpu);
81 local_irq_restore(psr);
82}
83
84asmlinkage int printk(const char *fmt, ...)
85{
86 struct kvm_vcpu *vcpu = current_vcpu;
87 va_list args;
88 int r;
89
90 memset(vcpu->arch.log_buf, 0, VMM_LOG_LEN);
91 va_start(args, fmt);
92 r = vsnprintf(vcpu->arch.log_buf, VMM_LOG_LEN, fmt, args);
93 va_end(args);
94 vcpu_debug_exit(vcpu);
95 return r;
96}
97
Xiantao Zhangbb46fb42008-04-01 14:49:24 +080098module_init(kvm_vmm_init)
99module_exit(kvm_vmm_exit)