void accel_ioctl_begin(void)
{
- if (likely(qemu_mutex_iothread_locked())) {
+ if (likely(bql_locked())) {
return;
}
void accel_ioctl_end(void)
{
- if (likely(qemu_mutex_iothread_locked())) {
+ if (likely(bql_locked())) {
return;
}
void accel_cpu_ioctl_begin(CPUState *cpu)
{
- if (unlikely(qemu_mutex_iothread_locked())) {
+ if (unlikely(bql_locked())) {
return;
}
void accel_cpu_ioctl_end(CPUState *cpu)
{
- if (unlikely(qemu_mutex_iothread_locked())) {
+ if (unlikely(bql_locked())) {
return;
}
* We allow to inhibit only when holding the BQL, so we can identify
* when an inhibitor wants to issue an ioctl easily.
*/
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
/* Block further invocations of the ioctls outside the BQL. */
CPU_FOREACH(cpu) {
rcu_register_thread();
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
cpu->neg.can_do_io = true;
qemu_guest_random_seed_thread_part2(cpu->random_seed);
do {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
#ifndef _WIN32
do {
int sig;
#else
qemu_sem_wait(&cpu->sem);
#endif
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_wait_io_event(cpu);
} while (!cpu->unplug);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
rcu_unregister_thread();
return NULL;
}
rcu_register_thread();
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
hvf_vcpu_destroy(cpu);
cpu_thread_signal_destroyed(cpu);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
rcu_unregister_thread();
return NULL;
}
rcu_register_thread();
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
cpu->neg.can_do_io = true;
kvm_destroy_vcpu(cpu);
cpu_thread_signal_destroyed(cpu);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
rcu_unregister_thread();
return NULL;
}
* should always be with BQL held, serialization is guaranteed.
* However, let's be sure of it.
*/
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
/*
* First make sure to flush the hardware buffers by kicking all
* vcpus out in a synchronous way.
trace_kvm_dirty_ring_reaper("wakeup");
r->reaper_state = KVM_DIRTY_RING_REAPER_REAPING;
- qemu_mutex_lock_iothread();
+ bql_lock();
kvm_dirty_ring_reap(s, NULL);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
r->reaper_iteration++;
}
return EXCP_HLT;
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
cpu_exec_start(cpu);
do {
#ifdef KVM_HAVE_MCE_INJECTION
if (unlikely(have_sigbus_pending)) {
- qemu_mutex_lock_iothread();
+ bql_lock();
kvm_arch_on_sigbus_vcpu(cpu, pending_sigbus_code,
pending_sigbus_addr);
have_sigbus_pending = false;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
#endif
* still full. Got kicked by KVM_RESET_DIRTY_RINGS.
*/
trace_kvm_dirty_ring_full(cpu->cpu_index);
- qemu_mutex_lock_iothread();
+ bql_lock();
/*
* We throttle vCPU by making it sleep once it exit from kernel
* due to dirty ring full. In the dirtylimit scenario, reaping
} else {
kvm_dirty_ring_reap(kvm_state, NULL);
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
dirtylimit_vcpu_execute(cpu);
ret = 0;
break;
break;
case KVM_SYSTEM_EVENT_CRASH:
kvm_cpu_synchronize_state(cpu);
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_system_guest_panicked(cpu_get_crash_info(cpu));
- qemu_mutex_unlock_iothread();
+ bql_unlock();
ret = 0;
break;
default:
} while (ret == 0);
cpu_exec_end(cpu);
- qemu_mutex_lock_iothread();
+ bql_lock();
if (ret < 0) {
cpu_dump_state(cpu, stderr, CPU_DUMP_CODE);
tcg_ctx->gen_tb = NULL;
}
#endif
- if (qemu_mutex_iothread_locked()) {
- qemu_mutex_unlock_iothread();
+ if (bql_locked()) {
+ bql_unlock();
}
assert_no_pages_locked();
}
#if defined(TARGET_I386)
if (cpu->interrupt_request & CPU_INTERRUPT_POLL) {
X86CPU *x86_cpu = X86_CPU(cpu);
- qemu_mutex_lock_iothread();
+ bql_lock();
apic_poll_irq(x86_cpu->apic_state);
cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
#endif /* TARGET_I386 */
if (!cpu_has_work(cpu)) {
#else
if (replay_exception()) {
CPUClass *cc = CPU_GET_CLASS(cpu);
- qemu_mutex_lock_iothread();
+ bql_lock();
cc->tcg_ops->do_interrupt(cpu);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
cpu->exception_index = -1;
if (unlikely(cpu->singlestep_enabled)) {
if (unlikely(qatomic_read(&cpu->interrupt_request))) {
int interrupt_request;
- qemu_mutex_lock_iothread();
+ bql_lock();
interrupt_request = cpu->interrupt_request;
if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) {
/* Mask out external interrupts for this step. */
if (interrupt_request & CPU_INTERRUPT_DEBUG) {
cpu->interrupt_request &= ~CPU_INTERRUPT_DEBUG;
cpu->exception_index = EXCP_DEBUG;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return true;
}
#if !defined(CONFIG_USER_ONLY)
cpu->interrupt_request &= ~CPU_INTERRUPT_HALT;
cpu->halted = 1;
cpu->exception_index = EXCP_HLT;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return true;
}
#if defined(TARGET_I386)
cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0, 0);
do_cpu_init(x86_cpu);
cpu->exception_index = EXCP_HALTED;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return true;
}
#else
else if (interrupt_request & CPU_INTERRUPT_RESET) {
replay_interrupt();
cpu_reset(cpu);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return true;
}
#endif /* !TARGET_I386 */
*/
if (unlikely(cpu->singlestep_enabled)) {
cpu->exception_index = EXCP_DEBUG;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return true;
}
cpu->exception_index = -1;
}
/* If we exit via cpu_loop_exit/longjmp it is reset in cpu_exec */
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
/* Finally, check if we need to exit to the main loop. */
section = io_prepare(&mr_offset, cpu, full->xlat_section, attrs, addr, ra);
mr = section->mr;
- qemu_mutex_lock_iothread();
+ bql_lock();
ret = int_ld_mmio_beN(cpu, full, ret_be, addr, size, mmu_idx,
type, ra, mr, mr_offset);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return ret;
}
section = io_prepare(&mr_offset, cpu, full->xlat_section, attrs, addr, ra);
mr = section->mr;
- qemu_mutex_lock_iothread();
+ bql_lock();
a = int_ld_mmio_beN(cpu, full, ret_be, addr, size - 8, mmu_idx,
MMU_DATA_LOAD, ra, mr, mr_offset);
b = int_ld_mmio_beN(cpu, full, ret_be, addr + size - 8, 8, mmu_idx,
MMU_DATA_LOAD, ra, mr, mr_offset + size - 8);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return int128_make128(b, a);
}
section = io_prepare(&mr_offset, cpu, full->xlat_section, attrs, addr, ra);
mr = section->mr;
- qemu_mutex_lock_iothread();
+ bql_lock();
ret = int_st_mmio_leN(cpu, full, val_le, addr, size, mmu_idx,
ra, mr, mr_offset);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return ret;
}
section = io_prepare(&mr_offset, cpu, full->xlat_section, attrs, addr, ra);
mr = section->mr;
- qemu_mutex_lock_iothread();
+ bql_lock();
int_st_mmio_leN(cpu, full, int128_getlo(val_le), addr, 8,
mmu_idx, ra, mr, mr_offset);
ret = int_st_mmio_leN(cpu, full, int128_gethi(val_le), addr + 8,
size - 8, mmu_idx, ra, mr, mr_offset + 8);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return ret;
}
* We're called without the iothread lock, so must take it while
* we're calling timer handlers.
*/
- qemu_mutex_lock_iothread();
+ bql_lock();
icount_notify_aio_contexts();
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
}
rcu_add_force_rcu_notifier(&force_rcu.notifier);
tcg_register_thread();
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
do {
if (cpu_can_run(cpu)) {
int r;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
r = tcg_cpus_exec(cpu);
- qemu_mutex_lock_iothread();
+ bql_lock();
switch (r) {
case EXCP_DEBUG:
cpu_handle_guest_debug(cpu);
*/
break;
case EXCP_ATOMIC:
- qemu_mutex_unlock_iothread();
+ bql_unlock();
cpu_exec_step_atomic(cpu);
- qemu_mutex_lock_iothread();
+ bql_lock();
default:
/* Ignore everything else? */
break;
} while (!cpu->unplug || cpu_can_run(cpu));
tcg_cpus_destroy(cpu);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
rcu_remove_force_rcu_notifier(&force_rcu.notifier);
rcu_unregister_thread();
return NULL;
rcu_add_force_rcu_notifier(&force_rcu);
tcg_register_thread();
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
/* Only used for icount_enabled() */
int64_t cpu_budget = 0;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
replay_mutex_lock();
- qemu_mutex_lock_iothread();
+ bql_lock();
if (icount_enabled()) {
int cpu_count = rr_cpu_count();
if (cpu_can_run(cpu)) {
int r;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (icount_enabled()) {
icount_prepare_for_run(cpu, cpu_budget);
}
if (icount_enabled()) {
icount_process_data(cpu);
}
- qemu_mutex_lock_iothread();
+ bql_lock();
if (r == EXCP_DEBUG) {
cpu_handle_guest_debug(cpu);
break;
} else if (r == EXCP_ATOMIC) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
cpu_exec_step_atomic(cpu);
- qemu_mutex_lock_iothread();
+ bql_lock();
break;
}
} else if (cpu->stop) {
/* mask must never be zero, except for A20 change call */
void tcg_handle_interrupt(CPUState *cpu, int mask)
{
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
cpu->interrupt_request |= mask;
void cpu_interrupt(CPUState *cpu, int mask)
{
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
cpu->interrupt_request |= mask;
qatomic_set(&cpu->neg.icount_decr.u16.high, -1);
}
{
coreaudioVoiceOut *core = in_client_data;
- qemu_mutex_lock_iothread();
+ bql_lock();
if (core->outputDeviceID) {
fini_out_device(core);
update_device_playback_state(core);
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return 0;
}
* BQL, so it goes to sleep; start_exclusive() is sleeping too, so
* neither CPU can proceed.
*/
- qemu_mutex_unlock_iothread();
+ bql_unlock();
start_exclusive();
wi->func(cpu, wi->data);
end_exclusive();
- qemu_mutex_lock_iothread();
+ bql_lock();
} else {
wi->func(cpu, wi->data);
}
s->guest_note = NULL;
if (s->resume) {
if (s->detached) {
- qemu_mutex_lock_iothread();
+ bql_lock();
}
vm_start();
if (s->detached) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
}
migrate_del_blocker(&dump_migration_blocker);
* BQL here if we need to. cpu_interrupt assumes it is held.*/
void cpu_reset_interrupt(CPUState *cpu, int mask)
{
- bool need_lock = !qemu_mutex_iothread_locked();
+ bool need_lock = !bql_locked();
if (need_lock) {
- qemu_mutex_lock_iothread();
+ bql_lock();
}
cpu->interrupt_request &= ~mask;
if (need_lock) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
}
{
bool use_iommu, pt;
/* Whether we need to take the BQL on our own */
- bool take_bql = !qemu_mutex_iothread_locked();
+ bool take_bql = !bql_locked();
assert(as);
* it. We'd better make sure we have had it already, or, take it.
*/
if (take_bql) {
- qemu_mutex_lock_iothread();
+ bql_lock();
}
/* Turn off first then on the other */
}
if (take_bql) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
return use_iommu;
* effect immediately. That just leaves interdomain loopback as the case
* which uses the BH.
*/
- if (!qemu_mutex_iothread_locked()) {
+ if (!bql_locked()) {
qemu_bh_schedule(s->gsi_bh);
return;
}
* We need the BQL because set_callback_pci_intx() may call into PCI code,
* and because we may need to manipulate the old and new GSI levels.
*/
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
qemu_mutex_lock(&s->port_lock);
switch (type) {
XenEvtchnPort *p = &s->port_table[port];
/* Because it *might* be a PIRQ port */
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
switch (p->type) {
case EVTCHNSTAT_closed:
return -ENOTSUP;
}
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
qemu_mutex_lock(&s->port_lock);
XenEvtchnState *s = xen_evtchn_singleton;
int pirq;
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
if (!s || gsi < 0 || gsi >= IOAPIC_NUM_PINS) {
return false;
return;
}
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
pirq = msi_pirq_target(addr, data);
return 1; /* Not a PIRQ */
}
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
pirq = msi_pirq_target(address, data);
if (!pirq || pirq >= s->nr_pirqs) {
return false;
}
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
pirq = msi_pirq_target(address, data);
if (!pirq || pirq >= s->nr_pirqs) {
return -ENOENT;
}
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
if (s->shinfo_gpa) {
/* If removing shinfo page, turn the kernel magic off first */
{
XenXenstoreState *s = opaque;
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
/*
* If there's a response pending, we obviously can't scribble over
ARMCPU *cpu = ARM_CPU(cs->cpu);
CPUARMState *env = &cpu->env;
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
trace_gicv3_cpuif_update(gicv3_redist_affid(cs), cs->hppi.irq,
cs->hppi.grp, cs->hppi.prio);
QEMUS390FlicIO *cur, *next;
uint8_t isc;
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
if (!(flic->pending & FLIC_PENDING_IO)) {
return 0;
}
{
uint32_t tmp;
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
g_assert(flic->pending & FLIC_PENDING_SERVICE);
tmp = flic->service_param;
flic->service_param = 0;
QEMUS390FlicIO *io;
uint8_t isc;
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
if (!(flic->pending & CR6_TO_PENDING_IO(cr6))) {
return NULL;
}
void qemu_s390_flic_dequeue_crw_mchk(QEMUS390FLICState *flic)
{
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
g_assert(flic->pending & FLIC_PENDING_MCHK_CR);
flic->pending &= ~FLIC_PENDING_MCHK_CR;
}
{
QEMUS390FLICState *flic = s390_get_qemu_flic(fs);
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
/* multiplexing is good enough for sclp - kvm does it internally as well */
flic->service_param |= parm;
flic->pending |= FLIC_PENDING_SERVICE;
QEMUS390FLICState *flic = s390_get_qemu_flic(fs);
QEMUS390FlicIO *io;
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
io = g_new0(QEMUS390FlicIO, 1);
io->id = subchannel_id;
io->nr = subchannel_nr;
{
QEMUS390FLICState *flic = s390_get_qemu_flic(fs);
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
flic->pending |= FLIC_PENDING_MCHK_CR;
qemu_s390_flic_notify(FLIC_PENDING_MCHK_CR);
bool qemu_s390_flic_has_any(QEMUS390FLICState *flic)
{
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
return !!flic->pending;
}
QEMUS390FlicIO *cur, *next;
int isc;
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
flic->simm = 0;
flic->nimm = 0;
flic->pending = 0;
smp_mb__after_rmw();
if (qatomic_read(&edu->status) & EDU_STATUS_IRQFACT) {
- qemu_mutex_lock_iothread();
+ bql_lock();
edu_raise_irq(edu, FACT_IRQ);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
}
struct SRCSCRResetInfo *ri = data.host_ptr;
IMX6SRCState *s = ri->s;
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
s->regs[SRC_SCR] = deposit32(s->regs[SRC_SCR], ri->reset_bit, 1, 0);
DPRINTF("reg[%s] <= 0x%" PRIx32 "\n",
struct SRCSCRResetInfo *ri = data.host_ptr;
IMX7SRCState *s = ri->s;
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
s->regs[SRC_A7RCR0] = deposit32(s->regs[SRC_A7RCR0], ri->reset_bit, 1, 0);
void *page;
void *tmpbuf = NULL;
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
for (;;) {
rc = netdev->tx_ring.req_cons;
RING_IDX rc, rp;
void *page;
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
if (xen_device_backend_get_state(&netdev->xendev) != XenbusStateConnected) {
return -1;
XenNetDev *netdev = XEN_NET_DEVICE(xendev);
unsigned int port, rx_copy;
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
if (xen_device_frontend_scanf(xendev, "tx-ring-ref", "%u",
&netdev->tx_ring_ref) != 1) {
trace_xen_netdev_disconnect(netdev->dev);
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
netdev->tx_ring.sring = NULL;
netdev->rx_ring.sring = NULL;
CPUPPCState *env = &cpu->env;
/* The TCG path should also be holding the BQL at this point */
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
if (FIELD_EX64(env->msr, MSR, PR)) {
qemu_log_mask(LOG_GUEST_ERROR, "Hypercall made with MSR[PR]=1\n");
{
PowerPCCPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
switch ((val >> 28) & 0x3) {
case 0x0:
break;
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
/* PowerPC 40x internal IRQ controller */
CPUPPCState *env = &cpu->env;
/* The TCG path should also be holding the BQL at this point */
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
g_assert(!vhyp_cpu_in_nested(cpu));
while (hrdata.received < 8) {
rng_backend_request_entropy(rngstate->backend, 8 - hrdata.received,
random_recv, &hrdata);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
qemu_sem_wait(&hrdata.sem);
- qemu_mutex_lock_iothread();
+ bql_lock();
}
qemu_sem_destroy(&hrdata.sem);
pending->ret = H_NO_MEM;
}
- qemu_mutex_lock_iothread();
+ bql_lock();
if (SPAPR_MACHINE(qdev_get_machine())->pending_hpt == pending) {
/* Ready to go */
free_pending_hpt(pending);
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return NULL;
}
*/
bool mpqemu_msg_send(MPQemuMsg *msg, QIOChannel *ioc, Error **errp)
{
- bool iolock = qemu_mutex_iothread_locked();
+ bool drop_bql = bql_locked();
bool iothread = qemu_in_iothread();
struct iovec send[2] = {};
int *fds = NULL;
* for IOThread case.
* Also skip lock handling while in a co-routine in the main context.
*/
- if (iolock && !iothread && !qemu_in_coroutine()) {
- qemu_mutex_unlock_iothread();
+ if (drop_bql && !iothread && !qemu_in_coroutine()) {
+ bql_unlock();
}
if (!qio_channel_writev_full_all(ioc, send, G_N_ELEMENTS(send),
trace_mpqemu_send_io_error(msg->cmd, msg->size, nfds);
}
- if (iolock && !iothread && !qemu_in_coroutine()) {
+ if (drop_bql && !iothread && !qemu_in_coroutine()) {
/* See above comment why skip locking here. */
- qemu_mutex_lock_iothread();
+ bql_lock();
}
return ret;
size_t *nfds, Error **errp)
{
struct iovec iov = { .iov_base = buf, .iov_len = len };
- bool iolock = qemu_mutex_iothread_locked();
+ bool drop_bql = bql_locked();
bool iothread = qemu_in_iothread();
int ret = -1;
*/
assert(qemu_in_coroutine() || !iothread);
- if (iolock && !iothread && !qemu_in_coroutine()) {
- qemu_mutex_unlock_iothread();
+ if (drop_bql && !iothread && !qemu_in_coroutine()) {
+ bql_unlock();
}
ret = qio_channel_readv_full_all_eof(ioc, &iov, 1, fds, nfds, errp);
- if (iolock && !iothread && !qemu_in_coroutine()) {
- qemu_mutex_lock_iothread();
+ if (drop_bql && !iothread && !qemu_in_coroutine()) {
+ bql_lock();
}
return (ret <= 0) ? ret : iov.iov_len;
}
if (release_lock) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
release_lock = false;
}
goto out;
}
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
guest_phys_blocks_init(&guest_phys_blocks);
guest_phys_blocks_append(&guest_phys_blocks);
}
if (ctx == qemu_get_aio_context()) {
- return qemu_mutex_iothread_locked();
+ return bql_locked();
} else {
return false;
}
AioContext *iohandler_get_aio_context(void);
/**
- * qemu_mutex_iothread_locked: Return lock status of the main loop mutex.
+ * bql_locked: Return lock status of the Big QEMU Lock (BQL)
*
- * The main loop mutex is the coarsest lock in QEMU, and as such it
+ * The Big QEMU Lock (BQL) is the coarsest lock in QEMU, and as such it
* must always be taken outside other locks. This function helps
* functions take different paths depending on whether the current
- * thread is running within the main loop mutex.
+ * thread is running within the BQL.
*
* This function should never be used in the block layer, because
* unit tests, block layer tools and qemu-storage-daemon do not
* have a BQL.
* Please instead refer to qemu_in_main_thread().
*/
-bool qemu_mutex_iothread_locked(void);
+bool bql_locked(void);
/**
* qemu_in_main_thread: return whether it's possible to safely access
} while (0)
/**
- * qemu_mutex_lock_iothread: Lock the main loop mutex.
+ * bql_lock: Lock the Big QEMU Lock (BQL).
*
- * This function locks the main loop mutex. The mutex is taken by
+ * This function locks the Big QEMU Lock (BQL). The lock is taken by
* main() in vl.c and always taken except while waiting on
- * external events (such as with select). The mutex should be taken
+ * external events (such as with select). The lock should be taken
* by threads other than the main loop thread when calling
* qemu_bh_new(), qemu_set_fd_handler() and basically all other
* functions documented in this file.
*
- * NOTE: tools currently are single-threaded and qemu_mutex_lock_iothread
+ * NOTE: tools currently are single-threaded and bql_lock
* is a no-op there.
*/
-#define qemu_mutex_lock_iothread() \
- qemu_mutex_lock_iothread_impl(__FILE__, __LINE__)
-void qemu_mutex_lock_iothread_impl(const char *file, int line);
+#define bql_lock() bql_lock_impl(__FILE__, __LINE__)
+void bql_lock_impl(const char *file, int line);
/**
- * qemu_mutex_unlock_iothread: Unlock the main loop mutex.
+ * bql_unlock: Unlock the Big QEMU Lock (BQL).
*
- * This function unlocks the main loop mutex. The mutex is taken by
+ * This function unlocks the Big QEMU Lock. The lock is taken by
* main() in vl.c and always taken except while waiting on
- * external events (such as with select). The mutex should be unlocked
+ * external events (such as with select). The lock should be unlocked
* as soon as possible by threads other than the main loop thread,
* because it prevents the main loop from processing callbacks,
* including timers and bottom halves.
*
- * NOTE: tools currently are single-threaded and qemu_mutex_unlock_iothread
+ * NOTE: tools currently are single-threaded and bql_unlock
* is a no-op there.
*/
-void qemu_mutex_unlock_iothread(void);
+void bql_unlock(void);
/**
* QEMU_IOTHREAD_LOCK_GUARD
*
- * Wrap a block of code in a conditional qemu_mutex_{lock,unlock}_iothread.
+ * Wrap a block of code in a conditional bql_{lock,unlock}.
*/
typedef struct IOThreadLockAuto IOThreadLockAuto;
static inline IOThreadLockAuto *qemu_iothread_auto_lock(const char *file,
int line)
{
- if (qemu_mutex_iothread_locked()) {
+ if (bql_locked()) {
return NULL;
}
- qemu_mutex_lock_iothread_impl(file, line);
+ bql_lock_impl(file, line);
/* Anything non-NULL causes the cleanup function to be called */
return (IOThreadLockAuto *)(uintptr_t)1;
}
static inline void qemu_iothread_auto_unlock(IOThreadLockAuto *l)
{
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
G_DEFINE_AUTOPTR_CLEANUP_FUNC(IOThreadLockAuto, qemu_iothread_auto_unlock)
typedef bool (*QemuCondTimedWaitFunc)(QemuCond *c, QemuMutex *m, int ms,
const char *f, int l);
-extern QemuMutexLockFunc qemu_bql_mutex_lock_func;
+extern QemuMutexLockFunc bql_mutex_lock_func;
extern QemuMutexLockFunc qemu_mutex_lock_func;
extern QemuMutexTrylockFunc qemu_mutex_trylock_func;
extern QemuRecMutexLockFunc qemu_rec_mutex_lock_func;
*result = r;
}
if (release_lock) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
RCU_READ_UNLOCK();
return val;
*result = r;
}
if (release_lock) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
RCU_READ_UNLOCK();
return val;
*result = r;
}
if (release_lock) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
RCU_READ_UNLOCK();
return val;
*result = r;
}
if (release_lock) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
RCU_READ_UNLOCK();
return val;
*result = r;
}
if (release_lock) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
RCU_READ_UNLOCK();
}
*result = r;
}
if (release_lock) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
RCU_READ_UNLOCK();
}
*result = r;
}
if (release_lock) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
RCU_READ_UNLOCK();
}
*result = r;
}
if (release_lock) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
RCU_READ_UNLOCK();
}
*result = r;
}
if (release_lock) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
RCU_READ_UNLOCK();
}
SaveBitmapState *dbms;
uint64_t pending = 0;
- qemu_mutex_lock_iothread();
+ bql_lock();
QSIMPLEQ_FOREACH(dbms, &s->dbms_list, entry) {
uint64_t gran = bdrv_dirty_bitmap_granularity(dbms->bitmap);
pending += DIV_ROUND_UP(sectors * BDRV_SECTOR_SIZE, gran);
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
trace_dirty_bitmap_state_pending(pending);
int64_t count;
if (bmds->shared_base) {
- qemu_mutex_lock_iothread();
+ bql_lock();
/* Skip unallocated sectors; intentionally treats failure or
* partial sector as an allocated sector */
while (cur_sector < total_sectors &&
}
cur_sector += count >> BDRV_SECTOR_BITS;
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
if (cur_sector >= total_sectors) {
* I/O runs in the main loop AioContext (see
* qemu_get_current_aio_context()).
*/
- qemu_mutex_lock_iothread();
+ bql_lock();
bdrv_reset_dirty_bitmap(bmds->dirty_bitmap, cur_sector * BDRV_SECTOR_SIZE,
nr_sectors * BDRV_SECTOR_SIZE);
blk->aiocb = blk_aio_preadv(bb, cur_sector * BDRV_SECTOR_SIZE, &blk->qiov,
0, blk_mig_read_cb, blk);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
bmds->cur_sector = cur_sector + nr_sectors;
return (bmds->cur_sector >= total_sectors);
/* Always called with iothread lock taken for
* simplicity, block_save_complete also calls it.
*/
- qemu_mutex_lock_iothread();
+ bql_lock();
ret = blk_mig_save_dirty_block(f, 1);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
if (ret < 0) {
return ret;
/* Estimate pending number of bytes to send */
uint64_t pending;
- qemu_mutex_lock_iothread();
+ bql_lock();
pending = get_remaining_dirty();
- qemu_mutex_unlock_iothread();
+ bql_unlock();
blk_mig_lock();
pending += block_mig_state.submitted * BLK_MIG_BLOCK_SIZE +
qio_channel_io_seek(QIO_CHANNEL(bioc), 0, 0, NULL);
bioc->usage = 0;
- qemu_mutex_lock_iothread();
+ bql_lock();
if (failover_get_state() != FAILOVER_STATUS_NONE) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
goto out;
}
vm_stop_force_state(RUN_STATE_COLO);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
trace_colo_vm_state_change("run", "stop");
/*
* Failover request bh could be called after vm_stop_force_state(),
if (failover_get_state() != FAILOVER_STATUS_NONE) {
goto out;
}
- qemu_mutex_lock_iothread();
+ bql_lock();
replication_do_checkpoint_all(&local_err);
if (local_err) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
goto out;
}
colo_send_message(s->to_dst_file, COLO_MESSAGE_VMSTATE_SEND, &local_err);
if (local_err) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
goto out;
}
/* Note: device state is saved into buffer */
ret = qemu_save_device_state(fb);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (ret < 0) {
goto out;
}
ret = 0;
- qemu_mutex_lock_iothread();
+ bql_lock();
vm_start();
- qemu_mutex_unlock_iothread();
+ bql_unlock();
trace_colo_vm_state_change("stop", "run");
out:
fb = qemu_file_new_output(QIO_CHANNEL(bioc));
object_unref(OBJECT(bioc));
- qemu_mutex_lock_iothread();
+ bql_lock();
replication_start_all(REPLICATION_MODE_PRIMARY, &local_err);
if (local_err) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
goto out;
}
vm_start();
- qemu_mutex_unlock_iothread();
+ bql_unlock();
trace_colo_vm_state_change("stop", "run");
timer_mod(s->colo_delay_timer, qemu_clock_get_ms(QEMU_CLOCK_HOST) +
void migrate_start_colo_process(MigrationState *s)
{
- qemu_mutex_unlock_iothread();
+ bql_unlock();
qemu_event_init(&s->colo_checkpoint_event, false);
s->colo_delay_timer = timer_new_ms(QEMU_CLOCK_HOST,
colo_checkpoint_notify, s);
qemu_sem_init(&s->colo_exit_sem, 0);
colo_process_checkpoint(s);
- qemu_mutex_lock_iothread();
+ bql_lock();
}
static void colo_incoming_process_checkpoint(MigrationIncomingState *mis,
Error *local_err = NULL;
int ret;
- qemu_mutex_lock_iothread();
+ bql_lock();
vm_stop_force_state(RUN_STATE_COLO);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
trace_colo_vm_state_change("run", "stop");
/* FIXME: This is unnecessary for periodic checkpoint mode */
return;
}
- qemu_mutex_lock_iothread();
+ bql_lock();
cpu_synchronize_all_states();
ret = qemu_loadvm_state_main(mis->from_src_file, mis);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (ret < 0) {
error_setg(errp, "Load VM's live state (ram) error");
return;
}
- qemu_mutex_lock_iothread();
+ bql_lock();
vmstate_loading = true;
colo_flush_ram_cache();
ret = qemu_load_device_state(fb);
if (ret < 0) {
error_setg(errp, "COLO: load device state failed");
vmstate_loading = false;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return;
}
if (local_err) {
error_propagate(errp, local_err);
vmstate_loading = false;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return;
}
if (local_err) {
error_propagate(errp, local_err);
vmstate_loading = false;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return;
}
/* Notify all filters of all NIC to do checkpoint */
if (local_err) {
error_propagate(errp, local_err);
vmstate_loading = false;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return;
}
vmstate_loading = false;
vm_start();
- qemu_mutex_unlock_iothread();
+ bql_unlock();
trace_colo_vm_state_change("stop", "run");
if (failover_get_state() == FAILOVER_STATUS_RELAUNCH) {
fb = qemu_file_new_input(QIO_CHANNEL(bioc));
object_unref(OBJECT(bioc));
- qemu_mutex_lock_iothread();
+ bql_lock();
replication_start_all(REPLICATION_MODE_SECONDARY, &local_err);
if (local_err) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
goto out;
}
vm_start();
- qemu_mutex_unlock_iothread();
+ bql_unlock();
trace_colo_vm_state_change("stop", "run");
colo_send_message(mis->to_src_file, COLO_MESSAGE_CHECKPOINT_READY,
Error *local_err = NULL;
QemuThread th;
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
if (!migration_incoming_colo_enabled()) {
return 0;
qemu_coroutine_yield();
mis->colo_incoming_co = NULL;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
/* Wait checkpoint incoming thread exit before free resource */
qemu_thread_join(&th);
- qemu_mutex_lock_iothread();
+ bql_lock();
/* We hold the global iothread lock, so it is safe here */
colo_release_ram_cache();
void global_dirty_log_change(unsigned int flag, bool start)
{
- qemu_mutex_lock_iothread();
+ bql_lock();
if (start) {
memory_global_dirty_log_start(flag);
} else {
memory_global_dirty_log_stop(flag);
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
/*
*/
static void global_dirty_log_sync(unsigned int flag, bool one_shot)
{
- qemu_mutex_lock_iothread();
+ bql_lock();
memory_global_dirty_log_sync(false);
if (one_shot) {
memory_global_dirty_log_stop(flag);
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
static DirtyPageRecord *vcpu_dirty_stat_alloc(VcpuStat *stat)
int64_t start_time;
DirtyPageRecord dirty_pages;
- qemu_mutex_lock_iothread();
+ bql_lock();
memory_global_dirty_log_start(GLOBAL_DIRTY_DIRTY_RATE);
/*
* KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE cap is enabled.
*/
dirtyrate_manual_reset_protect();
- qemu_mutex_unlock_iothread();
+ bql_unlock();
record_dirtypages_bitmap(&dirty_pages, true);
QEMUFile *tmp;
trace_migrate_fd_cleanup();
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (s->migration_thread_running) {
qemu_thread_join(&s->thread);
s->migration_thread_running = false;
}
- qemu_mutex_lock_iothread();
+ bql_lock();
multifd_save_cleanup();
qemu_mutex_lock(&s->qemu_file_lock);
}
trace_postcopy_start();
- qemu_mutex_lock_iothread();
+ bql_lock();
trace_postcopy_start_set_run();
migration_downtime_start(ms);
migration_downtime_end(ms);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (migrate_postcopy_ram()) {
/*
error_report_err(local_err);
}
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return -1;
}
* wait for the 'pause_sem' semaphore.
*/
if (s->state != MIGRATION_STATUS_CANCELLING) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
migrate_set_state(&s->state, *current_active_state,
MIGRATION_STATUS_PRE_SWITCHOVER);
qemu_sem_wait(&s->pause_sem);
migrate_set_state(&s->state, MIGRATION_STATUS_PRE_SWITCHOVER,
new_state);
*current_active_state = new_state;
- qemu_mutex_lock_iothread();
+ bql_lock();
}
return s->state == new_state ? 0 : -EINVAL;
{
int ret;
- qemu_mutex_lock_iothread();
+ bql_lock();
migration_downtime_start(s);
s->vm_old_state = runstate_get();
ret = qemu_savevm_state_complete_precopy(s->to_dst_file, false,
s->block_inactive);
out_unlock:
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return ret;
}
{
trace_migration_completion_postcopy_end();
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_savevm_state_complete_postcopy(s->to_dst_file);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
/*
* Shutdown the postcopy fast path thread. This is only needed when dest
*/
Error *local_err = NULL;
- qemu_mutex_lock_iothread();
+ bql_lock();
bdrv_activate_all(&local_err);
if (local_err) {
error_report_err(local_err);
} else {
s->block_inactive = false;
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
migrate_set_state(&s->state, current_active_state,
/* If we enabled cpu throttling for auto-converge, turn it off. */
cpu_throttle_stop();
- qemu_mutex_lock_iothread();
+ bql_lock();
switch (s->state) {
case MIGRATION_STATUS_COMPLETED:
migration_calculate_complete(s);
break;
}
migrate_fd_cleanup_schedule(s);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
static void bg_migration_iteration_finish(MigrationState *s)
*/
ram_write_tracking_stop();
- qemu_mutex_lock_iothread();
+ bql_lock();
switch (s->state) {
case MIGRATION_STATUS_COMPLETED:
migration_calculate_complete(s);
}
migrate_fd_cleanup_schedule(s);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
/*
object_ref(OBJECT(s));
update_iteration_initial_status(s);
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_savevm_state_header(s->to_dst_file);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
/*
* If we opened the return path, we need to make sure dst has it
qemu_savevm_send_colo_enable(s->to_dst_file);
}
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_savevm_state_setup(s->to_dst_file);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
qemu_savevm_wait_unplug(s, MIGRATION_STATUS_SETUP,
MIGRATION_STATUS_ACTIVE);
ram_write_tracking_prepare();
#endif
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_savevm_state_header(s->to_dst_file);
qemu_savevm_state_setup(s->to_dst_file);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
qemu_savevm_wait_unplug(s, MIGRATION_STATUS_SETUP,
MIGRATION_STATUS_ACTIVE);
trace_migration_thread_setup_complete();
migration_downtime_start(s);
- qemu_mutex_lock_iothread();
+ bql_lock();
s->vm_old_state = runstate_get();
s->vm_start_bh = qemu_bh_new(bg_migration_vm_start_bh, s);
qemu_bh_schedule(s->vm_start_bh);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
while (migration_is_active(s)) {
MigIterateState iter_state = bg_migration_iteration_run(s);
if (early_fail) {
migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE,
MIGRATION_STATUS_FAILED);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
bg_migration_iteration_finish(s);
migration_ops = g_malloc0(sizeof(MigrationOps));
migration_ops->ram_save_target_page = ram_save_target_page_legacy;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
ret = multifd_send_sync_main(f);
- qemu_mutex_lock_iothread();
+ bql_lock();
if (ret < 0) {
return ret;
}
uint64_t remaining_size = rs->migration_dirty_pages * TARGET_PAGE_SIZE;
if (!migration_in_postcopy() && remaining_size < s->threshold_size) {
- qemu_mutex_lock_iothread();
+ bql_lock();
WITH_RCU_READ_LOCK_GUARD() {
migration_bitmap_sync_precopy(rs, false);
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
remaining_size = rs->migration_dirty_pages * TARGET_PAGE_SIZE;
}
{
RAMBlock *block = NULL;
/* For memory_global_dirty_log_start below. */
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_mutex_lock_ramlist();
memory_global_dirty_log_sync(false);
}
ram_state->migration_dirty_pages = 0;
qemu_mutex_unlock_ramlist();
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
/* It is need to hold the global lock to call this helper */
{
if (replay_mode != REPLAY_MODE_NONE) {
unsigned long id;
- g_assert(!qemu_mutex_iothread_locked());
+ g_assert(!bql_locked());
g_assert(!replay_mutex_locked());
qemu_mutex_lock(&lock);
id = mutex_tail++;
static int console_can_read(void *opaque)
{
SemihostingConsole *c = opaque;
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
return (int)fifo8_num_free(&c->fifo);
}
static void console_read(void *opaque, const uint8_t *buf, int size)
{
SemihostingConsole *c = opaque;
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
while (size-- && !fifo8_is_full(&c->fifo)) {
fifo8_push(&c->fifo, *buf++);
}
{
SemihostingConsole *c = &console;
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
return !fifo8_is_empty(&c->fifo);
}
{
SemihostingConsole *c = &console;
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
/* Block if the fifo is completely empty. */
if (fifo8_is_empty(&c->fifo)) {
#include "qemu/osdep.h"
#include "qemu/main-loop.h"
-bool qemu_mutex_iothread_locked(void)
+bool bql_locked(void)
{
return false;
}
-void qemu_mutex_lock_iothread_impl(const char *file, int line)
+void bql_lock_impl(const char *file, int line)
{
}
-void qemu_mutex_unlock_iothread(void)
+void bql_unlock(void)
{
}
qemu_cond_timedwait_iothread(cpu->halt_cond,
sleeptime_ns / SCALE_MS);
} else {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
g_usleep(sleeptime_ns / SCALE_US);
- qemu_mutex_lock_iothread();
+ bql_lock();
}
sleeptime_ns = endtime_ns - qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
}
#endif /* CONFIG_LINUX */
-static QemuMutex qemu_global_mutex;
+/* The Big QEMU Lock (BQL) */
+static QemuMutex bql;
/*
* The chosen accelerator is supposed to register this.
qemu_init_sigbus();
qemu_cond_init(&qemu_cpu_cond);
qemu_cond_init(&qemu_pause_cond);
- qemu_mutex_init(&qemu_global_mutex);
+ qemu_mutex_init(&bql);
qemu_thread_get_self(&io_thread);
}
void run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data)
{
- do_run_on_cpu(cpu, func, data, &qemu_global_mutex);
+ do_run_on_cpu(cpu, func, data, &bql);
}
static void qemu_cpu_stop(CPUState *cpu, bool exit)
slept = true;
qemu_plugin_vcpu_idle_cb(cpu);
}
- qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex);
+ qemu_cond_wait(cpu->halt_cond, &bql);
}
if (slept) {
qemu_plugin_vcpu_resume_cb(cpu);
return current_cpu && qemu_cpu_is_self(current_cpu);
}
-QEMU_DEFINE_STATIC_CO_TLS(bool, iothread_locked)
+QEMU_DEFINE_STATIC_CO_TLS(bool, bql_locked)
-bool qemu_mutex_iothread_locked(void)
+bool bql_locked(void)
{
- return get_iothread_locked();
+ return get_bql_locked();
}
bool qemu_in_main_thread(void)
{
- return qemu_mutex_iothread_locked();
+ return bql_locked();
}
/*
* The BQL is taken from so many places that it is worth profiling the
* callers directly, instead of funneling them all through a single function.
*/
-void qemu_mutex_lock_iothread_impl(const char *file, int line)
+void bql_lock_impl(const char *file, int line)
{
- QemuMutexLockFunc bql_lock = qatomic_read(&qemu_bql_mutex_lock_func);
+ QemuMutexLockFunc bql_lock_fn = qatomic_read(&bql_mutex_lock_func);
- g_assert(!qemu_mutex_iothread_locked());
- bql_lock(&qemu_global_mutex, file, line);
- set_iothread_locked(true);
+ g_assert(!bql_locked());
+ bql_lock_fn(&bql, file, line);
+ set_bql_locked(true);
}
-void qemu_mutex_unlock_iothread(void)
+void bql_unlock(void)
{
- g_assert(qemu_mutex_iothread_locked());
- set_iothread_locked(false);
- qemu_mutex_unlock(&qemu_global_mutex);
+ g_assert(bql_locked());
+ set_bql_locked(false);
+ qemu_mutex_unlock(&bql);
}
void qemu_cond_wait_iothread(QemuCond *cond)
{
- qemu_cond_wait(cond, &qemu_global_mutex);
+ qemu_cond_wait(cond, &bql);
}
void qemu_cond_timedwait_iothread(QemuCond *cond, int ms)
{
- qemu_cond_timedwait(cond, &qemu_global_mutex, ms);
+ qemu_cond_timedwait(cond, &bql, ms);
}
/* signal CPU creation */
replay_mutex_unlock();
while (!all_vcpus_paused()) {
- qemu_cond_wait(&qemu_pause_cond, &qemu_global_mutex);
+ qemu_cond_wait(&qemu_pause_cond, &bql);
CPU_FOREACH(cpu) {
qemu_cpu_kick(cpu);
}
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
replay_mutex_lock();
- qemu_mutex_lock_iothread();
+ bql_lock();
}
void cpu_resume(CPUState *cpu)
cpu->stop = true;
cpu->unplug = true;
qemu_cpu_kick(cpu);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
qemu_thread_join(cpu->thread);
- qemu_mutex_lock_iothread();
+ bql_lock();
}
void cpus_register_accel(const AccelOpsClass *ops)
cpus_accel->create_vcpu_thread(cpu);
while (!cpu->created) {
- qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
+ qemu_cond_wait(&qemu_cpu_cond, &bql);
}
}
{
qatomic_set(&vcpu_dirty_rate_stat->running, 0);
dirtylimit_state_unlock();
- qemu_mutex_unlock_iothread();
+ bql_unlock();
qemu_thread_join(&vcpu_dirty_rate_stat->thread);
- qemu_mutex_lock_iothread();
+ bql_lock();
dirtylimit_state_lock();
}
AddressSpace *as;
assert(memory_region_transaction_depth);
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
--memory_region_transaction_depth;
if (!memory_region_transaction_depth) {
{
bool release_lock = false;
- if (!qemu_mutex_iothread_locked()) {
- qemu_mutex_lock_iothread();
+ if (!bql_locked()) {
+ bql_lock();
release_lock = true;
}
if (mr->flush_coalesced_mmio) {
}
if (release_lock) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
release_lock = false;
}
}
if (release_lock) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
release_lock = false;
}
qemu_init_cpu_list();
qemu_init_cpu_loop();
- qemu_mutex_lock_iothread();
+ bql_lock();
atexit(qemu_run_exit_notifiers);
* Now raise the debug interrupt so that it will
* trigger after the current instruction.
*/
- qemu_mutex_lock_iothread();
+ bql_lock();
cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return;
}
g_free(info);
/* Finally set the power status */
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
target_cpu->power_state = PSCI_ON;
}
ARMCPU *target_cpu;
struct CpuOnInfo *info;
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
DPRINTF("cpu %" PRId64 " (EL %d, %s) @ 0x%" PRIx64 " with R0 = 0x%" PRIx64
"\n", cpuid, target_el, target_aa64 ? "aarch64" : "aarch32", entry,
target_cpu_state->halted = 0;
/* Finally set the power status */
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
target_cpu->power_state = PSCI_ON;
}
CPUState *target_cpu_state;
ARMCPU *target_cpu;
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
/* Retrieve the cpu we are powering up */
target_cpu_state = arm_get_cpu_by_id(cpuid);
{
ARMCPU *target_cpu = ARM_CPU(target_cpu_state);
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
target_cpu->power_state = PSCI_OFF;
target_cpu_state->halted = 1;
target_cpu_state->exception_index = EXCP_HLT;
CPUState *target_cpu_state;
ARMCPU *target_cpu;
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
DPRINTF("cpu %" PRId64 "\n", cpuid);
CPUState *target_cpu_state;
ARMCPU *target_cpu;
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
DPRINTF("cpu %" PRId64 "\n", cpuid);
* VFIQ are masked unless running at EL0 or EL1, and HCR
* can only be written at EL2.
*/
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
arm_cpu_update_virq(cpu);
arm_cpu_update_vfiq(cpu);
arm_cpu_update_vserr(cpu);
* BQL needs to be held for any modification of
* cs->interrupt_request.
*/
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
arm_call_pre_el_change_hook(cpu);
* sleeping.
*/
qatomic_set_mb(&cpu->thread_kicked, false);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
pselect(0, 0, 0, 0, ts, &cpu->accel->unblock_ipi_mask);
- qemu_mutex_lock_iothread();
+ bql_lock();
}
static void hvf_wfi(CPUState *cpu)
flush_cpu_state(cpu);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
assert_hvf_ok(hv_vcpu_run(cpu->accel->fd));
/* handle VMEXIT */
uint32_t ec = syn_get_ec(syndrome);
ret = 0;
- qemu_mutex_lock_iothread();
+ bql_lock();
switch (exit_reason) {
case HV_EXIT_REASON_EXCEPTION:
/* This is the main one, handle below. */
if (run->s.regs.device_irq_level != cpu->device_irq_level) {
switched_level = cpu->device_irq_level ^ run->s.regs.device_irq_level;
- qemu_mutex_lock_iothread();
+ bql_lock();
if (switched_level & KVM_ARM_DEV_EL1_VTIMER) {
qemu_set_irq(cpu->gt_timer_outputs[GTIMER_VIRT],
/* We also mark unknown levels as processed to not waste cycles */
cpu->device_irq_level = run->s.regs.device_irq_level;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
return MEMTXATTRS_UNSPECIFIED;
env->exception.syndrome = debug_exit->hsr;
env->exception.vaddress = debug_exit->far;
env->exception.target_el = 1;
- qemu_mutex_lock_iothread();
+ bql_lock();
arm_cpu_do_interrupt(cs);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return false;
}
#if !TCG_OVERSIZED_GUEST
# error "Unexpected configuration"
#endif
- bool locked = qemu_mutex_iothread_locked();
+ bool locked = bql_locked();
if (!locked) {
- qemu_mutex_lock_iothread();
+ bql_lock();
}
if (ptw->out_be) {
cur_val = ldq_be_p(host);
}
}
if (!locked) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
#endif
goto illegal_return;
}
- qemu_mutex_lock_iothread();
+ bql_lock();
arm_call_pre_el_change_hook(env_archcpu(env));
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (!return_to_aa64) {
env->aarch64 = false;
*/
aarch64_sve_change_el(env, cur_el, new_el, return_to_aa64);
- qemu_mutex_lock_iothread();
+ bql_lock();
arm_call_el_change_hook(env_archcpu(env));
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return;
bool ts = is_secure && (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK);
bool take_exception;
- /* Take the iothread lock as we are going to touch the NVIC */
- qemu_mutex_lock_iothread();
+ /* Take the BQL as we are going to touch the NVIC */
+ bql_lock();
/* Check the background context had access to the FPU */
if (!v7m_cpacr_pass(env, is_secure, is_priv)) {
take_exception = !stacked_ok &&
armv7m_nvic_can_take_pending_exception(env->nvic);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (take_exception) {
raise_exception_ra(env, EXCP_LAZYFP, 0, 1, GETPC());
{
uint32_t mask;
- qemu_mutex_lock_iothread();
+ bql_lock();
arm_call_pre_el_change_hook(env_archcpu(env));
- qemu_mutex_unlock_iothread();
+ bql_unlock();
mask = aarch32_cpsr_valid_mask(env->features, &env_archcpu(env)->isar);
cpsr_write(env, val, mask, CPSRWriteExceptionReturn);
env->regs[15] &= (env->thumb ? ~1 : ~3);
arm_rebuild_hflags(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
arm_call_el_change_hook(env_archcpu(env));
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
/* Access to user mode registers from privileged modes. */
const ARMCPRegInfo *ri = rip;
if (ri->type & ARM_CP_IO) {
- qemu_mutex_lock_iothread();
+ bql_lock();
ri->writefn(env, ri, value);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
} else {
ri->writefn(env, ri, value);
}
uint32_t res;
if (ri->type & ARM_CP_IO) {
- qemu_mutex_lock_iothread();
+ bql_lock();
res = ri->readfn(env, ri);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
} else {
res = ri->readfn(env, ri);
}
const ARMCPRegInfo *ri = rip;
if (ri->type & ARM_CP_IO) {
- qemu_mutex_lock_iothread();
+ bql_lock();
ri->writefn(env, ri, value);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
} else {
ri->writefn(env, ri, value);
}
uint64_t res;
if (ri->type & ARM_CP_IO) {
- qemu_mutex_lock_iothread();
+ bql_lock();
res = ri->readfn(env, ri);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
} else {
res = ri->readfn(env, ri);
}
}
target_cpu = ARM_CPU(target_cpu_state);
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
ret = target_cpu->power_state;
break;
default:
void HELPER(write_eirr)(CPUHPPAState *env, target_ulong val)
{
env->cr[CR_EIRR] &= ~val;
- qemu_mutex_lock_iothread();
+ bql_lock();
eval_interrupt(env_archcpu(env));
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(write_eiem)(CPUHPPAState *env, target_ulong val)
{
env->cr[CR_EIEM] = val;
- qemu_mutex_lock_iothread();
+ bql_lock();
eval_interrupt(env_archcpu(env));
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void hppa_cpu_do_interrupt(CPUState *cs)
1. Adapt to our current QEMU's `CPUState` structure and `address_space_rw` API; many struct members have been moved around (emulated x86 state, xsave_buf) due to historical differences + QEMU needing to handle more emulation targets.
2. Removal of `apic_page` and hyperv-related functionality.
-3. More relaxed use of `qemu_mutex_lock_iothread`.
+3. More relaxed use of `bql_lock`.
}
vmx_update_tpr(cpu);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (!cpu_is_bsp(X86_CPU(cpu)) && cpu->halted) {
- qemu_mutex_lock_iothread();
+ bql_lock();
return EXCP_HLT;
}
rip = rreg(cpu->accel->fd, HV_X86_RIP);
env->eflags = rreg(cpu->accel->fd, HV_X86_RFLAGS);
- qemu_mutex_lock_iothread();
+ bql_lock();
update_apic_tpr(cpu);
current_cpu = cpu;
static void async_synic_update(CPUState *cs, run_on_cpu_data data)
{
- qemu_mutex_lock_iothread();
+ bql_lock();
hyperv_x86_synic_update(X86_CPU(cs));
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit)
/* Inject NMI */
if (cpu->interrupt_request & (CPU_INTERRUPT_NMI | CPU_INTERRUPT_SMI)) {
if (cpu->interrupt_request & CPU_INTERRUPT_NMI) {
- qemu_mutex_lock_iothread();
+ bql_lock();
cpu->interrupt_request &= ~CPU_INTERRUPT_NMI;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
DPRINTF("injected NMI\n");
ret = kvm_vcpu_ioctl(cpu, KVM_NMI);
if (ret < 0) {
}
}
if (cpu->interrupt_request & CPU_INTERRUPT_SMI) {
- qemu_mutex_lock_iothread();
+ bql_lock();
cpu->interrupt_request &= ~CPU_INTERRUPT_SMI;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
DPRINTF("injected SMI\n");
ret = kvm_vcpu_ioctl(cpu, KVM_SMI);
if (ret < 0) {
}
if (!kvm_pic_in_kernel()) {
- qemu_mutex_lock_iothread();
+ bql_lock();
}
/* Force the VCPU out of its inner loop to process any INIT requests
DPRINTF("setting tpr\n");
run->cr8 = cpu_get_apic_tpr(x86_cpu->apic_state);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
}
/* We need to protect the apic state against concurrent accesses from
* different threads in case the userspace irqchip is used. */
if (!kvm_irqchip_in_kernel()) {
- qemu_mutex_lock_iothread();
+ bql_lock();
}
cpu_set_apic_tpr(x86_cpu->apic_state, run->cr8);
cpu_set_apic_base(x86_cpu->apic_state, run->apic_base);
if (!kvm_irqchip_in_kernel()) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
return cpu_get_mem_attrs(env);
}
switch (run->exit_reason) {
case KVM_EXIT_HLT:
DPRINTF("handle_hlt\n");
- qemu_mutex_lock_iothread();
+ bql_lock();
ret = kvm_handle_halt(cpu);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
break;
case KVM_EXIT_SET_TPR:
ret = 0;
break;
case KVM_EXIT_TPR_ACCESS:
- qemu_mutex_lock_iothread();
+ bql_lock();
ret = kvm_handle_tpr_access(cpu);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
break;
case KVM_EXIT_FAIL_ENTRY:
code = run->fail_entry.hardware_entry_failure_reason;
break;
case KVM_EXIT_DEBUG:
DPRINTF("kvm_exit_debug\n");
- qemu_mutex_lock_iothread();
+ bql_lock();
ret = kvm_handle_debug(cpu, &run->debug.arch);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
break;
case KVM_EXIT_HYPERV:
ret = kvm_hv_handle_exit(cpu, &run->hyperv);
/* If the evtchn_upcall_pending flag is cleared, turn the GSI off. */
if (!vi->evtchn_upcall_pending) {
- qemu_mutex_lock_iothread();
+ bql_lock();
/*
* Check again now we have the lock, because it may have been
* asserted in the interim. And we don't want to take the lock
X86_CPU(cs)->env.xen_callback_asserted = false;
xen_evtchn_set_callback_level(0);
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
}
switch (hp.index) {
case HVM_PARAM_CALLBACK_IRQ:
- qemu_mutex_lock_iothread();
+ bql_lock();
err = xen_evtchn_set_callback_param(hp.value);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
xen_set_long_mode(exit->u.hcall.longmode);
break;
default:
CPUState *cpu;
int err;
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
trace_kvm_xen_soft_reset();
break;
case SHUTDOWN_soft_reset:
- qemu_mutex_lock_iothread();
+ bql_lock();
ret = kvm_xen_soft_reset();
- qemu_mutex_unlock_iothread();
+ bql_unlock();
break;
default:
rcu_register_thread();
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
current_cpu = cpu;
nvmm_destroy_vcpu(cpu);
cpu_thread_signal_destroyed(cpu);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
rcu_unregister_thread();
return NULL;
}
uint8_t tpr;
int ret;
- qemu_mutex_lock_iothread();
+ bql_lock();
tpr = cpu_get_apic_tpr(x86_cpu->apic_state);
if (tpr != qcpu->tpr) {
}
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
/*
tpr = exit->exitstate.cr8;
if (qcpu->tpr != tpr) {
qcpu->tpr = tpr;
- qemu_mutex_lock_iothread();
+ bql_lock();
cpu_set_apic_tpr(x86_cpu->apic_state, qcpu->tpr);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
}
CPUX86State *env = cpu_env(cpu);
int ret = 0;
- qemu_mutex_lock_iothread();
+ bql_lock();
if (!((cpu->interrupt_request & CPU_INTERRUPT_HARD) &&
(env->eflags & IF_MASK)) &&
ret = 1;
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return ret;
}
return 0;
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
cpu_exec_start(cpu);
/*
error_report("NVMM: Unexpected VM exit code 0x%lx [hw=0x%lx]",
exit->reason, exit->u.inv.hwcode);
nvmm_get_registers(cpu);
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_system_guest_panicked(cpu_get_crash_info(cpu));
- qemu_mutex_unlock_iothread();
+ bql_unlock();
ret = -1;
break;
}
} while (ret == 0);
cpu_exec_end(cpu);
- qemu_mutex_lock_iothread();
+ bql_lock();
qatomic_set(&cpu->exit_request, false);
void fpu_check_raise_ferr_irq(CPUX86State *env)
{
if (ferr_irq && !(env->hflags2 & HF2_IGNNE_MASK)) {
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_irq_raise(ferr_irq);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return;
}
}
{
CPUX86State *env = &X86_CPU(first_cpu)->env;
- assert(qemu_mutex_iothread_locked());
+ assert(bql_locked());
env->hflags2 |= HF2_IGNNE_MASK;
/*
break;
case 8:
if (!(env->hflags2 & HF2_VINTR_MASK)) {
- qemu_mutex_lock_iothread();
+ bql_lock();
cpu_set_apic_tpr(env_archcpu(env)->apic_state, t0);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
env->int_ctl = (env->int_ctl & ~V_TPR_MASK) | (t0 & V_TPR_MASK);
rcu_register_thread();
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
current_cpu = cpu;
whpx_destroy_vcpu(cpu);
cpu_thread_signal_destroyed(cpu);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
rcu_unregister_thread();
return NULL;
}
struct whpx_state *whpx = &whpx_global;
HRESULT hr;
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
if (!QTAILQ_EMPTY(&cpu->breakpoints) ||
(whpx->breakpoints.breakpoints &&
CPUX86State *env = cpu_env(cpu);
int ret = 0;
- qemu_mutex_lock_iothread();
+ bql_lock();
if (!((cpu->interrupt_request & CPU_INTERRUPT_HARD) &&
(env->eflags & IF_MASK)) &&
!(cpu->interrupt_request & CPU_INTERRUPT_NMI)) {
cpu->halted = true;
ret = 1;
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return ret;
}
memset(&new_int, 0, sizeof(new_int));
memset(reg_values, 0, sizeof(reg_values));
- qemu_mutex_lock_iothread();
+ bql_lock();
/* Inject NMI */
if (!vcpu->interruption_pending &&
reg_count += 1;
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
vcpu->ready_for_pic_interrupt = false;
if (reg_count) {
uint64_t tpr = vcpu->exit_ctx.VpContext.Cr8;
if (vcpu->tpr != tpr) {
vcpu->tpr = tpr;
- qemu_mutex_lock_iothread();
+ bql_lock();
cpu_set_apic_tpr(x86_cpu->apic_state, whpx_cr8_to_apic_tpr(vcpu->tpr));
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
vcpu->interruption_pending =
WhpxStepMode exclusive_step_mode = WHPX_STEP_NONE;
int ret;
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
if (whpx->running_cpus++ == 0) {
/* Insert breakpoints into memory, update exception exit bitmap. */
}
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (exclusive_step_mode != WHPX_STEP_NONE) {
start_exclusive();
error_report("WHPX: Unexpected VP exit code %d",
vcpu->exit_ctx.ExitReason);
whpx_get_registers(cpu);
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_system_guest_panicked(cpu_get_crash_info(cpu));
- qemu_mutex_unlock_iothread();
+ bql_unlock();
break;
}
cpu_exec_end(cpu);
}
- qemu_mutex_lock_iothread();
+ bql_lock();
current_cpu = cpu;
if (--whpx->running_cpus == 0) {
int64_t old_v = 0;
if (val & 0x1) {
- qemu_mutex_lock_iothread();
+ bql_lock();
loongarch_cpu_set_irq(cpu, IRQ_TIMER, 0);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
return old_v;
}
int r;
struct kvm_mips_interrupt intr;
- qemu_mutex_lock_iothread();
+ bql_lock();
if ((cs->interrupt_request & CPU_INTERRUPT_HARD) &&
cpu_mips_io_interrupts_pending(cpu)) {
}
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
* because there might be other conditions that state that c should
* be sleeping.
*/
- qemu_mutex_lock_iothread();
+ bql_lock();
cpu_interrupt(CPU(c), CPU_INTERRUPT_WAKE);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
static inline void mips_vpe_sleep(MIPSCPU *cpu)
break;
case TO_SPR(9, 0): /* PICMR */
env->picmr = rb;
- qemu_mutex_lock_iothread();
+ bql_lock();
if (env->picsr & env->picmr) {
cpu_interrupt(cs, CPU_INTERRUPT_HARD);
} else {
cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
break;
case TO_SPR(9, 2): /* PICSR */
env->picsr &= ~rb;
break;
case TO_SPR(10, 0): /* TTMR */
{
- qemu_mutex_lock_iothread();
+ bql_lock();
if ((env->ttmr & TTMR_M) ^ (rb & TTMR_M)) {
switch (rb & TTMR_M) {
case TIMER_NONE:
cs->interrupt_request &= ~CPU_INTERRUPT_TIMER;
}
cpu_openrisc_timer_update(cpu);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
break;
case TO_SPR(10, 1): /* TTCR */
- qemu_mutex_lock_iothread();
+ bql_lock();
cpu_openrisc_count_set(cpu, rb);
cpu_openrisc_timer_update(cpu);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
break;
}
#endif
return env->ttmr;
case TO_SPR(10, 1): /* TTCR */
- qemu_mutex_lock_iothread();
+ bql_lock();
cpu_openrisc_count_update(cpu);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return cpu_openrisc_count_get(cpu);
}
#endif
return;
}
- qemu_mutex_lock_iothread();
+ bql_lock();
CPU_FOREACH(cs) {
PowerPCCPU *cpu = POWERPC_CPU(cs);
CPUPPCState *cenv = &cpu->env;
ppc_set_irq(cpu, irq, 1);
}
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
/* Server Processor Control */
{
CPUState *cs;
- qemu_mutex_lock_iothread();
+ bql_lock();
CPU_FOREACH(cs) {
PowerPCCPU *cpu = POWERPC_CPU(cs);
CPUPPCState *cenv = &cpu->env;
ppc_set_irq(cpu, irq, 1);
}
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void helper_book3s_msgsnd(target_ulong rb)
}
/* Does iothread need to be locked for walking CPU list? */
- qemu_mutex_lock_iothread();
+ bql_lock();
THREAD_SIBLING_FOREACH(cs, ccs) {
PowerPCCPU *ccpu = POWERPC_CPU(ccs);
uint32_t thread_id = ppc_cpu_tir(ccpu);
if (ttir == thread_id) {
ppc_set_irq(ccpu, PPC_INTERRUPT_DOORBELL, 1);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return;
}
}
CPUPPCState *env = &cpu->env;
int ret;
- qemu_mutex_lock_iothread();
+ bql_lock();
switch (run->exit_reason) {
case KVM_EXIT_DCR:
break;
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return ret;
}
return dpdes;
}
- qemu_mutex_lock_iothread();
+ bql_lock();
THREAD_SIBLING_FOREACH(cs, ccs) {
PowerPCCPU *ccpu = POWERPC_CPU(ccs);
CPUPPCState *cenv = &ccpu->env;
dpdes |= (0x1 << thread_id);
}
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return dpdes;
}
}
/* Does iothread need to be locked for walking CPU list? */
- qemu_mutex_lock_iothread();
+ bql_lock();
THREAD_SIBLING_FOREACH(cs, ccs) {
PowerPCCPU *ccpu = POWERPC_CPU(ccs);
uint32_t thread_id = ppc_cpu_tir(ccpu);
ppc_set_irq(cpu, PPC_INTERRUPT_DOORBELL, val & (0x1 << thread_id));
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
#endif /* defined(TARGET_PPC64) */
} else {
int ret;
- qemu_mutex_lock_iothread();
+ bql_lock();
ret = ppc_dcr_read(env->dcr_env, (uint32_t)dcrn, &val);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (unlikely(ret != 0)) {
qemu_log_mask(LOG_GUEST_ERROR, "DCR read error %d %03x\n",
(uint32_t)dcrn, (uint32_t)dcrn);
POWERPC_EXCP_INVAL_INVAL, GETPC());
} else {
int ret;
- qemu_mutex_lock_iothread();
+ bql_lock();
ret = ppc_dcr_write(env->dcr_env, (uint32_t)dcrn, (uint32_t)val);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (unlikely(ret != 0)) {
qemu_log_mask(LOG_GUEST_ERROR, "DCR write error %d %03x\n",
(uint32_t)dcrn, (uint32_t)dcrn);
S390CPU *cpu = S390_CPU(cs);
int ret = 0;
- qemu_mutex_lock_iothread();
+ bql_lock();
kvm_cpu_synchronize_state(cs);
fprintf(stderr, "Unknown KVM exit: %d\n", run->exit_reason);
break;
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (ret == 0) {
ret = EXCP_INTERRUPT;
/* SCLP service call */
uint32_t HELPER(servc)(CPUS390XState *env, uint64_t r1, uint64_t r2)
{
- qemu_mutex_lock_iothread();
+ bql_lock();
int r = sclp_service_call(env_archcpu(env), r1, r2);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (r < 0) {
tcg_s390_program_interrupt(env, -r, GETPC());
}
switch (num) {
case 0x500:
/* KVM hypercall */
- qemu_mutex_lock_iothread();
+ bql_lock();
r = s390_virtio_hypercall(env);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
break;
case 0x44:
/* yield */
break;
case 0x308:
/* ipl */
- qemu_mutex_lock_iothread();
+ bql_lock();
handle_diag_308(env, r1, r3, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
r = 0;
break;
case 0x288:
/* stop the timer and remove pending CKC IRQs */
timer_del(env->tod_timer);
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
env->pending_int &= ~INTERRUPT_EXT_CLOCK_COMPARATOR;
/* the tod has to exceed the ckc, this can never happen if ckc is all 1's */
{
env->ckc = ckc;
- qemu_mutex_lock_iothread();
+ bql_lock();
update_ckc_timer(env);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void tcg_s390_tod_updated(CPUState *cs, run_on_cpu_data opaque)
.low = tod_low,
};
- qemu_mutex_lock_iothread();
+ bql_lock();
tdc->set(td, &tod, &error_abort);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return 0;
}
int cc;
/* TODO: needed to inject interrupts - push further down */
- qemu_mutex_lock_iothread();
+ bql_lock();
cc = handle_sigp(env, order_code & SIGP_ORDER_MASK, r1, r3);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return cc;
}
void HELPER(xsch)(CPUS390XState *env, uint64_t r1)
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
ioinst_handle_xsch(cpu, r1, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(csch)(CPUS390XState *env, uint64_t r1)
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
ioinst_handle_csch(cpu, r1, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(hsch)(CPUS390XState *env, uint64_t r1)
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
ioinst_handle_hsch(cpu, r1, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(msch)(CPUS390XState *env, uint64_t r1, uint64_t inst)
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
ioinst_handle_msch(cpu, r1, inst >> 16, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(rchp)(CPUS390XState *env, uint64_t r1)
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
ioinst_handle_rchp(cpu, r1, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(rsch)(CPUS390XState *env, uint64_t r1)
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
ioinst_handle_rsch(cpu, r1, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(sal)(CPUS390XState *env, uint64_t r1)
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
ioinst_handle_sal(cpu, r1, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(schm)(CPUS390XState *env, uint64_t r1, uint64_t r2, uint64_t inst)
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
ioinst_handle_schm(cpu, r1, r2, inst >> 16, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(ssch)(CPUS390XState *env, uint64_t r1, uint64_t inst)
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
ioinst_handle_ssch(cpu, r1, inst >> 16, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(stcrw)(CPUS390XState *env, uint64_t inst)
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
ioinst_handle_stcrw(cpu, inst >> 16, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(stsch)(CPUS390XState *env, uint64_t r1, uint64_t inst)
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
ioinst_handle_stsch(cpu, r1, inst >> 16, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
uint32_t HELPER(tpi)(CPUS390XState *env, uint64_t addr)
tcg_s390_program_interrupt(env, PGM_SPECIFICATION, ra);
}
- qemu_mutex_lock_iothread();
+ bql_lock();
io = qemu_s390_flic_dequeue_io(flic, env->cregs[6]);
if (!io) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return 0;
}
if (s390_cpu_virt_mem_write(cpu, addr, 0, &intc, sizeof(intc))) {
/* writing failed, reinject and properly clean up */
s390_io_interrupt(io->id, io->nr, io->parm, io->word);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
g_free(io);
s390_cpu_virt_mem_handle_exc(cpu, ra);
return 0;
}
g_free(io);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return 1;
}
void HELPER(tsch)(CPUS390XState *env, uint64_t r1, uint64_t inst)
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
ioinst_handle_tsch(cpu, r1, inst >> 16, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(chsc)(CPUS390XState *env, uint64_t inst)
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
ioinst_handle_chsc(cpu, inst >> 16, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
#endif
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
clp_service_call(cpu, r2, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(pcilg)(CPUS390XState *env, uint32_t r1, uint32_t r2)
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
pcilg_service_call(cpu, r1, r2, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(pcistg)(CPUS390XState *env, uint32_t r1, uint32_t r2)
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
pcistg_service_call(cpu, r1, r2, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(stpcifc)(CPUS390XState *env, uint32_t r1, uint64_t fiba,
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
stpcifc_service_call(cpu, r1, fiba, ar, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(sic)(CPUS390XState *env, uint64_t r1, uint64_t r3)
S390CPU *cpu = env_archcpu(env);
int r;
- qemu_mutex_lock_iothread();
+ bql_lock();
r = css_do_sic(cpu, (r3 >> 27) & 0x7, r1 & 0xffff);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
/* css_do_sic() may actually return a PGM_xxx value to inject */
if (r) {
tcg_s390_program_interrupt(env, -r, GETPC());
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
rpcit_service_call(cpu, r1, r2, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(pcistb)(CPUS390XState *env, uint32_t r1, uint32_t r3,
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
pcistb_service_call(cpu, r1, r3, gaddr, ar, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(mpcifc)(CPUS390XState *env, uint32_t r1, uint64_t fiba,
{
S390CPU *cpu = env_archcpu(env);
- qemu_mutex_lock_iothread();
+ bql_lock();
mpcifc_service_call(cpu, r1, fiba, ar, GETPC());
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
#endif
CPUState *cs;
/* We should be holding the BQL before we mess with IRQs */
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
if (env->pil_in && (env->interrupt_index == 0 ||
(env->interrupt_index & ~15) == TT_EXTINT)) {
(env->softint & ~(SOFTINT_TIMER | SOFTINT_STIMER));
/* We should be holding the BQL before we mess with IRQs */
- g_assert(qemu_mutex_iothread_locked());
+ g_assert(bql_locked());
/* TT_IVEC has a higher priority (16) than TT_EXTINT (31..17) */
if (env->ivec_status & 0x20) {
env->softint = value;
#if !defined(CONFIG_USER_ONLY)
if (cpu_interrupts_enabled(env)) {
- qemu_mutex_lock_iothread();
+ bql_lock();
cpu_check_irqs(env);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
#endif
return true;
cpu_raise_exception_ra(env, TT_ILL_INSN, GETPC());
} else {
/* cpu_put_psr may trigger interrupts, hence BQL */
- qemu_mutex_lock_iothread();
+ bql_lock();
cpu_put_psr(env, new_psr);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
}
#if !defined(CONFIG_USER_ONLY)
if (cpu_interrupts_enabled(env)) {
- qemu_mutex_lock_iothread();
+ bql_lock();
cpu_check_irqs(env);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
#endif
}
env->psrpil = new_pil;
if (cpu_interrupts_enabled(env)) {
- qemu_mutex_lock_iothread();
+ bql_lock();
cpu_check_irqs(env);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
#endif
}
#if !defined(CONFIG_USER_ONLY)
if (cpu_interrupts_enabled(env)) {
- qemu_mutex_lock_iothread();
+ bql_lock();
cpu_check_irqs(env);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
#endif
}
#if !defined(CONFIG_USER_ONLY)
if (cpu_interrupts_enabled(env)) {
- qemu_mutex_lock_iothread();
+ bql_lock();
cpu_check_irqs(env);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
#endif
}
env->sregs[PS] = (env->sregs[PS] & ~PS_INTLEVEL) |
(intlevel << PS_INTLEVEL_SHIFT);
- qemu_mutex_lock_iothread();
+ bql_lock();
check_interrupts(env);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (env->pending_irq_level) {
cpu_loop_exit(cpu);
void HELPER(check_interrupts)(CPUXtensaState *env)
{
- qemu_mutex_lock_iothread();
+ bql_lock();
check_interrupts(env);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
void HELPER(intset)(CPUXtensaState *env, uint32_t v)
typedef void (^CodeBlock)(void);
typedef bool (^BoolCodeBlock)(void);
-static void with_iothread_lock(CodeBlock block)
+static void with_bql(CodeBlock block)
{
- bool locked = qemu_mutex_iothread_locked();
+ bool locked = bql_locked();
if (!locked) {
- qemu_mutex_lock_iothread();
+ bql_lock();
}
block();
if (!locked) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
}
-static bool bool_with_iothread_lock(BoolCodeBlock block)
+static bool bool_with_bql(BoolCodeBlock block)
{
- bool locked = qemu_mutex_iothread_locked();
+ bool locked = bql_locked();
bool val;
if (!locked) {
- qemu_mutex_lock_iothread();
+ bql_lock();
}
val = block();
if (!locked) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
return val;
}
return;
}
- with_iothread_lock(^{
+ with_bql(^{
[self updateUIInfoLocked];
});
}
- (bool) handleEvent:(NSEvent *)event
{
- return bool_with_iothread_lock(^{
+ return bool_with_bql(^{
return [self handleEventLocked:event];
});
}
*/
- (void) raiseAllKeys
{
- with_iothread_lock(^{
+ with_bql(^{
qkbd_state_lift_all_keys(kbd);
});
}
{
COCOA_DEBUG("QemuCocoaAppController: applicationWillTerminate\n");
- with_iothread_lock(^{
+ with_bql(^{
shutdown_action = SHUTDOWN_ACTION_POWEROFF;
qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI);
});
/* Pause the guest */
- (void)pauseQEMU:(id)sender
{
- with_iothread_lock(^{
+ with_bql(^{
qmp_stop(NULL);
});
[sender setEnabled: NO];
/* Resume running the guest operating system */
- (void)resumeQEMU:(id) sender
{
- with_iothread_lock(^{
+ with_bql(^{
qmp_cont(NULL);
});
[sender setEnabled: NO];
/* Restarts QEMU */
- (void)restartQEMU:(id)sender
{
- with_iothread_lock(^{
+ with_bql(^{
qmp_system_reset(NULL);
});
}
/* Powers down QEMU */
- (void)powerDownQEMU:(id)sender
{
- with_iothread_lock(^{
+ with_bql(^{
qmp_system_powerdown(NULL);
});
}
}
__block Error *err = NULL;
- with_iothread_lock(^{
+ with_bql(^{
qmp_eject([drive cStringUsingEncoding: NSASCIIStringEncoding],
NULL, false, false, &err);
});
}
__block Error *err = NULL;
- with_iothread_lock(^{
+ with_bql(^{
qmp_blockdev_change_medium([drive cStringUsingEncoding:
NSASCIIStringEncoding],
NULL,
// get the throttle percentage
throttle_pct = [sender tag];
- with_iothread_lock(^{
+ with_bql(^{
cpu_throttle_set(throttle_pct);
});
COCOA_DEBUG("cpu throttling at %d%c\n", cpu_throttle_get_percentage(), '%');
return;
}
- with_iothread_lock(^{
+ with_bql(^{
QemuClipboardInfo *info = qemu_clipboard_info_ref(cbinfo);
qemu_event_reset(&cbevent);
qemu_clipboard_request(info, QEMU_CLIPBOARD_TYPE_TEXT);
while (info == cbinfo &&
info->types[QEMU_CLIPBOARD_TYPE_TEXT].available &&
info->types[QEMU_CLIPBOARD_TYPE_TEXT].data == NULL) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
qemu_event_wait(&cbevent);
- qemu_mutex_lock_iothread();
+ bql_lock();
}
if (info == cbinfo) {
int status;
COCOA_DEBUG("Second thread: calling qemu_default_main()\n");
- qemu_mutex_lock_iothread();
+ bql_lock();
status = qemu_default_main();
- qemu_mutex_unlock_iothread();
+ bql_unlock();
COCOA_DEBUG("Second thread: qemu_default_main() returned, exiting\n");
[cbowner release];
exit(status);
COCOA_DEBUG("Entered %s()\n", __func__);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
qemu_thread_create(&thread, "qemu_main", call_qemu_main,
NULL, QEMU_THREAD_DETACHED);
*/
bool need_lock = !qemu_thread_is_self(&me);
if (need_lock) {
- qemu_mutex_lock_iothread();
+ bql_lock();
}
if (info->flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT) {
}
if (need_lock) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
qapi_free_SpiceServerInfo(server);
if (ctx) {
return ctx;
}
- if (qemu_mutex_iothread_locked()) {
+ if (bql_locked()) {
/* Possibly in a vCPU thread. */
return qemu_get_aio_context();
}
glib_pollfds_fill(&timeout);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
replay_mutex_unlock();
ret = qemu_poll_ns((GPollFD *)gpollfds->data, gpollfds->len, timeout);
replay_mutex_lock();
- qemu_mutex_lock_iothread();
+ bql_lock();
glib_pollfds_poll();
poll_timeout_ns = qemu_soonest_timeout(poll_timeout_ns, timeout);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
replay_mutex_unlock();
replay_mutex_lock();
- qemu_mutex_lock_iothread();
+ bql_lock();
if (g_poll_ret > 0) {
for (i = 0; i < w->num; i++) {
w->revents[i] = poll_fds[n_poll_fds + i].revents;
[QSP_CONDVAR] = "condvar",
};
-QemuMutexLockFunc qemu_bql_mutex_lock_func = qemu_mutex_lock_impl;
+QemuMutexLockFunc bql_mutex_lock_func = qemu_mutex_lock_impl;
QemuMutexLockFunc qemu_mutex_lock_func = qemu_mutex_lock_impl;
QemuMutexTrylockFunc qemu_mutex_trylock_func = qemu_mutex_trylock_impl;
QemuRecMutexLockFunc qemu_rec_mutex_lock_func = qemu_rec_mutex_lock_impl;
{
qatomic_set(&qemu_mutex_lock_func, qsp_mutex_lock);
qatomic_set(&qemu_mutex_trylock_func, qsp_mutex_trylock);
- qatomic_set(&qemu_bql_mutex_lock_func, qsp_bql_mutex_lock);
+ qatomic_set(&bql_mutex_lock_func, qsp_bql_mutex_lock);
qatomic_set(&qemu_rec_mutex_lock_func, qsp_rec_mutex_lock);
qatomic_set(&qemu_rec_mutex_trylock_func, qsp_rec_mutex_trylock);
qatomic_set(&qemu_cond_wait_func, qsp_cond_wait);
{
qatomic_set(&qemu_mutex_lock_func, qemu_mutex_lock_impl);
qatomic_set(&qemu_mutex_trylock_func, qemu_mutex_trylock_impl);
- qatomic_set(&qemu_bql_mutex_lock_func, qemu_mutex_lock_impl);
+ qatomic_set(&bql_mutex_lock_func, qemu_mutex_lock_impl);
qatomic_set(&qemu_rec_mutex_lock_func, qemu_rec_mutex_lock_impl);
qatomic_set(&qemu_rec_mutex_trylock_func, qemu_rec_mutex_trylock_impl);
qatomic_set(&qemu_cond_wait_func, qemu_cond_wait_impl);
qatomic_sub(&rcu_call_count, n);
synchronize_rcu();
- qemu_mutex_lock_iothread();
+ bql_lock();
while (n > 0) {
node = try_dequeue();
while (!node) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
qemu_event_reset(&rcu_call_ready_event);
node = try_dequeue();
if (!node) {
qemu_event_wait(&rcu_call_ready_event);
node = try_dequeue();
}
- qemu_mutex_lock_iothread();
+ bql_lock();
}
n--;
node->func(node);
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
abort();
}
void drain_call_rcu(void)
{
struct rcu_drain rcu_drain;
- bool locked = qemu_mutex_iothread_locked();
+ bool locked = bql_locked();
memset(&rcu_drain, 0, sizeof(struct rcu_drain));
qemu_event_init(&rcu_drain.drain_complete_event, false);
if (locked) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
qatomic_dec(&in_drain_call_rcu);
if (locked) {
- qemu_mutex_lock_iothread();
+ bql_lock();
}
}