qemu_clock_get_ns does not take into account icount_time_shift
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
QEMU |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Hello,
If you check the qemu/util/
597: int64_t qemu_clock_
598: {
....
602: switch (type) {
....
606: case QEMU_CLOCK_VIRTUAL:
607: if (use_icount) {
608: return cpu_get_icount();
Now on line 606, in case we requested QEMU_CLOCK_VIRTUAL, and we are using icount, the value of cpu_get_icount(); will be returned.
However if I understand correctly, in order to convert icount to ns, you must use take into account the icount shift -- as defined in the documentation: "The virtual cpu will execute one instruction every 2^N ns of virtual time.".
Therefor, the correct value to return would be cpu_icount_
296: int64_t cpu_icount_
297: {
298: return icount << icount_time_shift;
299: }
Best Regards,
Humberto "SilverOne" Carvalho
Changed in qemu: | |
status: | Incomplete → Invalid |
Actually implementing this fix causes a linux boot to crash. So there may be something more to this. I will investigate more.
[ 892.294463] BUG: soft lockup - CPU#0 stuck for 347s! [swapper/0:1] emit+0x2c8/ 0x650 unlock+ 0x234/0x4dc 0x20/0x24) 0x9c/0xb0) 0x30/0x34) timer_fn+ 0x18c/0x1e4) hrtimer+ 0x88/0x2a8) run_queues+ 0xc0/0x1a4) run_queues) from [<c0076ef0>] (update_ process_ times+0x3c/ 0x70) process_ times) from [<c00d5ed4>] (tick_periodic+ 0x4c/0xcc) periodic+ 0x94/0x98) periodic) from [<c04ad8fc>] (arch_timer_ handler_ virt+0x38/ 0x40) handler_ virt) from [<c00c3b48>] (handle_ percpu_ devid_irq+ 0x80/0x194) percpu_ devid_irq) from [<c00bf738>] (generic_ handle_ irq+0x3c/ 0x4c) handle_ irq) from [<c0023ba4>] (handle_ IRQ+0x50/ 0xa0) irq+0x3c/ 0x70) svc+0x40/ 0x54) emit+0x2c8/ 0x650) select+ 0x12c/0x170) select) from [<c08da7d4>] (clocksource_ done_booting+ 0x38/0x4c)
[ 892.490416] Modules linked in:
[ 892.635725]
[ 892.790816] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.16.0-6-armmp-lpae #1 Debian 3.16.56-1+deb8u1
[ 893.098786] task: ee059640 ti: ee05a000 task.ti: ee05a000
[ 893.322395] PC is at vprintk_
[ 893.525852] LR is at console_
[ 893.749395] pc : [<c00bdd18>] lr : [<c00bd7a8>] psr: 60000153
[ 893.749395] sp : ee05bdc8 ip : ee05bd70 fp : ee05be2c
[ 894.117789] r10: 00000001 r9 : 00000000 r8 : 00000006
[ 894.329454] r7 : 00000000 r6 : 00000028 r5 : c0a3dd98 r4 : c0a3dd98
[ 894.571266] r3 : c09b44cc r2 : 60000153 r1 : 60000153 r0 : c0a3dd98
[ 894.807621] Flags: nZCv IRQs on FIQs off Mode SVC_32 ISA ARM Segment kernel
[ 895.089213] Control: 30c7387d Table: 40003000 DAC: fffffffd
[ 895.329468] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.16.0-6-armmp-lpae #1 Debian 3.16.56-1+deb8u1
[ 895.720505] [<c002cf60>] (unwind_backtrace) from [<c002764c>] (show_stack+
[ 896.065798] [<c002764c>] (show_stack) from [<c05ed770>] (dump_stack+
[ 896.393691] [<c05ed770>] (dump_stack) from [<c0024370>] (show_regs+
[ 896.713637] [<c0024370>] (show_regs) from [<c0103084>] (watchdog_
[ 897.062977] [<c0103084>] (watchdog_timer_fn) from [<c008d9c0>] (__run_
[ 897.412317] [<c008d9c0>] (__run_hrtimer) from [<c008ecf0>] (hrtimer_
[ 897.785790] [<c008ecf0>] (hrtimer_
[ 898.169815] [<c0076ef0>] (update_
[ 898.532622] [<c00d5ed4>] (tick_periodic) from [<c00d61b0>] (tick_handle_
[ 898.895806] [<c00d61b0>] (tick_handle_
[ 899.292479] [<c04ad8fc>] (arch_timer_
[ 899.702210] [<c00c3b48>] (handle_
[ 900.082647] [<c00bf738>] (generic_
[ 900.427431] [<c0023ba4>] (handle_IRQ) from [<c0008948>] (gic_handle_
[ 900.767678] [<c0008948>] (gic_handle_irq) from [<c05f4180>] (__irq_
[ 901.037948] Exception stack(0xee05bd80 to 0xee05bdc8)
[ 901.317607] bd80: c0a3dd98 60000153 60000153 c09b44cc c0a3dd98 c0a3dd98 00000028 00000000
[ 901.677252] bda0: 00000006 00000000 00000001 ee05be2c ee05bd70 ee05bdc8 c00bd7a8 c00bdd18
[ 901.970690] bdc0: 60000153 ffffffff
[ 902.218760] [<c05f4180>] (__irq_svc) from [<c00bdd18>] (vprintk_
[ 902.571360] [<c00bdd18>] (vprintk_emit) from [<c05eaeb8>] (printk+0x44/0x4c)
[ 902.916079] [<c05eaeb8>] (printk) from [<c00d14c0>] (__clocksource_
[ 903.290503] [<c00d14c0>] (__clocksource_
[ 903.671545] [<c...