Alexander Graf | 3ae0789 | 2010-04-16 00:11:37 +0200 | [diff] [blame] | 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 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 Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 23 | #ifdef CONFIG_KVM_BOOK3S_PR |
Alexander Graf | 468a12c | 2011-12-09 14:44:13 +0100 | [diff] [blame^] | 24 | static inline struct kvmppc_book3s_shadow_vcpu *svcpu_get(struct kvm_vcpu *vcpu) |
Alexander Graf | 3ae0789 | 2010-04-16 00:11:37 +0200 | [diff] [blame] | 25 | { |
Alexander Graf | 468a12c | 2011-12-09 14:44:13 +0100 | [diff] [blame^] | 26 | preempt_disable(); |
Alexander Graf | 3ae0789 | 2010-04-16 00:11:37 +0200 | [diff] [blame] | 27 | return &get_paca()->shadow_vcpu; |
| 28 | } |
Alexander Graf | 468a12c | 2011-12-09 14:44:13 +0100 | [diff] [blame^] | 29 | |
| 30 | static inline void svcpu_put(struct kvmppc_book3s_shadow_vcpu *svcpu) |
| 31 | { |
| 32 | preempt_enable(); |
| 33 | } |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 34 | #endif |
Alexander Graf | 3ae0789 | 2010-04-16 00:11:37 +0200 | [diff] [blame] | 35 | |
David Gibson | 54738c0 | 2011-06-29 00:22:41 +0000 | [diff] [blame] | 36 | #define SPAPR_TCE_SHIFT 12 |
| 37 | |
Andreas Schwab | 36cc66d | 2011-11-08 07:08:52 +0000 | [diff] [blame] | 38 | static 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 Graf | 3ae0789 | 2010-04-16 00:11:37 +0200 | [diff] [blame] | 71 | #endif /* __ASM_KVM_BOOK3S_64_H__ */ |