* [Qemu-devel] How Qemu timer interrupts code emulation?
@ 2015-05-22 15:36 Jun Koi
2015-05-22 16:13 ` Peter Maydell
0 siblings, 1 reply; 4+ messages in thread
From: Jun Koi @ 2015-05-22 15:36 UTC (permalink / raw)
To: qemu-devel@nongnu.org
[-- Attachment #1: Type: text/plain, Size: 481 bytes --]
Hi,
I am wondering how the timer interrupt works in softmmu TCG mode (on X86)?
In general, we would have timer & code execution run in parallel, then once
in a while, the timer would interrupt the code execution to switch it out
to execute the timer interrupt.
I looked at the code, but still confused on how the timer inform the code
emulation, and how the code emulation get notified on interrupt event.
Any pointer, please?
(I am looking at X86 code)
Thanks so much,
Jun
[-- Attachment #2: Type: text/html, Size: 630 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] How Qemu timer interrupts code emulation?
2015-05-22 15:36 [Qemu-devel] How Qemu timer interrupts code emulation? Jun Koi
@ 2015-05-22 16:13 ` Peter Maydell
2015-05-22 16:26 ` Nguyen Anh Quynh
0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2015-05-22 16:13 UTC (permalink / raw)
To: Jun Koi; +Cc: qemu-devel@nongnu.org
On 22 May 2015 at 16:36, Jun Koi <junkoi2004@gmail.com> wrote:
> In general, we would have timer & code execution run in parallel,
No code has to actually run when there's an active timer;
the event loop thread mostly sits blocked waiting for
something interesting to happen (io or a timer firing).
When it does then the event loop thread will call the
generic timer code, which will call the callback function
for that timer. Typically this is inside the device model
for whatever timer the hardware you're modelling is. It
will then (assuming it really wants to create a simulated
interrupt) call qemu_irq_set() to set its outbound IRQ
line. This will then end up calling into the emulated
interrupt controller and eventually (if the irq is not
masked by the interrupt controller) into the emulated
CPU, which calls cpu_interrupt(). In TCG that ends up
calling tcg_handle_interrupt(), which sets cpu->tcg_exit_req.
Every block of translated code has an initial part
(written by gen_tb_start()) which checks this flag, and
returns to the TCG main loop (in cpu-exec.c) if it is set.
Every time round the TCG main loop we check if there are
any pending interrupts, and if so we call the appropriate
CPU function to emulate the "take an interrupt" behaviour
of the target CPU.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] How Qemu timer interrupts code emulation?
2015-05-22 16:13 ` Peter Maydell
@ 2015-05-22 16:26 ` Nguyen Anh Quynh
2015-05-22 23:03 ` Bastian Koppelmann
0 siblings, 1 reply; 4+ messages in thread
From: Nguyen Anh Quynh @ 2015-05-22 16:26 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel@nongnu.org
[-- Attachment #1: Type: text/plain, Size: 1540 bytes --]
On Sat, May 23, 2015 at 12:13 AM, Peter Maydell <peter.maydell@linaro.org>
wrote:
> On 22 May 2015 at 16:36, Jun Koi <junkoi2004@gmail.com> wrote:
> > In general, we would have timer & code execution run in parallel,
>
> No code has to actually run when there's an active timer;
> the event loop thread mostly sits blocked waiting for
> something interesting to happen (io or a timer firing).
> When it does then the event loop thread will call the
> generic timer code, which will call the callback function
> for that timer. Typically this is inside the device model
> for whatever timer the hardware you're modelling is. It
> will then (assuming it really wants to create a simulated
> interrupt) call qemu_irq_set()
What is the exact name of this function? There is no such qemu_irq_set()
in the latest 2.3.0 source.
Thanks!
Jun
to set its outbound IRQ
> line. This will then end up calling into the emulated
> interrupt controller and eventually (if the irq is not
> masked by the interrupt controller) into the emulated
> CPU, which calls cpu_interrupt(). In TCG that ends up
> calling tcg_handle_interrupt(), which sets cpu->tcg_exit_req.
> Every block of translated code has an initial part
> (written by gen_tb_start()) which checks this flag, and
> returns to the TCG main loop (in cpu-exec.c) if it is set.
> Every time round the TCG main loop we check if there are
> any pending interrupts, and if so we call the appropriate
> CPU function to emulate the "take an interrupt" behaviour
> of the target CPU.
>
> -- PMM
>
>
[-- Attachment #2: Type: text/html, Size: 2260 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] How Qemu timer interrupts code emulation?
2015-05-22 16:26 ` Nguyen Anh Quynh
@ 2015-05-22 23:03 ` Bastian Koppelmann
0 siblings, 0 replies; 4+ messages in thread
From: Bastian Koppelmann @ 2015-05-22 23:03 UTC (permalink / raw)
To: Nguyen Anh Quynh, Peter Maydell; +Cc: qemu-devel@nongnu.org
[-- Attachment #1: Type: text/plain, Size: 1101 bytes --]
On 05/22/2015 06:26 PM, Nguyen Anh Quynh wrote:
>
>
> On Sat, May 23, 2015 at 12:13 AM, Peter Maydell
> <peter.maydell@linaro.org <mailto:peter.maydell@linaro.org>> wrote:
>
> On 22 May 2015 at 16:36, Jun Koi <junkoi2004@gmail.com
> <mailto:junkoi2004@gmail.com>> wrote:
> > In general, we would have timer & code execution run in parallel,
>
> No code has to actually run when there's an active timer;
> the event loop thread mostly sits blocked waiting for
> something interesting to happen (io or a timer firing).
> When it does then the event loop thread will call the
> generic timer code, which will call the callback function
> for that timer. Typically this is inside the device model
> for whatever timer the hardware you're modelling is. It
> will then (assuming it really wants to create a simulated
> interrupt) call qemu_irq_set()
>
>
> What is the exact name of this function? There is no such qemu_irq_set()
> in the latest 2.3.0 source.
>
Peter just got it switched around, it's qemu_set_irq() in include/hw/irq.h.
Cheers,
Bastian
[-- Attachment #2: Type: text/html, Size: 2359 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-05-22 23:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-22 15:36 [Qemu-devel] How Qemu timer interrupts code emulation? Jun Koi
2015-05-22 16:13 ` Peter Maydell
2015-05-22 16:26 ` Nguyen Anh Quynh
2015-05-22 23:03 ` Bastian Koppelmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).