hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/arch/powerpc/kvm/book3s_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 SUSE Linux Products GmbH 2009
165 *
....@@ -36,7 +25,6 @@
3625 #define OP_31_XOP_MTSR 210
3726 #define OP_31_XOP_MTSRIN 242
3827 #define OP_31_XOP_TLBIEL 274
39
-#define OP_31_XOP_TLBIE 306
4028 /* Opcode is officially reserved, reuse it as sc 1 when sc 1 doesn't trap */
4129 #define OP_31_XOP_FAKE_SC1 308
4230 #define OP_31_XOP_SLBMTE 402
....@@ -48,6 +36,7 @@
4836 #define OP_31_XOP_SLBMFEV 851
4937 #define OP_31_XOP_EIOIO 854
5038 #define OP_31_XOP_SLBMFEE 915
39
+#define OP_31_XOP_SLBFEE 979
5140
5241 #define OP_31_XOP_TBEGIN 654
5342 #define OP_31_XOP_TABORT 910
....@@ -246,7 +235,7 @@
246235
247236 #endif
248237
249
-int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
238
+int kvmppc_core_emulate_op_pr(struct kvm_vcpu *vcpu,
250239 unsigned int inst, int *advance)
251240 {
252241 int emulated = EMULATE_DONE;
....@@ -382,13 +371,13 @@
382371 if (kvmppc_h_pr(vcpu, cmd) == EMULATE_DONE)
383372 break;
384373
385
- run->papr_hcall.nr = cmd;
374
+ vcpu->run->papr_hcall.nr = cmd;
386375 for (i = 0; i < 9; ++i) {
387376 ulong gpr = kvmppc_get_gpr(vcpu, 4 + i);
388
- run->papr_hcall.args[i] = gpr;
377
+ vcpu->run->papr_hcall.args[i] = gpr;
389378 }
390379
391
- run->exit_reason = KVM_EXIT_PAPR_HCALL;
380
+ vcpu->run->exit_reason = KVM_EXIT_PAPR_HCALL;
392381 vcpu->arch.hcall_needed = 1;
393382 emulated = EMULATE_EXIT_USER;
394383 break;
....@@ -416,6 +405,23 @@
416405 return EMULATE_FAIL;
417406
418407 vcpu->arch.mmu.slbia(vcpu);
408
+ break;
409
+ case OP_31_XOP_SLBFEE:
410
+ if (!(inst & 1) || !vcpu->arch.mmu.slbfee) {
411
+ return EMULATE_FAIL;
412
+ } else {
413
+ ulong b, t;
414
+ ulong cr = kvmppc_get_cr(vcpu) & ~CR0_MASK;
415
+
416
+ b = kvmppc_get_gpr(vcpu, rb);
417
+ if (!vcpu->arch.mmu.slbfee(vcpu, b, &t))
418
+ cr |= 2 << CR0_SHIFT;
419
+ kvmppc_set_gpr(vcpu, rt, t);
420
+ /* copy XER[SO] bit to CR0[SO] */
421
+ cr |= (vcpu->arch.regs.xer & 0x80000000) >>
422
+ (31 - CR0_SHIFT);
423
+ kvmppc_set_cr(vcpu, cr);
424
+ }
419425 break;
420426 case OP_31_XOP_SLBMFEE:
421427 if (!vcpu->arch.mmu.slbmfee) {
....@@ -623,7 +629,7 @@
623629 }
624630
625631 if (emulated == EMULATE_FAIL)
626
- emulated = kvmppc_emulate_paired_single(run, vcpu);
632
+ emulated = kvmppc_emulate_paired_single(vcpu);
627633
628634 return emulated;
629635 }