Merge branches 'tracing/kmemtrace2' and 'tracing/ftrace' into tracing/urgent
[deliverable/linux.git] / arch / powerpc / kvm / 44x_tlb.h
CommitLineData
bbf45ba5
HB
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License, version 2, as
4 * published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 *
15 * Copyright IBM Corp. 2007
16 *
17 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
18 */
19
20#ifndef __KVM_POWERPC_TLB_H__
21#define __KVM_POWERPC_TLB_H__
22
23#include <linux/kvm_host.h>
24#include <asm/mmu-44x.h>
25
26extern int kvmppc_44x_tlb_index(struct kvm_vcpu *vcpu, gva_t eaddr,
27 unsigned int pid, unsigned int as);
7924bd41
HB
28extern int kvmppc_44x_dtlb_index(struct kvm_vcpu *vcpu, gva_t eaddr);
29extern int kvmppc_44x_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr);
bbf45ba5 30
75f74f0d
HB
31extern int kvmppc_44x_emul_tlbsx(struct kvm_vcpu *vcpu, u8 rt, u8 ra, u8 rb,
32 u8 rc);
33extern int kvmppc_44x_emul_tlbwe(struct kvm_vcpu *vcpu, u8 ra, u8 rs, u8 ws);
34
bbf45ba5 35/* TLB helper functions */
0f55dc48 36static inline unsigned int get_tlb_size(const struct kvmppc_44x_tlbe *tlbe)
bbf45ba5
HB
37{
38 return (tlbe->word0 >> 4) & 0xf;
39}
40
0f55dc48 41static inline gva_t get_tlb_eaddr(const struct kvmppc_44x_tlbe *tlbe)
bbf45ba5
HB
42{
43 return tlbe->word0 & 0xfffffc00;
44}
45
0f55dc48 46static inline gva_t get_tlb_bytes(const struct kvmppc_44x_tlbe *tlbe)
bbf45ba5
HB
47{
48 unsigned int pgsize = get_tlb_size(tlbe);
49 return 1 << 10 << (pgsize << 1);
50}
51
0f55dc48 52static inline gva_t get_tlb_end(const struct kvmppc_44x_tlbe *tlbe)
bbf45ba5
HB
53{
54 return get_tlb_eaddr(tlbe) + get_tlb_bytes(tlbe) - 1;
55}
56
0f55dc48 57static inline u64 get_tlb_raddr(const struct kvmppc_44x_tlbe *tlbe)
bbf45ba5
HB
58{
59 u64 word1 = tlbe->word1;
60 return ((word1 & 0xf) << 32) | (word1 & 0xfffffc00);
61}
62
0f55dc48 63static inline unsigned int get_tlb_tid(const struct kvmppc_44x_tlbe *tlbe)
bbf45ba5
HB
64{
65 return tlbe->tid & 0xff;
66}
67
0f55dc48 68static inline unsigned int get_tlb_ts(const struct kvmppc_44x_tlbe *tlbe)
bbf45ba5
HB
69{
70 return (tlbe->word0 >> 8) & 0x1;
71}
72
0f55dc48 73static inline unsigned int get_tlb_v(const struct kvmppc_44x_tlbe *tlbe)
bbf45ba5
HB
74{
75 return (tlbe->word0 >> 9) & 0x1;
76}
77
78static inline unsigned int get_mmucr_stid(const struct kvm_vcpu *vcpu)
79{
80 return vcpu->arch.mmucr & 0xff;
81}
82
83static inline unsigned int get_mmucr_sts(const struct kvm_vcpu *vcpu)
84{
85 return (vcpu->arch.mmucr >> 16) & 0x1;
86}
87
0f55dc48 88static inline gpa_t tlb_xlate(struct kvmppc_44x_tlbe *tlbe, gva_t eaddr)
bbf45ba5
HB
89{
90 unsigned int pgmask = get_tlb_bytes(tlbe) - 1;
91
92 return get_tlb_raddr(tlbe) | (eaddr & pgmask);
93}
94
95#endif /* __KVM_POWERPC_TLB_H__ */
This page took 0.098636 seconds and 5 git commands to generate.