Commit Graph

60351 Commits

Author SHA1 Message Date
Roman Kagan 1221f15041 i386/hyperv: error out if features requested but unsupported
In order to guarantee compatibility on migration, QEMU should have
complete control over the features it announces to the guest via CPUID.

However, for a number of Hyper-V-related cpu properties, if the
corresponding feature is not supported by the underlying KVM, the
propery is silently ignored and the feature is not announced to the
guest.

Refuse to start with an error instead.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Message-Id: <20180330170209.20627-3-rkagan@virtuozzo.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-04-09 16:36:38 +02:00
Roman Kagan 9445597b6a i386/hyperv: add hv-frequencies cpu property
In order to guarantee compatibility on migration, QEMU should have
complete control over the features it announces to the guest via CPUID.

However, the availability of Hyper-V frequency MSRs
(HV_X64_MSR_TSC_FREQUENCY and HV_X64_MSR_APIC_FREQUENCY) depends solely
on the support for them in the underlying KVM.

Introduce "hv-frequencies" cpu property (off by default) which gives
QEMU full control over whether these MSRs are announced.

While at this, drop the redundant check of the cpu tsc frequency, and
decouple this feature from hv-time.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20180330170209.20627-2-rkagan@virtuozzo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-04-09 16:36:38 +02:00
Justin Terry (VM) 7becac84fb target/i386: WHPX: set CPUID_EXT_HYPERVISOR bit
Implements the CPUID trap for CPUID 1 to include the
CPUID_EXT_HYPERVISOR flag in the ECX results. This was preventing some
older linux kernels from booting when trying to access MSR's that dont
make sense when virtualized.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
Message-Id: <20180326170658.606-1-juterry@microsoft.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-04-09 16:36:38 +02:00
Marc-André Lureau 648abbfbaa memfd: fix vhost-user-test on non-memfd capable host
On RHEL7, memfd is not supported, and vhost-user-test fails:
TEST: tests/vhost-user-test... (pid=10248)
  /x86_64/vhost-user/migrate:
  qemu-system-x86_64: -object memory-backend-memfd,id=mem,size=2M,: failed to create memfd
FAIL

There is a qemu_memfd_check() to prevent running memfd path, but it
also checks for fallback implementation. Let's specialize
qemu_memfd_check() to check memfd only, while qemu_memfd_alloc_check()
checks for the qemu_memfd_alloc() API.

Reported-by: Miroslav Rezanina <mrezanin@redhat.com>
Tested-by: Miroslav Rezanina <mrezanin@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20180328121804.16203-1-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2018-04-09 12:57:06 +02:00
Su Hang 053e45d2f3 scripts/checkpatch.pl: Bug fix
Commit 2b9aef6fcd introduced a regression:
checkpatch.pl started complaining about the following valid pattern:
do {
     /* something */
} while (condition);

Fix the script to once again permit this pattern.

Signed-off-by: Su Hang <suhang16@mails.ucas.ac.cn>
Message-Id: <1522029982-4650-1-git-send-email-suhang16@mails.ucas.ac.cn>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-04-05 14:43:08 +02:00
Alexandro Sanchez Bach 5cd10051c2 target/i386: Fix andn instruction
In commit 7073fbada7, the `andn` instruction
was implemented via `tcg_gen_andc` but passes the operands in the wrong
order:
- X86 defines `andn dest,src1,src2` as: dest = ~src1 & src2
- TCG defines `andc dest,src1,src2` as: dest = src1 & ~src2

The following simple test shows the issue:

    #include <stdio.h>
    #include <stdint.h>

    int main(void) {
        uint32_t ret = 0;
        __asm (
            "mov $0xFF00, %%ecx\n"
            "mov $0x0F0F, %%eax\n"
            "andn %%ecx, %%eax, %%ecx\n"
            "mov %%ecx, %0\n"
          : "=r" (ret));
        printf("%08X\n", ret);
        return 0;
    }

This patch fixes the problem by simply swapping the order of the two last
arguments in `tcg_gen_andc_tl`.

Reported-by: Alexandro Sanchez Bach <alexandro@phi.nz>
Signed-off-by: Alexandro Sanchez Bach <alexandro@phi.nz>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-04-05 14:41:54 +02:00
Bruce Rogers d69748463c sys_membarrier: fix up include directives
Our rule right now is to use <> for external headers only.
util/sys_membarrier.c violates that. Fix it up.

Signed-off-by: Bruce Rogers <brogers@suse.com>
Message-Id: <20180329151018.15319-1-brogers@suse.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-04-05 14:37:38 +02:00
Peter Maydell 0e87fdc966 Update version for v2.12.0-rc2 release
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-04-04 20:37:20 +01:00
Peter Maydell f1a639aaf2 -----BEGIN PGP SIGNATURE-----
iQIcBAABAgAGBQJaxPhdAAoJEL2+eyfA3jBXpWIP+wcpccO47D1TBHN+n6eR3RSX
 IVCzoHBSD/ii1HCLLH9YFHFb4N/HGzFX51Dqqvv/Y7ZJpp8ybbblFVLwM07f5mwM
 evf/1utvzhgTlrzMZ7VcByU869c+EbYR/r7pfEzAK7aCZXTj2Gvf2GxdZPrEjrWz
 dESYx8EzQOkVDbyOONrTweZgbDltJZO7Xmwu8tWKtdn3mw0OTBEj+m32+IFmprlE
 ZKGgswflQAdVeUSjXEVwgP5qeV3+rMSgDYTRka0TszAu6fy1QNpPSNrY+5E4lidK
 nAmzUzNpvr4GYwbX2RCPEwcC0Mk5ot9JFOmRnnER0UrpOA9VTv6+niG54q7bNyIx
 2bLtGhAY2PiV/EEjNrIT02/HUwO0wiMUBdhObmQj/XqLDmq2DhWHU2Z5NHHAMB0Y
 mTE7jpaKrZKv1Ui8LFG4mMWvoskJY5kcuHCJ2P29ktDIkctmirNa3NfdSqKSYaZh
 VOwkU4VsX41issBHW0ya96rL11A9qZAxiSUU81fQuEWJB55X3hq/q0Ze99/otVTN
 fAsDpMEG4A7sHBlVUQVRfTZH0ofgnkpQ5nHMMax0zY0/bDRqGRVTARHDFBSDqgLi
 xNB2YpNaVYqM8uyL8PMLHTPF79LgH74Ohe44rpwSUtxVvXRyW459dPsDC0VgLJrk
 tMOyBA8tHsY4XZuIZ8Y0
 =SxAD
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging

# gpg: Signature made Wed 04 Apr 2018 17:07:57 BST
# gpg:                using RSA key BDBE7B27C0DE3057
# gpg: Good signature from "Jeffrey Cody <jcody@redhat.com>"
# gpg:                 aka "Jeffrey Cody <jeff@codyprime.org>"
# gpg:                 aka "Jeffrey Cody <codyprime@gmail.com>"
# Primary key fingerprint: 9957 4B4D 3474 90E7 9D98  D624 BDBE 7B27 C0DE 3057

* remotes/cody/tags/block-pull-request:
  block/rbd: remove processed options from qdict

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-04-04 17:48:18 +01:00
Jeff Cody bfb15b4bec block/rbd: remove processed options from qdict
Commit 4bfb274 added some QAPIfication of option parsing in
qemu_rbd_open().  We need to remove all the options we processed,
otherwise in bdrv_open_inherit() we will think the remaining options are
invalid.

(This needs to go in 2.12 to avoid a regression that prevents rbd
from being opened.)

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
2018-04-04 12:05:13 -04:00
Laurent Vivier 74912f6dad tcg: fix 16-byte vector operations detection
configure tries to detect if the compiler
supports 16-byte vector operations.

As stated in the comment of the detection
program, there is a problem with the system
compiler on GCC on Centos 7.

This program doesn't actually detect the problem
with GCC on RHEL7 on PPC64LE (Red Hat 4.8.5-28).

This patch updates the test to look more like
it is in QEMU helpers, and now detects the problem.

The error reported is:

  CC      ppc64-softmmu/accel/tcg/tcg-runtime-gvec.o
  ..//accel/tcg/tcg-runtime-gvec.c: In function ‘helper_gvec_shl8i’:
  ../accel/tcg/tcg-runtime-gvec.c:558:26: internal compiler error: in emit_move_insn, at expr.c:3495
           *(vec8 *)(d + i) = *(vec8 *)(a + i) << shift;
                            ^
Fixes: db43267 "tcg: Add generic vector expanders"
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com>
Message-id: 20180328133152.24623-1-lvivier@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-04-04 16:23:57 +01:00
Peter Maydell fd69ad866b Block layer patches
-----BEGIN PGP SIGNATURE-----
 
 iQIcBAABAgAGBQJaw6JlAAoJEH8JsnLIjy/W8JcP/06bxQ+8056Vz/+oRAm3VEZN
 iFJ1w+A1cFVpaqeE1fl+nfluyT+bU4J8YIyeHQlgckFyzQz13v0cSSSpBJYfJAO9
 XSO/g96kILwN+h16NNdKX2K7uewVPZgyDbNf+FzM2UHuSSXdSp0ZbeW1yXvB6cpx
 hk2exA0Vfxm2dq2Xzz00EzGCWdZAnWWesj9pimASQ1W0426t7PJRCrRaUVawaJfT
 J+IB4zsF4BJ49CvqmeFqyPfDV9q1GF3c9EkXzFgw7qYY2C4F4bAKv82AxWiKEiRI
 cm1bHEdVyDFuBxzMuGOhZS3g2YkJDnEbkfJ0zj5cKmmYO2Pc0q8DeAMZTvy3aobL
 R5UawZTgPv2O71hOlRFl/YZwMjhb80BXDq9mx7TrrhQ5/wCAUOs4e1XYHn+kzL3W
 ohp5r74Qj1s84pGi8sPaXWm8myxalkTicT1cKFHztb+3+DwVPQIOXhMkMqrJyAK8
 3GwZsGmtzI5DCIyF3whLbElN/OHRM9zr/T+uwhRQw8bs/XYPU27f367Y+JJGAaZq
 xTD7vlF49XSOoSDTYcvJfODlloJODyL+CxFS/vpJKfMYgDWYQZiwvYeIEywmwIYE
 2bEdgcN/9BOdYK4NRuJzDY+Vra7iVnDvXhsZ8UClp/SPLspJ54zwCny9f5rSIDJF
 NSiBcahA5femreYqAfWz
 =quyk
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block layer patches

# gpg: Signature made Tue 03 Apr 2018 16:48:53 BST
# gpg:                using RSA key 7F09B272C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* remotes/kevin/tags/for-upstream:
  iotests: Test abnormally large size in compressed cluster descriptor
  qemu-iotests: Use ppc64 qemu_arch on ppc64le host
  iotests: Test preallocated truncate of 2G image
  block/file-posix: Fix fully preallocated truncate
  iotests: fix 208 for luks format
  iotests: Update 186 after commit ac64273c66
  iotests: Update 051 and 186 after commit 1454509726
  block: handle invalid lseek returns gracefully
  gluster: Fix blockdev-add with server.N.type=unix

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-04-04 14:00:07 +01:00
Peter Maydell e5efa1f5f2 -----BEGIN PGP SIGNATURE-----
iQIcBAABAgAGBQJaw6duAAoJEL2+eyfA3jBXoYUP/07v6FQ0E91eprL2Zg2uowA1
 u6e/neVhlzZgMpOevWfnjScBYHA5wjPjM2ZbKckbnFjH60s7gVBuYtbnwcChRMY1
 LXJts1LivuQOru5QIf0Fwi2W4vkPzV8rQsWp6nmnIDf/Jzs2iKEe6jy6A2enSLYM
 FKOrJc1ViNWFpW1y/7mV8gHIAChEC3wEL9L2JUQEvi4VQD7uCwJv0YS5Ci+xjV21
 /DPaVfZA4VMNNi+FTRezW+l5m0zOxenxUnDXqpP5yjgPyTpyqfHSCCVK54HLQ2L/
 8uMblucjRRFXl6zsX2Quzwqiq80D9KxidhOKk9OU1Yi+rbDz4vSTlE/fBRHKVVln
 Rd8DhTK7aPG1bsiQSHCqcd4+a9qsHOn0LY7tS1m78CaVx1O8JhMBe5Y+NJEMR8AM
 iiWss8QyXggDkagzyiGrMHguCI5yM0EWqYfWtjLBiKOkzTjn9xzSbAbn9JK9TBBa
 aZ6JwNE1krtsTydJ1K37KFNabX/yyZR1KlYUc90FwRC1b9pfPHCmaMQ2imx/pg/y
 f3p3uG1UQmBXMMgchstqc1Xf4BqEeOV5pBKlF2Dwodi1ewZoS+WtuvqjURs2aJUr
 2YLOGPBtPHboWl+kjmn+csJJ8zSWw9byRyHHKJN7zFEx3iXZ4I9HMauzap+goWJq
 2NCKYjzyWkuR7YLR4w3q
 =vLaJ
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging

# gpg: Signature made Tue 03 Apr 2018 17:10:22 BST
# gpg:                using RSA key BDBE7B27C0DE3057
# gpg: Good signature from "Jeffrey Cody <jcody@redhat.com>"
# gpg:                 aka "Jeffrey Cody <jeff@codyprime.org>"
# gpg:                 aka "Jeffrey Cody <codyprime@gmail.com>"
# Primary key fingerprint: 9957 4B4D 3474 90E7 9D98  D624 BDBE 7B27 C0DE 3057

* remotes/cody/tags/block-pull-request:
  gluster: Fix blockdev-add with server.N.type=unix
  blockjob: use qapi enum helpers
  blockjob: leak fix, remove from txn when failing early

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-04-04 12:33:23 +01:00
Peter Maydell 094b62cd9c Fix memory leaks when using object_property_get_str()
-----BEGIN PGP SIGNATURE-----
 
 iQIcBAABCAAGBQJaw4jqAAoJECgHk2+YTcWmEFcQAJcNSNyo/jqqnPEJyNo0+Yoy
 GWP/5sZ8fDKFWWnhFg/ZXpp+8Z4xh/25vriCjsBhQRrxaQYIeCyccUEFiGf17VK4
 jSa83rzuq4HMnLip4IT+j0ywRLa1wM79WaC//LpbRVGVdyCtuhwsQkMEOLiJbDdM
 RMh4cqhrpWenSTD/FBhTc9O37hea1ly5Iytw0+hx9cC4x1SiEwU1deT3Moimav1K
 ptRUqDtU8dUTxmmj7BIFyarGw++Um+eL+oabh49CRvn1eqy2tCBHMg8vjbRxiOTX
 iX0J3fb/YefBnZBGJtGqXXZYDC+f6Xblnmad05GVSuNPctUp+pKsflMtgjFfmuT4
 VZm0FFiW5QgF9a85WDNKhjMlidLtcyfHz7G7GrgIJ2vZsigg4tAmFC2D0+Ep2xxK
 UtXInPYqvwGIBUoEggZ5luWxxM0LEKK/Jhp9TjVvnIAdxj4/usigYjQ4Xxs4Q5nF
 tU5yFBkdK3t5CF3PMBZd18QCUnP26LE6Nmp3oGPdhOI1HjHXmV/GT123XB9EcIxJ
 xZSkhYfK4Lo5lXeo/6BLqzU8WJZmqXzBcVFnJZzY6dsQlG7m7NhoVJULXyjBymAM
 nbxrlT05dp7nsWLkHIiHEwx1UkjF7vZcf5+QM88p83820+qhj8d16GM2a7kvfnkC
 XC3hbdLcuWZ0WbYcg+B3
 =HHvc
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' into staging

Fix memory leaks when using object_property_get_str()

# gpg: Signature made Tue 03 Apr 2018 15:00:10 BST
# gpg:                using RSA key 2807936F984DC5A6
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>"
# Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF  D1AA 2807 936F 984D C5A6

* remotes/ehabkost/tags/x86-next-pull-request:
  sev/i386: fix memory leak in sev_guest_init()
  exec: fix memory leak in find_max_supported_pagesize()

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-04-04 11:13:52 +01:00
Peter Maydell 71ad102baa -----BEGIN PGP SIGNATURE-----
iQIcBAABAgAGBQJaw1h7AAoJEPMMOL0/L74855AP/1PWGJunWm0mwadEa3dhOGZh
 YSm1rK5Akt19ifwa+qFZ0zzxGUDOkY8McLyO+AIByQKQ5Z5Iv87ZmdOtBKTePXDe
 B7uiZxIuENW/TLmXqf5CeMQcwFPJUvf0IYk+y6S34Uuq+W09szUz4xLs6ORTkqFi
 1YxuwiVn6frnTo6gxPNhQl9VKVi+xaUVgXrrhOJOOcLdc/AAcBtbG2RpKFCff35d
 +dgwhXcpAAh4RwVsK1qYVAVyp+QKw6Sf7p2nMNRR+ZjdfqWWYqxuI1A7G7gAY3X5
 MkFCs7ccjHt+PMp9RS/5mnLBm3LQqcsQiiqVIifdq1APkr5ejOaD9wR7WQX0EIqD
 GN/ygUUgmOCYGE0EQNKQ/+Iq8adE6qKrsbeZkdM945vgFZ8aBBbN/22EKsqtpa3O
 5vovfVfAuy4egqtZ3hMYU8hcXFNRzUyTBrbUEpP0jT17OIpso0jiaEbFr9u3ajQU
 w0gE4N6aiI+LnIQeJ52QRUqvRneas2bm/Wc7NSY1wkJvZzv+AKRTMENqKlN9cTFk
 ZJGqGWcCny94ExOJwDi6A+DsyDOXL0n+IgBkO6yZqMFTMHu8uRfEYaJ5Oic0Yjbt
 G7lRCjwvfJRbyapFQYN5nUe1UmNSqzU75xfC1jVeLhBKgjtdPDzEBl+uvdcGh5Us
 bk8WR4ZbtxdO7WxdCzXd
 =CWOK
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-2.12-pull-request' into staging

# gpg: Signature made Tue 03 Apr 2018 11:33:31 BST
# gpg:                using RSA key F30C38BD3F2FBE3C
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>"
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>"
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>"
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* remotes/vivier2/tags/linux-user-for-2.12-pull-request:
  linux-user: fix TARGET___O_TMPFILE for sparc
  linux-user: define TARGET_ARCH_HAS_KA_RESTORER
  linux-user: fix alpha signal emulation

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-04-04 09:36:14 +01:00
Peter Maydell f7481f651c - fix a memory leak in the ipl code introduced with this release
- increase timeout in the bios to avoid hangs during migration (and
   rebuild bios to activate the change)
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEEw9DWbcNiT/aowBjO3s9rk8bwL68FAlrDOy4SHGNvaHVja0By
 ZWRoYXQuY29tAAoJEN7Pa5PG8C+vi5YP/3AlyYCxb51CF/1k1ao7VHVvJhQBs4Ez
 KURroqhpZXSyEVsqSixjnOFu8C56+Uzz4Qg3LdY32gClSjD0oyZHea00qf599GVk
 tIzQI2nSnuMtvOdAQVMUU+TZ4Arp5c9Pg+PA/3nH+K2SvJIoWEl3GxmknEhzTHkM
 /ZPhO676DV9fMzbIrIYtPrDMGL6qJ/6Crt2FL6UeRDFCFMbq1N+0irQSysFmWTKV
 pLEFe6j8TsvCxdbMwIqiRzry8Y5FvE1Mu1o6uFTJMYVmFGQHX5g7O563W78a1xHM
 n1zAbyqdNqF4h12KOF0zkDKgCS1j4Fl46NS5dg4pRCHuZ4tJy29bwvBAFcGpzR0R
 5LcgnrLYk7pwGi3aEozNdHCCqbN0H5HibqZ4dlzV24DQaGtJTJCTxM/RKSiigknF
 IWgIBd1NND7tVOmXdjhdvvfssge2HMmALq+sfKR5p3aUQiECvAN0n14UeArVFuaJ
 K59DyRYEVNkyunfux9kLQt3MdhRbSqagABBFdHkPsMPv4DSd9JXhjowh4CZdd7ex
 Xq2m5zc0mHNHsH3r+2Rr0Jh8Kal8O4OeD6qYK41mHrSTYbmVSkF8qd1Kw3ZhqAi1
 2EsPvGpG9zrsKBElTLfoP/rDgg+KxC1K9793K8Dl/MlKmWmNqwQg006KaUZ93Gp1
 dFHDz3BmEsY+
 =B1VD
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20180403' into staging

- fix a memory leak in the ipl code introduced with this release
- increase timeout in the bios to avoid hangs during migration (and
  rebuild bios to activate the change)

# gpg: Signature made Tue 03 Apr 2018 09:28:30 BST
# gpg:                using RSA key DECF6B93C6F02FAF
# gpg: Good signature from "Cornelia Huck <conny@cornelia-huck.de>"
# gpg:                 aka "Cornelia Huck <huckc@linux.vnet.ibm.com>"
# gpg:                 aka "Cornelia Huck <cornelia.huck@de.ibm.com>"
# gpg:                 aka "Cornelia Huck <cohuck@kernel.org>"
# gpg:                 aka "Cornelia Huck <cohuck@redhat.com>"
# Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0  18CE DECF 6B93 C6F0 2FAF

* remotes/cohuck/tags/s390x-20180403:
  pc-bios/s390-ccw: update image
  pc-bios/s390-ccw: Increase virtio timeout to 30 seconds
  hw/s390x: fix memory leak in s390_init_ipl_dev()

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-04-03 23:23:58 +01:00
Peter Maydell 9abfc88af3 xtensa-specific fixes for linux-user:
- fix flushing registers for signal processing in call8 and call12 frames;
 - fix PC value for restarted syscalls;
 - fix sysv IPC structures;
 - fix fadvise64 syscall;
 
 generic fixes for linux-user:
 
 - fix QEMU assertion in multithreaded application by calling cpu_copy
   under clone_lock;
 - fix mq_getsetattr implementation;
 - fix error propagation in clock_gettime;
 - implement clock_settime.
 -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCAAxFiEEK2eFS5jlMn3N6xfYUfnMkfg/oEQFAlrCYzwTHGpjbXZia2Jj
 QGdtYWlsLmNvbQAKCRBR+cyR+D+gRD1qD/9ZYl4iEoNJPzRAafwIpJf6hNv6SU0i
 2QBDSVWuyFjIZWZ2i2he6N3PZPTJ2YuCkG7sr/nhd8uWgFuULCUqedbgoheW+Jwf
 Wfn2F/d8qNhLIQv6XvNxUoIsKtsx+/359VegToz1XoxgD0dQYfpCtODK+kVfHMay
 1OXvY0Yy0p5e0G0et/uS6dl2dB3wibWtaaxMFcIX/nVbhOrwZLhOIAz58NhHAqvI
 Tq+pLqHheKRpsvNl2cOs8nhQ1X9m8nlhVjrIuv/V21P6fRZc0bIfINqHx7g8FRiQ
 O+B4MBGp0wgXbHKjTkOUUUn0FQBVqnv9xlfeLolu67usnX8hN5NuNYiJVVtFmy6R
 ChqvM5zDzykpo+wiPIn5nBzZvDF0H3rnRpGiZaboH0jdDJb6ZyUVU8PWIj6KbTLB
 uDaJ0Rn7MLZnBiqnNtME7cpLm+hDlIIHXu8PDFrSz8NqnoPQbE+OZwlAEnos05uL
 mB1roPALIeEAHvA64b+M2REy4/qpm+rZdjDXU6iGVXrdjN6bizykOIzyzhXikBpP
 Kpf5HuKFHLIHnFavZCqg3tJGkXB+0AmJV7p1XntXnZ4JWOP0OStbg/f21XOrZVVd
 RDpP2nmSzyP6EwHAIxKIDQPVEVeWbXnpAWz7qm++eOBXRUIcbtQVormXfmupR9kI
 /H8C+5fGf2LZeA==
 =NiR+
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/xtensa/tags/20180402-xtensa' into staging

xtensa-specific fixes for linux-user:

- fix flushing registers for signal processing in call8 and call12 frames;
- fix PC value for restarted syscalls;
- fix sysv IPC structures;
- fix fadvise64 syscall;

generic fixes for linux-user:

- fix QEMU assertion in multithreaded application by calling cpu_copy
  under clone_lock;
- fix mq_getsetattr implementation;
- fix error propagation in clock_gettime;
- implement clock_settime.

# gpg: Signature made Mon 02 Apr 2018 18:07:08 BST
# gpg:                using RSA key 51F9CC91F83FA044
# gpg: Good signature from "Max Filippov <filippov@cadence.com>"
# gpg:                 aka "Max Filippov <max.filippov@cogentembedded.com>"
# gpg:                 aka "Max Filippov <jcmvbkbc@gmail.com>"
# Primary key fingerprint: 2B67 854B 98E5 327D CDEB  17D8 51F9 CC91 F83F A044

* remotes/xtensa/tags/20180402-xtensa:
  target/xtensa: linux-user: fix fadvise64 call
  linux-user: implement clock_settime
  linux-user: fix error propagation in clock_gettime
  target/xtensa: linux-user: fix sysv IPC structures
  linux-user: fix mq_getsetattr implementation
  linux-user: call cpu_copy under clone_lock
  target/xtensa: linux-user: rewind pc for restarted syscall
  target/xtensa: fix flush_window_regs

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-04-03 19:02:46 +01:00
Kevin Wolf 9c1386d3ff A fix for preallocated truncation, a new iotest, and a fix to make the iotests work more comfortably on ppc64
-----BEGIN PGP SIGNATURE-----
 
 iQEcBAABAgAGBQJaw6CJAAoJEPQH2wBh1c9AZvcIAL51TsxzLBfYbEr7t/OqaYcT
 KptgkLn8UPUsVwEaZ1i9T+qpPqUhCgUeqBki4wTpGOfwmRO633L81lhlvLU1RD5f
 a9qsIWtvG0eYw+BU4P+ojltufdeQRQMxuLVhoiq2ur9vC8zUy6tEnF+yqOdWHYsm
 83Z2T/NFZ192zIwPD3Rq9/+ijllJOhODrHdAcnwBp0IuvlXi5FV7GjccB4scW/Ym
 LwDe7cNWv0XlzRlosyhTRs0HiOm+XiLAj5t9dVKFiuZsUwGFEXx6GiRtUutDf1j8
 5ham2wiYLsvxnSgRoUk486Txuj2ceNYDOvnllSv3uFh2kZyTaYewOL1acQFmtVw=
 =5AX/
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'mreitz/tags/pull-block-2018-04-03' into queue-block

A fix for preallocated truncation, a new iotest, and a fix to make the iotests work more comfortably on ppc64

# gpg: Signature made Tue Apr  3 17:40:57 2018 CEST
# gpg:                using RSA key F407DB0061D5CF40
# gpg: Good signature from "Max Reitz <mreitz@redhat.com>"
# Primary key fingerprint: 91BE B60A 30DB 3E88 57D1  1829 F407 DB00 61D5 CF40

* mreitz/tags/pull-block-2018-04-03:
  iotests: Test abnormally large size in compressed cluster descriptor
  qemu-iotests: Use ppc64 qemu_arch on ppc64le host
  iotests: Test preallocated truncate of 2G image
  block/file-posix: Fix fully preallocated truncate

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2018-04-03 17:48:45 +02:00
Alberto Garcia abd3622cc0 iotests: Test abnormally large size in compressed cluster descriptor
L2 entries for compressed clusters have a field that indicates the
number of sectors used to store the data in the image.

That's however not the size of the compressed data itself, just the
number of sectors where that data is located. The actual data size is
usually not a multiple of the sector size, and therefore cannot be
represented with this field.

The way it works is that QEMU reads all the specified sectors and
starts decompressing the data until there's enough to recover the
original uncompressed cluster. If there are any bytes left that
haven't been decompressed they are simply ignored.

One consequence of this is that even if the size field is larger than
it needs to be QEMU can handle it just fine: it will read more data
from disk but it will ignore the extra bytes.

This test creates an image with two compressed clusters that use 5
sectors (2.5 KB) each, increases the size field to the maximum (8192
sectors, or 4 MB) and verifies that the data can be read without
problems.

This test is important because while the decompressed data takes
exactly one cluster, the maximum value allowed in the compressed size
field is twice the cluster size. So although QEMU won't produce images
with such large values we need to make sure that it can handle them.

Another effect of increasing the size field is that it can make
it include data from the following host cluster(s). In this case
'qemu-img check' will detect that the refcounts are not correct, and
we'll need to rebuild them.

Additionally, this patch also tests that decreasing the size corrupts
the image since the original data can no longer be recovered. In this
case QEMU returns an error when trying to read the compressed data,
but 'qemu-img check' doesn't see anything wrong if the refcounts are
consistent.

One possible task for the future is to make 'qemu-img check' verify
the sizes of the compressed clusters, by trying to decompress the data
and checking that the size stored in the L2 entry is correct.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Message-id: 20180329120745.11154-1-berto@igalia.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
2018-04-03 17:39:37 +02:00
Lukáš Doktor 96914159b7 qemu-iotests: Use ppc64 qemu_arch on ppc64le host
The qemu target does not always correspond to the host machine type. For
example ppc64le machine target is ppc64. Let's introduce "qemu_arch"
variable to store the matching qemu architecture related to the current
architecture and use it when auto-detecting the default qemu binary.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
Message-id: 20180329112053.5399-2-ldoktor@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
2018-04-03 17:39:37 +02:00
Max Reitz 733d1dce0f iotests: Test preallocated truncate of 2G image
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 20180228131315.30194-3-mreitz@redhat.com
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
2018-04-03 17:39:37 +02:00
Max Reitz 82b45e0a0b block/file-posix: Fix fully preallocated truncate
Storing the lseek() result in an int results in it overflowing when the
file is at least 2 GB big.  Then, we have a 50 % chance of the result
being "negative" and thus thinking an error occurred when actually
everything went just fine.

So we should use the correct type for storing the result: off_t.

Reported-by: Daniel P. Berrange <berrange@redhat.com>
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1549231
Cc: qemu-stable@nongnu.org
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 20180228131315.30194-2-mreitz@redhat.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
2018-04-03 17:39:37 +02:00
Vladimir Sementsov-Ogievskiy eb42e7193e iotests: fix 208 for luks format
Support luks images creatins like in 205

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2018-04-03 17:13:51 +02:00
Peter Maydell 13b65ec54d nbd patches for 2018-04-02
- Eric Blake: nbd: Fix 32-bit compilation on BLOCK_STATUS
 - Eric Blake: nbd/client: Correctly handle bad server REP_META_CONTEXT
 - Eric Blake: nbd: trace meta context negotiation
 -----BEGIN PGP SIGNATURE-----
 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
 
 iQEcBAABCAAGBQJawjrlAAoJEKeha0olJ0NqFQMIAIJfn+VPlPSXsX72pYzlRDhQ
 rWmlpqrfeYo8+gfTSt30ZGa0LDz+ZiTlToN/NdCnqexBHiok0Im+vSzAH8UJFjpo
 KHvr/Lh/x+rvx1w5Z/+2wFu46EyrikwRHSLpvlCow5IyDv+GMPbS7qmVxT6Hri6f
 MsLJRqg54AwR6CuWXVdBC3SO1TV4VNJSM+Mmlrpk9G3s7l46HmYpS5PaNP3sjgLR
 vezmvZ1pCc4Q7bXjAOBSzyc3mCoq1XYldapgBOXRHCWQScYj13w+PWyLO6yVBWzG
 GDEDsD6GFdp/Sgphr66f+ou/ILt/Ic6SJ1s9wDZ+GRDPow8DmEcIiBIz92/iEys=
 =R2Qk
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2018-04-02' into staging

nbd patches for 2018-04-02

- Eric Blake: nbd: Fix 32-bit compilation on BLOCK_STATUS
- Eric Blake: nbd/client: Correctly handle bad server REP_META_CONTEXT
- Eric Blake: nbd: trace meta context negotiation

# gpg: Signature made Mon 02 Apr 2018 15:15:01 BST
# gpg:                using RSA key A7A16B4A2527436A
# gpg: Good signature from "Eric Blake <eblake@redhat.com>"
# gpg:                 aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>"
# gpg:                 aka "[jpeg image of size 6874]"
# Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2  F3AA A7A1 6B4A 2527 436A

* remotes/ericb/tags/pull-nbd-2018-04-02:
  nbd: trace meta context negotiation
  nbd/client: Correctly handle bad server REP_META_CONTEXT
  nbd: Fix 32-bit compilation on BLOCK_STATUS

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-04-03 15:59:50 +01:00
Alberto Garcia 627f607e3d iotests: Update 186 after commit ac64273c66
Commit ac64273c66 modified the output of iotest 186, changing
the QOM path of floppy drives from /machine/unattached/device[17] to
/machine/unattached/device[13].

Instead of updating the test output to reflect this change, this patch
adds a new filter that hides all QOM paths from the 'Attached to:'
line of the 'info block' command.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2018-04-03 16:58:48 +02:00
Alberto Garcia 242c172132 iotests: Update 051 and 186 after commit 1454509726
SCSI controllers are no longer created automatically for
-drive if=scsi, so this patch updates the tests that relied
on that.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2018-04-03 16:58:48 +02:00
Kevin Wolf 9dae635afa gluster: Fix blockdev-add with server.N.type=unix
The legacy command line interface gets the socket path from an option
called 'socket'. QAPI in contract uses SocketAddress, where the
corresponding option is called 'path'.

Fix the gluster block driver to accept both 'socket' and 'path', with
'path' being the preferred syntax.

https://bugzilla.redhat.com/show_bug.cgi?id=1545155

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20180403110810.25624-1-kwolf@redhat.com
Signed-off-by: Jeff Cody <jcody@redhat.com>
2018-04-03 09:57:14 -04:00
Marc-André Lureau 604343ced7 blockjob: use qapi enum helpers
QAPI generator provide #define helpers for looking up enum string.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Message-id: 20180327153011.29569-1-marcandre.lureau@redhat.com
Signed-off-by: Jeff Cody <jcody@redhat.com>
2018-04-03 09:56:55 -04:00
Marc-André Lureau a865cebb82 blockjob: leak fix, remove from txn when failing early
This fixes leaks found by ASAN such as:
  GTESTER tests/test-blockjob
=================================================================
==31442==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f88483cba38 in __interceptor_calloc (/lib64/libasan.so.4+0xdea38)
    #1 0x7f8845e1bd77 in g_malloc0 ../glib/gmem.c:129
    #2 0x7f8845e1c04b in g_malloc0_n ../glib/gmem.c:360
    #3 0x5584d2732498 in block_job_txn_new /home/elmarco/src/qemu/blockjob.c:172
    #4 0x5584d2739b28 in block_job_create /home/elmarco/src/qemu/blockjob.c:973
    #5 0x5584d270ae31 in mk_job /home/elmarco/src/qemu/tests/test-blockjob.c:34
    #6 0x5584d270b1c1 in do_test_id /home/elmarco/src/qemu/tests/test-blockjob.c:57
    #7 0x5584d270b65c in test_job_ids /home/elmarco/src/qemu/tests/test-blockjob.c:118
    #8 0x7f8845e40b69 in test_case_run ../glib/gtestutils.c:2255
    #9 0x7f8845e40f29 in g_test_run_suite_internal ../glib/gtestutils.c:2339
    #10 0x7f8845e40fd2 in g_test_run_suite_internal ../glib/gtestutils.c:2351
    #11 0x7f8845e411e9 in g_test_run_suite ../glib/gtestutils.c:2426
    #12 0x7f8845e3fe72 in g_test_run ../glib/gtestutils.c:1692
    #13 0x5584d270d6e2 in main /home/elmarco/src/qemu/tests/test-blockjob.c:377
    #14 0x7f8843641f29 in __libc_start_main (/lib64/libc.so.6+0x20f29)

Add an assert to make sure that the job doesn't have associated txn before free().

[Jeff Cody: N.B., used updated patch provided by John Snow]

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
2018-04-03 09:56:55 -04:00
Jeff Cody a03083a017 block: handle invalid lseek returns gracefully
In commit 223a23c198, we implemented a
workaround in the gluster driver to handle invalid values returned for
SEEK_DATA or SEEK_HOLE.

In some instances, these same invalid values can be seen in the posix
file handler as well - for example, it has been reported on FUSE gluster
mounts.

Calling assert() for these invalid values is overly harsh; we can safely
return -EIO and allow this case to be treated as a "learned nothing"
case (e.g., D4 / H4, as commented in the code).

This patch does the same thing that 223a23c198 did for gluster.c,
except in file-posix.c

Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2018-04-03 15:25:17 +02:00
Kevin Wolf 3e4d88eabf gluster: Fix blockdev-add with server.N.type=unix
The legacy command line interface gets the socket path from an option
called 'socket'. QAPI in contract uses SocketAddress, where the
corresponding option is called 'path'.

Fix the gluster block driver to accept both 'socket' and 'path', with
'path' being the preferred syntax.

https://bugzilla.redhat.com/show_bug.cgi?id=1545155

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2018-04-03 15:20:36 +02:00
Laurent Vivier 3ea7f4a226 linux-user: fix TARGET___O_TMPFILE for sparc
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20180402102453.9883-3-laurent@vivier.eu>
2018-04-03 11:50:24 +02:00
Laurent Vivier 5de154e82f linux-user: define TARGET_ARCH_HAS_KA_RESTORER
Sparc as an extended sigaction structure containing
the field ka_restorer used in place of sa_restorer.

Define TARGET_ARCH_HAS_KA_RESTORER and use it
with sparc.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20180402102453.9883-2-laurent@vivier.eu>
2018-04-03 11:50:15 +02:00
Laurent Vivier 95a29a4e3e linux-user: fix alpha signal emulation
setup_frame() doesn't set correctly the address of the trampoline code.
The offset of retcode array must be added to the stack frame address.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20180401204653.14211-1-laurent@vivier.eu>
2018-04-03 11:49:49 +02:00
Cornelia Huck d3b6e3bb6d pc-bios/s390-ccw: update image
Contains the following commits:
- pc-bios/s390-ccw: Move string arrays from bootmap header to .c file
- pc-bios/s390-ccw: Increase virtio timeout to 30 seconds

Signed-off-by: Cornelia Huck <cohuck@redhat.com>
2018-04-03 10:03:38 +02:00
Thomas Huth 23bf419c1c pc-bios/s390-ccw: Increase virtio timeout to 30 seconds
The current timeout is set to only three seconds - and considering that
vring_wait_reply() or rather get_second() is not doing any rounding,
the real timeout is likely rather 2 seconds in most cases. When the
host is really badly loaded, it's possible that we hit this timeout by
mistake; it's even more likely if we run the guest in TCG mode instead
of KVM.

So let's increase the timeout to 30 seconds instead to ease this situation
(30 seconds is also the timeout that is used by the Linux SCSI subsystem
for example, so this seems to be a sane value for block IO timeout).

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1549079
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1522316251-16399-1-git-send-email-thuth@redhat.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
[CH: tweaked commit message]
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
2018-04-03 10:03:38 +02:00
Greg Kurz d9b06db813 hw/s390x: fix memory leak in s390_init_ipl_dev()
The string returned by object_property_get_str() is dynamically allocated.

Fixes: 3c4e9baacf
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <152231460685.69730.14860451936216690693.stgit@bahia.lan>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
2018-04-03 10:03:38 +02:00
Greg Kurz 5d7bc72a43 sev/i386: fix memory leak in sev_guest_init()
The string returned by object_property_get_str() is dynamically allocated.

Fixes: d8575c6c02
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <152231462116.69730.14119625999092384450.stgit@bahia.lan>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-04-02 23:05:26 -03:00
Greg Kurz 72a841d2a4 exec: fix memory leak in find_max_supported_pagesize()
The string returned by object_property_get_str() is dynamically allocated.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <152231458624.69730.1752893648612848392.stgit@bahia.lan>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-04-02 23:05:15 -03:00
Eric Blake 2b53af2523 nbd: trace meta context negotiation
Having a more detailed log of the interaction between client and
server is invaluable in debugging how meta context negotiation
actually works.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180330130950.1931229-1-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2018-04-02 09:10:49 -05:00
Eric Blake 260e34dbb7 nbd/client: Correctly handle bad server REP_META_CONTEXT
It's never a good idea to blindly read for size bytes as
returned by the server without first validating that the size
is within bounds; a malicious or buggy server could cause us
to hang or get out of sync from reading further messages.

It may be smarter to try and teach the client to cope with
unexpected context ids by silently ignoring them instead of
hanging up on the server, but for now, if the server doesn't
reply with exactly the one context we expect, it's easier to
just give up - however, if we give up for any reason other
than an I/O failure, we might as well try to politely tell
the server we are quitting rather than continuing.

Fix some typos in the process.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180329231837.1914680-1-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2018-04-02 08:59:34 -05:00
Eric Blake 00d96a4612 nbd: Fix 32-bit compilation on BLOCK_STATUS
iotests 123 and 209 fail on 32-bit platforms.  The culprit:
sizeof(extent) is wrong; we want sizeof(*extent).  But since
the struct is 8 bytes, it happened to work on 64-bit platforms
where the pointer is also 8 bytes (nasty).

Fixes: 78a33ab58
Reported-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180327210517.1804242-1-eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2018-04-02 08:45:21 -05:00
Max Filippov 64a563dd8d target/xtensa: linux-user: fix fadvise64 call
fadvise64_64 on xtensa passes advice as the second argument and so must
be handled similar to PPC.

This fixes glibc testsuite tests posix/tst-posix_fadvise and
posix/tst-posix_fadvise64.

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2018-04-02 04:15:35 -07:00
Max Filippov 12e3340c23 linux-user: implement clock_settime
This fixes glibc testsuite test rt/tst-clock2.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2018-04-01 14:23:17 -07:00
Max Filippov b9f9908e2d linux-user: fix error propagation in clock_gettime
host_to_target_timespec may return error if target address could not be
locked, but it is ignored.
Propagate return value of host_to_target_timespec to the caller of
clock_gettime.

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2018-04-01 14:22:04 -07:00
Max Filippov a3da8be512 target/xtensa: linux-user: fix sysv IPC structures
- make target_ipc_perm fields match kernel definitions for xtensa;
- add target_semid64_ds with proper order of times and reserved fields
  for little/big endian specific for xtensa;
- add missing reserved fields after time fields to the target_shmid_ds;
- fix types of shm_cpid, shm_lpid and shm_nattch fields of
  target_shmid_ds to match kernel definitions for xtensa.

These changes fix guest ipcs output and fix glibc testsuite tests
sysvipc/test-sysvsem and sysvipc/test-sysvshm.

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2018-04-01 14:05:23 -07:00
Max Filippov a23ea40982 linux-user: fix mq_getsetattr implementation
mq_getsetattr implementation does not set errno correctly in case of
error. Also in the presence of both 2nd and 3rd arguments it calls both
mq_getattr and mq_setattr, whereas only the latter call would suffice.

Don't call mq_getattr in the presence of the 2nd argument. Don't copy
output back to user in case of error. Use get_errno to set errno value.

This fixes test rt/tst-mqueue2 from the glibc testsuite.

Cc: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Riku Voipio <riku.voipio@iki.fi>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2018-03-31 14:06:36 -07:00
Max Filippov 73a988d957 linux-user: call cpu_copy under clone_lock
cpu_copy adds newly created CPU object to container/machine/unattached,
but does it w/o proper locking. As a result when multiple threads create
threads rapidly QEMU may abort with the following message:

  GLib-CRITICAL **: g_hash_table_iter_next: assertion
  'ri->version == ri->hash_table->version' failed

  ERROR:qemu/qom/object.c:1663:object_get_canonical_path_component:
  code should not be reached

E.g. this issue is observed when running glibc test nptl/tst-eintr1.
Move cpu_copy invocation under clone_lock to fix that.

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2018-03-31 14:06:36 -07:00
Max Filippov 4a6bf7adb9 target/xtensa: linux-user: rewind pc for restarted syscall
In case of syscall restart request set pc back to the syscall
instruction.

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2018-03-31 14:06:35 -07:00
Max Filippov 20ef667060 target/xtensa: fix flush_window_regs
flush_window_regs uses wrong stack frame to save overflow registers in
call8 and call12 frames, which results in wrong register values in
callers of a function that received a signal.
Reimplement flush_window_regs closely following window overflow
sequence.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2018-03-31 14:06:35 -07:00