Move macro QEMU_GNUC_PREREQ to compiler.h

The macro is compiler specific and does not depend on the operating system.

Move macro QEMU_GNUC_PREREQ from osdep.h to compiler.h
and use it to simplify existing code.

host-utils.h uses this macro, so it now needs compiler.h
instead of osdep.h.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Fix and clean code which tests the gcc version

The code which tests whether gcc supports warn_unused_result was wrong.
Remove the wrong test from configure and replace it by code using
macro QEMU_GNUC_PREREQ in compiler.h.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
virtio: Use global memory barrier macros

The virtio code uses wmb() macros in several places, as required by the
SMP-aware virtio protocol.  However the wmb() macro is locally defined
to be a compiler barrier only.  This is probably sufficient on x86
due to its strong storage ordering model, but it certainly isn't on other
platforms, such as ppc.

In any case, qemu already has some globally defined memory barrier macros
in qemu-barrier.h.  This patch, therefore converts virtio.c to use those
barrier macros.  The macros in qemu-barrier.h are also wrong (or at least,
safe for x86 only) but this way at least there's only one place to fix
them.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Barriers in qemu-barrier.h should not be x86 specific

qemu-barrier.h contains a few macros implementing memory barrier
primitives used in several places throughout qemu.  However, apart
from the compiler-only barrier, the defined wmb() is correct only for
x86, or platforms which are similarly strongly ordered.

This patch addresses the FIXME about this by making the wmb() macro
arch dependent.  On x86, it remains a compiler barrier only, but with
a comment explaining in more detail the conditions under which this is
correct.  On weakly-ordered powerpc, an "eieio" instruction is used,
again with explanation of the conditions under which it is sufficient.

On other platforms, we use the __sync_synchronize() primitive,
available in sufficiently recent gcc (4.2 and after?).  This should
implement a full barrier which will be sufficient on all platforms,
although it may be overkill in some cases.  Other platforms can add
optimized versions in future if it's worth it for them.

Without proper memory barriers, it is easy to reproduce ordering
problems with virtio on powerpc; specifically, the QEMU puts new
element into the "used" ring and then updates the ring free-running
counter.  Without a barrier between these under the right
circumstances, the guest linux driver can receive an interrupt, read
the counter change but find the ring element to be handled still has
an old value, leading to an "id %u is not a head!\n" error message.
Similar problems are likely to be possible with kvm on other weakly
ordered platforms.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
irq: introduce qemu_irq_proxy()

In some cases we have a circular dependency involving irqs - the irq
controller depends on a bus, which in turn depends on the irq controller.
Add qemu_irq_proxy() which acts as a passthrough, except that the target
irq may be set later on.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
adlib: remove write-only variable

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qemu-char: use qemu_set_fd_handler/2 consistently

Now that qemu_set_fd_handler and qemu_set_fd_handler2 have different
implementations, one using qemu iohandlers and the other glib, it is not
safe to mix the two when inserting/deleting handlers.

Fixes kvm-autotest.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Makefile: Remove 'tarbin' target

Remove the 'tarbin' target -- it isn't used as part of the official
QEMU release process, and it's out of date (various new bios files
were never added to its list of files). It's better not to provide
it at all than to have a broken makefile target we never use or test.

(Creating a tarball by just pulling in binaries that have been installed
directly to the system you're running the build on is a bad idea anyway:
the better way to create a binary tarball would be just to install to
a temporary DESTDIR and then tar up that.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
MAINTAINERS: update maintainer for target-arm and ARM devboards

Add myself as co-maintainer alongside Paul Brook for the TCG ARM
guest implementation (target-arm) and the ARM dev boards (integratorcp,
realview, stellaris, versatilepb).

Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Acked-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
memory: implement memory_region_set_readonly()

The property is inheritable, but only if set to true.  This is so
that memory routers can mark sections of RAM as read-only via aliases.

Signed-off-by: Avi Kivity <avi@redhat.com>
pci: add pci_address_space_io()

Returns the I/O address space.  Useful for implementing
PCI-ISA bridge devices.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
isa: Pass i/o address space to isa_bus_new

Not used yet, but at least we're provided with the correct region.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
isa: add isa_register_ioport()

To replace isa_init_ioport and isa_init_ioport_range
as the ISA devices are converted to the memory api.

[avi: use memory_region_size()]

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
pc: Re-order pc_init1 to initialize the ISA bus before ISA devices

In particular, the i8259 was being initialized before the ISA bus,
leading to a crash.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
cs4231a: Convert to MemoryRegion

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
i8254: Convert to MemoryRegion

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
mips_malta: move i8259 initialization after piix4 initialization

i8259 is an ISA device (or at least, depends on the ISA infrastructure to
register its ioport); and the ISA bus is supplied by piix4.  Later patches
make this dependency explicit.

Use qemu_irq_proxy() to stop the cycle by adding an extra layer of
indirection.

Signed-off-by: Avi Kivity <avi@redhat.com>
mips_jazz: initialize i8259 after the ISA bus

Succeeding i8259 conversion to ISA requires this.

Signed-off-by: Avi Kivity <avi@redhat.com>
mips_r4k: initialize i8259 after the ISA bus

Succeeding i8259 conversion to ISA requires this.

Signed-off-by: Avi Kivity <avi@redhat.com>
ppc_prep: initialize i8259 after the ISA bus

Succeeding i8259 conversion to ISA requires this.

Signed-off-by: Avi Kivity <avi@redhat.com>