Alexander Graf | c7f38f4 | 2010-04-16 00:11:40 +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_BOOKE_H__ |
| 21 | #define __ASM_KVM_BOOKE_H__ |
| 22 | |
| 23 | #include <linux/types.h> |
| 24 | #include <linux/kvm_host.h> |
| 25 | |
Mihai Caraman | 188e267 | 2014-09-01 12:01:58 +0300 | [diff] [blame] | 26 | /* |
| 27 | * Number of available lpids. Only the low-order 6 bits of LPID rgister are |
| 28 | * implemented on e500mc+ cores. |
| 29 | */ |
Scott Wood | 043cc4d | 2011-12-20 15:34:20 +0000 | [diff] [blame] | 30 | #define KVMPPC_NR_LPIDS 64 |
| 31 | |
Bharat Bhushan | b12c784 | 2013-07-04 12:27:45 +0530 | [diff] [blame] | 32 | #define KVMPPC_INST_EHPRIV 0x7c00021c |
| 33 | #define EHPRIV_OC_SHIFT 11 |
| 34 | /* "ehpriv 1" : ehpriv with OC = 1 is used for debug emulation */ |
| 35 | #define EHPRIV_OC_DEBUG 1 |
Bharat Bhushan | 8c32a2e | 2013-03-20 20:24:58 +0000 | [diff] [blame] | 36 | |
Alexander Graf | c7f38f4 | 2010-04-16 00:11:40 +0200 | [diff] [blame] | 37 | static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val) |
| 38 | { |
Simon Guo | 1143a70 | 2018-05-07 14:20:07 +0800 | [diff] [blame^] | 39 | vcpu->arch.regs.gpr[num] = val; |
Alexander Graf | c7f38f4 | 2010-04-16 00:11:40 +0200 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num) |
| 43 | { |
Simon Guo | 1143a70 | 2018-05-07 14:20:07 +0800 | [diff] [blame^] | 44 | return vcpu->arch.regs.gpr[num]; |
Alexander Graf | c7f38f4 | 2010-04-16 00:11:40 +0200 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val) |
| 48 | { |
| 49 | vcpu->arch.cr = val; |
| 50 | } |
| 51 | |
| 52 | static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu) |
| 53 | { |
| 54 | return vcpu->arch.cr; |
| 55 | } |
| 56 | |
Sam bobroff | c63517c | 2015-05-27 09:56:57 +1000 | [diff] [blame] | 57 | static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, ulong val) |
Alexander Graf | c7f38f4 | 2010-04-16 00:11:40 +0200 | [diff] [blame] | 58 | { |
| 59 | vcpu->arch.xer = val; |
| 60 | } |
| 61 | |
Sam bobroff | c63517c | 2015-05-27 09:56:57 +1000 | [diff] [blame] | 62 | static inline ulong kvmppc_get_xer(struct kvm_vcpu *vcpu) |
Alexander Graf | c7f38f4 | 2010-04-16 00:11:40 +0200 | [diff] [blame] | 63 | { |
| 64 | return vcpu->arch.xer; |
| 65 | } |
| 66 | |
Cédric Le Goater | 7360177 | 2014-01-09 11:51:16 +0100 | [diff] [blame] | 67 | static inline bool kvmppc_need_byteswap(struct kvm_vcpu *vcpu) |
| 68 | { |
| 69 | /* XXX Would need to check TLB entry */ |
| 70 | return false; |
| 71 | } |
| 72 | |
Alexander Graf | c7f38f4 | 2010-04-16 00:11:40 +0200 | [diff] [blame] | 73 | static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val) |
| 74 | { |
| 75 | vcpu->arch.ctr = val; |
| 76 | } |
| 77 | |
| 78 | static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu) |
| 79 | { |
| 80 | return vcpu->arch.ctr; |
| 81 | } |
| 82 | |
| 83 | static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val) |
| 84 | { |
| 85 | vcpu->arch.lr = val; |
| 86 | } |
| 87 | |
| 88 | static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu) |
| 89 | { |
| 90 | return vcpu->arch.lr; |
| 91 | } |
| 92 | |
| 93 | static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val) |
| 94 | { |
| 95 | vcpu->arch.pc = val; |
| 96 | } |
| 97 | |
| 98 | static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu) |
| 99 | { |
| 100 | return vcpu->arch.pc; |
| 101 | } |
| 102 | |
| 103 | static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu) |
| 104 | { |
| 105 | return vcpu->arch.fault_dear; |
| 106 | } |
Alexander Graf | c12fb43 | 2014-06-20 14:43:36 +0200 | [diff] [blame] | 107 | |
| 108 | static inline bool kvmppc_supports_magic_page(struct kvm_vcpu *vcpu) |
| 109 | { |
| 110 | /* Magic page is only supported on e500v2 */ |
| 111 | #ifdef CONFIG_KVM_E500V2 |
| 112 | return true; |
| 113 | #else |
| 114 | return false; |
| 115 | #endif |
| 116 | } |
Alexander Graf | c7f38f4 | 2010-04-16 00:11:40 +0200 | [diff] [blame] | 117 | #endif /* __ASM_KVM_BOOKE_H__ */ |