Commit graph

78832 commits

Author SHA1 Message Date
Laurent Vivier 6733d57035 linux-user: fix the errno value in print_syscall_err()
errno of the target is returned as a negative value by the syscall,
not in the host errno variable.

The emulation of the target syscall can return an error while the
host doesn't set an errno value. Target errnos and host errnos can
also differ in some cases.

Fixes: c84be71f68 ("linux-user: Extend strace support to enable argument printing after syscall execution")
Cc: Filip.Bozuta@syrmia.com
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Message-Id: <20200708152435.706070-2-laurent@vivier.eu>
2020-07-14 09:29:14 +02:00
Laurent Vivier 65b261a63a linux-user: add netlink RTM_SETLINK command
This command is needed to be able to boot systemd in a container.

  $ sudo systemd-nspawn -D /chroot/armhf/sid/ -b
  Spawning container sid on /chroot/armhf/sid.
  Press ^] three times within 1s to kill container.
  systemd 245.6-2 running in system mode.
  Detected virtualization systemd-nspawn.
  Detected architecture arm.

  Welcome to Debian GNU/Linux bullseye/sid!

  Set hostname to <virt-arm>.
  Failed to enqueue loopback interface start request: Operation not supported
  Caught <SEGV>, dumped core as pid 3.
  Exiting PID 1...
  Container sid failed with error code 255.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200709072332.890440-2-laurent@vivier.eu>
2020-07-13 21:26:33 +02:00
Laurent Vivier d9679ee592 linux-user: add new netlink types
Only implement IFLA_PERM_ADDRESS to fix the following error:

  Unknown host QEMU_IFLA type: 54

The couple of other ones, IFLA_PROP_LIST and IFLA_ALT_IFNAME, have
been introduced to be used with RTM_NEWLINKPROP, RTM_DELLINKPROP and
RTM_GETLINKPROP that are not implemented by QEMU.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200709072332.890440-1-laurent@vivier.eu>
2020-07-13 21:25:33 +02:00
Laurent Vivier 4c1850c130 linux-user: Fix Coverity CID 1430271 / CID 1430272
In new functions print_ioctl() and print_syscall_ret_ioctl(), we don't
check if lock_user() returns NULL and this would cause a segfault in
thunk_print().

If lock_user() returns NULL don't call thunk_print() but prints only the
value of the (invalid) pointer.

Tested with:

    # cat ioctl.c
    #include <unistd.h>
    #include <sys/ioctl.h>

    int main(void)
    {
        int ret;

        ret = ioctl(STDOUT_FILENO, TCGETS, 0xdeadbeef);
        ret = ioctl(STDOUT_FILENO, TCSETSF, 0xdeadbeef);
        return 0;
    }
    # QEMU_STRACE= ./ioctl
    ...
    578 ioctl(1,TCGETS,0xdeadbeef) = -1 errno=2 (Bad address)
    578 ioctl(1,TCSETSF,0xdeadbeef) = -1 errno=2 (Bad address)
    ...
    # QEMU_STRACE= passwd
    ...
    623 ioctl(0,TCGETS,0x3fffed04) = 0 ({})
    623 ioctl(0,TCSETSF,{}) = 0
    ...

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Fixes: 79482e5987 ("linux-user: Add strace support for printing arguments of ioctl()")
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 21:22:08 +02:00
Matus Kysel d8c08b1e6c linux-user: refactor ipc syscall and support of semtimedop syscall
Refactoring ipc syscall for s390x and SPARC, so it matches glibc implementation

We should add support of semtimedop syscall as new version of glibc
2.31 uses semop based on semtimedop
(commit: 765cdd0bff ).

Signed-off-by: Matus Kysel <mkysel@tachyum.com>
Message-Id: <20200626124612.58593-2-mkysel@tachyum.com>
Message-Id: <20200626124612.58593-3-mkysel@tachyum.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
[lv: merged PATCH 1 & 2 to avoid build break on PATCH 1]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-07-13 21:21:02 +02:00
Josh Kunz 71e2443e4c linux-user: Use EPROTONOSUPPORT for unimplemented netlink protocols
Linux uses the EPROTONOSUPPORT error code[1] if the users requests a
netlink socket with an unsupported netlink protocol. This change
switches linux-user to use the same code as Linux, instead of
EPFNOSUPPORT (which AFAIK is just an anachronistic version of
EAFNOSUPPORT).

Tested by compiling all linux-user targets on x86.

[1]:
bfe91da29b/net/netlink/af_netlink.c (L683)

Signed-off-by: Josh Kunz <jkz@google.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200707001036.1671982-1-jkz@google.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-07-13 20:47:57 +02:00
Peter Maydell 5c65b1f135 target-arm queue:
* hw/arm/bcm2836: Remove unused 'cpu_type' field
  * target/arm: Fix mtedesc for do_mem_zpz
  * Add the ability to change the FEC PHY MDIO device number on i.MX25/i.MX6/i.MX7
  * target/arm: Don't do raw writes for PMINTENCLR
  * virtio-iommu: Fix coverity issue in virtio_iommu_handle_command()
  * build: Fix various issues with building on Haiku
  * target/nios2: fix wrctl behaviour when using icount
  * hw/arm/tosa: Encapsulate misc GPIO handling in a device
  * hw/arm/palm.c: Encapsulate misc GPIO handling in a device
  * hw/arm/aspeed: Do not create and attach empty SD cards by default
 -----BEGIN PGP SIGNATURE-----
 
 iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAl8MatAZHHBldGVyLm1h
 eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3uWHD/948wb0jmdMdAKVpmzGG7Zp
 aRQpWnrDRlB5i0yq326FPggIMcdGGvCBDTBaxfD6ToBAfii5lyiJcekBJsJ/ezbS
 YzoC+C0ZfsL87C4j7eajBkhLETPoykkXBjYC87zduFLcMIpSwZS936mzKKave+0/
 5R8/VGlGDfV9RQw0bn/bsz5H20XVYnk68ykzJdkjTy71+DH6r4/juVFwSom+zH7b
 rUYoyl6aYfTOiSZVeSKcSS1AU5vj9UCMwiiMumVfFM/NSDawCP8uiR7T2VtRTvyJ
 84Dw4YhgUMMYWQf+4UGt9lAijp65p3IsS7aP5F/5MEzU3HbVY62tccrqcuJtRwUf
 roGyNvsLurtEBfYte++Y2/+aacBkRdyqOBofYWBnY1MSKunZNSvVxNrwdCTsTNdW
 7r1QL862/5LoP3DbWFMeAMHcVceQzvQNkK1re/CmCXOEBazBNR0Vi0bEMBjFjVhu
 c2C4ywEOTU5aSfvYHcG6fU+iqhhBdAt/YP3u4d9kMqV5BX4k+3nb1VRCkOQfYGwE
 QTzoaIExAhDFb0aW6uR+48+5r2PBzNc9Dif1SwA5NM+f+77phdLde/K+lJbJ8tXg
 V5ZpeiXP7wz6y8+KVADibFVcy1d3fqw5/Yi8TSoSw+d/dQRKd/LRHB2Ig/R9mBp/
 sXdYKhEWwoq+jPmsTs8GsQ==
 =wxo7
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20200713' into staging

target-arm queue:
 * hw/arm/bcm2836: Remove unused 'cpu_type' field
 * target/arm: Fix mtedesc for do_mem_zpz
 * Add the ability to change the FEC PHY MDIO device number on i.MX25/i.MX6/i.MX7
 * target/arm: Don't do raw writes for PMINTENCLR
 * virtio-iommu: Fix coverity issue in virtio_iommu_handle_command()
 * build: Fix various issues with building on Haiku
 * target/nios2: fix wrctl behaviour when using icount
 * hw/arm/tosa: Encapsulate misc GPIO handling in a device
 * hw/arm/palm.c: Encapsulate misc GPIO handling in a device
 * hw/arm/aspeed: Do not create and attach empty SD cards by default

# gpg: Signature made Mon 13 Jul 2020 15:08:16 BST
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "peter.maydell@linaro.org"
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" [ultimate]
# gpg:                 aka "Peter Maydell <pmaydell@gmail.com>" [ultimate]
# gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" [ultimate]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* remotes/pmaydell/tags/pull-target-arm-20200713: (25 commits)
  hw/arm/aspeed: Do not create and attach empty SD cards by default
  hw/arm/palm.c: Encapsulate misc GPIO handling in a device
  hw/arm/palm.c: Detabify
  hw/arm/tosa: Encapsulate misc GPIO handling in a device
  hw/arm/tosa.c: Detabify
  hw/nios2: exit to main CPU loop only when unmasking interrupts
  target/nios2: Use gen_io_start around wrctl instruction
  target/nios2: in line the semantics of DISAS_UPDATE with other targets
  target/nios2: add DISAS_NORETURN case for nothing more to generate
  util/drm: make portable by avoiding struct dirent d_type
  util/oslib-posix.c: Implement qemu_init_exec_dir() for Haiku
  util/compatfd.c: Only include <sys/syscall.h> if CONFIG_SIGNALFD
  bswap.h: Include <endian.h> on Haiku for bswap operations
  osdep.h: For Haiku, define SIGIO as equivalent to SIGPOLL
  osdep.h: Always include <sys/signal.h> if it exists
  build: Check that mlockall() exists
  util/qemu-openpty.c: Don't assume pty.h is glibc-only
  build: Enable BSD symbols for Haiku
  virtio-iommu: Fix coverity issue in virtio_iommu_handle_command()
  target/arm: Don't do raw writes for PMINTENCLR
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 15:14:48 +01:00
Philippe Mathieu-Daudé 756f739b16 hw/arm/aspeed: Do not create and attach empty SD cards by default
Since added in commit 2bea128c3d, each SDHCI is wired with a SD
card, using empty card when no block drive provided. This is not
the desired behavior. The SDHCI exposes a SD bus to plug cards
on, if no card available, it is fine to have an unplugged bus.

Avoid creating unnecessary SD card device when no block drive
provided.

Fixes: 2bea128c3d ("hw/sd/aspeed_sdhci: New device")
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20200705173402.15620-1-f4bug@amsat.org
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:12 +01:00
Peter Maydell ad938fc1d5 hw/arm/palm.c: Encapsulate misc GPIO handling in a device
Replace the free-floating set of IRQs and palmte_onoff_gpios()
function with a simple QOM device that encapsulates this
behaviour.

This fixes Coverity issue CID 1421944, which points out that
the memory returned by qemu_allocate_irqs() is leaked.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20200628214230.2592-3-peter.maydell@linaro.org
2020-07-13 14:36:12 +01:00
Peter Maydell c1abd462d9 hw/arm/palm.c: Detabify
Remove hard-tabs from palm.c.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20200628214230.2592-2-peter.maydell@linaro.org
2020-07-13 14:36:11 +01:00
Peter Maydell d4e1d8f57e hw/arm/tosa: Encapsulate misc GPIO handling in a device
Currently we have a free-floating set of IRQs and a function
tosa_out_switch() which handle the GPIO lines on the tosa board which
connect to LEDs, and another free-floating IRQ and tosa_reset()
function to handle the GPIO line that resets the system.  Encapsulate
this behaviour in a simple QOM device.

This commit fixes Coverity issue CID 1421929 (which pointed out that
the 'outsignals' in tosa_gpio_setup() were leaked), because it
removes the use of the qemu_allocate_irqs() API from this code
entirely.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20200628203748.14250-3-peter.maydell@linaro.org
2020-07-13 14:36:11 +01:00
Peter Maydell ad9d854b70 hw/arm/tosa.c: Detabify
Remove the hardcoded tabs from hw/arm/tosa.c. There aren't
many, but since they're all in constant #defines they're not
going to go away with our usual "only when we touch a function"
policy on reformatting.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20200628203748.14250-2-peter.maydell@linaro.org
2020-07-13 14:36:11 +01:00
Wentong Wu dcef727e5e hw/nios2: exit to main CPU loop only when unmasking interrupts
Only when guest code is unmasking interrupts, terminate the excution
of translated code and exit to the main CPU loop to handle previous
pended interrupts because of the interrupts mask by guest code.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
Message-id: 20200710233433.19729-4-wentong.wu@intel.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:11 +01:00
Wentong Wu 77b3f2af57 target/nios2: Use gen_io_start around wrctl instruction
wrctl instruction on nios2 target will cause checking cpu
interrupt but tcg_handle_interrupt() will call cpu_abort()
if the CPU gets an interrupt while it's not in 'can do IO'
state, so add gen_io_start around wrctl instruction. Also
at the same time, end the onging TB with DISAS_UPDATE.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
Message-id: 20200710233433.19729-3-wentong.wu@intel.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:11 +01:00
Wentong Wu c769453571 target/nios2: in line the semantics of DISAS_UPDATE with other targets
In line the semantics of DISAS_UPDATE on nios2 target with other targets
which is to explicitly write the PC back into the cpu state before doing
a tcg_gen_exit_tb().

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
Message-id: 20200710233433.19729-2-wentong.wu@intel.com
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:10 +01:00
Wentong Wu 42928f2c9c target/nios2: add DISAS_NORETURN case for nothing more to generate
Add DISAS_NORETURN case for nothing more to generate because at runtime
execution will never return from some helper call. And at the same time
replace DISAS_UPDATE in t_gen_helper_raise_exception and gen_exception
with the newly added DISAS_NORETURN.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
Message-id: 20200710233433.19729-1-wentong.wu@intel.com
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:10 +01:00
Gerd Hoffmann 0b823cb07e util/drm: make portable by avoiding struct dirent d_type
Given this isn't perforance critical at all lets avoid the non-portable
d_type and use fstat instead to check whenever the file is a chardev.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reported-by: David Carlier <devnexen@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20200703145614.16684-10-peter.maydell@linaro.org
Message-id: 20200701180302.14821-1-kraxel@redhat.com
[PMM: fixed comment style; tweaked subject line]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:10 +01:00
David CARLIER 2b9b9e7010 util/oslib-posix.c: Implement qemu_init_exec_dir() for Haiku
The qemu_init_exec_dir() function is inherently non-portable;
provide an implementation for Haiku hosts.

Signed-off-by: David Carlier <devnexen@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20200703145614.16684-9-peter.maydell@linaro.org
[PMM: Expanded commit message]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:10 +01:00
David CARLIER 81b7b1e21d util/compatfd.c: Only include <sys/syscall.h> if CONFIG_SIGNALFD
util/compatfd.c includes <sys/syscall.h> so that the CONFIG_SIGNALFD
code can use SYS_signalfd. Guard the #include with CONFIG_SIGNALFD
to avoid portability issues on hosts like Haiku which do not
provide that header file.

Signed-off-by: David Carlier <devnexen@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20200703145614.16684-8-peter.maydell@linaro.org
[PMM: Expanded commit message]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:10 +01:00
David CARLIER 652a46ebba bswap.h: Include <endian.h> on Haiku for bswap operations
Haiku puts the bswap* functions in <endian.h>; pull in that
include file on that platform.

Signed-off-by: David Carlier <devnexen@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20200703145614.16684-7-peter.maydell@linaro.org
[PMM: Expanded commit message]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:10 +01:00
David CARLIER 8bf0f1754a osdep.h: For Haiku, define SIGIO as equivalent to SIGPOLL
Haiku doesn't provide SIGIO; fix this up in osdep.h by defining it as
equal to SIGPOLL.

Signed-off-by: David Carlier <devnexen@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20200703145614.16684-6-peter.maydell@linaro.org
[PMM: Expanded commit message]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:09 +01:00
David CARLIER 2a4b472c3c osdep.h: Always include <sys/signal.h> if it exists
Regularize our handling of <sys/signal.h>: currently we include it in
osdep.h, but only for OpenBSD, and we include it without an ifdef
guard in a couple of C files.  This causes problems for Haiku, which
doesn't have that header.

Instead, check in configure whether sys/signal.h exists, and if it
does then always include it from osdep.h.

Signed-off-by: David Carlier <devnexen@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20200703145614.16684-5-peter.maydell@linaro.org
[PMM: Expanded commit message; rename to HAVE_SYS_SIGNAL_H]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:09 +01:00
David CARLIER 195588ccd5 build: Check that mlockall() exists
Instead of assuming that all POSIX platforms provide mlockall(),
test for it in configure. If the host doesn't provide this platform
then os_mlock() will fail -ENOSYS, as it does already on Windows.

This is necessary for Haiku, which does not have mlockall().

Signed-off-by: David Carlier <devnexen@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20200703145614.16684-4-peter.maydell@linaro.org
[PMM: Expanded commit message; rename to HAVE_MLOCKALL]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:09 +01:00
David CARLIER c9c8b88f0b util/qemu-openpty.c: Don't assume pty.h is glibc-only
Instead of using an OS-specific ifdef test to select the "openpty()
is in pty.h" codepath, make configure check for the existence of
the header and use the new CONFIG_PTY instead.

This is necessary to build on Haiku, which also provides openpty()
via pty.h.

Signed-off-by: David Carlier <devnexen@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20200703145614.16684-3-peter.maydell@linaro.org
[PMM: Expanded commit message; rename to HAVE_PTY_H]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:09 +01:00
David CARLIER fc4334303e build: Enable BSD symbols for Haiku
Tell Haiku to provide various BSD functions by setting BSD_SOURCE
and linking libbsd.

Signed-off-by: David Carlier <devnexen@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20200703145614.16684-2-peter.maydell@linaro.org
[PMM: expanded commit message]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:08 +01:00
Eric Auger e95e05dab6 virtio-iommu: Fix coverity issue in virtio_iommu_handle_command()
Coverity points out (CID 1430180) that the new case is missing
break or a /* fallthrough */ comment. Break is the right thing to
do as in that case, tail is not used.

Fixes 1733eebb9e ("virtio-iommu: Implement RESV_MEM probe request")
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20200708160147.18426-1-eric.auger@redhat.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:08 +01:00
Aaron Lindsay 887c0f1544 target/arm: Don't do raw writes for PMINTENCLR
Raw writes to this register when in KVM mode can cause interrupts to be
raised (even when the PMU is disabled). Because the underlying state is
already aliased to PMINTENSET (which already provides raw write
functions), we can safely disable raw accesses to PMINTENCLR entirely.

Signed-off-by: Aaron Lindsay <aaron@os.amperecomputing.com>
Message-id: 20200707152616.1917154-1-aaron@os.amperecomputing.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:08 +01:00
Jean-Christophe Dubois 1f7197deb0 Add the ability to change the FEC PHY MDIO devices numbers on i.MX7 processor
Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
Message-id: c850187322be9930e47c8b234c385a7d0da245cb.1593806826.git.jcd@tribudubois.net
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
[PMM: updated for object_property_set_uint() argument reordering]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:08 +01:00
Jean-Christophe Dubois a9c167a3c4 Add the ability to change the FEC PHY MDIO device number on i.MX6 processor
Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
Message-id: 05a64e83eb1c0c865ac077b22c599425c024c02c.1593806826.git.jcd@tribudubois.net
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
[PMM: updated for object_property_set_uint() argument reordering]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:08 +01:00
Jean-Christophe Dubois 74c1330582 Add the ability to change the FEC PHY MDIO device number on i.MX25 processor
Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
Message-id: 9f8923ecd974160ae8f634c275b1100c2cbe66d7.1593806826.git.jcd@tribudubois.net
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
[PMM: updated for object_property_set_uint() argument reordering]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:07 +01:00
Richard Henderson cdecb3fc1e target/arm: Fix mtedesc for do_mem_zpz
The mtedesc that was constructed was not actually passed in.
Found by Coverity (CID 1429996).

Fixes: d28d12f008
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20200706202345.193676-1-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:07 +01:00
Philippe Mathieu-Daudé 75a73a11d3 hw/arm/bcm2836: Remove unused 'cpu_type' field
The 'cpu_type' has been moved from BCM283XState to BCM283XClass
in commit 210f47840d, but we forgot to remove the old variable.
Do it now.

Fixes: 210f47840d ("hw/arm/bcm2836: Hardcode correct CPU type")
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-id: 20200703200459.23294-1-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 14:36:07 +01:00
Peter Maydell 00ce6c36b3 * Some fuzzer related fixes
* Fixes / improvements for the "configure" script
 * Doc updates
 * Gitlab pipeline-status script
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAl8MPAARHHRodXRoQHJl
 ZGhhdC5jb20ACgkQLtnXdP5wLbVLTQ/9H0G+Vo46hqOYpb2+psbfSi29WXAQiyNM
 ZtcloeDW/fwhKUlxtEMTuuAuDNOleGj+UxAsGaodFIEgx5XnJT2MxeqOpE3uE9G0
 9r/potzlcztYgqRHRu+H0keZNYiMY70lZUJy8NSYl+KOnndeRBmSy/GwPb/HOzH5
 2t+hlsCFkbnvm1IOcaGCVKcRNvIlUmqRt5LmqkRVrOxe6u8kfm3lgkZ/CUHzfoDq
 N5S/DuVmy0IWiP25/WnVQiV4XYLUN4jf161XfacwypPmZrK/QT9ScZhaICNuEqIY
 krDH1ZDV2M6a69e1PecJUsPYEVlsfbnmEMb3aM/xEZtrHEm2b14MpQo0CePkWEQc
 BBHd0UkkjbC9K9Gqe8tXG2YC22ZgEi6psqRprdIixNNZptJ5oWYfZ0bAeuT2Bs+7
 VOhtUmRk7ufEu9FwOleSPpHlhkTAwuMh+sYma52wx9an6rB84i6oJPGlAeSje6db
 e2+D5J6z72ZxIxc7wUBbdoL70wM0tpbppYR0QO5TblJA+WJtBupQ6mw71TzeMoOg
 2ZJlwOsnbUy0EbwgKm7huHANAhCFhnbYv70KVseX3agPJ0vSZYDo2PT8vJXTL7Sk
 BNoFn3rI70b7HW40YL8jsMvO6zXrIuofwNkpEIRoNS+gItc2a3SQa/lBosQBQAy3
 5p+qPn/kQ1U=
 =f+Fr
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2020-07-13' into staging

* Some fuzzer related fixes
* Fixes / improvements for the "configure" script
* Doc updates
* Gitlab pipeline-status script

# gpg: Signature made Mon 13 Jul 2020 11:48:32 BST
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg:                issuer "thuth@redhat.com"
# gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full]
# gpg:                 aka "Thomas Huth <thuth@redhat.com>" [full]
# gpg:                 aka "Thomas Huth <huth@tuxfamily.org>" [full]
# gpg:                 aka "Thomas Huth <th.huth@posteo.de>" [unknown]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* remotes/huth-gitlab/tags/pull-request-2020-07-13:
  docs/system/s390x: Improve the 3270 documentation
  GitLab Gating CI: introduce pipeline-status contrib script
  disas/sh4: Add missing fallthrough annotations
  Remove the CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE switch
  docs/devel/fuzzing: Fix bugs in documentation
  tests/qtest/fuzz: Add missing spaces in description
  fuzz: add missing header for rcu_enable_atfork
  configure: do not clobber CFLAGS with --enable-fuzzing
  configure: fix malloc check

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 13:01:30 +01:00
Thomas Huth 2a84f48c2b docs/system/s390x: Improve the 3270 documentation
There is some additional information about the 3270 support in our Wiki
at https://wiki.qemu.org/Features/3270 - so let's include this information
into the main documentation now to have one single source of information
(the Wiki page could later be removed).

While at it, I also shortened the lines of the first example a little bit.
Otherwise they showed up with a horizontal scrollbar in my Firefox browser.

Message-Id: <20200713075112.442-1-thuth@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-13 11:40:52 +02:00
Cleber Rosa c02b2eac55 GitLab Gating CI: introduce pipeline-status contrib script
This script is intended to be used right after a push to a branch.

By default, it will look for the pipeline associated with the commit
that is the HEAD of the *local* staging branch.  It can be used as a
one time check, or with the `--wait` option to wait until the pipeline
completes.

If the pipeline is successful, then a merge of the staging branch into
the master branch should be the next step.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Message-Id: <20200709024657.2500558-2-crosa@redhat.com>
[thuth: Added the changes suggested by Erik Skultety]
Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-13 11:40:52 +02:00
Thomas Huth ccb237090f disas/sh4: Add missing fallthrough annotations
Add fallthrough annotations to be able to compile the code without
warnings with -Wimplicit-fallthrough. Looking at the code, it seems
like the fallthrough is indeed intended here, so the comments should
be appropriate.

Message-Id: <20200630055953.9309-1-thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-13 11:40:52 +02:00
Thomas Huth 7aa12aa215 Remove the CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE switch
GCC supports "#pragma GCC diagnostic" since version 4.6, and
Clang seems to support it, too, since its early versions 3.x.
That means that our minimum required compiler versions all support
this pragma already and we can remove the test from configure and
all the related #ifdefs in the code.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20200710045515.25986-1-thuth@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-13 11:40:52 +02:00
Thomas Huth 590246ead7 docs/devel/fuzzing: Fix bugs in documentation
Fix typo - the option is called "--fuzz-target" and not "--fuzz_taget".
Also use a different fuzzer in the example, since "virtio-net-fork-fuzz"
does not seem to be a valid fuzzer target (anymore?).

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20200709084059.22539-1-thuth@redhat.com>
2020-07-13 11:40:52 +02:00
Thomas Huth 2c65fefa05 tests/qtest/fuzz: Add missing spaces in description
There should be a space between "forking" and "for".

Message-Id: <20200709083719.22221-1-thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alexander Bulekov <alxndr@bu.edu>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-13 11:40:52 +02:00
Alexander Bulekov 230225eaaa fuzz: add missing header for rcu_enable_atfork
In 45222b9a90, I fixed a broken check for rcu_enable_atfork introduced
in d6919e4cb6. I added a call to rcu_enable_atfork after the
call to qemu_init in fuzz.c, but forgot to include the corresponding
header, breaking --enable-fuzzing --enable-werror builds.

Fixes: 45222b9a90 ("fuzz: fix broken qtest check at rcu_disable_atfork")
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
Message-Id: <20200708200104.21978-3-alxndr@bu.edu>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-13 11:40:52 +02:00
Alexander Bulekov 0ab6c2384c configure: do not clobber CFLAGS with --enable-fuzzing
When configuring with --enable-fuzzing, we overwrote the CFLAGS
added by all the preceding checks. Instead of overwriting CFLAGS, append
the ones we need.

Fixes: adc28027ff ("fuzz: add configure flag --enable-fuzzing")
Reported-by: Li Qiang <liq3ea@163.com>
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
Message-Id: <20200708200104.21978-2-alxndr@bu.edu>
Tested-by: Li Qiang <liq3ea@gmail.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-13 11:40:52 +02:00
Olaf Hering d1abf3fc6a configure: fix malloc check
Avoid random return value.

Fixes commit f2dfe54c74

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Message-Id: <20200707171326.16422-1-olaf@aepfle.de>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-13 11:40:52 +02:00
Peter Maydell 6c87d9f311 -----BEGIN PGP SIGNATURE-----
iQJQBAABCAA6FiEEh6m9kz+HxgbSdvYt2ujhCXWWnOUFAl8MGfccHG1hcmNhbmRy
 ZS5sdXJlYXVAcmVkaGF0LmNvbQAKCRDa6OEJdZac5TrvD/9GwEzrEJrvngF5w9Qx
 sZBu2ZdLewQuKrIXzG7c/PVxwSjcUl9Dn69sbI6f3h5QXdP9T0en2zgeSCb3qrHJ
 dsoLsprL89R44T6ZTvDO1fe1m/44UuXfdF/p8kkyQrnPwBXFAw3ZHKkNRtcIrihn
 lu06pGUmzL8OFvPC6B1gnN1d/oqB1mqoKs7UATz+UTxrEHQgPqQbEg7Hi+VGSA6e
 rBxogPoLrFrRrLPDDsdKp7Ylj3JaD5IF5A2E9Vv2LCMkNG/YgCuA6EqGuur7lHpL
 w8H2LbSwpNWu5vZNg3BfR9hMHrM1n//gwPwjhp1GM3MrvYjhTOIGASM9Ysav7tkY
 lB+wkutdNTE4boFILMRr2GXa7O+vByEOEV4FS8jXcZ3+hK2rfzHg6Yc0/ZThhL6O
 cwQuJTgeq/+7HycIq70yE7iLabKqE0akINAH/b6DmO+oeHrQPoHFS3ULjp6a4H1y
 Nk+y6pbmyw4Rjz8TQX90azKUkV/xVI/yCJZfqoDkYD3XzJCxekeabzT9GZ2VH0Wg
 BqPWrfEmYcGTkYLwOqC/48nngIcPmhh70BJ+r2NGfmLAaYYsDSX9a49fAwLTFAUG
 +VItzwRBqtf3ZFMOcsAtIDCtFjWPU3r7J76dJZdTJafe9TFAZxRSBLtdtL9OQ6S9
 91mSJry9zGH3+2fZs6jv6PtgSg==
 =Z07J
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/elmarco/tags/chardev-pull-request' into staging

# gpg: Signature made Mon 13 Jul 2020 09:23:19 BST
# gpg:                using RSA key 87A9BD933F87C606D276F62DDAE8E10975969CE5
# gpg:                issuer "marcandre.lureau@redhat.com"
# gpg: Good signature from "Marc-André Lureau <marcandre.lureau@redhat.com>" [full]
# gpg:                 aka "Marc-André Lureau <marcandre.lureau@gmail.com>" [full]
# Primary key fingerprint: 87A9 BD93 3F87 C606 D276  F62D DAE8 E109 7596 9CE5

* remotes/elmarco/tags/chardev-pull-request:
  chardev: Extract system emulation specific code
  chardev: Reduce "char-mux.h" scope, rename it "chardev-internal.h"
  chardev: Restrict msmouse / wctablet / testdev to system emulation
  tests/test-char: Remove unused "chardev/char-mux.h" include
  monitor/misc: Remove unused "chardev/char-mux.h" include
  char: fix use-after-free with dup chardev & reconnect
  chardev: don't abort on attempt to add duplicated chardev
  char-socket: initialize reconnect timer only when the timer doesn't start

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-13 09:34:24 +01:00
Philippe Mathieu-Daudé 30827bad38 chardev: Extract system emulation specific code
Split out code only used during system emulation,
to reduce code pulled in user emulation and tools.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200423202112.644-6-philmd@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-13 11:59:47 +04:00
Philippe Mathieu-Daudé ffa0f7eb57 chardev: Reduce "char-mux.h" scope, rename it "chardev-internal.h"
No file out of chardev/ requires access to this header,
restrict its scope.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200423202112.644-5-philmd@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-13 11:59:47 +04:00
Philippe Mathieu-Daudé c383efd50a chardev: Restrict msmouse / wctablet / testdev to system emulation
The msmouse / wctablet / testdev character devices are only
used by system emulation. Remove them from user mode and tools.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200423202112.644-4-philmd@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-13 11:59:47 +04:00
Philippe Mathieu-Daudé 35b49e93fd tests/test-char: Remove unused "chardev/char-mux.h" include
This test never required "chardev/char-mux.h", remove it.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200423202112.644-3-philmd@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-13 11:59:47 +04:00
Philippe Mathieu-Daudé 833ef7ec56 monitor/misc: Remove unused "chardev/char-mux.h" include
monitor/misc.c never required "chardev/char-mux.h", remove it.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200423202112.644-2-philmd@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-13 11:59:47 +04:00
Marc-André Lureau 6806601969 char: fix use-after-free with dup chardev & reconnect
With a reconnect socket, qemu_char_open() will start a background
thread. It should keep a reference on the chardev.

Fixes invalid read:
READ of size 8 at 0x6040000ac858 thread T7
    #0 0x5555598d37b8 in unix_connect_saddr /home/elmarco/src/qq/util/qemu-sockets.c:954
    #1 0x5555598d4751 in socket_connect /home/elmarco/src/qq/util/qemu-sockets.c:1109
    #2 0x555559707c34 in qio_channel_socket_connect_sync /home/elmarco/src/qq/io/channel-socket.c:145
    #3 0x5555596adebb in tcp_chr_connect_client_task /home/elmarco/src/qq/chardev/char-socket.c:1104
    #4 0x555559723d55 in qio_task_thread_worker /home/elmarco/src/qq/io/task.c:123
    #5 0x5555598a6731 in qemu_thread_start /home/elmarco/src/qq/util/qemu-thread-posix.c:519
    #6 0x7ffff40d4431 in start_thread (/lib64/libpthread.so.0+0x9431)
    #7 0x7ffff40029d2 in __clone (/lib64/libc.so.6+0x1019d2)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20200420112012.567284-1-marcandre.lureau@redhat.com>
2020-07-13 11:59:47 +04:00
Marc-André Lureau 14a7a20306 chardev: don't abort on attempt to add duplicated chardev
This is a regression from commit d2623129a7 ("qom: Drop parameter @errp
of object_property_add() & friends").

(qemu) chardev-add id=null,backend=null
(qemu) chardev-add id=null,backend=null
Unexpected error in object_property_try_add() at /home/elmarco/src/qemu/qom/object.c:1166:
attempt to add duplicate property 'null' to object (type 'container')

That case is currently not covered in the test suite, but will be with
the queued patch "char: fix use-after-free with dup chardev &
reconnect".

Fixes: d2623129a7
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
2020-07-13 11:59:47 +04:00