* [Qemu-devel] [PATCH 0/2] tcg: Move TCG arch-specific initialization inside TCG code
@ 2014-12-19 4:26 Eduardo Habkost
2014-12-19 4:26 ` [Qemu-devel] [PATCH 1/2] tcg: Introduce tcg_arch_init() function Eduardo Habkost
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Eduardo Habkost @ 2014-12-19 4:26 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, Andreas Färber, rth
Many architectures manually call arch-specific TCG initialization at CPU init
time[1], instead of having tcg_init() doing all initialization steps. This
series introduces a tcg_arch_init() function that may be implemented by
architecture-specific code for TCG initialization.
[1] You can see it by grepping for "inited" on target-*/cpu.c.
Eduardo Habkost (2):
tcg: Introduce tcg_arch_init() function
target-i386: Implement tcg_arch_init()
include/qemu-common.h | 1 +
stubs/Makefile.objs | 1 +
stubs/tcg.c | 5 +++++
target-i386/cpu.c | 7 -------
target-i386/translate.c | 2 +-
translate-all.c | 1 +
6 files changed, 9 insertions(+), 8 deletions(-)
create mode 100644 stubs/tcg.c
--
1.9.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 1/2] tcg: Introduce tcg_arch_init() function
2014-12-19 4:26 [Qemu-devel] [PATCH 0/2] tcg: Move TCG arch-specific initialization inside TCG code Eduardo Habkost
@ 2014-12-19 4:26 ` Eduardo Habkost
2014-12-19 14:05 ` Richard Henderson
2014-12-19 4:26 ` [Qemu-devel] [PATCH 2/2] target-i386: Implement tcg_arch_init() Eduardo Habkost
2014-12-19 9:47 ` [Qemu-devel] [PATCH 0/2] tcg: Move TCG arch-specific initialization inside TCG code Andreas Färber
2 siblings, 1 reply; 7+ messages in thread
From: Eduardo Habkost @ 2014-12-19 4:26 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, Andreas Färber, rth
Many architectures have arch-specific initialization functions that are
called from CPU initialization at target-*/cpu.c.
Instead of requiring the CPU code to keep track of TCG initialization,
let an arch-specific init function to be defined, and it will get called
by tcg_exec_init().
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
include/qemu-common.h | 1 +
stubs/Makefile.objs | 1 +
stubs/tcg.c | 5 +++++
translate-all.c | 1 +
4 files changed, 8 insertions(+)
create mode 100644 stubs/tcg.c
diff --git a/include/qemu-common.h b/include/qemu-common.h
index f862214..5ea8070 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -269,6 +269,7 @@ typedef struct PCIHostDeviceAddress {
void tcg_exec_init(unsigned long tb_size);
bool tcg_enabled(void);
+void tcg_arch_init(void);
void cpu_exec_init_all(void);
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 5e347d0..240f270 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -40,3 +40,4 @@ stub-obj-$(CONFIG_WIN32) += fd-register.o
stub-obj-y += cpus.o
stub-obj-y += kvm.o
stub-obj-y += qmp_pc_dimm_device_list.o
+stub-obj-y += tcg.o
diff --git a/stubs/tcg.c b/stubs/tcg.c
new file mode 100644
index 0000000..15a11d6
--- /dev/null
+++ b/stubs/tcg.c
@@ -0,0 +1,5 @@
+#include "qemu-common.h"
+
+void tcg_arch_init(void)
+{
+}
diff --git a/translate-all.c b/translate-all.c
index c24cfe8..8e15a78 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -702,6 +702,7 @@ void tcg_exec_init(unsigned long tb_size)
initialize the prologue now. */
tcg_prologue_init(&tcg_ctx);
#endif
+ tcg_arch_init();
}
bool tcg_enabled(void)
--
1.9.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 2/2] target-i386: Implement tcg_arch_init()
2014-12-19 4:26 [Qemu-devel] [PATCH 0/2] tcg: Move TCG arch-specific initialization inside TCG code Eduardo Habkost
2014-12-19 4:26 ` [Qemu-devel] [PATCH 1/2] tcg: Introduce tcg_arch_init() function Eduardo Habkost
@ 2014-12-19 4:26 ` Eduardo Habkost
2014-12-19 9:47 ` [Qemu-devel] [PATCH 0/2] tcg: Move TCG arch-specific initialization inside TCG code Andreas Färber
2 siblings, 0 replies; 7+ messages in thread
From: Eduardo Habkost @ 2014-12-19 4:26 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, Andreas Färber, rth
With tcg_arch_init(), we can finally remove the "inited" variable from
x86_cpu_initfn().
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target-i386/cpu.c | 7 -------
target-i386/translate.c | 2 +-
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index b81ac5c..dee112d 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2885,7 +2885,6 @@ static void x86_cpu_initfn(Object *obj)
X86CPU *cpu = X86_CPU(obj);
X86CPUClass *xcc = X86_CPU_GET_CLASS(obj);
CPUX86State *env = &cpu->env;
- static int inited;
cs->env_ptr = env;
cpu_exec_init(env);
@@ -2928,12 +2927,6 @@ static void x86_cpu_initfn(Object *obj)
env->cpuid_apic_id = x86_cpu_apic_id_from_index(cs->cpu_index);
x86_cpu_load_def(cpu, xcc->cpu_def, &error_abort);
-
- /* init various static tables used in TCG mode */
- if (tcg_enabled() && !inited) {
- inited = 1;
- optimize_flags_init();
- }
}
static int64_t x86_cpu_get_arch_id(CPUState *cs)
diff --git a/target-i386/translate.c b/target-i386/translate.c
index fc75da7..10b9cc2 100644
--- a/target-i386/translate.c
+++ b/target-i386/translate.c
@@ -7841,7 +7841,7 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s,
return s->pc;
}
-void optimize_flags_init(void)
+void tcg_arch_init(void)
{
static const char reg_names[CPU_NB_REGS][4] = {
#ifdef TARGET_X86_64
--
1.9.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] tcg: Move TCG arch-specific initialization inside TCG code
2014-12-19 4:26 [Qemu-devel] [PATCH 0/2] tcg: Move TCG arch-specific initialization inside TCG code Eduardo Habkost
2014-12-19 4:26 ` [Qemu-devel] [PATCH 1/2] tcg: Introduce tcg_arch_init() function Eduardo Habkost
2014-12-19 4:26 ` [Qemu-devel] [PATCH 2/2] target-i386: Implement tcg_arch_init() Eduardo Habkost
@ 2014-12-19 9:47 ` Andreas Färber
2014-12-19 10:29 ` Paolo Bonzini
2 siblings, 1 reply; 7+ messages in thread
From: Andreas Färber @ 2014-12-19 9:47 UTC (permalink / raw)
To: Eduardo Habkost, qemu-devel; +Cc: Paolo Bonzini, rth
Am 19.12.2014 um 05:26 schrieb Eduardo Habkost:
> Many architectures manually call arch-specific TCG initialization at CPU init
> time[1], instead of having tcg_init() doing all initialization steps. This
> series introduces a tcg_arch_init() function that may be implemented by
> architecture-specific code for TCG initialization.
How do you imagine this to work with multiple CPU types? From the looks
of it, this is for the target CPU, not the TCG architecture, so
tcg_arch_init() limits us to one implementation unlike now.
On the other hand it doesn't seem to be a per-CPU, i.e. CPUClass,
initialization either...
Regards,
Andreas
--
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 21284 AG Nürnberg
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] tcg: Move TCG arch-specific initialization inside TCG code
2014-12-19 9:47 ` [Qemu-devel] [PATCH 0/2] tcg: Move TCG arch-specific initialization inside TCG code Andreas Färber
@ 2014-12-19 10:29 ` Paolo Bonzini
2014-12-19 13:16 ` Eduardo Habkost
0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2014-12-19 10:29 UTC (permalink / raw)
To: Andreas Färber, Eduardo Habkost, qemu-devel; +Cc: rth
On 19/12/2014 10:47, Andreas Färber wrote:
> How do you imagine this to work with multiple CPU types? From the looks
> of it, this is for the target CPU, not the TCG architecture, so
> tcg_arch_init() limits us to one implementation unlike now.
> On the other hand it doesn't seem to be a per-CPU, i.e. CPUClass,
> initialization either...
I think these should go in a separate CPUClass method that is called by
tcg_exec_init (only for first_cpu now; later for all CPUs if each CPU
gets a separate tcg_ctx).
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] tcg: Move TCG arch-specific initialization inside TCG code
2014-12-19 10:29 ` Paolo Bonzini
@ 2014-12-19 13:16 ` Eduardo Habkost
0 siblings, 0 replies; 7+ messages in thread
From: Eduardo Habkost @ 2014-12-19 13:16 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: rth, Andreas Färber, qemu-devel
On Fri, Dec 19, 2014 at 11:29:34AM +0100, Paolo Bonzini wrote:
> On 19/12/2014 10:47, Andreas Färber wrote:
> > How do you imagine this to work with multiple CPU types? From the looks
> > of it, this is for the target CPU, not the TCG architecture, so
> > tcg_arch_init() limits us to one implementation unlike now.
> > On the other hand it doesn't seem to be a per-CPU, i.e. CPUClass,
> > initialization either...
>
> I think these should go in a separate CPUClass method that is called by
> tcg_exec_init (only for first_cpu now; later for all CPUs if each CPU
> gets a separate tcg_ctx).
configure_accelerator() (and tcg_exec_init()) is called before
machine_class->init() (where the CPUs are created).
I have work in progress that introduces arch-specific TYPE_ACCEL
subclasses. With this, we can then make tcg_arch_init() a TYPE_TCG_ACCEL
method that arch-specific TYPE_TCG_ACCEL subclasses can implement.
Is it already possible to build a QEMU binary with multiple TCG arches,
today?
--
Eduardo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] tcg: Introduce tcg_arch_init() function
2014-12-19 4:26 ` [Qemu-devel] [PATCH 1/2] tcg: Introduce tcg_arch_init() function Eduardo Habkost
@ 2014-12-19 14:05 ` Richard Henderson
0 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2014-12-19 14:05 UTC (permalink / raw)
To: Eduardo Habkost, qemu-devel; +Cc: Paolo Bonzini, Andreas Färber
On 12/18/2014 10:26 PM, Eduardo Habkost wrote:
> +void tcg_arch_init(void);
I'm not keen on the name, because it's fairly ambiguous whether "arch" is
talking about the host or target. It doesn't help that "tcg_target" is the
host. ;-P
Assuming we do this (see hook discussion), what about "translator" instead?
r~
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-12-19 14:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-19 4:26 [Qemu-devel] [PATCH 0/2] tcg: Move TCG arch-specific initialization inside TCG code Eduardo Habkost
2014-12-19 4:26 ` [Qemu-devel] [PATCH 1/2] tcg: Introduce tcg_arch_init() function Eduardo Habkost
2014-12-19 14:05 ` Richard Henderson
2014-12-19 4:26 ` [Qemu-devel] [PATCH 2/2] target-i386: Implement tcg_arch_init() Eduardo Habkost
2014-12-19 9:47 ` [Qemu-devel] [PATCH 0/2] tcg: Move TCG arch-specific initialization inside TCG code Andreas Färber
2014-12-19 10:29 ` Paolo Bonzini
2014-12-19 13:16 ` Eduardo Habkost
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).