From patchwork Thu Oct 27 15:10:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 79744 Delivered-To: patch@linaro.org Received: by 10.80.142.83 with SMTP id 19csp724823edx; Thu, 27 Oct 2016 09:01:13 -0700 (PDT) X-Received: by 10.31.209.6 with SMTP id i6mr2603239vkg.144.1477584073531; Thu, 27 Oct 2016 09:01:13 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g80si3620442vkd.180.2016.10.27.09.01.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 27 Oct 2016 09:01:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzn7A-0003LP-ND for patch@linaro.org; Thu, 27 Oct 2016 12:01:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzmTc-00043y-5e for qemu-devel@nongnu.org; Thu, 27 Oct 2016 11:20:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzmTX-0004iN-Rw for qemu-devel@nongnu.org; Thu, 27 Oct 2016 11:20:20 -0400 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:37060) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bzmTX-0004hj-GM for qemu-devel@nongnu.org; Thu, 27 Oct 2016 11:20:15 -0400 Received: by mail-wm0-x229.google.com with SMTP id 140so29781461wmv.0 for ; Thu, 27 Oct 2016 08:20:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bqvUODBq2o7/H7juwU4UgqbDc5Z2OGgDs/WgsH1xj2A=; b=Tc63tlxOqRMgP8VW6hriwVJiE3zkYBw7hx7yfLRuMt5vM3KcJchAT4paKVI5vF6N9b 7YANlkRQqpC+Iwqc+w2UB+IOuCi/3vVrMbuXRF6Q3Y62U14pN8H74Tk09JOX+NfRE7FK eA0alDugjzmCZMYuw57DDFQBK3wX2ZxIOAhjw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bqvUODBq2o7/H7juwU4UgqbDc5Z2OGgDs/WgsH1xj2A=; b=dgt4x+V9jCWS9Da1mIGOuQnufmFZcgE+zr/mTrjdJtxakMYF1x/HKu38UrTMOQV/ix FHLlqmhYDAyjlhAh95Wqgudl+BS64AL7/6xtBJAQBRdK8tevBYVvwCJk31zOGhXnGonP vvFFBhacua9ltdHFMq8RSUAw7clhjq+TiS+SzMMpvT5s9BE3TjSMLjhMpUyGY7M61g59 nrDJcCW1PyGoQwWrUOfRQcB8lldmuXQKQ40zfXox3g+nQ0bNkUpW4bl+cVKNa3GSC3hq /usP11Y1LwnMptExTKpjVfDg7kkEh3Ai+fTpa995udEgMdmOXUkTePOIzk8Ip5krwNFO 1a3Q== X-Gm-Message-State: ABUngvfTWAwYdThxpu12HOHcteLwijxoLStQ7Xct4qVZiW6nIcGkJlox5m2pUtsZCAa+ahbJ X-Received: by 10.194.238.162 with SMTP id vl2mr7286421wjc.39.1477581603505; Thu, 27 Oct 2016 08:20:03 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id a1sm9015771wju.41.2016.10.27.08.19.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Oct 2016 08:19:59 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id E845C3E0406; Thu, 27 Oct 2016 16:11:00 +0100 (BST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: pbonzini@redhat.com Date: Thu, 27 Oct 2016 16:10:20 +0100 Message-Id: <20161027151030.20863-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161027151030.20863-1-alex.bennee@linaro.org> References: <20161027151030.20863-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::229 Subject: [Qemu-devel] [PATCH v5 23/33] *_run_on_cpu: introduce run_on_cpu_data type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mttcg@listserver.greensocs.com, peter.maydell@linaro.org, "open list:Overall" , "Michael S. Tsirkin" , jan.kiszka@siemens.com, qemu-devel@nongnu.org, Alexander Graf , cota@braap.org, bobby.prani@gmail.com, rth@twiddle.net, fred.konrad@greensocs.com, Eduardo Habkost , nikunj@linux.vnet.ibm.com, serge.fdrv@gmail.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , David Gibson , mark.burton@greensocs.com, Peter Crosthwaite , Marcelo Tosatti , claudio.fontana@huawei.com, a.rigo@virtualopensystems.com, "open list:PowerPC" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This changes the *_run_on_cpu APIs (and helpers) to pass data in a run_on_cpu_data type instead of a plain void *. This is because we sometimes want to pass a target address (target_ulong) and this fails on 32 bit hosts emulating 64 bit guests. Signed-off-by: Alex BennĂ©e --- cpus-common.c | 9 +++++---- cpus.c | 7 ++++--- hw/i386/kvm/apic.c | 14 +++++++------- hw/i386/kvmvapic.c | 13 ++++++------- hw/ppc/ppce500_spin.c | 6 +++--- hw/ppc/spapr.c | 4 ++-- hw/ppc/spapr_hcall.c | 12 ++++++------ include/qom/cpu.h | 31 ++++++++++++++++++++++++++----- kvm-all.c | 20 +++++++++++--------- target-i386/helper.c | 8 ++++---- target-i386/kvm.c | 4 ++-- target-s390x/cpu.c | 4 ++-- target-s390x/cpu.h | 4 ++-- target-s390x/misc_helper.c | 4 ++-- translate-all.c | 13 ++++++------- 15 files changed, 88 insertions(+), 65 deletions(-) -- 2.10.1 diff --git a/cpus-common.c b/cpus-common.c index 3e11452..59f751e 100644 --- a/cpus-common.c +++ b/cpus-common.c @@ -109,7 +109,7 @@ void cpu_list_remove(CPUState *cpu) struct qemu_work_item { struct qemu_work_item *next; run_on_cpu_func func; - void *data; + run_on_cpu_data data; bool free, exclusive, done; }; @@ -129,7 +129,7 @@ static void queue_work_on_cpu(CPUState *cpu, struct qemu_work_item *wi) qemu_cpu_kick(cpu); } -void do_run_on_cpu(CPUState *cpu, run_on_cpu_func func, void *data, +void do_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data, QemuMutex *mutex) { struct qemu_work_item wi; @@ -154,7 +154,7 @@ void do_run_on_cpu(CPUState *cpu, run_on_cpu_func func, void *data, } } -void async_run_on_cpu(CPUState *cpu, run_on_cpu_func func, void *data) +void async_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data) { struct qemu_work_item *wi; @@ -296,7 +296,8 @@ void cpu_exec_end(CPUState *cpu) } } -void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func func, void *data) +void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func func, + run_on_cpu_data data) { struct qemu_work_item *wi; diff --git a/cpus.c b/cpus.c index 0c046e3..8f98060 100644 --- a/cpus.c +++ b/cpus.c @@ -600,7 +600,7 @@ static const VMStateDescription vmstate_timers = { } }; -static void cpu_throttle_thread(CPUState *cpu, void *opaque) +static void cpu_throttle_thread(CPUState *cpu, run_on_cpu_data opaque) { double pct; double throttle_ratio; @@ -630,8 +630,9 @@ static void cpu_throttle_timer_tick(void *opaque) return; } CPU_FOREACH(cpu) { + run_on_cpu_data data = { .host_ptr = (uintptr_t) NULL }; if (!atomic_xchg(&cpu->throttle_thread_scheduled, 1)) { - async_run_on_cpu(cpu, cpu_throttle_thread, NULL); + async_run_on_cpu(cpu, cpu_throttle_thread, data); } } @@ -1011,7 +1012,7 @@ void qemu_init_cpu_loop(void) qemu_thread_get_self(&io_thread); } -void run_on_cpu(CPUState *cpu, run_on_cpu_func func, void *data) +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); } diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c index c016e63..45e370a 100644 --- a/hw/i386/kvm/apic.c +++ b/hw/i386/kvm/apic.c @@ -125,9 +125,9 @@ static void kvm_apic_vapic_base_update(APICCommonState *s) } } -static void kvm_apic_put(CPUState *cs, void *data) +static void kvm_apic_put(CPUState *cs, run_on_cpu_data data) { - APICCommonState *s = data; + APICCommonState *s = (APICCommonState *) data.host_ptr; struct kvm_lapic_state kapic; int ret; @@ -143,12 +143,12 @@ static void kvm_apic_put(CPUState *cs, void *data) static void kvm_apic_post_load(APICCommonState *s) { - run_on_cpu(CPU(s->cpu), kvm_apic_put, s); + run_on_cpu(CPU(s->cpu), kvm_apic_put, RUN_ON_CPU_HOST_PTR(s)); } -static void do_inject_external_nmi(CPUState *cpu, void *data) +static void do_inject_external_nmi(CPUState *cpu, run_on_cpu_data data) { - APICCommonState *s = data; + APICCommonState *s = (APICCommonState *) data.host_ptr; uint32_t lvt; int ret; @@ -166,7 +166,7 @@ static void do_inject_external_nmi(CPUState *cpu, void *data) static void kvm_apic_external_nmi(APICCommonState *s) { - run_on_cpu(CPU(s->cpu), do_inject_external_nmi, s); + run_on_cpu(CPU(s->cpu), do_inject_external_nmi, RUN_ON_CPU_HOST_PTR(s)); } static uint64_t kvm_apic_mem_read(void *opaque, hwaddr addr, @@ -199,7 +199,7 @@ static void kvm_apic_reset(APICCommonState *s) /* Not used by KVM, which uses the CPU mp_state instead. */ s->wait_for_sipi = 0; - run_on_cpu(CPU(s->cpu), kvm_apic_put, s); + run_on_cpu(CPU(s->cpu), kvm_apic_put, RUN_ON_CPU_HOST_PTR(s)); } static void kvm_apic_realize(DeviceState *dev, Error **errp) diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c index 3be6b96..2b71295 100644 --- a/hw/i386/kvmvapic.c +++ b/hw/i386/kvmvapic.c @@ -487,10 +487,9 @@ typedef struct VAPICEnableTPRReporting { bool enable; } VAPICEnableTPRReporting; -static void vapic_do_enable_tpr_reporting(CPUState *cpu, void *data) +static void vapic_do_enable_tpr_reporting(CPUState *cpu, run_on_cpu_data data) { - VAPICEnableTPRReporting *info = data; - + VAPICEnableTPRReporting *info = (VAPICEnableTPRReporting *) data.host_ptr; apic_enable_tpr_access_reporting(info->apic, info->enable); } @@ -505,7 +504,7 @@ static void vapic_enable_tpr_reporting(bool enable) CPU_FOREACH(cs) { cpu = X86_CPU(cs); info.apic = cpu->apic_state; - run_on_cpu(cs, vapic_do_enable_tpr_reporting, &info); + run_on_cpu(cs, vapic_do_enable_tpr_reporting, RUN_ON_CPU_HOST_PTR(&info)); } } @@ -738,9 +737,9 @@ static void vapic_realize(DeviceState *dev, Error **errp) nb_option_roms++; } -static void do_vapic_enable(CPUState *cs, void *data) +static void do_vapic_enable(CPUState *cs, run_on_cpu_data data) { - VAPICROMState *s = data; + VAPICROMState *s = (VAPICROMState *) data.host_ptr; X86CPU *cpu = X86_CPU(cs); static const uint8_t enabled = 1; @@ -762,7 +761,7 @@ static void kvmvapic_vm_state_change(void *opaque, int running, if (s->state == VAPIC_ACTIVE) { if (smp_cpus == 1) { - run_on_cpu(first_cpu, do_vapic_enable, s); + run_on_cpu(first_cpu, do_vapic_enable, RUN_ON_CPU_HOST_PTR(s)); } else { zero = g_malloc0(s->rom_state.vapic_size); cpu_physical_memory_write(s->vapic_paddr, zero, diff --git a/hw/ppc/ppce500_spin.c b/hw/ppc/ppce500_spin.c index 8e16f65..2383cd0 100644 --- a/hw/ppc/ppce500_spin.c +++ b/hw/ppc/ppce500_spin.c @@ -84,11 +84,11 @@ static void mmubooke_create_initial_mapping(CPUPPCState *env, env->tlb_dirty = true; } -static void spin_kick(CPUState *cs, void *data) +static void spin_kick(CPUState *cs, run_on_cpu_data data) { PowerPCCPU *cpu = POWERPC_CPU(cs); CPUPPCState *env = &cpu->env; - SpinInfo *curspin = data; + SpinInfo *curspin = (SpinInfo *) data.host_ptr; hwaddr map_size = 64 * 1024 * 1024; hwaddr map_start; @@ -147,7 +147,7 @@ static void spin_write(void *opaque, hwaddr addr, uint64_t value, if (!(ldq_p(&curspin->addr) & 1)) { /* run CPU */ - run_on_cpu(cpu, spin_kick, curspin); + run_on_cpu(cpu, spin_kick, RUN_ON_CPU_HOST_PTR(curspin)); } } diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 63df95b..538cd93 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2151,7 +2151,7 @@ static void spapr_machine_finalizefn(Object *obj) g_free(spapr->kvm_type); } -static void ppc_cpu_do_nmi_on_cpu(CPUState *cs, void *arg) +static void ppc_cpu_do_nmi_on_cpu(CPUState *cs, run_on_cpu_data arg) { cpu_synchronize_state(cs); ppc_cpu_do_system_reset(cs); @@ -2162,7 +2162,7 @@ static void spapr_nmi(NMIState *n, int cpu_index, Error **errp) CPUState *cs; CPU_FOREACH(cs) { - async_run_on_cpu(cs, ppc_cpu_do_nmi_on_cpu, NULL); + async_run_on_cpu(cs, ppc_cpu_do_nmi_on_cpu, (run_on_cpu_data) NULL); } } diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index c5e7e8c..d8ffd1e 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -18,9 +18,9 @@ struct SPRSyncState { target_ulong mask; }; -static void do_spr_sync(CPUState *cs, void *arg) +static void do_spr_sync(CPUState *cs, run_on_cpu_data arg) { - struct SPRSyncState *s = arg; + struct SPRSyncState *s = (struct SPRSyncState *) arg.host_ptr; PowerPCCPU *cpu = POWERPC_CPU(cs); CPUPPCState *env = &cpu->env; @@ -37,7 +37,7 @@ static void set_spr(CPUState *cs, int spr, target_ulong value, .value = value, .mask = mask }; - run_on_cpu(cs, do_spr_sync, &s); + run_on_cpu(cs, do_spr_sync, RUN_ON_CPU_HOST_PTR(&s)); } static bool has_spr(PowerPCCPU *cpu, int spr) @@ -911,10 +911,10 @@ typedef struct { Error *err; } SetCompatState; -static void do_set_compat(CPUState *cs, void *arg) +static void do_set_compat(CPUState *cs, run_on_cpu_data arg) { PowerPCCPU *cpu = POWERPC_CPU(cs); - SetCompatState *s = arg; + SetCompatState *s = (SetCompatState *) arg.host_ptr; cpu_synchronize_state(cs); ppc_set_compat(cpu, s->cpu_version, &s->err); @@ -1017,7 +1017,7 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu_, .err = NULL, }; - run_on_cpu(cs, do_set_compat, &s); + run_on_cpu(cs, do_set_compat, RUN_ON_CPU_HOST_PTR(&s)); if (s.err) { error_report_err(s.err); diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 0c44b3c..d8e6702 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -231,7 +231,28 @@ struct kvm_run; #define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS) /* work queue */ -typedef void (*run_on_cpu_func)(CPUState *cpu, void *data); + +/* The union type allows passing of 64 bit target pointers on 32 bit + * hosts in a single parameter + */ +typedef union { + int host_int; + unsigned host_unsigned; + uintptr_t host_ptr; + void *void_ptr; /* for (run_on_cpu_data) NULL casts */ + vaddr target_ptr; +} run_on_cpu_data; + +static inline run_on_cpu_data roc_host_ptr(void * p) { + run_on_cpu_data d = { .host_ptr = (uintptr_t) p}; + return d; +} + +/* #define RUN_ON_CPU_HOST_PTR(p) ((run_on_cpu_data) (uintptr_t) p) */ +#define RUN_ON_CPU_HOST_PTR(p) roc_host_ptr(p) + +typedef void (*run_on_cpu_func)(CPUState *cpu, run_on_cpu_data data); + struct qemu_work_item; /** @@ -647,7 +668,7 @@ bool cpu_is_stopped(CPUState *cpu); * * Used internally in the implementation of run_on_cpu. */ -void do_run_on_cpu(CPUState *cpu, run_on_cpu_func func, void *data, +void do_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data, QemuMutex *mutex); /** @@ -658,7 +679,7 @@ void do_run_on_cpu(CPUState *cpu, run_on_cpu_func func, void *data, * * Schedules the function @func for execution on the vCPU @cpu. */ -void run_on_cpu(CPUState *cpu, run_on_cpu_func func, void *data); +void run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data); /** * async_run_on_cpu: @@ -668,7 +689,7 @@ void run_on_cpu(CPUState *cpu, run_on_cpu_func func, void *data); * * Schedules the function @func for execution on the vCPU @cpu asynchronously. */ -void async_run_on_cpu(CPUState *cpu, run_on_cpu_func func, void *data); +void async_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data); /** * async_safe_run_on_cpu: @@ -682,7 +703,7 @@ void async_run_on_cpu(CPUState *cpu, run_on_cpu_func func, void *data); * Unlike run_on_cpu and async_run_on_cpu, the function is run outside the * BQL. */ -void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func func, void *data); +void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data); /** * qemu_get_cpu: diff --git a/kvm-all.c b/kvm-all.c index efb5fe3..831189b 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1856,7 +1856,7 @@ void kvm_flush_coalesced_mmio_buffer(void) s->coalesced_flush_in_progress = false; } -static void do_kvm_cpu_synchronize_state(CPUState *cpu, void *arg) +static void do_kvm_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg) { if (!cpu->kvm_vcpu_dirty) { kvm_arch_get_registers(cpu); @@ -1867,11 +1867,11 @@ static void do_kvm_cpu_synchronize_state(CPUState *cpu, void *arg) void kvm_cpu_synchronize_state(CPUState *cpu) { if (!cpu->kvm_vcpu_dirty) { - run_on_cpu(cpu, do_kvm_cpu_synchronize_state, NULL); + run_on_cpu(cpu, do_kvm_cpu_synchronize_state, (run_on_cpu_data) NULL); } } -static void do_kvm_cpu_synchronize_post_reset(CPUState *cpu, void *arg) +static void do_kvm_cpu_synchronize_post_reset(CPUState *cpu, run_on_cpu_data arg) { kvm_arch_put_registers(cpu, KVM_PUT_RESET_STATE); cpu->kvm_vcpu_dirty = false; @@ -1879,10 +1879,10 @@ static void do_kvm_cpu_synchronize_post_reset(CPUState *cpu, void *arg) void kvm_cpu_synchronize_post_reset(CPUState *cpu) { - run_on_cpu(cpu, do_kvm_cpu_synchronize_post_reset, NULL); + run_on_cpu(cpu, do_kvm_cpu_synchronize_post_reset, (run_on_cpu_data) NULL); } -static void do_kvm_cpu_synchronize_post_init(CPUState *cpu, void *arg) +static void do_kvm_cpu_synchronize_post_init(CPUState *cpu, run_on_cpu_data arg) { kvm_arch_put_registers(cpu, KVM_PUT_FULL_STATE); cpu->kvm_vcpu_dirty = false; @@ -1890,7 +1890,7 @@ static void do_kvm_cpu_synchronize_post_init(CPUState *cpu, void *arg) void kvm_cpu_synchronize_post_init(CPUState *cpu) { - run_on_cpu(cpu, do_kvm_cpu_synchronize_post_init, NULL); + run_on_cpu(cpu, do_kvm_cpu_synchronize_post_init, (run_on_cpu_data) NULL); } int kvm_cpu_exec(CPUState *cpu) @@ -2219,9 +2219,10 @@ struct kvm_set_guest_debug_data { int err; }; -static void kvm_invoke_set_guest_debug(CPUState *unused_cpu, void *data) +static void kvm_invoke_set_guest_debug(CPUState *unused_cpu, run_on_cpu_data data) { - struct kvm_set_guest_debug_data *dbg_data = data; + struct kvm_set_guest_debug_data *dbg_data = + (struct kvm_set_guest_debug_data *) data.host_ptr; dbg_data->err = kvm_vcpu_ioctl(dbg_data->cpu, KVM_SET_GUEST_DEBUG, &dbg_data->dbg); @@ -2238,7 +2239,8 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap) } kvm_arch_update_guest_debug(cpu, &data.dbg); - run_on_cpu(cpu, kvm_invoke_set_guest_debug, &data); + run_on_cpu(cpu, kvm_invoke_set_guest_debug, + (run_on_cpu_data) (uintptr_t) &data); return data.err; } diff --git a/target-i386/helper.c b/target-i386/helper.c index 9bc961b..e2bade4 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -1121,9 +1121,9 @@ typedef struct MCEInjectionParams { int flags; } MCEInjectionParams; -static void do_inject_x86_mce(CPUState *cs, void *data) +static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data) { - MCEInjectionParams *params = data; + MCEInjectionParams *params = (MCEInjectionParams *) data.host_ptr; X86CPU *cpu = X86_CPU(cs); CPUX86State *cenv = &cpu->env; uint64_t *banks = cenv->mce_banks + 4 * params->bank; @@ -1230,7 +1230,7 @@ void cpu_x86_inject_mce(Monitor *mon, X86CPU *cpu, int bank, return; } - run_on_cpu(cs, do_inject_x86_mce, ¶ms); + run_on_cpu(cs, do_inject_x86_mce, RUN_ON_CPU_HOST_PTR(¶ms)); if (flags & MCE_INJECT_BROADCAST) { CPUState *other_cs; @@ -1243,7 +1243,7 @@ void cpu_x86_inject_mce(Monitor *mon, X86CPU *cpu, int bank, if (other_cs == cs) { continue; } - run_on_cpu(other_cs, do_inject_x86_mce, ¶ms); + run_on_cpu(other_cs, do_inject_x86_mce, RUN_ON_CPU_HOST_PTR(¶ms)); } } } diff --git a/target-i386/kvm.c b/target-i386/kvm.c index ee1f53e..f125d3f 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -150,7 +150,7 @@ static int kvm_get_tsc(CPUState *cs) return 0; } -static inline void do_kvm_synchronize_tsc(CPUState *cpu, void *arg) +static inline void do_kvm_synchronize_tsc(CPUState *cpu, run_on_cpu_data arg) { kvm_get_tsc(cpu); } @@ -161,7 +161,7 @@ void kvm_synchronize_all_tsc(void) if (kvm_enabled()) { CPU_FOREACH(cpu) { - run_on_cpu(cpu, do_kvm_synchronize_tsc, NULL); + run_on_cpu(cpu, do_kvm_synchronize_tsc, (run_on_cpu_data) NULL); } } } diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index 35ae2ce..20b4692 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -164,7 +164,7 @@ static void s390_cpu_machine_reset_cb(void *opaque) { S390CPU *cpu = opaque; - run_on_cpu(CPU(cpu), s390_do_cpu_full_reset, NULL); + run_on_cpu(CPU(cpu), s390_do_cpu_full_reset, (run_on_cpu_data) NULL); } #endif @@ -220,7 +220,7 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp) s390_cpu_gdb_init(cs); qemu_init_vcpu(cs); #if !defined(CONFIG_USER_ONLY) - run_on_cpu(cs, s390_do_cpu_full_reset, NULL); + run_on_cpu(cs, s390_do_cpu_full_reset, (run_on_cpu_data) NULL); #else cpu_reset(cs); #endif diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h index 4e58cde..fd36a25 100644 --- a/target-s390x/cpu.h +++ b/target-s390x/cpu.h @@ -502,13 +502,13 @@ static inline hwaddr decode_basedisp_s(CPUS390XState *env, uint32_t ipb, #define decode_basedisp_rs decode_basedisp_s /* helper functions for run_on_cpu() */ -static inline void s390_do_cpu_reset(CPUState *cs, void *arg) +static inline void s390_do_cpu_reset(CPUState *cs, run_on_cpu_data arg) { S390CPUClass *scc = S390_CPU_GET_CLASS(cs); scc->cpu_reset(cs); } -static inline void s390_do_cpu_full_reset(CPUState *cs, void *arg) +static inline void s390_do_cpu_full_reset(CPUState *cs, run_on_cpu_data arg) { cpu_reset(cs); } diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c index 5851e4d..53d3491 100644 --- a/target-s390x/misc_helper.c +++ b/target-s390x/misc_helper.c @@ -129,7 +129,7 @@ static int modified_clear_reset(S390CPU *cpu) pause_all_vcpus(); cpu_synchronize_all_states(); CPU_FOREACH(t) { - run_on_cpu(t, s390_do_cpu_full_reset, NULL); + run_on_cpu(t, s390_do_cpu_full_reset, (run_on_cpu_data) NULL); } s390_cmma_reset(); subsystem_reset(); @@ -148,7 +148,7 @@ static int load_normal_reset(S390CPU *cpu) pause_all_vcpus(); cpu_synchronize_all_states(); CPU_FOREACH(t) { - run_on_cpu(t, s390_do_cpu_reset, NULL); + run_on_cpu(t, s390_do_cpu_reset, (run_on_cpu_data) NULL); } s390_cmma_reset(); subsystem_reset(); diff --git a/translate-all.c b/translate-all.c index 79b763d..0b0631e 100644 --- a/translate-all.c +++ b/translate-all.c @@ -889,16 +889,14 @@ static void page_flush_tb(void) } /* flush all the translation blocks */ -static void do_tb_flush(CPUState *cpu, void *data) +static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) { - unsigned tb_flush_req = (unsigned) (uintptr_t) data; - tb_lock(); - /* If it's already been done on request of another CPU, + /* If it is already been done on request of another CPU, * just retry. */ - if (tcg_ctx.tb_ctx.tb_flush_count != tb_flush_req) { + if (tcg_ctx.tb_ctx.tb_flush_count != tb_flush_count.host_int) { goto done; } @@ -939,8 +937,9 @@ done: void tb_flush(CPUState *cpu) { if (tcg_enabled()) { - uintptr_t tb_flush_req = atomic_mb_read(&tcg_ctx.tb_ctx.tb_flush_count); - async_safe_run_on_cpu(cpu, do_tb_flush, (void *) tb_flush_req); + run_on_cpu_data tb_flush_count; + tb_flush_count.host_int = atomic_mb_read(&tcg_ctx.tb_ctx.tb_flush_count); + async_safe_run_on_cpu(cpu, do_tb_flush, tb_flush_count); } }