Add mfdec emulation
Subsystems (2)
PATCH 15/27 Add mfdec emulation
We support setting the DEC to a certain value right now. Doing that basically triggers the CPU local timer.
But there's also an mfdec command that enabled the OS to read the decrementor.
This is required at least by all desktop and server PowerPC Linux kernels. It can't really hurt to allow embedded ones to do it as well though.
--- arch/powerpc/kvm/emulate.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-)
arch/powerpc/kvm/emulate.c +12 -1
@@ -66,12 +66,14 @@void kvmppc_emulate_dec (struct kvm_vcpu *vcpu) { +unsigned long nr_jiffies; +if (vcpu->arch.tcr &TCR_DIE ) {/* The decrementer ticks at the same rate as the timebase, so * that's how we convert the guest DEC value to the number of * host ticks. */ -unsigned long nr_jiffies; + vcpu->arch.dec_jiffies =mftb (); nr_jiffies = vcpu->arch.dec / tb_ticks_per_jiffy;mod_timer (&vcpu->arch.dec_timer,get_jiffies_64 () + nr_jiffies);
@@ -211,6 +213,15 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)/* Note: SPRG4-7 are user-readable, so we don't get * a trap. */ +case SPRN_DEC : + { +u64 jd =mftb () - vcpu->arch.dec_jiffies; + vcpu->arch.gpr[rt] = vcpu->arch.dec - jd; +#ifdef DEBUG_EMUL +printk (KERN_INFO "mfDEC: %x - %llx = %lx\n" , vcpu->arch.dec, jd, vcpu->arch.gpr[rt]); +#endif +break ; + }default : emulated =kvmppc_core_emulate_mfspr (vcpu, sprn, rt);if (emulated =EMULATE_FAIL ) {
Signature · 1 line
1.6.0.2
Quoted 39 lines · Alexander Graf
We support setting the DEC to a certain value right now. Doing that basically triggers the CPU local timer.
But there's also an mfdec command that enabled the OS to read the decrementor.
This is required at least by all desktop and server PowerPC Linux kernels. It can't really hurt to allow embedded ones to do it as well though.
Signed-off-by Alexander Graf <[email protected]>--- arch/powerpc/kvm/emulate.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-)arch/powerpc/kvm/emulate.c +5
-1@@ -66,12 +66,14 @@void kvmppc_emulate_dec (struct kvm_vcpu *vcpu) { +unsigned long nr_jiffies; +if (vcpu->arch.tcr &TCR_DIE ) {/* The decrementer ticks at the same rate as the timebase, so * that's how we convert the guest DEC value to the number of * host ticks. */ -unsigned long nr_jiffies; + vcpu->arch.dec_jiffies =mftb (); nr_jiffies = vcpu->arch.dec / tb_ticks_per_jiffy;mod_timer (&vcpu->arch.dec_timer,get_jiffies_64 () + nr_jiffies);@@ -211,6 +213,15 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)/* Note: SPRG4-7 are user-readable, so we don't get * a trap. */ +case SPRN_DEC : + {
arch/powerpc/kvm/emulate.c int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu) · line 227
Quoted 10 lines
arch/powerpc/kvm/emulate.c +7
-0+u64 jd =mftb () - vcpu->arch.dec_jiffies; + vcpu->arch.gpr[rt] = vcpu->arch.dec - jd; +#ifdef DEBUG_EMUL +printk (KERN_INFO "mfDEC: %x - %llx = %lx\n" , vcpu->arch.dec, jd, vcpu->arch.gpr[rt]); +#endif +break ; + }default : emulated =kvmppc_core_emulate_mfspr (vcpu, sprn, rt);if (emulated =EMULATE_FAIL ) {
mftb() doesn't exist for ppc32, so we'll need to use the get_tb() wrapper instead.
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center