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