]> Git Repo - qemu.git/log
qemu.git
8 years agoi2c: Add asserts for second smbus i2c_start_transfer()
Corey Minyard [Mon, 24 Oct 2016 15:42:33 +0000 (10:42 -0500)]
i2c: Add asserts for second smbus i2c_start_transfer()

Some SMBus operations restart the transfer to convert from
write to read mode without an intervening i2c_end_transfer().
The second call cannot fail, so the return code is unchecked,
but this causes Coverity to complain.  So add some asserts
and documentation about this.

Signed-off-by: Corey Minyard <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agotarget-arm: Implement new HLT trap for semihosting
Peter Maydell [Mon, 24 Oct 2016 15:26:56 +0000 (16:26 +0100)]
target-arm: Implement new HLT trap for semihosting

Version 2.0 of the semihosting specification introduces new trap
instructions for AArch32: HLT 0xF000 for A32 and HLT 0x3C for T32.
Implement these (in the same way we implement the existing HLT
semihosting trap for A64).

The old traps via SVC and BKPT are unaffected.

Signed-off-by: Peter Maydell <[email protected]>
Message-id: 1476792973[email protected]

8 years agohw/display: QOM'ify pl110.c
xiaoqiang zhao [Mon, 24 Oct 2016 15:26:56 +0000 (16:26 +0100)]
hw/display: QOM'ify pl110.c

Drop the old Sysbus init and use instance_init and
DeviceClass::realize instead

Signed-off-by: xiaoqiang zhao <[email protected]>
Message-id: 20161023091816[email protected]
[PMM: added accidentally dropped blank line]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agohw/arm: QOM'ify strongarm.c
xiaoqiang zhao [Mon, 24 Oct 2016 15:26:56 +0000 (16:26 +0100)]
hw/arm: QOM'ify strongarm.c

Drop the old Sysbus init and use instance_init and
DeviceClass::realize instead

Signed-off-by: xiaoqiang zhao <[email protected]>
Message-id: 20161023091816[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agohw/arm: QOM'ify pxa2xx_gpio.c
xiaoqiang zhao [Mon, 24 Oct 2016 15:26:55 +0000 (16:26 +0100)]
hw/arm: QOM'ify pxa2xx_gpio.c

Drop the old Sysbus init and use instance_init and
DeviceClass::realize instead

Signed-off-by: xiaoqiang zhao <[email protected]>
Message-id: 20161023091816[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agohw/arm: QOM'ify musicpal.c
xiaoqiang zhao [Mon, 24 Oct 2016 15:26:55 +0000 (16:26 +0100)]
hw/arm: QOM'ify musicpal.c

Drop the old Sysbus init and use instance_init and
DeviceClass::realize instead

Signed-off-by: xiaoqiang zhao <[email protected]>
Message-id: 20161023091816[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agotimer: stm32f2xx_timer: add check for prescaler value
Prasad J Pandit [Mon, 24 Oct 2016 15:26:55 +0000 (16:26 +0100)]
timer: stm32f2xx_timer: add check for prescaler value

The STM32F2XX Timer emulator uses a 16 bit prescaler value to
limit the timer clock rate. It does that by dividing the timer
frequency. If the prescaler 's->tim_psc' was set to be UINT_MAX,
it'd lead to divide by zero error. Limit prescaler value to 16
bits to avoid it.

Reported-by: Huawei PSIRT <[email protected]>
Signed-off-by: Prasad J Pandit <[email protected]>
Message-id: 1476800269[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agoi2c: Fix SMBus read transactions to avoid double events
Corey Minyard [Mon, 24 Oct 2016 15:26:55 +0000 (16:26 +0100)]
i2c: Fix SMBus read transactions to avoid double events

Change 2293c27faddf (i2c: implement broadcast write) added broadcast
capability to the I2C bus, but it broke SMBus read transactions.
An SMBus read transaction does two i2c_start_transaction() calls
without an intervening i2c_end_transfer() call.  This will
result in i2c_start_transfer() adding the same device to the
current_devs list twice, and then the ->event() for the same
device gets called twice in the second call to i2c_start_transfer(),
resulting in the smbus code getting confused.

Note that this happens even with pure I2C devices when simulating
SMBus over I2C.

This fix only scans the bus if the current set of devices is empty.
This means that the current set of devices stays fixed until
i2c_end_transfer() is called, which is really what you want.

This also deletes the empty check from the top of i2c_end_transfer().
It's unnecessary, and it prevents the broadcast variable from being
set to false at the end of the transaction if no devices were on
the bus.

Cc: KONRAD Frederic <[email protected]>
Cc: Alistair Francis <[email protected]>
Cc: Peter Crosthwaite <[email protected]>
Cc: Kwon <[email protected]>
Cc: Peter Maydell <[email protected]>
Signed-off-by: Corey Minyard <[email protected]>
Reviewed-by: KONRAD Frederic <[email protected]>
Tested-by: KONRAD Frederic <[email protected]>
Message-id: 1470153614[email protected]
Signed-off-by: Peter Maydell <[email protected]>
8 years agotimer: a9gtimer: remove loop to auto-increment comparator
Prasad J Pandit [Mon, 24 Oct 2016 15:26:54 +0000 (16:26 +0100)]
timer: a9gtimer: remove loop to auto-increment comparator

ARM A9MP processor has a peripheral timer with an auto-increment
register, which holds an increment step value. A user could set
this value to zero. When auto-increment control bit is enabled,
it leads to an infinite loop in 'a9_gtimer_update' while
updating comparator value. Remove this loop incrementing the
comparator value.

Reported-by: Li Qiang <[email protected]>
Signed-off-by: Prasad J Pandit <[email protected]>
Message-id: 1476733226[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agoARM: Virt: ACPI: Build an IORT table with RC and ITS nodes
Prem Mallappa [Mon, 24 Oct 2016 15:26:54 +0000 (16:26 +0100)]
ARM: Virt: ACPI: Build an IORT table with RC and ITS nodes

This patch builds an IORT table that features a root complex node and
an ITS node. This complements the ITS description in the ACPI MADT
table and allows vhost-net on ACPI guest.

Signed-off-by: Prem Mallappa <[email protected]>
Signed-off-by: Eric Auger <[email protected]>
Reviewed-by: Andrew Jones <[email protected]>
Message-id: 1476707466[email protected]
Signed-off-by: Peter Maydell <[email protected]>
8 years agoACPI: Add IORT Structure definition
Prem Mallappa [Mon, 24 Oct 2016 15:26:54 +0000 (16:26 +0100)]
ACPI: Add IORT Structure definition

ACPI Spec 6.0 introduces IO Remapping Table Structure. This patch
introduces the definitions required to describe the IO relationship
between the PCIe root complex and the ITS.

This conforms to:
"IO Remapping Table System Software on ARM Platforms",
Document number: ARM DEN 0049B, October 2015.

Signed-off-by: Prem Mallappa <[email protected]>
Signed-off-by: Eric Auger <[email protected]>
Reviewed-by: Andrew Jones <[email protected]>
Message-id: 1476707466[email protected]
Signed-off-by: Peter Maydell <[email protected]>
8 years agotests: Add tests for the ARM MPTimer
Dmitry Osipenko [Mon, 24 Oct 2016 15:26:54 +0000 (16:26 +0100)]
tests: Add tests for the ARM MPTimer

ARM MPTimer is a per-CPU core timer, essential part of the ARM Cortex-A9
MPCore. Add QTests for it.

Signed-off-by: Dmitry Osipenko <[email protected]>
Message-id: 1c9a2f1c80f87e935b4a28919457c81b6b2256e9.1475421224[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agoarm_mptimer: Convert to use ptimer
Dmitry Osipenko [Mon, 24 Oct 2016 15:26:53 +0000 (16:26 +0100)]
arm_mptimer: Convert to use ptimer

Current ARM MPTimer implementation uses QEMUTimer for the actual timer,
this implementation isn't complete and mostly tries to duplicate of what
generic ptimer is already doing fine.

Conversion to ptimer brings the following benefits and fixes:
- Simple timer pausing implementation
- Fixes counter value preservation after stopping the timer
- Properly handles prescaler != 0 / counter = 0 / load = 0 cases
- Code simplification and reduction

Bump VMSD to version 3, since VMState is changed and is not compatible
with the previous implementation.

Signed-off-by: Dmitry Osipenko <[email protected]>
Reviewed-by: Peter Crosthwaite <[email protected]>
Message-id: 37f378c33bb5a28d5cd71167a6bd5bff5e59cbc3.1475421224[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agotests: ptimer: Replace 10000 with 1
Dmitry Osipenko [Mon, 24 Oct 2016 15:26:53 +0000 (16:26 +0100)]
tests: ptimer: Replace 10000 with 1

The 10000 is an arbitrarily chosen value used for advancing the QEMU
time, so that ptimer's now != last. Change it to 1 to make code a bit
more readable.

Signed-off-by: Dmitry Osipenko <[email protected]>
Message-id: 63256eaac54c84dac7c797f41296cc49e751d09d.1475421224[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agotests: ptimer: Change the copyright comment
Dmitry Osipenko [Mon, 24 Oct 2016 15:26:53 +0000 (16:26 +0100)]
tests: ptimer: Change the copyright comment

Eric Blake suggested that use of "Author:" in the copyright text of the
files created by individuals is incorrect, replace it with "Copyright".

Signed-off-by: Dmitry Osipenko <[email protected]>
Message-id: 9d8b626f462d4a5094b1945fbd763b8a2e28dd86.1475421224[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agotests: ptimer: Add tests for "no counter round down" policy
Dmitry Osipenko [Mon, 24 Oct 2016 15:26:53 +0000 (16:26 +0100)]
tests: ptimer: Add tests for "no counter round down" policy

PTIMER_POLICY_NO_COUNTER_ROUND_DOWN makes ptimer_get_count() return the
actual counter value and not the one less.

Signed-off-by: Dmitry Osipenko <[email protected]>
Message-id: 0082889309b3dc66c03c8de00b8c1ef40c1e3955.1475421224[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agohw/ptimer: Add "no counter round down" policy
Dmitry Osipenko [Mon, 24 Oct 2016 15:26:52 +0000 (16:26 +0100)]
hw/ptimer: Add "no counter round down" policy

For most of the timers counter starts to decrement after first period
expires. Due to rounding down performed by the ptimer_get_count, it returns
counter - 1 for the running timer, so that for the ptimer user it looks
like counter gets decremented immediately after running the timer. Add "no
counter round down" policy that provides correct behaviour for those timers.

Signed-off-by: Dmitry Osipenko <[email protected]>
Message-id: ef39622d0ebfdc32a0877e59ffdf6910dc3db688.1475421224[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agotests: ptimer: Add tests for "no immediate reload" policy
Dmitry Osipenko [Mon, 24 Oct 2016 15:26:52 +0000 (16:26 +0100)]
tests: ptimer: Add tests for "no immediate reload" policy

PTIMER_POLICY_NO_IMMEDIATE_RELOAD makes ptimer to not to re-load
counter on setting counter value to "0" or starting to run with "0".

Signed-off-by: Dmitry Osipenko <[email protected]>
Message-id: a7acf805e447cc7f637ecacbd45cca34ea3bf425.1475421224[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agohw/ptimer: Add "no immediate reload" policy
Dmitry Osipenko [Mon, 24 Oct 2016 15:26:52 +0000 (16:26 +0100)]
hw/ptimer: Add "no immediate reload" policy

Immediate counter re-load on setting (or on starting to run with)
counter = 0 is a wrong behaviour for some of the timers. Add "no
immediate reload" policy that provides correct behaviour for such timers.

Signed-off-by: Dmitry Osipenko <[email protected]>
Message-id: bf9385cd2550ca451d564fa46007688cee3f3d9d.1475421224[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agotests: ptimer: Add tests for "no immediate trigger" policy
Dmitry Osipenko [Mon, 24 Oct 2016 15:26:52 +0000 (16:26 +0100)]
tests: ptimer: Add tests for "no immediate trigger" policy

PTIMER_POLICY_NO_IMMEDIATE_TRIGGER makes ptimer to not to trigger on starting
to run with / setting counter to "0".

Signed-off-by: Dmitry Osipenko <[email protected]>
Message-id: 12b1e745f90fe2ca3d59197166bc3d379260f912.1475421224[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agohw/ptimer: Add "no immediate trigger" policy
Dmitry Osipenko [Mon, 24 Oct 2016 15:26:51 +0000 (16:26 +0100)]
hw/ptimer: Add "no immediate trigger" policy

Performing trigger on setting (or starting to run with) counter = 0 could
be a wrong behaviour for some of the timers, provide "no immediate trigger"
policy to maintain correct behaviour for such timers.

Signed-off-by: Dmitry Osipenko <[email protected]>
Message-id: 72c0319cf2ec599f22397b7da280c06c34dc40dd.1475421224[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agotests: ptimer: Add tests for "continuous trigger" policy
Dmitry Osipenko [Mon, 24 Oct 2016 15:26:51 +0000 (16:26 +0100)]
tests: ptimer: Add tests for "continuous trigger" policy

PTIMER_POLICY_CONTINUOUS_TRIGGER makes periodic ptimer to re-trigger every
period in case of load = delta = 0.

Signed-off-by: Dmitry Osipenko <[email protected]>
Message-id: 7a908ab38b902d521eb959941f9efe2df8ce4297.1475421224[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agohw/ptimer: Add "continuous trigger" policy
Dmitry Osipenko [Mon, 24 Oct 2016 15:26:51 +0000 (16:26 +0100)]
hw/ptimer: Add "continuous trigger" policy

Currently, periodic timer that has load = delta = 0 performs trigger
on timer reload and stops, printing a "period zero" error message.
Introduce new policy that makes periodic timer to continuously trigger
with a period interval in case of load = 0.

Signed-off-by: Dmitry Osipenko <[email protected]>
Message-id: 632b23dd11055d9bd5e338d66b38fac0bd51462e.1475421224[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agotests: ptimer: Add tests for "wraparound after one period" policy
Dmitry Osipenko [Mon, 24 Oct 2016 15:26:51 +0000 (16:26 +0100)]
tests: ptimer: Add tests for "wraparound after one period" policy

PTIMER_POLICY_WRAP_AFTER_ONE_PERIOD changes ptimer behaviour in a such way,
that it would wrap around after one period instead of doing it immediately.

Signed-off-by: Dmitry Osipenko <[email protected]>
Message-id: ce27bb84ed9f2b64300dd4e90f3eff235a7dcedf.1475421224[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agohw/ptimer: Add "wraparound after one period" policy
Dmitry Osipenko [Mon, 24 Oct 2016 15:26:50 +0000 (16:26 +0100)]
hw/ptimer: Add "wraparound after one period" policy

Currently, periodic counter wraps around immediately once counter reaches
"0", this is wrong behaviour for some of the timers, resulting in one period
being lost. Add new ptimer policy that provides correct behaviour for such
timers, so that counter stays with "0" for a one period before wrapping
around.

Signed-off-by: Dmitry Osipenko <[email protected]>
Message-id: f22a670cf1f4be298b31640cb5f4be1df0f20ab6.1475421224[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agohw/arm/virt: Set minimum_page_bits to 12
Peter Maydell [Mon, 24 Oct 2016 15:26:50 +0000 (16:26 +0100)]
hw/arm/virt: Set minimum_page_bits to 12

Since the virt board model will never create a CPU which is
pre-ARMv7, we know that our minimum page size is 4K and can
set minimum_page_bits accordingly, for improved performance.

Note that this is a migration compatibility break, so
we introduce it only for the virt-2.8 machine and onward;
virt-2.7 continues using the old 1K pages.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
8 years agotarget-arm: Make page size a runtime setting
Peter Maydell [Mon, 24 Oct 2016 15:26:50 +0000 (16:26 +0100)]
target-arm: Make page size a runtime setting

Rather than defining TARGET_PAGE_BITS to always be 10,
switch to using a value picked at runtime. This allows us
to use 4K pages for modern ARM CPUs (and in particular all
64-bit CPUs) without having to drop support for the old
ARMv5 CPUs which had 1K pages.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
8 years agomigration/savevm.c: migrate non-default page size
Peter Maydell [Mon, 24 Oct 2016 15:26:50 +0000 (16:26 +0100)]
migration/savevm.c: migrate non-default page size

Add a subsection to vmstate_configuration which is present
only if the guest is using a target page size which is
different from the default. This allows us to helpfully
diagnose attempts to migrate between machines which
are using different target page sizes.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
8 years agocpu: Support a target CPU having a variable page size
Peter Maydell [Mon, 24 Oct 2016 15:26:49 +0000 (16:26 +0100)]
cpu: Support a target CPU having a variable page size

Support target CPUs having a page size which isn't knownn
at compile time. To use this, the CPU implementation should:
 * define TARGET_PAGE_BITS_VARY
 * not define TARGET_PAGE_BITS
 * define TARGET_PAGE_BITS_MIN to the smallest value it
   might possibly want for TARGET_PAGE_BITS
 * call set_preferred_target_page_bits() in its realize
   function to indicate the actual preferred target page
   size for the CPU (and report any error from it)

In CONFIG_USER_ONLY, the CPU implementation should continue
to define TARGET_PAGE_BITS appropriately for the guest
OS page size.

Machines which want to take advantage of having the page
size something larger than TARGET_PAGE_BITS_MIN must
set the MachineClass minimum_page_bits field to a value
which they guarantee will be no greater than the preferred
page size for any CPU they create.

Note that changing the target page size by setting
minimum_page_bits is a migration compatibility break
for that machine.

For debugging purposes, attempts to use TARGET_PAGE_SIZE
before it has been finally confirmed will assert.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
8 years agotranslate-all.c: Compute L1 page table properties at runtime
Vijaya Kumar K [Mon, 24 Oct 2016 15:26:49 +0000 (16:26 +0100)]
translate-all.c: Compute L1 page table properties at runtime

Remove L1 page mapping table properties computing
statically using macros which is dependent on
TARGET_PAGE_BITS. Drop macros V_L1_SIZE, V_L1_SHIFT,
V_L1_BITS macros and replace with variables which are
computed at early stage of VM boot.

Removing dependency can help to make TARGET_PAGE_BITS
dynamic.

Signed-off-by: Vijaya Kumar K <[email protected]>
Message-id: 1465808915[email protected]
[PMM:
 assert(v_l1_shift % V_L2_BITS == 0)
 cache v_l2_levels
 initialize from page_init() rather than vl.c
 minor code style fixes
 put v_l1_size into a local where used as a loop limit]
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agoexec.c: Remove static allocation of sub_section of sub_page
Vijaya Kumar K [Mon, 24 Oct 2016 15:26:49 +0000 (16:26 +0100)]
exec.c: Remove static allocation of sub_section of sub_page

Allocate sub_section dynamically. Remove dependency
on TARGET_PAGE_SIZE to make run-time page size detection
for arm platforms.

Signed-off-by: Vijaya Kumar K <[email protected]>
Message-id: 1465808915[email protected]
[PMM: use flexible array member rather than separate malloc
 so we don't need an extra pointer deref when using it]
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agomigration: Remove static allocation of xzblre cache buffer
Vijaya Kumar K [Mon, 24 Oct 2016 15:26:49 +0000 (16:26 +0100)]
migration: Remove static allocation of xzblre cache buffer

Allocate xzblre zero page cache buffer dynamically.
Remove dependency on TARGET_PAGE_SIZE to make run-time
page size detection for arm platforms.

Signed-off-by: Vijaya Kumar K <[email protected]>
Message-id: 1465808915[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
8 years agoMerge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
Peter Maydell [Mon, 24 Oct 2016 14:03:09 +0000 (15:03 +0100)]
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging

* KVM run_on_cpu fix (Alex)
* atomic usage fixes (Emilio, me)
* hugetlbfs alignment fix (Haozhong)
* CharBackend refactoring (Marc-André)
* test-i386 fixes (me)
* MemoryListener optimizations (me)
* Miscellaneous bugfixes (me)
* iSER support (Roy)
* --version formatting (Thomas)

# gpg: Signature made Mon 24 Oct 2016 14:46:19 BST
# gpg:                using RSA key 0xBFFBD25F78C7AE83
# gpg: Good signature from "Paolo Bonzini <[email protected]>"
# gpg:                 aka "Paolo Bonzini <[email protected]>"
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* remotes/bonzini/tags/for-upstream: (50 commits)
  exec.c: workaround regression caused by alignment change in d2f39ad
  char: remove explicit_be_open from CharDriverState
  char: use common error path in qmp_chardev_add
  char: replace avail_connections
  char: remove unused qemu_chr_fe_event
  char: use an enum for CHR_EVENT
  char: remove unused CHR_EVENT_FOCUS
  char: move fe_open in CharBackend
  char: remove explicit_fe_open, use a set_handlers argument
  char: rename chr_close/chr_free
  char: move front end handlers in CharBackend
  tests: start chardev unit tests
  char: make some qemu_chr_fe skip if no driver
  char: replace qemu_chr_claim/release with qemu_chr_fe_init/deinit
  vhost-user: only initialize queue 0 CharBackend
  char: fold qemu_chr_set_handlers in qemu_chr_fe_set_handlers
  char: use qemu_chr_fe* functions with CharBackend argument
  colo: claim in find_and_check_chardev
  char: rename some frontend functions
  char: remaining switch to CharBackend in frontend
  ...

Signed-off-by: Peter Maydell <[email protected]>
8 years agoexec.c: workaround regression caused by alignment change in d2f39ad
Haozhong Zhang [Mon, 24 Oct 2016 12:49:37 +0000 (20:49 +0800)]
exec.c: workaround regression caused by alignment change in d2f39ad

Commit d2f39ad "exec.c: Ensure right alignment also for file backed ram"
added an additional alignment requirement on the size of backend file
besides the previous page size. On x86, the alignment is changed from
4KB in QEMU 2.6 to 2MB in QEMU 2.7.

This change breaks certain usages in QEMU 2.7 on x86, e.g.
    -object memory-backend-file,id=mem1,mem-path=/tmp/,size=$SZ
    -device pc-dimm,id=dimm1,memdev=mem1
where $SZ is multiple of 4KB but not 2MB (e.g. 1023M). QEMU 2.7
reports the following error message and aborts:
qemu-system-x86_64: -device pc-dimm,memdev=mem1,id=nv1: backend memory size must be multiple of 0x200000

The same regression may also happen in other platforms as indicated by
Igor Mammedov. This change is however necessary for s390 according to
the commit message of d2f39ad, so we workaround the regression by taking
the change only on s390.

Signed-off-by: Haozhong Zhang <[email protected]>
Reported-by: "Xu, Anthony" <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: remove explicit_be_open from CharDriverState
Marc-André Lureau [Sat, 22 Oct 2016 10:09:43 +0000 (13:09 +0300)]
char: remove explicit_be_open from CharDriverState

It's only used in qmp_chardev_add(), so use a create() argument instead.

Also switched to typedef functions for CharDriverParse/CharDriverCreate.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022100951[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: use common error path in qmp_chardev_add
Marc-André Lureau [Sat, 22 Oct 2016 10:09:42 +0000 (13:09 +0300)]
char: use common error path in qmp_chardev_add

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022100951[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: replace avail_connections
Marc-André Lureau [Sat, 22 Oct 2016 10:09:41 +0000 (13:09 +0300)]
char: replace avail_connections

No need to count the users of a CharDriverState, it can rely on the fact
of whether there is a CharBackend associated or if there is enough space
in the muxer.

Simplify and fold chr_mux_new_fe() in qemu_chr_fe_init() since there is
a single user now. Also switch from fprintf to raising error instead.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022100951[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: remove unused qemu_chr_fe_event
Marc-André Lureau [Sat, 22 Oct 2016 10:09:40 +0000 (13:09 +0300)]
char: remove unused qemu_chr_fe_event

I introduced this function in d61b0c9a2f7f, but it isn't
used. Furthermore, it was incomplete, as it would need to translate QEMU
chr events to Spice port events.

(presumably it was used in the follow-up NBD-spice series that was not
completed: http://lists.gnu.org/archive/html/qemu-devel/2013-11/msg02024.html)

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022100951[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: use an enum for CHR_EVENT
Marc-André Lureau [Sat, 22 Oct 2016 10:09:39 +0000 (13:09 +0300)]
char: use an enum for CHR_EVENT

This may help to catch unhandled cases, and avoid having to maintain
numbering.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022100951[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: remove unused CHR_EVENT_FOCUS
Marc-André Lureau [Sat, 22 Oct 2016 10:09:38 +0000 (13:09 +0300)]
char: remove unused CHR_EVENT_FOCUS

Usage has long been removed, since commit f220174de8d9.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022100951[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: move fe_open in CharBackend
Marc-André Lureau [Sat, 22 Oct 2016 10:09:37 +0000 (13:09 +0300)]
char: move fe_open in CharBackend

The fe_open state belongs to front end.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022100951[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: remove explicit_fe_open, use a set_handlers argument
Marc-André Lureau [Sat, 22 Oct 2016 09:53:03 +0000 (12:53 +0300)]
char: remove explicit_fe_open, use a set_handlers argument

No need to keep explicit_fe_open around if it affects only a
qemu_chr_fe_set_handlers(). Use an additional argument instead.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: rename chr_close/chr_free
Marc-André Lureau [Sat, 22 Oct 2016 09:53:02 +0000 (12:53 +0300)]
char: rename chr_close/chr_free

The function is used to free the backend opaque pointer, let's name it
accordingly.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: move front end handlers in CharBackend
Marc-André Lureau [Sat, 22 Oct 2016 09:53:01 +0000 (12:53 +0300)]
char: move front end handlers in CharBackend

Since the hanlders are associated with a CharBackend, rather than the
CharDriverState, it is more appropriate to store in CharBackend. This
avoids the handler copy dance in qemu_chr_fe_set_handlers() then
mux_chr_update_read_handler(), by storing the CharBackend pointer
directly.

Also a mux CharDriver should go through mux->backends[focused], since
chr->be will stay NULL. Before that, it was possible to call
chr->handler by mistake with surprising results, for ex through
qemu_chr_be_can_write(), which would result in calling the last set
handler front end, not the one with focus.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agotests: start chardev unit tests
Marc-André Lureau [Sat, 22 Oct 2016 09:53:00 +0000 (12:53 +0300)]
tests: start chardev unit tests

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: make some qemu_chr_fe skip if no driver
Marc-André Lureau [Sat, 22 Oct 2016 09:52:59 +0000 (12:52 +0300)]
char: make some qemu_chr_fe skip if no driver

In most cases, front ends do not care about the side effect of
CharBackend, so we can simply skip the checks and call the qemu_chr_fe
functions even without associated CharDriver.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: replace qemu_chr_claim/release with qemu_chr_fe_init/deinit
Marc-André Lureau [Sat, 22 Oct 2016 09:52:58 +0000 (12:52 +0300)]
char: replace qemu_chr_claim/release with qemu_chr_fe_init/deinit

Now that all front end use qemu_chr_fe_init(), we can move chardev
claiming in init(), and add a function deinit() to release the chardev
and cleanup handlers.

The qemu_chr_fe_claim_no_fail() for property are gone, since the
property will raise an error instead. In other cases, where there is
already an error path, an error is raised instead. Finally, other cases
are handled by &error_abort in qemu_chr_fe_init().

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agovhost-user: only initialize queue 0 CharBackend
Marc-André Lureau [Sat, 22 Oct 2016 09:52:57 +0000 (12:52 +0300)]
vhost-user: only initialize queue 0 CharBackend

All the queues share the same chardev. Initialize only the first queue
CharBackend, and pass it to other queues. This will allow to claim the
chardev only once in a later change.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: fold qemu_chr_set_handlers in qemu_chr_fe_set_handlers
Marc-André Lureau [Sat, 22 Oct 2016 09:52:56 +0000 (12:52 +0300)]
char: fold qemu_chr_set_handlers in qemu_chr_fe_set_handlers

qemu_chr_add_handlers*() have been removed in previous change, so the
common qemu_chr_set_handlers() is no longer needed.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: use qemu_chr_fe* functions with CharBackend argument
Marc-André Lureau [Sat, 22 Oct 2016 09:52:55 +0000 (12:52 +0300)]
char: use qemu_chr_fe* functions with CharBackend argument

This also switches from qemu_chr_add_handlers() to
qemu_chr_fe_set_handlers(). Note that qemu_chr_fe_set_handlers() now
takes the focus when fe_open (qemu_chr_add_handlers() did take the
focus)

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agocolo: claim in find_and_check_chardev
Marc-André Lureau [Sat, 22 Oct 2016 09:52:54 +0000 (12:52 +0300)]
colo: claim in find_and_check_chardev

This factors out claiming of chardev, and changes the call to
non-fatal to return an error like the rest of the chardev checks.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: rename some frontend functions
Marc-André Lureau [Sat, 22 Oct 2016 09:52:53 +0000 (12:52 +0300)]
char: rename some frontend functions

qemu_chr_accept_input() and qemu_chr_disconnect() are only used by
frontend, so use qemu_chr_fe prefix.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: remaining switch to CharBackend in frontend
Marc-André Lureau [Sat, 22 Oct 2016 09:52:52 +0000 (12:52 +0300)]
char: remaining switch to CharBackend in frontend

Similar to previous change, for the remaining CharDriverState front ends
users.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: replace PROP_CHR with CharBackend
Marc-André Lureau [Sat, 22 Oct 2016 09:52:51 +0000 (12:52 +0300)]
char: replace PROP_CHR with CharBackend

Store the property in a CharBackend instead of CharDriverState*.  This
also replace systematically chr by chr.chr to access the
CharDriverState*. The following patches will replace it with calls to
qemu_chr_fe CharBackend functions.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: start converting mux driver to use CharBackend
Marc-André Lureau [Sat, 22 Oct 2016 09:52:50 +0000 (12:52 +0300)]
char: start converting mux driver to use CharBackend

Start using qemu_chr_fe* CharBackend functions:
initialize a CharBackend and use qemu_chr_fe_set_handlers().

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: introduce CharBackend
Marc-André Lureau [Sat, 22 Oct 2016 09:52:49 +0000 (12:52 +0300)]
char: introduce CharBackend

This new structure is meant to keep the details associated with a char
driver usage. On initialization, it gets a tag from the mux backend.
It can change its handlers thanks to qemu_chr_fe_set_handlers().

This structure is introduced so that all frontend will be moved to hold
and use a CharBackend. This will allow to better track char usage and
allocation, and help prevent some memory leaks or corruption.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agomux: split mux_chr_update_read_handler()
Marc-André Lureau [Sat, 22 Oct 2016 09:52:48 +0000 (12:52 +0300)]
mux: split mux_chr_update_read_handler()

Make qemu_chr_add_handlers_full() aware of mux handling. This allows
introduction of a tag associated with the fe handlers and a
qemu_chr_set_handlers() function to set the handler for a particular
tag. That will allow to get rid of qemu_chr_add_handlers*() in later
changes, in favor of qemu_chr_fe_set_handler().

To this end, chr_update_read_handler callback is enhanced with a tag
argument, and mux_chr_update_read_handler() is splitted in new
functions: mux_chr_new_handler_tag(), mux_chr_set_handlers(),
mux_set_focus().

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agoxilinx: fix buffer overflow on realize
Paolo Bonzini [Sun, 23 Oct 2016 15:42:22 +0000 (17:42 +0200)]
xilinx: fix buffer overflow on realize

ASAN complains about buffer overflow when running:
aarch64-softmmu/qemu-system-aarch64 -machine xilinx-zynq-a9

==476==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000035e38 at pc 0x000000f75253 bp 0x7ffc597e0ec0 sp 0x7ffc597e0eb0
READ of size 8 at 0x602000035e38 thread T0
    #0 0xf75252 in xilinx_spips_realize hw/ssi/xilinx_spips.c:623
    #1 0xb9ef6c in device_set_realized hw/core/qdev.c:918
    #2 0x129ae01 in property_set_bool qom/object.c:1854
    #3 0x1296e70 in object_property_set qom/object.c:1088
    #4 0x129dd1b in object_property_set_qobject qom/qom-qobject.c:27
    #5 0x1297168 in object_property_set_bool qom/object.c:1157
    #6 0xb9aeac in qdev_init_nofail hw/core/qdev.c:358
    #7 0x78a5bf in zynq_init_spi_flashes /home/elmarco/src/qemu/hw/arm/xilinx_zynq.c:125
    #8 0x78af60 in zynq_init /home/elmarco/src/qemu/hw/arm/xilinx_zynq.c:238
    #9 0x998eac in main /home/elmarco/src/qemu/vl.c:4534
    #10 0x7f96ed692730 in __libc_start_main (/lib64/libc.so.6+0x20730)
    #11 0x41d0a8 in _start (/home/elmarco/src/qemu/aarch64-softmmu/qemu-system-aarch64+0x41d0a8)

0x602000035e38 is located 0 bytes to the right of 8-byte region [0x602000035e30,0x602000035e38)
allocated by thread T0 here:
    #0 0x7f970b014e60 in malloc (/lib64/libasan.so.3+0xc6e60)
    #1 0x7f96f15b0e18 in g_malloc (/lib64/libglib-2.0.so.0+0x4ee18)
    #2 0xb9ef6c in device_set_realized hw/core/qdev.c:918
    #3 0x129ae01 in property_set_bool qom/object.c:1854
    #4 0x1296e70 in object_property_set qom/object.c:1088
    #5 0x129dd1b in object_property_set_qobject qom/qom-qobject.c:27
    #6 0x1297168 in object_property_set_bool qom/object.c:1157
    #7 0xb9aeac in qdev_init_nofail hw/core/qdev.c:358
    #8 0x78a5bf in zynq_init_spi_flashes /home/elmarco/src/qemu/hw/arm/xilinx_zynq.c:125
    #9 0x78af60 in zynq_init /home/elmarco/src/qemu/hw/arm/xilinx_zynq.c:238
    #10 0x998eac in main /home/elmarco/src/qemu/vl.c:4534
    #11 0x7f96ed692730 in __libc_start_main (/lib64/libc.so.6+0x20730)

s->spi is allocated with the size of num_busses which may be 1 (by
default).  Change to use a loop up to s->num_busses also for the
call to ssi_auto_connect_slaves().

Reported-by: Marc-André Lureau <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: remove init callback
Marc-André Lureau [Sat, 22 Oct 2016 09:52:46 +0000 (12:52 +0300)]
char: remove init callback

The CharDriverState.init() callback is no longer set since commit
a61ae7f88ce and thus unused. The only user, the malta FGPA display has
been converted to use an event "opened" callback instead.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agomalta: replace chr init by CHR_EVENT_OPENED handler
Marc-André Lureau [Sat, 22 Oct 2016 09:52:45 +0000 (12:52 +0300)]
malta: replace chr init by CHR_EVENT_OPENED handler

The CharDriverState.init() callback was introduced in commit
ceecf1d158. It is only called from text_console_do_init(), but it is no
longer set since commit a61ae7f88 (init assignment has been removed by
accident).

It seems correct to use an event callback instead and print the console
text on CHR_EVENT_OPENED. That way we can remove the single user of
CharDriverState init().

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agosun4uv: fix serial initialization regression
Marc-André Lureau [Sat, 22 Oct 2016 09:52:44 +0000 (12:52 +0300)]
sun4uv: fix serial initialization regression

Since commit b6607a1a204d, serial_hds_isa_init() was introduced to
factor out serial_isa_init() loops. However, sun4uv shouldn't start from
0 when there is a mm serial on 0 already. Add a "from" argument to
serial_hds_isa_init().

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agoringbuf: fix chr_write return value
Marc-André Lureau [Sat, 22 Oct 2016 09:52:43 +0000 (12:52 +0300)]
ringbuf: fix chr_write return value

It should return the number of written bytes.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: remove use-after-free on win-stdio
Marc-André Lureau [Sat, 22 Oct 2016 09:52:42 +0000 (12:52 +0300)]
char: remove use-after-free on win-stdio

Found by reviewing the code, win_stdio_close() is called by
qemu_chr_free() which then call qemu_chr_free_common() taking care of
freeing CharDriverState*.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agorng: remove unused included header
Marc-André Lureau [Sat, 22 Oct 2016 09:52:41 +0000 (12:52 +0300)]
rng: remove unused included header

DEFINE_PROP_CHR is not used (rng is not of TYPE_DEVICE)

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161022095318[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar.h: misc doc fix
Marc-André Lureau [Tue, 11 Oct 2016 15:20:12 +0000 (19:20 +0400)]
char.h: misc doc fix

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20161011152012[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: serial: check divider value against baud base
Prasad J Pandit [Wed, 12 Oct 2016 05:58:08 +0000 (11:28 +0530)]
char: serial: check divider value against baud base

16550A UART device uses an oscillator to generate frequencies
(baud base), which decide communication speed. This speed could
be changed by dividing it by a divider. If the divider is
greater than the baud base, speed is set to zero, leading to a
divide by zero error. Add check to avoid it.

Reported-by: Huawei PSIRT <[email protected]>
Signed-off-by: Prasad J Pandit <[email protected]>
Message-Id: <1476251888[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agomemory: optimize memory_region_sync_dirty_bitmap
Paolo Bonzini [Fri, 23 Sep 2016 09:08:54 +0000 (11:08 +0200)]
memory: optimize memory_region_sync_dirty_bitmap

Avoid walking the FlatView of all address spaces.  Most of the
address spaces will have no log_sync callback on their listeners.

Signed-off-by: Paolo Bonzini <[email protected]>
8 years agomemory: optimize memory_global_dirty_log_sync
Paolo Bonzini [Thu, 22 Sep 2016 14:09:08 +0000 (16:09 +0200)]
memory: optimize memory_global_dirty_log_sync

Only return a nonzero dirty_log_mask for RAM/ROM memory regions.

Signed-off-by: Paolo Bonzini <[email protected]>
8 years agomemory: add a per-AddressSpace list of listeners
Paolo Bonzini [Thu, 22 Sep 2016 14:23:06 +0000 (16:23 +0200)]
memory: add a per-AddressSpace list of listeners

This speeds up MEMORY_LISTENER_CALL noticeably.  Right now,
with many PCI devices you have N regions added to M AddressSpaces
(M = # PCI devices with bus-master enabled) and each call looks
up the whole listener list, with at least M listeners in it.
Because most of the regions in N are BARs, which are also roughly
proportional to M, the whole thing is O(M^3).  This changes it
to O(M^2), which is the best we can do without rewriting the
whole thing.

Signed-off-by: Paolo Bonzini <[email protected]>
8 years agomemory: eliminate global MemoryListeners
Paolo Bonzini [Thu, 22 Sep 2016 14:11:54 +0000 (16:11 +0200)]
memory: eliminate global MemoryListeners

There is none, so just drop the code.

Signed-off-by: Paolo Bonzini <[email protected]>
8 years agotcg: try sti when moving a constant into a dead memory temp
Paolo Bonzini [Thu, 15 Sep 2016 13:16:00 +0000 (15:16 +0200)]
tcg: try sti when moving a constant into a dead memory temp

This comes from free from unifying tcg_reg_alloc_mov and
tcg_reg_alloc_movi's handling of TEMP_VAL_CONST.  It triggers
often on moves to cc_dst, such as the following translation
of "sub $0x3c,%esp":

  before:                          after:
  subl   $0x3c,%ebp                subl   $0x3c,%ebp
  movl   %ebp,0x10(%r14)           movl   %ebp,0x10(%r14)
  movl   $0x3c,%ebx                movl   $0x3c,0x2c(%r14)
  movl   %ebx,0x2c(%r14)

Signed-off-by: Paolo Bonzini <[email protected]>
Message-Id: <1473945360[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agotarget-i386: fix 32-bit addresses in LEA
Paolo Bonzini [Wed, 12 Oct 2016 07:23:39 +0000 (09:23 +0200)]
target-i386: fix 32-bit addresses in LEA

This was found with test-i386.  The issue is that instructions
such as

    addr32 lea (%eax), %rax

did not perform a 32-bit extension, because the LEA translation
skipped the gen_lea_v_seg step.  That step does not just add
segments, it also takes care of extending from address size to
pointer size.

Signed-off-by: Paolo Bonzini <[email protected]>
8 years agotest-i386: fix bitrot for 64-bit
Paolo Bonzini [Wed, 12 Oct 2016 06:57:19 +0000 (08:57 +0200)]
test-i386: fix bitrot for 64-bit

Signed-off-by: Paolo Bonzini <[email protected]>
8 years agoqht-bench: relax test_start/stop atomic accesses
Emilio G. Cota [Fri, 14 Oct 2016 09:54:51 +0000 (11:54 +0200)]
qht-bench: relax test_start/stop atomic accesses

test_start/stop are used only as flags to loop on. Barriers are unnecessary,
since no dependent data is transferred among threads apart from the flags
themselves.

This commit relaxes the three accesses to test_start/stop that were
not yet relaxed.

Signed-off-by: Emilio G. Cota <[email protected]>
8 years agoatomic: base mb_read/mb_set on load-acquire and store-release
Paolo Bonzini [Mon, 19 Sep 2016 09:36:44 +0000 (11:36 +0200)]
atomic: base mb_read/mb_set on load-acquire and store-release

This introduces load-acquire and store-release operations in QEMU.
For now, just use them as an implementation detail of atomic_mb_read
and atomic_mb_set.

Since docs/atomics.txt documents that atomic_mb_read only synchronizes
with an atomic_mb_set of the same variable, we can use the new implementation
everywhere instead of seq-cst loads and stores.

Signed-off-by: Paolo Bonzini <[email protected]>
8 years agorcu: simplify memory barriers
Paolo Bonzini [Mon, 19 Sep 2016 09:27:46 +0000 (11:27 +0200)]
rcu: simplify memory barriers

Thanks to the acquire semantics of qemu_event_reset and qemu_event_wait,
some memory barriers can be removed.

Signed-off-by: Paolo Bonzini <[email protected]>
8 years agoqemu-thread: use acquire/release to clarify semantics of QemuEvent
Paolo Bonzini [Mon, 19 Sep 2016 09:10:57 +0000 (11:10 +0200)]
qemu-thread: use acquire/release to clarify semantics of QemuEvent

Do not use the somewhat mysterious atomic_mb_read/atomic_mb_set,
instead make sure that the operations on QemuEvent are annotated
with the desired acquire and release semantics.

In particular, qemu_event_set wakes up the waiting thread, so it must
be a release from the POV of the waker (compare with qemu_mutex_unlock).
And it actually needs a full barrier, because that's the only thing that
provides something like a "load-release".

Use smp_mb_acquire until we have atomic_load_acquire and
atomic_store_release in atomic.h.

Signed-off-by: Paolo Bonzini <[email protected]>
8 years agoatomic: introduce smp_mb_acquire and smp_mb_release
Paolo Bonzini [Mon, 19 Sep 2016 08:50:38 +0000 (10:50 +0200)]
atomic: introduce smp_mb_acquire and smp_mb_release

Signed-off-by: Paolo Bonzini <[email protected]>
8 years agoPut the copyright information on a separate line
Thomas Huth [Wed, 5 Oct 2016 09:54:44 +0000 (11:54 +0200)]
Put the copyright information on a separate line

The output string QEMU with "--version" is very long, it does
not fit into a normal line of a terminal window anymore. By
putting the copyright information on a separate line instead,
the output looks much nicer.

Signed-off-by: Thomas Huth <[email protected]>
Message-Id: <1475661284[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agoblock/iscsi: Adding new iSER transport layer option
Roy Shterman [Sun, 9 Oct 2016 08:14:56 +0000 (11:14 +0300)]
block/iscsi: Adding new iSER transport layer option

iSER is a new transport layer supported in Libiscsi,
iSER provides a zero-copy RDMA capable interface that can
improve performance.

In order to use the new iSER transport one need to have RDMA supported HW
and to choose iser as the protocol name in Libiscsi URI.

For now iSER memory buffers are pre-allocated and pre-registered,
hence in order to work with iSER from QEMU, one need to enable
MEMLOCK attribute in the VM to be large enough for all iSER buffers and RDMA
resources.

Signed-off-by: Roy Shterman <[email protected]>
Message-Id: <1476000896[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agoblock/iscsi: Introducing new zero-copy API
Roy Shterman [Sun, 9 Oct 2016 08:14:55 +0000 (11:14 +0300)]
block/iscsi: Introducing new zero-copy API

A new API to deploy zero-copy command submission. The new API takes I/O
vectors list and number of I/O vectors to submit as input parameters
when initiating the command. New API must be used if working with
iSER transport option.

Signed-off-by: Roy Shterman <[email protected]>
Message-Id: <1476000896[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agoMerge remote-tracking branch 'remotes/sstabellini/tags/xen-20161021-tag' into staging
Peter Maydell [Mon, 24 Oct 2016 09:26:44 +0000 (10:26 +0100)]
Merge remote-tracking branch 'remotes/sstabellini/tags/xen-20161021-tag' into staging

Xen 2016/10/21

# gpg: Signature made Fri 21 Oct 2016 20:52:42 BST
# gpg:                using RSA key 0x894F8F4870E1AE90
# gpg: Good signature from "Stefano Stabellini <[email protected]>"
# gpg:                 aka "Stefano Stabellini <[email protected]>"
# Primary key fingerprint: D04E 33AB A51F 67BA 07D3  0AEA 894F 8F48 70E1 AE90

* remotes/sstabellini/tags/xen-20161021-tag:
  xen_platform: SUSE xenlinux unplug for emulated PCI
  xen_platform: unplug also SCSI disks
  xen-usb: do not reference PAGE_SIZE

Signed-off-by: Peter Maydell <[email protected]>
8 years agorbd: shift byte count as a 64-bit value
Paolo Bonzini [Mon, 10 Oct 2016 19:58:58 +0000 (21:58 +0200)]
rbd: shift byte count as a 64-bit value

Otherwise, reads of more than 2GB fail.  Until commit
7bbca9e290a9c7c217b5a24fc6094e91e54bd05d, reads of 2^41
bytes succeeded at least theoretically.

In fact, pdiscard ought to receive a 64-bit integer as the
count for the same reason.

Reported by Coverity.

Fixes: 7bbca9e290a9c7c217b5a24fc6094e91e54bd05d
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agokvm-all: don't use stale dbg_data->cpu
Alex Bennée [Mon, 10 Oct 2016 15:46:25 +0000 (16:46 +0100)]
kvm-all: don't use stale dbg_data->cpu

The changes to run_on_cpu and friends mean that all helpers are passed
the CPUState of vCPU they are running on. The conversion missed the
field in commit e0eeb4a21a3ca4b296220ce4449d8acef9de9049 which
introduced bugs.

Reported-by: Claudio Imbrenda <[email protected]>
Tested-by: Claudio Imbrenda <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
Message-Id: <20161010154625[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agoxen_platform: SUSE xenlinux unplug for emulated PCI
Olaf Hering [Fri, 21 Oct 2016 12:37:07 +0000 (14:37 +0200)]
xen_platform: SUSE xenlinux unplug for emulated PCI

Implement SUSE specific unplug protocol for emulated PCI devices
in PVonHVM guests. Its a simple 'outl(1, (ioaddr + 4));'.
This protocol was implemented and used since Xen 3.0.4.
It is used in all SUSE/SLES/openSUSE releases up to SLES11SP3 and
openSUSE 12.3.
In addition old (pre-2011) VMDP versions are handled as well.

Signed-off-by: Olaf Hering <[email protected]>
Reviewed-by: Stefano Stabellini <[email protected]>
Signed-off-by: Stefano Stabellini <[email protected]>
8 years agoxen_platform: unplug also SCSI disks
Olaf Hering [Fri, 21 Oct 2016 12:37:06 +0000 (14:37 +0200)]
xen_platform: unplug also SCSI disks

Using 'vdev=sd[a-o]' will create an emulated LSI controller, which can
be used by the emulated BIOS to boot from disk. If the HVM domU has also
PV driver the disk may appear twice in the guest. To avoid this an
unplug of the emulated hardware is needed, similar to what is done for
IDE and NIC drivers already.

Since the SCSI controller provides only disks the entire controller can
be unplugged at once.

Impact of the change for classic and pvops based guest kernels:

 vdev=sda:disk0
before: pvops:   disk0=pv xvda + emulated sda
        classic: disk0=pv sda  + emulated sdq
after:  pvops:   disk0=pv xvda
        classic: disk0=pv sda

 vdev=hda:disk0, vdev=sda:disk1
before: pvops:   disk0=pv xvda
                 disk1=emulated sda
        classic: disk0=pv hda
                 disk1=pv sda  + emulated sdq
after:  pvops:   disk0=pv xvda
                 disk1=not accessible by blkfront, index hda==index sda
        classic: disk0=pv hda
                 disk1=pv sda

 vdev=hda:disk0, vdev=sda:disk1, vdev=sdb:disk2
before: pvops:   disk0=pv xvda
                 disk1=emulated sda
                 disk2=pv xvdb + emulated sdb
        classic: disk0=pv hda
                 disk1=pv sda  + emulated sdq
                 disk2=pv sdb  + emulated sdr
after:  pvops:   disk0=pv xvda
                 disk1=not accessible by blkfront, index hda==index sda
                 disk2=pv xvdb
        classic: disk0=pv hda
                 disk1=pv sda
                 disk2=pv sda

Signed-off-by: Olaf Hering <[email protected]>
Reviewed-by: Stefano Stabellini <[email protected]>
Signed-off-by: Stefano Stabellini <[email protected]>
8 years agoxen-usb: do not reference PAGE_SIZE
Stefano Stabellini [Fri, 21 Oct 2016 19:08:27 +0000 (12:08 -0700)]
xen-usb: do not reference PAGE_SIZE

PAGE_SIZE is undefined on ARM64. Use XC_PAGE_SIZE instead, which is
always 4096 even when page granularity is 64K.

For this to actually work with 64K pages, more changes are required.

Signed-off-by: Stefano Stabellini <[email protected]>
Reviewed-by: Juergen Gross <[email protected]>
Release-acked-by: Wei Liu <[email protected]>
8 years agoMerge remote-tracking branch 'remotes/riku/tags/pull-linux-user-20160921' into staging
Peter Maydell [Fri, 21 Oct 2016 12:49:58 +0000 (13:49 +0100)]
Merge remote-tracking branch 'remotes/riku/tags/pull-linux-user-20160921' into staging

Linux-user changes, mostly bugfixes and adding support for some
new syscalls and some obscure syscalls as well. Includes some
missed patches from earlier rounds, and dropping unicore32 target.

v2: fix the syslog patch and test build with clang-3.8
v3: drop ustat patch

# gpg: Signature made Fri 21 Oct 2016 13:38:06 BST
# gpg:                using RSA key 0xB44890DEDE3C9BC0
# gpg: Good signature from "Riku Voipio <[email protected]>"
# gpg:                 aka "Riku Voipio <[email protected]>"
# Primary key fingerprint: FF82 03C8 C391 98AE 0581  41EF B448 90DE DE3C 9BC0

* remotes/riku/tags/pull-linux-user-20160921: (21 commits)
  linux-user: disable unicore32 linux-user build
  linux-user: added support for pwritev() system call.
  linux-user: added support for preadv() system call.
  linux-user: Fix fadvise64() syscall support for Mips32
  linux-user: Redirect termbits.h for Mips64 to termbits.h for Mips32
  linux-user: Update ioctls definitions for Mips32
  linux-user: Update mips_syscall_args[] array in main.c
  linux-user: Add support for syncfs() syscall
  linux-user: Add support for clock_adjtime() syscall
  linux-user: Fix definition of target_sigevent for 32-bit guests
  linux-user: use libc wrapper instead of direct mremap syscall
  linux-user: Don't use alloca() for epoll_wait's epoll event array
  linux-user: add RTA_PRIORITY in netlink
  linux-user: add kcmp() syscall
  linux-user: sparc64: Use correct target SHMLBA in shmat()
  linux-user: Remove a duplicate item from strace.list
  linux-user: Fix syslog() syscall support
  linux-user: Fix socketcall() syscall support
  linux-user: Fix msgrcv() and msgsnd() syscalls support
  linux-user: Fix mq_open() syscall support
  ...

Signed-off-by: Peter Maydell <[email protected]>
8 years agolinux-user: disable unicore32 linux-user build
Riku Voipio [Wed, 28 Sep 2016 00:33:23 +0000 (03:33 +0300)]
linux-user: disable unicore32 linux-user build

In order to cleanup linux-user, we need support for most relatively
modern syscalls. unicore32 lacks support for syscalls like
epoll_pwait, preventing cleaning up the CONFIG_EPOLL mess.

This patch can be reverted when unicore32 starts either supporting
the syscalls as defined in mainline kernel, or the oldabi interface
gains support for syscalls supported since at kernel 2.6.19 / glibc 2.6

Cc: MPRC <[email protected]>
Cc: Xuetao Guan <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
8 years agolinux-user: added support for pwritev() system call.
Dejan Jovicevic [Tue, 11 Oct 2016 09:52:47 +0000 (11:52 +0200)]
linux-user: added support for pwritev() system call.

This system call performs the same task as the writev() system call,
with the exception of having the fourth argument, offset, which
specifes the file offset at which the input operation is to be performed.
Because of this, the pwritev() implementation is based on the writev()
implementation in linux-user mode.

But, since pwritev() is implemented in the kernel as a 5-argument syscall,
5 arguments are needed to be handled as input and passed to the host
syscall.

The pos_l and pos_h argument of the safe_pwritev() are of type unsigned
long, which can be of different sizes on different platforms. The input
arguments are converted to the appropriate host size when passed to
safe_pwritev().

Signed-off-by: Dejan Jovicevic <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
8 years agolinux-user: added support for preadv() system call.
Dejan Jovicevic [Tue, 11 Oct 2016 09:52:46 +0000 (11:52 +0200)]
linux-user: added support for preadv() system call.

This system call performs the same task as the readv() system call,
with the exception of having the fourth argument, offset, which
specifes the file offset at which the input operation is to be performed.
Because of this, the preadv() implementation is based on the readv()
implementation in linux-user mode.

But, since preadv() is implemented in the kernel as a 5-argument syscall,
5 arguments are needed to be handled as input and passed to the host
syscall.

The pos_l and pos_h argument of the safe_preadv() are of type unsigned
long, which can be of different sizes on different platforms. The input
arguments are converted to the appropriate host size when passed to
safe_preadv().

Signed-off-by: Dejan Jovicevic <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
8 years agolinux-user: Fix fadvise64() syscall support for Mips32
Aleksandar Markovic [Wed, 12 Oct 2016 12:30:25 +0000 (14:30 +0200)]
linux-user: Fix fadvise64() syscall support for Mips32

By looking at the file arch/mips/kernel/scall32-o32.S in Linux
kernel, it can be deduced that, for Mips32 platform, syscall
corresponding to number _NR_fadvise64 as defined in kernel file
arch/mips/include/uapi/asm/unistd.h translates to kernel function
sys_fadvise64_64, and that argument layout for this system call is
as follows:

              0             32 0             32
             +----------------+----------------+
      (arg1) |       fd       |     __pad      | (arg2)
             +----------------+----------------+
      (arg3) |             buffer              | (arg4)
             +----------------+----------------+
      (arg5) |               len               | (arg6)
             +----------------+----------------+
      (arg7) |     advise     |    not used    | (arg8)
             +----------------+----------------+

The same argument layout can be deduced from glibc code, and
relevant commit messages in linux kernel and glibc.

The fix is to change TARGET_NR_fadvise64 to TARGET_NR_fadvise64_64
in Mips32 syscall numbers table. Array mips_syscall_args[] in
linux-user/main.c also already have "fadvise64_64" (and not
"fadvise64") in corresponding place for the syscall number in
question, so no change for linux-user/main.c.

This patch also fixes the failure LTP test posix_fadvise03, if
executed on Qemu-emulated Mips32 platform (user mode).

Signed-off-by: Aleksandar Rikalo <[email protected]>
Signed-off-by: Miroslav Tisma <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
8 years agolinux-user: Redirect termbits.h for Mips64 to termbits.h for Mips32
Aleksandar Markovic [Wed, 12 Oct 2016 12:30:24 +0000 (14:30 +0200)]
linux-user: Redirect termbits.h for Mips64 to termbits.h for Mips32

linux-user/mips64/termbits.h and linux-user/mips/termbits.h
originate from the same files in Linux kernel. There is no plan
to split original headers in Linux kernel into Mips32 and Mips64
versions any time soon. Therefore, it is better not to have
separate Mips32 and Mips64 variants in Qemu.

This patch makes these two files effectively the same, allowing the
mainenance by changing only a single file. (This is already done in
the same fashion for some other headers in same directories.)

Signed-off-by: Aleksandar Markovic <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
8 years agolinux-user: Update ioctls definitions for Mips32
Aleksandar Markovic [Wed, 12 Oct 2016 12:30:23 +0000 (14:30 +0200)]
linux-user: Update ioctls definitions for Mips32

Update linux-user/mips/termbits.h with ioctl definitions from kernel
file arch/mips/include/uapi/asm/ioctls.h.

Signed-off-by: Aleksandar Markovic <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
8 years agolinux-user: Update mips_syscall_args[] array in main.c
Aleksandar Markovic [Wed, 12 Oct 2016 12:30:22 +0000 (14:30 +0200)]
linux-user: Update mips_syscall_args[] array in main.c

Array mips_syscall_args[] determines number of arguments for each
syscall on Mips32. It wasn't updated with newer syscalls. Also,
preadv and pwritev have 5 arguments, not 6.

Signed-off-by: Aleksandar Markovic <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
8 years agolinux-user: Add support for syncfs() syscall
Aleksandar Markovic [Mon, 10 Oct 2016 11:23:30 +0000 (13:23 +0200)]
linux-user: Add support for syncfs() syscall

This patch implements Qemu user mode syncfs() syscall support. Syscall
syncfs() syncs the filesystem containing file determined by the open
file descriptor passed as the argument to syncfs().

The implementation consists of a straightforward invocation of host's
syncfs(). Configure and strace support is included as well.

Signed-off-by: Aleksandar Markovic <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
8 years agolinux-user: Add support for clock_adjtime() syscall
Aleksandar Markovic [Mon, 10 Oct 2016 11:23:29 +0000 (13:23 +0200)]
linux-user: Add support for clock_adjtime() syscall

This patch implements Qemu user mode clock_adjtime() syscall support.

The implementation is based on invocation of host's clock_adjtime().

Signed-off-by: Aleksandar Rikalo <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
8 years agolinux-user: Fix definition of target_sigevent for 32-bit guests
Peter Maydell [Fri, 2 Sep 2016 17:40:01 +0000 (18:40 +0100)]
linux-user: Fix definition of target_sigevent for 32-bit guests

The sigevent structure includes a union with some fields which
are pointers. For the QEMU target_sigevent structure we must
represent these as abi_ulongs, not host function pointers.

This error was causing the compiler to believe it should 8-align
the _sigev_un union on a 64-bit host, which meant that the
code in target_to_host_sigevent() was looking at the wrong
offset to find the _tid field, and timer_create() would
spuriously fail with EINVAL.

This fixes the final loose end noted in LP:1042388.

While we're editing the structure, switch the 'int32_t' fields
to 'abi_int'; this will only matter for guests with non-standard
integer alignment like m68k.

Signed-off-by: Peter Maydell <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
8 years agolinux-user: use libc wrapper instead of direct mremap syscall
Felix Janda [Fri, 30 Sep 2016 23:39:27 +0000 (19:39 -0400)]
linux-user: use libc wrapper instead of direct mremap syscall

This commit essentially reverts commit
3af72a4d98dca033492102603734cbc63cd2694a, which has replaced
five-argument calls to mremap() by direct mremap syscalls for
compatibility with glibc older than version 2.4.

The direct syscall was buggy for 64bit targets on 32bit hosts
because of the default integer type promotions. Since glibc-2.4
is now a decade old, we can remove this workaround.

Signed-off-by: Felix Janda <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
8 years agolinux-user: Don't use alloca() for epoll_wait's epoll event array
Peter Maydell [Mon, 18 Jul 2016 14:36:00 +0000 (15:36 +0100)]
linux-user: Don't use alloca() for epoll_wait's epoll event array

The epoll event array which epoll_wait() allocates has a size
determined by the guest which could potentially be quite large.
Use g_try_new() rather than alloca() so that we can fail more
cleanly if the guest hands us an oversize value. (ENOMEM is
not a documented return value for epoll_wait() but in practice
some kernel configurations can return it -- see for instance
sys_oabi_epoll_wait() on ARM.)

This rearrangement includes fixing a bug where we were
incorrectly passing a negative length to unlock_user() in
the error-exit codepath.

Signed-off-by: Peter Maydell <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
This page took 0.092385 seconds and 4 git commands to generate.