forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/arch/powerpc/kvm/emulate.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.
....@@ -61,11 +50,10 @@
6150
6251 dec_time = vcpu->arch.dec;
6352 /*
64
- * Guest timebase ticks at the same frequency as host decrementer.
65
- * So use the host decrementer calculations for decrementer emulation.
53
+ * Guest timebase ticks at the same frequency as host timebase.
54
+ * So use the host timebase calculations for decrementer emulation.
6655 */
67
- dec_time = dec_time << decrementer_clockevent.shift;
68
- do_div(dec_time, decrementer_clockevent.mult);
56
+ dec_time = tb_to_ns(dec_time);
6957 dec_nsec = do_div(dec_time, NSEC_PER_SEC);
7058 hrtimer_start(&vcpu->arch.dec_timer,
7159 ktime_set(dec_time, dec_nsec), HRTIMER_MODE_REL);
....@@ -203,7 +191,7 @@
203191
204192 /* XXX Should probably auto-generate instruction decoding for a particular core
205193 * from opcode tables in the future. */
206
-int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
194
+int kvmppc_emulate_instruction(struct kvm_vcpu *vcpu)
207195 {
208196 u32 inst;
209197 int rs, rt, sprn;
....@@ -282,8 +270,9 @@
282270 * these are illegal instructions.
283271 */
284272 if (inst == KVMPPC_INST_SW_BREAKPOINT) {
285
- run->exit_reason = KVM_EXIT_DEBUG;
286
- run->debug.arch.address = kvmppc_get_pc(vcpu);
273
+ vcpu->run->exit_reason = KVM_EXIT_DEBUG;
274
+ vcpu->run->debug.arch.status = 0;
275
+ vcpu->run->debug.arch.address = kvmppc_get_pc(vcpu);
287276 emulated = EMULATE_EXIT_USER;
288277 advance = 0;
289278 } else
....@@ -296,7 +285,7 @@
296285 }
297286
298287 if (emulated == EMULATE_FAIL) {
299
- emulated = vcpu->kvm->arch.kvm_ops->emulate_op(run, vcpu, inst,
288
+ emulated = vcpu->kvm->arch.kvm_ops->emulate_op(vcpu, inst,
300289 &advance);
301290 if (emulated == EMULATE_AGAIN) {
302291 advance = 0;