* [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets
2012-09-17 16:00 [Qemu-devel] [RFC PATCH 00/10] Add --disable-tcg Paolo Bonzini
@ 2012-09-17 16:00 ` Paolo Bonzini
2012-09-17 17:02 ` Peter Maydell
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 02/10] configure: add CONFIG_TCG=y to config-host.mak Paolo Bonzini
` (9 subsequent siblings)
10 siblings, 1 reply; 29+ messages in thread
From: Paolo Bonzini @ 2012-09-17 16:00 UTC (permalink / raw)
To: qemu-devel
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
configure | 63 +++++++++++++++++++++++++++++++++++++--------------------------
1 file modificato, 37 inserzioni(+), 26 rimozioni(-)
diff --git a/configure b/configure
index 7e23309..cea8db0 100755
--- a/configure
+++ b/configure
@@ -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
--
1.7.12
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets Paolo Bonzini
@ 2012-09-17 17:02 ` Peter Maydell
2012-09-17 17:09 ` Paolo Bonzini
2012-09-17 18:30 ` Stefano Stabellini
0 siblings, 2 replies; 29+ messages in thread
From: Peter Maydell @ 2012-09-17 17:02 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, Stefano Stabellini
On 17 September 2012 17:00, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> configure | 63 +++++++++++++++++++++++++++++++++++++--------------------------
> 1 file modificato, 37 inserzioni(+), 26 rimozioni(-)
>
> diff --git a/configure b/configure
> index 7e23309..cea8db0 100755
> --- a/configure
> +++ b/configure
> @@ -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
> +}
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.
> +
> 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
...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.
> + 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
> --
> 1.7.12
>
>
>
-- PMM
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets
2012-09-17 17:02 ` Peter Maydell
@ 2012-09-17 17:09 ` Paolo Bonzini
2012-09-17 17:13 ` Peter Maydell
2012-09-17 18:21 ` Stefano Stabellini
2012-09-17 18:30 ` Stefano Stabellini
1 sibling, 2 replies; 29+ messages in thread
From: Paolo Bonzini @ 2012-09-17 17:09 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, Stefano Stabellini
Il 17/09/2012 19:02, Peter Maydell ha scritto:
> 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
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets
2012-09-17 17:09 ` Paolo Bonzini
@ 2012-09-17 17:13 ` Peter Maydell
2012-09-17 18:21 ` Stefano Stabellini
1 sibling, 0 replies; 29+ messages in thread
From: Peter Maydell @ 2012-09-17 17:13 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, Stefano Stabellini
On 17 September 2012 18:09, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Il 17/09/2012 19:02, Peter Maydell ha scritto:
>> 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
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets
2012-09-17 17:09 ` Paolo Bonzini
2012-09-17 17:13 ` Peter Maydell
@ 2012-09-17 18:21 ` Stefano Stabellini
1 sibling, 0 replies; 29+ messages in thread
From: Stefano Stabellini @ 2012-09-17 18:21 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Peter Maydell, qemu-devel@nongnu.org, Stefano Stabellini
On Mon, 17 Sep 2012, Paolo Bonzini wrote:
> Il 17/09/2012 19:02, Peter Maydell ha scritto:
> > 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.
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.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets
2012-09-17 17:02 ` Peter Maydell
2012-09-17 17:09 ` Paolo Bonzini
@ 2012-09-17 18:30 ` Stefano Stabellini
2012-09-17 18:53 ` Stefano Stabellini
1 sibling, 1 reply; 29+ messages in thread
From: Stefano Stabellini @ 2012-09-17 18:30 UTC (permalink / raw)
To: Peter Maydell; +Cc: Paolo Bonzini, qemu-devel@nongnu.org, Stefano Stabellini
On Mon, 17 Sep 2012, Peter Maydell wrote:
> On 17 September 2012 17:00, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > ---
> > configure | 63 +++++++++++++++++++++++++++++++++++++--------------------------
> > 1 file modificato, 37 inserzioni(+), 26 rimozioni(-)
> >
> > diff --git a/configure b/configure
> > index 7e23309..cea8db0 100755
> > --- a/configure
> > +++ b/configure
> > @@ -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
> > +}
>
> 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.
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.
> > 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
>
> ...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.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets
2012-09-17 18:30 ` Stefano Stabellini
@ 2012-09-17 18:53 ` Stefano Stabellini
2012-09-17 19:15 ` Peter Maydell
0 siblings, 1 reply; 29+ messages in thread
From: Stefano Stabellini @ 2012-09-17 18:53 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: Peter Maydell, qemu-devel@nongnu.org, Paolo Bonzini
On Mon, 17 Sep 2012, Stefano Stabellini wrote:
> On Mon, 17 Sep 2012, Peter Maydell wrote:
> > On 17 September 2012 17:00, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > > ---
> > > configure | 63 +++++++++++++++++++++++++++++++++++++--------------------------
> > > 1 file modificato, 37 inserzioni(+), 26 rimozioni(-)
> > >
> > > diff --git a/configure b/configure
> > > index 7e23309..cea8db0 100755
> > > --- a/configure
> > > +++ b/configure
> > > @@ -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
> > > +}
> >
> > 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.
>
> 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.
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.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets
2012-09-17 18:53 ` Stefano Stabellini
@ 2012-09-17 19:15 ` Peter Maydell
0 siblings, 0 replies; 29+ messages in thread
From: Peter Maydell @ 2012-09-17 19:15 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: Paolo Bonzini, qemu-devel@nongnu.org
On 17 September 2012 19:53, Stefano Stabellini
<stefano.stabellini@eu.citrix.com> wrote:
> On Mon, 17 Sep 2012, Stefano Stabellini wrote:
>> On Mon, 17 Sep 2012, Peter Maydell wrote:
>> > 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.
>>
>> 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.
>
> 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.
> 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
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Qemu-devel] [RFC PATCH 02/10] configure: add CONFIG_TCG=y to config-host.mak
2012-09-17 16:00 [Qemu-devel] [RFC PATCH 00/10] Add --disable-tcg Paolo Bonzini
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets Paolo Bonzini
@ 2012-09-17 16:00 ` Paolo Bonzini
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 03/10] vl: implement tcg_enabled() and tcg_available() as for other accelerators Paolo Bonzini
` (8 subsequent siblings)
10 siblings, 0 replies; 29+ messages in thread
From: Paolo Bonzini @ 2012-09-17 16:00 UTC (permalink / raw)
To: qemu-devel
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
configure | 1 +
1 file modificato, 1 inserzione(+)
diff --git a/configure b/configure
index cea8db0..f705dce 100755
--- a/configure
+++ b/configure
@@ -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
--
1.7.12
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [RFC PATCH 03/10] vl: implement tcg_enabled() and tcg_available() as for other accelerators
2012-09-17 16:00 [Qemu-devel] [RFC PATCH 00/10] Add --disable-tcg Paolo Bonzini
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 01/10] configure: factor out list of supported Xen/KVM targets Paolo Bonzini
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 02/10] configure: add CONFIG_TCG=y to config-host.mak Paolo Bonzini
@ 2012-09-17 16:00 ` Paolo Bonzini
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 04/10] tcg: change cpu_restore_state to return void Paolo Bonzini
` (7 subsequent siblings)
10 siblings, 0 replies; 29+ messages in thread
From: Paolo Bonzini @ 2012-09-17 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori
From: Anthony Liguori <aliguori@us.ibm.com>
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.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
arch_init.c | 4 ++++
exec.c | 6 +-----
qemu-common.h | 8 +++++++-
vl.c | 2 +-
4 file modificati, 13 inserzioni(+), 7 rimozioni(-)
diff --git a/arch_init.c b/arch_init.c
index 5a1173e..fb41467 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -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)
diff --git a/exec.c b/exec.c
index 5834766..1270d78 100644
--- a/exec.c
+++ b/exec.c
@@ -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)
diff --git a/qemu-common.h b/qemu-common.h
index e5c2bcd..6a3b075 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -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);
diff --git a/vl.c b/vl.c
index 7c577fa..fa022d1 100644
--- a/vl.c
+++ b/vl.c
@@ -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;
--
1.7.12
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [RFC PATCH 04/10] tcg: change cpu_restore_state to return void
2012-09-17 16:00 [Qemu-devel] [RFC PATCH 00/10] Add --disable-tcg Paolo Bonzini
` (2 preceding siblings ...)
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 03/10] vl: implement tcg_enabled() and tcg_available() as for other accelerators Paolo Bonzini
@ 2012-09-17 16:00 ` Paolo Bonzini
2012-09-17 17:06 ` Peter Maydell
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 05/10] exec: small adjustments for TCG separation Paolo Bonzini
` (6 subsequent siblings)
10 siblings, 1 reply; 29+ messages in thread
From: Paolo Bonzini @ 2012-09-17 16:00 UTC (permalink / raw)
To: qemu-devel
The return value is used nowhere.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
exec-all.h | 4 ++--
translate-all.c | 9 ++++-----
2 file modificati, 6 inserzioni(+), 7 rimozioni(-)
diff --git a/exec-all.h b/exec-all.h
index dba9609..cecafa1 100644
--- a/exec-all.h
+++ b/exec-all.h
@@ -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,
diff --git a/translate-all.c b/translate-all.c
index 5bd2d37..f2f9036 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -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;
}
--
1.7.12
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 04/10] tcg: change cpu_restore_state to return void
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 04/10] tcg: change cpu_restore_state to return void Paolo Bonzini
@ 2012-09-17 17:06 ` Peter Maydell
2012-09-17 17:09 ` Paolo Bonzini
0 siblings, 1 reply; 29+ messages in thread
From: Peter Maydell @ 2012-09-17 17:06 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On 17 September 2012 17:00, Paolo Bonzini <pbonzini@redhat.com> wrote:
> 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
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 04/10] tcg: change cpu_restore_state to return void
2012-09-17 17:06 ` Peter Maydell
@ 2012-09-17 17:09 ` Paolo Bonzini
2012-09-17 17:20 ` Peter Maydell
0 siblings, 1 reply; 29+ messages in thread
From: Paolo Bonzini @ 2012-09-17 17:09 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel
Il 17/09/2012 19:06, Peter Maydell ha scritto:
>> > 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
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 04/10] tcg: change cpu_restore_state to return void
2012-09-17 17:09 ` Paolo Bonzini
@ 2012-09-17 17:20 ` Peter Maydell
2012-09-17 18:25 ` Paolo Bonzini
0 siblings, 1 reply; 29+ messages in thread
From: Peter Maydell @ 2012-09-17 17:20 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On 17 September 2012 18:09, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Il 17/09/2012 19:06, Peter Maydell ha scritto:
>>> > 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
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 04/10] tcg: change cpu_restore_state to return void
2012-09-17 17:20 ` Peter Maydell
@ 2012-09-17 18:25 ` Paolo Bonzini
2012-09-17 18:57 ` Peter Maydell
0 siblings, 1 reply; 29+ messages in thread
From: Paolo Bonzini @ 2012-09-17 18:25 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel
Il 17/09/2012 19:20, Peter Maydell ha scritto:
>> > 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...
Nothing, but in some cases cpu_restore_state() is called from exception
handling helpers or something like that. My knowledge is spotty.
Paolo
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 04/10] tcg: change cpu_restore_state to return void
2012-09-17 18:25 ` Paolo Bonzini
@ 2012-09-17 18:57 ` Peter Maydell
0 siblings, 0 replies; 29+ messages in thread
From: Peter Maydell @ 2012-09-17 18:57 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On 17 September 2012 19:25, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Il 17/09/2012 19:20, Peter Maydell ha scritto:
>>> > 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...
>
> 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
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Qemu-devel] [RFC PATCH 05/10] exec: small adjustments for TCG separation
2012-09-17 16:00 [Qemu-devel] [RFC PATCH 00/10] Add --disable-tcg Paolo Bonzini
` (3 preceding siblings ...)
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 04/10] tcg: change cpu_restore_state to return void Paolo Bonzini
@ 2012-09-17 16:00 ` Paolo Bonzini
2012-09-17 19:17 ` Blue Swirl
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 06/10] monitor: disable info jit if !TCG Paolo Bonzini
` (5 subsequent siblings)
10 siblings, 1 reply; 29+ messages in thread
From: Paolo Bonzini @ 2012-09-17 16:00 UTC (permalink / raw)
To: qemu-devel
Add 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).
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
cpu-exec.c | 2 ++
exec-all.h | 20 ++++++++++++++++++--
exec.c | 55 ++++++++++++++++++++++++++++++++++---------------------
3 file modificati, 54 inserzioni(+), 23 rimozioni(-)
diff --git a/cpu-exec.c b/cpu-exec.c
index 134b3c4..b047b6c 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -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;
diff --git a/exec-all.h b/exec-all.h
index cecafa1..4c61ed1 100644
--- a/exec-all.h
+++ b/exec-all.h
@@ -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"
diff --git a/exec.c b/exec.c
index 1270d78..3e77de2 100644
--- a/exec.c
+++ b/exec.c
@@ -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));
}
#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;
+#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
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 05/10] exec: small adjustments for TCG separation
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 05/10] exec: small adjustments for TCG separation Paolo Bonzini
@ 2012-09-17 19:17 ` Blue Swirl
2012-09-17 21:47 ` Richard Henderson
0 siblings, 1 reply; 29+ messages in thread
From: Blue Swirl @ 2012-09-17 19:17 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On Mon, Sep 17, 2012 at 4:00 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Add 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).
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> cpu-exec.c | 2 ++
> exec-all.h | 20 ++++++++++++++++++--
> exec.c | 55 ++++++++++++++++++++++++++++++++++---------------------
> 3 file modificati, 54 inserzioni(+), 23 rimozioni(-)
>
> diff --git a/cpu-exec.c b/cpu-exec.c
> index 134b3c4..b047b6c 100644
> --- a/cpu-exec.c
> +++ b/cpu-exec.c
> @@ -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;
> diff --git a/exec-all.h b/exec-all.h
> index cecafa1..4c61ed1 100644
> --- a/exec-all.h
> +++ b/exec-all.h
> @@ -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"
>
> diff --git a/exec.c b/exec.c
> index 1270d78..3e77de2 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -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));
> }
> #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.
> +#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
>
>
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 05/10] exec: small adjustments for TCG separation
2012-09-17 19:17 ` Blue Swirl
@ 2012-09-17 21:47 ` Richard Henderson
0 siblings, 0 replies; 29+ messages in thread
From: Richard Henderson @ 2012-09-17 21:47 UTC (permalink / raw)
To: Blue Swirl; +Cc: Paolo Bonzini, qemu-devel
On 09/17/2012 12:17 PM, Blue Swirl wrote:
>> > +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~
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Qemu-devel] [RFC PATCH 06/10] monitor: disable info jit if !TCG
2012-09-17 16:00 [Qemu-devel] [RFC PATCH 00/10] Add --disable-tcg Paolo Bonzini
` (4 preceding siblings ...)
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 05/10] exec: small adjustments for TCG separation Paolo Bonzini
@ 2012-09-17 16:00 ` Paolo Bonzini
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 07/10] configure: emit summary at the very end Paolo Bonzini
` (4 subsequent siblings)
10 siblings, 0 replies; 29+ messages in thread
From: Paolo Bonzini @ 2012-09-17 16:00 UTC (permalink / raw)
To: qemu-devel
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
exec.c | 5 +++++
monitor.c | 4 ++++
2 file modificati, 9 inserzioni(+)
diff --git a/exec.c b/exec.c
index 3e77de2..f7c1099 100644
--- a/exec.c
+++ b/exec.c
@@ -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;
diff --git a/monitor.c b/monitor.c
index 67064e2..f70201b 100644
--- a/monitor.c
+++ b/monitor.c
@@ -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 = "",
--
1.7.12
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [RFC PATCH 07/10] configure: emit summary at the very end
2012-09-17 16:00 [Qemu-devel] [RFC PATCH 00/10] Add --disable-tcg Paolo Bonzini
` (5 preceding siblings ...)
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 06/10] monitor: disable info jit if !TCG Paolo Bonzini
@ 2012-09-17 16:00 ` Paolo Bonzini
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 08/10] configure: add --disable-tcg configure option Paolo Bonzini
` (3 subsequent siblings)
10 siblings, 0 replies; 29+ messages in thread
From: Paolo Bonzini @ 2012-09-17 16:00 UTC (permalink / raw)
To: qemu-devel
We'll need to modify the list of targets in the next patch.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
configure | 184 +++++++++++++++++++++++++++++++-------------------------------
1 file modificato, 92 inserzioni(+), 92 rimozioni(-)
diff --git a/configure b/configure
index f705dce..3cdf9d9 100755
--- a/configure
+++ b/configure
@@ -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"
--
1.7.12
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [RFC PATCH 08/10] configure: add --disable-tcg configure option
2012-09-17 16:00 [Qemu-devel] [RFC PATCH 00/10] Add --disable-tcg Paolo Bonzini
` (6 preceding siblings ...)
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 07/10] configure: emit summary at the very end Paolo Bonzini
@ 2012-09-17 16:00 ` Paolo Bonzini
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 09/10] i386: move TCG functions out of helper.o, non-TCG functions to cpu.o Paolo Bonzini
` (2 subsequent siblings)
10 siblings, 0 replies; 29+ messages in thread
From: Paolo Bonzini @ 2012-09-17 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori
From: Anthony Liguori <aliguori@us.ibm.com>
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.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
configure | 38 +++++++++++++++++++++++++++++++-------
1 file modificato, 31 inserzioni(+), 7 rimozioni(-)
diff --git a/configure b/configure
index 3cdf9d9..bf8fd55 100755
--- a/configure
+++ b/configure
@@ -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"
--
1.7.12
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [RFC PATCH 09/10] i386: move TCG functions out of helper.o, non-TCG functions to cpu.o
2012-09-17 16:00 [Qemu-devel] [RFC PATCH 00/10] Add --disable-tcg Paolo Bonzini
` (7 preceding siblings ...)
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 08/10] configure: add --disable-tcg configure option Paolo Bonzini
@ 2012-09-17 16:00 ` Paolo Bonzini
2012-09-17 17:12 ` Peter Maydell
2012-09-17 19:15 ` Blue Swirl
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 10/10] build: do not build TCG files if TCG is disabled Paolo Bonzini
2012-09-17 19:20 ` [Qemu-devel] [RFC PATCH 00/10] Add --disable-tcg Blue Swirl
10 siblings, 2 replies; 29+ messages in thread
From: Paolo Bonzini @ 2012-09-17 16:00 UTC (permalink / raw)
To: qemu-devel
This lets non-TCG build remove *_helper.c from the build.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
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(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 423e009..e0f0b57 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -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,
diff --git a/target-i386/excp_helper.c b/target-i386/excp_helper.c
index aaa5ca2..391f115 100644
--- a/target-i386/excp_helper.c
+++ b/target-i386/excp_helper.c
@@ -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.
diff --git a/target-i386/fpu_helper.c b/target-i386/fpu_helper.c
index dfc34a6..7747236 100644
--- a/target-i386/fpu_helper.c
+++ b/target-i386/fpu_helper.c
@@ -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 */
diff --git a/target-i386/helper.c b/target-i386/helper.c
index 8a5da3d..cfc7f1a 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -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
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 09/10] i386: move TCG functions out of helper.o, non-TCG functions to cpu.o
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 09/10] i386: move TCG functions out of helper.o, non-TCG functions to cpu.o Paolo Bonzini
@ 2012-09-17 17:12 ` Peter Maydell
2012-09-17 18:39 ` Paolo Bonzini
2012-09-17 19:15 ` Blue Swirl
1 sibling, 1 reply; 29+ messages in thread
From: Peter Maydell @ 2012-09-17 17:12 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On 17 September 2012 17:00, Paolo Bonzini <pbonzini@redhat.com> wrote:
> This lets non-TCG build remove *_helper.c from the build.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> 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(-)
>
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 423e009..e0f0b57 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -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;
> +}
Can we just put these in machine.c where their only user is?
> +
> static const TypeInfo x86_cpu_type_info = {
> .name = TYPE_X86_CPU,
> .parent = TYPE_CPU,
> diff --git a/target-i386/excp_helper.c b/target-i386/excp_helper.c
> index aaa5ca2..391f115 100644
> --- a/target-i386/excp_helper.c
> +++ b/target-i386/excp_helper.c
> @@ -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;
> + }
> + }
> +}
Why does moving this from one helper.c file to another let us
remove *helper.c from the non-TCG build?
> +
> /*
> * Check nested exceptions and change to double or triple fault if
> * needed. It should only be called, if this is not an interrupt.
> diff --git a/target-i386/fpu_helper.c b/target-i386/fpu_helper.c
> index dfc34a6..7747236 100644
> --- a/target-i386/fpu_helper.c
> +++ b/target-i386/fpu_helper.c
> @@ -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 */
>
> diff --git a/target-i386/helper.c b/target-i386/helper.c
> index 8a5da3d..cfc7f1a 100644
> --- a/target-i386/helper.c
> +++ b/target-i386/helper.c
> @@ -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
>
>
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 09/10] i386: move TCG functions out of helper.o, non-TCG functions to cpu.o
2012-09-17 17:12 ` Peter Maydell
@ 2012-09-17 18:39 ` Paolo Bonzini
0 siblings, 0 replies; 29+ messages in thread
From: Paolo Bonzini @ 2012-09-17 18:39 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel
Il 17/09/2012 19:12, Peter Maydell ha scritto:
>> > +
>> > + 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;
>> > + }
>> > + }
>> > +}
> Why does moving this from one helper.c file 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
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 09/10] i386: move TCG functions out of helper.o, non-TCG functions to cpu.o
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 09/10] i386: move TCG functions out of helper.o, non-TCG functions to cpu.o Paolo Bonzini
2012-09-17 17:12 ` Peter Maydell
@ 2012-09-17 19:15 ` Blue Swirl
1 sibling, 0 replies; 29+ messages in thread
From: Blue Swirl @ 2012-09-17 19:15 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On Mon, Sep 17, 2012 at 4:00 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> This lets non-TCG build remove *_helper.c from the build.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> 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(-)
>
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 423e009..e0f0b57 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -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,
> diff --git a/target-i386/excp_helper.c b/target-i386/excp_helper.c
> index aaa5ca2..391f115 100644
> --- a/target-i386/excp_helper.c
> +++ b/target-i386/excp_helper.c
> @@ -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))
Please fix coding style while moving.
> + 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;
> + }
> + }
> +}
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.
> +
> /*
> * Check nested exceptions and change to double or triple fault if
> * needed. It should only be called, if this is not an interrupt.
> diff --git a/target-i386/fpu_helper.c b/target-i386/fpu_helper.c
> index dfc34a6..7747236 100644
> --- a/target-i386/fpu_helper.c
> +++ b/target-i386/fpu_helper.c
> @@ -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 */
>
> diff --git a/target-i386/helper.c b/target-i386/helper.c
> index 8a5da3d..cfc7f1a 100644
> --- a/target-i386/helper.c
> +++ b/target-i386/helper.c
> @@ -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
>
>
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Qemu-devel] [RFC PATCH 10/10] build: do not build TCG files if TCG is disabled
2012-09-17 16:00 [Qemu-devel] [RFC PATCH 00/10] Add --disable-tcg Paolo Bonzini
` (8 preceding siblings ...)
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 09/10] i386: move TCG functions out of helper.o, non-TCG functions to cpu.o Paolo Bonzini
@ 2012-09-17 16:00 ` Paolo Bonzini
2012-09-17 19:20 ` [Qemu-devel] [RFC PATCH 00/10] Add --disable-tcg Blue Swirl
10 siblings, 0 replies; 29+ messages in thread
From: Paolo Bonzini @ 2012-09-17 16:00 UTC (permalink / raw)
To: qemu-devel
Only 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).
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
Makefile.target | 5 +++--
target-i386/Makefile.objs | 7 ++++---
2 file modificati, 7 inserzioni(+), 5 rimozioni(-)
diff --git a/Makefile.target b/Makefile.target
index d9d54b8..2f1687a 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -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
diff --git a/target-i386/Makefile.objs b/target-i386/Makefile.objs
index c1d4f05..b6cb055 100644
--- a/target-i386/Makefile.objs
+++ b/target-i386/Makefile.objs
@@ -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
--
1.7.12
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 00/10] Add --disable-tcg
2012-09-17 16:00 [Qemu-devel] [RFC PATCH 00/10] Add --disable-tcg Paolo Bonzini
` (9 preceding siblings ...)
2012-09-17 16:00 ` [Qemu-devel] [RFC PATCH 10/10] build: do not build TCG files if TCG is disabled Paolo Bonzini
@ 2012-09-17 19:20 ` Blue Swirl
10 siblings, 0 replies; 29+ messages in thread
From: Blue Swirl @ 2012-09-17 19:20 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On Mon, Sep 17, 2012 at 4:00 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> 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.
Nice series. If it doesn't break anything, I think it's almost ready
to be applied.
>
> 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(-)
>
> --
> 1.7.12
>
>
^ permalink raw reply [flat|nested] 29+ messages in thread