forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/arch/powerpc/kvm/emulate_loadstore.c
....@@ -1,16 +1,5 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
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.
143 *
154 * Copyright IBM Corp. 2007
165 * Copyright 2011 Freescale Semiconductor, Inc.
....@@ -82,9 +71,7 @@
8271 */
8372 int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
8473 {
85
- struct kvm_run *run = vcpu->run;
8674 u32 inst;
87
- int ra, rs, rt;
8875 enum emulation_result emulated = EMULATE_FAIL;
8976 int advance = 1;
9077 struct instruction_op op;
....@@ -96,16 +83,6 @@
9683 if (emulated != EMULATE_DONE)
9784 return emulated;
9885
99
- ra = get_ra(inst);
100
- rs = get_rs(inst);
101
- rt = get_rt(inst);
102
-
103
- /*
104
- * if mmio_vsx_tx_sx_enabled == 0, copy data between
105
- * VSR[0..31] and memory
106
- * if mmio_vsx_tx_sx_enabled == 1, copy data between
107
- * VSR[32..63] and memory
108
- */
10986 vcpu->arch.mmio_vsx_copy_nums = 0;
11087 vcpu->arch.mmio_vsx_offset = 0;
11188 vcpu->arch.mmio_copy_type = KVMPPC_VSX_COPY_NONE;
....@@ -117,7 +94,7 @@
11794
11895 emulated = EMULATE_FAIL;
11996 vcpu->arch.regs.msr = vcpu->arch.shared->msr;
120
- if (analyse_instr(&op, &vcpu->arch.regs, inst) == 0) {
97
+ if (analyse_instr(&op, &vcpu->arch.regs, ppc_inst(inst)) == 0) {
12198 int type = op.type & INSTR_TYPE_MASK;
12299 int size = GETSIZE(op.type);
123100
....@@ -126,10 +103,10 @@
126103 int instr_byte_swap = op.type & BYTEREV;
127104
128105 if (op.type & SIGNEXT)
129
- emulated = kvmppc_handle_loads(run, vcpu,
106
+ emulated = kvmppc_handle_loads(vcpu,
130107 op.reg, size, !instr_byte_swap);
131108 else
132
- emulated = kvmppc_handle_load(run, vcpu,
109
+ emulated = kvmppc_handle_load(vcpu,
133110 op.reg, size, !instr_byte_swap);
134111
135112 if ((op.type & UPDATE) && (emulated != EMULATE_FAIL))
....@@ -146,10 +123,10 @@
146123 vcpu->arch.mmio_sp64_extend = 1;
147124
148125 if (op.type & SIGNEXT)
149
- emulated = kvmppc_handle_loads(run, vcpu,
126
+ emulated = kvmppc_handle_loads(vcpu,
150127 KVM_MMIO_REG_FPR|op.reg, size, 1);
151128 else
152
- emulated = kvmppc_handle_load(run, vcpu,
129
+ emulated = kvmppc_handle_load(vcpu,
153130 KVM_MMIO_REG_FPR|op.reg, size, 1);
154131
155132 if ((op.type & UPDATE) && (emulated != EMULATE_FAIL))
....@@ -186,12 +163,12 @@
186163
187164 if (size == 16) {
188165 vcpu->arch.mmio_vmx_copy_nums = 2;
189
- emulated = kvmppc_handle_vmx_load(run,
190
- vcpu, KVM_MMIO_REG_VMX|op.reg,
166
+ emulated = kvmppc_handle_vmx_load(vcpu,
167
+ KVM_MMIO_REG_VMX|op.reg,
191168 8, 1);
192169 } else {
193170 vcpu->arch.mmio_vmx_copy_nums = 1;
194
- emulated = kvmppc_handle_vmx_load(run, vcpu,
171
+ emulated = kvmppc_handle_vmx_load(vcpu,
195172 KVM_MMIO_REG_VMX|op.reg,
196173 size, 1);
197174 }
....@@ -239,7 +216,7 @@
239216 io_size_each = op.element_size;
240217 }
241218
242
- emulated = kvmppc_handle_vsx_load(run, vcpu,
219
+ emulated = kvmppc_handle_vsx_load(vcpu,
243220 KVM_MMIO_REG_VSX|op.reg, io_size_each,
244221 1, op.type & SIGNEXT);
245222 break;
....@@ -249,8 +226,7 @@
249226 /* if need byte reverse, op.val has been reversed by
250227 * analyse_instr().
251228 */
252
- emulated = kvmppc_handle_store(run, vcpu, op.val,
253
- size, 1);
229
+ emulated = kvmppc_handle_store(vcpu, op.val, size, 1);
254230
255231 if ((op.type & UPDATE) && (emulated != EMULATE_FAIL))
256232 kvmppc_set_gpr(vcpu, op.update_reg, op.ea);
....@@ -272,7 +248,7 @@
272248 if (op.type & FPCONV)
273249 vcpu->arch.mmio_sp64_extend = 1;
274250
275
- emulated = kvmppc_handle_store(run, vcpu,
251
+ emulated = kvmppc_handle_store(vcpu,
276252 VCPU_FPR(vcpu, op.reg), size, 1);
277253
278254 if ((op.type & UPDATE) && (emulated != EMULATE_FAIL))
....@@ -312,12 +288,12 @@
312288
313289 if (size == 16) {
314290 vcpu->arch.mmio_vmx_copy_nums = 2;
315
- emulated = kvmppc_handle_vmx_store(run,
316
- vcpu, op.reg, 8, 1);
291
+ emulated = kvmppc_handle_vmx_store(vcpu,
292
+ op.reg, 8, 1);
317293 } else {
318294 vcpu->arch.mmio_vmx_copy_nums = 1;
319
- emulated = kvmppc_handle_vmx_store(run,
320
- vcpu, op.reg, size, 1);
295
+ emulated = kvmppc_handle_vmx_store(vcpu,
296
+ op.reg, size, 1);
321297 }
322298
323299 break;
....@@ -360,7 +336,7 @@
360336 io_size_each = op.element_size;
361337 }
362338
363
- emulated = kvmppc_handle_vsx_store(run, vcpu,
339
+ emulated = kvmppc_handle_vsx_store(vcpu,
364340 op.reg, io_size_each, 1);
365341 break;
366342 }