Linux 3.12.28
[linux/fpc-iii.git] / arch / ia64 / kvm / misc.h
blobdd979e00b574a990374a4e715a3ab123586719c4
1 #ifndef __KVM_IA64_MISC_H
2 #define __KVM_IA64_MISC_H
4 #include <linux/kvm_host.h>
5 /*
6 * misc.h
7 * Copyright (C) 2007, Intel Corporation.
8 * Xiantao Zhang (xiantao.zhang@intel.com)
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms and conditions of the GNU General Public License,
12 * version 2, as published by the Free Software Foundation.
14 * This program is distributed in the hope it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
19 * You should have received a copy of the GNU General Public License along with
20 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21 * Place - Suite 330, Boston, MA 02111-1307 USA.
26 *Return p2m base address at host side!
28 static inline uint64_t *kvm_host_get_pmt(struct kvm *kvm)
30 return (uint64_t *)(kvm->arch.vm_base +
31 offsetof(struct kvm_vm_data, kvm_p2m));
34 static inline void kvm_set_pmt_entry(struct kvm *kvm, gfn_t gfn,
35 u64 paddr, u64 mem_flags)
37 uint64_t *pmt_base = kvm_host_get_pmt(kvm);
38 unsigned long pte;
40 pte = PAGE_ALIGN(paddr) | mem_flags;
41 pmt_base[gfn] = pte;
44 /*Function for translating host address to guest address*/
46 static inline void *to_guest(struct kvm *kvm, void *addr)
48 return (void *)((unsigned long)(addr) - kvm->arch.vm_base +
49 KVM_VM_DATA_BASE);
52 /*Function for translating guest address to host address*/
54 static inline void *to_host(struct kvm *kvm, void *addr)
56 return (void *)((unsigned long)addr - KVM_VM_DATA_BASE
57 + kvm->arch.vm_base);
60 /* Get host context of the vcpu */
61 static inline union context *kvm_get_host_context(struct kvm_vcpu *vcpu)
63 union context *ctx = &vcpu->arch.host;
64 return to_guest(vcpu->kvm, ctx);
67 /* Get guest context of the vcpu */
68 static inline union context *kvm_get_guest_context(struct kvm_vcpu *vcpu)
70 union context *ctx = &vcpu->arch.guest;
71 return to_guest(vcpu->kvm, ctx);
74 /* kvm get exit data from gvmm! */
75 static inline struct exit_ctl_data *kvm_get_exit_data(struct kvm_vcpu *vcpu)
77 return &vcpu->arch.exit_data;
80 /*kvm get vcpu ioreq for kvm module!*/
81 static inline struct kvm_mmio_req *kvm_get_vcpu_ioreq(struct kvm_vcpu *vcpu)
83 struct exit_ctl_data *p_ctl_data;
85 if (vcpu) {
86 p_ctl_data = kvm_get_exit_data(vcpu);
87 if (p_ctl_data->exit_reason == EXIT_REASON_MMIO_INSTRUCTION)
88 return &p_ctl_data->u.ioreq;
91 return NULL;
94 #endif