sdk/emulator/qemu.git
12 years agoserial: add windows inf file for the pci card to docs
Gerd Hoffmann [Wed, 17 Oct 2012 07:54:21 +0000 (09:54 +0200)]
serial: add windows inf file for the pci card to docs

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoserial: add pci variant
Gerd Hoffmann [Wed, 17 Oct 2012 07:54:20 +0000 (09:54 +0200)]
serial: add pci variant

So we get a hot-pluggable 16550 uart.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoserial: split serial.c
Gerd Hoffmann [Wed, 17 Oct 2012 07:54:19 +0000 (09:54 +0200)]
serial: split serial.c

Split serial.c into serial.c, serial.h and serial-isa.c.  While being at
creating a serial.h header file move the serial prototypes from pc.h to
the new serial.h.  The latter leads to s/pc.h/serial.h/ in tons of
boards which just want the serial bits from pc.h

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoCall MADV_HUGEPAGE for guest RAM allocations
Luiz Capitulino [Fri, 5 Oct 2012 19:47:57 +0000 (16:47 -0300)]
Call MADV_HUGEPAGE for guest RAM allocations

This makes it possible for QEMU to use transparent huge pages (THP)
when transparent_hugepage/enabled=madvise. Otherwise THP is only
used when it's enabled system wide.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoMerge remote-tracking branch 'quintela/migration-next-20121017' into staging
Anthony Liguori [Mon, 22 Oct 2012 18:26:23 +0000 (13:26 -0500)]
Merge remote-tracking branch 'quintela/migration-next-20121017' into staging

* quintela/migration-next-20121017: (41 commits)
  cpus: create qemu_in_vcpu_thread()
  savevm: make qemu_file_put_notify() return errors
  savevm: un-export qemu_file_set_error()
  block-migration: handle errors with the return codes correctly
  block-migration:  Switch meaning of return value
  block-migration: make flush_blks() return errors
  buffered_file: buffered_put_buffer() don't need to set last_error
  savevm: Only qemu_fflush() can generate errors
  savevm: make qemu_fill_buffer() be consistent
  savevm: unexport qemu_ftell()
  savevm: unfold qemu_fclose_internal()
  savevm: make qemu_fflush() return an error code
  savevm: Remove qemu_fseek()
  virtio-net: use qemu_get_buffer() in a temp buffer
  savevm: unexport qemu_fflush
  migration: make migrate_fd_wait_for_unfreeze() return errors
  buffered_file: make buffered_flush return the error code
  buffered_file: callers of buffered_flush() already check for errors
  buffered_file: We can access directly to bandwidth_limit
  buffered_file: unfold migrate_fd_close
  ...

12 years agoMerge remote-tracking branch 'qemu-kvm/memory/dma' into staging
Anthony Liguori [Mon, 22 Oct 2012 18:26:07 +0000 (13:26 -0500)]
Merge remote-tracking branch 'qemu-kvm/memory/dma' into staging

* qemu-kvm/memory/dma: (23 commits)
  pci: honor PCI_COMMAND_MASTER
  pci: give each device its own address space
  memory: add address_space_destroy()
  dma: make dma access its own address space
  memory: per-AddressSpace dispatch
  s390: avoid reaching into memory core internals
  memory: use AddressSpace for MemoryListener filtering
  memory: move tcg flush into a tcg memory listener
  memory: move address_space_memory and address_space_io out of memory core
  memory: manage coalesced mmio via a MemoryListener
  xen: drop no-op MemoryListener callbacks
  kvm: drop no-op MemoryListener callbacks
  xen_pt: drop no-op MemoryListener callbacks
  vfio: drop no-op MemoryListener callbacks
  memory: drop no-op MemoryListener callbacks
  memory: provide defaults for MemoryListener operations
  memory: maintain a list of address spaces
  memory: export AddressSpace
  memory: prepare AddressSpace for exporting
  xen_pt: use separate MemoryListeners for memory and I/O
  ...

12 years agopci: honor PCI_COMMAND_MASTER
Avi Kivity [Wed, 3 Oct 2012 15:42:58 +0000 (17:42 +0200)]
pci: honor PCI_COMMAND_MASTER

Currently we ignore PCI_COMMAND_MASTER completely: DMA succeeds even when
the bit is clear.

Honor PCI_COMMAND_MASTER by inserting a memory region into the device's
bus master address space, and tying its enable status to PCI_COMMAND_MASTER.

Tested using

  setpci -s 03 COMMAND=3

while a ping was running on a NIC in slot 3.  The kernel (Linux) detected
the stall and recovered after the command

  setpci -s 03 COMMAND=7

was issued.

Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agopci: give each device its own address space
Avi Kivity [Wed, 3 Oct 2012 15:17:27 +0000 (17:17 +0200)]
pci: give each device its own address space

Accesses from different devices can resolve differently
(depending on bridge settings, iommus, and PCI_COMMAND_MASTER), so
set up an address space for each device.

Currently iommus are expressed outside the memory API, so this doesn't
work if an iommu is present.

Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agomemory: add address_space_destroy()
Avi Kivity [Sun, 7 Oct 2012 10:59:55 +0000 (12:59 +0200)]
memory: add address_space_destroy()

Since address spaces can be created dynamically by device hotplug, they
can also be destroyed dynamically.

Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agodma: make dma access its own address space
Avi Kivity [Wed, 3 Oct 2012 14:42:37 +0000 (16:42 +0200)]
dma: make dma access its own address space

Instead of accessing the cpu address space, use an address space
configured by the caller.

Eventually all dma functionality will be folded into AddressSpace,
but we have to start from something.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agomemory: per-AddressSpace dispatch
Avi Kivity [Wed, 3 Oct 2012 14:22:53 +0000 (16:22 +0200)]
memory: per-AddressSpace dispatch

Currently we use a global radix tree to dispatch memory access.  This only
works with a single address space; to support multiple address spaces we
make the radix tree a member of AddressSpace (via an intermediate structure
AddressSpaceDispatch to avoid exposing too many internals).

A side effect is that address_space_io also gains a dispatch table.  When
we remove all the pre-memory-API I/O registrations, we can use that for
dispatching I/O and get rid of the original I/O dispatch.

Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agos390: avoid reaching into memory core internals
Avi Kivity [Wed, 3 Oct 2012 14:14:23 +0000 (16:14 +0200)]
s390: avoid reaching into memory core internals

use cpu_physical_memory_is_io() instead.

Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agomemory: use AddressSpace for MemoryListener filtering
Avi Kivity [Tue, 2 Oct 2012 18:13:51 +0000 (20:13 +0200)]
memory: use AddressSpace for MemoryListener filtering

Using the AddressSpace type reduces confusion, as you can't accidentally
supply the MemoryRegion you're interested in.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agomemory: move tcg flush into a tcg memory listener
Avi Kivity [Tue, 2 Oct 2012 16:54:45 +0000 (18:54 +0200)]
memory: move tcg flush into a tcg memory listener

We plan to make the core listener listen to all address spaces; this
will cause many more flushes than necessary.  Prepare for that by
moving the flush into a tcg-specific listener.

Later we can avoid registering the listener if tcg is disabled.

Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agomemory: move address_space_memory and address_space_io out of memory core
Avi Kivity [Tue, 2 Oct 2012 16:49:28 +0000 (18:49 +0200)]
memory: move address_space_memory and address_space_io out of memory core

With this change, memory.c no longer knows anything about special address
spaces, so it is prepared for AddressSpace based DMA.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agomemory: manage coalesced mmio via a MemoryListener
Avi Kivity [Tue, 2 Oct 2012 16:21:54 +0000 (18:21 +0200)]
memory: manage coalesced mmio via a MemoryListener

Instead of calling a global function on coalesced mmio changes, which
routes the call to kvm if enabled, add coalesced mmio hooks to
MemoryListener and make kvm use that instead.

The motivation is support for multiple address spaces (which means we
we need to filter the call on the right address space) but the result
is cleaner as well.

Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agofix CONFIG_QEMU_HELPERDIR generation again
Michael Tokarev [Sun, 21 Oct 2012 18:52:54 +0000 (22:52 +0400)]
fix CONFIG_QEMU_HELPERDIR generation again

commit 38f419f35225 fixed a breakage with CONFIG_QEMU_HELPERDIR
which has been introduced by 8bf188aa18ef7a8.  But while techinically
that fix has been correct, all other similar variables are handled
differently.  Make it consistent, and let scripts/create_config
expand and capitalize the variable properly like for all other
qemu_*dir variables.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
12 years agotarget-sparc: fix FMOVr instruction
Aurelien Jarno [Tue, 16 Oct 2012 23:28:35 +0000 (01:28 +0200)]
target-sparc: fix FMOVr instruction

Like the MOVr instruction, the FMOVr instruction has the condition
encoded between bits 10 and 12.

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agohw/pl031: Use LOG_GUEST_ERROR
Peter Maydell [Thu, 18 Oct 2012 13:11:42 +0000 (14:11 +0100)]
hw/pl031: Use LOG_GUEST_ERROR

Use LOG_GUEST_ERROR rather than hw_error or direct fprintf.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agohw/pl022: Use LOG_UNIMP and LOG_GUEST_ERROR
Peter Maydell [Thu, 18 Oct 2012 13:11:41 +0000 (14:11 +0100)]
hw/pl022: Use LOG_UNIMP and LOG_GUEST_ERROR

Use LOG_UNIMP and LOG_GUEST_ERROR where appropriate rather
than hw_error().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agohw/pl011: Use LOG_UNIMP and LOG_GUEST_ERROR
Peter Maydell [Thu, 18 Oct 2012 13:11:40 +0000 (14:11 +0100)]
hw/pl011: Use LOG_UNIMP and LOG_GUEST_ERROR

Use the new LOG_UNIMP and LOG_GUEST_ERROR logging types rather
than hw_error().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agohw/pl190: Use LOG_GUEST_ERROR
Peter Maydell [Thu, 18 Oct 2012 13:11:39 +0000 (14:11 +0100)]
hw/pl190: Use LOG_GUEST_ERROR

If the guest attempts an offset to a nonexistent register, just
log this via LOG_GUEST_ERROR rather than killing QEMU with a hw_error.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agohw/pl041: Use LOG_UNIMP
Peter Maydell [Thu, 18 Oct 2012 13:11:38 +0000 (14:11 +0100)]
hw/pl041: Use LOG_UNIMP

Use the new LOG_UNIMP tracing to report unimplemented
features.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agohw/pl181: Use LOG_UNIMP and LOG_GUEST_ERROR
Peter Maydell [Thu, 18 Oct 2012 13:11:37 +0000 (14:11 +0100)]
hw/pl181: Use LOG_UNIMP and LOG_GUEST_ERROR

Rather than a mix of direct printing to stderr and aborting
via hw_error(), use LOG_UNIMP and LOG_GUEST_ERROR.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agohw/hw.h: Add include of qemu-log.h
Peter Maydell [Thu, 18 Oct 2012 13:11:36 +0000 (14:11 +0100)]
hw/hw.h: Add include of qemu-log.h

Add an include of qemu-log.h to hw.h, so that device model
code has access to these logging functions without the need
to directly include qemu-log.h.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoqemu-log: Add new log category for guest bugs
Peter Maydell [Thu, 18 Oct 2012 13:11:35 +0000 (14:11 +0100)]
qemu-log: Add new log category for guest bugs

Add a new category for device models to log guest behaviour
which is likely to be a guest bug of some kind (accessing
nonexistent registers, reading 32 bit wide registers with
a byte access, etc). Making this its own log category allows
those who care (mostly guest OS authors) to see the complaints
without bothering most users.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Remove cpu_tmp0 as a global
Richard Henderson [Tue, 16 Oct 2012 09:32:31 +0000 (19:32 +1000)]
target-sparc: Remove cpu_tmp0 as a global

Subroutines do their own local temporary management.
Within disas_sparc_insn we limit the existance of the variable
to OP=2 insns, and delay initialization as late as is reasonable
for the specific XOP.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Make cpu_dst local to OP=2 insns
Richard Henderson [Tue, 16 Oct 2012 09:32:30 +0000 (19:32 +1000)]
target-sparc: Make cpu_dst local to OP=2 insns

And initialize it such that it (may) write directly to rd.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Only use cpu_dst for eventual writes to a gpr
Richard Henderson [Tue, 16 Oct 2012 09:32:29 +0000 (19:32 +1000)]
target-sparc: Only use cpu_dst for eventual writes to a gpr

Use cpu_tmp0 for other stuff, like Write Priv Register.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Remove last uses of cpu_tmp64
Richard Henderson [Tue, 16 Oct 2012 09:32:28 +0000 (19:32 +1000)]
target-sparc: Remove last uses of cpu_tmp64

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Remove cpu_tmp64 use from softint insns
Richard Henderson [Tue, 16 Oct 2012 09:32:27 +0000 (19:32 +1000)]
target-sparc: Remove cpu_tmp64 use from softint insns

The use of "tl" functions and a tmp64 is logically incompatible.
Use cpu_tmp0 instead.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Don't use a temporary for gen_dest_fpr_D
Richard Henderson [Tue, 16 Oct 2012 09:32:26 +0000 (19:32 +1000)]
target-sparc: Don't use a temporary for gen_dest_fpr_D

In all cases we don't have write-before-read problems.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Remove usage of cpu_tmp64 from most helper functions
Richard Henderson [Tue, 16 Oct 2012 09:32:25 +0000 (19:32 +1000)]
target-sparc: Remove usage of cpu_tmp64 from most helper functions

Use a locally allocated temporary instead.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Tidy ldfsr, stfsr
Richard Henderson [Tue, 16 Oct 2012 09:32:24 +0000 (19:32 +1000)]
target-sparc: Tidy ldfsr, stfsr

Remove the last uses of cpu_tmp32.  Unify the code between sparc64
and sparc32 by using the proper "tl" functions.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Avoid cpu_tmp32 in Write Priv Register
Richard Henderson [Tue, 16 Oct 2012 09:32:23 +0000 (19:32 +1000)]
target-sparc: Avoid cpu_tmp32 in Write Priv Register

No need to copy to a temporary to store 32 bits.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Avoid cpu_tmp32 in Read Priv Register
Richard Henderson [Tue, 16 Oct 2012 09:32:22 +0000 (19:32 +1000)]
target-sparc: Avoid cpu_tmp32 in Read Priv Register

We don't need another temporary here.  Load directly into the
register we want to set.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Use get_temp_i32 in gen_dest_fpr_F
Richard Henderson [Tue, 16 Oct 2012 09:32:21 +0000 (19:32 +1000)]
target-sparc: Use get_temp_i32 in gen_dest_fpr_F

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Split out get_temp_i32
Richard Henderson [Tue, 16 Oct 2012 09:32:20 +0000 (19:32 +1000)]
target-sparc: Split out get_temp_i32

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Make the cpu_addr variable local to load/store handling
Richard Henderson [Tue, 16 Oct 2012 09:32:19 +0000 (19:32 +1000)]
target-sparc: Make the cpu_addr variable local to load/store handling

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Cleanup cpu_src[12] allocation
Richard Henderson [Tue, 16 Oct 2012 09:32:18 +0000 (19:32 +1000)]
target-sparc: Cleanup cpu_src[12] allocation

Now that get_temp_tl is used for get_src[12], we don't need to
pre-allocate these temporaries.

Fallout from this is moving some assignments around cas/casx to
avoid uninitialized variable warnings.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Finish conversion to gen_load_gpr
Richard Henderson [Tue, 16 Oct 2012 09:32:17 +0000 (19:32 +1000)]
target-sparc: Finish conversion to gen_load_gpr

All users of gen_movl_{reg_TN,TN_reg} are removed.  At the same time,
make cpu_val a local variable for load/store disassembly.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Convert swap to gen_load/store_gpr
Richard Henderson [Tue, 16 Oct 2012 09:32:16 +0000 (19:32 +1000)]
target-sparc: Convert swap to gen_load/store_gpr

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Convert asi helpers to gen_*_gpr
Richard Henderson [Tue, 16 Oct 2012 09:32:15 +0000 (19:32 +1000)]
target-sparc: Convert asi helpers to gen_*_gpr

Push the DisasContext down so that we can use gen_load/store_gpr
in sode gen_ldda_asi, gen_stda_ast, gen_cas_asi, gen_casx_asi.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Use gen_load_gpr in get_src[12]
Richard Henderson [Tue, 16 Oct 2012 09:32:14 +0000 (19:32 +1000)]
target-sparc: Use gen_load_gpr in get_src[12]

This means we can avoid the incoming temporary, though the cleanup
of the existing temporaries is not performed in this patch.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Conversion to gen_*_gpr, part 1
Richard Henderson [Tue, 16 Oct 2012 09:32:13 +0000 (19:32 +1000)]
target-sparc: Conversion to gen_*_gpr, part 1

Only handle the easy cases directly within disas_sparc_insn.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Add gen_load/store/dest_gpr
Richard Henderson [Tue, 16 Oct 2012 09:32:12 +0000 (19:32 +1000)]
target-sparc: Add gen_load/store/dest_gpr

Infrastructure to be used to clean up handling of temporaries.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoexec: Make MIN_CODE_GEN_BUFFER_SIZE private to exec.c
Richard Henderson [Tue, 16 Oct 2012 07:30:14 +0000 (17:30 +1000)]
exec: Make MIN_CODE_GEN_BUFFER_SIZE private to exec.c

It is used nowhere else, and the corresponding MAX_CODE_GEN_BUFFER_SIZE
also lives there.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoexec: Allocate code_gen_prologue from code_gen_buffer
Richard Henderson [Tue, 16 Oct 2012 07:30:13 +0000 (17:30 +1000)]
exec: Allocate code_gen_prologue from code_gen_buffer

We had a hack for arm and sparc, allocating code_gen_prologue to a
special section.  Which, honestly does no good under certain cases.
We've already got limits on code_gen_buffer_size to ensure that all
TBs can use direct branches between themselves; reuse this limit to
ensure the prologue is also reachable.

As a bonus, we get to avoid marking a page of the main executable's
data segment as executable.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoexec: Do not use absolute address hints for code_gen_buffer with -fpie
Richard Henderson [Tue, 16 Oct 2012 07:30:12 +0000 (17:30 +1000)]
exec: Do not use absolute address hints for code_gen_buffer with -fpie

The hard-coded addresses inside alloc_code_gen_buffer only make sense
if we're building an executable that will actually run at the address
we've put into the linker scripts.

When we're building with -fpie, the executable will run at some
random location chosen by the kernel.  We get better placement for
the code_gen_buffer if we allow the kernel to place the memory,
as it will tend to to place it near the executable, based on the
PROT_EXEC bit.

Since code_gen_prologue is always inside the executable, this effect
is easily seen at the end of most TB, with the exit_tb opcode, and
with any calls to helper functions.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoexec: Don't make DEFAULT_CODE_GEN_BUFFER_SIZE too large
Richard Henderson [Tue, 16 Oct 2012 07:30:11 +0000 (17:30 +1000)]
exec: Don't make DEFAULT_CODE_GEN_BUFFER_SIZE too large

For ARM we cap the buffer size to 16MB.  Do not allocate 32MB in that case.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoexec: Split up and tidy code_gen_buffer
Richard Henderson [Tue, 16 Oct 2012 07:30:10 +0000 (17:30 +1000)]
exec: Split up and tidy code_gen_buffer

It now consists of:

A macro definition of MAX_CODE_GEN_BUFFER_SIZE with host-specific values,

A function size_code_gen_buffer that applies most of the reasoning for
choosing a buffer size,

Three variations of a function alloc_code_gen_buffer that contain all
of the logic for allocating executable memory via a given allocation
mechanism.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agocreate struct for machine initialization arguments
Eduardo Habkost [Mon, 15 Oct 2012 20:22:02 +0000 (17:22 -0300)]
create struct for machine initialization arguments

This should help us to:
- More easily add or remove machine initialization arguments without
  having to change every single machine init function;
- More easily make mechanical changes involving the machine init
  functions in the future;
- Let machine initialization forward the init arguments to other
  functions more easily.

This change was half-mechanical process: first the struct was added with
the local ram_size, boot_device, kernel_*, initrd_*, and cpu_model local
variable initialization to all functions. Then the compiler helped me
locate the local variables that are unused, so they could be removed.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agovga: remove CONFIG_BOCHS_VBE
Gerd Hoffmann [Mon, 15 Oct 2012 06:02:57 +0000 (08:02 +0200)]
vga: remove CONFIG_BOCHS_VBE

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agovga: add specs for standard vga
Gerd Hoffmann [Mon, 15 Oct 2012 06:02:56 +0000 (08:02 +0200)]
vga: add specs for standard vga

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agovga: add mmio bar to standard vga
Gerd Hoffmann [Mon, 15 Oct 2012 06:02:55 +0000 (08:02 +0200)]
vga: add mmio bar to standard vga

This patch adds a mmio bar to the qemu standard vga which allows to
access the standard vga registers and bochs dispi interface registers
via mmio.

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agovga: fix indention
Gerd Hoffmann [Mon, 15 Oct 2012 06:02:54 +0000 (08:02 +0200)]
vga: fix indention

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotests/tcg: fix build
Catalin Patulea [Tue, 16 Oct 2012 20:00:23 +0000 (16:00 -0400)]
tests/tcg: fix build

This broke when the tests were moved from tests/ to tests/tcg/.

On x86_64 host/i386-linux-user non-kvm guest, test-i386 and test-mmap are broken, but at least they build.

To build/run the tests:
$ cd $BUILD_PATH/tests/tcg
$ SRC_PATH=path/to/qemu make <target>

Signed-off-by: Catalin Patulea <catalinp@google.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agoallow make {dist, }clean work w/out configure
Mike Frysinger [Sun, 16 Sep 2012 20:07:13 +0000 (16:07 -0400)]
allow make {dist, }clean work w/out configure

There's no reason to require configure to run before running a clean
target, so check MAKECMDGOALS before.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotci: fix build breakage for target-sparc
Michael Roth [Mon, 8 Oct 2012 20:45:49 +0000 (15:45 -0500)]
tci: fix build breakage for target-sparc

commit c28ae41 introduced GETPC() usage for sparc, which is currently
not defined when building with --enable-tcg-interpreter. Add sparc to
the list of targets we selectively define GETPC() for.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agoMAINTAINERS: Update email address for Stefan Hajnoczi
Stefan Hajnoczi [Sun, 7 Oct 2012 16:08:49 +0000 (18:08 +0200)]
MAINTAINERS: Update email address for Stefan Hajnoczi

Switch to my new work email address from which I am contributing.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agoconfigure: Fix CONFIG_QEMU_HELPERDIR generation
Jan Kiszka [Wed, 17 Oct 2012 17:09:25 +0000 (19:09 +0200)]
configure: Fix CONFIG_QEMU_HELPERDIR generation

We need to evaluate $libexecdir in configure, otherwise we literally end
up with "${prefix}/libexec" instead of the absolute path as
CONFIG_QEMU_HELPERDIR.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agoqemu-options.hx: Change from recommending '?' to 'help'
Peter Maydell [Thu, 4 Oct 2012 15:22:01 +0000 (16:22 +0100)]
qemu-options.hx: Change from recommending '?' to 'help'

Update the -help output and documentation so that it recommends
'help' rather than '?' for the various "list valid values for this
option" cases. '?' is deprecated (as it can fail confusingly if
not quoted), so it's better to steer users towards 'help'. ('?'
still works, for backwards compatibility.)

This is the -help option part of the change otherwise done in
commit c8057f9, since we are now past release 1.2 and free to
change our help text without worrying about breaking libvirt.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agoMerge branch 'linux-user-for-upstream' of git://git.linaro.org/people/rikuvoipio...
Aurelien Jarno [Fri, 19 Oct 2012 18:28:22 +0000 (20:28 +0200)]
Merge branch 'linux-user-for-upstream' of git://git.linaro.org/people/rikuvoipio/qemu

* 'linux-user-for-upstream' of git://git.linaro.org/people/rikuvoipio/qemu:
  linux-user: register align p{read, write}64
  linux-user: ppc: mark as long long aligned
  tcg: Remove TCG_TARGET_HAS_GUEST_BASE define
  configure: Remove unnecessary host_guest_base code
  linux-user: If loading fails, print error as string, not number
  linux-user: Fix siginfo handling
  alpha-linux-user: Fix sigaltstack structure definition
  linux-user: Implement gethostname
  linux-user: Perform more checks on iovec lists
  linux-user: fix multi-threaded /proc/self/maps
  linux-user: fix statfs

12 years agoMerge branch 'trivial-patches' of git://github.com/stefanha/qemu
Aurelien Jarno [Fri, 19 Oct 2012 18:18:44 +0000 (20:18 +0200)]
Merge branch 'trivial-patches' of git://github.com/stefanha/qemu

* 'trivial-patches' of git://github.com/stefanha/qemu:
  ui/vnc-jobs.c: Fix minor typos in comments
  net/tap-win32: Fix compiler warning caused by missing include statement
  configure: Remove unused parameters from main function
  target-arm/neon_helper: Remove obsolete FIXME comment
  targphys.h: Don't define target_phys_addr_t for user-mode emulators
  ui/vnc: Only report/use TIGHT_PNG encoding if enabled.

12 years agomicroblaze: Update PC before simulating syscall
Edgar E. Iglesias [Thu, 26 Apr 2012 12:18:25 +0000 (14:18 +0200)]
microblaze: Update PC before simulating syscall

Fixes a clone() emulation bug were the new thread starts
at the point of the syscall and thus clones in a loop.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
12 years agomicroblaze: Support setting of TLS ptr
Edgar E. Iglesias [Thu, 26 Apr 2012 12:17:41 +0000 (14:17 +0200)]
microblaze: Support setting of TLS ptr

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
12 years agoui/vnc-jobs.c: Fix minor typos in comments
Peter Maydell [Thu, 18 Oct 2012 16:40:53 +0000 (17:40 +0100)]
ui/vnc-jobs.c: Fix minor typos in comments

Fix some minor typos/grammar errors in comments.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12 years agonet/tap-win32: Fix compiler warning caused by missing include statement
Stefan Weil [Wed, 17 Oct 2012 17:53:50 +0000 (19:53 +0200)]
net/tap-win32: Fix compiler warning caused by missing include statement

The include file for net_init_tap was missing:

net/tap-win32.c:703:
 warning: no previous prototype for ‘net_init_tap’

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12 years agoconfigure: Remove unused parameters from main function
Stefan Weil [Mon, 15 Oct 2012 05:45:40 +0000 (07:45 +0200)]
configure: Remove unused parameters from main function

This modification is required if compiler option -Wunused-parameter is activated.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12 years agotarget-arm/neon_helper: Remove obsolete FIXME comment
Peter Maydell [Fri, 12 Oct 2012 18:07:23 +0000 (19:07 +0100)]
target-arm/neon_helper: Remove obsolete FIXME comment

Commit 33ebc29 fixed the bugs in the implementation of VQRSHL,
but forgot to remove the FIXME comment...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12 years agotargphys.h: Don't define target_phys_addr_t for user-mode emulators
Peter Maydell [Fri, 12 Oct 2012 17:59:44 +0000 (18:59 +0100)]
targphys.h: Don't define target_phys_addr_t for user-mode emulators

Commit 4be403c accidentally defined the target_phys_addr_t type when
building user-mode emulators. Since the type doesn't really make
any sense except for system emulators, avoid defining it when building
in user mode.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12 years agoui/vnc: Only report/use TIGHT_PNG encoding if enabled.
Joel Martin [Wed, 16 May 2012 12:54:25 +0000 (12:54 +0000)]
ui/vnc: Only report/use TIGHT_PNG encoding if enabled.

If TIGHT_PNG is not enabled by the --enable-vnc-png configure flag
then do not report to the client that it is supported.

Also, since TIGHT_PNG is the same as the TIGHT encoding but with the
filter/copy replaced with PNG data, adding it to the supported
encodings list when it is disabled will cause the TIGHT encoding to be
used even though the client requested TIGHT_PNG.

Signed-off-by: Joel Martin <github@martintribe.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12 years agotarget-arm/translate: Fix RRX operands
Peter Crosthwaite [Tue, 16 Oct 2012 09:15:50 +0000 (19:15 +1000)]
target-arm/translate: Fix RRX operands

Instructions that both use the RRX second operand and update CS were
incorrect, as the Carry flag was updated too early. An example of such an
instruction would be:

ands r12,r13,RRX

Ands, because of the "s" flag will update the carry flag. But the RRX second
operand rotates through the C flag which should happen before the update.
Fixed the ordering of the two, the old carry is read by "r13,RRX" before being
updated.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reported-by: Vinesh Peringat <vineshp@xilinx.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agocpus: create qemu_in_vcpu_thread()
Juan Quintela [Tue, 18 Sep 2012 14:30:11 +0000 (16:30 +0200)]
cpus: create qemu_in_vcpu_thread()

Old code used !io_thread to know if a thread was an vcpu or not.  That
fails when we introduce the iothread.

Signed-off-by: Juan Quintela <quintela@redhat.com>
12 years agosavevm: make qemu_file_put_notify() return errors
Juan Quintela [Tue, 4 Sep 2012 10:45:42 +0000 (12:45 +0200)]
savevm: make qemu_file_put_notify() return errors

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agosavevm: un-export qemu_file_set_error()
Juan Quintela [Thu, 30 Aug 2012 11:37:56 +0000 (13:37 +0200)]
savevm: un-export qemu_file_set_error()

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoblock-migration: handle errors with the return codes correctly
Juan Quintela [Wed, 29 Aug 2012 19:59:22 +0000 (21:59 +0200)]
block-migration: handle errors with the return codes correctly

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoblock-migration: Switch meaning of return value
Juan Quintela [Wed, 29 Aug 2012 19:37:14 +0000 (21:37 +0200)]
block-migration:  Switch meaning of return value

Make consistent the result of blk_mig_save_dirty_block() and
mig_save_device_dirty()

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoblock-migration: make flush_blks() return errors
Juan Quintela [Wed, 29 Aug 2012 18:17:13 +0000 (20:17 +0200)]
block-migration: make flush_blks() return errors

This means we don't need to pass through qemu_file to get the errors.
Adjust all callers.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agobuffered_file: buffered_put_buffer() don't need to set last_error
Juan Quintela [Wed, 29 Aug 2012 17:52:16 +0000 (19:52 +0200)]
buffered_file: buffered_put_buffer() don't need to set last_error

Callers on savevm.c:qemu_fflush() will set it.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agosavevm: Only qemu_fflush() can generate errors
Juan Quintela [Wed, 29 Aug 2012 17:43:39 +0000 (19:43 +0200)]
savevm: Only qemu_fflush() can generate errors

Move the error check to the beggining of the callers.  Once this is fixed
qemu_file_set_if_error() is not used anymore, so remove it.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agosavevm: make qemu_fill_buffer() be consistent
Juan Quintela [Wed, 29 Aug 2012 17:36:26 +0000 (19:36 +0200)]
savevm: make qemu_fill_buffer() be consistent

It was setting last_error directly once, and with the helper the other time.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agosavevm: unexport qemu_ftell()
Juan Quintela [Wed, 29 Aug 2012 17:16:56 +0000 (19:16 +0200)]
savevm: unexport qemu_ftell()

It was unused out of savevm.c.

Signed-off-by: Juan Quintela <quintela@redhat.com>
12 years agosavevm: unfold qemu_fclose_internal()
Juan Quintela [Wed, 29 Aug 2012 17:14:54 +0000 (19:14 +0200)]
savevm: unfold qemu_fclose_internal()

It was used only one, and was only one if.  It makes error handling
saner.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agosavevm: make qemu_fflush() return an error code
Juan Quintela [Wed, 29 Aug 2012 17:08:59 +0000 (19:08 +0200)]
savevm: make qemu_fflush() return an error code

Adjust all the callers.  We moved the set of last_error from inside
qemu_fflush() to all the callers.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agosavevm: Remove qemu_fseek()
Juan Quintela [Wed, 29 Aug 2012 17:04:47 +0000 (19:04 +0200)]
savevm: Remove qemu_fseek()

It has no users, and is only half implemented.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agovirtio-net: use qemu_get_buffer() in a temp buffer
Juan Quintela [Wed, 29 Aug 2012 17:03:09 +0000 (19:03 +0200)]
virtio-net: use qemu_get_buffer() in a temp buffer

qemu_fseek() is known to be wrong.  Would be removed on the next
commit.  This code should never been used (value has been
MAC_TABLE_ENTRIES since 2009).

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agosavevm: unexport qemu_fflush
Juan Quintela [Tue, 28 Aug 2012 11:54:06 +0000 (13:54 +0200)]
savevm: unexport qemu_fflush

It is not used outside of savevm.c

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agomigration: make migrate_fd_wait_for_unfreeze() return errors
Juan Quintela [Fri, 24 Aug 2012 10:51:48 +0000 (12:51 +0200)]
migration: make migrate_fd_wait_for_unfreeze() return errors

Adjust all callers

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agobuffered_file: make buffered_flush return the error code
Juan Quintela [Fri, 24 Aug 2012 10:43:04 +0000 (12:43 +0200)]
buffered_file: make buffered_flush return the error code

Or the amount of data written if there is no error.  Adjust all callers.

Signed-off-by: Juan Quintela <quintela@redhat.com>
12 years agobuffered_file: callers of buffered_flush() already check for errors
Juan Quintela [Fri, 24 Aug 2012 09:45:31 +0000 (11:45 +0200)]
buffered_file: callers of buffered_flush() already check for errors

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agobuffered_file: We can access directly to bandwidth_limit
Juan Quintela [Fri, 20 Jul 2012 11:33:53 +0000 (13:33 +0200)]
buffered_file: We can access directly to bandwidth_limit

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agobuffered_file: unfold migrate_fd_close
Juan Quintela [Fri, 20 Jul 2012 11:19:36 +0000 (13:19 +0200)]
buffered_file: unfold migrate_fd_close

We only used it once, just remove the callback indirection.

Signed-off-by: Juan Quintela <quintela@redhat.com>
12 years agobuffered_file: unfold migrate_fd_wait_for_unfreeze
Juan Quintela [Fri, 20 Jul 2012 11:16:28 +0000 (13:16 +0200)]
buffered_file: unfold migrate_fd_wait_for_unfreeze

We only used it once, just remove the callback indirection.

Signed-off-by: Juan Quintela <quintela@redhat.com>
12 years agobuffered_file: unfold migrate_fd_put_ready
Juan Quintela [Fri, 20 Jul 2012 11:13:59 +0000 (13:13 +0200)]
buffered_file: unfold migrate_fd_put_ready

We only use it once, just remove the callback indirection.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agobuffered_file: unfold migrate_fd_put_buffer
Juan Quintela [Fri, 20 Jul 2012 11:10:54 +0000 (13:10 +0200)]
buffered_file: unfold migrate_fd_put_buffer

We only used it once, just remove the callback indirection

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agobuffered_file: opaque is MigrationState
Juan Quintela [Fri, 20 Jul 2012 11:07:17 +0000 (13:07 +0200)]
buffered_file: opaque is MigrationState

It always have that type, just change it.
We will remove buffered file later on the migration thread series.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agobuffered_file: rename opaque to migration_state
Juan Quintela [Fri, 20 Jul 2012 11:04:42 +0000 (13:04 +0200)]
buffered_file: rename opaque to migration_state

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoBufferedFile: append, then flush
Paolo Bonzini [Tue, 16 Aug 2011 23:43:24 +0000 (16:43 -0700)]
BufferedFile: append, then flush

Simplify the logic for pushing data from the buffer to the output
pipe/socket.  This also matches more closely what will be the
operation of the migration thread.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
12 years agomigration: Add dirty_pages_rate to query migrate output
Juan Quintela [Mon, 13 Aug 2012 10:31:25 +0000 (12:31 +0200)]
migration: Add dirty_pages_rate to query migrate output

It indicates how many pages were dirtied during the last second.

Signed-off-by: Juan Quintela <quintela@redhat.com>