diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2016-10-31 10:36:08 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-10-31 15:00:25 +0100 |
commit | 14e6fe12a705c065fecdfd2a97199728123d4d9a (patch) | |
tree | c78875a95ca8fa9f6bac7dc95a1415f5dbfb7cfc /include/qom | |
parent | 12e9700d7a926aeb7f97a5d3c368bbe6745be884 (diff) |
*_run_on_cpu: introduce run_on_cpu_data type
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 <alex.bennee@linaro.org>
Message-Id: <20161027151030.20863-24-alex.bennee@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/qom')
-rw-r--r-- | include/qom/cpu.h | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 9f597bb0c0..3f79a8e955 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -231,7 +231,25 @@ 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 long host_ulong; + void *host_ptr; + vaddr target_ptr; +} run_on_cpu_data; + +#define RUN_ON_CPU_HOST_PTR(p) ((run_on_cpu_data){.host_ptr = (p)}) +#define RUN_ON_CPU_HOST_INT(i) ((run_on_cpu_data){.host_int = (i)}) +#define RUN_ON_CPU_HOST_ULONG(ul) ((run_on_cpu_data){.host_ulong = (ul)}) +#define RUN_ON_CPU_TARGET_PTR(v) ((run_on_cpu_data){.target_ptr = (v)}) +#define RUN_ON_CPU_NULL RUN_ON_CPU_HOST_PTR(NULL) + +typedef void (*run_on_cpu_func)(CPUState *cpu, run_on_cpu_data data); + struct qemu_work_item; /** @@ -637,7 +655,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); /** @@ -648,7 +666,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: @@ -658,7 +676,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: @@ -672,7 +690,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: |