|
@@ -23,6 +23,7 @@
|
|
|
#include <linux/types.h>
|
|
|
#include <linux/string.h>
|
|
|
#include <linux/kvm_host.h>
|
|
|
+#include <linux/clockchips.h>
|
|
|
|
|
|
#include <asm/reg.h>
|
|
|
#include <asm/time.h>
|
|
@@ -104,8 +105,12 @@ void kvmppc_emulate_dec(struct kvm_vcpu *vcpu)
|
|
|
*/
|
|
|
|
|
|
dec_time = vcpu->arch.dec;
|
|
|
- dec_time *= 1000;
|
|
|
- do_div(dec_time, tb_ticks_per_usec);
|
|
|
+ /*
|
|
|
+ * Guest timebase ticks at the same frequency as host decrementer.
|
|
|
+ * So use the host decrementer calculations for decrementer emulation.
|
|
|
+ */
|
|
|
+ dec_time = dec_time << decrementer_clockevent.shift;
|
|
|
+ do_div(dec_time, decrementer_clockevent.mult);
|
|
|
dec_nsec = do_div(dec_time, NSEC_PER_SEC);
|
|
|
hrtimer_start(&vcpu->arch.dec_timer,
|
|
|
ktime_set(dec_time, dec_nsec), HRTIMER_MODE_REL);
|