Add --disable-tcg
cover Add --disable-tcg
This is an old series from Anthony that was never committed. Now that QEMU does not use ARG0 anymore, it is much simpler to move things to and from the helper.c files as needed to remove most of the TCG code from non-TCG builds.
Of course we're still a long way from there, since cpu-exec.c is intimately linked with exec.c, but we can already add a --disable-tcg option that works, and disable some lengthy parts of the build when using it.
Patches that make s390 and ppc work with --disable-tcg (along the lines of patch 9) are welcome. I'm not going to do that myself otherwise, sorry.
Paolo
Anthony Liguori (2):
vl: implement tcg_enabled() and tcg_available() as for other accelerators
configure: add --disable-tcg configure option
Paolo Bonzini (9):
configure: factor out list of supported Xen/KVM targets
configure: add CONFIG_TCG=y to config-host.mak
tcg: change cpu_restore_state to return void
exec: small adjustments for TCG separation
monitor: disable info jit if !TCG
configure: emit summary at the very end
i386: move TCG functions out of helper.o, non-TCG functions to cpu.o
build: do not build TCG files if TCG is disabled
Makefile.target | 5 +- arch_init.c | 4 + configure | 278 ++++++++++++++++++++++++++-------------------- cpu-exec.c | 2 + exec-all.h | 20 +++- exec.c | 68 +++++++----- monitor.c | 4 + qemu-common.h | 8 +- target-i386/Makefile.objs | 7 +- target-i386/cpu.c | 18 +++ target-i386/excp_helper.c | 24 ++++ target-i386/fpu_helper.c | 18 --- target-i386/helper.c | 24 ---- translate-all.c | 9 +- vl.c | 2 +-
15 file modificati, 289 inserzioni(+), 207 rimozioni(-)
Signature · 1 line
1.7.12
RFC PATCH 1/10 configure: factor out list of supported Xen/KVM targets
--- configure | 63 +++++++++++++++++++++++++++++++++++++--------------------------
1 file modificato, 37 inserzioni(+), 26 rimozioni(-)
configure +37 -26
@@ -3664,6 +3664,31 @@ if test "$linux" = "yes" ; then fi fi +supported_kvm_target() { + test "$kvm" = "yes" || return 1 + test "$target_softmmu" = "yes" || return 1 + case "$target_arch2:$cpu" in + i386:i386 | i386:x86_64 | x86_64:i386 | x86_64:x86_64 | \ + ppc:ppc | ppcemb:ppc | ppc64:ppc | \ + ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \ + s390x:s390x) + return 0 + ;; + esac + return 1 +} + +supported_xen_target() { + test "$xen" = "yes" || return 1 + test "$target_softmmu" = "yes" || return 1 + case "$target_arch2:$cpu" in + i386:i386 | i386:x86_64 | x86_64:i386 | x86_64:x86_64) + return 0 + ;; + esac + return 1 +} + for target in $target_list; do target_dir="$target" config_target_mak=$target_dir/config-target.mak
@@ -3886,38 +3911,24 @@ if [ "$TARGET_ABI_DIR" = "" ]; then TARGET_ABI_DIR=$TARGET_ARCH fi echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak -case "$target_arch2" in - i386|x86_64) - if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then - target_phys_bits=64 - echo "CONFIG_XEN=y" >> $config_target_mak - if test "$xen_pci_passthrough" = yes; then + +if supported_xen_target; then + target_phys_bits=64 + echo "CONFIG_XEN=y" >> $config_target_mak + if test "$xen_pci_passthrough" = yes; then echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" - fi - else - echo "CONFIG_NO_XEN=y" >> $config_target_mak fi - ;; - *) +else echo "CONFIG_NO_XEN=y" >> $config_target_mak -esac -case "$target_arch2" in - i386|x86_64|ppcemb|ppc|ppc64|s390x) +fi +if supported_kvm_target; then # Make sure the target and host cpus are compatible - if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \ - \( "$target_arch2" = "$cpu" -o \ - \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \ - \( "$target_arch2" = "ppc64" -a "$cpu" = "ppc" \) -o \ - \( "$target_arch2" = "ppc" -a "$cpu" = "ppc64" \) -o \ - \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \ - \( "$target_arch2" = "x86_64" -a "$cpu" = "i386" \) -o \ - \( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then - echo "CONFIG_KVM=y" >> $config_target_mak - if test "$vhost_net" = "yes" ; then + echo "CONFIG_KVM=y" >> $config_target_mak + if test "$vhost_net" = "yes" ; then echo "CONFIG_VHOST_NET=y" >> $config_target_mak - fi fi -esac +fi + case "$target_arch2" in i386|x86_64) echo "CONFIG_HAVE_GET_MEMORY_MAPPING=y" >> $config_target_mak
Signature · 1 line
1.7.12
Re: [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets
Quoted 27 lines · Paolo Bonzini
Signed-off-by Paolo Bonzini <[email protected]>--- configure | 63 +++++++++++++++++++++++++++++++++++++--------------------------1 file modificato, 37 inserzioni(+), 26 rimozioni(-)
configure +14
-0@@ -3664,6 +3664,31 @@ if test "$linux" = "yes" ; then fi fi +supported_kvm_target() { + test "$kvm" = "yes" || return 1 + test "$target_softmmu" = "yes" || return 1 + case "$target_arch2:$cpu" in + i386:i386 | i386:x86_64 | x86_64:i386 | x86_64:x86_64 | \ + ppc:ppc | ppcemb:ppc | ppc64:ppc | \ + ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \ + s390x:s390x) + return 0 + ;; + esac + return 1 +} +
configure if test "$linux" = "yes" ; then · line 3690
Quoted 10 lines
configure +10
-0+supported_xen_target() { + test "$xen" = "yes" || return 1 + test "$target_softmmu" = "yes" || return 1 + case "$target_arch2:$cpu" in + i386:i386 | i386:x86_64 | x86_64:i386 | x86_64:x86_64) + return 0 + ;; + esac + return 1 +}
This is a change in behaviour, isn't it? The old configure code enables CONFIG_XEN based only on $target_arch2, it doesn't try to ensure that the host and target CPU are the same architecture. Granted, that looks like a bug, but it should probably be fixed in a separate patch to this kind of refactoring patch.
Quoted 7 lines
configure +1
-0+ for target in $target_list; do target_dir="$target" config_target_mak=$target_dir/config-target.mak@@ -3886,38 +3911,24 @@ if [ "$TARGET_ABI_DIR" = "" ]; then TARGET_ABI_DIR=$TARGET_ARCH fi
configure if [ "$TARGET_ABI_DIR" = "" ]; then · line 3916
Quoted 10 lines
configure +3
-6echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak -case "$target_arch2" in - i386|x86_64) - if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then - target_phys_bits=64 - echo "CONFIG_XEN=y" >> $config_target_mak - if test "$xen_pci_passthrough" = yes; then + +if supported_xen_target; then + target_phys_bits=64
...and while I'm looking at this code, this looks kind of bogus. If Xen requires 64 bit physaddrs it should probably just be asserting this here, not randomly changing target_phys_bits. In fact all the supported Xen target archs already have 64 bit physaddrs, so it's harmless. But if there ever were a target Xen arch which didn't support 64 bit phys addrs then the right approach would be to convert it to do so regardless of whether we were using Xen or not.
Quoted 39 lines
configure +9
-21+ echo "CONFIG_XEN=y" >> $config_target_mak + if test "$xen_pci_passthrough" = yes; then echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" - fi - else - echo "CONFIG_NO_XEN=y" >> $config_target_mak fi - ;; - *) +else echo "CONFIG_NO_XEN=y" >> $config_target_mak -esac -case "$target_arch2" in - i386|x86_64|ppcemb|ppc|ppc64|s390x) +fi +if supported_kvm_target; then # Make sure the target and host cpus are compatible - if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \ - \( "$target_arch2" = "$cpu" -o \ - \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \ - \( "$target_arch2" = "ppc64" -a "$cpu" = "ppc" \) -o \ - \( "$target_arch2" = "ppc" -a "$cpu" = "ppc64" \) -o \ - \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \ - \( "$target_arch2" = "x86_64" -a "$cpu" = "i386" \) -o \ - \( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then - echo "CONFIG_KVM=y" >> $config_target_mak - if test "$vhost_net" = "yes" ; then + echo "CONFIG_KVM=y" >> $config_target_mak + if test "$vhost_net" = "yes" ; then echo "CONFIG_VHOST_NET=y" >> $config_target_mak - fi fi -esac +fi + case "$target_arch2" in i386|x86_64) echo "CONFIG_HAVE_GET_MEMORY_MAPPING=y" >> $config_target_mak --
Quoted 4 lines
1.7.12
-- PMM
Re: [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets
Il 17/09/2012 19:02, Peter Maydell ha scritto:
Quoted 6 lines
If Xen requires 64 bit physaddrs it should probably just be asserting this here, not randomly changing
target_phys_bits. In fact all the supported Xen target archs already have 64 bit physaddrs, so it's harmless. But if there ever were a target Xen arch which didn't support 64 bit phys addrs then the right approach would be to convert it to do so regardless of whether we were using Xen or not.
No, Xen does not require 64-bit physaddrs, but it supports them even if you build it for 32-bit. Memory is accessed through a "hole" (the mapcache) provided by the hypervisor, so that a 32-bit QEMU address space is enough to run 64-bit guests. At least that's my understanding.
Paolo
Re: [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets
Quoted 10 lines · Paolo Bonzini
Il 17/09/2012 19:02, Peter Maydell ha scritto:
Quoted 6 lines
If Xen requires 64 bit physaddrs it should probably just be asserting this here, not randomly changing
target_phys_bits. In fact all the supported Xen target archs already have 64 bit physaddrs, so it's harmless. But if there ever were a target Xen arch which didn't support 64 bit phys addrs then the right approach would be to convert it to do so regardless of whether we were using Xen or not.No, Xen does not require 64-bit physaddrs, but it supports them even if you build it for 32-bit.
If it doesn't require them then it definitely shouldn't be messing with the value of target_phys_bits in configure...
-- PMM
Re: [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets
In reply to Paolo BonziniQuoted 8 lines · Paolo Bonzini
Il 17/09/2012 19:02, Peter Maydell ha scritto:
Quoted 6 lines
If Xen requires 64 bit physaddrs it should probably just be asserting this here, not randomly changing
target_phys_bits. In fact all the supported Xen target archs already have 64 bit physaddrs, so it's harmless. But if there ever were a target Xen arch which didn't support 64 bit phys addrs then the right approach would be to convert it to do so regardless of whether we were using Xen or not.
Quoted 4 lines
No, Xen does not require 64-bit physaddrs, but it supports them even if you build it for 32-bit. Memory is accessed through a "hole" (the mapcache) provided by the hypervisor, so that a 32-bit QEMU address space is enough to run 64-bit guests. At least that's my understanding.
Xen requires 64 bit physaddrs because no matter what the specified arch of the host or the guest at configure time is, the guest could still be 64 bit. In other words: the arch of the guest and the arch of the host are irrelevant on Xen and physaddrs should always be 64 bit.
Re: [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets
In reply to Peter MaydellQuoted 36 lines · Peter Maydell
Quoted 35 lines · Paolo Bonzini
Signed-off-by Paolo Bonzini <[email protected]>--- configure | 63 +++++++++++++++++++++++++++++++++++++--------------------------1 file modificato, 37 inserzioni(+), 26 rimozioni(-)
configure +22
-0@@ -3664,6 +3664,31 @@ if test "$linux" = "yes" ; then fi fi +supported_kvm_target() { + test "$kvm" = "yes" || return 1 + test "$target_softmmu" = "yes" || return 1 + case "$target_arch2:$cpu" in + i386:i386 | i386:x86_64 | x86_64:i386 | x86_64:x86_64 | \ + ppc:ppc | ppcemb:ppc | ppc64:ppc | \ + ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \ + s390x:s390x) + return 0 + ;; + esac + return 1 +} + +supported_xen_target() { + test "$xen" = "yes" || return 1 + test "$target_softmmu" = "yes" || return 1 + case "$target_arch2:$cpu" in + i386:i386 | i386:x86_64 | x86_64:i386 | x86_64:x86_64) + return 0 + ;; + esac
Quoted 8 lines
configure if test "$linux" = "yes" ; then · line 3690
Quoted 2 lines
configure +2
-0+ return 1 +}This is a change in behaviour, isn't it? The old configure code enables
CONFIG_XENbased only on $target_arch2, it doesn't try to ensure that the host and target CPU are the same architecture. Granted, that looks like a bug, but it should probably be fixed in a separate patch to this kind of refactoring patch.
That's because the target cpu is irrelevant, QEMU never sees it (it is only a device emulator on Xen).
I have no problems with the introduction of supported_xen_target(), but I would prefer if you could avoid $cpu tests.
Quoted 17 lines
Quoted 6 lines
configure +0
-0for target in $target_list; do target_dir="$target" config_target_mak=$target_dir/config-target.mak@@ -3886,38 +3911,24 @@ if [ "$TARGET_ABI_DIR" = "" ]; then TARGET_ABI_DIR=$TARGET_ARCH ficonfigure if [ "$TARGET_ABI_DIR" = "" ]; then · line 3916
Quoted 10 lines
configure +3
-6echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak -case "$target_arch2" in - i386|x86_64) - if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then - target_phys_bits=64 - echo "CONFIG_XEN=y" >> $config_target_mak - if test "$xen_pci_passthrough" = yes; then + +if supported_xen_target; then + target_phys_bits=64
Quoted 7 lines
...and while I'm looking at this code, this looks kind of bogus. If Xen requires 64 bit physaddrs it should probably just be asserting this here, not randomly changing
target_phys_bits. In fact all the supported Xen target archs already have 64 bit physaddrs, so it's harmless. But if there ever were a target Xen arch which didn't support 64 bit phys addrs then the right approach would be to convert it to do so regardless of whether we were using Xen or not.
I have just noticed that nowadays even i386 sets target_phys_bits to 64. In that case we can remove these two lines.
Re: [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets
Quoted 46 lines · Stefano Stabellini
Quoted 36 lines · Peter Maydell
Quoted 35 lines · Paolo Bonzini
Signed-off-by Paolo Bonzini <[email protected]>--- configure | 63 +++++++++++++++++++++++++++++++++++++--------------------------1 file modificato, 37 inserzioni(+), 26 rimozioni(-)
configure +22
-0@@ -3664,6 +3664,31 @@ if test "$linux" = "yes" ; then fi fi +supported_kvm_target() { + test "$kvm" = "yes" || return 1 + test "$target_softmmu" = "yes" || return 1 + case "$target_arch2:$cpu" in + i386:i386 | i386:x86_64 | x86_64:i386 | x86_64:x86_64 | \ + ppc:ppc | ppcemb:ppc | ppc64:ppc | \ + ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \ + s390x:s390x) + return 0 + ;; + esac + return 1 +} + +supported_xen_target() { + test "$xen" = "yes" || return 1 + test "$target_softmmu" = "yes" || return 1 + case "$target_arch2:$cpu" in + i386:i386 | i386:x86_64 | x86_64:i386 | x86_64:x86_64) + return 0 + ;; + esacQuoted 8 lines
configure if test "$linux" = "yes" ; then · line 3690
Quoted 2 lines
configure +2
-0+ return 1 +}This is a change in behaviour, isn't it? The old configure code enables
CONFIG_XENbased only on $target_arch2, it doesn't try to ensure that the host and target CPU are the same architecture. Granted, that looks like a bug, but it should probably be fixed in a separate patch to this kind of refactoring patch.
Quoted 4 lines
That's because the target cpu is irrelevant, QEMU never sees it (it is only a device emulator on Xen).
I have no problems with the introduction ofsupported_xen_target(), but I would prefer if you could avoid $cpu tests.
Reading again what you wrote and the relevant code, I think that you meant that both host and guest should be x86 machines (rather than one being ARM and the other x86). In that case I agree and I think it is OK to make the change in this patch.
Paolo's test supports both i386:x86_64 and x86_64:i386, so I think should be OK.
Re: [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets
Quoted 13 lines · Stefano Stabellini
Quoted 11 lines · Stefano Stabellini
Quoted 5 lines · Peter Maydell
This is a change in behaviour, isn't it? The old configure code enables
CONFIG_XENbased only on $target_arch2, it doesn't try to ensure that the host and target CPU are the same architecture. Granted, that looks like a bug, but it should probably be fixed in a separate patch to this kind of refactoring patch.That's because the target cpu is irrelevant, QEMU never sees it (it is only a device emulator on Xen).
I have no problems with the introduction ofsupported_xen_target(), but I would prefer if you could avoid $cpu tests.
Quoted 4 lines
Reading again what you wrote and the relevant code, I think that you meant that both host and guest should be x86 machines (rather than one being ARM and the other x86). In that case I agree and I think it is OK to make the change in this patch.
Yes, that is what I meant, sorry: at the moment if you build an x86 softmmu target on an ARM host and your ARM host has Xen headers we'll try to enable Xen when it's not going to work.
Quoted 2 lines
Paolo's test supports both i386:x86_64 and x86_64:i386, so I think should be OK.
Yes, the final result looks OK, I'd just like it split out from the refactoring part, ideally.
-- PMM
RFC PATCH 2/10 configure: add CONFIG_TCG=y to config-host.mak
In reply to Paolo Bonzini--- configure | 1 +
1 file modificato, 1 inserzione(+)
configure +1 -0
@@ -3459,6 +3459,7 @@ fi if test "$signalfd" = "yes" ; then echo "CONFIG_SIGNALFD=y" >> $config_host_mak fi +echo "CONFIG_TCG=y" >> $config_host_mak if test "$tcg_interpreter" = "yes" ; then echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak fi
Signature · 1 line
1.7.12
RFC PATCH 3/10 vl: implement tcg_enabled() and tcg_available() as for other accelerators
In reply to Paolo BonziniFrom: Anthony Liguori <[email protected]>
This way, tcg_enabled() can be used to stub out entire sections of code that are not used on TCG. This will limit the use of #ifdef and improves code checking from the compiler.
--- arch_init.c | 4 ++++ exec.c | 6 +----- qemu-common.h | 8 +++++++- vl.c | 2 +-
4 file modificati, 13 inserzioni(+), 7 rimozioni(-)
arch_init.c +4 -0
@@ -1061,7 +1061,11 @@ int audio_available(void)int tcg_available (void ) { +#if defined(CONFIG_TCG )return 1 ; +#else +return 0 ; +#endif }int kvm_available (void )
exec.c +1 -5
@@ -615,6 +615,7 @@ static void code_gen_alloc(unsigned long tb_size)size. */ void tcg_exec_init (unsigned long tb_size) { + tcg_allowed =1 ;cpu_gen_init ();code_gen_alloc (tb_size); code_gen_ptr = code_gen_buffer;
@@ -627,11 +628,6 @@ void tcg_exec_init(unsigned long tb_size)#endif } -bool tcg_enabled (void ) -{ -return code_gen_buffer !=NULL ; -} -void cpu_exec_init_all (void ) {#if !defined(CONFIG_USER_ONLY )
qemu-common.h +7 -1
@@ -301,8 +301,14 @@ typedef struct PCIHostDeviceAddress {unsigned int function; } PCIHostDeviceAddress; +extern int tcg_allowed;void tcg_exec_init (unsigned long tb_size); -bool tcg_enabled (void ); + +#ifdef CONFIG_TCG +#define tcg_enabled () (tcg_allowed) +#else +#define tcg_enabled () 0 +#endif void cpu_exec_init_all (void );
vl.c +1 -1
@@ -260,7 +260,7 @@ static NotifierList exit_notifiers =static NotifierList machine_init_done_notifiers =NOTIFIER_LIST_INITIALIZER (machine_init_done_notifiers); -static int tcg_allowed =1 ; +int tcg_allowed =0 ;int kvm_allowed =0 ;int xen_allowed =0 ;uint32_t xen_domid;
Signature · 1 line
1.7.12
RFC PATCH 4/10 tcg: change cpu_restore_state to return void
In reply to Paolo BonziniThe return value is used nowhere.
--- exec-all.h | 4 ++-- translate-all.c | 9 ++++-----
2 file modificati, 6 inserzioni(+), 7 rimozioni(-)
exec-all.h +2 -2
@@ -84,8 +84,8 @@ void restore_state_to_opc(CPUArchState *env, struct TranslationBlock *tb,void cpu_gen_init (void );int cpu_gen_code (CPUArchState *env,struct TranslationBlock *tb,int *gen_code_size_ptr); -int cpu_restore_state (struct TranslationBlock *tb, -CPUArchState *env,uintptr_t searched_pc); +void cpu_restore_state (struct TranslationBlock *tb, +CPUArchState *env,uintptr_t searched_pc); void QEMU_NORETURN cpu_resume_from_signal(CPUArchState *env1, void *puc); void QEMU_NORETURN cpu_io_recompile(CPUArchState *env, uintptr_t retaddr); TranslationBlock *tb_gen_code(CPUArchState *env,
translate-all.c +4 -5
@@ -108,8 +108,8 @@ int cpu_gen_code(CPUArchState *env, TranslationBlock *tb, int *gen_code_size_ptr/* The cpu state corresponding to 'searched_pc' is restored. */ -int cpu_restore_state (TranslationBlock *tb, -CPUArchState *env,uintptr_t searched_pc) +void cpu_restore_state (TranslationBlock *tb, +CPUArchState *env,uintptr_t searched_pc) {TCGContext *s = &tcg_ctx;int j;
@@ -135,7 +135,7 @@ int cpu_restore_state(TranslationBlock *tb,/* find opc index corresponding to search_pc */ tc_ptr = (uintptr_t )tb->tc_ptr;if (searched_pc < tc_ptr) -return -1 ; +return ; s->tb_next_offset = tb->tb_next_offset;#ifdef USE_DIRECT_JUMP
@@ -147,7 +147,7 @@ int cpu_restore_state(TranslationBlock *tb,#endif j =tcg_gen_code_search_pc (s, (uint8_t *)tc_ptr, searched_pc - tc_ptr);if (j <0 ) -return -1 ; +return ;/* now find start of instruction before */ while (gen_opc_instr_start[j] ==0 ) j--;
@@ -159,5 +159,4 @@ int cpu_restore_state(TranslationBlock *tb, s->restore_time +=profile_getclock () - ti; s->restore_count++;#endif -return 0 ; }
Signature · 1 line
1.7.12
Re: [Qemu-devel] [RFC PATCH 04/10] tcg: change cpu_restore_state to return void
Quoted 1 line · Paolo Bonzini
The return value is used nowhere.
...it looks like we should probably assert() rather than ploughing blindly forward if we try to restore state to match a PC value and it doesn't work for some reason.
-- PMM
Re: [Qemu-devel] [RFC PATCH 04/10] tcg: change cpu_restore_state to return void
Il 17/09/2012 19:06, Peter Maydell ha scritto:
Quoted 4 lines
Quoted 1 line
Quoted 1 line
The return value is used nowhere.
...it looks like we should probably
assert()rather than ploughing blindly forward if we try to restore state to match a PC value and it doesn't work for some reason.
Couldn't that mean simply that the tb for instance wasn't mapped anywhere? That's the KVM case, at least.
Paolo
Re: [Qemu-devel] [RFC PATCH 04/10] tcg: change cpu_restore_state to return void
Quoted 8 lines · Paolo Bonzini
Il 17/09/2012 19:06, Peter Maydell ha scritto:
Quoted 4 lines
Quoted 1 line
Quoted 1 line
The return value is used nowhere.
...it looks like we should probably
assert()rather than ploughing blindly forward if we try to restore state to match a PC value and it doesn't work for some reason.Couldn't that mean simply that the tb for instance wasn't mapped anywhere? That's the KVM case, at least.
Hmm. For TCG there are certainly some cases where failure to cpu_restore_state() means that the current CPU state is now broken; that should be fatal (and I'm not sure there are any cases where failure is OK. I think calls are generally protected by checking that tb_find_pc() returned non-NULL, so we shouldn't be trying to restore state unless we really were in the middle of a TB that we know about and can translate.)
I'm not sure what the TB concept means for KVM -- after all KVM doesn't do any translation...
-- PMM
Re: [Qemu-devel] [RFC PATCH 04/10] tcg: change cpu_restore_state to return void
Il 17/09/2012 19:20, Peter Maydell ha scritto:
Quoted 10 lines
Quoted 2 lines
Quoted 2 lines
Couldn't that mean simply that the tb for instance wasn't mapped anywhere? That's the KVM case, at least.
Hmm. For TCG there are certainly some cases where failure to
cpu_restore_state()means that the current CPU state is now broken; that should be fatal (and I'm not sure there are any cases where failure is OK. I think calls are generally protected by checking thattb_find_pc()returned non-NULL, so we shouldn't be trying to restore state unless we really were in the middle of a TB that we know about and can translate.)
Quoted 2 lines
I'm not sure what the TB concept means for KVM -- after all KVM doesn't do any translation...
Nothing, but in some cases cpu_restore_state() is called from exception handling helpers or something like that. My knowledge is spotty.
Paolo
Re: [Qemu-devel] [RFC PATCH 04/10] tcg: change cpu_restore_state to return void
Quoted 11 lines · Paolo Bonzini
Il 17/09/2012 19:20, Peter Maydell ha scritto:
Quoted 10 lines
Quoted 2 lines
Quoted 2 lines
Couldn't that mean simply that the tb for instance wasn't mapped anywhere? That's the KVM case, at least.
Hmm. For TCG there are certainly some cases where failure to
cpu_restore_state()means that the current CPU state is now broken; that should be fatal (and I'm not sure there are any cases where failure is OK. I think calls are generally protected by checking thattb_find_pc()returned non-NULL, so we shouldn't be trying to restore state unless we really were in the middle of a TB that we know about and can translate.)
Quoted 5 lines
Quoted 2 lines
I'm not sure what the TB concept means for KVM -- after all KVM doesn't do any translation...
Nothing, but in some cases
cpu_restore_state()is called from exception handling helpers or something like that. My knowledge is spotty.
That sounds like we ought to either not call it or have it always return-doing-nothing if we're using KVM.
-- PMM
RFC PATCH 5/10 exec: small adjustments for TCG separation
In reply to Paolo BonziniAdd stubs for cpu_restore_state and tlb_fill, which should respectively have no effect and never be used outside TCG mode.
Add assertions that TCG is enabled around code that calls to TCG from exec.c, so that the compiler can remove the entire functions as dead (the proper way to do this should be to move them to cpu-exec.c instead).
--- cpu-exec.c | 2 ++ exec-all.h | 20 ++++++++++++++++++-- exec.c | 55 ++++++++++++++++++++++++++++++++++---------------------
3 file modificati, 54 inserzioni(+), 23 rimozioni(-)
cpu-exec.c +2 -0
@@ -189,6 +189,8 @@ int cpu_exec(CPUArchState *env)uint8_t *tc_ptr;tcg_target_ulong next_tb; +assert (tcg_enabled ()); +if (env->halted) {if (!cpu_has_work (env)) {return EXCP_HALTED ;
exec-all.h +18 -2
@@ -84,8 +84,6 @@ void restore_state_to_opc(CPUArchState *env, struct TranslationBlock *tb,void cpu_gen_init (void );int cpu_gen_code (CPUArchState *env,struct TranslationBlock *tb,int *gen_code_size_ptr); -void cpu_restore_state (struct TranslationBlock *tb, -CPUArchState *env,uintptr_t searched_pc); void QEMU_NORETURN cpu_resume_from_signal(CPUArchState *env1, void *puc); void QEMU_NORETURN cpu_io_recompile(CPUArchState *env, uintptr_t retaddr); TranslationBlock *tb_gen_code(CPUArchState *env,
@@ -282,6 +280,16 @@ static inline void tb_add_jump(TranslationBlock *tb, int n,TranslationBlock *tb_find_pc (uintptr_t pc_ptr); +#ifdef CONFIG_TCG +void cpu_restore_state (struct TranslationBlock *tb, +CPUArchState *env,uintptr_t searched_pc); +#else +static inline void cpu_restore_state (struct TranslationBlock *tb, +CPUArchState *env,uintptr_t searched_pc) +{ +} +#endif +#include "qemu-lock.h" extern spinlock_t tb_lock;
@@ -316,8 +324,16 @@ uint64_t io_mem_read(struct MemoryRegion *mr, target_phys_addr_t addr,void io_mem_write (struct MemoryRegion *mr,target_phys_addr_t addr,uint64_t value,unsigned size); +#ifdef CONFIG_TCG void tlb_fill (CPUArchState *env1,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr); +#else +static inline void tlb_fill (CPUArchState *env1,target_ulong addr, +int is_write,int mmu_idx,uintptr_t retaddr) +{ +abort (); +} +#endif #include "softmmu_defs.h"
exec.c +34 -21
94 lines not on this page · raw message
Signature · 1 line
1.7.12
Re: [Qemu-devel] [RFC PATCH 05/10] exec: small adjustments for TCG separation
Quoted 153 lines · Paolo Bonzini
Add stubs for
cpu_restore_stateandtlb_fill, which should respectively have no effect and never be used outside TCG mode.Add assertions that TCG is enabled around code that calls to TCG from
exec.c, so that the compiler can remove the entire functions as dead (the proper way to do this should be to move them tocpu-exec.cinstead).Signed-off-by Paolo Bonzini <[email protected]>--- cpu-exec.c | 2 ++ exec-all.h | 20 ++++++++++++++++++-- exec.c | 55 ++++++++++++++++++++++++++++++++++---------------------3 file modificati, 54 inserzioni(+), 23 rimozioni(-)
cpu-exec.c +2
-0@@ -189,6 +189,8 @@ int cpu_exec(CPUArchState *env)uint8_t *tc_ptr;tcg_target_ulong next_tb; +assert (tcg_enabled ()); +if (env->halted) {if (!cpu_has_work (env)) {return EXCP_HALTED ;exec-all.h +18
-2@@ -84,8 +84,6 @@ void restore_state_to_opc(CPUArchState *env, struct TranslationBlock *tb,void cpu_gen_init (void );int cpu_gen_code (CPUArchState *env,struct TranslationBlock *tb,int *gen_code_size_ptr); -void cpu_restore_state (struct TranslationBlock *tb, -CPUArchState *env,uintptr_t searched_pc); void QEMU_NORETURN cpu_resume_from_signal(CPUArchState *env1, void *puc); void QEMU_NORETURN cpu_io_recompile(CPUArchState *env, uintptr_t retaddr); TranslationBlock *tb_gen_code(CPUArchState *env,@@ -282,6 +280,16 @@ static inline void tb_add_jump(TranslationBlock *tb, int n,TranslationBlock *tb_find_pc (uintptr_t pc_ptr); +#ifdef CONFIG_TCG +void cpu_restore_state (struct TranslationBlock *tb, +CPUArchState *env,uintptr_t searched_pc); +#else +static inline void cpu_restore_state (struct TranslationBlock *tb, +CPUArchState *env,uintptr_t searched_pc) +{ +} +#endif +#include "qemu-lock.h" extern spinlock_t tb_lock;@@ -316,8 +324,16 @@ uint64_t io_mem_read(struct MemoryRegion *mr, target_phys_addr_t addr,void io_mem_write (struct MemoryRegion *mr,target_phys_addr_t addr,uint64_t value,unsigned size); +#ifdef CONFIG_TCG void tlb_fill (CPUArchState *env1,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr); +#else +static inline void tlb_fill (CPUArchState *env1,target_ulong addr, +int is_write,int mmu_idx,uintptr_t retaddr) +{ +abort (); +} +#endif #include "softmmu_defs.h" exec.c +8
-21@@ -108,6 +108,8 @@ static unsigned long code_gen_buffer_size;static unsigned long code_gen_buffer_max_size;static uint8_t *code_gen_ptr; +CPUInterruptHandler cpu_interrupt_handler; +#if !defined(CONFIG_USER_ONLY )int phys_ram_fd;static int in_migration;@@ -610,24 +612,6 @@ static void code_gen_alloc(unsigned long tb_size) tbs =g_malloc (code_gen_max_blocks *sizeof (TranslationBlock)); } -/* Must be called before using the QEMU cpus. 'tb_size' is the size -(in bytes) allocated to the translation buffer. Zero means default -size. */ -void tcg_exec_init (unsigned long tb_size) -{ - tcg_allowed =1 ; -cpu_gen_init (); -code_gen_alloc (tb_size); - code_gen_ptr = code_gen_buffer; -tcg_register_jit (code_gen_buffer, code_gen_buffer_size); -page_init (); -#if !defined(CONFIG_USER_ONLY ) || !defined(CONFIG_USE_GUEST_BASE ) -/* There's no guest base to take into account, so go ahead and -initialize the prologue now. */ -tcg_prologue_init (&tcg_ctx); -#endif -} -void cpu_exec_init_all (void ) {#if !defined(CONFIG_USER_ONLY )@@ -1032,6 +1016,8 @@ TranslationBlock *tb_gen_code(CPUArchState *env,target_ulong virt_page2;int code_gen_size; +assert (tcg_enabled ()); + phys_pc =get_page_addr_code (env, pc); tb =tb_alloc (pc);if (!tb) {@@ -1707,9 +1693,6 @@ static void tcg_handle_interrupt(CPUArchState *env, int mask) cpu_unlink_tb(env); } } - -CPUInterruptHandler cpu_interrupt_handler = tcg_handle_interrupt; -#else /* CONFIG_USER_ONLY */ void cpu_interrupt (CPUArchState *env,int mask)@@ -2934,6 +2917,8 @@ static void check_watchpoint(int offset, int len_mask, int flags)CPUWatchpoint *wp;int cpu_flags; +assert (tcg_enabled ()); +if (env->watchpoint_hit) {/* We re-entered the check after replacing the TB. Now raise * the debug interrupt so that is will trigger after the @@ -4112,6 +4097,8 @@ void cpu_io_recompile(CPUArchState *env, uintptr_t retaddr)target_ulong pc, cs_base;uint64_t flags; +assert (tcg_enabled ()); + tb =tb_find_pc (retaddr);if (!tb) { cpu_abort(env, "cpu_io_recompile: could not find TB for pc=%p",@@ -4243,3 +4230,29 @@ bool cpu_physical_memory_is_io(target_phys_addr_t phys_addr) memory_region_is_romd(section->mr)); }
exec.c bool cpu_physical_memory_is_io(target_phys_addr_t phys_addr) · line 4241
Quoted 10 lines
exec.c +9
-0#endif + +/* Must be called before using the QEMU cpus. 'tb_size' is the size +(in bytes) allocated to the translation buffer. Zero means default +size. */ +void tcg_exec_init (unsigned long tb_size) +{ +#ifndef CONFIG_TCG +/* We cannot yet use tcg_enabled() here, it is set below. */ +return ;
This leaves a lot of unreachable code after return, possibly introducing warnings and with low enough optimization level, maybe break linking. Please add #else and move #endif to end of the function.
Quoted 22 lines
exec.c +17
-1+#endif + + tcg_allowed =1 ; +#ifndef CONFIG_USER_ONLY + cpu_interrupt_handler = tcg_handle_interrupt; +#endif +cpu_gen_init (); +code_gen_alloc (tb_size); + code_gen_ptr = code_gen_buffer; +tcg_register_jit (code_gen_buffer, code_gen_buffer_size); +page_init (); +#if !defined(CONFIG_USER_ONLY ) || !defined(CONFIG_USE_GUEST_BASE ) +/* There's no guest base to take into account, so go ahead and +initialize the prologue now. */ +tcg_prologue_init (&tcg_ctx); +#endif +} --1.7.12
Re: [Qemu-devel] [RFC PATCH 05/10] exec: small adjustments for TCG separation
Quoted 10 lines · Blue Swirl
Quoted 5 lines
exec.c bool cpu_physical_memory_is_io(target_phys_addr_t phys_addr) · line 4241
Quoted 5 lines
exec.c +5
-0+void tcg_exec_init (unsigned long tb_size) +{ +#ifndef CONFIG_TCG +/* We cannot yet use tcg_enabled() here, it is set below. */ +return ;This leaves a lot of unreachable code after return, possibly introducing warnings and with low enough optimization level, maybe break linking. Please add #else and move #endif to end of the function.
No, this really should work all the time.
Certainly gcc will not warn for unreachable code after return, and will even at -O0 remove it.
r~
RFC PATCH 6/10 monitor: disable info jit if !TCG
In reply to Paolo Bonzini--- exec.c | 5 +++++ monitor.c | 4 ++++
2 file modificati, 9 inserzioni(+)
exec.c +5 -0
@@ -4157,6 +4157,11 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf)int direct_jmp_count, direct_jmp2_count, cross_page;TranslationBlock *tb; +if (!tcg_enabled ()) { +cpu_fprintf (f,"TCG not enabled\n" ); +return ; + } + target_code_size =0 ; max_target_code_size =0 ; cross_page =0 ;
monitor.c +4 -0
@@ -906,10 +906,12 @@ static void do_info_registers(Monitor *mon)#endif } +#ifdef CONFIG_TCG static void do_info_jit (Monitor *mon) {dump_exec_info ((FILE *)mon, monitor_fprintf); } +#endif static void do_info_history (Monitor *mon) {
@@ -2558,6 +2560,7 @@ static mon_cmd_t info_cmds[] = { .help = "show memory tree", .mhandler.info = do_info_mtree, }, +#if defined(CONFIG_TCG ) { .name = "jit", .args_type = "",
@@ -2565,6 +2568,7 @@ static mon_cmd_t info_cmds[] = { .help = "show dynamic compiler info", .mhandler.info = do_info_jit, }, +#endif { .name = "kvm", .args_type = "",
Signature · 1 line
1.7.12
RFC PATCH 7/10 configure: emit summary at the very end
In reply to Paolo BonziniWe'll need to modify the list of targets in the next patch.
--- configure | 184 +++++++++++++++++++++++++++++++-------------------------------
1 file modificato, 92 inserzioni(+), 92 rimozioni(-)
configure +92 -92
@@ -3113,98 +3113,6 @@ if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then roms="$roms spapr-rtas" fi -echo "Install prefix $prefix" -echo "BIOS directory `eval echo $qemu_datadir`" -echo "binary directory `eval echo $bindir`" -echo "library directory `eval echo $libdir`" -echo "libexec directory `eval echo $libexecdir`" -echo "include directory `eval echo $includedir`" -echo "config directory `eval echo $sysconfdir`" -if test "$mingw32" = "no" ; then -echo "Manual directory `eval echo $mandir`" -echo "ELF interp prefix $interp_prefix" -fi -echo "Source path $source_path" -echo "C compiler $cc" -echo "Host C compiler $host_cc" -echo "Objective-C compiler $objcc" -echo "CFLAGS $CFLAGS" -echo "QEMU_CFLAGS $QEMU_CFLAGS" -echo "LDFLAGS $LDFLAGS" -echo "make $make" -echo "install $install" -echo "python $python" -if test "$slirp" = "yes" ; then - echo "smbd $smbd" -fi -echo "host CPU $cpu" -echo "host big endian $bigendian" -echo "target list $target_list" -echo "tcg debug enabled $debug_tcg" -echo "gprof enabled $gprof" -echo "sparse enabled $sparse" -echo "strip binaries $strip_opt" -echo "profiler $profiler" -echo "static build $static" -echo "-Werror enabled $werror" -if test "$darwin" = "yes" ; then - echo "Cocoa support $cocoa" -fi -echo "SDL support $sdl" -echo "curses support $curses" -echo "curl support $curl" -echo "mingw32 support $mingw32" -echo "Audio drivers $audio_drv_list" -echo "Extra audio cards $audio_card_list" -echo "Block whitelist $block_drv_whitelist" -echo "Mixer emulation $mixemu" -echo "VirtFS support $virtfs" -echo "VNC support $vnc" -if test "$vnc" = "yes" ; then - echo "VNC TLS support $vnc_tls" - echo "VNC SASL support $vnc_sasl" - echo "VNC JPEG support $vnc_jpeg" - echo "VNC PNG support $vnc_png" -fi -if test -n "$sparc_cpu"; then - echo "Target Sparc Arch $sparc_cpu" -fi -echo "xen support $xen" -echo "brlapi support $brlapi" -echo "bluez support $bluez" -echo "Documentation $docs" -[ ! -z "$uname_release" ] && \ -echo "uname -r $uname_release" -echo "NPTL support $nptl" -echo "GUEST_BASE $guest_base" -echo "PIE $pie" -echo "vde support $vde" -echo "Linux AIO support $linux_aio" -echo "ATTR/XATTR support $attr" -echo "Install blobs $blobs" -echo "KVM support $kvm" -echo "TCG interpreter $tcg_interpreter" -echo "fdt support $fdt" -echo "preadv support $preadv" -echo "fdatasync $fdatasync" -echo "madvise $madvise" -echo "posix_madvise $posix_madvise" -echo "uuid support $uuid" -echo "libcap-ng support $cap_ng" -echo "vhost-net support $vhost_net" -echo "Trace backend $trace_backend" -echo "Trace output file $trace_file-<pid>" -echo "spice support $spice ($spice_protocol_version/$spice_server_version)" -echo "rbd support $rbd" -echo "xfsctl support $xfs" -echo "nss used $smartcard_nss" -echo "usb net redir $usb_redir" -echo "OpenGL support $opengl" -echo "libiscsi support $libiscsi" -echo "build guest agent $guest_agent" -echo "seccomp support $seccomp" -echo "coroutine backend $coroutine_backend" - if test "$sdl_too_old" = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support" fi
@@ -4203,3 +4111,95 @@ symlink "$source_path/Makefile.user" "$d/Makefile" if test "$docs" = "yes" ; then mkdir -p QMP fi + +echo "Install prefix $prefix" +echo "BIOS directory `eval echo $qemu_datadir`" +echo "binary directory `eval echo $bindir`" +echo "library directory `eval echo $libdir`" +echo "libexec directory `eval echo $libexecdir`" +echo "include directory `eval echo $includedir`" +echo "config directory `eval echo $sysconfdir`" +if test "$mingw32" = "no" ; then +echo "Manual directory `eval echo $mandir`" +echo "ELF interp prefix $interp_prefix" +fi +echo "Source path $source_path" +echo "C compiler $cc" +echo "Host C compiler $host_cc" +echo "Objective-C compiler $objcc" +echo "CFLAGS $CFLAGS" +echo "QEMU_CFLAGS $QEMU_CFLAGS" +echo "LDFLAGS $LDFLAGS" +echo "make $make" +echo "install $install" +echo "python $python" +if test "$slirp" = "yes" ; then + echo "smbd $smbd" +fi +echo "host CPU $cpu" +echo "host big endian $bigendian" +echo "target list $target_list" +echo "tcg debug enabled $debug_tcg" +echo "gprof enabled $gprof" +echo "sparse enabled $sparse" +echo "strip binaries $strip_opt" +echo "profiler $profiler" +echo "static build $static" +echo "-Werror enabled $werror" +if test "$darwin" = "yes" ; then + echo "Cocoa support $cocoa" +fi +echo "SDL support $sdl" +echo "curses support $curses" +echo "curl support $curl" +echo "mingw32 support $mingw32" +echo "Audio drivers $audio_drv_list" +echo "Extra audio cards $audio_card_list" +echo "Block whitelist $block_drv_whitelist" +echo "Mixer emulation $mixemu" +echo "VirtFS support $virtfs" +echo "VNC support $vnc" +if test "$vnc" = "yes" ; then + echo "VNC TLS support $vnc_tls" + echo "VNC SASL support $vnc_sasl" + echo "VNC JPEG support $vnc_jpeg" + echo "VNC PNG support $vnc_png" +fi +if test -n "$sparc_cpu"; then + echo "Target Sparc Arch $sparc_cpu" +fi +echo "xen support $xen" +echo "brlapi support $brlapi" +echo "bluez support $bluez" +echo "Documentation $docs" +[ ! -z "$uname_release" ] && \ +echo "uname -r $uname_release" +echo "NPTL support $nptl" +echo "GUEST_BASE $guest_base" +echo "PIE $pie" +echo "vde support $vde" +echo "Linux AIO support $linux_aio" +echo "ATTR/XATTR support $attr" +echo "Install blobs $blobs" +echo "KVM support $kvm" +echo "TCG interpreter $tcg_interpreter" +echo "fdt support $fdt" +echo "preadv support $preadv" +echo "fdatasync $fdatasync" +echo "madvise $madvise" +echo "posix_madvise $posix_madvise" +echo "uuid support $uuid" +echo "libcap-ng support $cap_ng" +echo "vhost-net support $vhost_net" +echo "Trace backend $trace_backend" +echo "Trace output file $trace_file-<pid>" +echo "spice support $spice ($spice_protocol_version/$spice_server_version)" +echo "rbd support $rbd" +echo "xfsctl support $xfs" +echo "nss used $smartcard_nss" +echo "usb net redir $usb_redir" +echo "OpenGL support $opengl" +echo "libiscsi support $libiscsi" +echo "build guest agent $guest_agent" +echo "seccomp support $seccomp" +echo "coroutine backend $coroutine_backend"
Signature · 1 line
1.7.12
RFC PATCH 8/10 configure: add --disable-tcg configure option
In reply to Paolo BonziniFrom: Anthony Liguori <[email protected]>
This lets you build without TCG (KVM/Xen/qtest only). When this flag is passed to configure, it will automatically filter out the target list to only those that support KVM or Xen.
--- configure | 38 +++++++++++++++++++++++++++++++-------
1 file modificato, 31 inserzioni(+), 7 rimozioni(-)
configure +31 -7
@@ -165,6 +165,7 @@ cap_ng="" attr="" libattr="" xfs="" +tcg="yes" vhost_net="no" kvm="no"
@@ -748,6 +749,10 @@ for opt do ;; --enable-cap-ng) cap_ng="yes" ;; + --disable-tcg) tcg="no" + ;; + --enable-tcg) tcg="yes" + ;; --disable-spice) spice="no" ;; --enable-spice) spice="yes"
@@ -3259,7 +3264,6 @@ qemu_version=`head $source_path/VERSION` echo "VERSION=$qemu_version" >>$config_host_mak echo "PKGVERSION=$pkgversion" >>$config_host_mak echo "SRC_PATH=$source_path" >> $config_host_mak -echo "TARGET_DIRS=$target_list" >> $config_host_mak if [ "$docs" = "yes" ] ; then echo "BUILD_DOCS=yes" >> $config_host_mak fi
@@ -3367,9 +3371,11 @@ fi if test "$signalfd" = "yes" ; then echo "CONFIG_SIGNALFD=y" >> $config_host_mak fi -echo "CONFIG_TCG=y" >> $config_host_mak -if test "$tcg_interpreter" = "yes" ; then - echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak +if test "$tcg" = "yes"; then + echo "CONFIG_TCG=y" >> $config_host_mak + if test "$tcg_interpreter" = "yes" ; then + echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak + fi fi if test "$fdatasync" = "yes" ; then echo "CONFIG_FDATASYNC=y" >> $config_host_mak
@@ -3598,6 +3604,15 @@ supported_xen_target() { return 1 } +supported_target() { + test "$tcg" = "yes" && return 0 + supported_kvm_target && return 0 + supported_xen_target && return 0 + return 1 +} + +target_list2= + for target in $target_list; do target_dir="$target" config_target_mak=$target_dir/config-target.mak
@@ -3639,6 +3654,10 @@ case "$target" in ;; esac +supported_target || continue + +target_list2="$target $target_list2" + mkdir -p $target_dir echo "# Automatically generated by configure - do not modify" > $config_target_mak
@@ -4058,6 +4077,8 @@ echo "QEMU_INCLUDES+=$includes" >> $config_target_mak done # for target in $targets +echo "TARGET_DIRS=$target_list2" >> $config_host_mak + # build tree in object directory in case the source is not in the current directory DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32" DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas"
@@ -4138,8 +4159,7 @@ if test "$slirp" = "yes" ; then fi echo "host CPU $cpu" echo "host big endian $bigendian" -echo "target list $target_list" -echo "tcg debug enabled $debug_tcg" +echo "target list $target_list2" echo "gprof enabled $gprof" echo "sparse enabled $sparse" echo "strip binaries $strip_opt"
@@ -4182,7 +4202,11 @@ echo "Linux AIO support $linux_aio" echo "ATTR/XATTR support $attr" echo "Install blobs $blobs" echo "KVM support $kvm" -echo "TCG interpreter $tcg_interpreter" +echo "TCG support $tcg" +if test "$tcg" = "yes" ; then + echo "TCG debug enabled $debug_tcg" + echo "TCG interpreter $tcg_interpreter" +fi echo "fdt support $fdt" echo "preadv support $preadv" echo "fdatasync $fdatasync"
Signature · 1 line
1.7.12
RFC PATCH 9/10 i386: move TCG functions out of helper.o, non-TCG functions to cpu.o
In reply to Paolo BonziniThis lets non-TCG build remove *_helper.c from the build.
--- target-i386/cpu.c | 18 ++++++++++++++++++ target-i386/excp_helper.c | 24 ++++++++++++++++++++++++ target-i386/fpu_helper.c | 18 ------------------ target-i386/helper.c | 24 ------------------------
4 file modificati, 42 inserzioni(+), 42 rimozioni(-)
target-i386/cpu.c +18 -0
@@ -1831,6 +1831,24 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->reset = x86_cpu_reset; } +void cpu_get_fp80 (uint64_t *pmant,uint16_t *pexp,floatx80 f) +{ +CPU_LDoubleU temp; + + temp.d = f; + *pmant = temp.l.lower; + *pexp = temp.l.upper; +} + +floatx80 cpu_set_fp80 (uint64_t mant,uint16_t upper) +{ +CPU_LDoubleU temp; + + temp.l.upper = upper; + temp.l.lower = mant; +return temp.d; +} +static const TypeInfo x86_cpu_type_info = { .name =TYPE_X86_CPU , .parent =TYPE_CPU ,
target-i386/excp_helper.c +24 -0
@@ -40,6 +40,30 @@ void helper_raise_exception(CPUX86State *env, int exception_index)raise_exception (env, exception_index); } +void breakpoint_handler (CPUX86State *env) +{ +CPUBreakpoint *bp; + +if (env->watchpoint_hit) { +if (env->watchpoint_hit->flags &BP_CPU ) { + env->watchpoint_hit =NULL ; +if (check_hw_breakpoints (env,0 )) +raise_exception (env,EXCP01_DB ); +else +cpu_resume_from_signal (env,NULL ); + } + }else { + QTAILQ_FOREACH(bp, &env->breakpoints, entry) +if (bp->pc == env->eip) { +if (bp->flags &BP_CPU ) { +check_hw_breakpoints (env,1 ); +raise_exception (env,EXCP01_DB ); + } +break ; + } + } +} +/* * Check nested exceptions and change to double or triple fault if * needed. It should only be called, if this is not an interrupt.
target-i386/fpu_helper.c +0 -18
@@ -1198,24 +1198,6 @@ void helper_fxrstor(CPUX86State *env, target_ulong ptr, int data64) } } -void cpu_get_fp80 (uint64_t *pmant,uint16_t *pexp,floatx80 f) -{ -CPU_LDoubleU temp; - - temp.d = f; - *pmant = temp.l.lower; - *pexp = temp.l.upper; -} - -floatx80 cpu_set_fp80 (uint64_t mant,uint16_t upper) -{ -CPU_LDoubleU temp; - - temp.l.upper = upper; - temp.l.lower = mant; -return temp.d; -} -/* MMX/SSE */ /* XXX: optimize by storing fptt and fptags in the static cpu state */
target-i386/helper.c +0 -24
@@ -941,30 +941,6 @@ int check_hw_breakpoints(CPUX86State *env, int force_dr6_update)return hit_enabled; } -void breakpoint_handler (CPUX86State *env) -{ -CPUBreakpoint *bp; - -if (env->watchpoint_hit) { -if (env->watchpoint_hit->flags &BP_CPU ) { - env->watchpoint_hit =NULL ; -if (check_hw_breakpoints (env,0 )) -raise_exception (env,EXCP01_DB ); -else -cpu_resume_from_signal (env,NULL ); - } - }else { - QTAILQ_FOREACH(bp, &env->breakpoints, entry) -if (bp->pc == env->eip) { -if (bp->flags &BP_CPU ) { -check_hw_breakpoints (env,1 ); -raise_exception (env,EXCP01_DB ); - } -break ; - } - } -} - typedef struct MCEInjectionParams { Monitor *mon; CPUX86State *env;
Signature · 1 line
1.7.12
Re: [Qemu-devel] [RFC PATCH 09/10] i386: move TCG functions out of helper.o, non-TCG functions to cpu.o
Quoted 25 lines · Paolo Bonzini
This lets non-TCG build remove *_helper.c from the build.
Signed-off-by Paolo Bonzini <[email protected]>--- target-i386/cpu.c | 18 ++++++++++++++++++ target-i386/excp_helper.c | 24 ++++++++++++++++++++++++ target-i386/fpu_helper.c | 18 ------------------ target-i386/helper.c | 24 ------------------------4 file modificati, 42 inserzioni(+), 42 rimozioni(-)
target-i386/cpu.c +7
-0@@ -1831,6 +1831,24 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->reset = x86_cpu_reset; } +void cpu_get_fp80 (uint64_t *pmant,uint16_t *pexp,floatx80 f) +{ +CPU_LDoubleU temp; + + temp.d = f; + *pmant = temp.l.lower; + *pexp = temp.l.upper;
target-i386/cpu.c static void x86_cpu_common_class_init(ObjectClass *oc, void *data) · line 1850
Quoted 10 lines
target-i386/cpu.c +10
-0+} + +floatx80 cpu_set_fp80 (uint64_t mant,uint16_t upper) +{ +CPU_LDoubleU temp; + + temp.l.upper = upper; + temp.l.lower = mant; +return temp.d; +}
Can we just put these in machine.c where their only user is?
Quoted 25 lines
target-i386/cpu.c +1
-0+static const TypeInfo x86_cpu_type_info = { .name =TYPE_X86_CPU , .parent =TYPE_CPU ,target-i386/excp_helper.c +13
-0@@ -40,6 +40,30 @@ void helper_raise_exception(CPUX86State *env, int exception_index)raise_exception (env, exception_index); } +void breakpoint_handler (CPUX86State *env) +{ +CPUBreakpoint *bp; + +if (env->watchpoint_hit) { +if (env->watchpoint_hit->flags &BP_CPU ) { + env->watchpoint_hit =NULL ; +if (check_hw_breakpoints (env,0 )) +raise_exception (env,EXCP01_DB ); +else +cpu_resume_from_signal (env,NULL ); + } + }else {
target-i386/excp_helper.c void helper_raise_exception(CPUX86State *env, int exception_index) · line 65
Quoted 10 lines
target-i386/excp_helper.c +10
-0+ QTAILQ_FOREACH(bp, &env->breakpoints, entry) +if (bp->pc == env->eip) { +if (bp->flags &BP_CPU ) { +check_hw_breakpoints (env,1 ); +raise_exception (env,EXCP01_DB ); + } +break ; + } + } +}
Why does moving this from one helper.c file to another let us remove *helper.c from the non-TCG build?
Quoted 73 lines
target-i386/excp_helper.c +1
-0+/* * Check nested exceptions and change to double or triple fault if * needed. It should only be called, if this is not an interrupt. target-i386/fpu_helper.c +0
-18@@ -1198,24 +1198,6 @@ void helper_fxrstor(CPUX86State *env, target_ulong ptr, int data64) } } -void cpu_get_fp80 (uint64_t *pmant,uint16_t *pexp,floatx80 f) -{ -CPU_LDoubleU temp; - - temp.d = f; - *pmant = temp.l.lower; - *pexp = temp.l.upper; -} - -floatx80 cpu_set_fp80 (uint64_t mant,uint16_t upper) -{ -CPU_LDoubleU temp; - - temp.l.upper = upper; - temp.l.lower = mant; -return temp.d; -} -/* MMX/SSE */ /* XXX: optimize by storing fptt and fptags in the static cpu state */ target-i386/helper.c +0
-25@@ -941,30 +941,6 @@ int check_hw_breakpoints(CPUX86State *env, int force_dr6_update)return hit_enabled; } -void breakpoint_handler (CPUX86State *env) -{ -CPUBreakpoint *bp; - -if (env->watchpoint_hit) { -if (env->watchpoint_hit->flags &BP_CPU ) { - env->watchpoint_hit =NULL ; -if (check_hw_breakpoints (env,0 )) -raise_exception (env,EXCP01_DB ); -else -cpu_resume_from_signal (env,NULL ); - } - }else { - QTAILQ_FOREACH(bp, &env->breakpoints, entry) -if (bp->pc == env->eip) { -if (bp->flags &BP_CPU ) { -check_hw_breakpoints (env,1 ); -raise_exception (env,EXCP01_DB ); - } -break ; - } - } -} - typedef struct MCEInjectionParams { Monitor *mon; CPUX86State *env; --1.7.12
Re: [Qemu-devel] [RFC PATCH 09/10] i386: move TCG functions out of helper.o, non-TCG functions to cpu.o
Il 17/09/2012 19:12, Peter Maydell ha scritto:
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
target-i386/excp_helper.c +14
-0+ +if (env->watchpoint_hit) { +if (env->watchpoint_hit->flags &BP_CPU ) { + env->watchpoint_hit =NULL ; +if (check_hw_breakpoints (env,0 )) +raise_exception (env,EXCP01_DB ); +else +cpu_resume_from_signal (env,NULL ); + } + }else { + QTAILQ_FOREACH(bp, &env->breakpoints, entry) +if (bp->pc == env->eip) { +if (bp->flags &BP_CPU ) { +check_hw_breakpoints (env,1 );
Quoted 8 lines
Quoted 6 lines
target-i386/excp_helper.c void helper_raise_exception(CPUX86State *env, int exception_index) · line 65
Quoted 6 lines
target-i386/excp_helper.c +6
-0+raise_exception (env,EXCP01_DB ); + } +break ; + } + } +}Why does moving this from one
helper.cfile to another let us remove *helper.c from the non-TCG build?
It's *_helper.c, i.e. helper.c remains in the non-TCG build. But this function has a dependency on excp_helper.c, and is not used in the non-TCG case, so move it where it belongs.
Paolo
Re: [Qemu-devel] [RFC PATCH 09/10] i386: move TCG functions out of helper.o, non-TCG functions to cpu.o
In reply to Paolo BonziniQuoted 45 lines · Paolo Bonzini
This lets non-TCG build remove *_helper.c from the build.
Signed-off-by Paolo Bonzini <[email protected]>--- target-i386/cpu.c | 18 ++++++++++++++++++ target-i386/excp_helper.c | 24 ++++++++++++++++++++++++ target-i386/fpu_helper.c | 18 ------------------ target-i386/helper.c | 24 ------------------------4 file modificati, 42 inserzioni(+), 42 rimozioni(-)
target-i386/cpu.c +18
-0@@ -1831,6 +1831,24 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->reset = x86_cpu_reset; } +void cpu_get_fp80 (uint64_t *pmant,uint16_t *pexp,floatx80 f) +{ +CPU_LDoubleU temp; + + temp.d = f; + *pmant = temp.l.lower; + *pexp = temp.l.upper; +} + +floatx80 cpu_set_fp80 (uint64_t mant,uint16_t upper) +{ +CPU_LDoubleU temp; + + temp.l.upper = upper; + temp.l.lower = mant; +return temp.d; +} +static const TypeInfo x86_cpu_type_info = { .name =TYPE_X86_CPU , .parent =TYPE_CPU ,target-i386/excp_helper.c +0
-0@@ -40,6 +40,30 @@ void helper_raise_exception(CPUX86State *env, int exception_index)raise_exception (env, exception_index);
target-i386/excp_helper.c void helper_raise_exception(CPUX86State *env, int exception_index) · line 50
Quoted 10 lines
target-i386/excp_helper.c +8
-0} +void breakpoint_handler (CPUX86State *env) +{ +CPUBreakpoint *bp; + +if (env->watchpoint_hit) { +if (env->watchpoint_hit->flags &BP_CPU ) { + env->watchpoint_hit =NULL ; +if (check_hw_breakpoints (env,0 ))
Please fix coding style while moving.
Quoted 5 lines
target-i386/excp_helper.c +5
-0+raise_exception (env,EXCP01_DB ); + else +cpu_resume_from_signal (env ,NULL ); + } + }else {
target-i386/excp_helper.c void helper_raise_exception(CPUX86State *env, int exception_index) · line 65
Quoted 10 lines
target-i386/excp_helper.c +10
-0+ QTAILQ_FOREACH(bp, &env->breakpoints, entry) +if (bp->pc == env->eip) { +if (bp->flags &BP_CPU ) { +check_hw_breakpoints (env,1 ); +raise_exception (env,EXCP01_DB ); + } +break ; + } + } +}
The only user for this function is in cpu.c, so if moved there, this function could be static. excp_helper.c does make sense too.
Quoted 73 lines
target-i386/excp_helper.c +1
-0+/* * Check nested exceptions and change to double or triple fault if * needed. It should only be called, if this is not an interrupt. target-i386/fpu_helper.c +0
-18@@ -1198,24 +1198,6 @@ void helper_fxrstor(CPUX86State *env, target_ulong ptr, int data64) } } -void cpu_get_fp80 (uint64_t *pmant,uint16_t *pexp,floatx80 f) -{ -CPU_LDoubleU temp; - - temp.d = f; - *pmant = temp.l.lower; - *pexp = temp.l.upper; -} - -floatx80 cpu_set_fp80 (uint64_t mant,uint16_t upper) -{ -CPU_LDoubleU temp; - - temp.l.upper = upper; - temp.l.lower = mant; -return temp.d; -} -/* MMX/SSE */ /* XXX: optimize by storing fptt and fptags in the static cpu state */ target-i386/helper.c +0
-25@@ -941,30 +941,6 @@ int check_hw_breakpoints(CPUX86State *env, int force_dr6_update)return hit_enabled; } -void breakpoint_handler (CPUX86State *env) -{ -CPUBreakpoint *bp; - -if (env->watchpoint_hit) { -if (env->watchpoint_hit->flags &BP_CPU ) { - env->watchpoint_hit =NULL ; -if (check_hw_breakpoints (env,0 )) -raise_exception (env,EXCP01_DB ); -else -cpu_resume_from_signal (env,NULL ); - } - }else { - QTAILQ_FOREACH(bp, &env->breakpoints, entry) -if (bp->pc == env->eip) { -if (bp->flags &BP_CPU ) { -check_hw_breakpoints (env,1 ); -raise_exception (env,EXCP01_DB ); - } -break ; - } - } -} - typedef struct MCEInjectionParams { Monitor *mon; CPUX86State *env; --1.7.12
RFC PATCH 10/10 build: do not build TCG files if TCG is disabled
In reply to Paolo BonziniOnly cpu-exec.c is left in, even though in principle it is TCG-specific. Removing it involves moving large parts of code from exec.c to there (and perhaps the other way, too).
--- Makefile.target | 5 +++-- target-i386/Makefile.objs | 7 ++++---
2 file modificati, 7 inserzioni(+), 5 rimozioni(-)
Makefile.target +3 -2
@@ -69,8 +69,9 @@ all: $(PROGS) stap ######################################################### # cpu emulator library -obj-y = exec.o translate-all.o cpu-exec.o -obj-y += tcg/tcg.o tcg/optimize.o +obj-y = exec.o cpu-exec.o +obj-$(CONFIG_TCG) += tcg/tcg.o tcg/optimize.o +obj-$(CONFIG_TCG) += translate-all.o obj-$(CONFIG_TCG_INTERPRETER) += tci.o obj-y += fpu/softfloat.o obj-y += disas.o
target-i386/Makefile.objs +4 -3
@@ -1,6 +1,7 @@ -obj-y += translate.o helper.o cpu.o -obj-y += excp_helper.o fpu_helper.o cc_helper.o int_helper.o svm_helper.o -obj-y += smm_helper.o misc_helper.o mem_helper.o seg_helper.o +obj-y += helper.o cpu.o +obj-$(CONFIG_TCG) += translate.o +obj-$(CONFIG_TCG) += excp_helper.o fpu_helper.o cc_helper.o int_helper.o svm_helper.o +obj-$(CONFIG_TCG) += smm_helper.o misc_helper.o mem_helper.o seg_helper.o obj-$(CONFIG_SOFTMMU) += machine.o arch_memory_mapping.o arch_dump.o obj-$(CONFIG_KVM) += kvm.o hyperv.o obj-$(CONFIG_NO_KVM) += kvm-stub.o
Signature · 1 line
1.7.12
Quoted 5 lines · Paolo Bonzini
This is an old series from Anthony that was never committed. Now that QEMU does not use ARG0 anymore, it is much simpler to move things to and from the
helper.cfiles as needed to remove most of the TCG code from non-TCG builds.
Quoted 8 lines
Of course we're still a long way from there, since
cpu-exec.cis intimately linked withexec.c, but we can already add a --disable-tcg option that works, and disable some lengthy parts of the build when using it.Patches that make s390 and ppc work with --disable-tcg (along the lines of patch 9) are welcome. I'm not going to do that myself otherwise, sorry.
Nice series. If it doesn't break anything, I think it's almost ready to be applied.
Quoted 39 lines
Paolo
Anthony Liguori (2):
vl: implementtcg_enabled()andtcg_available()as for other accelerators
configure: add --disable-tcg configure optionPaolo Bonzini (9):
configure: factor out list of supported Xen/KVM targets
configure: addCONFIG_TCG=yto config-host.mak
tcg: changecpu_restore_stateto return void
exec: small adjustments for TCG separation
monitor: disable info jit if !TCG
configure: emit summary at the very end
i386: move TCG functions out of helper.o, non-TCG functions to cpu.o
build: do not build TCG files if TCG is disabledMakefile.target | 5 +- arch_init.c | 4 + configure | 278 ++++++++++++++++++++++++++-------------------- cpu-exec.c | 2 + exec-all.h | 20 +++- exec.c | 68 +++++++----- monitor.c | 4 + qemu-common.h | 8 +- target-i386/Makefile.objs | 7 +- target-i386/cpu.c | 18 +++ target-i386/excp_helper.c | 24 ++++ target-i386/fpu_helper.c | 18 --- target-i386/helper.c | 24 ---- translate-all.c | 9 +- vl.c | 2 +-15 file modificati, 289 inserzioni(+), 207 rimozioni(-)
--
1.7.12