1 #ifndef __KVM_IA64_MISC_H
2 #define __KVM_IA64_MISC_H
4 #include <linux/kvm_host.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
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
+ KVM_P2M_OFS
);
33 static inline void kvm_set_pmt_entry(struct kvm
*kvm
, gfn_t gfn
,
34 u64 paddr
, u64 mem_flags
)
36 uint64_t *pmt_base
= kvm_host_get_pmt(kvm
);
39 pte
= PAGE_ALIGN(paddr
) | mem_flags
;
43 /*Function for translating host address to guest address*/
45 static inline void *to_guest(struct kvm
*kvm
, void *addr
)
47 return (void *)((unsigned long)(addr
) - kvm
->arch
.vm_base
+
51 /*Function for translating guest address to host address*/
53 static inline void *to_host(struct kvm
*kvm
, void *addr
)
55 return (void *)((unsigned long)addr
- KVM_VM_DATA_BASE
59 /* Get host context of the vcpu */
60 static inline union context
*kvm_get_host_context(struct kvm_vcpu
*vcpu
)
62 union context
*ctx
= &vcpu
->arch
.host
;
63 return to_guest(vcpu
->kvm
, ctx
);
66 /* Get guest context of the vcpu */
67 static inline union context
*kvm_get_guest_context(struct kvm_vcpu
*vcpu
)
69 union context
*ctx
= &vcpu
->arch
.guest
;
70 return to_guest(vcpu
->kvm
, ctx
);
73 /* kvm get exit data from gvmm! */
74 static inline struct exit_ctl_data
*kvm_get_exit_data(struct kvm_vcpu
*vcpu
)
76 return &vcpu
->arch
.exit_data
;
79 /*kvm get vcpu ioreq for kvm module!*/
80 static inline struct kvm_mmio_req
*kvm_get_vcpu_ioreq(struct kvm_vcpu
*vcpu
)
82 struct exit_ctl_data
*p_ctl_data
;
85 p_ctl_data
= kvm_get_exit_data(vcpu
);
86 if (p_ctl_data
->exit_reason
== EXIT_REASON_MMIO_INSTRUCTION
)
87 return &p_ctl_data
->u
.ioreq
;