blob: 2054e4726ba203c2daa7a165d673cac07f31285d [file] [log] [blame]
Alexander Graf3ae07892010-04-16 00:11:37 +02001/*
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 SUSE Linux Products GmbH 2010
16 *
17 * Authors: Alexander Graf <agraf@suse.de>
18 */
19
20#ifndef __ASM_KVM_BOOK3S_64_H__
21#define __ASM_KVM_BOOK3S_64_H__
22
Paul Mackerrasde56a942011-06-29 00:21:34 +000023#ifdef CONFIG_KVM_BOOK3S_PR
Alexander Graf468a12c2011-12-09 14:44:13 +010024static inline struct kvmppc_book3s_shadow_vcpu *svcpu_get(struct kvm_vcpu *vcpu)
Alexander Graf3ae07892010-04-16 00:11:37 +020025{
Alexander Graf468a12c2011-12-09 14:44:13 +010026 preempt_disable();
Alexander Graf3ae07892010-04-16 00:11:37 +020027 return &get_paca()->shadow_vcpu;
28}
Alexander Graf468a12c2011-12-09 14:44:13 +010029
30static inline void svcpu_put(struct kvmppc_book3s_shadow_vcpu *svcpu)
31{
32 preempt_enable();
33}
Paul Mackerrasde56a942011-06-29 00:21:34 +000034#endif
Alexander Graf3ae07892010-04-16 00:11:37 +020035
David Gibson54738c02011-06-29 00:22:41 +000036#define SPAPR_TCE_SHIFT 12
37
Andreas Schwab36cc66d2011-11-08 07:08:52 +000038static inline unsigned long compute_tlbie_rb(unsigned long v, unsigned long r,
39 unsigned long pte_index)
40{
41 unsigned long rb, va_low;
42
43 rb = (v & ~0x7fUL) << 16; /* AVA field */
44 va_low = pte_index >> 3;
45 if (v & HPTE_V_SECONDARY)
46 va_low = ~va_low;
47 /* xor vsid from AVA */
48 if (!(v & HPTE_V_1TB_SEG))
49 va_low ^= v >> 12;
50 else
51 va_low ^= v >> 24;
52 va_low &= 0x7ff;
53 if (v & HPTE_V_LARGE) {
54 rb |= 1; /* L field */
55 if (cpu_has_feature(CPU_FTR_ARCH_206) &&
56 (r & 0xff000)) {
57 /* non-16MB large page, must be 64k */
58 /* (masks depend on page size) */
59 rb |= 0x1000; /* page encoding in LP field */
60 rb |= (va_low & 0x7f) << 16; /* 7b of VA in AVA/LP field */
61 rb |= (va_low & 0xfe); /* AVAL field (P7 doesn't seem to care) */
62 }
63 } else {
64 /* 4kB page */
65 rb |= (va_low & 0x7ff) << 12; /* remaining 11b of VA */
66 }
67 rb |= (v >> 54) & 0x300; /* B field */
68 return rb;
69}
70
Alexander Graf3ae07892010-04-16 00:11:37 +020071#endif /* __ASM_KVM_BOOK3S_64_H__ */