Hollis Blanchard | db93f57 | 2008-11-05 09:36:18 -0600 | [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 IBM Corp. 2008 |
| 16 | * |
| 17 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> |
| 18 | */ |
| 19 | |
| 20 | #ifndef __ASM_44X_H__ |
| 21 | #define __ASM_44X_H__ |
| 22 | |
| 23 | #include <linux/kvm_host.h> |
| 24 | |
Hollis Blanchard | db93f57 | 2008-11-05 09:36:18 -0600 | [diff] [blame] | 25 | #define PPC44x_TLB_SIZE 64 |
| 26 | |
Hollis Blanchard | 7924bd4 | 2008-12-02 15:51:55 -0600 | [diff] [blame] | 27 | /* If the guest is expecting it, this can be as large as we like; we'd just |
| 28 | * need to find some way of advertising it. */ |
| 29 | #define KVM44x_GUEST_TLB_SIZE 64 |
| 30 | |
Hollis Blanchard | c46fb02 | 2009-01-03 16:22:58 -0600 | [diff] [blame] | 31 | struct kvmppc_44x_tlbe { |
| 32 | u32 tid; /* Only the low 8 bits are used. */ |
| 33 | u32 word0; |
| 34 | u32 word1; |
| 35 | u32 word2; |
| 36 | }; |
| 37 | |
Hollis Blanchard | 7924bd4 | 2008-12-02 15:51:55 -0600 | [diff] [blame] | 38 | struct kvmppc_44x_shadow_ref { |
| 39 | struct page *page; |
| 40 | u16 gtlb_index; |
| 41 | u8 writeable; |
| 42 | u8 tid; |
| 43 | }; |
| 44 | |
Hollis Blanchard | db93f57 | 2008-11-05 09:36:18 -0600 | [diff] [blame] | 45 | struct kvmppc_vcpu_44x { |
| 46 | /* Unmodified copy of the guest's TLB. */ |
Hollis Blanchard | 7924bd4 | 2008-12-02 15:51:55 -0600 | [diff] [blame] | 47 | struct kvmppc_44x_tlbe guest_tlb[KVM44x_GUEST_TLB_SIZE]; |
Hollis Blanchard | db93f57 | 2008-11-05 09:36:18 -0600 | [diff] [blame] | 48 | |
Hollis Blanchard | 7924bd4 | 2008-12-02 15:51:55 -0600 | [diff] [blame] | 49 | /* References to guest pages in the hardware TLB. */ |
| 50 | struct kvmppc_44x_shadow_ref shadow_refs[PPC44x_TLB_SIZE]; |
Hollis Blanchard | db93f57 | 2008-11-05 09:36:18 -0600 | [diff] [blame] | 51 | |
Hollis Blanchard | c5fbdff | 2008-12-02 15:51:56 -0600 | [diff] [blame] | 52 | /* State of the shadow TLB at guest context switch time. */ |
| 53 | struct kvmppc_44x_tlbe shadow_tlb[PPC44x_TLB_SIZE]; |
| 54 | u8 shadow_tlb_mod[PPC44x_TLB_SIZE]; |
| 55 | |
Hollis Blanchard | db93f57 | 2008-11-05 09:36:18 -0600 | [diff] [blame] | 56 | struct kvm_vcpu vcpu; |
| 57 | }; |
| 58 | |
| 59 | static inline struct kvmppc_vcpu_44x *to_44x(struct kvm_vcpu *vcpu) |
| 60 | { |
| 61 | return container_of(vcpu, struct kvmppc_vcpu_44x, vcpu); |
| 62 | } |
| 63 | |
Hollis Blanchard | fe4e771 | 2008-11-10 14:57:36 -0600 | [diff] [blame] | 64 | void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 new_pid); |
Hollis Blanchard | c5fbdff | 2008-12-02 15:51:56 -0600 | [diff] [blame] | 65 | void kvmppc_44x_tlb_put(struct kvm_vcpu *vcpu); |
| 66 | void kvmppc_44x_tlb_load(struct kvm_vcpu *vcpu); |
Hollis Blanchard | fe4e771 | 2008-11-10 14:57:36 -0600 | [diff] [blame] | 67 | |
Hollis Blanchard | db93f57 | 2008-11-05 09:36:18 -0600 | [diff] [blame] | 68 | #endif /* __ASM_44X_H__ */ |