]> Git Repo - qemu.git/log
qemu.git
6 years agonvme: fix oob access issue(CVE-2018-16847)
Li Qiang [Fri, 2 Nov 2018 01:22:43 +0000 (18:22 -0700)]
nvme: fix oob access issue(CVE-2018-16847)

Currently, the nvme_cmb_ops mr doesn't check the addr and size.
This can lead an oob access issue. This is triggerable in the guest.
Add check to avoid this issue.

Fixes CVE-2018-16847.

Reported-by: Li Qiang <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
Signed-off-by: Li Qiang <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
6 years agoMAINTAINERS: clarify some of the tags
Cornelia Huck [Fri, 26 Oct 2018 10:57:11 +0000 (12:57 +0200)]
MAINTAINERS: clarify some of the tags

The MAINTAINERS file is a bit sparse on information about what
the different designators are. Let's add some more information
to give contributors a better idea about what the different
roles are.

Signed-off-by: Cornelia Huck <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Message-id: 20181026105711[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agoMerge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-november-2018-v2...
Peter Maydell [Mon, 19 Nov 2018 10:23:45 +0000 (10:23 +0000)]
Merge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-november-2018-v2' into staging

MIPS queue for QEMU 3.1-rc2 - v2

# gpg: Signature made Sat 17 Nov 2018 18:30:46 GMT
# gpg:                using RSA key D4972A8967F75A65
# gpg: Good signature from "Aleksandar Markovic <[email protected]>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 8526 FBF1 5DA3 811F 4A01  DD75 D497 2A89 67F7 5A65

* remotes/amarkovic/tags/mips-queue-november-2018-v2:
  MAINTAINERS: Add Stefan Markovic as a MIPS reviewer
  target/mips: Disable R5900 support
  target/mips: Rename MMI-related functions
  target/mips: Rename MMI-related opcodes
  target/mips: Rename MMI-related masks
  target/mips: Guard check_insn with INSN_R5900 check
  target/mips: Guard check_insn_opc_user_only with INSN_R5900 check
  target/mips: Fix decoding mechanism of special R5900 opcodes
  target/mips: Fix decoding mechanism of R5900 DIV1 and DIVU1
  target/mips: Fix decoding mechanism of R5900 MFLO1, MFHI1, MTLO1 and MTHI1
  linux-user: Update MIPS specific prctl() implementation

Signed-off-by: Peter Maydell <[email protected]>
6 years agoMerge remote-tracking branch 'remotes/riscv/tags/riscv-for-master-3.1-rc2' into staging
Peter Maydell [Mon, 19 Nov 2018 09:35:27 +0000 (09:35 +0000)]
Merge remote-tracking branch 'remotes/riscv/tags/riscv-for-master-3.1-rc2' into staging

RISC-V Patches for 3.1-rc2

This pull request contains four patches that aren't really related to
each other aside from all being bug fixes that I think should go in for
3.1.0:

* The second half of Alistair's memory leak patch set that I missed last
  week.
* A fix to make fclass.d availiable only on RV64IFD systems (without
  this it's availiable on RV32IFD systems, truncating the result).
* A fix to make sfence.vm availiable only in priv-1.9.1, and sfence.vma
  only availiable in priv-1.10.
* A change to respect fences in user-mode emulators, which were
  previously treated as NOPs.

As usual, this builds and boot Linux for me.  I don't think I have
anything else planned for 3.1.0, but I may be wrong as things are a bit
hectic this week.

# gpg: Signature made Tue 13 Nov 2018 23:48:38 GMT
# gpg:                using RSA key EF4CA1502CCBAB41
# gpg: Good signature from "Palmer Dabbelt <[email protected]>"
# gpg:                 aka "Palmer Dabbelt <[email protected]>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 00CE 76D1 8349 60DF CE88  6DF8 EF4C A150 2CCB AB41

* remotes/riscv/tags/riscv-for-master-3.1-rc2:
  RISC-V: Respect fences for user-only emulators
  target/riscv: Fix sfence.vm/a both available in any priv version
  target/riscv: Fix FCLASS_D being treated as RV64 only
  hw/riscv/virt: Free the test device tree node name

Signed-off-by: Peter Maydell <[email protected]>
6 years agoMAINTAINERS: Add Stefan Markovic as a MIPS reviewer
Aleksandar Markovic [Sat, 17 Nov 2018 14:04:33 +0000 (15:04 +0100)]
MAINTAINERS: Add Stefan Markovic as a MIPS reviewer

Add Stefan Markovic as a MIPS reviewer. He had several key
contributions to QEMU for MIPS this year. He is a meticulous
person with the ability to think and act on many levels.

Reviewed-by: Stefan Markovic <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
6 years agotarget/mips: Disable R5900 support
Aleksandar Markovic [Sat, 17 Nov 2018 14:08:57 +0000 (15:08 +0100)]
target/mips: Disable R5900 support

Disable R5900 support. There are some outstanding issues related
to ABI support and emulation accuracy, that were not understood
well during review process. Disable to avoid backward compatibility
issues.

Reverts commit ed4f49ba9bb56ebca6987b1083255daf6c89b5de.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
6 years agotarget/mips: Rename MMI-related functions
Aleksandar Markovic [Sat, 17 Nov 2018 15:02:22 +0000 (16:02 +0100)]
target/mips: Rename MMI-related functions

Rename MMI-related functions.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Stefan Markovic <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
6 years agotarget/mips: Rename MMI-related opcodes
Aleksandar Markovic [Sat, 17 Nov 2018 14:53:58 +0000 (15:53 +0100)]
target/mips: Rename MMI-related opcodes

Rename MMI-related opcodes.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Stefan Markovic <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
6 years agotarget/mips: Rename MMI-related masks
Aleksandar Markovic [Tue, 30 Oct 2018 17:28:14 +0000 (18:28 +0100)]
target/mips: Rename MMI-related masks

Rename MMI-related masks.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Stefan Markovic <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
6 years agotarget/mips: Guard check_insn with INSN_R5900 check
Fredrik Noring [Wed, 7 Nov 2018 19:19:45 +0000 (20:19 +0100)]
target/mips: Guard check_insn with INSN_R5900 check

Explicitely mark handling of PREF instruction for R5900 as
treating the same as NOP.

Reviewed-by: Aleksandar Markovic <[email protected]>
Signed-off-by: Fredrik Noring <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
6 years agotarget/mips: Guard check_insn_opc_user_only with INSN_R5900 check
Fredrik Noring [Wed, 7 Nov 2018 19:19:34 +0000 (20:19 +0100)]
target/mips: Guard check_insn_opc_user_only with INSN_R5900 check

Avoid using check_opc_user_only() as a decision making code wrt
various architectures. Use ctx->insn_flags checks instead.

Reviewed-by: Aleksandar Markovic <[email protected]>
Signed-off-by: Fredrik Noring <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
6 years agotarget/mips: Fix decoding mechanism of special R5900 opcodes
Fredrik Noring [Wed, 7 Nov 2018 19:19:14 +0000 (20:19 +0100)]
target/mips: Fix decoding mechanism of special R5900 opcodes

MOVN, MOVZ, MFHI, MFLO, MTHI, MTLO, MULT, MULTU, DIV, DIVU, DMULT,
DMULTU, DDIV, DDIVU and JR are decoded in decode_opc_special_tx79
instead of the generic decode_opc_special_legacy.

Reviewed-by: Aleksandar Markovic <[email protected]>
Signed-off-by: Fredrik Noring <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
6 years agotarget/mips: Fix decoding mechanism of R5900 DIV1 and DIVU1
Fredrik Noring [Wed, 7 Nov 2018 19:18:15 +0000 (20:18 +0100)]
target/mips: Fix decoding mechanism of R5900 DIV1 and DIVU1

DIV1 and DIVU1 are generated in gen_div1_tx79 instead of the generic
gen_muldiv.

Signed-off-by: Fredrik Noring <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
6 years agotarget/mips: Fix decoding mechanism of R5900 MFLO1, MFHI1, MTLO1 and MTHI1
Fredrik Noring [Wed, 7 Nov 2018 19:18:01 +0000 (20:18 +0100)]
target/mips: Fix decoding mechanism of R5900 MFLO1, MFHI1, MTLO1 and MTHI1

MFLO1, MFHI1, MTLO1 and MTHI1 are generated in gen_HILO1_tx79 instead of
the generic gen_HILO.

Reviewed-by: Aleksandar Markovic <[email protected]>
Signed-off-by: Fredrik Noring <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
6 years agolinux-user: Update MIPS specific prctl() implementation
Stefan Markovic [Wed, 14 Nov 2018 13:37:08 +0000 (14:37 +0100)]
linux-user: Update MIPS specific prctl() implementation

Perform needed checks before actual prctl() PR_SET_FP_MODE and
PR_GET_FP_MODE work based on kernel implementation. Also, update
necessary hflags.

Reviewed-by: Laurent Vivier <[email protected]>
Signed-off-by: Stefan Markovic <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
6 years agoMerge remote-tracking branch 'remotes/kraxel/tags/fixes-31-20181116-pull-request...
Peter Maydell [Fri, 16 Nov 2018 13:53:01 +0000 (13:53 +0000)]
Merge remote-tracking branch 'remotes/kraxel/tags/fixes-31-20181116-pull-request' into staging

ui: add rendernode arg for egl-headless (fixes permission issues with libvirt)

# gpg: Signature made Fri 16 Nov 2018 13:29:15 GMT
# gpg:                using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <[email protected]>"
# gpg:                 aka "Gerd Hoffmann <[email protected]>"
# gpg:                 aka "Gerd Hoffmann (private) <[email protected]>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/fixes-31-20181116-pull-request:
  help: Provide help for egl-headless
  ui: Allow specifying 'rendernode' display option for egl-headless
  qapi: Add "rendernode" display option for egl-headless

Signed-off-by: Peter Maydell <[email protected]>
6 years agohelp: Provide help for egl-headless
Erik Skultety [Fri, 16 Nov 2018 10:14:44 +0000 (11:14 +0100)]
help: Provide help for egl-headless

EGL headless has been missing from QEMU's help or man page, we should
mention that such a thing exists, especially since projects like libvirt
might rely on that. This patch also adds the newly introduced option for
egl-headless 'rendernode'.

Signed-off-by: Erik Skultety <[email protected]>
Message-id: 87ef678b0934d3abba66c46c9e65b57119d29295.1542362949[email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
6 years agoui: Allow specifying 'rendernode' display option for egl-headless
Erik Skultety [Fri, 16 Nov 2018 10:14:43 +0000 (11:14 +0100)]
ui: Allow specifying 'rendernode' display option for egl-headless

As libvirt can't predict which rendernode QEMU would pick, it
won't adjust the permissions on the device, hence QEMU getting
"Permission denied" when opening the DRI device. Therefore, enable
'rendernode' option for egl-headless display type.

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

Signed-off-by: Erik Skultety <[email protected]>
Message-id: 27f4617f19aa1072114f10f1aa9dd199735ef982.1542362949[email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
6 years agoqapi: Add "rendernode" display option for egl-headless
Erik Skultety [Fri, 16 Nov 2018 10:14:42 +0000 (11:14 +0100)]
qapi: Add "rendernode" display option for egl-headless

Unlike SPICE, egl-headless doesn't offer a way of specifying the DRM
node used for OpenGL, hence QEMU always selecting the first one that is
available. Thus, add the 'rendernode' option for egl-headless to QAPI.

Signed-off-by: Erik Skultety <[email protected]>
Message-id: 7658e15eca72d520e7a5fb1c2e724702d83d4f7f.1542362949[email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
6 years agoMerge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging
Peter Maydell [Fri, 16 Nov 2018 10:01:04 +0000 (10:01 +0000)]
Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging

# gpg: Signature made Fri 16 Nov 2018 03:38:58 GMT
# gpg:                using RSA key EF04965B398D6211
# gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <[email protected]>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 215D 46F4 8246 689E C77F  3562 EF04 965B 398D 6211

* remotes/jasowang/tags/net-pull-request:
  net/filter-rewriter.c: Fix coverity static analysis issue

Signed-off-by: Peter Maydell <[email protected]>
6 years agonet/filter-rewriter.c: Fix coverity static analysis issue
Zhang Chen [Wed, 31 Oct 2018 00:50:15 +0000 (08:50 +0800)]
net/filter-rewriter.c: Fix coverity static analysis issue

The original code just follow the TCP state diagram,
but in this case, we can skip the TCPS_TIME_WAIT state to simplify
the implementation.

Signed-off-by: Zhang Chen <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
6 years agoMerge remote-tracking branch 'remotes/stefanberger/tags/pull-tpm-2018-11-15-1' into...
Peter Maydell [Thu, 15 Nov 2018 14:18:25 +0000 (14:18 +0000)]
Merge remote-tracking branch 'remotes/stefanberger/tags/pull-tpm-2018-11-15-1' into staging

Merge tpm 2018/11/15 v1

# gpg: Signature made Thu 15 Nov 2018 14:03:45 GMT
# gpg:                using RSA key 75AD65802A0B4211
# gpg: Good signature from "Stefan Berger <[email protected]>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: B818 B9CA DF90 89C2 D5CE  C66B 75AD 6580 2A0B 4211

* remotes/stefanberger/tags/pull-tpm-2018-11-15-1:
  tests: tpm: Use g_test_message rather than fprintf
  tpm: use loop iterator to set sts data field

Signed-off-by: Peter Maydell <[email protected]>
6 years agolinux-user/sparc/signal.c: Remove dead code
Peter Maydell [Thu, 15 Nov 2018 11:46:16 +0000 (11:46 +0000)]
linux-user/sparc/signal.c: Remove dead code

Coverity complains (CID 1390847) about some dead code in
do_sigreturn(). This is an if (err) clause that can never be
true, copied from the kernel (where __get_user returns an error).
The one code path that could report an error is in the
currently commented-out pseudocode for handling FPU register
restoring, so move the if into that comment (and fix the
broken indent in the comment in the process).

(The new position for the error check is also the semantically
correct one -- we should not restore the signal mask from
the signal frame if we get an error here, so the check must
be done before set_sigmask(), not after.)

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Message-id: 20181115114616[email protected]

6 years agomake-release: add skiboot .version file
Michael Roth [Fri, 9 Nov 2018 16:13:52 +0000 (10:13 -0600)]
make-release: add skiboot .version file

This is needed to build skiboot from tarball-distributed sources
since the git data the make_release.sh script relies on to generate
it is not available.

Cc: [email protected]
Reported-by: Michael Tokarev <[email protected]>
Signed-off-by: Michael Roth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: 20181109161352[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agoMerge remote-tracking branch 'remotes/stsquad/tags/pull-testing-fixes-for-3.1-141118...
Peter Maydell [Thu, 15 Nov 2018 11:26:48 +0000 (11:26 +0000)]
Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-fixes-for-3.1-141118-1' into staging

Testing tweaks:

  - split MacOSX build
  - fix for readdir() failures in check-tcg

# gpg: Signature made Wed 14 Nov 2018 13:08:24 GMT
# gpg:                using RSA key FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <[email protected]>"
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* remotes/stsquad/tags/pull-testing-fixes-for-3.1-141118-1:
  tests/tcg/multiarch: fix 32bit linux-test on 64bit host
  .travis.yml: split MacOSX builds and reduce target list

Signed-off-by: Peter Maydell <[email protected]>
6 years agoMerge remote-tracking branch 'remotes/cohuck/tags/s390x-20181114' into staging
Peter Maydell [Thu, 15 Nov 2018 10:01:16 +0000 (10:01 +0000)]
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20181114' into staging

Fix error handling during zpci device creation.

# gpg: Signature made Wed 14 Nov 2018 10:08:43 GMT
# gpg:                using RSA key DECF6B93C6F02FAF
# gpg: Good signature from "Cornelia Huck <[email protected]>"
# gpg:                 aka "Cornelia Huck <[email protected]>"
# gpg:                 aka "Cornelia Huck <[email protected]>"
# gpg:                 aka "Cornelia Huck <[email protected]>"
# gpg:                 aka "Cornelia Huck <[email protected]>"
# Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0  18CE DECF 6B93 C6F0 2FAF

* remotes/cohuck/tags/s390x-20181114:
  s390x/pci: properly fail if the zPCI device cannot be created

Signed-off-by: Peter Maydell <[email protected]>
6 years agotests: tpm: Use g_test_message rather than fprintf
Stefan Berger [Tue, 6 Nov 2018 14:08:40 +0000 (09:08 -0500)]
tests: tpm: Use g_test_message rather than fprintf

Display a message during the test using g_test_message rather
than fprintf.

Signed-off-by: Stefan Berger <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
6 years agotpm: use loop iterator to set sts data field
Prasad J Pandit [Tue, 6 Nov 2018 05:21:44 +0000 (10:51 +0530)]
tpm: use loop iterator to set sts data field

When TIS request is done, set 'sts' data field across all localities.

Signed-off-by: Prasad J Pandit <[email protected]>
Reviewed-by: Stefan Berger <[email protected]>
Signed-off-by: Stefan Berger <[email protected]>
6 years agotests/tcg/multiarch: fix 32bit linux-test on 64bit host
Laurent Vivier [Tue, 13 Nov 2018 17:54:37 +0000 (18:54 +0100)]
tests/tcg/multiarch: fix 32bit linux-test on 64bit host

Fix:

  TEST    linux-test on i386
  .../tests/tcg/multiarch/linux-test.c:201: readdir

readdir() calls getdents64() to have the list of the entries in a
directory, and getdents64() can return 64bit d_off values (with ext4,
for instance) that will not fit in the 32bit d_off field of the
readdir() dirent structure.

To avoid that, use readdir64() to use a 64bit d_off field too.

Signed-off-by: Laurent Vivier <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
6 years ago.travis.yml: split MacOSX builds and reduce target list
Alex Bennée [Mon, 8 Oct 2018 10:56:13 +0000 (11:56 +0100)]
.travis.yml: split MacOSX builds and reduce target list

We have reached the point where the MacOSX build was regularly timing
out. So as before I've reduced the target list to "major"
architectures to try and bring the build time down. I've added an
additional MacOSX build with the latest XCode with a minimal list of
"most likely" targets on MacOS.

Signed-off-by: Alex Bennée <[email protected]>
6 years agoRISC-V: Respect fences for user-only emulators
Palmer Dabbelt [Fri, 9 Nov 2018 18:56:50 +0000 (10:56 -0800)]
RISC-V: Respect fences for user-only emulators

Our current fence implementation ignores fences for the user-only
configurations.  This is incorrect but unlikely to manifest: it requires
multi-threaded user-only code that takes advantage of the weakness in
the host's memory model and can be inlined by TCG.

This patch simply treats fences the same way for all our emulators.
I've given it to testing as I don't want to construct a test that would
actually trigger the failure.

Our fence implementation has an additional deficiency where we map all
RISC-V fences to full fences.  Now that we have a formal memory model
for RISC-V we can start to take advantage of the strength bits on our
fence instructions.  This requires a bit more though, so I'm going to
split it out because the implementation is still correct without taking
advantage of these weaker fences.

Thanks to Richard Henderson for pointing out both of the issues.

Signed-off-by: Palmer Dabbelt <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
6 years agotarget/riscv: Fix sfence.vm/a both available in any priv version
Bastian Koppelmann [Thu, 8 Nov 2018 12:06:28 +0000 (13:06 +0100)]
target/riscv: Fix sfence.vm/a both available in any priv version

sfence.vm has been replaced in priv v1.10 spec by sfence.vma.

Reported-by: Richard Henderson <[email protected]>
Signed-off-by: Bastian Koppelmann <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Palmer Dabbelt <[email protected]>
6 years agotarget/riscv: Fix FCLASS_D being treated as RV64 only
Bastian Koppelmann [Thu, 8 Nov 2018 12:06:27 +0000 (13:06 +0100)]
target/riscv: Fix FCLASS_D being treated as RV64 only

Signed-off-by: Bastian Koppelmann <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Palmer Dabbelt <[email protected]>
6 years agohw/riscv/virt: Free the test device tree node name
Alistair Francis [Wed, 7 Nov 2018 21:51:45 +0000 (21:51 +0000)]
hw/riscv/virt: Free the test device tree node name

Signed-off-by: Alistair Francis <[email protected]>
Signed-off-by: Palmer Dabbelt <[email protected]>
6 years agoUpdate version for v3.1.0-rc1 release
Peter Maydell [Tue, 13 Nov 2018 18:16:14 +0000 (18:16 +0000)]
Update version for v3.1.0-rc1 release

Signed-off-by: Peter Maydell <[email protected]>
6 years agos390x/pci: properly fail if the zPCI device cannot be created
David Hildenbrand [Tue, 13 Nov 2018 12:17:10 +0000 (13:17 +0100)]
s390x/pci: properly fail if the zPCI device cannot be created

Right now, errors during realize()/pre_plug/plug of the zPCI device
would result in QEMU crashing instead of failing nicely when creating
a zPCI device for a PCI device.

Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Collin Walling <[email protected]>
Signed-off-by: David Hildenbrand <[email protected]>
Message-Id: <20181113121710[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
6 years agoMerge remote-tracking branch 'remotes/mdroth/tags/qga-pull-2018-11-12-tag' into staging
Peter Maydell [Tue, 13 Nov 2018 12:32:30 +0000 (12:32 +0000)]
Merge remote-tracking branch 'remotes/mdroth/tags/qga-pull-2018-11-12-tag' into staging

qemu-ga patch queue for 3.1.0

* add missing #include guards for guest-agent-core.h
* fix leaks introduced with recent win32 enablement of disk info in
  guest-get-fsinfo

# gpg: Signature made Tue 13 Nov 2018 02:52:12 GMT
# gpg:                using RSA key 3353C9CEF108B584
# gpg: Good signature from "Michael Roth <[email protected]>"
# gpg:                 aka "Michael Roth <[email protected]>"
# gpg:                 aka "Michael Roth <[email protected]>"
# Primary key fingerprint: CEAC C9E1 5534 EBAB B82D  3FA0 3353 C9CE F108 B584

* remotes/mdroth/tags/qga-pull-2018-11-12-tag:
  qga: Add multiple include guard to guest-agent-core.h
  qga-win: fix leaks of build_guest_disk_info()

Signed-off-by: Peter Maydell <[email protected]>
6 years agoMerge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-3.1-pull-request...
Peter Maydell [Tue, 13 Nov 2018 11:45:16 +0000 (11:45 +0000)]
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-3.1-pull-request' into staging

- gdb signal handling fix
- add SO_REUSEPORT
- remove dead-code

# gpg: Signature made Mon 12 Nov 2018 20:48:23 GMT
# gpg:                using RSA key F30C38BD3F2FBE3C
# gpg: Good signature from "Laurent Vivier <[email protected]>"
# gpg:                 aka "Laurent Vivier <[email protected]>"
# gpg:                 aka "Laurent Vivier (Red Hat) <[email protected]>"
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* remotes/vivier2/tags/linux-user-for-3.1-pull-request:
  linux-user: Add support for SO_REUSEPORT
  linux-user: Clean up nios2 main loop signal handling
  linux-user: Don't call gdb_handlesig() before queue_signal()
  linux-user: Remove dead error-checking code

Signed-off-by: Peter Maydell <[email protected]>
6 years agoMerge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20181113' into...
Peter Maydell [Tue, 13 Nov 2018 10:52:32 +0000 (10:52 +0000)]
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20181113' into staging

target/arm queue:
 * Remove no-longer-needed workaround for small SAU regions for v8M
 * Remove antique TODO comment
 * MAINTAINERS: Add an entry for the 'collie' machine
 * hw/arm/sysbus-fdt: Only call match_fn callback if the type matches
 * Fix infinite recursion in tlbi_aa64_vmalle1_write()
 * ARM KVM: fix various bugs in handling of guest debugging
 * Correctly implement handling of HCR_EL2.{VI, VF}
 * Hyp mode R14 is shared with User and System
 * Give Cortex-A15 and -A7 the EL2 feature

# gpg: Signature made Tue 13 Nov 2018 10:51:53 GMT
# gpg:                using RSA key 3C2525ED14360CDE
# gpg: Good signature from "Peter Maydell <[email protected]>"
# gpg:                 aka "Peter Maydell <[email protected]>"
# gpg:                 aka "Peter Maydell <[email protected]>"
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* remotes/pmaydell/tags/pull-target-arm-20181113:
  target/arm/cpu: Give Cortex-A15 and -A7 the EL2 feature
  target/arm: Hyp mode R14 is shared with User and System
  target/arm: Correctly implement handling of HCR_EL2.{VI, VF}
  target/arm: Track the state of our irq lines from the GIC explicitly
  Revert "target/arm: Implement HCR.VI and VF"
  arm: fix aa64_generate_debug_exceptions to work with EL2
  arm: use symbolic MDCR_TDE in arm_debug_target_el
  tests/guest-debug: fix scoping of failcount
  target/arm64: kvm debug set target_el when passing exception to guest
  target/arm64: hold BQL when calling do_interrupt()
  target/arm64: properly handle DBGVR RESS bits
  target/arm: Fix typo in tlbi_aa64_vmalle1_write
  hw/arm/sysbus-fdt: Only call match_fn callback if the type matches
  MAINTAINERS: Add an entry for the 'collie' machine
  target/arm: Remove antique TODO comment
  target/arm: Remove workaround for small SAU regions

Signed-off-by: Peter Maydell <[email protected]>
6 years agotarget/arm/cpu: Give Cortex-A15 and -A7 the EL2 feature
Peter Maydell [Tue, 13 Nov 2018 10:47:59 +0000 (10:47 +0000)]
target/arm/cpu: Give Cortex-A15 and -A7 the EL2 feature

The Cortex-A15 and Cortex-A7 both have EL2; now we've implemented
it properly we can enable the feature bit.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Edgar E. Iglesias <[email protected]>
Message-id: 20181109173553[email protected]

6 years agotarget/arm: Hyp mode R14 is shared with User and System
Peter Maydell [Tue, 13 Nov 2018 10:47:59 +0000 (10:47 +0000)]
target/arm: Hyp mode R14 is shared with User and System

Hyp mode is an exception to the general rule that each AArch32
mode has its own r13, r14 and SPSR -- it has a banked r13 and
SPSR but shares its r14 with User and System mode. We were
incorrectly implementing it as banked, which meant that on
entry to Hyp mode r14 was 0 rather than the USR/SYS r14.

We provide a new function r14_bank_number() which is like
the existing bank_number() but provides the index into
env->banked_r14[]; bank_number() provides the index to use
for env->banked_r13[] and env->banked_cpsr[].

All the points in the code that were using bank_number()
to index into env->banked_r14[] are updated for consintency:
 * switch_mode() -- this is the only place where we fix
   an actual bug
 * aarch64_sync_32_to_64() and aarch64_sync_64_to_32():
   no behavioural change as we already special-cased Hyp R14
 * kvm32.c: no behavioural change since the guest can't ever
   be in Hyp mode, but conceptually the right thing to do
 * msr_banked()/mrs_banked(): we can never get to the case
   that accesses banked_r14[] with tgtmode == ARM_CPU_MODE_HYP,
   so no behavioural change

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Edgar E. Iglesias <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-id: 20181109173553[email protected]

6 years agotarget/arm: Correctly implement handling of HCR_EL2.{VI, VF}
Peter Maydell [Tue, 13 Nov 2018 10:47:59 +0000 (10:47 +0000)]
target/arm: Correctly implement handling of HCR_EL2.{VI, VF}

In commit 8a0fc3a29fc2315325400 we tried to implement HCR_EL2.{VI,VF},
but we got it wrong and had to revert it.

In that commit we implemented them as simply tracking whether there
is a pending virtual IRQ or virtual FIQ. This is not correct -- these
bits cause a software-generated VIRQ/VFIQ, which is distinct from
whether there is a hardware-generated VIRQ/VFIQ caused by the
external interrupt controller. So we need to track separately
the HCR_EL2 bit state and the external virq/vfiq line state, and
OR the two together to get the actual pending VIRQ/VFIQ state.

Fixes: 8a0fc3a29fc2315325400c738f807d0d4ae0ab7f
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: 20181109134731[email protected]

6 years agotarget/arm: Track the state of our irq lines from the GIC explicitly
Peter Maydell [Tue, 13 Nov 2018 10:47:59 +0000 (10:47 +0000)]
target/arm: Track the state of our irq lines from the GIC explicitly

Currently we track the state of the four irq lines from the GIC
only via the cs->interrupt_request or KVM irq state. That means
that we assume that an interrupt is asserted if and only if the
external line is set. This assumption is incorrect for VIRQ
and VFIQ, because the HCR_EL2.{VI,VF} bits allow assertion
of VIRQ and VFIQ separately from the state of the external line.

To handle this, start tracking the state of the external lines
explicitly in a CPU state struct field, as is common practice
for devices.

The complicated part of this is dealing with inbound migration
from an older QEMU which didn't have this state. We assume in
that case that the older QEMU did not implement the HCR_EL2.{VI,VF}
bits as generating interrupts, and so the line state matches
the current state in cs->interrupt_request. (This is not quite
true between commit 8a0fc3a29fc2315325400c7 and its revert, but
that commit is broken and never made it into any released QEMU
version.)

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-id: 20181109134731[email protected]

6 years agoRevert "target/arm: Implement HCR.VI and VF"
Peter Maydell [Tue, 13 Nov 2018 10:47:59 +0000 (10:47 +0000)]
Revert "target/arm: Implement HCR.VI and VF"

This reverts commit 8a0fc3a29fc2315325400c738f807d0d4ae0ab7f.

The implementation of HCR.VI and VF in that commit is not
correct -- they do not track the overall "is there a pending
VIRQ or VFIQ" status, but whether there is a pending interrupt
due to "this mechanism", ie the hypervisor having set the VI/VF
bits. The overall pending state for VIRQ and VFIQ is effectively
the logical OR of the inbound lines from the GIC with the
VI and VF bits. Commit 8a0fc3a29fc231 would result in pending
VIRQ/VFIQ possibly being lost when the hypervisor wrote to HCR.

As a preliminary to implementing the HCR.VI/VF feature properly,
revert the broken one entirely.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-id: 20181109134731[email protected]

6 years agoarm: fix aa64_generate_debug_exceptions to work with EL2
Alex Bennée [Tue, 13 Nov 2018 10:47:59 +0000 (10:47 +0000)]
arm: fix aa64_generate_debug_exceptions to work with EL2

The test was incomplete and incorrectly caused debug exceptions to be
generated when returning to EL2 after a failed attempt to single-step
an EL1 instruction. Fix this while cleaning up the function a little.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: 20181109152119[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agoarm: use symbolic MDCR_TDE in arm_debug_target_el
Alex Bennée [Tue, 13 Nov 2018 10:47:59 +0000 (10:47 +0000)]
arm: use symbolic MDCR_TDE in arm_debug_target_el

We already have this symbol defined so lets use it.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: 20181109152119[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agotests/guest-debug: fix scoping of failcount
Alex Bennée [Tue, 13 Nov 2018 10:47:59 +0000 (10:47 +0000)]
tests/guest-debug: fix scoping of failcount

You should declare you are using a global version of a variable before
you attempt to modify it in a function.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: 20181109152119[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agotarget/arm64: kvm debug set target_el when passing exception to guest
Alex Bennée [Tue, 13 Nov 2018 10:47:59 +0000 (10:47 +0000)]
target/arm64: kvm debug set target_el when passing exception to guest

When we are debugging the guest all exceptions come our way but might
be for the guest's own debug exceptions. We use the ->do_interrupt()
infrastructure to inject the exception into the guest. However, we are
missing a full setup of the exception structure, causing an assert
later down the line.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: 20181109152119[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agotarget/arm64: hold BQL when calling do_interrupt()
Alex Bennée [Tue, 13 Nov 2018 10:47:59 +0000 (10:47 +0000)]
target/arm64: hold BQL when calling do_interrupt()

Fix the assertion failure when running interrupts.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: 20181109152119[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agotarget/arm64: properly handle DBGVR RESS bits
Alex Bennée [Tue, 13 Nov 2018 10:47:59 +0000 (10:47 +0000)]
target/arm64: properly handle DBGVR RESS bits

This only fails with some (broken) versions of gdb but we should
treat the top bits of DBGBVR as RESS. Properly sign extend QEMU's
reference copy of dbgbvr and also update the register descriptions in
the comment.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: 20181109152119[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agotarget/arm: Fix typo in tlbi_aa64_vmalle1_write
Richard Henderson [Tue, 13 Nov 2018 10:47:58 +0000 (10:47 +0000)]
target/arm: Fix typo in tlbi_aa64_vmalle1_write

This would cause an infinite recursion or loop.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-id: 20181110121711[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
6 years agohw/arm/sysbus-fdt: Only call match_fn callback if the type matches
Eric Auger [Tue, 13 Nov 2018 10:47:58 +0000 (10:47 +0000)]
hw/arm/sysbus-fdt: Only call match_fn callback if the type matches

Commit af7d64ede0b9 (hw/arm/sysbus-fdt: Allow device matching with DT
compatible value) introduced a match_fn callback which gets called
for each registered combo to check whether a sysbus device can be
dynamically instantiated. However the callback gets called even if
the device type does not match the binding combo typename field.
This causes an assert when passing "-device ramfb" to the qemu
command line as vfio_platform_match() gets called on a non
vfio-platform device.

To fix this regression, let's change the add_fdt_node() logic so
that we first check the type and if the match_fn callback is defined,
then we also call it.

Binding combos only requesting a type check do not define the
match_fn callback.

Fixes: af7d64ede0b9 (hw/arm/sysbus-fdt: Allow device matching with
DT compatible value)

Signed-off-by: Eric Auger <[email protected]>
Reported-by: Thomas Huth <[email protected]>
Reviewed-by: Alex Williamson <[email protected]>
Tested-by: Geert Uytterhoeven <[email protected]>
Message-id: 20181106184212[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agoMAINTAINERS: Add an entry for the 'collie' machine
Thomas Huth [Tue, 13 Nov 2018 10:47:58 +0000 (10:47 +0000)]
MAINTAINERS: Add an entry for the 'collie' machine

There is no active maintainer, but since Peter is picking up
patches via [email protected], I think we could at least use
"Odd Fixes" as status here.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: 1541528230[email protected]
[PMM: Also add myself as an M: contact]
Signed-off-by: Peter Maydell <[email protected]>
6 years agotarget/arm: Remove antique TODO comment
Peter Maydell [Tue, 13 Nov 2018 10:47:58 +0000 (10:47 +0000)]
target/arm: Remove antique TODO comment

Remove a TODO comment about implementing the vectored interrupt
controller. We have had an implementation of that for a decade;
it's in hw/intc/pl190.c.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: 20181106164118[email protected]
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
6 years agotarget/arm: Remove workaround for small SAU regions
Peter Maydell [Tue, 13 Nov 2018 10:47:58 +0000 (10:47 +0000)]
target/arm: Remove workaround for small SAU regions

Before we supported direct execution from MMIO regions, we
implemented workarounds in commit 720424359917887c926a33d2
which let us avoid doing so, even if the SAU or MPU region
was less than page-sized.

Once we implemented execute-from-MMIO, we removed part
of those workarounds in commit d4b6275df320cee76; but
we forgot the one in get_phys_addr_pmsav8() which
suppressed use of small SAU regions in executable regions.
Remove that workaround now.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-id: 20181106163801[email protected]

6 years agoMerge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Peter Maydell [Mon, 12 Nov 2018 17:11:22 +0000 (17:11 +0000)]
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block layer patches:

- file-posix: Don't waste a file descriptor for locking, don't lock the
  same bit multiple times
- nvme: Fix double free and memory leak
- Misc error handling fixes
- Added NULL checks found by static analysis
- Allow more block drivers to not be included in the qemu build

# gpg: Signature made Mon 12 Nov 2018 17:05:00 GMT
# gpg:                using RSA key 7F09B272C88F2FD6
# gpg: Good signature from "Kevin Wolf <[email protected]>"
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* remotes/kevin/tags/for-upstream:
  qcow2: Read outside array bounds in qcow2_pre_write_overlap_check()
  block: Fix potential Null pointer dereferences in vvfat.c
  qemu-img: assert block_job_get() does not return NULL in img_commit()
  block: Null pointer dereference in blk_root_get_parent_desc()
  job: Fix off-by-one assert checks for JobSTT and JobVerbTable
  block: Make more block drivers compile-time configurable
  tests: Add unit tests for image locking
  file-posix: Drop s->lock_fd
  file-posix: Skip effectiveless OFD lock operations
  nvme: free cmbuf in nvme_exit
  nvme: don't unref ctrl_mem when device unrealized
  blockdev: Consistently use snapshot_node_name in external_snapshot_prepare()
  blockdev: handle error on block latency histogram set error
  file-posix: Use error API properly

Signed-off-by: Peter Maydell <[email protected]>
6 years agoMerge remote-tracking branch 'mreitz/tags/pull-block-2018-11-12' into queue-block
Kevin Wolf [Mon, 12 Nov 2018 16:57:32 +0000 (17:57 +0100)]
Merge remote-tracking branch 'mreitz/tags/pull-block-2018-11-12' into queue-block

Block patches:
- Added NULL checks found by static analysis
- Allow more block drivers to not be included in the qemu build

# gpg: Signature made Mon Nov 12 17:51:18 2018 CET
# gpg:                using RSA key F407DB0061D5CF40
# gpg: Good signature from "Max Reitz <[email protected]>"
# Primary key fingerprint: 91BE B60A 30DB 3E88 57D1  1829 F407 DB00 61D5 CF40

* mreitz/tags/pull-block-2018-11-12:
  qcow2: Read outside array bounds in qcow2_pre_write_overlap_check()
  block: Fix potential Null pointer dereferences in vvfat.c
  qemu-img: assert block_job_get() does not return NULL in img_commit()
  block: Null pointer dereference in blk_root_get_parent_desc()
  job: Fix off-by-one assert checks for JobSTT and JobVerbTable
  block: Make more block drivers compile-time configurable

Signed-off-by: Kevin Wolf <[email protected]>
6 years agoqcow2: Read outside array bounds in qcow2_pre_write_overlap_check()
Liam Merwick [Mon, 5 Nov 2018 21:38:39 +0000 (21:38 +0000)]
qcow2: Read outside array bounds in qcow2_pre_write_overlap_check()

The commit for 0e4e4318eaa5 increments QCOW2_OL_MAX_BITNR but does not
add an array entry for QCOW2_OL_BITMAP_DIRECTORY_BITNR to metadata_ol_names[].
As a result, an array dereference of metadata_ol_names[8] in
qcow2_pre_write_overlap_check() could result in a read outside of the array bounds.

Fixes: 0e4e4318eaa5 ('qcow2: add overlap check for bitmap directory')
Cc: Vladimir Sementsov-Ogievskiy <[email protected]>
Signed-off-by: Liam Merwick <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Message-id: 1541453919[email protected]
Signed-off-by: Max Reitz <[email protected]>
6 years agoblock: Fix potential Null pointer dereferences in vvfat.c
Liam Merwick [Mon, 5 Nov 2018 21:38:38 +0000 (21:38 +0000)]
block: Fix potential Null pointer dereferences in vvfat.c

The calls to find_mapping_for_cluster() may return NULL but it
isn't always checked for before dereferencing the value returned.
Additionally, add some asserts to cover cases where NULL can't
be returned but which might not be obvious at first glance.

Signed-off-by: Liam Merwick <[email protected]>
Message-id: 1541453919[email protected]
[mreitz: Dropped superfluous check of "mapping" following an assertion
         that it is not NULL, and fixed some indentation]
Signed-off-by: Max Reitz <[email protected]>
6 years agoqemu-img: assert block_job_get() does not return NULL in img_commit()
Liam Merwick [Mon, 5 Nov 2018 21:38:37 +0000 (21:38 +0000)]
qemu-img: assert block_job_get() does not return NULL in img_commit()

Although the function block_job_get() can return NULL, it would be a
serious bug if it did so (because the job yields before executing anything
(if it started successfully); but otherwise, commit_active_start() would
have returned an error).  However, as a precaution, before dereferencing
the 'job' pointer in img_commit() assert it is not NULL.

Signed-off-by: Liam Merwick <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Message-id: 1541453919[email protected]
Signed-off-by: Max Reitz <[email protected]>
6 years agoblock: Null pointer dereference in blk_root_get_parent_desc()
Liam Merwick [Mon, 5 Nov 2018 21:38:36 +0000 (21:38 +0000)]
block: Null pointer dereference in blk_root_get_parent_desc()

The dev_id returned by the call to blk_get_attached_dev_id() in
blk_root_get_parent_desc() can be NULL (an internal call to
object_get_canonical_path may have returned NULL).

Instead of just checking this case before before dereferencing,
adjust blk_get_attached_dev_id() to return the empty string if no
object path can be found (similar to the case when blk->dev is NULL
and an empty string is returned).

Signed-off-by: Liam Merwick <[email protected]>
Message-id: 1541453919[email protected]
Reviewed-by: Max Reitz <[email protected]>
Signed-off-by: Max Reitz <[email protected]>
6 years agojob: Fix off-by-one assert checks for JobSTT and JobVerbTable
Liam Merwick [Mon, 5 Nov 2018 21:38:35 +0000 (21:38 +0000)]
job: Fix off-by-one assert checks for JobSTT and JobVerbTable

In the assert checking the array dereference of JobVerbTable[verb]
in job_apply_verb() the check of the index, verb, allows an overrun
because an index equal to the array size is permitted.

Similarly, in the assert check of JobSTT[s0][s1] with index s1
in job_state_transition(), an off-by-one overrun is not flagged
either.

This is not a run-time issue as there are no callers actually
passing in the max value.

Signed-off-by: Liam Merwick <[email protected]>
Reviewed-by: Darren Kenny <[email protected]>
Reviewed-by: Mark Kanda <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: John Snow <[email protected]>
Message-id: 1541453919[email protected]
Signed-off-by: Max Reitz <[email protected]>
6 years agoblock: Make more block drivers compile-time configurable
Jeff Cody [Wed, 7 Nov 2018 06:36:44 +0000 (07:36 +0100)]
block: Make more block drivers compile-time configurable

This adds configure options to control the following block drivers:

* Bochs
* Cloop
* Dmg
* Qcow (V1)
* Vdi
* Vvfat
* qed
* parallels
* sheepdog

Each of these defaults to being enabled.

Signed-off-by: Jeff Cody <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
Message-id: 20181107063644[email protected]
Signed-off-by: Max Reitz <[email protected]>
6 years agotests: Add unit tests for image locking
Fam Zheng [Thu, 11 Oct 2018 07:21:35 +0000 (15:21 +0800)]
tests: Add unit tests for image locking

Signed-off-by: Fam Zheng <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
6 years agofile-posix: Drop s->lock_fd
Fam Zheng [Thu, 11 Oct 2018 07:21:34 +0000 (15:21 +0800)]
file-posix: Drop s->lock_fd

The lock_fd field is not strictly necessary because transferring locked
bytes from old fd to the new one shouldn't fail anyway. This spares the
user one fd per image.

Signed-off-by: Fam Zheng <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
6 years agofile-posix: Skip effectiveless OFD lock operations
Fam Zheng [Thu, 11 Oct 2018 07:21:33 +0000 (15:21 +0800)]
file-posix: Skip effectiveless OFD lock operations

If we know we've already locked the bytes, don't do it again; similarly
don't unlock a byte if we haven't locked it. This doesn't change the
behavior, but fixes a corner case explained below.

Libvirt had an error handling bug that an image can get its (ownership,
file mode, SELinux) permissions changed (RHBZ 1584982) by mistake behind
QEMU. Specifically, an image in use by Libvirt VM has:

    $ ls -lhZ b.img
    -rw-r--r--. qemu qemu system_u:object_r:svirt_image_t:s0:c600,c690 b.img

Trying to attach it a second time won't work because of image locking.
And after the error, it becomes:

    $ ls -lhZ b.img
    -rw-r--r--. root root system_u:object_r:virt_image_t:s0 b.img

Then, we won't be able to do OFD lock operations with the existing fd.
In other words, the code such as in blk_detach_dev:

    blk_set_perm(blk, 0, BLK_PERM_ALL, &error_abort);

can abort() QEMU, out of environmental changes.

This patch is an easy fix to this and the change is regardlessly
reasonable, so do it.

Signed-off-by: Fam Zheng <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
6 years agonvme: free cmbuf in nvme_exit
Li Qiang [Mon, 29 Oct 2018 06:29:41 +0000 (23:29 -0700)]
nvme: free cmbuf in nvme_exit

This avoid a memory leak in unhotplug nvme device.

Signed-off-by: Li Qiang <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
6 years agonvme: don't unref ctrl_mem when device unrealized
Li Qiang [Mon, 29 Oct 2018 06:29:40 +0000 (23:29 -0700)]
nvme: don't unref ctrl_mem when device unrealized

Currently, when hotplug/unhotplug nvme device, it will cause an
assert in object.c. Following is the backtrack:

ERROR:qom/object.c:981:object_unref: assertion failed: (obj->ref > 0)

Thread 2 "qemu-system-x86" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffcbd32700 (LWP 18844)]
0x00007fffdb9e4fff in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
/lib/x86_64-linux-gnu/libglib-2.0.so.0
/lib/x86_64-linux-gnu/libglib-2.0.so.0
qom/object.c:981
/home/liqiang02/qemu-upstream/qemu/memory.c:1732
/home/liqiang02/qemu-upstream/qemu/memory.c:285
util/qemu-thread-posix.c:504
/lib/x86_64-linux-gnu/libpthread.so.0

This is caused by memory_region_unref in nvme_exit.

Remove it to make the PCIdevice refcount correct.

Signed-off-by: Li Qiang <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
6 years agoblockdev: Consistently use snapshot_node_name in external_snapshot_prepare()
Peter Maydell [Thu, 1 Nov 2018 16:30:37 +0000 (16:30 +0000)]
blockdev: Consistently use snapshot_node_name in external_snapshot_prepare()

In the function external_snapshot_prepare() we have a
BlockdevSnapshotSync struct, which has the usual combination
of has_snapshot_node_name and snapshot_node_name fields for an
optional field. We set up a local variable
        const char *snapshot_node_name =
            s->has_snapshot_node_name ? s->snapshot_node_name : NULL;

and then mostly use "if (!snapshot_node_name)" for checking
whether we have a snapshot node name. The exception is that in
one place we check s->has_snapshot_node_name instead. This
confuses Coverity (CID 1396473), which thinks it might be
possible to get here with s->has_snapshot_node_name true but
snapshot_node_name NULL, and warns that the call to
qdict_put_str() will segfault in that case.

Make the code consistent and unconfuse Coverity by using
the same check for this conditional that we do in the rest
of the surrounding code.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alberto Garcia <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
6 years agoblockdev: handle error on block latency histogram set error
zhenwei pi [Mon, 5 Nov 2018 03:04:56 +0000 (11:04 +0800)]
blockdev: handle error on block latency histogram set error

Function block_latency_histogram_set may return error, but qapi ignore this.
This can be reproduced easily by qmp command:
virsh qemu-monitor-command INSTANCE '{"execute":"x-block-latency-histogram-set",
"arguments":{"device":"drive-virtio-disk1","boundaries":[10,200,40]}}'
In fact this command does not work, but we still get success result.

qmp_x_block_latency_histogram_set is a batch setting API, report error ASAP.

Signed-off-by: zhenwei pi <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
6 years agofile-posix: Use error API properly
Fam Zheng [Thu, 1 Nov 2018 06:29:09 +0000 (14:29 +0800)]
file-posix: Use error API properly

Use error_report for situations that affect user operation (i.e.  we're
actually returning error), and warn_report/warn_report_err when some
less critical error happened but the user operation can still carry on.

For raw_normalize_devicepath, add Error parameter to propagate to
its callers.

Suggested-by: Markus Armbruster <[email protected]>
Signed-off-by: Fam Zheng <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
6 years agoMerge remote-tracking branch 'remotes/kraxel/tags/fixes-31-20181112-pull-request...
Peter Maydell [Mon, 12 Nov 2018 15:55:40 +0000 (15:55 +0000)]
Merge remote-tracking branch 'remotes/kraxel/tags/fixes-31-20181112-pull-request' into staging

fixes for 3.1: mark bt as deprecated, bugfixes for pulse, gtk and edid.

# gpg: Signature made Mon 12 Nov 2018 15:14:58 GMT
# gpg:                using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <[email protected]>"
# gpg:                 aka "Gerd Hoffmann <[email protected]>"
# gpg:                 aka "Gerd Hoffmann (private) <[email protected]>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/fixes-31-20181112-pull-request:
  ui/gtk: fix cursor in egl mode
  pulseaudio: process audio data in smaller chunks
  edid: silence a stringop-overflow warning
  bt: Mark the bluetooth subsystem as deprecated

Signed-off-by: Peter Maydell <[email protected]>
6 years agolinux-user: Add support for SO_REUSEPORT
Yunqiang Su [Tue, 30 Oct 2018 12:55:08 +0000 (13:55 +0100)]
linux-user: Add support for SO_REUSEPORT

Add support for SO_REUSEPORT, including strace support. SO_REUSEPORT
was introduced relatively recently, since Linux 3.9, so use
'#if defined SO_REUSEPORT'.

Signed-off-by: Yunqiang Su <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Message-Id: <1540904108[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
6 years agohw/acpi/nvdimm: Don't take address of fields in packed structs
Peter Maydell [Tue, 16 Oct 2018 17:52:36 +0000 (18:52 +0100)]
hw/acpi/nvdimm: Don't take address of fields in packed structs

Taking the address of a field in a packed struct is a bad idea, because
it might not be actually aligned enough for that pointer type (and
thus cause a crash on dereference on some host architectures). Newer
versions of clang warn about this. Avoid the bug by not using the
"modify in place" byte swapping functions.

Patch produced with scripts/coccinelle/inplace-byteswaps.cocci.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Message-id: 20181016175236[email protected]

6 years agolinux-user: Clean up nios2 main loop signal handling
Peter Maydell [Fri, 19 Oct 2018 17:49:58 +0000 (18:49 +0100)]
linux-user: Clean up nios2 main loop signal handling

The nios2 main loop code's code does some odd
things with gdb_handlesig() that no other target
CPU does: it has some signals that are delivered
to gdb and only to gdb. Stop doing this, and instead
behave like all the other targets:
 * a trap instruction becomes a SIGTRAP
 * an unhandled exception type returned from cpu_exec()
   causes us to abort(), not to try to hand gdb a SIGILL

This fixes in passing Coverity issue CID 1390853,
which was a complaint that the old code failed to
check the return value from gdb_handlesig().

Signed-off-by: Peter Maydell <[email protected]>
Message-Id: <20181019174958[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
[lv: removed gdbsig unused variable]
Signed-off-by: Laurent Vivier <[email protected]>
6 years agolinux-user: Don't call gdb_handlesig() before queue_signal()
Peter Maydell [Fri, 19 Oct 2018 17:49:57 +0000 (18:49 +0100)]
linux-user: Don't call gdb_handlesig() before queue_signal()

The CPU main-loop routines for linux-user generally
call gdb_handlesig() when they're about to queue a
SIGTRAP signal. This is wrong, because queue_signal()
will cause us to pend a signal, and process_pending_signals()
will then call gdb_handlesig() itself. So the effect is that
we notify gdb of the SIGTRAP, and then if gdb says "OK,
continue with signal X" we will incorrectly notify
gdb of the signal X as well. We don't do this double-notify
for anything else, only SIGTRAP.

Remove this unnecessary and incorrect code from all
the targets except for nios2 (whose main loop is
doing something different and broken, and will be handled
in a separate patch).

This bug only manifests if the user responds to the reported
SIGTRAP using "signal SIGFOO" rather than "continue"; since
the latter is the overwhelmingly common thing to do after a
breakpoint most people won't have hit this.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20181019174958[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
6 years agolinux-user: Remove dead error-checking code
Peter Maydell [Fri, 19 Oct 2018 16:17:15 +0000 (17:17 +0100)]
linux-user: Remove dead error-checking code

Remove some dead code spotted by Coverity (CID 1009855,
13908541390847). The underlying cause in all these cases
is the same: QEMU's put_user operations can't result in
errors, but the kernel's equivalent does. So when code
was copied from the kernel signal-frame-setup/teardown
code, checks on error flags that were needed in the kernel
became dead code for us.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Message-Id: <20181019161715[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
6 years agoui/gtk: fix cursor in egl mode
Gerd Hoffmann [Wed, 7 Nov 2018 07:49:49 +0000 (08:49 +0100)]
ui/gtk: fix cursor in egl mode

In egl mode the scale_x and scale_y variables are not set, so the
scaling logic in the mouse motion event handler does not work.

Fix that.  Also scale the cursor position in gd_egl_cursor_position().

Reported-by: Chen Zhang <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Tested-by: Chen Zhang <[email protected]>
Message-id: 20181107074949[email protected]

6 years agopulseaudio: process audio data in smaller chunks
Gerd Hoffmann [Fri, 9 Nov 2018 14:20:32 +0000 (15:20 +0100)]
pulseaudio: process audio data in smaller chunks

The rate of pulseaudio absorbing the audio stream is used to control the
the rate of the guests audio stream.  When the emulated hardware uses
small chunks (like intel-hda does) we need small chunks on the audio
backend side too, otherwise that feedback loop doesn't work very well.

Cc: Max Ehrlich <[email protected]>
Cc: Martin Schrodt <[email protected]>
Buglink: https://bugs.launchpad.net/bugs/1795527
Signed-off-by: Gerd Hoffmann <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: 20181109142032[email protected]

6 years agoedid: silence a stringop-overflow warning
Marc-André Lureau [Sat, 10 Nov 2018 11:16:23 +0000 (15:16 +0400)]
edid: silence a stringop-overflow warning

Simplify the code that doesn't need strncpy() since length of string
is already computed.

/home/elmarco/src/qemu/hw/display/edid-generate.c: In function 'edid_desc_text':
/home/elmarco/src/qemu/hw/display/edid-generate.c:168:5: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
     strncpy((char *)(desc + 5), text, len);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/elmarco/src/qemu/hw/display/edid-generate.c:164:11: note: length computed here
     len = strlen(text);
           ^~~~~~~~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Message-id: 20181110111623[email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
6 years agobt: Mark the bluetooth subsystem as deprecated
Thomas Huth [Mon, 12 Nov 2018 10:00:30 +0000 (11:00 +0100)]
bt: Mark the bluetooth subsystem as deprecated

It has been unmaintained since years, and there were only trivial or
tree-wide changes to the related files since many years, so the
code is likely very bitrotten and broken. For example the following
segfaults as soon as as you press a key:

 qemu-system-x86_64 -usb -device usb-bt-dongle -bt hci -bt device:keyboard

Since we are not aware of anybody using bluetooth with the current
version of QEMU, let's mark the subsystem as deprecated, with a special
request for the users to write to the qemu-devel mailing list in case
they still use it (so we could revert the deprecation status in that
case).

Signed-off-by: Thomas Huth <[email protected]>
Message-id: 1542016830[email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
6 years agodocker: use HTTPS git URL for virglrenderer
Stefan Hajnoczi [Thu, 8 Nov 2018 11:15:31 +0000 (11:15 +0000)]
docker: use HTTPS git URL for virglrenderer

When you clone the repository without previous commit history, 'git://'
doesn't protect from man-in-the-middle attacks.  HTTPS is more secure
since the client verifies the server certificate.

Cc: Philippe Mathieu-Daudé <[email protected]>
Suggested-by: Eric Blake <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Tested-by: Alex Bennée <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Message-id: 20181108111531[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agotarget-alpha: use HTTPS git URL for palcode
Stefan Hajnoczi [Thu, 8 Nov 2018 11:15:30 +0000 (11:15 +0000)]
target-alpha: use HTTPS git URL for palcode

When you clone the repository without previous commit history, 'git://'
doesn't protect from man-in-the-middle attacks.  HTTPS is more secure
since the client verifies the server certificate.

Cc: Richard Henderson <[email protected]>
Suggested-by: Eric Blake <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Acked-by: Richard Henderson <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-id: 20181108111531[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agopc-testdev: use HTTPS git URL
Stefan Hajnoczi [Thu, 8 Nov 2018 11:15:29 +0000 (11:15 +0000)]
pc-testdev: use HTTPS git URL

When you clone the repository without previous commit history, 'git://'
doesn't protect from man-in-the-middle attacks.  HTTPS is more secure
since the client verifies the server certificate.

Cc: Paolo Bonzini <[email protected]>
Suggested-by: Eric Blake <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-id: 20181108111531[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agogit: use HTTPS git URLs for repo.or.cz
Stefan Hajnoczi [Thu, 8 Nov 2018 11:15:28 +0000 (11:15 +0000)]
git: use HTTPS git URLs for repo.or.cz

When you clone the repository without previous commit history, 'git://'
doesn't protect from man-in-the-middle attacks.  HTTPS is more secure
since the client verifies the server certificate.

Suggested-by: Eric Blake <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: 20181108111531[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agogitmodules: use 'https://' instead of 'git://'
Stefan Hajnoczi [Thu, 8 Nov 2018 11:15:27 +0000 (11:15 +0000)]
gitmodules: use 'https://' instead of 'git://'

When you clone the repository without previous commit history, 'git://'
doesn't protect from man-in-the-middle attacks.  HTTPS is more secure
since the client verifies the server certificate.

Also change git.qemu-project.org to git.qemu.org (we control both domain
names but qemu.org is used more widely).

Reported-by: Jann Horn <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: 20181108111531[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agoMAINTAINERS: use 'https://' instead of 'git://' for GitHub
Stefan Hajnoczi [Thu, 8 Nov 2018 11:15:26 +0000 (11:15 +0000)]
MAINTAINERS: use 'https://' instead of 'git://' for GitHub

When you clone the repository without previous commit history, 'git://'
doesn't protect from man-in-the-middle attacks.  HTTPS is more secure
since the client verifies the server certificate.

Reported-by: Jann Horn <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Acked-by: Cornelia Huck <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: 20181108111531[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agoget_maintainer: use 'https://' instead of 'git://'
Stefan Hajnoczi [Thu, 8 Nov 2018 11:15:25 +0000 (11:15 +0000)]
get_maintainer: use 'https://' instead of 'git://'

When you clone the repository without previous commit history, 'git://'
doesn't protect from man-in-the-middle attacks.  HTTPS is more secure
since the client verifies the server certificate.

Reported-by: Jann Horn <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-id: 20181108111531[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agoREADME: use 'https://' instead of 'git://'
Stefan Hajnoczi [Thu, 8 Nov 2018 11:15:24 +0000 (11:15 +0000)]
README: use 'https://' instead of 'git://'

When you clone the repository without previous commit history, 'git://'
doesn't protect from man-in-the-middle attacks.  HTTPS is more secure
since the client verifies the server certificate.

Reported-by: Jann Horn <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Message-id: 20181108111531[email protected]
Signed-off-by: Peter Maydell <[email protected]>
6 years agoMerge remote-tracking branch 'remotes/thibault/tags/samuel-thibault' into staging
Peter Maydell [Mon, 12 Nov 2018 10:12:07 +0000 (10:12 +0000)]
Merge remote-tracking branch 'remotes/thibault/tags/samuel-thibault' into staging

slirp updates

Peter Maydell (4):
  slirp: Don't pass possibly -1 fd to send()
  slirp: Use g_new() to allocate sockets in socreate()
  slirp: Remove code that handles socreate() failure
  slirp: fork_exec(): create and connect child socket before fork()

# gpg: Signature made Sat 10 Nov 2018 14:08:53 GMT
# gpg:                using RSA key E3F65A9E9560DB4C
# gpg: Good signature from "Samuel Thibault <[email protected]>"
# gpg:                 aka "Samuel Thibault <[email protected]>"
# gpg:                 aka "Samuel Thibault <[email protected]>"
# gpg:                 aka "Samuel Thibault <[email protected]>"
# gpg:                 aka "Samuel Thibault <[email protected]>"
# gpg:                 aka "Samuel Thibault <[email protected]>"
# gpg:                 aka "Samuel Thibault <[email protected]>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 900C B024 B679 31D4 0F82  304B D017 8C76 7D06 9EE6
#      Subkey fingerprint: 33FA 7B64 6195 01F8 CE9C  8F97 E3F6 5A9E 9560 DB4C

* remotes/thibault/tags/samuel-thibault:
  slirp: fork_exec(): create and connect child socket before fork()
  slirp: Remove code that handles socreate() failure
  slirp: Use g_new() to allocate sockets in socreate()
  slirp: Don't pass possibly -1 fd to send()

Signed-off-by: Peter Maydell <[email protected]>
6 years agoslirp: fork_exec(): create and connect child socket before fork()
Peter Maydell [Tue, 6 Nov 2018 15:13:23 +0000 (15:13 +0000)]
slirp: fork_exec(): create and connect child socket before fork()

Currently fork_exec() fork()s, and then creates and connects the
child socket which it uses for communication with the parent in
the child process. This is awkward because the child has no
mechanism to report failure back to the parent, which might end
up blocked forever in accept(). The child code also has an issue
pointed out by Coverity (CID 1005727), where if the qemu_socket()
call fails it will pass -1 as a file descriptor to connect().

Fix these issues by moving the creation of the child's end of
the socket to before the fork(), where we are in a position to
handle a possible failure.

Signed-off-by: Peter Maydell <[email protected]>
Signed-off-by: Samuel Thibault <[email protected]>
6 years agoslirp: Remove code that handles socreate() failure
Peter Maydell [Tue, 6 Nov 2018 15:13:22 +0000 (15:13 +0000)]
slirp: Remove code that handles socreate() failure

Now that socreate() can never fail, we can remove the code
that was trying to handle that situation.

In particular this removes code in tcp_connect() that
provoked Coverity to complain (CID 1005724): in
 closesocket(accept(inso->s, (struct sockaddr *)&addr, &addrlen));
if the accept() call fails then we pass closesocket() -1
instead of a valid file descriptor.

Signed-off-by: Peter Maydell <[email protected]>
Signed-off-by: Samuel Thibault <[email protected]>
6 years agoslirp: Use g_new() to allocate sockets in socreate()
Peter Maydell [Tue, 6 Nov 2018 15:13:21 +0000 (15:13 +0000)]
slirp: Use g_new() to allocate sockets in socreate()

The slirp socreate() function can only fail if the attempt
to malloc() the struct socket fails. Switch to using
g_new() instead, which will allow us to remove the
error-handling code from its callers.

Signed-off-by: Peter Maydell <[email protected]>
Signed-off-by: Samuel Thibault <[email protected]>
6 years agoslirp: Don't pass possibly -1 fd to send()
Peter Maydell [Tue, 6 Nov 2018 15:13:20 +0000 (15:13 +0000)]
slirp: Don't pass possibly -1 fd to send()

Coverity complains (CID 1005726) that we might pass -1 as the fd
argument to send() in slirp_send(), because we previously checked for
"so->s == -1 && so->extra".  The case of "so->s == -1 but so->extra
NULL" should not in theory happen, but it is hard to guarantee
because various places in the code do so->s = qemu_socket(...) and so
will end up with so->s == -1 on failure, and not all the paths which
call that always throw away the socket in that case (eg
tcp_fconnect()).  So just check specifically for the condition and
fail slirp_send().

Signed-off-by: Peter Maydell <[email protected]>
Signed-off-by: Samuel Thibault <[email protected]>
6 years agoqga: Add multiple include guard to guest-agent-core.h
Peter Maydell [Thu, 8 Nov 2018 12:52:23 +0000 (12:52 +0000)]
qga: Add multiple include guard to guest-agent-core.h

The guest-agent-core.h header was missing the usual guards
against multiple inclusion; add them.

(Spotted by lgtm.com's static analyzer.)

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Michael Roth <[email protected]>
6 years agoqga-win: fix leaks of build_guest_disk_info()
Marc-André Lureau [Sat, 3 Nov 2018 13:01:43 +0000 (17:01 +0400)]
qga-win: fix leaks of build_guest_disk_info()

Introduced in commit b1ba8890e63ce9432c41c5c3fc229f54c87c9c99, vol_h
handle should be closed, and "out" cleanup should be done after
DeviceIoControl() fails.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Michael Roth <[email protected]>
6 years agoMerge remote-tracking branch 'remotes/gkurz/tags/for-upstream' into staging
Peter Maydell [Fri, 9 Nov 2018 10:54:10 +0000 (10:54 +0000)]
Merge remote-tracking branch 'remotes/gkurz/tags/for-upstream' into staging

Fixes a potential use-after-free issue that could be triggered by a
misbehaving guest.

# gpg: Signature made Thu 08 Nov 2018 20:36:48 GMT
# gpg:                using RSA key 71D4D5E5822F73D6
# gpg: Good signature from "Greg Kurz <[email protected]>"
# gpg:                 aka "Gregory Kurz <[email protected]>"
# gpg:                 aka "[jpeg image of size 3330]"
# Primary key fingerprint: B482 8BAF 9431 40CE F2A3  4910 71D4 D5E5 822F 73D6

* remotes/gkurz/tags/for-upstream:
  9p: write lock path in v9fs_co_open2()

Signed-off-by: Peter Maydell <[email protected]>
6 years ago9p: write lock path in v9fs_co_open2()
Greg Kurz [Wed, 7 Nov 2018 00:00:04 +0000 (01:00 +0100)]
9p: write lock path in v9fs_co_open2()

The assumption that the fid cannot be used by any other operation is
wrong. At least, nothing prevents a misbehaving client to create a
file with a given fid, and to pass this fid to some other operation
at the same time (ie, without waiting for the response to the creation
request). The call to v9fs_path_copy() performed by the worker thread
after the file was created can race with any access to the fid path
performed by some other thread. This causes use-after-free issues that
can be detected by ASAN with a custom 9p client.

Unlike other operations that only read the fid path, v9fs_co_open2()
does modify it. It should hence take the write lock.

Cc: P J P <[email protected]>
Reported-by: zhibin hu <[email protected]>
Signed-off-by: Greg Kurz <[email protected]>
6 years agoMerge remote-tracking branch 'remotes/riscv/tags/riscv-for-master-3.1-rc1' into staging
Peter Maydell [Thu, 8 Nov 2018 18:37:29 +0000 (18:37 +0000)]
Merge remote-tracking branch 'remotes/riscv/tags/riscv-for-master-3.1-rc1' into staging

A Single RISC-V Patch for 3.1-rc1

This tag contains a single patch that I'd like to target for rc1: a fix
for a memory leak that was detected by static code analysis.

There are still three patch sets that I'd like to try to get up for 3.1:

* The patch set Basian just published that contains fixes for a pair of
  issues he found when converting our port to decodetree.
* An as-of-yet-unwritten fix to the third issue that Basian pointed out.
* A fix to our fflags bug, which is currently coupled to some CSR
  refactoring that I don't think is OK for 3.1.

I'm at Plumbers next week (and I think Alistair is there too?), but I'll
try to find a way to squeeze in as much as possible.

# gpg: Signature made Thu 08 Nov 2018 16:50:27 GMT
# gpg:                using RSA key EF4CA1502CCBAB41
# gpg: Good signature from "Palmer Dabbelt <[email protected]>"
# gpg:                 aka "Palmer Dabbelt <[email protected]>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 00CE 76D1 8349 60DF CE88  6DF8 EF4C A150 2CCB AB41

* remotes/riscv/tags/riscv-for-master-3.1-rc1:
  riscv: spike: Fix memory leak in the board init

Signed-off-by: Peter Maydell <[email protected]>
6 years agoriscv: spike: Fix memory leak in the board init
Alistair Francis [Mon, 5 Nov 2018 19:44:41 +0000 (19:44 +0000)]
riscv: spike: Fix memory leak in the board init

Coverity caught a malloc() call that was never freed. This patch ensures
that we free the memory but also updates the allocation to use
g_strdup_printf() instead of malloc().

Signed-off-by: Alistair Francis <[email protected]>
Suggested-by: Peter Maydell <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Palmer Dabbelt <[email protected]>
Signed-off-by: Palmer Dabbelt <[email protected]>
This page took 0.104162 seconds and 4 git commands to generate.