[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/4] hw/i386/pc: hold the BQL when calling cpu_g
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 1/4] hw/i386/pc: hold the BQL when calling cpu_get_ticks |
Date: |
Tue, 14 Aug 2018 08:37:49 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
On 14/08/2018 03:37, Emilio G. Cota wrote:
> Signed-off-by: Emilio G. Cota <address@hidden>
> ---
> hw/i386/pc.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 83a444472b..7371cd9960 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -158,7 +158,18 @@ static uint64_t ioportF0_read(void *opaque, hwaddr addr,
> unsigned size)
> /* TSC handling */
> uint64_t cpu_get_tsc(CPUX86State *env)
> {
> - return cpu_get_ticks();
> + uint64_t ret;
> + bool locked;
> +
> + locked = qemu_mutex_iothread_locked();
> + if (!locked) {
> + qemu_mutex_lock_iothread();
> + }
> + ret = cpu_get_ticks();
> + if (!locked) {
> + qemu_mutex_unlock_iothread();
> + }
> + return ret;
> }
>
> /* IRQ handling */
>
We could use a spinlock for the rare case of timers_state.cpu_ticks_prev
> ticks (or even, on 64-bit, a seqlock+spinlock). I'll give it a shot.
Paolo