Revert "crypto: camellia - Use kernel-provided bitops, unaligned access helpers"
[linux-2.6/btrfs-unstable.git] / arch / powerpc / kvm / 44x_tlb.h
blob2ccd46b6f6b762474a63a89fe2e4a8ec63e62b8e
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.
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.
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.
15 * Copyright IBM Corp. 2007
17 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
20 #ifndef __KVM_POWERPC_TLB_H__
21 #define __KVM_POWERPC_TLB_H__
23 #include <linux/kvm_host.h>
24 #include <asm/mmu-44x.h>
26 extern int kvmppc_44x_tlb_index(struct kvm_vcpu *vcpu, gva_t eaddr,
27 unsigned int pid, unsigned int as);
28 extern struct tlbe *kvmppc_44x_dtlb_search(struct kvm_vcpu *vcpu, gva_t eaddr);
29 extern struct tlbe *kvmppc_44x_itlb_search(struct kvm_vcpu *vcpu, gva_t eaddr);
31 /* TLB helper functions */
32 static inline unsigned int get_tlb_size(const struct tlbe *tlbe)
34 return (tlbe->word0 >> 4) & 0xf;
37 static inline gva_t get_tlb_eaddr(const struct tlbe *tlbe)
39 return tlbe->word0 & 0xfffffc00;
42 static inline gva_t get_tlb_bytes(const struct tlbe *tlbe)
44 unsigned int pgsize = get_tlb_size(tlbe);
45 return 1 << 10 << (pgsize << 1);
48 static inline gva_t get_tlb_end(const struct tlbe *tlbe)
50 return get_tlb_eaddr(tlbe) + get_tlb_bytes(tlbe) - 1;
53 static inline u64 get_tlb_raddr(const struct tlbe *tlbe)
55 u64 word1 = tlbe->word1;
56 return ((word1 & 0xf) << 32) | (word1 & 0xfffffc00);
59 static inline unsigned int get_tlb_tid(const struct tlbe *tlbe)
61 return tlbe->tid & 0xff;
64 static inline unsigned int get_tlb_ts(const struct tlbe *tlbe)
66 return (tlbe->word0 >> 8) & 0x1;
69 static inline unsigned int get_tlb_v(const struct tlbe *tlbe)
71 return (tlbe->word0 >> 9) & 0x1;
74 static inline unsigned int get_mmucr_stid(const struct kvm_vcpu *vcpu)
76 return vcpu->arch.mmucr & 0xff;
79 static inline unsigned int get_mmucr_sts(const struct kvm_vcpu *vcpu)
81 return (vcpu->arch.mmucr >> 16) & 0x1;
84 static inline gpa_t tlb_xlate(struct tlbe *tlbe, gva_t eaddr)
86 unsigned int pgmask = get_tlb_bytes(tlbe) - 1;
88 return get_tlb_raddr(tlbe) | (eaddr & pgmask);
91 #endif /* __KVM_POWERPC_TLB_H__ */