Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [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. 2007 |
| 16 | * |
| 17 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> |
| 18 | */ |
| 19 | |
| 20 | #include <linux/jiffies.h> |
Alexander Graf | 544c676 | 2009-11-02 12:02:31 +0000 | [diff] [blame] | 21 | #include <linux/hrtimer.h> |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 22 | #include <linux/types.h> |
| 23 | #include <linux/string.h> |
| 24 | #include <linux/kvm_host.h> |
| 25 | |
Hollis Blanchard | 75f74f0 | 2008-11-05 09:36:16 -0600 | [diff] [blame] | 26 | #include <asm/reg.h> |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 27 | #include <asm/time.h> |
| 28 | #include <asm/byteorder.h> |
| 29 | #include <asm/kvm_ppc.h> |
Hollis Blanchard | c381a04 | 2008-11-05 09:36:15 -0600 | [diff] [blame] | 30 | #include <asm/disassemble.h> |
Hollis Blanchard | 73e75b4 | 2008-12-02 15:51:57 -0600 | [diff] [blame] | 31 | #include "timing.h" |
Marcelo Tosatti | 46f43c6 | 2009-06-18 11:47:27 -0300 | [diff] [blame] | 32 | #include "trace.h" |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 33 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 34 | #define OP_TRAP 3 |
Alexander Graf | 513579e | 2009-10-30 05:47:16 +0000 | [diff] [blame] | 35 | #define OP_TRAP_64 2 |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 36 | |
| 37 | #define OP_31_XOP_LWZX 23 |
| 38 | #define OP_31_XOP_LBZX 87 |
| 39 | #define OP_31_XOP_STWX 151 |
| 40 | #define OP_31_XOP_STBX 215 |
Alexander Graf | 1c85e73 | 2010-03-24 21:48:27 +0100 | [diff] [blame] | 41 | #define OP_31_XOP_LBZUX 119 |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 42 | #define OP_31_XOP_STBUX 247 |
| 43 | #define OP_31_XOP_LHZX 279 |
| 44 | #define OP_31_XOP_LHZUX 311 |
| 45 | #define OP_31_XOP_MFSPR 339 |
Alexander Graf | 1c85e73 | 2010-03-24 21:48:27 +0100 | [diff] [blame] | 46 | #define OP_31_XOP_LHAX 343 |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 47 | #define OP_31_XOP_STHX 407 |
| 48 | #define OP_31_XOP_STHUX 439 |
| 49 | #define OP_31_XOP_MTSPR 467 |
| 50 | #define OP_31_XOP_DCBI 470 |
| 51 | #define OP_31_XOP_LWBRX 534 |
| 52 | #define OP_31_XOP_TLBSYNC 566 |
| 53 | #define OP_31_XOP_STWBRX 662 |
| 54 | #define OP_31_XOP_LHBRX 790 |
| 55 | #define OP_31_XOP_STHBRX 918 |
| 56 | |
| 57 | #define OP_LWZ 32 |
| 58 | #define OP_LWZU 33 |
| 59 | #define OP_LBZ 34 |
| 60 | #define OP_LBZU 35 |
| 61 | #define OP_STW 36 |
| 62 | #define OP_STWU 37 |
| 63 | #define OP_STB 38 |
| 64 | #define OP_STBU 39 |
| 65 | #define OP_LHZ 40 |
| 66 | #define OP_LHZU 41 |
Alexander Graf | 3587d53 | 2010-02-19 11:00:30 +0100 | [diff] [blame] | 67 | #define OP_LHA 42 |
| 68 | #define OP_LHAU 43 |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 69 | #define OP_STH 44 |
| 70 | #define OP_STHU 45 |
| 71 | |
Alexander Graf | 00c3a37 | 2010-04-16 00:11:42 +0200 | [diff] [blame] | 72 | #ifdef CONFIG_PPC_BOOK3S |
Alexander Graf | 513579e | 2009-10-30 05:47:16 +0000 | [diff] [blame] | 73 | static int kvmppc_dec_enabled(struct kvm_vcpu *vcpu) |
| 74 | { |
| 75 | return 1; |
| 76 | } |
| 77 | #else |
| 78 | static int kvmppc_dec_enabled(struct kvm_vcpu *vcpu) |
| 79 | { |
| 80 | return vcpu->arch.tcr & TCR_DIE; |
| 81 | } |
| 82 | #endif |
| 83 | |
Hollis Blanchard | 75f74f0 | 2008-11-05 09:36:16 -0600 | [diff] [blame] | 84 | void kvmppc_emulate_dec(struct kvm_vcpu *vcpu) |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 85 | { |
Alexander Graf | 544c676 | 2009-11-02 12:02:31 +0000 | [diff] [blame] | 86 | unsigned long dec_nsec; |
Alexander Graf | 9a7a9b0 | 2009-10-30 05:47:15 +0000 | [diff] [blame] | 87 | |
Alexander Graf | 544c676 | 2009-11-02 12:02:31 +0000 | [diff] [blame] | 88 | pr_debug("mtDEC: %x\n", vcpu->arch.dec); |
Alexander Graf | 00c3a37 | 2010-04-16 00:11:42 +0200 | [diff] [blame] | 89 | #ifdef CONFIG_PPC_BOOK3S |
Alexander Graf | 7706664d | 2009-12-21 20:21:24 +0100 | [diff] [blame] | 90 | /* mtdec lowers the interrupt line when positive. */ |
| 91 | kvmppc_core_dequeue_dec(vcpu); |
| 92 | |
Alexander Graf | 513579e | 2009-10-30 05:47:16 +0000 | [diff] [blame] | 93 | /* POWER4+ triggers a dec interrupt if the value is < 0 */ |
| 94 | if (vcpu->arch.dec & 0x80000000) { |
Alexander Graf | 544c676 | 2009-11-02 12:02:31 +0000 | [diff] [blame] | 95 | hrtimer_try_to_cancel(&vcpu->arch.dec_timer); |
Alexander Graf | 513579e | 2009-10-30 05:47:16 +0000 | [diff] [blame] | 96 | kvmppc_core_queue_dec(vcpu); |
| 97 | return; |
| 98 | } |
| 99 | #endif |
| 100 | if (kvmppc_dec_enabled(vcpu)) { |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 101 | /* The decrementer ticks at the same rate as the timebase, so |
| 102 | * that's how we convert the guest DEC value to the number of |
| 103 | * host ticks. */ |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 104 | |
Alexander Graf | 544c676 | 2009-11-02 12:02:31 +0000 | [diff] [blame] | 105 | hrtimer_try_to_cancel(&vcpu->arch.dec_timer); |
| 106 | dec_nsec = vcpu->arch.dec; |
| 107 | dec_nsec *= 1000; |
| 108 | dec_nsec /= tb_ticks_per_usec; |
| 109 | hrtimer_start(&vcpu->arch.dec_timer, ktime_set(0, dec_nsec), |
| 110 | HRTIMER_MODE_REL); |
Alexander Graf | 513579e | 2009-10-30 05:47:16 +0000 | [diff] [blame] | 111 | vcpu->arch.dec_jiffies = get_tb(); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 112 | } else { |
Alexander Graf | 544c676 | 2009-11-02 12:02:31 +0000 | [diff] [blame] | 113 | hrtimer_try_to_cancel(&vcpu->arch.dec_timer); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 114 | } |
| 115 | } |
| 116 | |
Scott Wood | 5ce941e | 2011-04-27 17:24:21 -0500 | [diff] [blame] | 117 | u32 kvmppc_get_dec(struct kvm_vcpu *vcpu, u64 tb) |
| 118 | { |
| 119 | u64 jd = tb - vcpu->arch.dec_jiffies; |
| 120 | return vcpu->arch.dec - jd; |
| 121 | } |
| 122 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 123 | /* XXX to do: |
| 124 | * lhax |
| 125 | * lhaux |
| 126 | * lswx |
| 127 | * lswi |
| 128 | * stswx |
| 129 | * stswi |
| 130 | * lha |
| 131 | * lhau |
| 132 | * lmw |
| 133 | * stmw |
| 134 | * |
| 135 | * XXX is_bigendian should depend on MMU mapping or MSR[LE] |
| 136 | */ |
Hollis Blanchard | 75f74f0 | 2008-11-05 09:36:16 -0600 | [diff] [blame] | 137 | /* XXX Should probably auto-generate instruction decoding for a particular core |
| 138 | * from opcode tables in the future. */ |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 139 | int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu) |
| 140 | { |
Alexander Graf | c7f38f4 | 2010-04-16 00:11:40 +0200 | [diff] [blame] | 141 | u32 inst = kvmppc_get_last_inst(vcpu); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 142 | u32 ea; |
| 143 | int ra; |
| 144 | int rb; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 145 | int rs; |
| 146 | int rt; |
| 147 | int sprn; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 148 | enum emulation_result emulated = EMULATE_DONE; |
| 149 | int advance = 1; |
| 150 | |
Hollis Blanchard | 73e75b4 | 2008-12-02 15:51:57 -0600 | [diff] [blame] | 151 | /* this default type might be overwritten by subcategories */ |
| 152 | kvmppc_set_exit_type(vcpu, EMULATED_INST_EXITS); |
| 153 | |
Joe Perches | 689fd14 | 2010-09-11 19:10:53 +0000 | [diff] [blame] | 154 | pr_debug("Emulating opcode %d / %d\n", get_op(inst), get_xop(inst)); |
Alexander Graf | 513579e | 2009-10-30 05:47:16 +0000 | [diff] [blame] | 155 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 156 | switch (get_op(inst)) { |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 157 | case OP_TRAP: |
Alexander Graf | 00c3a37 | 2010-04-16 00:11:42 +0200 | [diff] [blame] | 158 | #ifdef CONFIG_PPC_BOOK3S |
Alexander Graf | 513579e | 2009-10-30 05:47:16 +0000 | [diff] [blame] | 159 | case OP_TRAP_64: |
Alexander Graf | 25a8a02 | 2010-01-08 02:58:07 +0100 | [diff] [blame] | 160 | kvmppc_core_queue_program(vcpu, SRR1_PROGTRAP); |
Liu Yu | daf5e27 | 2010-02-02 19:44:35 +0800 | [diff] [blame] | 161 | #else |
| 162 | kvmppc_core_queue_program(vcpu, vcpu->arch.esr | ESR_PTR); |
| 163 | #endif |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 164 | advance = 0; |
| 165 | break; |
| 166 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 167 | case 31: |
| 168 | switch (get_xop(inst)) { |
| 169 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 170 | case OP_31_XOP_LWZX: |
Hollis Blanchard | ac3cd34 | 2008-05-21 18:22:52 -0500 | [diff] [blame] | 171 | rt = get_rt(inst); |
| 172 | emulated = kvmppc_handle_load(run, vcpu, rt, 4, 1); |
| 173 | break; |
| 174 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 175 | case OP_31_XOP_LBZX: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 176 | rt = get_rt(inst); |
| 177 | emulated = kvmppc_handle_load(run, vcpu, rt, 1, 1); |
| 178 | break; |
| 179 | |
Alexander Graf | 1c85e73 | 2010-03-24 21:48:27 +0100 | [diff] [blame] | 180 | case OP_31_XOP_LBZUX: |
| 181 | rt = get_rt(inst); |
| 182 | ra = get_ra(inst); |
| 183 | rb = get_rb(inst); |
| 184 | |
| 185 | ea = kvmppc_get_gpr(vcpu, rb); |
| 186 | if (ra) |
| 187 | ea += kvmppc_get_gpr(vcpu, ra); |
| 188 | |
| 189 | emulated = kvmppc_handle_load(run, vcpu, rt, 1, 1); |
| 190 | kvmppc_set_gpr(vcpu, ra, ea); |
| 191 | break; |
| 192 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 193 | case OP_31_XOP_STWX: |
Hollis Blanchard | ac3cd34 | 2008-05-21 18:22:52 -0500 | [diff] [blame] | 194 | rs = get_rs(inst); |
| 195 | emulated = kvmppc_handle_store(run, vcpu, |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 196 | kvmppc_get_gpr(vcpu, rs), |
Hollis Blanchard | ac3cd34 | 2008-05-21 18:22:52 -0500 | [diff] [blame] | 197 | 4, 1); |
| 198 | break; |
| 199 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 200 | case OP_31_XOP_STBX: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 201 | rs = get_rs(inst); |
| 202 | emulated = kvmppc_handle_store(run, vcpu, |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 203 | kvmppc_get_gpr(vcpu, rs), |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 204 | 1, 1); |
| 205 | break; |
| 206 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 207 | case OP_31_XOP_STBUX: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 208 | rs = get_rs(inst); |
| 209 | ra = get_ra(inst); |
| 210 | rb = get_rb(inst); |
| 211 | |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 212 | ea = kvmppc_get_gpr(vcpu, rb); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 213 | if (ra) |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 214 | ea += kvmppc_get_gpr(vcpu, ra); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 215 | |
| 216 | emulated = kvmppc_handle_store(run, vcpu, |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 217 | kvmppc_get_gpr(vcpu, rs), |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 218 | 1, 1); |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 219 | kvmppc_set_gpr(vcpu, rs, ea); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 220 | break; |
| 221 | |
Alexander Graf | 1c85e73 | 2010-03-24 21:48:27 +0100 | [diff] [blame] | 222 | case OP_31_XOP_LHAX: |
| 223 | rt = get_rt(inst); |
| 224 | emulated = kvmppc_handle_loads(run, vcpu, rt, 2, 1); |
| 225 | break; |
| 226 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 227 | case OP_31_XOP_LHZX: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 228 | rt = get_rt(inst); |
| 229 | emulated = kvmppc_handle_load(run, vcpu, rt, 2, 1); |
| 230 | break; |
| 231 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 232 | case OP_31_XOP_LHZUX: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 233 | rt = get_rt(inst); |
| 234 | ra = get_ra(inst); |
| 235 | rb = get_rb(inst); |
| 236 | |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 237 | ea = kvmppc_get_gpr(vcpu, rb); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 238 | if (ra) |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 239 | ea += kvmppc_get_gpr(vcpu, ra); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 240 | |
| 241 | emulated = kvmppc_handle_load(run, vcpu, rt, 2, 1); |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 242 | kvmppc_set_gpr(vcpu, ra, ea); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 243 | break; |
| 244 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 245 | case OP_31_XOP_MFSPR: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 246 | sprn = get_sprn(inst); |
| 247 | rt = get_rt(inst); |
| 248 | |
| 249 | switch (sprn) { |
| 250 | case SPRN_SRR0: |
Alexander Graf | de7906c | 2010-07-29 14:47:46 +0200 | [diff] [blame] | 251 | kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->srr0); |
| 252 | break; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 253 | case SPRN_SRR1: |
Alexander Graf | de7906c | 2010-07-29 14:47:46 +0200 | [diff] [blame] | 254 | kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->srr1); |
| 255 | break; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 256 | case SPRN_PVR: |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 257 | kvmppc_set_gpr(vcpu, rt, vcpu->arch.pvr); break; |
Liu Yu | 06579dd | 2009-06-05 14:54:31 +0800 | [diff] [blame] | 258 | case SPRN_PIR: |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 259 | kvmppc_set_gpr(vcpu, rt, vcpu->vcpu_id); break; |
Alexander Graf | 513579e | 2009-10-30 05:47:16 +0000 | [diff] [blame] | 260 | case SPRN_MSSSR0: |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 261 | kvmppc_set_gpr(vcpu, rt, 0); break; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 262 | |
| 263 | /* Note: mftb and TBRL/TBWL are user-accessible, so |
| 264 | * the guest can always access the real TB anyways. |
| 265 | * In fact, we probably will never see these traps. */ |
| 266 | case SPRN_TBWL: |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 267 | kvmppc_set_gpr(vcpu, rt, get_tb() >> 32); break; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 268 | case SPRN_TBWU: |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 269 | kvmppc_set_gpr(vcpu, rt, get_tb()); break; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 270 | |
| 271 | case SPRN_SPRG0: |
Alexander Graf | a73a959 | 2010-07-29 14:47:47 +0200 | [diff] [blame] | 272 | kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->sprg0); |
| 273 | break; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 274 | case SPRN_SPRG1: |
Alexander Graf | a73a959 | 2010-07-29 14:47:47 +0200 | [diff] [blame] | 275 | kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->sprg1); |
| 276 | break; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 277 | case SPRN_SPRG2: |
Alexander Graf | a73a959 | 2010-07-29 14:47:47 +0200 | [diff] [blame] | 278 | kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->sprg2); |
| 279 | break; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 280 | case SPRN_SPRG3: |
Alexander Graf | a73a959 | 2010-07-29 14:47:47 +0200 | [diff] [blame] | 281 | kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->sprg3); |
| 282 | break; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 283 | /* Note: SPRG4-7 are user-readable, so we don't get |
| 284 | * a trap. */ |
| 285 | |
Alexander Graf | 9a7a9b0 | 2009-10-30 05:47:15 +0000 | [diff] [blame] | 286 | case SPRN_DEC: |
| 287 | { |
Scott Wood | 5ce941e | 2011-04-27 17:24:21 -0500 | [diff] [blame] | 288 | kvmppc_set_gpr(vcpu, rt, |
| 289 | kvmppc_get_dec(vcpu, get_tb())); |
Alexander Graf | 9a7a9b0 | 2009-10-30 05:47:15 +0000 | [diff] [blame] | 290 | break; |
| 291 | } |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 292 | default: |
Hollis Blanchard | 75f74f0 | 2008-11-05 09:36:16 -0600 | [diff] [blame] | 293 | emulated = kvmppc_core_emulate_mfspr(vcpu, sprn, rt); |
| 294 | if (emulated == EMULATE_FAIL) { |
| 295 | printk("mfspr: unknown spr %x\n", sprn); |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 296 | kvmppc_set_gpr(vcpu, rt, 0); |
Hollis Blanchard | 75f74f0 | 2008-11-05 09:36:16 -0600 | [diff] [blame] | 297 | } |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 298 | break; |
| 299 | } |
Scott Wood | 49ea069 | 2011-03-28 15:01:24 -0500 | [diff] [blame] | 300 | kvmppc_set_exit_type(vcpu, EMULATED_MFSPR_EXITS); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 301 | break; |
| 302 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 303 | case OP_31_XOP_STHX: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 304 | rs = get_rs(inst); |
| 305 | ra = get_ra(inst); |
| 306 | rb = get_rb(inst); |
| 307 | |
| 308 | emulated = kvmppc_handle_store(run, vcpu, |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 309 | kvmppc_get_gpr(vcpu, rs), |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 310 | 2, 1); |
| 311 | break; |
| 312 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 313 | case OP_31_XOP_STHUX: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 314 | rs = get_rs(inst); |
| 315 | ra = get_ra(inst); |
| 316 | rb = get_rb(inst); |
| 317 | |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 318 | ea = kvmppc_get_gpr(vcpu, rb); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 319 | if (ra) |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 320 | ea += kvmppc_get_gpr(vcpu, ra); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 321 | |
| 322 | emulated = kvmppc_handle_store(run, vcpu, |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 323 | kvmppc_get_gpr(vcpu, rs), |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 324 | 2, 1); |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 325 | kvmppc_set_gpr(vcpu, ra, ea); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 326 | break; |
| 327 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 328 | case OP_31_XOP_MTSPR: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 329 | sprn = get_sprn(inst); |
| 330 | rs = get_rs(inst); |
| 331 | switch (sprn) { |
| 332 | case SPRN_SRR0: |
Alexander Graf | de7906c | 2010-07-29 14:47:46 +0200 | [diff] [blame] | 333 | vcpu->arch.shared->srr0 = kvmppc_get_gpr(vcpu, rs); |
| 334 | break; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 335 | case SPRN_SRR1: |
Alexander Graf | de7906c | 2010-07-29 14:47:46 +0200 | [diff] [blame] | 336 | vcpu->arch.shared->srr1 = kvmppc_get_gpr(vcpu, rs); |
| 337 | break; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 338 | |
| 339 | /* XXX We need to context-switch the timebase for |
| 340 | * watchdog and FIT. */ |
| 341 | case SPRN_TBWL: break; |
| 342 | case SPRN_TBWU: break; |
| 343 | |
Alexander Graf | 513579e | 2009-10-30 05:47:16 +0000 | [diff] [blame] | 344 | case SPRN_MSSSR0: break; |
| 345 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 346 | case SPRN_DEC: |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 347 | vcpu->arch.dec = kvmppc_get_gpr(vcpu, rs); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 348 | kvmppc_emulate_dec(vcpu); |
| 349 | break; |
| 350 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 351 | case SPRN_SPRG0: |
Alexander Graf | a73a959 | 2010-07-29 14:47:47 +0200 | [diff] [blame] | 352 | vcpu->arch.shared->sprg0 = kvmppc_get_gpr(vcpu, rs); |
| 353 | break; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 354 | case SPRN_SPRG1: |
Alexander Graf | a73a959 | 2010-07-29 14:47:47 +0200 | [diff] [blame] | 355 | vcpu->arch.shared->sprg1 = kvmppc_get_gpr(vcpu, rs); |
| 356 | break; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 357 | case SPRN_SPRG2: |
Alexander Graf | a73a959 | 2010-07-29 14:47:47 +0200 | [diff] [blame] | 358 | vcpu->arch.shared->sprg2 = kvmppc_get_gpr(vcpu, rs); |
| 359 | break; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 360 | case SPRN_SPRG3: |
Alexander Graf | a73a959 | 2010-07-29 14:47:47 +0200 | [diff] [blame] | 361 | vcpu->arch.shared->sprg3 = kvmppc_get_gpr(vcpu, rs); |
| 362 | break; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 363 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 364 | default: |
Hollis Blanchard | 75f74f0 | 2008-11-05 09:36:16 -0600 | [diff] [blame] | 365 | emulated = kvmppc_core_emulate_mtspr(vcpu, sprn, rs); |
| 366 | if (emulated == EMULATE_FAIL) |
| 367 | printk("mtspr: unknown spr %x\n", sprn); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 368 | break; |
| 369 | } |
Scott Wood | 49ea069 | 2011-03-28 15:01:24 -0500 | [diff] [blame] | 370 | kvmppc_set_exit_type(vcpu, EMULATED_MTSPR_EXITS); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 371 | break; |
| 372 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 373 | case OP_31_XOP_DCBI: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 374 | /* Do nothing. The guest is performing dcbi because |
| 375 | * hardware DMA is not snooped by the dcache, but |
| 376 | * emulated DMA either goes through the dcache as |
| 377 | * normal writes, or the host kernel has handled dcache |
| 378 | * coherence. */ |
| 379 | break; |
| 380 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 381 | case OP_31_XOP_LWBRX: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 382 | rt = get_rt(inst); |
| 383 | emulated = kvmppc_handle_load(run, vcpu, rt, 4, 0); |
| 384 | break; |
| 385 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 386 | case OP_31_XOP_TLBSYNC: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 387 | break; |
| 388 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 389 | case OP_31_XOP_STWBRX: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 390 | rs = get_rs(inst); |
| 391 | ra = get_ra(inst); |
| 392 | rb = get_rb(inst); |
| 393 | |
| 394 | emulated = kvmppc_handle_store(run, vcpu, |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 395 | kvmppc_get_gpr(vcpu, rs), |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 396 | 4, 0); |
| 397 | break; |
| 398 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 399 | case OP_31_XOP_LHBRX: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 400 | rt = get_rt(inst); |
| 401 | emulated = kvmppc_handle_load(run, vcpu, rt, 2, 0); |
| 402 | break; |
| 403 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 404 | case OP_31_XOP_STHBRX: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 405 | rs = get_rs(inst); |
| 406 | ra = get_ra(inst); |
| 407 | rb = get_rb(inst); |
| 408 | |
| 409 | emulated = kvmppc_handle_store(run, vcpu, |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 410 | kvmppc_get_gpr(vcpu, rs), |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 411 | 2, 0); |
| 412 | break; |
| 413 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 414 | default: |
Hollis Blanchard | 75f74f0 | 2008-11-05 09:36:16 -0600 | [diff] [blame] | 415 | /* Attempt core-specific emulation below. */ |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 416 | emulated = EMULATE_FAIL; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 417 | } |
| 418 | break; |
| 419 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 420 | case OP_LWZ: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 421 | rt = get_rt(inst); |
| 422 | emulated = kvmppc_handle_load(run, vcpu, rt, 4, 1); |
| 423 | break; |
| 424 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 425 | case OP_LWZU: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 426 | ra = get_ra(inst); |
| 427 | rt = get_rt(inst); |
| 428 | emulated = kvmppc_handle_load(run, vcpu, rt, 4, 1); |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 429 | kvmppc_set_gpr(vcpu, ra, vcpu->arch.paddr_accessed); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 430 | break; |
| 431 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 432 | case OP_LBZ: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 433 | rt = get_rt(inst); |
| 434 | emulated = kvmppc_handle_load(run, vcpu, rt, 1, 1); |
| 435 | break; |
| 436 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 437 | case OP_LBZU: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 438 | ra = get_ra(inst); |
| 439 | rt = get_rt(inst); |
| 440 | emulated = kvmppc_handle_load(run, vcpu, rt, 1, 1); |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 441 | kvmppc_set_gpr(vcpu, ra, vcpu->arch.paddr_accessed); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 442 | break; |
| 443 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 444 | case OP_STW: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 445 | rs = get_rs(inst); |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 446 | emulated = kvmppc_handle_store(run, vcpu, |
| 447 | kvmppc_get_gpr(vcpu, rs), |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 448 | 4, 1); |
| 449 | break; |
| 450 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 451 | case OP_STWU: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 452 | ra = get_ra(inst); |
| 453 | rs = get_rs(inst); |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 454 | emulated = kvmppc_handle_store(run, vcpu, |
| 455 | kvmppc_get_gpr(vcpu, rs), |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 456 | 4, 1); |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 457 | kvmppc_set_gpr(vcpu, ra, vcpu->arch.paddr_accessed); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 458 | break; |
| 459 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 460 | case OP_STB: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 461 | rs = get_rs(inst); |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 462 | emulated = kvmppc_handle_store(run, vcpu, |
| 463 | kvmppc_get_gpr(vcpu, rs), |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 464 | 1, 1); |
| 465 | break; |
| 466 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 467 | case OP_STBU: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 468 | ra = get_ra(inst); |
| 469 | rs = get_rs(inst); |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 470 | emulated = kvmppc_handle_store(run, vcpu, |
| 471 | kvmppc_get_gpr(vcpu, rs), |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 472 | 1, 1); |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 473 | kvmppc_set_gpr(vcpu, ra, vcpu->arch.paddr_accessed); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 474 | break; |
| 475 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 476 | case OP_LHZ: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 477 | rt = get_rt(inst); |
| 478 | emulated = kvmppc_handle_load(run, vcpu, rt, 2, 1); |
| 479 | break; |
| 480 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 481 | case OP_LHZU: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 482 | ra = get_ra(inst); |
| 483 | rt = get_rt(inst); |
| 484 | emulated = kvmppc_handle_load(run, vcpu, rt, 2, 1); |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 485 | kvmppc_set_gpr(vcpu, ra, vcpu->arch.paddr_accessed); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 486 | break; |
| 487 | |
Alexander Graf | 3587d53 | 2010-02-19 11:00:30 +0100 | [diff] [blame] | 488 | case OP_LHA: |
| 489 | rt = get_rt(inst); |
| 490 | emulated = kvmppc_handle_loads(run, vcpu, rt, 2, 1); |
| 491 | break; |
| 492 | |
| 493 | case OP_LHAU: |
| 494 | ra = get_ra(inst); |
| 495 | rt = get_rt(inst); |
| 496 | emulated = kvmppc_handle_loads(run, vcpu, rt, 2, 1); |
| 497 | kvmppc_set_gpr(vcpu, ra, vcpu->arch.paddr_accessed); |
| 498 | break; |
| 499 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 500 | case OP_STH: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 501 | rs = get_rs(inst); |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 502 | emulated = kvmppc_handle_store(run, vcpu, |
| 503 | kvmppc_get_gpr(vcpu, rs), |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 504 | 2, 1); |
| 505 | break; |
| 506 | |
Hollis Blanchard | cea5d8c | 2009-01-03 16:23:05 -0600 | [diff] [blame] | 507 | case OP_STHU: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 508 | ra = get_ra(inst); |
| 509 | rs = get_rs(inst); |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 510 | emulated = kvmppc_handle_store(run, vcpu, |
| 511 | kvmppc_get_gpr(vcpu, rs), |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 512 | 2, 1); |
Alexander Graf | 8e5b26b | 2010-01-08 02:58:01 +0100 | [diff] [blame] | 513 | kvmppc_set_gpr(vcpu, ra, vcpu->arch.paddr_accessed); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 514 | break; |
| 515 | |
| 516 | default: |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 517 | emulated = EMULATE_FAIL; |
Hollis Blanchard | 75f74f0 | 2008-11-05 09:36:16 -0600 | [diff] [blame] | 518 | } |
| 519 | |
| 520 | if (emulated == EMULATE_FAIL) { |
| 521 | emulated = kvmppc_core_emulate_op(run, vcpu, inst, &advance); |
Alexander Graf | 37f5bca | 2010-02-19 11:00:31 +0100 | [diff] [blame] | 522 | if (emulated == EMULATE_AGAIN) { |
| 523 | advance = 0; |
| 524 | } else if (emulated == EMULATE_FAIL) { |
Hollis Blanchard | 75f74f0 | 2008-11-05 09:36:16 -0600 | [diff] [blame] | 525 | advance = 0; |
| 526 | printk(KERN_ERR "Couldn't emulate instruction 0x%08x " |
| 527 | "(op %d xop %d)\n", inst, get_op(inst), get_xop(inst)); |
Alexander Graf | 5f2b105 | 2010-01-10 03:27:32 +0100 | [diff] [blame] | 528 | kvmppc_core_queue_program(vcpu, 0); |
Hollis Blanchard | 75f74f0 | 2008-11-05 09:36:16 -0600 | [diff] [blame] | 529 | } |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 530 | } |
| 531 | |
Alexander Graf | c7f38f4 | 2010-04-16 00:11:40 +0200 | [diff] [blame] | 532 | trace_kvm_ppc_instr(inst, kvmppc_get_pc(vcpu), emulated); |
Christian Ehrhardt | 3b4bd79 | 2008-07-14 14:00:04 +0200 | [diff] [blame] | 533 | |
Alexander Graf | c7f38f4 | 2010-04-16 00:11:40 +0200 | [diff] [blame] | 534 | /* Advance past emulated instruction. */ |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 535 | if (advance) |
Alexander Graf | c7f38f4 | 2010-04-16 00:11:40 +0200 | [diff] [blame] | 536 | kvmppc_set_pc(vcpu, kvmppc_get_pc(vcpu) + 4); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 537 | |
| 538 | return emulated; |
| 539 | } |