2019-06-04 08:11:33 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2009-01-03 22:23:10 +00:00
|
|
|
/*
|
2011-04-27 22:24:21 +00:00
|
|
|
* Copyright (C) 2008-2011 Freescale Semiconductor, Inc. All rights reserved.
|
2009-01-03 22:23:10 +00:00
|
|
|
*
|
|
|
|
* Author: Yu Liu, <yu.liu@freescale.com>
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This file is derived from arch/powerpc/kvm/44x_emulate.c,
|
|
|
|
* by Hollis Blanchard <hollisb@us.ibm.com>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <asm/kvm_ppc.h>
|
|
|
|
#include <asm/disassemble.h>
|
2012-02-15 13:28:48 +00:00
|
|
|
#include <asm/dbell.h>
|
2015-09-25 15:02:23 +00:00
|
|
|
#include <asm/reg_booke.h>
|
2009-01-03 22:23:10 +00:00
|
|
|
|
|
|
|
#include "booke.h"
|
2011-12-20 15:34:29 +00:00
|
|
|
#include "e500.h"
|
2009-01-03 22:23:10 +00:00
|
|
|
|
2014-04-17 11:25:33 +00:00
|
|
|
#define XOP_DCBTLS 166
|
2012-02-15 13:28:48 +00:00
|
|
|
#define XOP_MSGSND 206
|
|
|
|
#define XOP_MSGCLR 238
|
2015-09-25 15:02:23 +00:00
|
|
|
#define XOP_MFTMR 366
|
2009-01-03 22:23:10 +00:00
|
|
|
#define XOP_TLBIVAX 786
|
|
|
|
#define XOP_TLBSX 914
|
|
|
|
#define XOP_TLBRE 946
|
|
|
|
#define XOP_TLBWE 978
|
2011-12-20 15:34:39 +00:00
|
|
|
#define XOP_TLBILX 18
|
2013-07-04 06:57:45 +00:00
|
|
|
#define XOP_EHPRIV 270
|
2009-01-03 22:23:10 +00:00
|
|
|
|
2012-02-15 13:28:48 +00:00
|
|
|
#ifdef CONFIG_KVM_E500MC
|
|
|
|
static int dbell2prio(ulong param)
|
|
|
|
{
|
|
|
|
int msg = param & PPC_DBELL_TYPE_MASK;
|
|
|
|
int prio = -1;
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case PPC_DBELL_TYPE(PPC_DBELL):
|
|
|
|
prio = BOOKE_IRQPRIO_DBELL;
|
|
|
|
break;
|
|
|
|
case PPC_DBELL_TYPE(PPC_DBELL_CRIT):
|
|
|
|
prio = BOOKE_IRQPRIO_DBELL_CRIT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return prio;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int kvmppc_e500_emul_msgclr(struct kvm_vcpu *vcpu, int rb)
|
|
|
|
{
|
2018-05-07 06:20:07 +00:00
|
|
|
ulong param = vcpu->arch.regs.gpr[rb];
|
2012-02-15 13:28:48 +00:00
|
|
|
int prio = dbell2prio(param);
|
|
|
|
|
|
|
|
if (prio < 0)
|
|
|
|
return EMULATE_FAIL;
|
|
|
|
|
|
|
|
clear_bit(prio, &vcpu->arch.pending_exceptions);
|
|
|
|
return EMULATE_DONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int kvmppc_e500_emul_msgsnd(struct kvm_vcpu *vcpu, int rb)
|
|
|
|
{
|
2018-05-07 06:20:07 +00:00
|
|
|
ulong param = vcpu->arch.regs.gpr[rb];
|
2012-02-15 13:28:48 +00:00
|
|
|
int prio = dbell2prio(rb);
|
|
|
|
int pir = param & PPC_DBELL_PIR_MASK;
|
|
|
|
int i;
|
|
|
|
struct kvm_vcpu *cvcpu;
|
|
|
|
|
|
|
|
if (prio < 0)
|
|
|
|
return EMULATE_FAIL;
|
|
|
|
|
|
|
|
kvm_for_each_vcpu(i, cvcpu, vcpu->kvm) {
|
|
|
|
int cpir = cvcpu->arch.shared->pir;
|
|
|
|
if ((param & PPC_DBELL_MSG_BRDCAST) || (cpir == pir)) {
|
|
|
|
set_bit(prio, &cvcpu->arch.pending_exceptions);
|
|
|
|
kvm_vcpu_kick(cvcpu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return EMULATE_DONE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-07-04 06:57:45 +00:00
|
|
|
static int kvmppc_e500_emul_ehpriv(struct kvm_run *run, struct kvm_vcpu *vcpu,
|
|
|
|
unsigned int inst, int *advance)
|
|
|
|
{
|
|
|
|
int emulated = EMULATE_DONE;
|
|
|
|
|
|
|
|
switch (get_oc(inst)) {
|
|
|
|
case EHPRIV_OC_DEBUG:
|
|
|
|
run->exit_reason = KVM_EXIT_DEBUG;
|
2018-05-07 06:20:08 +00:00
|
|
|
run->debug.arch.address = vcpu->arch.regs.nip;
|
2013-07-04 06:57:45 +00:00
|
|
|
run->debug.arch.status = 0;
|
|
|
|
kvmppc_account_exit(vcpu, DEBUG_EXITS);
|
|
|
|
emulated = EMULATE_EXIT_USER;
|
|
|
|
*advance = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
emulated = EMULATE_FAIL;
|
|
|
|
}
|
|
|
|
return emulated;
|
|
|
|
}
|
|
|
|
|
2014-04-17 11:25:33 +00:00
|
|
|
static int kvmppc_e500_emul_dcbtls(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
|
|
|
|
|
|
|
|
/* Always fail to lock the cache */
|
|
|
|
vcpu_e500->l1csr0 |= L1CSR0_CUL;
|
|
|
|
return EMULATE_DONE;
|
|
|
|
}
|
|
|
|
|
2015-09-25 15:02:23 +00:00
|
|
|
static int kvmppc_e500_emul_mftmr(struct kvm_vcpu *vcpu, unsigned int inst,
|
|
|
|
int rt)
|
|
|
|
{
|
|
|
|
/* Expose one thread per vcpu */
|
|
|
|
if (get_tmrn(inst) == TMRN_TMCFG0) {
|
|
|
|
kvmppc_set_gpr(vcpu, rt,
|
|
|
|
1 | (1 << TMRN_TMCFG0_NATHRD_SHIFT));
|
|
|
|
return EMULATE_DONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EMULATE_FAIL;
|
|
|
|
}
|
|
|
|
|
2013-10-07 16:47:53 +00:00
|
|
|
int kvmppc_core_emulate_op_e500(struct kvm_run *run, struct kvm_vcpu *vcpu,
|
|
|
|
unsigned int inst, int *advance)
|
2009-01-03 22:23:10 +00:00
|
|
|
{
|
|
|
|
int emulated = EMULATE_DONE;
|
2012-05-04 12:01:33 +00:00
|
|
|
int ra = get_ra(inst);
|
|
|
|
int rb = get_rb(inst);
|
|
|
|
int rt = get_rt(inst);
|
2012-10-11 06:13:22 +00:00
|
|
|
gva_t ea;
|
2009-01-03 22:23:10 +00:00
|
|
|
|
|
|
|
switch (get_op(inst)) {
|
|
|
|
case 31:
|
|
|
|
switch (get_xop(inst)) {
|
|
|
|
|
2014-04-17 11:25:33 +00:00
|
|
|
case XOP_DCBTLS:
|
|
|
|
emulated = kvmppc_e500_emul_dcbtls(vcpu);
|
|
|
|
break;
|
|
|
|
|
2012-02-15 13:28:48 +00:00
|
|
|
#ifdef CONFIG_KVM_E500MC
|
|
|
|
case XOP_MSGSND:
|
2012-05-04 12:01:33 +00:00
|
|
|
emulated = kvmppc_e500_emul_msgsnd(vcpu, rb);
|
2012-02-15 13:28:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case XOP_MSGCLR:
|
2012-05-04 12:01:33 +00:00
|
|
|
emulated = kvmppc_e500_emul_msgclr(vcpu, rb);
|
2012-02-15 13:28:48 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2009-01-03 22:23:10 +00:00
|
|
|
case XOP_TLBRE:
|
|
|
|
emulated = kvmppc_e500_emul_tlbre(vcpu);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XOP_TLBWE:
|
|
|
|
emulated = kvmppc_e500_emul_tlbwe(vcpu);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XOP_TLBSX:
|
2012-10-11 06:13:22 +00:00
|
|
|
ea = kvmppc_get_ea_indexed(vcpu, ra, rb);
|
|
|
|
emulated = kvmppc_e500_emul_tlbsx(vcpu, ea);
|
2009-01-03 22:23:10 +00:00
|
|
|
break;
|
|
|
|
|
2012-10-11 06:13:22 +00:00
|
|
|
case XOP_TLBILX: {
|
|
|
|
int type = rt & 0x3;
|
|
|
|
ea = kvmppc_get_ea_indexed(vcpu, ra, rb);
|
|
|
|
emulated = kvmppc_e500_emul_tlbilx(vcpu, type, ea);
|
2011-12-20 15:34:39 +00:00
|
|
|
break;
|
2012-10-11 06:13:22 +00:00
|
|
|
}
|
2011-12-20 15:34:39 +00:00
|
|
|
|
2009-01-03 22:23:10 +00:00
|
|
|
case XOP_TLBIVAX:
|
2012-10-11 06:13:22 +00:00
|
|
|
ea = kvmppc_get_ea_indexed(vcpu, ra, rb);
|
|
|
|
emulated = kvmppc_e500_emul_tlbivax(vcpu, ea);
|
2009-01-03 22:23:10 +00:00
|
|
|
break;
|
|
|
|
|
2015-09-25 15:02:23 +00:00
|
|
|
case XOP_MFTMR:
|
|
|
|
emulated = kvmppc_e500_emul_mftmr(vcpu, inst, rt);
|
|
|
|
break;
|
|
|
|
|
2013-07-04 06:57:45 +00:00
|
|
|
case XOP_EHPRIV:
|
|
|
|
emulated = kvmppc_e500_emul_ehpriv(run, vcpu, inst,
|
|
|
|
advance);
|
|
|
|
break;
|
|
|
|
|
2009-01-03 22:23:10 +00:00
|
|
|
default:
|
|
|
|
emulated = EMULATE_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
emulated = EMULATE_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (emulated == EMULATE_FAIL)
|
|
|
|
emulated = kvmppc_booke_emulate_op(run, vcpu, inst, advance);
|
|
|
|
|
|
|
|
return emulated;
|
|
|
|
}
|
|
|
|
|
2013-10-07 16:47:53 +00:00
|
|
|
int kvmppc_core_emulate_mtspr_e500(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)
|
2009-01-03 22:23:10 +00:00
|
|
|
{
|
|
|
|
struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
|
|
|
|
int emulated = EMULATE_DONE;
|
|
|
|
|
|
|
|
switch (sprn) {
|
2011-12-20 15:34:47 +00:00
|
|
|
#ifndef CONFIG_KVM_BOOKE_HV
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_PID:
|
2011-04-27 22:24:21 +00:00
|
|
|
kvmppc_set_pid(vcpu, spr_val);
|
2009-01-03 22:23:10 +00:00
|
|
|
break;
|
|
|
|
case SPRN_PID1:
|
2011-06-14 23:35:14 +00:00
|
|
|
if (spr_val != 0)
|
|
|
|
return EMULATE_FAIL;
|
2012-05-04 12:55:12 +00:00
|
|
|
vcpu_e500->pid[1] = spr_val;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_PID2:
|
2011-06-14 23:35:14 +00:00
|
|
|
if (spr_val != 0)
|
|
|
|
return EMULATE_FAIL;
|
2012-05-04 12:55:12 +00:00
|
|
|
vcpu_e500->pid[2] = spr_val;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_MAS0:
|
2012-05-04 12:55:12 +00:00
|
|
|
vcpu->arch.shared->mas0 = spr_val;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_MAS1:
|
2012-05-04 12:55:12 +00:00
|
|
|
vcpu->arch.shared->mas1 = spr_val;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_MAS2:
|
2012-05-04 12:55:12 +00:00
|
|
|
vcpu->arch.shared->mas2 = spr_val;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_MAS3:
|
KVM: PPC: Paravirtualize SPRG4-7, ESR, PIR, MASn
This allows additional registers to be accessed by the guest
in PR-mode KVM without trapping.
SPRG4-7 are readable from userspace. On booke, KVM will sync
these registers when it enters the guest, so that accesses from
guest userspace will work. The guest kernel, OTOH, must consistently
use either the real registers or the shared area between exits. This
also applies to the already-paravirted SPRG3.
On non-booke, it's not clear to what extent SPRG4-7 are supported
(they're not architected for book3s, but exist on at least some classic
chips). They are copied in the get/set regs ioctls, but I do not see any
non-booke emulation. I also do not see any syncing with real registers
(in PR-mode) including the user-readable SPRG3. This patch should not
make that situation any worse.
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-11-09 00:23:30 +00:00
|
|
|
vcpu->arch.shared->mas7_3 &= ~(u64)0xffffffff;
|
|
|
|
vcpu->arch.shared->mas7_3 |= spr_val;
|
2011-08-18 20:25:21 +00:00
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_MAS4:
|
2012-05-04 12:55:12 +00:00
|
|
|
vcpu->arch.shared->mas4 = spr_val;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_MAS6:
|
2012-05-04 12:55:12 +00:00
|
|
|
vcpu->arch.shared->mas6 = spr_val;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_MAS7:
|
KVM: PPC: Paravirtualize SPRG4-7, ESR, PIR, MASn
This allows additional registers to be accessed by the guest
in PR-mode KVM without trapping.
SPRG4-7 are readable from userspace. On booke, KVM will sync
these registers when it enters the guest, so that accesses from
guest userspace will work. The guest kernel, OTOH, must consistently
use either the real registers or the shared area between exits. This
also applies to the already-paravirted SPRG3.
On non-booke, it's not clear to what extent SPRG4-7 are supported
(they're not architected for book3s, but exist on at least some classic
chips). They are copied in the get/set regs ioctls, but I do not see any
non-booke emulation. I also do not see any syncing with real registers
(in PR-mode) including the user-readable SPRG3. This patch should not
make that situation any worse.
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-11-09 00:23:30 +00:00
|
|
|
vcpu->arch.shared->mas7_3 &= (u64)0xffffffff;
|
|
|
|
vcpu->arch.shared->mas7_3 |= (u64)spr_val << 32;
|
2011-08-18 20:25:21 +00:00
|
|
|
break;
|
2011-12-20 15:34:47 +00:00
|
|
|
#endif
|
2010-01-22 10:50:29 +00:00
|
|
|
case SPRN_L1CSR0:
|
|
|
|
vcpu_e500->l1csr0 = spr_val;
|
|
|
|
vcpu_e500->l1csr0 &= ~(L1CSR0_DCFI | L1CSR0_CLFC);
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_L1CSR1:
|
2012-05-04 12:55:12 +00:00
|
|
|
vcpu_e500->l1csr1 = spr_val;
|
2014-04-17 10:53:13 +00:00
|
|
|
vcpu_e500->l1csr1 &= ~(L1CSR1_ICFI | L1CSR1_ICLFR);
|
2012-05-04 12:55:12 +00:00
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_HID0:
|
2012-05-04 12:55:12 +00:00
|
|
|
vcpu_e500->hid0 = spr_val;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_HID1:
|
2012-05-04 12:55:12 +00:00
|
|
|
vcpu_e500->hid1 = spr_val;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
|
2009-02-17 08:52:08 +00:00
|
|
|
case SPRN_MMUCSR0:
|
|
|
|
emulated = kvmppc_e500_emul_mt_mmucsr0(vcpu_e500,
|
2010-01-08 01:58:01 +00:00
|
|
|
spr_val);
|
2009-02-17 08:52:08 +00:00
|
|
|
break;
|
|
|
|
|
2014-07-04 08:17:28 +00:00
|
|
|
case SPRN_PWRMGTCR0:
|
|
|
|
/*
|
|
|
|
* Guest relies on host power management configurations
|
|
|
|
* Treat the request as a general store
|
|
|
|
*/
|
|
|
|
vcpu->arch.pwrmgtcr0 = spr_val;
|
|
|
|
break;
|
|
|
|
|
2018-12-12 14:03:03 +00:00
|
|
|
case SPRN_BUCSR:
|
|
|
|
/*
|
|
|
|
* If we are here, it means that we have already flushed the
|
|
|
|
* branch predictor, so just return to guest.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
2009-01-03 22:23:13 +00:00
|
|
|
/* extra exceptions */
|
2014-08-20 13:36:23 +00:00
|
|
|
#ifdef CONFIG_SPE_POSSIBLE
|
2009-01-03 22:23:13 +00:00
|
|
|
case SPRN_IVOR32:
|
2010-01-08 01:58:01 +00:00
|
|
|
vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_UNAVAIL] = spr_val;
|
2009-01-03 22:23:13 +00:00
|
|
|
break;
|
|
|
|
case SPRN_IVOR33:
|
2010-01-08 01:58:01 +00:00
|
|
|
vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_FP_DATA] = spr_val;
|
2009-01-03 22:23:13 +00:00
|
|
|
break;
|
|
|
|
case SPRN_IVOR34:
|
2010-01-08 01:58:01 +00:00
|
|
|
vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_FP_ROUND] = spr_val;
|
2009-01-03 22:23:13 +00:00
|
|
|
break;
|
2014-08-20 13:36:23 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_ALTIVEC
|
|
|
|
case SPRN_IVOR32:
|
|
|
|
vcpu->arch.ivor[BOOKE_IRQPRIO_ALTIVEC_UNAVAIL] = spr_val;
|
|
|
|
break;
|
|
|
|
case SPRN_IVOR33:
|
|
|
|
vcpu->arch.ivor[BOOKE_IRQPRIO_ALTIVEC_ASSIST] = spr_val;
|
|
|
|
break;
|
|
|
|
#endif
|
2009-01-03 22:23:13 +00:00
|
|
|
case SPRN_IVOR35:
|
2010-01-08 01:58:01 +00:00
|
|
|
vcpu->arch.ivor[BOOKE_IRQPRIO_PERFORMANCE_MONITOR] = spr_val;
|
2009-01-03 22:23:13 +00:00
|
|
|
break;
|
2011-12-20 15:34:47 +00:00
|
|
|
#ifdef CONFIG_KVM_BOOKE_HV
|
|
|
|
case SPRN_IVOR36:
|
|
|
|
vcpu->arch.ivor[BOOKE_IRQPRIO_DBELL] = spr_val;
|
|
|
|
break;
|
|
|
|
case SPRN_IVOR37:
|
|
|
|
vcpu->arch.ivor[BOOKE_IRQPRIO_DBELL_CRIT] = spr_val;
|
|
|
|
break;
|
|
|
|
#endif
|
2009-01-03 22:23:10 +00:00
|
|
|
default:
|
2012-05-04 12:55:12 +00:00
|
|
|
emulated = kvmppc_booke_emulate_mtspr(vcpu, sprn, spr_val);
|
2009-01-03 22:23:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return emulated;
|
|
|
|
}
|
|
|
|
|
2013-10-07 16:47:53 +00:00
|
|
|
int kvmppc_core_emulate_mfspr_e500(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val)
|
2009-01-03 22:23:10 +00:00
|
|
|
{
|
|
|
|
struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
|
|
|
|
int emulated = EMULATE_DONE;
|
|
|
|
|
|
|
|
switch (sprn) {
|
2011-12-20 15:34:47 +00:00
|
|
|
#ifndef CONFIG_KVM_BOOKE_HV
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_PID:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu_e500->pid[0];
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_PID1:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu_e500->pid[1];
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_PID2:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu_e500->pid[2];
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_MAS0:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu->arch.shared->mas0;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_MAS1:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu->arch.shared->mas1;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_MAS2:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu->arch.shared->mas2;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_MAS3:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = (u32)vcpu->arch.shared->mas7_3;
|
KVM: PPC: Paravirtualize SPRG4-7, ESR, PIR, MASn
This allows additional registers to be accessed by the guest
in PR-mode KVM without trapping.
SPRG4-7 are readable from userspace. On booke, KVM will sync
these registers when it enters the guest, so that accesses from
guest userspace will work. The guest kernel, OTOH, must consistently
use either the real registers or the shared area between exits. This
also applies to the already-paravirted SPRG3.
On non-booke, it's not clear to what extent SPRG4-7 are supported
(they're not architected for book3s, but exist on at least some classic
chips). They are copied in the get/set regs ioctls, but I do not see any
non-booke emulation. I also do not see any syncing with real registers
(in PR-mode) including the user-readable SPRG3. This patch should not
make that situation any worse.
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-11-09 00:23:30 +00:00
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_MAS4:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu->arch.shared->mas4;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_MAS6:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu->arch.shared->mas6;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_MAS7:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu->arch.shared->mas7_3 >> 32;
|
KVM: PPC: Paravirtualize SPRG4-7, ESR, PIR, MASn
This allows additional registers to be accessed by the guest
in PR-mode KVM without trapping.
SPRG4-7 are readable from userspace. On booke, KVM will sync
these registers when it enters the guest, so that accesses from
guest userspace will work. The guest kernel, OTOH, must consistently
use either the real registers or the shared area between exits. This
also applies to the already-paravirted SPRG3.
On non-booke, it's not clear to what extent SPRG4-7 are supported
(they're not architected for book3s, but exist on at least some classic
chips). They are copied in the get/set regs ioctls, but I do not see any
non-booke emulation. I also do not see any syncing with real registers
(in PR-mode) including the user-readable SPRG3. This patch should not
make that situation any worse.
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-11-09 00:23:30 +00:00
|
|
|
break;
|
2011-12-20 15:34:47 +00:00
|
|
|
#endif
|
2012-05-20 23:21:23 +00:00
|
|
|
case SPRN_DECAR:
|
|
|
|
*spr_val = vcpu->arch.decar;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_TLB0CFG:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu->arch.tlbcfg[0];
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_TLB1CFG:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu->arch.tlbcfg[1];
|
|
|
|
break;
|
2013-04-11 00:03:10 +00:00
|
|
|
case SPRN_TLB0PS:
|
|
|
|
if (!has_feature(vcpu, VCPU_FTR_MMU_V2))
|
|
|
|
return EMULATE_FAIL;
|
|
|
|
*spr_val = vcpu->arch.tlbps[0];
|
|
|
|
break;
|
|
|
|
case SPRN_TLB1PS:
|
|
|
|
if (!has_feature(vcpu, VCPU_FTR_MMU_V2))
|
|
|
|
return EMULATE_FAIL;
|
|
|
|
*spr_val = vcpu->arch.tlbps[1];
|
|
|
|
break;
|
2010-01-22 10:50:29 +00:00
|
|
|
case SPRN_L1CSR0:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu_e500->l1csr0;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_L1CSR1:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu_e500->l1csr1;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_HID0:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu_e500->hid0;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
case SPRN_HID1:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu_e500->hid1;
|
|
|
|
break;
|
2011-03-29 21:49:10 +00:00
|
|
|
case SPRN_SVR:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu_e500->svr;
|
|
|
|
break;
|
2009-01-03 22:23:10 +00:00
|
|
|
|
2009-02-17 08:52:08 +00:00
|
|
|
case SPRN_MMUCSR0:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = 0;
|
|
|
|
break;
|
2009-02-17 08:52:08 +00:00
|
|
|
|
2009-06-05 06:54:31 +00:00
|
|
|
case SPRN_MMUCFG:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu->arch.mmucfg;
|
|
|
|
break;
|
2013-04-11 00:03:11 +00:00
|
|
|
case SPRN_EPTCFG:
|
|
|
|
if (!has_feature(vcpu, VCPU_FTR_MMU_V2))
|
|
|
|
return EMULATE_FAIL;
|
|
|
|
/*
|
|
|
|
* Legacy Linux guests access EPTCFG register even if the E.PT
|
|
|
|
* category is disabled in the VM. Give them a chance to live.
|
|
|
|
*/
|
|
|
|
*spr_val = vcpu->arch.eptcfg;
|
|
|
|
break;
|
2009-06-05 06:54:31 +00:00
|
|
|
|
2014-07-04 08:17:28 +00:00
|
|
|
case SPRN_PWRMGTCR0:
|
|
|
|
*spr_val = vcpu->arch.pwrmgtcr0;
|
|
|
|
break;
|
|
|
|
|
2009-01-03 22:23:13 +00:00
|
|
|
/* extra exceptions */
|
2014-08-20 13:36:23 +00:00
|
|
|
#ifdef CONFIG_SPE_POSSIBLE
|
2009-01-03 22:23:13 +00:00
|
|
|
case SPRN_IVOR32:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_UNAVAIL];
|
2009-01-03 22:23:13 +00:00
|
|
|
break;
|
|
|
|
case SPRN_IVOR33:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_FP_DATA];
|
2009-01-03 22:23:13 +00:00
|
|
|
break;
|
|
|
|
case SPRN_IVOR34:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_FP_ROUND];
|
2009-01-03 22:23:13 +00:00
|
|
|
break;
|
2014-08-20 13:36:23 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_ALTIVEC
|
|
|
|
case SPRN_IVOR32:
|
|
|
|
*spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_ALTIVEC_UNAVAIL];
|
|
|
|
break;
|
|
|
|
case SPRN_IVOR33:
|
|
|
|
*spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_ALTIVEC_ASSIST];
|
|
|
|
break;
|
|
|
|
#endif
|
2009-01-03 22:23:13 +00:00
|
|
|
case SPRN_IVOR35:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_PERFORMANCE_MONITOR];
|
2009-01-03 22:23:13 +00:00
|
|
|
break;
|
2011-12-20 15:34:47 +00:00
|
|
|
#ifdef CONFIG_KVM_BOOKE_HV
|
|
|
|
case SPRN_IVOR36:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_DBELL];
|
2011-12-20 15:34:47 +00:00
|
|
|
break;
|
|
|
|
case SPRN_IVOR37:
|
2012-05-04 12:55:12 +00:00
|
|
|
*spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_DBELL_CRIT];
|
2011-12-20 15:34:47 +00:00
|
|
|
break;
|
|
|
|
#endif
|
2009-01-03 22:23:10 +00:00
|
|
|
default:
|
2012-05-04 12:55:12 +00:00
|
|
|
emulated = kvmppc_booke_emulate_mfspr(vcpu, sprn, spr_val);
|
2009-01-03 22:23:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return emulated;
|
|
|
|
}
|
|
|
|
|