Skip to content

Commit 2daab50

Browse files
Tudor Laurentiupaulusmack
authored andcommitted
KVM: PPC: e500: Emulate TMCFG0 TMRN register
Emulate TMCFG0 TMRN register exposing one HW thread per vcpu. Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com> [Laurentiu.Tudor@freescale.com: rebased on latest kernel, use define instead of hardcoded value, moved code in own function] Signed-off-by: Laurentiu Tudor <Laurentiu.Tudor@freescale.com> Acked-by: Scott Wood <scotttwood@freescale.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
1 parent d4cd4f9 commit 2daab50

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

arch/powerpc/include/asm/disassemble.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ static inline unsigned int get_dcrn(u32 inst)
4242
return ((inst >> 16) & 0x1f) | ((inst >> 6) & 0x3e0);
4343
}
4444

45+
static inline unsigned int get_tmrn(u32 inst)
46+
{
47+
return ((inst >> 16) & 0x1f) | ((inst >> 6) & 0x3e0);
48+
}
49+
4550
static inline unsigned int get_rt(u32 inst)
4651
{
4752
return (inst >> 21) & 0x1f;

arch/powerpc/kvm/e500_emulate.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
#include <asm/kvm_ppc.h>
1616
#include <asm/disassemble.h>
1717
#include <asm/dbell.h>
18+
#include <asm/reg_booke.h>
1819

1920
#include "booke.h"
2021
#include "e500.h"
2122

2223
#define XOP_DCBTLS 166
2324
#define XOP_MSGSND 206
2425
#define XOP_MSGCLR 238
26+
#define XOP_MFTMR 366
2527
#define XOP_TLBIVAX 786
2628
#define XOP_TLBSX 914
2729
#define XOP_TLBRE 946
@@ -113,6 +115,19 @@ static int kvmppc_e500_emul_dcbtls(struct kvm_vcpu *vcpu)
113115
return EMULATE_DONE;
114116
}
115117

118+
static int kvmppc_e500_emul_mftmr(struct kvm_vcpu *vcpu, unsigned int inst,
119+
int rt)
120+
{
121+
/* Expose one thread per vcpu */
122+
if (get_tmrn(inst) == TMRN_TMCFG0) {
123+
kvmppc_set_gpr(vcpu, rt,
124+
1 | (1 << TMRN_TMCFG0_NATHRD_SHIFT));
125+
return EMULATE_DONE;
126+
}
127+
128+
return EMULATE_FAIL;
129+
}
130+
116131
int kvmppc_core_emulate_op_e500(struct kvm_run *run, struct kvm_vcpu *vcpu,
117132
unsigned int inst, int *advance)
118133
{
@@ -165,6 +180,10 @@ int kvmppc_core_emulate_op_e500(struct kvm_run *run, struct kvm_vcpu *vcpu,
165180
emulated = kvmppc_e500_emul_tlbivax(vcpu, ea);
166181
break;
167182

183+
case XOP_MFTMR:
184+
emulated = kvmppc_e500_emul_mftmr(vcpu, inst, rt);
185+
break;
186+
168187
case XOP_EHPRIV:
169188
emulated = kvmppc_e500_emul_ehpriv(run, vcpu, inst,
170189
advance);

0 commit comments

Comments
 (0)