aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2014-04-17 07:25:33 -0400
committerAlexander Graf <agraf@suse.de>2014-05-30 08:26:17 -0400
commit8f20a3ab27342171462781cef4637c18d3dbc5f8 (patch)
tree9f7320513c255bd7e9bd5f0e707a26d1b2453fcd /arch
parent07fec1c2e75ef2f55d7a211414b0d63e185e84f0 (diff)
KVM: PPC: E500: Add dcbtls emulation
The dcbtls instruction is able to lock data inside the L1 cache. We don't want to give the guest actual access to hardware cache locks, as that could influence other VMs on the same system. But we can tell the guest that its locking attempt failed. By implementing the instruction we at least don't give the guest a program exception which it definitely does not expect. Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/include/asm/reg_booke.h1
-rw-r--r--arch/powerpc/kvm/e500_emulate.c14
2 files changed, 15 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/reg_booke.h b/arch/powerpc/include/asm/reg_booke.h
index 163c3b05a76e..464f1089b532 100644
--- a/arch/powerpc/include/asm/reg_booke.h
+++ b/arch/powerpc/include/asm/reg_booke.h
@@ -583,6 +583,7 @@
583 583
584/* Bit definitions for L1CSR0. */ 584/* Bit definitions for L1CSR0. */
585#define L1CSR0_CPE 0x00010000 /* Data Cache Parity Enable */ 585#define L1CSR0_CPE 0x00010000 /* Data Cache Parity Enable */
586#define L1CSR0_CUL 0x00000400 /* Data Cache Unable to Lock */
586#define L1CSR0_CLFC 0x00000100 /* Cache Lock Bits Flash Clear */ 587#define L1CSR0_CLFC 0x00000100 /* Cache Lock Bits Flash Clear */
587#define L1CSR0_DCFI 0x00000002 /* Data Cache Flash Invalidate */ 588#define L1CSR0_DCFI 0x00000002 /* Data Cache Flash Invalidate */
588#define L1CSR0_CFI 0x00000002 /* Cache Flash Invalidate */ 589#define L1CSR0_CFI 0x00000002 /* Cache Flash Invalidate */
diff --git a/arch/powerpc/kvm/e500_emulate.c b/arch/powerpc/kvm/e500_emulate.c
index 95d886f461fb..002d51764143 100644
--- a/arch/powerpc/kvm/e500_emulate.c
+++ b/arch/powerpc/kvm/e500_emulate.c
@@ -19,6 +19,7 @@
19#include "booke.h" 19#include "booke.h"
20#include "e500.h" 20#include "e500.h"
21 21
22#define XOP_DCBTLS 166
22#define XOP_MSGSND 206 23#define XOP_MSGSND 206
23#define XOP_MSGCLR 238 24#define XOP_MSGCLR 238
24#define XOP_TLBIVAX 786 25#define XOP_TLBIVAX 786
@@ -103,6 +104,15 @@ static int kvmppc_e500_emul_ehpriv(struct kvm_run *run, struct kvm_vcpu *vcpu,
103 return emulated; 104 return emulated;
104} 105}
105 106
107static int kvmppc_e500_emul_dcbtls(struct kvm_vcpu *vcpu)
108{
109 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
110
111 /* Always fail to lock the cache */
112 vcpu_e500->l1csr0 |= L1CSR0_CUL;
113 return EMULATE_DONE;
114}
115
106int kvmppc_core_emulate_op_e500(struct kvm_run *run, struct kvm_vcpu *vcpu, 116int kvmppc_core_emulate_op_e500(struct kvm_run *run, struct kvm_vcpu *vcpu,
107 unsigned int inst, int *advance) 117 unsigned int inst, int *advance)
108{ 118{
@@ -116,6 +126,10 @@ int kvmppc_core_emulate_op_e500(struct kvm_run *run, struct kvm_vcpu *vcpu,
116 case 31: 126 case 31:
117 switch (get_xop(inst)) { 127 switch (get_xop(inst)) {
118 128
129 case XOP_DCBTLS:
130 emulated = kvmppc_e500_emul_dcbtls(vcpu);
131 break;
132
119#ifdef CONFIG_KVM_E500MC 133#ifdef CONFIG_KVM_E500MC
120 case XOP_MSGSND: 134 case XOP_MSGSND:
121 emulated = kvmppc_e500_emul_msgsnd(vcpu, rb); 135 emulated = kvmppc_e500_emul_msgsnd(vcpu, rb);