Huge miscellaneous pull request for 2020-06-11
Subsystems (2)
The following changes since commit 31d321c2b3574dcc74e9f6411af06bca6b5d10f4:
Merge remote-tracking branch 'remotes/philmd-gitlab/tags/sparc-next-20200609' into staging (2020-06-09 17:29:47 +0100)
are available in the Git repository at:
git://github.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to d3ffb42f3fbe24c29a2bd7806dab1dd521b4d59c:
target/i386: Remove obsolete TODO file (2020-06-11 14:08:59 -0400)
----------------------------------------------------------------
* Miscellaneous fixes and feature enablement (many)
* SEV refactoring (David)
* Hyper-V initial support (Jon)
* i386 TCG fixes (x87 and SSE, Joseph)
* vmport cleanup and improvements (Philippe, Liran)
* Use-after-free with vCPU hot-unplug (Nengyuan)
* run-coverity-scan improvements (myself)
* Record/replay fixes (Pavel)
* -machine kernel_irqchip=split improvements for INTx (Peter)
* Code cleanups (Philippe)
* Crash and security fixes (PJP)
* HVF cleanups (Roman)
----------------------------------------------------------------
Anthony PERARD (1):
xen: fix build without pci passthrough
Babu Moger (1):
target/i386: Fix the CPUID leaf CPUID_Fn80000008
Cathy Zhang (1):
x86/cpu: Enable AVX512_VP2INTERSECT cpu feature
Cédric Le Goater (1):
qom/object: Fix object_child_foreach_recursive() return value
David Carlier (1):
util/oslib: Returns the real thread identifier on FreeBSD and NetBSD
David Gibson (9):
target/i386: sev: Remove unused QSevGuestInfoClass target/i386: sev: Move local structure definitions into .c file target/i386: sev: Rename QSevGuestInfo
target/i386: sev: Embed SEVState in SevGuestState target/i386: sev: Partial cleanup to sev_state global target/i386: sev: Remove redundant cbitpos and reduced_phys_bits fields target/i386: sev: Remove redundant policy field target/i386: sev: Remove redundant handle field target/i386: sev: Unify SEVState and SevGuestState
Edgar E. Iglesias (1):
tests: machine-none-test: Enable MicroBlaze testing
Igor Mammedov (2):
vl.c: run preconfig loop before creating default RAM backend
numa: prevent usage of -M memory-backend and -numa memdev at the same time
Janne Grunau (1):
target/i386: fix phadd* with identical destination and source register
Jon Doron (6):
hyperv: expose API to determine if synic is enabled
vmbus: add vmbus protocol definitions
vmbus: vmbus implementation
i386:pc: whitelist dynamic vmbus-bridge
i386: Hyper-V VMBus ACPI DSDT entry
vmbus: add infrastructure to save/load vmbus requests
Joseph Myers (12):
target/i386: implement special cases for fxtract target/i386: fix fscale handling of signaling NaN target/i386: fix fscale handling of invalid exponent encodings target/i386: fix fscale handling of infinite exponents target/i386: fix fscale handling of rounding precision target/i386: fix floating-point load-constant rounding target/i386: fix fxam handling of invalid encodings target/i386: fix fbstp handling of negative zero target/i386: fix fbstp handling of out-of-range values target/i386: fix fisttpl, fisttpll handling of out-of-range values target/i386: fix IEEE x87 floating-point exception raising target/i386: correct fix for pcmpxstrx substring search
Julio Faracco (1):
i386: Remove unused define's from hax and hvf
Leonid Bloch (1):
configure: Do not ignore malloc value
Like Xu (1):
target/i386: define a new MSR based feature word - FEAT_PERF_CAPABILITIES
Liran Alon (14):
hw/i386/vmport: Add reference to VMware open-vm-tools hw/i386/vmport: Add device properties
hw/i386/vmport: Propagate IOPort read to vCPU EAX register hw/i386/vmport: Set EAX to -1 on failed and unsupported commands hw/i386/vmport: Introduce vmware-vmx-version property hw/i386/vmport: Report vmware-vmx-type in CMD_GETVERSION hw/i386/vmport: Introduce vmport.h
hw/i386/vmport: Define enum for all commands hw/i386/vmport: Add support for CMD_GETBIOSUUID hw/i386/vmport: Add support for CMD_GET_VCPU_INFO hw/i386/vmport: Allow x2apic without IR
i386/cpu: Store LAPIC bus frequency in CPU structure hw/i386/vmport: Add support for CMD_GETHZ
hw/i386/vmport: Assert vmport initialized before registering commands
Markus Armbruster (1):
cpus: Fix botched configure_icount() error API violation fix
Masahiro Yamada (5):
qom: remove index from object_resolve_abs_path() qom/object: factor out the initialization of hash table of properties qom/object: simplify type_initialize_interface() qom/object: pass (Object *) to object_initialize_with_type() qom/container: remove .instance_size initializer from container_info
Michael S. Tsirkin (1):
checkpatch: reversed logic with acpi test checks
Pan Nengyuan (1):
i386/kvm: fix a use-after-free when vcpu plug/unplug
Paolo Bonzini (9):
docker.py/build: support -t and -f arguments
docker.py/build: support binary files in --extra-files
run-coverity-scan: get Coverity token and email from special git config section
run-coverity-scan: use docker.py
run-coverity-scan: add --no-update-tools option
run-coverity-scan: use --no-update-tools in docker run
run-coverity-scan: download tools outside the container
run-coverity-scan: support --update-tools-only --docker
stubs: move Xen stubs to accel/
Pavel Dovgaluk (3):
icount: fix shift=auto for record/replay
replay: implement fair mutex
replay: fix replay shutdown for console mode
Peter Xu (3):
vfio/pci: Use kvm_irqchip_add_irqfd_notifier_gsi() for irqfds
KVM: Pass EventNotifier into kvm_irqchip_assign_irqfd
KVM: Kick resamplefd for split kernel irqchip
Philippe Mathieu-Daudé (19):
target/i386: Fix OUTL debug output
qom/object: Move Object typedef to 'qemu/typedefs.h' io/task: Move 'qom/object.h' header to source
Makefile: Let the 'help' target list the helper targets
accel: Move Xen accelerator code under accel/xen/
exec: Let address_space_read/write_cached() propagate MemTxResult
exec: Propagate cpu_memory_rw_debug() error
disas: Let disas::read_memory() handler return EIO on error hw/elf_ops: Do not ignore write failures when loading ELF hw/i386/vmport: Allow QTest use without crashing
memory: Make 'info mtree' not display disabled regions by default qemu/thread: Mark qemu_thread_exit() with 'noreturn' attribute sysemu/accel: Restrict machine methods to system-mode sysemu/tcg: Only declare tcg_allowed when TCG is available sysemu/hvf: Only declare hvf_allowed when HVF is available target/ppc: Restrict PPCVirtualHypervisorClass to system-mode exec/memory: Remove unused MemoryRegionMmio type
hw/usb: Move device-specific declarations to new 'hcd-musb.h' header exec/cpu-common: Move MUSB specific typedefs to 'hw/usb/hcd-musb.h'
Prasad J Pandit (4):
megasas: use unsigned type for reply_queue_head and check index
megasas: avoid NULL pointer dereference
megasas: use unsigned type for positive numeric fields
exec: set map length to zero when returning NULL
Roman Bolshakov (12):
i386: hvf: Move HVFState definition into hvf
i386: hvf: Drop useless declarations in sysemu
i386: hvf: Drop unused variable
i386: hvf: Use ins_len to advance IP
i386: hvf: Use IP from CPUX86State
i386: hvf: Drop fetch_rip from HVFX86EmulatorState
i386: hvf: Drop rflags from HVFX86EmulatorState
i386: hvf: Drop copy of RFLAGS defines
i386: hvf: Drop regs in HVFX86EmulatorState
i386: hvf: Move lazy_flags into CPUX86State
i386: hvf: Move mmio_buf into CPUX86State
i386: hvf: Drop HVFX86EmulatorState
Sai Pavan Boddu (1):
chardev/char-socket: Properly make qio connections non blocking
Thomas Huth (1):
target/i386: Remove obsolete TODO file
WangBowen (1):
hax: Dynamic allocate vcpu state structure
Wei Huang (1):
hw/i386/amd_iommu: Fix the reserved bits definition of IOMMU commands
MAINTAINERS | 2 + Makefile | 9 +- Makefile.objs | 1 + accel/Makefile.objs | 1 + accel/kvm/kvm-all.c | 95 +- accel/kvm/trace-events | 1 + accel/stubs/Makefile.objs | 1 + stubs/xen-hvm.c => accel/stubs/xen-stub.c | 23 +- accel/xen/Makefile.objs | 1 + hw/xen/xen-common.c => accel/xen/xen-all.c | 12 +- chardev/char-socket.c | 4 +- configure | 25 +- cpus.c | 26 +- disas.c | 13 +- exec.c | 29 +- hmp-commands-info.hx | 7 +- hw/Makefile.objs | 2 +- hw/acpi/piix4.c | 2 +- hw/block/vhost-user-blk.c | 1 - hw/core/machine.c | 4 + hw/core/numa.c | 5 + hw/hyperv/Kconfig | 5 + hw/hyperv/Makefile.objs | 1 + hw/hyperv/hyperv.c | 8 + hw/hyperv/trace-events | 18 + hw/hyperv/vmbus.c | 2778 ++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 43 + hw/i386/amd_iommu.c | 19 +- hw/i386/pc.c | 3 +- hw/i386/pc_piix.c | 5 +- hw/i386/pc_q35.c | 3 + hw/i386/vmmouse.c | 20 +- hw/i386/vmport.c | 183 +- hw/i386/vmport.h | 34 - hw/i386/xen/xen-hvm.c | 1 + hw/i386/xen/xen_platform.c | 1 + hw/intc/ioapic.c | 19 + hw/isa/piix3.c | 1 + hw/pci-host/pam.c | 1 - hw/pci/msix.c | 1 + hw/scsi/megasas.c | 44 +- hw/scsi/vhost-user-scsi.c | 1 - hw/usb/hcd-musb.c | 5 +- hw/usb/tusb6010.c | 1 + hw/vfio/pci.c | 37 +- hw/xen/Makefile.objs | 3 +- hw/xen/xen_pt.c | 12 +- hw/xen/xen_pt.h | 6 +- hw/xen/xen_pt_stub.c | 22 + include/exec/cpu-all.h | 1 + include/exec/cpu-common.h | 3 - include/exec/memory.h | 30 +- include/exec/ram_addr.h | 2 +- include/hw/display/edid.h | 3 - include/hw/elf_ops.h | 11 +- include/hw/hyperv/hyperv.h | 1 + include/hw/hyperv/vmbus-bridge.h | 35 + include/hw/hyperv/vmbus-proto.h | 222 +++ include/hw/hyperv/vmbus.h | 230 +++ include/hw/i386/vmport.h | 28 + include/hw/usb.h | 30 - include/hw/usb/hcd-musb.h | 47 + include/hw/xen/xen.h | 11 - include/io/task.h | 2 - include/qemu/thread.h | 2 +- include/qemu/typedefs.h | 2 +- include/qom/object.h | 2 - include/qom/qom-qobject.h | 2 - include/sysemu/accel.h | 2 + include/sysemu/hvf.h | 72 +- include/sysemu/kvm.h | 4 + include/sysemu/sysemu.h | 1 - include/sysemu/tcg.h | 2 +- include/sysemu/xen.h | 38 + io/task.c | 1 + memory.c | 75 +- migration/savevm.c | 2 +- monitor/misc.c | 3 +- qom/container.c | 1 - qom/object.c | 39 +- replay/replay-internal.c | 15 +- replay/replay.c | 5 + scripts/checkpatch.pl | 2 +- scripts/coverity-scan/coverity-scan.docker | 3 +- scripts/coverity-scan/run-coverity-scan | 139 +- softmmu/vl.c | 7 +- stubs/Makefile.objs | 2 - stubs/qmp_memory_device.c | 1 - stubs/xen-common.c | 13 - target/i386/TODO | 31 - target/i386/cpu.c | 42 +- target/i386/cpu.h | 11 +- target/i386/fpu_helper.c | 258 ++- target/i386/hax-all.c | 25 +- target/i386/hax-i386.h | 7 +- target/i386/hvf/hvf-i386.h | 37 +- target/i386/hvf/hvf.c | 30 +- target/i386/hvf/x86.c | 2 +- target/i386/hvf/x86.h | 89 +- target/i386/hvf/x86_decode.c | 25 +- target/i386/hvf/x86_emu.c | 122 +- target/i386/hvf/x86_flags.c | 81 +- target/i386/hvf/x86_task.c | 10 +- target/i386/hvf/x86hvf.c | 6 +- target/i386/kvm.c | 34 +- target/i386/misc_helper.c | 2 +- target/i386/ops_sse.h | 57 +- target/i386/sev.c | 257 +-- target/i386/sev_i386.h | 49 - target/ppc/cpu.h | 4 +- target/ppc/kvm_ppc.h | 22 +- target/ppc/translate_init.inc.c | 4 + tests/docker/Makefile.include | 2 +- tests/docker/docker.py | 14 +- tests/qtest/machine-none-test.c | 10 +- tests/tcg/i386/Makefile.target | 3 + tests/tcg/i386/test-i386-fbstp.c | 140 ++ tests/tcg/i386/test-i386-fisttp.c | 100 + tests/tcg/i386/test-i386-fldcst.c | 199 ++ tests/tcg/i386/test-i386-fp-exceptions.c | 831 +++++++++ tests/tcg/i386/test-i386-fscale.c | 108 ++ tests/tcg/i386/test-i386-fxam.c | 143 ++ tests/tcg/i386/test-i386-fxtract.c | 120 ++ tests/tcg/i386/test-i386-pcmpistri.c | 33 + tests/test-io-task.c | 1 + util/oslib-posix.c | 9 + 126 files changed, 6575 insertions(+), 973 deletions(-) rename stubs/xen-hvm.c => accel/stubs/xen-stub.c (63%) create mode 100644 accel/xen/Makefile.objs rename hw/xen/xen-common.c => accel/xen/xen-all.c (96%) create mode 100644 hw/hyperv/trace-events create mode 100644 hw/hyperv/vmbus.c delete mode 100644 hw/i386/vmport.h create mode 100644 hw/xen/xen_pt_stub.c create mode 100644 include/hw/hyperv/vmbus-bridge.h create mode 100644 include/hw/hyperv/vmbus-proto.h create mode 100644 include/hw/hyperv/vmbus.h create mode 100644 include/hw/i386/vmport.h create mode 100644 include/hw/usb/hcd-musb.h create mode 100644 include/sysemu/xen.h delete mode 100644 stubs/xen-common.c delete mode 100644 target/i386/TODO create mode 100644 tests/tcg/i386/test-i386-fbstp.c create mode 100644 tests/tcg/i386/test-i386-fisttp.c create mode 100644 tests/tcg/i386/test-i386-fldcst.c create mode 100644 tests/tcg/i386/test-i386-fp-exceptions.c create mode 100644 tests/tcg/i386/test-i386-fscale.c create mode 100644 tests/tcg/i386/test-i386-fxam.c create mode 100644 tests/tcg/i386/test-i386-fxtract.c create mode 100644 tests/tcg/i386/test-i386-pcmpistri.c
Signature · 1 line
2.26.2
[PULL 004/115] run-coverity-scan: use docker.py
Our trusted docker wrapper allows run-coverity-scan to run with both docker and podman.
For the "run" phase this is transparent; for the "build" phase however scripts are replaced with a bind mount (-v). This is not an issue because the secret option is meant for secrets stored globally in the system and bind mounts are a valid substitute for secrets that are known to whoever builds the container.
--- scripts/coverity-scan/coverity-scan.docker | 2 +- scripts/coverity-scan/run-coverity-scan | 32 ++++++++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-)
scripts/coverity-scan/coverity-scan.docker +1 -1
@@ -128,4 +128,4 @@ RUN rpm -q $PACKAGES | sort > /packages.txt ENV PATH $PATH:/usr/libexec/python3-sphinx/ ENV COVERITY_TOOL_BASE=/coverity-tools COPY run-coverity-scan run-coverity-scan -RUN --mount=type=secret,id=coverity.token,required ./run-coverity-scan --update-tools-only --tokenfile /run/secrets/coverity.token +RUN ./run-coverity-scan --update-tools-only --tokenfile /work/token
scripts/coverity-scan/run-coverity-scan +21 -11
@@ -29,7 +29,9 @@ # Command line options: # --dry-run : run the tools, but don't actually do the upload -# --docker : create and work inside a docker container +# --docker : create and work inside a container +# --docker-engine : specify the container engine to use (docker/podman/auto); +# implies --docker # --update-tools-only : update the cached copy of the tools, but don't run them # --tokenfile : file to read Coverity token from # --version ver : specify version being analyzed (default: ask git)
@@ -197,6 +199,17 @@ while [ "$#" -ge 1 ]; do ;; --docker) DOCKER=yes + DOCKER_ENGINE=auto + shift + ;; + --docker-engine) + shift + if [ $# -eq 0 ]; then + echo "--docker-engine needs an argument" + exit 1 + fi + DOCKER=yes + DOCKER_ENGINE="$1" shift ;; *)
@@ -283,9 +296,8 @@ if [ "$DOCKER" = yes ]; then # build docker container including the coverity-scan tools # Put the Coverity token into a temporary file that only # we have read access to, and then pass it to docker build - # using --secret. This requires at least Docker 18.09. - # Mostly what we are trying to do here is ensure we don't leak - # the token into the Docker image. + # using a volume. A volume is enough for the token not to + # leak into the Docker image. umask 077 SECRETDIR=$(mktemp -d) if [ -z "$SECRETDIR" ]; then
@@ -300,12 +312,10 @@ if [ "$DOCKER" = yes ]; then # TODO: This re-downloads the tools every time, rather than # caching and reusing the image produced with the downloaded tools. # Not sure why. - # TODO: how do you get 'docker build' to print the output of the - # commands it is running to its stdout? This would be useful for debug. - DOCKER_BUILDKIT=1 docker build -t coverity-scanner \ - --secret id=coverity.token,src="$SECRET" \ - -f scripts/coverity-scan/coverity-scan.docker \ - scripts/coverity-scan + tests/docker/docker.py --engine ${DOCKER_ENGINE} build \ + -t coverity-scanner -f scripts/coverity-scan/coverity-scan.docker \ + -v "$SECRETDIR:/work" \ + --extra-files scripts/coverity-scan/run-coverity-scan echo "Archiving sources to be analyzed..." ./scripts/archive-source.sh "$SECRETDIR/qemu-sources.tgz" if [ "$DRYRUN" = yes ]; then
@@ -323,7 +333,7 @@ if [ "$DOCKER" = yes ]; then # Arrange for this docker run to get access to the sources with -v. # We pass through all the configuration from the outer script to the inner. export COVERITY_EMAIL COVERITY_BUILD_CMD - docker run -it --env COVERITY_EMAIL --env COVERITY_BUILD_CMD \ + tests/docker/docker.py run -it --env COVERITY_EMAIL --env COVERITY_BUILD_CMD \ -v "$SECRETDIR:/work" coverity-scanner \ ./run-coverity-scan --version "$VERSION" \ --description "$DESCRIPTION" $DRYRUNARG --tokenfile /work/token \
Signature · 1 line
2.26.2
[PULL 008/115] run-coverity-scan: support --update-tools-only --docker
In reply to Paolo BonziniJust build the container when run-coverity-scan is invoked with --update-tools-only --docker. This requires moving the "docker build" logic into the update_coverity_tools function.
The only snag is that --update-tools-only --docker requires access to the dockerfile. For now just report an error for --src-tarball, and "docker build" will fail if not in a source tree. Another possibility could be to host our container images on a public registry, and use "FROM qemu:fedora" to make the Dockerfile small enough that it can be included directly in the run-coverity-scan script.
--- scripts/coverity-scan/run-coverity-scan | 39 +++++++++++++++---------- 1 file changed, 23 insertions(+), 16 deletions(-)
scripts/coverity-scan/run-coverity-scan +23 -16
@@ -95,6 +95,18 @@ check_upload_permissions() { } +build_docker_image() { + # build docker container including the coverity-scan tools + echo "Building docker container..." + # TODO: This re-unpacks the tools every time, rather than caching + # and reusing the image produced by the COPY of the .tgz file. + # Not sure why. + tests/docker/docker.py --engine ${DOCKER_ENGINE} build \ + -t coverity-scanner -f scripts/coverity-scan/coverity-scan.docker \ + --extra-files scripts/coverity-scan/run-coverity-scan \ + "$COVERITY_TOOL_BASE"/coverity_tool.tgz +} + update_coverity_tools () { # Check for whether we need to download the Coverity tools # (either because we don't have a copy, or because it's out of date)
@@ -128,6 +140,11 @@ update_coverity_tools () { fi fi rm -f coverity_tool.md5.new + cd "$SRCDIR" + + if [ "$DOCKER" = yes ]; then + build_docker_image + fi }
@@ -252,15 +269,16 @@ fi PROJNAME=QEMU TARBALL=cov-int.tar.xz -if [ "$UPDATE" = only ] && [ "$DOCKER" = yes ]; then - echo "Combining --docker and --update-only is not supported" - exit 1 -fi - if [ "$UPDATE" = only ]; then # Just do the tools update; we don't need to check whether # we are in a source tree or have upload rights for this, # so do it before some of the command line and source tree checks. + + if [ "$DOCKER" = yes ] && [ ! -z "$SRCTARBALL" ]; then + echo --update-tools-only --docker is incompatible with --src-tarball. + exit 1 + fi + update_coverity_tools exit 0 fi
@@ -322,17 +340,6 @@ if [ "$DOCKER" = yes ]; then echo "Created temporary directory $SECRETDIR" SECRET="$SECRETDIR/token" echo "$COVERITY_TOKEN" > "$SECRET" - if [ "$UPDATE" != no ]; then - # build docker container including the coverity-scan tools - echo "Building docker container..." - # TODO: This re-unpacks the tools every time, rather than caching - # and reusing the image produced by the COPY of the .tgz file. - # Not sure why. - tests/docker/docker.py --engine ${DOCKER_ENGINE} build \ - -t coverity-scanner -f scripts/coverity-scan/coverity-scan.docker \ - --extra-files scripts/coverity-scan/run-coverity-scan \ - "$COVERITY_TOOL_BASE"/coverity_tool.tgz - fi echo "Archiving sources to be analyzed..." ./scripts/archive-source.sh "$SECRETDIR/qemu-sources.tgz" ARGS="--no-update-tools"
Signature · 1 line
2.26.2
[PULL 010/115] numa: prevent usage of -M memory-backend and -numa memdev at the same time
In reply to Paolo BonziniFrom: Igor Mammedov <[email protected]>
Options -M memory-backend and -numa memdev are mutually exclusive, and if used together, it might lead to a crash in the worst case. For example when the same backend is used with these options together:
-m 4G \
-object memory-backend-ram,id=mem0,size=4G \
-M pc,memory-backend=mem0 \
-numa node,memdev=mem0
QEMU will abort with:
exec.c:2006: qemu_ram_set_idstr: Assertion `!new_block->idstr[0]' failed.
and following backtrace:
abort ()
qemu_ram_set_idstr ()
vmstate_register_ram ()
vmstate_register_ram_global ()
machine_consume_memdev ()
numa_init_memdev_container ()
numa_complete_configuration ()
machine_run_board_init ()
add a check to error out in case the user tries to use both options at the same time.
Message-Id: <[email protected]>
--- hw/core/numa.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/core/numa.c +5 -0
@@ -757,6 +757,11 @@ void numa_complete_configuration(MachineState *ms) }if (!numa_uses_legacy_mem () && mc->default_ram_id) { +if (ms->ram_memdev_id) { +error_report ("'-machine memory-backend' and '-numa memdev'" +" properties are mutually exclusive" ); +exit (1 ); + } ms->ram =g_new (MemoryRegion,1 );memory_region_init (ms->ram,OBJECT (ms), mc->default_ram_id, ram_size);
Signature · 1 line
2.26.2
[PULL 002/115] docker.py/build: support binary files in --extra-files
In reply to Paolo BonziniRead the --extra-files in binary mode to avoid encoding errors.
--- tests/docker/docker.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tests/docker/docker.py +6 -2
@@ -56,15 +56,19 @@ class EngineEnum(enum.IntEnum): USE_ENGINE = EngineEnum.AUTO +def _bytes_checksum(bytes): + """Calculate a digest string unique to the text content""" + return hashlib.sha1(bytes).hexdigest() + def _text_checksum(text): """Calculate a digest string unique to the text content""" - return hashlib.sha1(text.encode('utf-8')).hexdigest() + return _bytes_checksum(text.encode('utf-8')) def _read_dockerfile(path): return open(path, 'rt', encoding='utf-8').read() def _file_checksum(filename): - return _text_checksum(_read_dockerfile(filename)) + return _bytes_checksum(open(filename, 'rb').read()) def _guess_engine_command():
Signature · 1 line
2.26.2
[PULL 007/115] run-coverity-scan: download tools outside the container
In reply to Paolo BonziniThis lets us look at coverity_tool.md5 across executions of run-coverity-scan and skip the download.
--- scripts/coverity-scan/coverity-scan.docker | 3 +- scripts/coverity-scan/run-coverity-scan | 42 +++++++++++----------- 2 files changed, 24 insertions(+), 21 deletions(-)
scripts/coverity-scan/coverity-scan.docker +2 -1
@@ -127,5 +127,6 @@ RUN dnf install -y $PACKAGES RUN rpm -q $PACKAGES | sort > /packages.txt ENV PATH $PATH:/usr/libexec/python3-sphinx/ ENV COVERITY_TOOL_BASE=/coverity-tools +COPY coverity_tool.tgz coverity_tool.tgz +RUN mkdir -p /coverity-tools/coverity_tool && cd /coverity-tools/coverity_tool && tar xf /coverity_tool.tgz COPY run-coverity-scan run-coverity-scan -RUN ./run-coverity-scan --update-tools-only --tokenfile /work/token
scripts/coverity-scan/run-coverity-scan +22 -20
70 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 006/115] run-coverity-scan: use --no-update-tools in docker run
In reply to Paolo BonziniTools are already updated via the docker build.
--- scripts/coverity-scan/run-coverity-scan | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
scripts/coverity-scan/run-coverity-scan +5 -6
@@ -325,17 +325,16 @@ if [ "$DOCKER" = yes ]; then fi echo "Archiving sources to be analyzed..." ./scripts/archive-source.sh "$SECRETDIR/qemu-sources.tgz" + ARGS="--no-update-tools" if [ "$DRYRUN" = yes ]; then - DRYRUNARG=--dry-run + ARGS="$ARGS --dry-run" fi echo "Running scanner..." # If we need to capture the output tarball, get the inner run to # save it to the secrets directory so we can copy it out before the # directory is cleaned up. if [ ! -z "$RESULTSTARBALL" ]; then - RTARGS="--results-tarball /work/cov-int.tar.xz" - else - RTARGS="" + ARGS="$ARGS --results-tarball /work/cov-int.tar.xz" fi # Arrange for this docker run to get access to the sources with -v. # We pass through all the configuration from the outer script to the inner.
@@ -343,8 +342,8 @@ if [ "$DOCKER" = yes ]; then tests/docker/docker.py run -it --env COVERITY_EMAIL --env COVERITY_BUILD_CMD \ -v "$SECRETDIR:/work" coverity-scanner \ ./run-coverity-scan --version "$VERSION" \ - --description "$DESCRIPTION" $DRYRUNARG --tokenfile /work/token \ - --srcdir /qemu --src-tarball /work/qemu-sources.tgz $RTARGS + --description "$DESCRIPTION" $ARGS --tokenfile /work/token \ + --srcdir /qemu --src-tarball /work/qemu-sources.tgz if [ ! -z "$RESULTSTARBALL" ]; then echo "Copying results tarball to $RESULTSTARBALL..." cp "$SECRETDIR/cov-int.tar.xz" "$RESULTSTARBALL"
Signature · 1 line
2.26.2
[PULL 001/115] docker.py/build: support -t and -f arguments
In reply to Paolo BonziniThe docker.py command line is subtly different from docker and podman's, in that the tag and Dockerfile are passed via positional arguments. Remove this gratuitous difference and just parse -f and -t.
-f was previously used by --extra-files, only keep the long option.
--- tests/docker/Makefile.include | 2 +- tests/docker/docker.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
tests/docker/Makefile.include +1 -1
@@ -55,7 +55,7 @@ docker-image-%: $(DOCKER_FILES_DIR)/%.docker else docker-image-%: $(DOCKER_FILES_DIR)/%.docker $(call quiet-command,\ - $(DOCKER_SCRIPT) build qemu:$* $< \ + $(DOCKER_SCRIPT) build -t qemu:$* -f $< \ $(if $V,,--quiet) $(if $(NOCACHE),--no-cache) \ $(if $(NOUSER),,--add-current-user) \ $(if $(EXTRA_FILES),--extra-files $(EXTRA_FILES))\
tests/docker/docker.py +3 -3
@@ -392,16 +392,16 @@ class BuildCommand(SubCommand): help="""Specify a binary that will be copied to the container together with all its dependent libraries""") - parser.add_argument("--extra-files", "-f", nargs='*', + parser.add_argument("--extra-files", nargs='*', help="""Specify files that will be copied in the Docker image, fulfilling the ADD directive from the Dockerfile""") parser.add_argument("--add-current-user", "-u", dest="user", action="store_true", help="Add the current user to image's passwd") - parser.add_argument("tag", + parser.add_argument("-t", dest="tag", help="Image Tag") - parser.add_argument("dockerfile", + parser.add_argument("-f", dest="dockerfile", help="Dockerfile name") def run(self, args, argv):
Signature · 1 line
2.26.2
[PULL 016/115] Makefile: Let the 'help' target list the helper targets
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
List the name of the helper targets when calling 'make help', along with the tool targets:
$ make help [...]
Helper targets:
fsdev/virtfs-proxy-helper - Build virtfs-proxy-helper
scsi/qemu-pr-helper - Build qemu-pr-helper
qemu-bridge-helper - Build qemu-bridge-helper
vhost-user-gpu - Build vhost-user-gpu
virtiofsd - Build virtiofsdTools targets:
qemu-ga - Build qemu-ga tool
qemu-keymap - Build qemu-keymap tool
elf2dmp - Build elf2dmp tool
ivshmem-client - Build ivshmem-client tool
ivshmem-server - Build ivshmem-server tool
qemu-nbd - Build qemu-nbd tool
qemu-storage-daemon - Build qemu-storage-daemon tool
qemu-img - Build qemu-img tool
qemu-io - Build qemu-io tool
qemu-edid - Build qemu-edid tool--- Makefile | 9 +++++++-- configure | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-)
Makefile +7 -2
@@ -336,9 +336,9 @@ $(call set-vpath, $(SRC_PATH)) LIBS+=-lz $(LIBS_TOOLS) vhost-user-json-y = -HELPERS-y = +HELPERS-y = $(HELPERS) -HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = qemu-bridge-helper$(EXESUF) +HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) += qemu-bridge-helper$(EXESUF) ifeq ($(CONFIG_LINUX)$(CONFIG_VIRGL)$(CONFIG_GBM)$(CONFIG_TOOLS),yyyy) HELPERS-y += vhost-user-gpu$(EXESUF)
@@ -1258,6 +1258,11 @@ endif $(call print-help-run,$(t)/fuzz,Build fuzzer for $(t)); \ ))) \ echo '') + @$(if $(HELPERS-y), \ + echo 'Helper targets:'; \ + $(foreach t, $(HELPERS-y), \ + $(call print-help-run,$(t),Build $(shell basename $(t)));) \ + echo '') @$(if $(TOOLS), \ echo 'Tools targets:'; \ $(foreach t, $(TOOLS), \
configure +3 -2
@@ -6394,7 +6394,7 @@ if test "$softmmu" = yes ; then if test "$linux" = yes; then if test "$virtfs" != no && test "$cap_ng" = yes && test "$attr" = yes ; then virtfs=yes - tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)" + helpers="$helpers fsdev/virtfs-proxy-helper\$(EXESUF)" else if test "$virtfs" = yes; then error_exit "VirtFS requires libcap-ng devel and libattr devel"
@@ -6409,7 +6409,7 @@ if test "$softmmu" = yes ; then fi mpath=no fi - tools="$tools scsi/qemu-pr-helper\$(EXESUF)" + helpers="$helpers scsi/qemu-pr-helper\$(EXESUF)" else if test "$virtfs" = yes; then error_exit "VirtFS is supported only on Linux"
@@ -7651,6 +7651,7 @@ else QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES" fi +echo "HELPERS=$helpers" >> $config_host_mak echo "TOOLS=$tools" >> $config_host_mak echo "ROMS=$roms" >> $config_host_mak echo "MAKE=$make" >> $config_host_mak
Signature · 1 line
2.26.2
[PULL 020/115] i386:pc: whitelist dynamic vmbus-bridge
In reply to Paolo BonziniFrom: Jon Doron <[email protected]>
As vmbus-bridge is derived from sysbus device, it has to be whitelisted to be allowed to be created with -device.
Message-Id: <[email protected]>
--- hw/i386/pc_piix.c | 2 ++ hw/i386/pc_q35.c | 2 ++ 2 files changed, 4 insertions(+)
hw/i386/pc_piix.c +2 -0
@@ -60,6 +60,7 @@#include "migration/global_state.h" #include "migration/misc.h" #include "sysemu/numa.h" +#include "hw/hyperv/vmbus-bridge.h" #include "hw/mem/nvdimm.h" #include "hw/i386/acpi-build.h"
@@ -419,6 +420,7 @@ static void pc_i440fx_machine_options(MachineClass *m) m->default_machine_opts ="firmware=bios-256k.bin" ; m->default_display ="std" ;machine_class_allow_dynamic_sysbus_dev (m,TYPE_RAMFB_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (m,TYPE_VMBUS_BRIDGE ); }static void pc_i440fx_5_1_machine_options (MachineClass *m)
hw/i386/pc_q35.c +2 -0
@@ -53,6 +53,7 @@#include "qapi/error.h" #include "qemu/error-report.h" #include "sysemu/numa.h" +#include "hw/hyperv/vmbus-bridge.h" #include "hw/mem/nvdimm.h" #include "hw/i386/acpi-build.h"
@@ -348,6 +349,7 @@ static void pc_q35_machine_options(MachineClass *m)machine_class_allow_dynamic_sysbus_dev (m,TYPE_AMD_IOMMU_DEVICE );machine_class_allow_dynamic_sysbus_dev (m,TYPE_INTEL_IOMMU_DEVICE );machine_class_allow_dynamic_sysbus_dev (m,TYPE_RAMFB_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (m,TYPE_VMBUS_BRIDGE ); m->max_cpus =288 ; }
Signature · 1 line
2.26.2
[PULL 021/115] i386: Hyper-V VMBus ACPI DSDT entry
In reply to Paolo BonziniFrom: Jon Doron <[email protected]>
Guest OS uses ACPI to discover VMBus presence. Add a corresponding entry to DSDT in case VMBus has been enabled.
Experimentally Windows guests were found to require this entry to include two IRQ resources. They seem to never be used but they still have to be there.
Make IRQ numbers user-configurable via corresponding properties; use 7 and 13 by default.
Message-Id: <[email protected]>
--- hw/hyperv/vmbus.c | 7 ++++++ hw/i386/acpi-build.c | 43 ++++++++++++++++++++++++++++++++ include/hw/hyperv/vmbus-bridge.h | 3 +++ 3 files changed, 53 insertions(+)
hw/hyperv/vmbus.c +7 -0
@@ -2641,6 +2641,12 @@ static const VMStateDescription vmstate_vmbus_bridge = { }, }; +static Property vmbus_bridge_props[] = { +DEFINE_PROP_UINT8 ("irq0" , VMBusBridge, irq0,7 ), +DEFINE_PROP_UINT8 ("irq1" , VMBusBridge, irq1,13 ), +DEFINE_PROP_END_OF_LIST () +}; +static void vmbus_bridge_class_init (ObjectClass *klass,void *data) {DeviceClass *k =DEVICE_CLASS (klass);
@@ -2651,6 +2657,7 @@ static void vmbus_bridge_class_init(ObjectClass *klass, void *data) sk->explicit_ofw_unit_address = vmbus_bridge_ofw_unit_address;set_bit (DEVICE_CATEGORY_BRIDGE , k->categories); k->vmsd = &vmstate_vmbus_bridge; +device_class_set_props (k, vmbus_bridge_props);/* override SysBusDevice's default */ k->user_creatable = true; }
hw/i386/acpi-build.c +43 -0
64 lines not on this page · raw message
include/hw/hyperv/vmbus-bridge.h +3 -0
@@ -19,6 +19,9 @@ typedef struct VMBus VMBus;typedef struct VMBusBridge {SysBusDevice parent_obj; +uint8_t irq0; +uint8_t irq1; +VMBus *bus; }VMBusBridge ;
Signature · 1 line
2.26.2
[PULL 003/115] run-coverity-scan: get Coverity token and email from special git config section
In reply to Paolo BonziniSupport a [coverity] section in .git/config. It can be used to retrieve the token and also, if it is different from user.email, the username of the submitter.
--- scripts/coverity-scan/run-coverity-scan | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
scripts/coverity-scan/run-coverity-scan +15 -9
@@ -41,9 +41,10 @@ # is intended mainly for internal use by the Docker support # # User-specifiable environment variables: -# COVERITY_TOKEN -- Coverity token +# COVERITY_TOKEN -- Coverity token (default: looks at your +# coverity.token config) # COVERITY_EMAIL -- the email address to use for uploads (default: -# looks at your git user.email config) +# looks at your git coverity.email or user.email config) # COVERITY_BUILD_CMD -- make command (default: 'make -jN' where N is # number of CPUs as determined by 'nproc') # COVERITY_TOOL_BASE -- set to directory to put coverity tools
@@ -58,11 +59,11 @@ check_upload_permissions() { # with status 1 if the check failed (usually a bad token); # will exit the script with status 0 if the check indicated that we # can't upload yet (ie we are at quota) - # Assumes that PROJTOKEN, PROJNAME and DRYRUN have been initialized. + # Assumes that COVERITY_TOKEN, PROJNAME and DRYRUN have been initialized. echo "Checking upload permissions..." - if ! up_perm="$(wget https://scan.coverity.com/api/upload_permitted --post-data "token=$PROJTOKEN&project=$PROJNAME" -q -O -)"; then + if ! up_perm="$(wget https://scan.coverity.com/api/upload_permitted --post-data "token=$COVERITY_TOKEN&project=$PROJNAME" -q -O -)"; then echo "Coverity Scan API access denied: bad token?" exit 1 fi
@@ -94,20 +95,20 @@ check_upload_permissions() { update_coverity_tools () { # Check for whether we need to download the Coverity tools # (either because we don't have a copy, or because it's out of date) - # Assumes that COVERITY_TOOL_BASE, PROJTOKEN and PROJNAME are set. + # Assumes that COVERITY_TOOL_BASE, COVERITY_TOKEN and PROJNAME are set. mkdir -p "$COVERITY_TOOL_BASE" cd "$COVERITY_TOOL_BASE" echo "Checking for new version of coverity build tools..." - wget https://scan.coverity.com/download/linux64 --post-data "token=$PROJTOKEN&project=$PROJNAME&md5=1" -O coverity_tool.md5.new + wget https://scan.coverity.com/download/linux64 --post-data "token=$COVERITY_TOKEN&project=$PROJNAME&md5=1" -O coverity_tool.md5.new if ! cmp -s coverity_tool.md5 coverity_tool.md5.new; then # out of date md5 or no md5: download new build tool # blow away the old build tool echo "Downloading coverity build tools..." rm -rf coverity_tool coverity_tool.tgz - wget https://scan.coverity.com/download/linux64 --post-data "token=$PROJTOKEN&project=$PROJNAME" -O coverity_tool.tgz + wget https://scan.coverity.com/download/linux64 --post-data "token=$COVERITY_TOKEN&project=$PROJNAME" -O coverity_tool.tgz if ! (cat coverity_tool.md5.new; echo " coverity_tool.tgz") | md5sum -c --status; then echo "Downloaded tarball didn't match md5sum!" exit 1
@@ -205,6 +206,9 @@ while [ "$#" -ge 1 ]; do esac done +if [ -z "$COVERITY_TOKEN" ]; then + COVERITY_TOKEN="$(git config coverity.token)" +fi if [ -z "$COVERITY_TOKEN" ]; then echo "COVERITY_TOKEN environment variable not set" exit 1
@@ -225,7 +229,6 @@ if [ -z "$SRCDIR" ]; then SRCDIR="$PWD" fi -PROJTOKEN="$COVERITY_TOKEN" PROJNAME=QEMU TARBALL=cov-int.tar.xz
@@ -268,6 +271,9 @@ if [ -z "$DESCRIPTION" ]; then DESCRIPTION="$(git rev-parse HEAD)" fi +if [ -z "$COVERITY_EMAIL" ]; then + COVERITY_EMAIL="$(git config coverity.email)" +fi if [ -z "$COVERITY_EMAIL" ]; then COVERITY_EMAIL="$(git config user.email)" fi
@@ -393,7 +399,7 @@ if [ "$DRYRUN" = yes ]; then exit 0 fi -curl --form token="$PROJTOKEN" --form email="$COVERITY_EMAIL" \ +curl --form token="$COVERITY_TOKEN" --form email="$COVERITY_EMAIL" \ --form file=@"$TARBALL" --form version="$VERSION" \ --form description="$DESCRIPTION" \ https://scan.coverity.com/builds?project="$PROJNAME"
Signature · 1 line
2.26.2
[PULL 015/115] io/task: Move 'qom/object.h' header to source
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
We need "qom/object.h" to call object_ref()/object_unref(), and to test the TYPE_DUMMY.
Message-Id: <[email protected]>
--- include/io/task.h | 2 -- io/task.c | 1 + tests/test-io-task.c | 1 + 3 files changed, 2 insertions(+), 2 deletions(-)
include/io/task.h +0 -2
@@ -21,8 +21,6 @@#ifndef QIO_TASK_H #define QIO_TASK_H -#include "qom/object.h" -typedef struct QIOTask QIOTask ; typedef void (*QIOTaskFunc)(QIOTask *task,
io/task.c +1 -0
@@ -22,6 +22,7 @@#include "io/task.h" #include "qapi/error.h" #include "qemu/thread.h" +#include "qom/object.h" #include "trace.h" struct QIOTaskThreadData {
tests/test-io-task.c +1 -0
@@ -20,6 +20,7 @@#include "qemu/osdep.h" +#include "qom/object.h" #include "io/task.h" #include "qapi/error.h" #include "qemu/module.h"
Signature · 1 line
2.26.2
[PULL 028/115] hw/i386/vmport: Set EAX to -1 on failed and unsupported commands
In reply to Paolo BonziniFrom: Liran Alon <[email protected]>
This is used as a signal for VMware Tools to know if a command it attempted to invoke, failed or is unsupported. As a result, VMware Tools will either report failure to user or fallback to another backdoor command in attempt to perform some operation.
A few examples:
* open-vm-tools TimeSyncReadHost() function fallbacks to CMD_GETTIMEFULL command when CMD_GETTIMEFULL_WITH_LAG fails/unsupported.
* open-vm-tools Hostinfo_NestingSupported() function verifies EAX != -1 to check for success.
* open-vm-tools Hostinfo_VCPUInfoBackdoor() functions checks if reserved-bit is set to indicate command is unimplemented.
Message-Id: <[email protected]>
--- hw/core/machine.c | 1 + hw/i386/vmport.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)
hw/core/machine.c +1 -0
@@ -44,6 +44,7 @@ GlobalProperty hw_compat_4_2[] = { { "qxl-vga", "revision", "4" }, { "fw_cfg", "acpi-mr-restore", "false" }, { "vmport", "x-read-set-eax", "off" }, + { "vmport", "x-signal-unsupported-cmd", "off" }, };const size_t hw_compat_4_2_len =G_N_ELEMENTS (hw_compat_4_2);
hw/i386/vmport.c +15 -4
@@ -44,9 +44,12 @@#define VMPORT_MAGIC 0x564D5868/* Compatibility flags for migration */ -#define VMPORT_COMPAT_READ_SET_EAX_BIT 0 -#define VMPORT_COMPAT_READ_SET_EAX \ +#define VMPORT_COMPAT_READ_SET_EAX_BIT 0 +#define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT 1 +#define VMPORT_COMPAT_READ_SET_EAX \ (1 << VMPORT_COMPAT_READ_SET_EAX_BIT) +#define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD \ + (1 << VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT)#define VMPORT (obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT)
@@ -87,17 +90,23 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr addr, eax = env->regs[R_EAX ];if (eax !=VMPORT_MAGIC ) { - goto out; + goto err; } command = env->regs[R_ECX ];trace_vmport_command (command);if (command >=VMPORT_ENTRIES || !s->func[command]) {qemu_log_mask (LOG_UNIMP ,"vmport: unknown command %x\n" , command); - goto out; + goto err; } eax = s->func[command](s->opaque[command], addr); + goto out; + +err: +if (s->compat_flags &VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD ) { + eax =UINT32_MAX ; + } out:/*
@@ -168,6 +177,8 @@ static Property vmport_properties[] = {/* Used to enforce compatibility for migration */ DEFINE_PROP_BIT ("x-read-set-eax" , VMPortState, compat_flags,VMPORT_COMPAT_READ_SET_EAX_BIT , true), +DEFINE_PROP_BIT ("x-signal-unsupported-cmd" , VMPortState, compat_flags, +VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT , true), DEFINE_PROP_END_OF_LIST(), };
Signature · 1 line
2.26.2
[PULL 027/115] hw/i386/vmport: Propagate IOPort read to vCPU EAX register
In reply to Paolo BonziniFrom: Liran Alon <[email protected]>
vmport_ioport_read() returns the value that should propagate to vCPU EAX register when guest reads VMPort IOPort (i.e. By x86 IN instruction).
However, because vmport_ioport_read() calls cpu_synchronize_state(), the returned value gets overridden by the value in QEMU vCPU EAX register. i.e. cpu->env.regs[R_EAX].
To fix this issue, change vmport_ioport_read() to explicitly override cpu->env.regs[R_EAX] with the value it wish to propagate to vCPU EAX register.
Message-Id: <[email protected]>
--- hw/core/machine.c | 1 + hw/i386/vmport.c | 32 +++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-)
hw/core/machine.c +1 -0
@@ -43,6 +43,7 @@ GlobalProperty hw_compat_4_2[] = { { "qxl", "revision", "4" }, { "qxl-vga", "revision", "4" }, { "fw_cfg", "acpi-mr-restore", "false" }, + { "vmport", "x-read-set-eax", "off" }, };const size_t hw_compat_4_2_len =G_N_ELEMENTS (hw_compat_4_2);
hw/i386/vmport.c +29 -3
@@ -43,6 +43,11 @@#define VMPORT_ENTRIES 0x2c#define VMPORT_MAGIC 0x564D5868 +/* Compatibility flags for migration */ +#define VMPORT_COMPAT_READ_SET_EAX_BIT 0 +#define VMPORT_COMPAT_READ_SET_EAX \ + (1 << VMPORT_COMPAT_READ_SET_EAX_BIT) +#define VMPORT (obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT) typedef struct VMPortState {
@@ -51,6 +56,8 @@ typedef struct VMPortState {MemoryRegion io;VMPortReadFunc *func[VMPORT_ENTRIES ];void *opaque[VMPORT_ENTRIES ]; + +uint32_t compat_flags; } VMPortState;static VMPortState *port_state;
@@ -80,17 +87,33 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr addr, eax = env->regs[R_EAX ];if (eax !=VMPORT_MAGIC ) { -return eax; + goto out; } command = env->regs[R_ECX ];trace_vmport_command (command);if (command >=VMPORT_ENTRIES || !s->func[command]) {qemu_log_mask (LOG_UNIMP ,"vmport: unknown command %x\n" , command); -return eax; + goto out; + } + + eax = s->func[command](s->opaque[command], addr); + +out: +/* +* The call above to cpu_synchronize_state() gets vCPU registers values +* to QEMU but also cause QEMU to write QEMU vCPU registers values to +* vCPU implementation (e.g. Accelerator such as KVM) just before +* resuming guest. +* +* Therefore, in order to make IOPort return value propagate to +* guest EAX, we need to explicitly update QEMU EAX register value. +*/ +if (s->compat_flags &VMPORT_COMPAT_READ_SET_EAX ) { + cpu->env.regs[R_EAX ] = eax; } -return s->func[command](s->opaque[command], addr); +return eax; } static void vmport_ioport_write(void *opaque, hwaddr addr,
@@ -142,6 +165,9 @@ static void vmport_realizefn(DeviceState *dev, Error **errp) }static Property vmport_properties[] = { +/* Used to enforce compatibility for migration */ +DEFINE_PROP_BIT ("x-read-set-eax" , VMPortState, compat_flags, +VMPORT_COMPAT_READ_SET_EAX_BIT , true),DEFINE_PROP_END_OF_LIST (), };
Signature · 1 line
2.26.2
Re: [PULL 027/115] hw/i386/vmport: Propagate IOPort read to vCPU EAX register
Quoted 27 lines · Paolo Bonzini
From: Liran Alon <[email protected]>
vmport_ioport_read()returns the value that should propagate to vCPU EAX register when guest reads VMPort IOPort (i.e. By x86 IN instruction).However, because
vmport_ioport_read()callscpu_synchronize_state(), the returned value gets overridden by the value in QEMU vCPU EAX register. i.e. cpu->env.regs[R_EAX].To fix this issue, change
vmport_ioport_read()to explicitly override cpu->env.regs[R_EAX] with the value it wish to propagate to vCPU EAX register.Reviewed-by Nikita Leshenko <[email protected]>Signed-off-by Liran Alon <[email protected]>Message-Id: <[email protected]>
Signed-off-by Paolo Bonzini <[email protected]>--- hw/core/machine.c | 1 + hw/i386/vmport.c | 32 +++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-)hw/core/machine.c +0
-0
hw/core/machine.c GlobalProperty hw_compat_4_2[] = { · line 46
Quoted 4 lines
hw/core/machine.c +1
-0@@ -43,6 +43,7 @@ GlobalProperty hw_compat_4_2[] = { { "qxl", "revision", "4" }, { "qxl-vga", "revision", "4" }, { "fw_cfg", "acpi-mr-restore", "false" }, + { "vmport", "x-read-set-eax", "off" },
This is modifying the hw_compat_4_2 properties while qemu-5.0 has been already released. I think all the vmport property updates [1] should go to hw_compat_5_0.
Liran? Paolo?
Thanks,
Laurent
[1]
b889212973da hw/i386/vmport: Propagate IOPort read to vCPU EAX register 0342ee761ef2 hw/i386/vmport: Set EAX to -1 on failed and unsupported commandsf8bdc550370f hw/i386/vmport: Report vmware-vmx-type in CMD_GETVERSION aaacf1c15a22 hw/i386/vmport: Add support for CMD_GETBIOSUUID
{ "vmport", "x-read-set-eax", "off" },
{ "vmport", "x-signal-unsupported-cmd", "off" },
{ "vmport", "x-report-vmx-type", "off" },
{ "vmport", "x-cmds-v2", "off" },Re: [PULL 027/115] hw/i386/vmport: Propagate IOPort read to vCPU EAX register
Quoted 36 lines · Laurent Vivier
Quoted 27 lines · Paolo Bonzini
From: Liran Alon <[email protected]>
vmport_ioport_read()returns the value that should propagate to vCPU EAX register when guest reads VMPort IOPort (i.e. By x86 IN instruction).However, because
vmport_ioport_read()callscpu_synchronize_state(), the returned value gets overridden by the value in QEMU vCPU EAX register. i.e. cpu->env.regs[R_EAX].To fix this issue, change
vmport_ioport_read()to explicitly override cpu->env.regs[R_EAX] with the value it wish to propagate to vCPU EAX register.Reviewed-by Nikita Leshenko <[email protected]>Signed-off-by Liran Alon <[email protected]>Message-Id: <[email protected]>
Signed-off-by Paolo Bonzini <[email protected]>--- hw/core/machine.c | 1 + hw/i386/vmport.c | 32 +++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-)hw/core/machine.c +0
-0hw/core/machine.c GlobalProperty hw_compat_4_2[] = { · line 46
Quoted 4 lines
hw/core/machine.c +1
-0@@ -43,6 +43,7 @@ GlobalProperty hw_compat_4_2[] = { { "qxl", "revision", "4" }, { "qxl-vga", "revision", "4" }, { "fw_cfg", "acpi-mr-restore", "false" }, + { "vmport", "x-read-set-eax", "off" },This is modifying the
hw_compat_4_2properties while qemu-5.0 has been already released. I think all the vmport property updates [1] should go tohw_compat_5_0.
Quoted 1 line
Liran? Paolo?
When I submitted these patches, QEMU 5.0 wasn't released yet. That's why I updated hw_compat_4_2[].
Having said that, I believe the compatibility risk here is very small and therefore because QEMU 5.0 was released for a very short time-span before these patches were merged, I'm not sure it's really preferable to move these flags to hw_compat_5_0[]. But I will leave this for Paolo to decide.
(Note that moving these flags will also risk in comparability people running with current patches and specifying explicitly machine-type 5.0...)
-Liran
Quoted 17 lines
Thanks,
Laurent[1]
b889212973dahw/i386/vmport: Propagate IOPort read to vCPU EAX register0342ee761ef2hw/i386/vmport: Set EAX to -1 on failed and unsupported commandsf8bdc550370fhw/i386/vmport: Report vmware-vmx-type inCMD_GETVERSIONaaacf1c15a22hw/i386/vmport: Add support forCMD_GETBIOSUUID{ "vmport", "x-read-set-eax", "off" }, { "vmport", "x-signal-unsupported-cmd", "off" }, { "vmport", "x-report-vmx-type", "off" }, { "vmport", "x-cmds-v2", "off" },
Re: [PULL 027/115] hw/i386/vmport: Propagate IOPort read to vCPU EAX register
Quoted 9 lines · Liran Alon
Having said that, I believe the compatibility risk here is very small and therefore because QEMU 5.0 was
released for a very short time-span before these patches were merged, I'm not sure it's really preferable
to move these flags to hw_compat_5_0[]. But I will leave this for Paolo to decide.
(Note that moving these flags will also risk in comparability people running with current patches and
specifying explicitly machine-type 5.0...)
Since this has never made it into a release, I'll fix them up.
Paolo
Re: [PULL 027/115] hw/i386/vmport: Propagate IOPort read to vCPU EAX register
Quoted 11 lines · Paolo Bonzini
Quoted 9 lines · Liran Alon
Having said that, I believe the compatibility risk here is very small and therefore because QEMU 5.0 was
released for a very short time-span before these patches were merged, I'm not sure it's really preferable
to move these flags to hw_compat_5_0[]. But I will leave this for Paolo to decide.
(Note that moving these flags will also risk in comparability people running with current patches and
specifying explicitly machine-type 5.0...)
Quoted 1 line
Since this has never made it into a release, I'll fix them up.
I agree, I think this is what to do.
Thanks,
Laurent
[PULL 011/115] icount: fix shift=auto for record/replay
In reply to Paolo BonziniFrom: Pavel Dovgalyuk <[email protected]>
This patch fixes shift=auto when record/replay is enabled. Now user does not need to guess the best shift value.
--
v2:
moved icount_time_shift to vmstate subsection
Message-Id: <158988500050.15192.692077802469400393.stgit@pasha-ThinkPad-X280>
--- cpus.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
cpus.c +19 -1
@@ -379,7 +379,8 @@ static void icount_adjust(void)seqlock_write_lock (&timers_state.vm_clock_seqlock, &timers_state.vm_clock_lock); - cur_time =cpu_get_clock_locked (); + cur_time =REPLAY_CLOCK_LOCKED (REPLAY_CLOCK_VIRTUAL_RT , +cpu_get_clock_locked ()); cur_icount =cpu_get_icount_locked (); delta = cur_icount - cur_time;
@@ -647,6 +648,11 @@ static bool adjust_timers_state_needed(void *opaque)return s->icount_rt_timer !=NULL ; } +static bool shift_state_needed (void *opaque) +{ +return use_icount ==2 ; +} +/* * Subsection for warp timer migration is optional, because may not be created */
@@ -674,6 +680,17 @@ static const VMStateDescription icount_vmstate_adjust_timers = { } }; +static const VMStateDescription icount_vmstate_shift = { + .name ="timer/icount/shift" , + .version_id =1 , + .minimum_version_id =1 , + .needed = shift_state_needed, + .fields = (VMStateField []) { +VMSTATE_INT16 (icount_time_shift, TimersState), +VMSTATE_END_OF_LIST () + } +}; +/* * This is a subsection for icount migration. */
@@ -690,6 +707,7 @@ static const VMStateDescription icount_vmstate_timers = { .subsections = (const VMStateDescription*[]) { &icount_vmstate_warp_timer, &icount_vmstate_adjust_timers, + &icount_vmstate_shift,NULL } };
Signature · 1 line
2.26.2
[PULL 012/115] qom/object: Fix object_child_foreach_recursive() return value
In reply to Paolo BonziniFrom: Cédric Le Goater <[email protected]>
When recursing, the return value of do_object_child_foreach() is not taken into account.
Message-Id: <[email protected]>
--- qom/object.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
qom/object.c +4 -1
@@ -1051,7 +1051,10 @@ static int do_object_child_foreach(Object *obj,break ; }if (recurse) { -do_object_child_foreach (child, fn, opaque, true); + ret =do_object_child_foreach (child, fn, opaque, true); +if (ret !=0 ) { +break ; + } } } }
Signature · 1 line
2.26.2
[PULL 023/115] target/i386: Fix the CPUID leaf CPUID_Fn80000008
In reply to Paolo BonziniFrom: Babu Moger <[email protected]>
CPUID leaf CPUID_Fn80000008_ECX provides information about the number of threads supported by the processor. It was found that the field ApicIdSize(bits 15-12) was not set correctly.
ApicIdSize is defined as the number of bits required to represent all the ApicId values within a package.
Valid Values: Value Description
3h-0h Reserved.
4h up to 16 threads.
5h up to 32 threads.
6h up to 64 threads.
7h up to 128 threads.
Fh-8h Reserved.
Fix the bit appropriately.
This came up during following thread.
https://lore.kernel.org/qemu-devel/158643709116.17430.15995069125716778943.malonedeb@wampee.canonical.com/#t
Refer the Processor Programming Reference (PPR) for AMD Family 17h Model 01h, Revision B1 Processors. The documentation is available from the bugzilla Link below.
Message-Id: <[email protected]>
--- target/i386/cpu.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
target/i386/cpu.c +12 -3
@@ -5837,11 +5837,20 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *eax = cpu->phys_bits; } *ebx = env->features[FEAT_8000_0008_EBX ]; - *ecx =0 ; - *edx =0 ;if (cs->nr_cores * cs->nr_threads >1 ) { - *ecx |= (cs->nr_cores * cs->nr_threads) -1 ; +/* +* Bits 15:12 is "The number of bits in the initial +* Core::X86::Apic::ApicId[ApicId] value that indicate +* thread ID within a package". This is already stored at +* CPUX86State::pkg_offset. +* Bits 7:0 is "The number of threads in the package is NC+1" +*/ + *ecx = (env->pkg_offset <<12 ) | + ((cs->nr_cores * cs->nr_threads) -1 ); + }else { + *ecx =0 ; } + *edx =0 ;break ;case 0x8000000A :if (env->features[FEAT_8000_0001_ECX ] &CPUID_EXT3_SVM ) {
Signature · 1 line
2.26.2
[PULL 005/115] run-coverity-scan: add --no-update-tools option
In reply to Paolo BonziniProvide a quick way to skip building the container while we figure out how to get caching right.
--- scripts/coverity-scan/run-coverity-scan | 37 +++++++++++++++---------- 1 file changed, 23 insertions(+), 14 deletions(-)
scripts/coverity-scan/run-coverity-scan +23 -14
@@ -33,6 +33,7 @@ # --docker-engine : specify the container engine to use (docker/podman/auto); # implies --docker # --update-tools-only : update the cached copy of the tools, but don't run them +# --no-update-tools : do not update the cached copy of the tools # --tokenfile : file to read Coverity token from # --version ver : specify version being analyzed (default: ask git) # --description desc : specify description of this version (default: ask git)
@@ -130,7 +131,7 @@ update_coverity_tools () { # Check user-provided environment variables and arguments DRYRUN=no -UPDATE_ONLY=no +UPDATE=yes DOCKER=no while [ "$#" -ge 1 ]; do
@@ -139,9 +140,13 @@ while [ "$#" -ge 1 ]; do shift DRYRUN=yes ;; + --no-update-tools) + shift + UPDATE=no + ;; --update-tools-only) shift - UPDATE_ONLY=yes + UPDATE=only ;; --version) shift
@@ -245,12 +250,12 @@ fi PROJNAME=QEMU TARBALL=cov-int.tar.xz -if [ "$UPDATE_ONLY" = yes ] && [ "$DOCKER" = yes ]; then +if [ "$UPDATE" = only ] && [ "$DOCKER" = yes ]; then echo "Combining --docker and --update-only is not supported" exit 1 fi -if [ "$UPDATE_ONLY" = yes ]; then +if [ "$UPDATE" = only ]; then # Just do the tools update; we don't need to check whether # we are in a source tree or have upload rights for this, # so do it before some of the command line and source tree checks.
@@ -293,7 +298,6 @@ fi # Run ourselves inside docker if that's what the user wants if [ "$DOCKER" = yes ]; then - # build docker container including the coverity-scan tools # Put the Coverity token into a temporary file that only # we have read access to, and then pass it to docker build # using a volume. A volume is enough for the token not to
@@ -308,14 +312,17 @@ if [ "$DOCKER" = yes ]; then echo "Created temporary directory $SECRETDIR" SECRET="$SECRETDIR/token" echo "$COVERITY_TOKEN" > "$SECRET" - echo "Building docker container..." - # TODO: This re-downloads the tools every time, rather than - # caching and reusing the image produced with the downloaded tools. - # Not sure why. - tests/docker/docker.py --engine ${DOCKER_ENGINE} build \ - -t coverity-scanner -f scripts/coverity-scan/coverity-scan.docker \ - -v "$SECRETDIR:/work" \ - --extra-files scripts/coverity-scan/run-coverity-scan + if [ "$UPDATE" != no ]; then + # build docker container including the coverity-scan tools + echo "Building docker container..." + # TODO: This re-downloads the tools every time, rather than + # caching and reusing the image produced with the downloaded tools. + # Not sure why. + tests/docker/docker.py --engine ${DOCKER_ENGINE} build \ + -t coverity-scanner -f scripts/coverity-scan/coverity-scan.docker \ + -v "$SECRETDIR:/work" \ + --extra-files scripts/coverity-scan/run-coverity-scan + fi echo "Archiving sources to be analyzed..." ./scripts/archive-source.sh "$SECRETDIR/qemu-sources.tgz" if [ "$DRYRUN" = yes ]; then
@@ -350,7 +357,9 @@ fi check_upload_permissions -update_coverity_tools +if [ "$UPDATE" != no ]; then + update_coverity_tools +fi TOOLBIN="$(cd "$COVERITY_TOOL_BASE" && echo $PWD/coverity_tool/cov-analysis-*/bin)"
Signature · 1 line
2.26.2
[PULL 009/115] vl.c: run preconfig loop before creating default RAM backend
In reply to Paolo BonziniFrom: Igor Mammedov <[email protected]>
Default RAM backend depends on numa_uses_legacy_mem(), which is infulenced by -numa options on CLI or set-numa-node QMP command at preconfig time. If QEMU is started with '-preconfig' without -numa, it will lead to creating default RAM backend even if later set-numa-node is used to assing RAM to NUMA nodes using 'memdev' NUMA option.
That at best will waste RAM object created by default and with next patch adding a check to prevent usage of conflicting
'-M memory-backend' and '-numa memdev'
options, it will make QEMU error out if user tries to configure NUMA at preconfig time with memdev option, making set-numa-node unusable.
To fix issue, move preconfig loop before default RAM backend is created, so that numa_uses_legacy_mem() would take into account effects of set-numa-node commands executed at preconfig time.
Message-Id: <[email protected]>
--- softmmu/vl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
softmmu/vl.c +3 -2
@@ -4334,12 +4334,13 @@ void qemu_init(int argc, char **argv, char **envp)parse_numa_opts (current_machine); +/* do monitor/qmp handling at preconfig state if requested */ +qemu_main_loop (); +if (machine_class->default_ram_id && current_machine->ram_size &&numa_uses_legacy_mem () && !current_machine->ram_memdev_id) {create_default_memdev (current_machine, mem_path); } -/* do monitor/qmp handling at preconfig state if requested */ -qemu_main_loop ();audio_init_audiodevs ();
Signature · 1 line
2.26.2
[PULL 018/115] vmbus: add vmbus protocol definitions
In reply to Paolo BonziniFrom: Jon Doron <[email protected]>
Add a header with data structures and constants used in Hyper-V VMBus hypervisor <-> guest interactions.
Based on the respective stuff from Linux kernel.
Message-Id: <[email protected]>
--- include/hw/hyperv/vmbus-proto.h | 222 ++++++++++++++++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 include/hw/hyperv/vmbus-proto.h
include/hw/hyperv/vmbus-proto.h new file +222 -0
@@ -0,0 +1,222 @@ +/* +* QEMU Hyper-V VMBus support +* +* Copyright (c) 2017-2018 Virtuozzo International GmbH. +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef HW_HYPERV_VMBUS_PROTO_H +#define HW_HYPERV_VMBUS_PROTO_H + +#define VMBUS_VERSION_WS2008 ((0 << 16) | (13)) +#define VMBUS_VERSION_WIN7 ((1 << 16) | (1)) +#define VMBUS_VERSION_WIN8 ((2 << 16) | (4)) +#define VMBUS_VERSION_WIN8_1 ((3 << 16) | (0)) +#define VMBUS_VERSION_WIN10 ((4 << 16) | (0)) +#define VMBUS_VERSION_INVAL -1 +#define VMBUS_VERSION_CURRENT VMBUS_VERSION_WIN10 + +#define VMBUS_MESSAGE_CONNECTION_ID 1 +#define VMBUS_EVENT_CONNECTION_ID 2 +#define VMBUS_MONITOR_CONNECTION_ID 3 +#define VMBUS_SINT 2 + +#define VMBUS_MSG_INVALID 0 +#define VMBUS_MSG_OFFERCHANNEL 1 +#define VMBUS_MSG_RESCIND_CHANNELOFFER 2 +#define VMBUS_MSG_REQUESTOFFERS 3 +#define VMBUS_MSG_ALLOFFERS_DELIVERED 4 +#define VMBUS_MSG_OPENCHANNEL 5 +#define VMBUS_MSG_OPENCHANNEL_RESULT 6 +#define VMBUS_MSG_CLOSECHANNEL 7 +#define VMBUS_MSG_GPADL_HEADER 8 +#define VMBUS_MSG_GPADL_BODY 9 +#define VMBUS_MSG_GPADL_CREATED 10 +#define VMBUS_MSG_GPADL_TEARDOWN 11 +#define VMBUS_MSG_GPADL_TORNDOWN 12 +#define VMBUS_MSG_RELID_RELEASED 13 +#define VMBUS_MSG_INITIATE_CONTACT 14 +#define VMBUS_MSG_VERSION_RESPONSE 15 +#define VMBUS_MSG_UNLOAD 16 +#define VMBUS_MSG_UNLOAD_RESPONSE 17 +#define VMBUS_MSG_COUNT 18 + +#define VMBUS_MESSAGE_SIZE_ALIGN sizeof(uint64_t) + +#define VMBUS_PACKET_INVALID 0x0 +#define VMBUS_PACKET_SYNCH 0x1 +#define VMBUS_PACKET_ADD_XFER_PAGESET 0x2 +#define VMBUS_PACKET_RM_XFER_PAGESET 0x3 +#define VMBUS_PACKET_ESTABLISH_GPADL 0x4 +#define VMBUS_PACKET_TEARDOWN_GPADL 0x5 +#define VMBUS_PACKET_DATA_INBAND 0x6 +#define VMBUS_PACKET_DATA_USING_XFER_PAGES 0x7 +#define VMBUS_PACKET_DATA_USING_GPADL 0x8 +#define VMBUS_PACKET_DATA_USING_GPA_DIRECT 0x9 +#define VMBUS_PACKET_CANCEL_REQUEST 0xa +#define VMBUS_PACKET_COMP 0xb +#define VMBUS_PACKET_DATA_USING_ADDITIONAL_PKT 0xc +#define VMBUS_PACKET_ADDITIONAL_DATA 0xd + +#define VMBUS_CHANNEL_USER_DATA_SIZE 120 + +#define VMBUS_OFFER_MONITOR_ALLOCATED 0x1 +#define VMBUS_OFFER_INTERRUPT_DEDICATED 0x1 + +#define VMBUS_RING_BUFFER_FEAT_PENDING_SZ (1ul << 0) + +#define VMBUS_CHANNEL_ENUMERATE_DEVICE_INTERFACE 0x1 +#define VMBUS_CHANNEL_SERVER_SUPPORTS_TRANSFER_PAGES 0x2 +#define VMBUS_CHANNEL_SERVER_SUPPORTS_GPADLS 0x4 +#define VMBUS_CHANNEL_NAMED_PIPE_MODE 0x10 +#define VMBUS_CHANNEL_LOOPBACK_OFFER 0x100 +#define VMBUS_CHANNEL_PARENT_OFFER 0x200 +#define VMBUS_CHANNEL_REQUEST_MONITORED_NOTIFICATION 0x400 +#define VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER 0x2000 + +#define VMBUS_PACKET_FLAG_REQUEST_COMPLETION 1 + +typedef struct vmbus_message_header { +uint32_t message_type; +uint32_t _padding; +}vmbus_message_header ; + +typedef struct vmbus_message_initiate_contact { +vmbus_message_header header; +uint32_t version_requested; +uint32_t target_vcpu; +uint64_t interrupt_page; +uint64_t monitor_page1; +uint64_t monitor_page2; +}vmbus_message_initiate_contact ; + +typedef struct vmbus_message_version_response { +vmbus_message_header header; +uint8_t version_supported; +uint8_t status; +}vmbus_message_version_response ; + +typedef struct vmbus_message_offer_channel { +vmbus_message_header header; +uint8_t type_uuid[16 ]; +uint8_t instance_uuid[16 ]; +uint64_t _reserved1; +uint64_t _reserved2; +uint16_t channel_flags; +uint16_t mmio_size_mb; +uint8_t user_data[VMBUS_CHANNEL_USER_DATA_SIZE ]; +uint16_t sub_channel_index; +uint16_t _reserved3; +uint32_t child_relid; +uint8_t monitor_id; +uint8_t monitor_flags; +uint16_t interrupt_flags; +uint32_t connection_id; +}vmbus_message_offer_channel ; + +typedef struct vmbus_message_rescind_channel_offer { +vmbus_message_header header; +uint32_t child_relid; +}vmbus_message_rescind_channel_offer ; + +typedef struct vmbus_gpa_range { +uint32_t byte_count; +uint32_t byte_offset; +uint64_t pfn_array[]; +}vmbus_gpa_range ; + +typedef struct vmbus_message_gpadl_header { +vmbus_message_header header; +uint32_t child_relid; +uint32_t gpadl_id; +uint16_t range_buflen; +uint16_t rangecount; +vmbus_gpa_range range[]; +} QEMU_PACKED vmbus_message_gpadl_header; + +typedef struct vmbus_message_gpadl_body { +vmbus_message_header header; +uint32_t message_number; +uint32_t gpadl_id; +uint64_t pfn_array[]; +}vmbus_message_gpadl_body ; + +typedef struct vmbus_message_gpadl_created { +vmbus_message_header header; +uint32_t child_relid; +uint32_t gpadl_id; +uint32_t status; +}vmbus_message_gpadl_created ; + +typedef struct vmbus_message_gpadl_teardown { +vmbus_message_header header; +uint32_t child_relid; +uint32_t gpadl_id; +}vmbus_message_gpadl_teardown ; + +typedef struct vmbus_message_gpadl_torndown { +vmbus_message_header header; +uint32_t gpadl_id; +}vmbus_message_gpadl_torndown ; + +typedef struct vmbus_message_open_channel { +vmbus_message_header header; +uint32_t child_relid; +uint32_t open_id; +uint32_t ring_buffer_gpadl_id; +uint32_t target_vp; +uint32_t ring_buffer_offset; +uint8_t user_data[VMBUS_CHANNEL_USER_DATA_SIZE ]; +}vmbus_message_open_channel ; + +typedef struct vmbus_message_open_result { +vmbus_message_header header; +uint32_t child_relid; +uint32_t open_id; +uint32_t status; +}vmbus_message_open_result ; + +typedef struct vmbus_message_close_channel { +vmbus_message_header header; +uint32_t child_relid; +}vmbus_message_close_channel ; + +typedef struct vmbus_ring_buffer { +uint32_t write_index; +uint32_t read_index; +uint32_t interrupt_mask; +uint32_t pending_send_sz; +uint32_t _reserved1[12 ]; +uint32_t feature_bits; +}vmbus_ring_buffer ; + +typedef struct vmbus_packet_hdr { +uint16_t type; +uint16_t offset_qwords; +uint16_t len_qwords; +uint16_t flags; +uint64_t transaction_id; +}vmbus_packet_hdr ; + +typedef struct vmbus_pkt_gpa_direct { +uint32_t _reserved; +uint32_t rangecount; +vmbus_gpa_range range[]; +}vmbus_pkt_gpa_direct ; + +typedef struct vmbus_xferpg_range { +uint32_t byte_count; +uint32_t byte_offset; +}vmbus_xferpg_range ; + +typedef struct vmbus_pkt_xferpg { +uint16_t buffer_id; +uint8_t sender_owns_set; +uint8_t _reserved; +uint32_t rangecount; +vmbus_xferpg_range range[]; +}vmbus_pkt_xferpg ; + +#endif
Signature · 1 line
2.26.2
[PULL 029/115] hw/i386/vmport: Introduce vmware-vmx-version property
In reply to Paolo BonziniFrom: Liran Alon <[email protected]>
vmware-vmx-version is a number returned from CMD_GETVERSION which specifies to guest VMware Tools the the host VMX version. If the host reports a number that is different than what the guest VMware Tools expects, it may force guest to upgrade VMware Tools. (See comment above VERSION_MAGIC and VmCheck_IsVirtualWorld() function in open-vm-tools open-source code).
For better readability and allow maintaining compatability for guests which may expect different vmware-vmx-version, make vmware-vmx-version a VMPort object property. This would allow user to control it's value via "-global vmport.vmware-vmx-version=X".
Message-Id: <[email protected]>
--- hw/i386/vmport.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
hw/i386/vmport.c +8 -1
@@ -60,6 +60,8 @@ typedef struct VMPortState {VMPortReadFunc *func[VMPORT_ENTRIES ];void *opaque[VMPORT_ENTRIES ]; +uint32_t vmware_vmx_version; +uint32_t compat_flags; } VMPortState;
@@ -138,7 +140,7 @@ static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr)X86CPU *cpu =X86_CPU (current_cpu); cpu->env.regs[R_EBX ] =VMPORT_MAGIC ; -return 6 ; +return port_state->vmware_vmx_version; }static uint32_t vmport_cmd_ram_size (void *opaque,uint32_t addr)
@@ -179,6 +181,11 @@ static Property vmport_properties[] = { VMPORT_COMPAT_READ_SET_EAX_BIT, true),DEFINE_PROP_BIT ("x-signal-unsupported-cmd" , VMPortState, compat_flags,VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT , true), + +/* Default value taken from open-vm-tools code VERSION_MAGIC definition */ +DEFINE_PROP_UINT32 ("vmware-vmx-version" , VMPortState, + vmware_vmx_version,6 ), + DEFINE_PROP_END_OF_LIST(), };
Signature · 1 line
2.26.2
[PULL 032/115] hw/i386/vmport: Define enum for all commands
In reply to Paolo BonziniFrom: Liran Alon <[email protected]>
No functional change.
Defining an enum for all VMPort commands have the following advantages:
* It gets rid of the error-prone requirement to update VMPORT_ENTRIES when new VMPort commands are added to QEMU.
* It makes it clear to know by looking at one place at the source, what are all the VMPort commands supported by QEMU.
Message-Id: <[email protected]>
--- hw/i386/vmmouse.c | 18 ++++++------------ hw/i386/vmport.c | 11 ++--------- include/hw/i386/vmport.h | 11 ++++++++++- 3 files changed, 18 insertions(+), 22 deletions(-)
hw/i386/vmmouse.c +6 -12
@@ -34,12 +34,6 @@/* debug only vmmouse */ //#define DEBUG_VMMOUSE -/* VMMouse Commands */ -#define VMMOUSE_GETVERSION 10 -#define VMMOUSE_DATA 39 -#define VMMOUSE_STATUS 40 -#define VMMOUSE_COMMAND 41 -#define VMMOUSE_READ_ID 0x45414552#define VMMOUSE_DISABLE 0x000000f5#define VMMOUSE_REQUEST_RELATIVE 0x4c455252
@@ -217,10 +211,10 @@ static uint32_t vmmouse_ioport_read(void *opaque, uint32_t addr) command = data[2 ] &0xFFFF ;switch (command) { -case VMMOUSE_STATUS : +case VMPORT_CMD_VMMOUSE_STATUS : data[0 ] =vmmouse_get_status (s);break ; -case VMMOUSE_COMMAND : +case VMPORT_CMD_VMMOUSE_COMMAND :switch (data[1 ]) {case VMMOUSE_DISABLE :vmmouse_disable (s);
@@ -239,7 +233,7 @@ static uint32_t vmmouse_ioport_read(void *opaque, uint32_t addr)break ; }break ; -case VMMOUSE_DATA : +case VMPORT_CMD_VMMOUSE_DATA :vmmouse_data (s, data, data[1 ]);break ;default :
@@ -296,9 +290,9 @@ static void vmmouse_realizefn(DeviceState *dev, Error **errp)return ; } -vmport_register (VMMOUSE_STATUS , vmmouse_ioport_read, s); -vmport_register (VMMOUSE_COMMAND , vmmouse_ioport_read, s); -vmport_register (VMMOUSE_DATA , vmmouse_ioport_read, s); +vmport_register (VMPORT_CMD_VMMOUSE_STATUS , vmmouse_ioport_read, s); +vmport_register (VMPORT_CMD_VMMOUSE_COMMAND , vmmouse_ioport_read, s); +vmport_register (VMPORT_CMD_VMMOUSE_DATA , vmmouse_ioport_read, s); }static Property vmmouse_properties[] = {
hw/i386/vmport.c +2 -9
@@ -37,10 +37,6 @@#include "cpu.h" #include "trace.h" -#define VMPORT_CMD_GETVERSION 0x0a -#define VMPORT_CMD_GETRAMSIZE 0x14 - -#define VMPORT_ENTRIES 0x2c#define VMPORT_MAGIC 0x564D5868/* Compatibility flags for migration */
@@ -71,12 +67,9 @@ typedef struct VMPortState {static VMPortState *port_state; -void vmport_register (unsigned char command,VMPortReadFunc *func,void *opaque) +void vmport_register (VMPortCommand command,VMPortReadFunc *func,void *opaque) { -if (command >=VMPORT_ENTRIES ) { -return ; - } - +assert (command <VMPORT_ENTRIES );trace_vmport_register (command, func, opaque); port_state->func[command] = func; port_state->opaque[command] = opaque;
include/hw/i386/vmport.h +10 -1
@@ -6,11 +6,20 @@#define TYPE_VMPORT "vmport"typedef uint32_t (VMPortReadFunc )(void *opaque,uint32_t address); +typedef enum { +VMPORT_CMD_GETVERSION =10 , +VMPORT_CMD_GETRAMSIZE =20 , +VMPORT_CMD_VMMOUSE_DATA =39 , +VMPORT_CMD_VMMOUSE_STATUS =40 , +VMPORT_CMD_VMMOUSE_COMMAND =41 , +VMPORT_ENTRIES +}VMPortCommand ; +static inline void vmport_init (ISABus *bus) {isa_create_simple (bus,TYPE_VMPORT ); } -void vmport_register (unsigned char command,VMPortReadFunc *func,void *opaque); +void vmport_register (VMPortCommand command,VMPortReadFunc *func,void *opaque);#endif
Signature · 1 line
2.26.2
[PULL 036/115] i386/cpu: Store LAPIC bus frequency in CPU structure
In reply to Paolo BonziniFrom: Liran Alon <[email protected]>
No functional change.
This information will be used by following patches.
Message-Id: <[email protected]>
--- target/i386/cpu.h | 1 + target/i386/kvm.c | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-)
target/i386/cpu.h +1 -0
@@ -1584,6 +1584,7 @@ typedef struct CPUX86State {bool tsc_valid;int64_t tsc_khz;int64_t user_tsc_khz;/* for sanity check only */ +uint64_t apic_bus_freq;#if defined(CONFIG_KVM ) || defined(CONFIG_HVF )void *xsave_buf;#endif
target/i386/kvm.c +7 -3
@@ -59,6 +59,10 @@ do { } while (0)#endif +/* From arch/x86/kvm/lapic.h */ +#define KVM_APIC_BUS_CYCLE_NS 1 +#define KVM_APIC_BUS_FREQUENCY (1000000000ULL / KVM_APIC_BUS_CYCLE_NS) +#define MSR_KVM_WALL_CLOCK 0x11#define MSR_KVM_SYSTEM_TIME 0x12
@@ -1469,6 +1473,8 @@ int kvm_arch_init_vcpu(CPUState *cs) } } + env->apic_bus_freq =KVM_APIC_BUS_FREQUENCY ; +/* Paravirtualization CPUIDs */ r =hyperv_handle_properties (cs, cpuid_data.entries);if (r <0 ) {
@@ -1773,9 +1779,7 @@ int kvm_arch_init_vcpu(CPUState *cs) c = &cpuid_data.entries[cpuid_i++]; c->function =KVM_CPUID_SIGNATURE |0x10 ; c->eax = env->tsc_khz; -/* LAPIC resolution of 1ns (freq: 1GHz) is hardcoded in KVM's -* APIC_BUS_CYCLE_NS */ - c->ebx =1000000 ; + c->ebx = env->apic_bus_freq /1000 ;/* Hz to KHz */ c->ecx = c->edx =0 ; c =cpuid_find_entry (&cpuid_data.cpuid, kvm_base,0 );
Signature · 1 line
2.26.2
[PULL 033/115] hw/i386/vmport: Add support for CMD_GETBIOSUUID
In reply to Paolo BonziniFrom: Liran Alon <[email protected]>
This is VMware documented functionallity that some guests rely on. Returns the BIOS UUID of the current virtual machine.
Note that we also introduce a new compatability flag "x-cmds-v2" to make sure to expose new VMPort commands only to new machine-types. This flag will also be used by the following patches that will introduce additional VMPort commands.
Message-Id: <[email protected]>
--- hw/core/machine.c | 1 + hw/i386/vmport.c | 22 ++++++++++++++++++++++ include/hw/i386/vmport.h | 1 + 3 files changed, 24 insertions(+)
hw/core/machine.c +1 -0
@@ -46,6 +46,7 @@ GlobalProperty hw_compat_4_2[] = { { "vmport", "x-read-set-eax", "off" }, { "vmport", "x-signal-unsupported-cmd", "off" }, { "vmport", "x-report-vmx-type", "off" }, + { "vmport", "x-cmds-v2", "off" }, };const size_t hw_compat_4_2_len =G_N_ELEMENTS (hw_compat_4_2);
hw/i386/vmport.c +22 -0
@@ -32,6 +32,7 @@#include "hw/isa/isa.h" #include "hw/i386/vmport.h" #include "hw/qdev-properties.h" +#include "sysemu/sysemu.h" #include "sysemu/hw_accel.h" #include "qemu/log.h" #include "cpu.h"
@@ -43,12 +44,15 @@#define VMPORT_COMPAT_READ_SET_EAX_BIT 0#define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT 1#define VMPORT_COMPAT_REPORT_VMX_TYPE_BIT 2 +#define VMPORT_COMPAT_CMDS_V2_BIT 3#define VMPORT_COMPAT_READ_SET_EAX \ (1 << VMPORT_COMPAT_READ_SET_EAX_BIT)#define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD \ (1 << VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT)#define VMPORT_COMPAT_REPORT_VMX_TYPE \ (1 << VMPORT_COMPAT_REPORT_VMX_TYPE_BIT) +#define VMPORT_COMPAT_CMDS_V2 \ + (1 << VMPORT_COMPAT_CMDS_V2_BIT)#define VMPORT (obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT)
@@ -143,6 +147,18 @@ static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr)return port_state->vmware_vmx_version; } +static uint32_t vmport_cmd_get_bios_uuid (void *opaque,uint32_t addr) +{ +X86CPU *cpu =X86_CPU (current_cpu); +uint32_t *uuid_parts = (uint32_t *)(qemu_uuid.data); + + cpu->env.regs[R_EAX ] =le32_to_cpu (uuid_parts[0 ]); + cpu->env.regs[R_EBX ] =le32_to_cpu (uuid_parts[1 ]); + cpu->env.regs[R_ECX ] =le32_to_cpu (uuid_parts[2 ]); + cpu->env.regs[R_EDX ] =le32_to_cpu (uuid_parts[3 ]); +return cpu->env.regs[R_EAX ]; +} +static uint32_t vmport_cmd_ram_size (void *opaque,uint32_t addr) {X86CPU *cpu =X86_CPU (current_cpu);
@@ -170,9 +186,13 @@ static void vmport_realizefn(DeviceState *dev, Error **errp)isa_register_ioport (isadev, &s->io,0x5658 ); port_state = s; +/* Register some generic port commands */ vmport_register (VMPORT_CMD_GETVERSION , vmport_cmd_get_version,NULL );vmport_register (VMPORT_CMD_GETRAMSIZE , vmport_cmd_ram_size,NULL ); +if (s->compat_flags &VMPORT_COMPAT_CMDS_V2 ) { +vmport_register (VMPORT_CMD_GETBIOSUUID , vmport_cmd_get_bios_uuid,NULL ); + } }static Property vmport_properties[] = {
@@ -183,6 +203,8 @@ static Property vmport_properties[] = { VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT, true),DEFINE_PROP_BIT ("x-report-vmx-type" , VMPortState, compat_flags,VMPORT_COMPAT_REPORT_VMX_TYPE_BIT , true), +DEFINE_PROP_BIT ("x-cmds-v2" , VMPortState, compat_flags, +VMPORT_COMPAT_CMDS_V2_BIT , true),/* Default value taken from open-vm-tools code VERSION_MAGIC definition */ DEFINE_PROP_UINT32("vmware-vmx-version", VMPortState,
include/hw/i386/vmport.h +1 -0
@@ -8,6 +8,7 @@ typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address); typedef enum { VMPORT_CMD_GETVERSION = 10, + VMPORT_CMD_GETBIOSUUID = 19, VMPORT_CMD_GETRAMSIZE = 20, VMPORT_CMD_VMMOUSE_DATA = 39, VMPORT_CMD_VMMOUSE_STATUS = 40,
Signature · 1 line
2.26.2
[PULL 013/115] target/i386: Fix OUTL debug output
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Fix OUTL instructions incorrectly displayed as OUTW.
Message-Id: <[email protected]>
--- target/i386/misc_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/misc_helper.c +1 -1
@@ -70,7 +70,7 @@ target_ulong helper_inw(CPUX86State *env, uint32_t port)void helper_outl (CPUX86State *env,uint32_t port,uint32_t data) {#ifdef CONFIG_USER_ONLY -fprintf (stderr,"outw: port=0x%04x, data=%08x\n" , port, data); +fprintf (stderr,"outl: port=0x%04x, data=%08x\n" , port, data);#else address_space_stl (&address_space_io, port, data,cpu_get_mem_attrs (env),NULL );
Signature · 1 line
2.26.2
[PULL 026/115] hw/i386/vmport: Add device properties
In reply to Paolo BonziniFrom: Liran Alon <[email protected]>
No functional change.
This is done as a preparation for the following patches that will introduce several device properties.
Message-Id: <[email protected]>
--- hw/i386/vmport.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/i386/vmport.c +6 -0
@@ -30,6 +30,7 @@#include "qemu/osdep.h" #include "hw/isa/isa.h" +#include "hw/qdev-properties.h" #include "sysemu/hw_accel.h" #include "qemu/log.h" #include "vmport.h"
@@ -140,6 +141,10 @@ static void vmport_realizefn(DeviceState *dev, Error **errp)vmport_register (VMPORT_CMD_GETRAMSIZE , vmport_cmd_ram_size,NULL ); } +static Property vmport_properties[] = { +DEFINE_PROP_END_OF_LIST (), +}; +static void vmport_class_initfn (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -147,6 +152,7 @@ static void vmport_class_initfn(ObjectClass *klass, void *data) dc->realize = vmport_realizefn;/* Reason: realize sets global port_state */ dc->user_creatable = false; +device_class_set_props (dc, vmport_properties); }static const TypeInfo vmport_info = {
Signature · 1 line
2.26.2
[PULL 039/115] accel: Move Xen accelerator code under accel/xen/
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
This code is not related to hardware emulation.
Move it under accel/ with the other hypervisors.
Message-Id: <[email protected]>
--- MAINTAINERS | 2 ++ accel/Makefile.objs | 1 + accel/xen/Makefile.objs | 1 + hw/xen/xen-common.c => accel/xen/xen-all.c | 8 +++++ hw/acpi/piix4.c | 2 +- hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 1 + hw/i386/pc_q35.c | 1 + hw/i386/xen/xen-hvm.c | 1 + hw/i386/xen/xen_platform.c | 1 + hw/isa/piix3.c | 1 + hw/pci/msix.c | 1 + hw/xen/Makefile.objs | 2 +- include/exec/ram_addr.h | 2 +- include/hw/xen/xen.h | 11 ------- include/sysemu/xen.h | 38 ++++++++++++++++++++++ migration/savevm.c | 2 +- softmmu/vl.c | 2 +- stubs/xen-hvm.c | 9 ----- target/i386/cpu.c | 2 +- 20 files changed, 63 insertions(+), 26 deletions(-) create mode 100644 accel/xen/Makefile.objs rename hw/xen/xen-common.c => accel/xen/xen-all.c (98%) create mode 100644 include/sysemu/xen.h
MAINTAINERS +2 -0
@@ -440,6 +440,7 @@ M: Paul Durrant <[email protected]> L: [email protected] S: Supported F: */xen* +F: accel/xen/* F: hw/9pfs/xen-9p* F: hw/char/xen_console.c F: hw/display/xenfb.c
@@ -453,6 +454,7 @@ F: hw/i386/xen/ F: hw/pci-host/xen_igd_pt.c F: include/hw/block/dataplane/xen* F: include/hw/xen/ +F: include/sysemu/xen.h F: include/sysemu/xen-mapcache.h Guest CPU Cores (HAXM)
accel/Makefile.objs +1 -0
@@ -2,4 +2,5 @@ common-obj-$(CONFIG_SOFTMMU) += accel.o obj-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_POSIX)) += qtest.o obj-$(CONFIG_KVM) += kvm/ obj-$(CONFIG_TCG) += tcg/ +obj-$(CONFIG_XEN) += xen/ obj-y += stubs/
accel/xen/Makefile.objs new file +1 -0
@@ -0,0 +1 @@ +obj-y += xen-all.o
accel/xen/xen-all.c renamed from hw/xen/xen-common.c +8 -0
@@ -16,6 +16,7 @@#include "hw/xen/xen_pt.h" #include "chardev/char.h" #include "sysemu/accel.h" +#include "sysemu/xen.h" #include "sysemu/runstate.h" #include "migration/misc.h" #include "migration/global_state.h"
@@ -31,6 +32,13 @@ do { } while (0)#endif +static bool xen_allowed; + +bool xen_enabled (void ) +{ +return xen_allowed; +} +xc_interface *xen_xc;xenforeignmemory_handle *xen_fmem;xendevicemodel_handle *xen_dmod;
hw/acpi/piix4.c +1 -1
@@ -30,6 +30,7 @@#include "hw/acpi/acpi.h" #include "sysemu/runstate.h" #include "sysemu/sysemu.h" +#include "sysemu/xen.h" #include "qapi/error.h" #include "qemu/range.h" #include "exec/address-spaces.h"
@@ -41,7 +42,6 @@#include "hw/mem/nvdimm.h" #include "hw/acpi/memory_hotplug.h" #include "hw/acpi/acpi_dev_interface.h" -#include "hw/xen/xen.h" #include "migration/vmstate.h" #include "hw/core/cpu.h" #include "trace.h"
hw/i386/pc.c +1 -0
@@ -57,6 +57,7 @@#include "sysemu/tcg.h" #include "sysemu/numa.h" #include "sysemu/kvm.h" +#include "sysemu/xen.h" #include "sysemu/qtest.h" #include "sysemu/reset.h" #include "sysemu/runstate.h"
hw/i386/pc_piix.c +1 -0
@@ -53,6 +53,7 @@#include "cpu.h" #include "qapi/error.h" #include "qemu/error-report.h" +#include "sysemu/xen.h" #ifdef CONFIG_XEN #include <xen/hvm/hvm_info_table.h> #include "hw/xen/xen_pt.h"
hw/i386/pc_q35.c +1 -0
@@ -36,6 +36,7 @@#include "hw/rtc/mc146818rtc.h" #include "hw/xen/xen.h" #include "sysemu/kvm.h" +#include "sysemu/xen.h" #include "hw/kvm/clock.h" #include "hw/pci-host/q35.h" #include "hw/qdev-properties.h"
hw/i386/xen/xen-hvm.c +1 -0
@@ -28,6 +28,7 @@#include "qemu/range.h" #include "sysemu/runstate.h" #include "sysemu/sysemu.h" +#include "sysemu/xen.h" #include "sysemu/xen-mapcache.h" #include "trace.h" #include "exec/address-spaces.h"
hw/i386/xen/xen_platform.c +1 -0
@@ -33,6 +33,7 @@#include "hw/xen/xen-legacy-backend.h" #include "trace.h" #include "exec/address-spaces.h" +#include "sysemu/xen.h" #include "sysemu/block-backend.h" #include "qemu/error-report.h" #include "qemu/module.h"
hw/isa/piix3.c +1 -0
@@ -28,6 +28,7 @@#include "hw/irq.h" #include "hw/isa/isa.h" #include "hw/xen/xen.h" +#include "sysemu/xen.h" #include "sysemu/sysemu.h" #include "sysemu/reset.h" #include "sysemu/runstate.h"
hw/pci/msix.c +1 -0
@@ -19,6 +19,7 @@#include "hw/pci/msix.h" #include "hw/pci/pci.h" #include "hw/xen/xen.h" +#include "sysemu/xen.h" #include "migration/qemu-file-types.h" #include "migration/vmstate.h" #include "qemu/range.h"
hw/xen/Makefile.objs +1 -1
@@ -1,5 +1,5 @@ # xen backend driver support -common-obj-$(CONFIG_XEN) += xen-legacy-backend.o xen_devconfig.o xen_pvdev.o xen-common.o xen-bus.o xen-bus-helper.o xen-backend.o +common-obj-$(CONFIG_XEN) += xen-legacy-backend.o xen_devconfig.o xen_pvdev.o xen-bus.o xen-bus-helper.o xen-backend.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen-host-pci-device.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_graphics.o xen_pt_msi.o
include/exec/ram_addr.h +1 -1
@@ -21,7 +21,7 @@#ifndef CONFIG_USER_ONLY #include "cpu.h" -#include "hw/xen/xen.h" +#include "sysemu/xen.h" #include "sysemu/tcg.h" #include "exec/ramlist.h" #include "exec/ramblock.h"
include/hw/xen/xen.h +0 -11
@@ -20,13 +20,6 @@ extern uint32_t xen_domid;extern enum xen_mode xen_mode;extern bool xen_domid_restrict; -extern bool xen_allowed; - -static inline bool xen_enabled (void ) -{ -return xen_allowed; -} -int xen_pci_slot_get_pirq (PCIDevice *pci_dev,int irq_num);void xen_piix3_set_irq (void *opaque,int irq_num,int level);void xen_piix_pci_write_config_client (uint32_t address,uint32_t val,int len);
@@ -39,10 +32,6 @@ void xenstore_store_pv_console_info(int i, struct Chardev *chr);void xen_hvm_init (PCMachineState *pcms,MemoryRegion **ram_memory); -void xen_ram_alloc (ram_addr_t ram_addr,ram_addr_t size, -struct MemoryRegion *mr,Error **errp); -void xen_hvm_modified_memory (ram_addr_t start,ram_addr_t length); -void xen_register_framebuffer (struct MemoryRegion *mr);#endif /* QEMU_HW_XEN_H */
include/sysemu/xen.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* QEMU Xen support +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef SYSEMU_XEN_H +#define SYSEMU_XEN_H + +#ifdef CONFIG_XEN + +bool xen_enabled (void ); + +#ifndef CONFIG_USER_ONLY +void xen_hvm_modified_memory (ram_addr_t start,ram_addr_t length); +void xen_ram_alloc (ram_addr_t ram_addr,ram_addr_t size, +struct MemoryRegion *mr,Error **errp); +#endif + +#else /* !CONFIG_XEN */ + +#define xen_enabled () 0 +#ifndef CONFIG_USER_ONLY +static inline void xen_hvm_modified_memory (ram_addr_t start,ram_addr_t length) +{ +/* nothing */ +} +static inline void xen_ram_alloc (ram_addr_t ram_addr,ram_addr_t size, +MemoryRegion *mr,Error **errp) +{ +g_assert_not_reached (); +} +#endif + +#endif /* CONFIG_XEN */ + +#endif
migration/savevm.c +1 -1
@@ -28,7 +28,6 @@#include "qemu/osdep.h" #include "hw/boards.h" -#include "hw/xen/xen.h" #include "net/net.h" #include "migration.h" #include "migration/snapshot.h"
@@ -59,6 +58,7 @@#include "sysemu/replay.h" #include "sysemu/runstate.h" #include "sysemu/sysemu.h" +#include "sysemu/xen.h" #include "qjson.h" #include "migration/colo.h" #include "qemu/bitmap.h"
softmmu/vl.c +1 -1
@@ -36,6 +36,7 @@#include "sysemu/runstate.h" #include "sysemu/seccomp.h" #include "sysemu/tcg.h" +#include "sysemu/xen.h" #include "qemu/error-report.h" #include "qemu/sockets.h"
@@ -178,7 +179,6 @@ static NotifierList exit_notifiers =static NotifierList machine_init_done_notifiers =NOTIFIER_LIST_INITIALIZER (machine_init_done_notifiers); -bool xen_allowed;uint32_t xen_domid;enum xen_mode xen_mode =XEN_EMULATE ;bool xen_domid_restrict;
stubs/xen-hvm.c +0 -9
@@ -35,11 +35,6 @@ int xen_is_pirq_msi(uint32_t msi_data)return 0 ; } -void xen_ram_alloc (ram_addr_t ram_addr,ram_addr_t size,MemoryRegion *mr, -Error **errp) -{ -} -qemu_irq *xen_interrupt_controller_init (void ) {return NULL ;
@@ -49,10 +44,6 @@ void xen_register_framebuffer(MemoryRegion *mr) { } -void xen_hvm_modified_memory (ram_addr_t start,ram_addr_t length) -{ -} -void xen_hvm_init (PCMachineState *pcms,MemoryRegion **ram_memory) { }
target/i386/cpu.c +1 -1
@@ -29,6 +29,7 @@#include "sysemu/reset.h" #include "sysemu/hvf.h" #include "sysemu/cpus.h" +#include "sysemu/xen.h" #include "kvm_i386.h" #include "sev_i386.h"
@@ -54,7 +55,6 @@#include "hw/i386/topology.h" #ifndef CONFIG_USER_ONLY #include "exec/address-spaces.h" -#include "hw/xen/xen.h" #include "hw/i386/apic_internal.h" #include "hw/boards.h" #endif
Signature · 1 line
2.26.2
[PULL 038/115] hw/i386/vmport: Assert vmport initialized before registering commands
In reply to Paolo BonziniFrom: Liran Alon <[email protected]>
vmport_register() is also called from other modules such as vmmouse. Therefore, these modules rely that vmport is realized before those call sites. If this is violated, vmport_register() will NULL-deref.
To make such issues easier to debug, assert in vmport_register() that vmport is already realized.
Message-Id: <[email protected]>
--- hw/i386/vmport.c | 2 ++ 1 file changed, 2 insertions(+)
hw/i386/vmport.c +2 -0
@@ -81,6 +81,8 @@ static VMPortState *port_state;void vmport_register (VMPortCommand command,VMPortReadFunc *func,void *opaque) {assert (command <VMPORT_ENTRIES ); +assert (port_state); +trace_vmport_register (command, func, opaque); port_state->func[command] = func; port_state->opaque[command] = opaque;
Signature · 1 line
2.26.2
[PULL 042/115] qom/object: simplify type_initialize_interface()
In reply to Paolo BonziniFrom: Masahiro Yamada <[email protected]>
iface_impl->class is the same as new_iface. Make it more readable.
Message-Id: <[email protected]>
--- qom/object.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
qom/object.c +1 -2
@@ -262,8 +262,7 @@ static void type_initialize_interface(TypeImpl *ti, TypeImpl *interface_type, new_iface->concrete_class = ti->class; new_iface->interface_type = interface_type; - ti->class->interfaces =g_slist_append (ti->class->interfaces, - iface_impl->class); + ti->class->interfaces =g_slist_append (ti->class->interfaces, new_iface); }static void object_property_free (gpointer data)
Signature · 1 line
2.26.2
[PULL 014/115] qom/object: Move Object typedef to 'qemu/typedefs.h'
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
We use the Object type all over the place.
Forward declare it in "qemu/typedefs.h".
Message-Id: <[email protected]>
--- hw/block/vhost-user-blk.c | 1 - hw/pci-host/pam.c | 1 - hw/scsi/vhost-user-scsi.c | 1 - include/hw/display/edid.h | 3 --- include/qemu/typedefs.h | 1 + include/qom/object.h | 2 -- include/qom/qom-qobject.h | 2 -- include/sysemu/sysemu.h | 1 - stubs/qmp_memory_device.c | 1 - 9 files changed, 1 insertion(+), 12 deletions(-)
hw/block/vhost-user-blk.c +0 -1
@@ -20,7 +20,6 @@#include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/cutils.h" -#include "qom/object.h" #include "hw/qdev-core.h" #include "hw/qdev-properties.h" #include "hw/virtio/vhost.h"
hw/pci-host/pam.c +0 -1
@@ -28,7 +28,6 @@*/ #include "qemu/osdep.h" -#include "qom/object.h" #include "hw/pci-host/pam.h" void init_pam(DeviceState *dev, MemoryRegion *ram_memory,
hw/scsi/vhost-user-scsi.c +0 -1
@@ -18,7 +18,6 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/error-report.h" -#include "qom/object.h" #include "hw/fw-path-provider.h" #include "hw/qdev-core.h" #include "hw/qdev-properties.h"
include/hw/display/edid.h +0 -3
@@ -1,9 +1,6 @@ #ifndef EDID_H #define EDID_H -#include "qom/object.h" -#include "hw/qdev-properties.h" - typedef struct qemu_edid_info { const char *vendor; /* http://www.uefi.org/pnp_id_list */ const char *name;
include/qemu/typedefs.h +1 -0
@@ -76,6 +76,7 @@ typedef struct NetFilterState NetFilterState;typedef struct NICInfo NICInfo ;typedef struct NodeInfo NodeInfo ;typedef struct NumaNodeMem NumaNodeMem ; +typedef struct Object Object ;typedef struct ObjectClass ObjectClass ;typedef struct PCIBridge PCIBridge ;typedef struct PCIBus PCIBus ;
include/qom/object.h +0 -2
@@ -20,8 +20,6 @@struct TypeImpl ;typedef struct TypeImpl *Type ; -typedef struct Object Object ; -typedef struct TypeInfo TypeInfo ;typedef struct InterfaceClass InterfaceClass ;
include/qom/qom-qobject.h +0 -2
@@ -13,8 +13,6 @@#ifndef QEMU_QOM_QOBJECT_H #define QEMU_QOM_QOBJECT_H -#include "qom/object.h" -/* * object_property_get_qobject: * @obj: the object
include/sysemu/sysemu.h +0 -1
@@ -5,7 +5,6 @@#include "qemu/timer.h" #include "qemu/notify.h" #include "qemu/uuid.h" -#include "qom/object.h" /* vl.c */
stubs/qmp_memory_device.c +0 -1
@@ -1,5 +1,4 @@#include "qemu/osdep.h" -#include "qom/object.h" #include "hw/mem/memory-device.h" MemoryDeviceInfoList *qmp_memory_device_list (void )
Signature · 1 line
2.26.2
[PULL 044/115] qom/container: remove .instance_size initializer from container_info
In reply to Paolo BonziniFrom: Masahiro Yamada <[email protected]>
You can omit .instance_size if it is the same as that of the parent.
.class_size = sizeof(ObjectClass)
... is omitted here, so removing .instance_size is more consistent.
Message-Id: <[email protected]>
--- qom/container.c | 1 - 1 file changed, 1 deletion(-)
qom/container.c +0 -1
@@ -16,7 +16,6 @@static const TypeInfo container_info = { .name ="container" , - .instance_size =sizeof (Object), .parent =TYPE_OBJECT , };
Signature · 1 line
2.26.2
[PULL 043/115] qom/object: pass (Object *) to object_initialize_with_type()
In reply to Paolo BonziniFrom: Masahiro Yamada <[email protected]>
object_new_with_type() already passes (Object *) pointer. Avoid casting back and forth.
Message-Id: <[email protected]>
--- qom/object.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
qom/object.c +1 -3
@@ -494,10 +494,8 @@ static void object_class_property_init_all(Object *obj) } } -static void object_initialize_with_type (void *data,size_t size,TypeImpl *type) +static void object_initialize_with_type (Object *obj,size_t size,TypeImpl *type) { -Object *obj = data; -type_initialize (type);g_assert (type->instance_size >=sizeof (Object));
Signature · 1 line
2.26.2
[PULL 037/115] hw/i386/vmport: Add support for CMD_GETHZ
In reply to Paolo BonziniFrom: Liran Alon <[email protected]>
This command returns to guest information on LAPIC bus frequency and TSC frequency.
One can see how this interface is used by Linux vmware_platform_setup() introduced in Linux commit 88b094fb8d4f ("x86: Hypervisor detection and get tsc_freq from hypervisor").
Message-Id: <[email protected]>
--- hw/i386/vmport.c | 19 +++++++++++++++++++ include/hw/i386/vmport.h | 1 + 2 files changed, 20 insertions(+)
hw/i386/vmport.c +19 -0
@@ -174,6 +174,24 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr)return ram_size; } +static uint32_t vmport_cmd_get_hz (void *opaque,uint32_t addr) +{ +X86CPU *cpu =X86_CPU (current_cpu); + +if (cpu->env.tsc_khz && cpu->env.apic_bus_freq) { +uint64_t tsc_freq = (uint64_t )cpu->env.tsc_khz *1000 ; + + cpu->env.regs[R_ECX ] = cpu->env.apic_bus_freq; + cpu->env.regs[R_EBX ] = (uint32_t )(tsc_freq >>32 ); + cpu->env.regs[R_EAX ] = (uint32_t )tsc_freq; + }else { +/* Signal cmd as not supported */ + cpu->env.regs[R_EBX ] =UINT32_MAX ; + } + +return cpu->env.regs[R_EAX ]; +} +static uint32_t vmport_cmd_get_vcpu_info (void *opaque,uint32_t addr) {X86CPU *cpu =X86_CPU (current_cpu);
@@ -211,6 +229,7 @@ static void vmport_realizefn(DeviceState *dev, Error **errp)vmport_register (VMPORT_CMD_GETRAMSIZE , vmport_cmd_ram_size,NULL );if (s->compat_flags &VMPORT_COMPAT_CMDS_V2 ) {vmport_register (VMPORT_CMD_GETBIOSUUID , vmport_cmd_get_bios_uuid,NULL ); +vmport_register (VMPORT_CMD_GETHZ , vmport_cmd_get_hz,NULL );vmport_register (VMPORT_CMD_GET_VCPU_INFO , vmport_cmd_get_vcpu_info,NULL ); }
include/hw/i386/vmport.h +1 -0
@@ -13,6 +13,7 @@ typedef enum {VMPORT_CMD_VMMOUSE_DATA =39 ,VMPORT_CMD_VMMOUSE_STATUS =40 ,VMPORT_CMD_VMMOUSE_COMMAND =41 , +VMPORT_CMD_GETHZ =45 ,VMPORT_CMD_GET_VCPU_INFO =68 , VMPORT_ENTRIES } VMPortCommand;
Signature · 1 line
2.26.2
[PULL 035/115] hw/i386/vmport: Allow x2apic without IR
In reply to Paolo BonziniFrom: Liran Alon <[email protected]>
Signal to guest that hypervisor supports x2apic without VT-d/IOMMU Interrupt-Remapping support. This allows guest to use x2apic in case all APIC IDs fits in 8-bit (i.e. Max APIC ID < 255).
See Linux kernel commit 4cca6ea04d31 ("x86/apic: Allow x2apic without IR on VMware platform") and Linux try_to_enable_x2apic() function.
Message-Id: <[email protected]>
--- hw/i386/vmport.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
hw/i386/vmport.c +8 -1
@@ -176,7 +176,14 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr)static uint32_t vmport_cmd_get_vcpu_info (void *opaque,uint32_t addr) { -return 1 <<VCPU_INFO_RESERVED_BIT ; +X86CPU *cpu =X86_CPU (current_cpu); +uint32_t ret =0 ; + +if (cpu->env.features[FEAT_1_ECX ] &CPUID_EXT_X2APIC ) { + ret |=1 <<VCPU_INFO_LEGACY_X2APIC_BIT ; + } + +return ret; }static const MemoryRegionOps vmport_ops = {
Signature · 1 line
2.26.2
[PULL 046/115] hax: Dynamic allocate vcpu state structure
In reply to Paolo BonziniFrom: WangBowen <[email protected]>
Dynamic allocating vcpu state structure according to smp value to be more precise and safe. Previously it will alloccate array of fixed size HAX_MAX_VCPU.
This is achieved by using g_new0 to dynamic allocate the array. The allocated size is obtained from smp.max_cpus in MachineState. Also, the size is compared with HAX_MAX_VCPU when creating the vm. The reason for choosing dynamic array over linked list is because the status is visited by index all the time.
This will lead to QEMU checking whether the smp value is larger than the HAX_MAX_VCPU when creating vm, if larger, the process will terminate, otherwise it will allocate array of size smp to store the status.
V2: Check max_cpus before open vm. (Philippe)
Message-Id: <[email protected]>
--- target/i386/hax-all.c | 25 +++++++++++++++++++------ target/i386/hax-i386.h | 5 +++-- 2 files changed, 22 insertions(+), 8 deletions(-)
target/i386/hax-all.c +19 -6
@@ -232,10 +232,10 @@ int hax_init_vcpu(CPUState *cpu)return ret; } -struct hax_vm *hax_vm_create (struct hax_state *hax) +struct hax_vm *hax_vm_create (struct hax_state *hax,int max_cpus) {struct hax_vm *vm; -int vm_id =0 , ret; +int vm_id =0 , ret, i;if (hax_invalid_fd (hax->fd)) {return NULL ;
@@ -245,6 +245,11 @@ struct hax_vm *hax_vm_create(struct hax_state *hax)return hax->vm; } +if (max_cpus >HAX_MAX_VCPU ) { +fprintf (stderr,"Maximum VCPU number QEMU supported is %d\n" ,HAX_MAX_VCPU ); +return NULL ; + } + vm = g_new0(struct hax_vm, 1); ret =hax_host_create_vm (hax, &vm_id);
@@ -259,6 +264,12 @@ struct hax_vm *hax_vm_create(struct hax_state *hax) goto error; } + vm->numvcpus = max_cpus; + vm->vcpus = g_new0(struct hax_vcpu_state *, vm->numvcpus); +for (i =0 ; i < vm->numvcpus; i++) { + vm->vcpus[i] =NULL ; + } + hax->vm = vm;return vm;
@@ -272,12 +283,14 @@ int hax_vm_destroy(struct hax_vm *vm) {int i; -for (i =0 ; i <HAX_MAX_VCPU ; i++) +for (i =0 ; i < vm->numvcpus; i++)if (vm->vcpus[i]) {fprintf (stderr,"VCPU should be cleaned before vm clean\n" );return -1 ; }hax_close_fd (vm->fd); + vm->numvcpus =0 ; +g_free (vm->vcpus);g_free (vm); hax_global.vm =NULL ;return 0 ;
@@ -292,7 +305,7 @@ static void hax_handle_interrupt(CPUState *cpu, int mask) } } -static int hax_init (ram_addr_t ram_size) +static int hax_init (ram_addr_t ram_size,int max_cpus) {struct hax_state *hax =NULL ;struct hax_qemu_version qversion;
@@ -324,7 +337,7 @@ static int hax_init(ram_addr_t ram_size) goto error; } - hax->vm =hax_vm_create (hax); + hax->vm =hax_vm_create (hax, max_cpus);if (!hax->vm) {fprintf (stderr,"Failed to create HAX VM\n" ); ret = -EINVAL ;
@@ -352,7 +365,7 @@ static int hax_init(ram_addr_t ram_size)static int hax_accel_init (MachineState *ms) { -int ret =hax_init (ms->ram_size); +int ret =hax_init (ms->ram_size, (int )ms->smp.max_cpus);if (ret && (ret != -ENOSPC )) {fprintf (stderr,"No accelerator found.\n" );
target/i386/hax-i386.h +3 -2
@@ -47,7 +47,8 @@ struct hax_state {struct hax_vm {hax_fd fd;int id; -struct hax_vcpu_state *vcpus[HAX_MAX_VCPU ]; +int numvcpus; +struct hax_vcpu_state **vcpus; };#ifdef NEED_CPU_H
@@ -58,7 +59,7 @@ int valid_hax_tunnel_size(uint16_t size);/* Host specific functions */ int hax_mod_version (struct hax_state *hax,struct hax_module_version *version);int hax_inject_interrupt (CPUArchState *env,int vector); -struct hax_vm *hax_vm_create (struct hax_state *hax); +struct hax_vm *hax_vm_create (struct hax_state *hax,int max_cpus);int hax_vcpu_run (struct hax_vcpu_state *vcpu);int hax_vcpu_create (int id); int hax_sync_vcpu_state(CPUArchState *env, struct vcpu_state_t *state,
Signature · 1 line
2.26.2
[PULL 045/115] cpus: Fix botched configure_icount() error API violation fix
In reply to Paolo BonziniFrom: Markus Armbruster <[email protected]>
Before recent commit abc9bf69a66, configure_icount() returned early when option "shift" was absent: succeed when option "align" was also absent, else fail.
Since then, it still errors out when only "align" is present, but continues when both are absent. Crashes when examining the value of "shift" further. Reproducer: -icount "".
Revert this erroneous part of the commit.
Message-Id: <[email protected]>
--- cpus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
cpus.c +4 -2
@@ -821,8 +821,10 @@ void configure_icount(QemuOpts *opts, Error **errp)bool align =qemu_opt_get_bool (opts,"align" , false);long time_shift =-1 ; -if (!option &&qemu_opt_get (opts,"align" )) { -error_setg (errp,"Please specify shift option when using align" ); +if (!option) { +if (qemu_opt_get (opts,"align" ) !=NULL ) { +error_setg (errp,"Please specify shift option when using align" ); + }return ; }
Signature · 1 line
2.26.2
[PULL 024/115] target/i386: fix phadd* with identical destination and source register
In reply to Paolo BonziniFrom: Janne Grunau <[email protected]>
Detected by asm test suite failures in dav1d
(https://code.videolan.org/videolan/dav1d). Can be reproduced by qemu-x86_64 -cpu core2duo ./tests/checkasm --test=mc_8bpc 1659890620.
Message-Id: <[email protected]>
--- target/i386/ops_sse.h | 53 +++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 20 deletions(-)
target/i386/ops_sse.h +33 -20
@@ -1435,34 +1435,47 @@ void glue(helper_pshufb, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)void glue (helper_phaddw ,SUFFIX )(CPUX86State *env,Reg *d,Reg *s) { - d->W (0 ) = (int16_t )d->W (0 ) + (int16_t )d->W (1 ); - d->W (1 ) = (int16_t )d->W (2 ) + (int16_t )d->W (3 ); -XMM_ONLY (d->W (2 ) = (int16_t )d->W (4 ) + (int16_t )d->W (5 )); -XMM_ONLY (d->W (3 ) = (int16_t )d->W (6 ) + (int16_t )d->W (7 )); - d->W ((2 <<SHIFT ) +0 ) = (int16_t )s->W (0 ) + (int16_t )s->W (1 ); - d->W ((2 <<SHIFT ) +1 ) = (int16_t )s->W (2 ) + (int16_t )s->W (3 ); -XMM_ONLY (d->W (6 ) = (int16_t )s->W (4 ) + (int16_t )s->W (5 )); -XMM_ONLY (d->W (7 ) = (int16_t )s->W (6 ) + (int16_t )s->W (7 )); + +Reg r; + + r.W (0 ) = (int16_t )d->W (0 ) + (int16_t )d->W (1 ); + r.W (1 ) = (int16_t )d->W (2 ) + (int16_t )d->W (3 ); +XMM_ONLY (r.W (2 ) = (int16_t )d->W (4 ) + (int16_t )d->W (5 )); +XMM_ONLY (r.W (3 ) = (int16_t )d->W (6 ) + (int16_t )d->W (7 )); + r.W ((2 <<SHIFT ) +0 ) = (int16_t )s->W (0 ) + (int16_t )s->W (1 ); + r.W ((2 <<SHIFT ) +1 ) = (int16_t )s->W (2 ) + (int16_t )s->W (3 ); +XMM_ONLY (r.W (6 ) = (int16_t )s->W (4 ) + (int16_t )s->W (5 )); +XMM_ONLY (r.W (7 ) = (int16_t )s->W (6 ) + (int16_t )s->W (7 )); + + *d = r; }void glue (helper_phaddd ,SUFFIX )(CPUX86State *env,Reg *d,Reg *s) { - d->L (0 ) = (int32_t )d->L (0 ) + (int32_t )d->L (1 ); -XMM_ONLY (d->L (1 ) = (int32_t )d->L (2 ) + (int32_t )d->L (3 )); - d->L ((1 <<SHIFT ) +0 ) = (int32_t )s->L (0 ) + (int32_t )s->L (1 ); -XMM_ONLY (d->L (3 ) = (int32_t )s->L (2 ) + (int32_t )s->L (3 )); +Reg r; + + r.L (0 ) = (int32_t )d->L (0 ) + (int32_t )d->L (1 ); +XMM_ONLY (r.L (1 ) = (int32_t )d->L (2 ) + (int32_t )d->L (3 )); + r.L ((1 <<SHIFT ) +0 ) = (int32_t )s->L (0 ) + (int32_t )s->L (1 ); +XMM_ONLY (r.L (3 ) = (int32_t )s->L (2 ) + (int32_t )s->L (3 )); + + *d = r; }void glue (helper_phaddsw ,SUFFIX )(CPUX86State *env,Reg *d,Reg *s) { - d->W (0 ) =satsw ((int16_t )d->W (0 ) + (int16_t )d->W (1 )); - d->W (1 ) =satsw ((int16_t )d->W (2 ) + (int16_t )d->W (3 )); -XMM_ONLY (d->W (2 ) =satsw ((int16_t )d->W (4 ) + (int16_t )d->W (5 ))); -XMM_ONLY (d->W (3 ) =satsw ((int16_t )d->W (6 ) + (int16_t )d->W (7 ))); - d->W ((2 <<SHIFT ) +0 ) =satsw ((int16_t )s->W (0 ) + (int16_t )s->W (1 )); - d->W ((2 <<SHIFT ) +1 ) =satsw ((int16_t )s->W (2 ) + (int16_t )s->W (3 )); -XMM_ONLY (d->W (6 ) =satsw ((int16_t )s->W (4 ) + (int16_t )s->W (5 ))); -XMM_ONLY (d->W (7 ) =satsw ((int16_t )s->W (6 ) + (int16_t )s->W (7 ))); +Reg r; + + r.W (0 ) =satsw ((int16_t )d->W (0 ) + (int16_t )d->W (1 )); + r.W (1 ) =satsw ((int16_t )d->W (2 ) + (int16_t )d->W (3 )); +XMM_ONLY (r.W (2 ) =satsw ((int16_t )d->W (4 ) + (int16_t )d->W (5 ))); +XMM_ONLY (r.W (3 ) =satsw ((int16_t )d->W (6 ) + (int16_t )d->W (7 ))); + r.W ((2 <<SHIFT ) +0 ) =satsw ((int16_t )s->W (0 ) + (int16_t )s->W (1 )); + r.W ((2 <<SHIFT ) +1 ) =satsw ((int16_t )s->W (2 ) + (int16_t )s->W (3 )); +XMM_ONLY (r.W (6 ) =satsw ((int16_t )s->W (4 ) + (int16_t )s->W (5 ))); +XMM_ONLY (r.W (7 ) =satsw ((int16_t )s->W (6 ) + (int16_t )s->W (7 ))); + + *d = r; }void glue (helper_pmaddubsw ,SUFFIX )(CPUX86State *env,Reg *d,Reg *s)
Signature · 1 line
2.26.2
[PULL 034/115] hw/i386/vmport: Add support for CMD_GET_VCPU_INFO
In reply to Paolo BonziniFrom: Liran Alon <[email protected]>
Command currently returns that it is unimplemented by setting the reserved-bit in it's return value.
Following patches will return various useful vCPU information to guest.
Message-Id: <[email protected]>
--- hw/i386/vmport.c | 14 ++++++++++++++ include/hw/i386/vmport.h | 1 + 2 files changed, 15 insertions(+)
hw/i386/vmport.c +14 -0
@@ -54,6 +54,13 @@#define VMPORT_COMPAT_CMDS_V2 \ (1 << VMPORT_COMPAT_CMDS_V2_BIT) +/* vCPU features reported by CMD_GET_VCPU_INFO */ +#define VCPU_INFO_SLC64_BIT 0 +#define VCPU_INFO_SYNC_VTSCS_BIT 1 +#define VCPU_INFO_HV_REPLAY_OK_BIT 2 +#define VCPU_INFO_LEGACY_X2APIC_BIT 3 +#define VCPU_INFO_RESERVED_BIT 31 +#define VMPORT (obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT) typedef struct VMPortState {
@@ -167,6 +174,11 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr)return ram_size; } +static uint32_t vmport_cmd_get_vcpu_info (void *opaque,uint32_t addr) +{ +return 1 <<VCPU_INFO_RESERVED_BIT ; +} +static const MemoryRegionOps vmport_ops = { .read = vmport_ioport_read, .write = vmport_ioport_write,
@@ -192,6 +204,8 @@ static void vmport_realizefn(DeviceState *dev, Error **errp)vmport_register (VMPORT_CMD_GETRAMSIZE , vmport_cmd_ram_size,NULL );if (s->compat_flags &VMPORT_COMPAT_CMDS_V2 ) {vmport_register (VMPORT_CMD_GETBIOSUUID , vmport_cmd_get_bios_uuid,NULL ); +vmport_register (VMPORT_CMD_GET_VCPU_INFO , vmport_cmd_get_vcpu_info, +NULL ); } }
include/hw/i386/vmport.h +1 -0
@@ -13,6 +13,7 @@ typedef enum {VMPORT_CMD_VMMOUSE_DATA =39 ,VMPORT_CMD_VMMOUSE_STATUS =40 ,VMPORT_CMD_VMMOUSE_COMMAND =41 , +VMPORT_CMD_GET_VCPU_INFO =68 , VMPORT_ENTRIES } VMPortCommand;
Signature · 1 line
2.26.2
[PULL 055/115] target/i386: fix fscale handling of rounding precision
In reply to Paolo BonziniFrom: Joseph Myers <[email protected]>
The fscale implementation uses floatx80_scalbn for the final scaling operation. floatx80_scalbn ends up rounding the result using the dynamic rounding precision configured for the FPU. But only a limited set of x87 floating-point instructions are supposed to respect the dynamic rounding precision, and fscale is not in that set. Fix the implementation to save and restore the rounding precision around the call to floatx80_scalbn.
Message-Id: <[email protected]>
--- target/i386/fpu_helper.c | 3 +++ tests/tcg/i386/test-i386-fscale.c | 13 +++++++++++++ 2 files changed, 16 insertions(+)
target/i386/fpu_helper.c +3 -0
@@ -1001,7 +1001,10 @@ void helper_fscale(CPUX86State *env) } }else {int n =floatx80_to_int32_round_to_zero (ST1 , &env->fp_status); +signed char save = env->fp_status.floatx80_rounding_precision; + env->fp_status.floatx80_rounding_precision =80 ;ST0 =floatx80_scalbn (ST0 , n, &env->fp_status); + env->fp_status.floatx80_rounding_precision = save; } }
tests/tcg/i386/test-i386-fscale.c +13 -0
@@ -8,6 +8,8 @@ union u {long double ld; }; +volatile long double ld_third =1.0L /3.0L ; +volatile long double ld_four_thirds =4.0L /3.0L ;volatile union u ld_invalid_1 = { .s = {1 ,1234 } };volatile union u ld_invalid_2 = { .s = {0 ,1234 } };volatile union u ld_invalid_3 = { .s = {0 ,0x7fff } };
@@ -91,5 +93,16 @@ int main(void)printf ("FAIL: fscale finite down inf\n" ); ret =1 ; } +/* Set round-to-nearest with single-precision rounding. */ + cw = cw & ~0xf00 ; + __asm__volatile ("fldcw %0" : :"m" (cw)); + __asm__volatile ("fscale" :"=t" (ld_res) : +"0" (ld_third),"u" (2.0L )); + cw = cw |0x300 ; + __asm__volatile ("fldcw %0" : :"m" (cw)); +if (ld_res != ld_four_thirds) { +printf ("FAIL: fscale single-precision\n" ); + ret =1 ; + }return ret; }
Signature · 1 line
2.26.2
[PULL 051/115] target/i386: implement special cases for fxtract
In reply to Paolo BonziniFrom: Joseph Myers <[email protected]>
The implementation of the fxtract instruction treats all nonzero operands as normal numbers, so yielding incorrect results for invalid formats, infinities, NaNs and subnormal and pseudo-denormal operands. Implement appropriate handling of all those cases.
Message-Id: <[email protected]>
--- target/i386/fpu_helper.c | 25 +++++- tests/tcg/i386/test-i386-fxtract.c | 120 +++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/i386/test-i386-fxtract.c
target/i386/fpu_helper.c +24 -1
@@ -767,10 +767,33 @@ void helper_fxtract(CPUX86State *env) &env->fp_status);fpush (env);ST0 = temp.d; + }else if (floatx80_invalid_encoding (ST0 )) { +float_raise (float_flag_invalid, &env->fp_status); +ST0 =floatx80_default_nan (&env->fp_status); +fpush (env); +ST0 =ST1 ; + }else if (floatx80_is_any_nan (ST0 )) { +if (floatx80_is_signaling_nan (ST0 , &env->fp_status)) { +float_raise (float_flag_invalid, &env->fp_status); +ST0 =floatx80_silence_nan (ST0 , &env->fp_status); + } +fpush (env); +ST0 =ST1 ; + }else if (floatx80_is_infinity (ST0 )) { +fpush (env); +ST0 =ST1 ; +ST1 = floatx80_infinity; }else {int expdif; - expdif =EXPD (temp) -EXPBIAS ; +if (EXPD (temp) ==0 ) { +int shift =clz64 (temp.l.lower); + temp.l.lower <<= shift; + expdif =1 -EXPBIAS - shift; +float_raise (float_flag_input_denormal, &env->fp_status); + }else { + expdif =EXPD (temp) -EXPBIAS ; + }/* DP exponent bias */ ST0 =int32_to_floatx80 (expdif, &env->fp_status);fpush (env);
tests/tcg/i386/test-i386-fxtract.c new file +120 -0
120 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 048/115] megasas: use unsigned type for reply_queue_head and check index
In reply to Paolo BonziniFrom: Prasad J Pandit <[email protected]>
A guest user may set 'reply_queue_head' field of MegasasState to a negative value. Later in 'megasas_lookup_frame' it is used to index into s->frames[] array. Use unsigned type to avoid OOB access issue.
Also check that 'index' value stays within s->frames[] bounds through the while() loop in 'megasas_lookup_frame' to avoid OOB access.
Message-Id: <[email protected]>
--- hw/scsi/megasas.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/scsi/megasas.c +2 -2
@@ -112,7 +112,7 @@ typedef struct MegasasState {uint64_t reply_queue_pa;void *reply_queue;int reply_queue_len; -int reply_queue_head; +uint16_t reply_queue_head;int reply_queue_tail;uint64_t consumer_pa;uint64_t producer_pa;
@@ -445,7 +445,7 @@ static MegasasCmd *megasas_lookup_frame(MegasasState *s, index = s->reply_queue_head; -while (num < s->fw_cmds) { +while (num < s->fw_cmds && index <MEGASAS_MAX_FRAMES ) {if (s->frames[index].pa && s->frames[index].pa == frame) { cmd = &s->frames[index];break ;
Signature · 1 line
2.26.2
[PULL 041/115] qom/object: factor out the initialization of hash table of properties
In reply to Paolo BonziniFrom: Masahiro Yamada <[email protected]>
Properties are not related to the initialization of interfaces.
The initialization of the hash table can be moved after the if-block, and unified.
Message-Id: <[email protected]>
--- qom/object.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
qom/object.c +3 -5
@@ -316,8 +316,6 @@ static void type_initialize(TypeImpl *ti)g_assert (parent->instance_size <= ti->instance_size);memcpy (ti->class, parent->class, parent->class_size); ti->class->interfaces =NULL ; - ti->class->properties =g_hash_table_new_full ( - g_str_hash, g_str_equal,NULL , object_property_free);for (e = parent->class->interfaces; e; e = e->next) {InterfaceClass *iface = e->data;
@@ -347,11 +345,11 @@ static void type_initialize(TypeImpl *ti)type_initialize_interface (ti, t, t); } - }else { - ti->class->properties =g_hash_table_new_full ( - g_str_hash, g_str_equal,NULL , object_property_free); } + ti->class->properties =g_hash_table_new_full (g_str_hash, g_str_equal,NULL , + object_property_free); + ti->class->type = ti;while (parent) {
Signature · 1 line
2.26.2
[PULL 064/115] target/i386: fix fisttpl, fisttpll handling of out-of-range values
In reply to Paolo BonziniFrom: Joseph Myers <[email protected]>
The fist / fistt family of instructions should all store the most negative integer in the destination format when the rounded / truncated integer result is out of range or the input is an invalid encoding, infinity or NaN. The fisttpl and fisttpll implementations (32-bit and 64-bit results, truncate towards zero) failed to do this, producing the most positive integer in some cases instead. Fix this by copying the code used to handle this issue for fistpl and fistpll, adjusted to use the _round_to_zero functions for the actual conversion (but without any other changes to that code).
Message-Id: <[email protected]>
--- target/i386/fpu_helper.c | 28 ++++++++- tests/tcg/i386/test-i386-fisttp.c | 100 ++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 tests/tcg/i386/test-i386-fisttp.c
target/i386/fpu_helper.c +26 -2
@@ -338,12 +338,36 @@ int32_t helper_fistt_ST0(CPUX86State *env)int32_t helper_fisttl_ST0 (CPUX86State *env) { -return floatx80_to_int32_round_to_zero (ST0 , &env->fp_status); +int32_t val; +signed char old_exp_flags; + + old_exp_flags =get_float_exception_flags (&env->fp_status); +set_float_exception_flags (0 , &env->fp_status); + + val =floatx80_to_int32_round_to_zero (ST0 , &env->fp_status); +if (get_float_exception_flags (&env->fp_status) & float_flag_invalid) { + val =0x80000000 ; + } +set_float_exception_flags (get_float_exception_flags (&env->fp_status) + | old_exp_flags, &env->fp_status); +return val; }int64_t helper_fisttll_ST0 (CPUX86State *env) { -return floatx80_to_int64_round_to_zero (ST0 , &env->fp_status); +int64_t val; +signed char old_exp_flags; + + old_exp_flags =get_float_exception_flags (&env->fp_status); +set_float_exception_flags (0 , &env->fp_status); + + val =floatx80_to_int64_round_to_zero (ST0 , &env->fp_status); +if (get_float_exception_flags (&env->fp_status) & float_flag_invalid) { + val =0x8000000000000000ULL ; + } +set_float_exception_flags (get_float_exception_flags (&env->fp_status) + | old_exp_flags, &env->fp_status); +return val; }void helper_fldt_ST0 (CPUX86State *env,target_ulong ptr)
tests/tcg/i386/test-i386-fisttp.c new file +100 -0
100 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 053/115] target/i386: fix fscale handling of invalid exponent encodings
In reply to Paolo BonziniFrom: Joseph Myers <[email protected]>
The fscale implementation does not check for invalid encodings in the exponent operand, thus treating them like INT_MIN (the value returned for invalid encodings by floatx80_to_int32_round_to_zero). Fix it to treat them similarly to signaling NaN exponents, thus generating a quiet NaN result.
Message-Id: <[email protected]>
--- target/i386/fpu_helper.c | 5 ++++- tests/tcg/i386/test-i386-fscale.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-)
target/i386/fpu_helper.c +4 -1
@@ -968,7 +968,10 @@ void helper_frndint(CPUX86State *env)void helper_fscale (CPUX86State *env) { -if (floatx80_is_any_nan (ST1 )) { +if (floatx80_invalid_encoding (ST1 )) { +float_raise (float_flag_invalid, &env->fp_status); +ST0 =floatx80_default_nan (&env->fp_status); + }else if (floatx80_is_any_nan (ST1 )) {ST0 =ST1 ;if (floatx80_is_signaling_nan (ST0 , &env->fp_status)) {float_raise (float_flag_invalid, &env->fp_status);
tests/tcg/i386/test-i386-fscale.c +29 -0
@@ -8,6 +8,11 @@ union u {long double ld; }; +volatile union u ld_invalid_1 = { .s = {1 ,1234 } }; +volatile union u ld_invalid_2 = { .s = {0 ,1234 } }; +volatile union u ld_invalid_3 = { .s = {0 ,0x7fff } }; +volatile union u ld_invalid_4 = { .s = { (UINT64_C (1 ) <<63 ) -1 ,0x7fff } }; +volatile long double ld_res;int isnan_ld (long double x)
@@ -33,5 +38,29 @@ int main(void)printf ("FAIL: fscale snan\n" ); ret =1 ; } + __asm__volatile ("fscale" :"=t" (ld_res) : +"0" (2.5L ),"u" (ld_invalid_1.ld)); +if (!isnan_ld (ld_res) ||issignaling_ld (ld_res)) { +printf ("FAIL: fscale invalid 1\n" ); + ret =1 ; + } + __asm__volatile ("fscale" :"=t" (ld_res) : +"0" (2.5L ),"u" (ld_invalid_2.ld)); +if (!isnan_ld (ld_res) ||issignaling_ld (ld_res)) { +printf ("FAIL: fscale invalid 2\n" ); + ret =1 ; + } + __asm__volatile ("fscale" :"=t" (ld_res) : +"0" (2.5L ),"u" (ld_invalid_3.ld)); +if (!isnan_ld (ld_res) ||issignaling_ld (ld_res)) { +printf ("FAIL: fscale invalid 3\n" ); + ret =1 ; + } + __asm__volatile ("fscale" :"=t" (ld_res) : +"0" (2.5L ),"u" (ld_invalid_4.ld)); +if (!isnan_ld (ld_res) ||issignaling_ld (ld_res)) { +printf ("FAIL: fscale invalid 4\n" ); + ret =1 ; + }return ret; }
Signature · 1 line
2.26.2
[PULL 031/115] hw/i386/vmport: Introduce vmport.h
In reply to Paolo BonziniFrom: Liran Alon <[email protected]>
No functional change. This is mere refactoring.
Message-Id: <[email protected]>
--- hw/i386/pc.c | 2 +- hw/i386/vmmouse.c | 2 +- hw/i386/vmport.c | 2 +- hw/i386/vmport.h | 34 ---------------------------------- include/hw/i386/vmport.h | 16 ++++++++++++++++ 5 files changed, 19 insertions(+), 37 deletions(-) delete mode 100644 hw/i386/vmport.h create mode 100644 include/hw/i386/vmport.h
hw/i386/pc.c +1 -1
@@ -31,6 +31,7 @@#include "hw/i386/apic.h" #include "hw/i386/topology.h" #include "hw/i386/fw_cfg.h" +#include "hw/i386/vmport.h" #include "sysemu/cpus.h" #include "hw/block/fdc.h" #include "hw/ide.h"
@@ -91,7 +92,6 @@#include "qapi/qmp/qerror.h" #include "config-devices.h" #include "e820_memory_layout.h" -#include "vmport.h" #include "fw_cfg.h" #include "trace.h"
hw/i386/vmmouse.c +1 -1
@@ -25,10 +25,10 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "ui/console.h" +#include "hw/i386/vmport.h" #include "hw/input/i8042.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" -#include "vmport.h" #include "cpu.h" /* debug only vmmouse */
hw/i386/vmport.c +1 -1
@@ -30,10 +30,10 @@#include "qemu/osdep.h" #include "hw/isa/isa.h" +#include "hw/i386/vmport.h" #include "hw/qdev-properties.h" #include "sysemu/hw_accel.h" #include "qemu/log.h" -#include "vmport.h" #include "cpu.h" #include "trace.h"
hw/i386/vmport.h deleted +0 -34
@@ -1,34 +0,0 @@ -/* -* QEMU VMPort emulation -* -* Copyright (C) 2007 Hervé Poussineau -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -*/ - -#ifndef HW_I386_VMPORT_H -#define HW_I386_VMPORT_H - -#define TYPE_VMPORT "vmport" - -typedef uint32_t (VMPortReadFunc )(void *opaque,uint32_t address); - -void vmport_register (unsigned char command,VMPortReadFunc *func,void *opaque); - -#endif
include/hw/i386/vmport.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef HW_VMPORT_H +#define HW_VMPORT_H + +#include "hw/isa/isa.h" + +#define TYPE_VMPORT "vmport" +typedef uint32_t (VMPortReadFunc )(void *opaque,uint32_t address); + +static inline void vmport_init (ISABus *bus) +{ +isa_create_simple (bus,TYPE_VMPORT ); +} + +void vmport_register (unsigned char command,VMPortReadFunc *func,void *opaque); + +#endif
Signature · 1 line
2.26.2
[PULL 052/115] target/i386: fix fscale handling of signaling NaN
In reply to Paolo BonziniFrom: Joseph Myers <[email protected]>
The implementation of the fscale instruction returns a NaN exponent unchanged. Fix it to return a quiet NaN when the provided exponent is a signaling NaN.
Message-Id: <[email protected]>
--- target/i386/fpu_helper.c | 4 ++++ tests/tcg/i386/test-i386-fscale.c | 37 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tests/tcg/i386/test-i386-fscale.c
target/i386/fpu_helper.c +4 -0
@@ -970,6 +970,10 @@ void helper_fscale(CPUX86State *env) {if (floatx80_is_any_nan (ST1 )) {ST0 =ST1 ; +if (floatx80_is_signaling_nan (ST0 , &env->fp_status)) { +float_raise (float_flag_invalid, &env->fp_status); +ST0 =floatx80_silence_nan (ST0 , &env->fp_status); + } }else {int n =floatx80_to_int32_round_to_zero (ST1 , &env->fp_status);ST0 =floatx80_scalbn (ST0 , n, &env->fp_status);
tests/tcg/i386/test-i386-fscale.c new file +37 -0
@@ -0,0 +1,37 @@ +/* Test fscale instruction. */ + +#include <stdint.h> +#include <stdio.h> + +union u { +struct {uint64_t sig;uint16_t sign_exp; } s; +long double ld; +}; + +volatile long double ld_res; + +int isnan_ld (long double x) +{ +union u tmp = { .ld = x }; +return ((tmp.s.sign_exp &0x7fff ) ==0x7fff && + (tmp.s.sig >>63 ) !=0 && + (tmp.s.sig <<1 ) !=0 ); +} + +int issignaling_ld (long double x) +{ +union u tmp = { .ld = x }; +return isnan_ld (x) && (tmp.s.sig &UINT64_C (0x4000000000000000 )) ==0 ; +} + +int main (void ) +{ +int ret =0 ; + __asm__volatile ("fscale" :"=t" (ld_res) : +"0" (2.5L ),"u" (__builtin_nansl ("" ))); +if (!isnan_ld (ld_res) ||issignaling_ld (ld_res)) { +printf ("FAIL: fscale snan\n" ); + ret =1 ; + } +return ret; +}
Signature · 1 line
2.26.2
[PULL 066/115] x86/cpu: Enable AVX512_VP2INTERSECT cpu feature
In reply to Paolo BonziniFrom: Cathy Zhang <[email protected]>
AVX512_VP2INTERSECT compute vector pair intersection to a pair of mask registers, which is introduced with intel Tiger Lake, defining as CPUID.(EAX=7,ECX=0):EDX[bit 08].
Refer to the following release spec:
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf
Message-Id: <[email protected]>
--- target/i386/cpu.c | 2 +- target/i386/cpu.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
target/i386/cpu.c +1 -1
@@ -985,7 +985,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = { .feat_names = {NULL ,NULL ,"avx512-4vnniw" ,"avx512-4fmaps" ,NULL ,NULL ,NULL ,NULL , -NULL ,NULL ,"md-clear" ,NULL , +"avx512-vp2intersect" ,NULL ,"md-clear" ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL /* pconfig */ ,NULL , NULL, NULL, NULL, NULL,
target/i386/cpu.h +2 -0
@@ -772,6 +772,8 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_EDX_AVX512_4VNNIW (1U << 2)/* AVX512 Multiply Accumulation Single Precision */ #define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3) +/* AVX512 Vector Pair Intersection to a Pair of Mask Registers */ +#define CPUID_7_0_EDX_AVX512_VP2INTERSECT (1U << 8)/* Speculation Control */ #define CPUID_7_0_EDX_SPEC_CTRL (1U << 26)/* Single Thread Indirect Branch Predictors */
Signature · 1 line
2.26.2
[PULL 025/115] hw/i386/vmport: Add reference to VMware open-vm-tools
In reply to Paolo BonziniFrom: Liran Alon <[email protected]>
This official VMware open-source project can be used as reference to understand how guest code interacts with VMPort virtual device. Thus, providing understanding on how device is expected to behave.
Message-Id: <[email protected]>
--- hw/i386/vmport.c | 7 +++++++ 1 file changed, 7 insertions(+)
hw/i386/vmport.c +7 -0
@@ -21,6 +21,13 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + +/* +* Guest code that interacts with this virtual device can be found +* in VMware open-vm-tools open-source project: +* https://github.com/vmware/open-vm-tools +*/ +#include "qemu/osdep.h" #include "hw/isa/isa.h" #include "sysemu/hw_accel.h"
Signature · 1 line
2.26.2
[PULL 068/115] KVM: Pass EventNotifier into kvm_irqchip_assign_irqfd
In reply to Paolo BonziniFrom: Peter Xu <[email protected]>
So that kvm_irqchip_assign_irqfd() can have access to the EventNotifiers, especially the resample event. It is needed in follow up patch to cache and kick resamplefds from QEMU.
Message-Id: <[email protected]>
--- accel/kvm/kvm-all.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
accel/kvm/kvm-all.c +10 -6
@@ -1662,9 +1662,13 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg,return kvm_update_routing_entry (s, &kroute); } -static int kvm_irqchip_assign_irqfd (KVMState *s,int fd,int rfd,int virq, +static int kvm_irqchip_assign_irqfd (KVMState *s,EventNotifier *event, +EventNotifier *resample,int virq,bool assign) { +int fd =event_notifier_get_fd (event); +int rfd = resample ?event_notifier_get_fd (resample) :-1 ; +struct kvm_irqfd irqfd = { .fd = fd, .gsi = virq,
@@ -1769,7 +1773,9 @@ int kvm_irqchip_add_hv_sint_route(KVMState *s, uint32_t vcpu, uint32_t sint)return -ENOSYS ; } -static int kvm_irqchip_assign_irqfd (KVMState *s,int fd,int virq,bool assign) +static int kvm_irqchip_assign_irqfd (KVMState *s,EventNotifier *event, +EventNotifier *resample,int virq, +bool assign) {abort (); }
@@ -1783,15 +1789,13 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg)int kvm_irqchip_add_irqfd_notifier_gsi (KVMState *s,EventNotifier *n,EventNotifier *rn,int virq) { -return kvm_irqchip_assign_irqfd (s,event_notifier_get_fd (n), - rn ?event_notifier_get_fd (rn) :-1 , virq, true); +return kvm_irqchip_assign_irqfd (s, n, rn, virq, true); }int kvm_irqchip_remove_irqfd_notifier_gsi (KVMState *s,EventNotifier *n,int virq) { -return kvm_irqchip_assign_irqfd (s,event_notifier_get_fd (n),-1 , virq, - false); +return kvm_irqchip_assign_irqfd (s, n,NULL , virq, false); } int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n,
Signature · 1 line
2.26.2
[PULL 056/115] exec: Let address_space_read/write_cached() propagate MemTxResult
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Both address_space_read_cached_slow() and address_space_write_cached_slow() return a MemTxResult type. Do not discard it, return it to the caller.
--- exec.c | 16 ++++++++-------- include/exec/memory.h | 19 +++++++++++-------- 2 files changed, 19 insertions(+), 16 deletions(-)
exec.c +8 -8
@@ -3718,7 +3718,7 @@ static inline MemoryRegion *address_space_translate_cached(/* Called from RCU critical section. address_space_read_cached uses this * out of line function when the target is an MMIO or IOMMU region. */ -void +MemTxResult address_space_read_cached_slow (MemoryRegionCache *cache,hwaddr addr,void *buf,hwaddr len) {
@@ -3728,15 +3728,15 @@ address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr, l = len; mr =address_space_translate_cached (cache, addr, &addr1, &l, false,MEMTXATTRS_UNSPECIFIED ); -flatview_read_continue (cache->fv, - addr,MEMTXATTRS_UNSPECIFIED , buf, len, - addr1, l, mr); +return flatview_read_continue (cache->fv, + addr,MEMTXATTRS_UNSPECIFIED , buf, len, + addr1, l, mr); }/* Called from RCU critical section. address_space_write_cached uses this * out of line function when the target is an MMIO or IOMMU region. */ -void +MemTxResult address_space_write_cached_slow (MemoryRegionCache *cache,hwaddr addr,const void *buf,hwaddr len) {
@@ -3746,9 +3746,9 @@ address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr, l = len; mr =address_space_translate_cached (cache, addr, &addr1, &l, true,MEMTXATTRS_UNSPECIFIED ); -flatview_write_continue (cache->fv, - addr,MEMTXATTRS_UNSPECIFIED , buf, len, - addr1, l, mr); +return flatview_write_continue (cache->fv, + addr,MEMTXATTRS_UNSPECIFIED , buf, len, + addr1, l, mr); }#define ARG1_DECL MemoryRegionCache *cache
include/exec/memory.h +11 -8
@@ -2354,10 +2354,11 @@ void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_t addr);/* Internal functions, part of the implementation of address_space_read_cached * and address_space_write_cached. */ -void address_space_read_cached_slow (MemoryRegionCache *cache, -hwaddr addr,void *buf,hwaddr len); -void address_space_write_cached_slow (MemoryRegionCache *cache, -hwaddr addr,const void *buf,hwaddr len); +MemTxResult address_space_read_cached_slow (MemoryRegionCache *cache, +hwaddr addr,void *buf,hwaddr len); +MemTxResult address_space_write_cached_slow (MemoryRegionCache *cache, +hwaddr addr,const void *buf, +hwaddr len);static inline bool memory_access_is_direct (MemoryRegion *mr,bool is_write) {
@@ -2422,15 +2423,16 @@ MemTxResult address_space_read(AddressSpace *as, hwaddr addr,* @buf: buffer with the data transferred * @len: length of the data transferred */ -static inline void +static inline MemTxResult address_space_read_cached (MemoryRegionCache *cache,hwaddr addr,void *buf,hwaddr len) {assert (addr < cache->len && len <= cache->len - addr);if (likely (cache->ptr)) {memcpy (buf, cache->ptr + addr, len); +return MEMTX_OK ; }else { -address_space_read_cached_slow (cache, addr, buf, len); +return address_space_read_cached_slow (cache, addr, buf, len); } }
@@ -2442,15 +2444,16 @@ address_space_read_cached(MemoryRegionCache *cache, hwaddr addr,* @buf: buffer with the data transferred * @len: length of the data transferred */ -static inline void +static inline MemTxResult address_space_write_cached (MemoryRegionCache *cache,hwaddr addr,const void *buf,hwaddr len) {assert (addr < cache->len && len <= cache->len - addr);if (likely (cache->ptr)) {memcpy (cache->ptr + addr, buf, len); +return MEMTX_OK ; }else { -address_space_write_cached_slow (cache, addr, buf, len); +return address_space_write_cached_slow (cache, addr, buf, len); } }
Signature · 1 line
2.26.2
[PULL 049/115] megasas: avoid NULL pointer dereference
In reply to Paolo BonziniFrom: Prasad J Pandit <[email protected]>
While in megasas_handle_frame(), megasas_enqueue_frame() may set a NULL frame into MegasasCmd object for a given 'frame_addr' address. Add check to avoid a NULL pointer dereference issue.
Message-Id: <[email protected]>
--- hw/scsi/megasas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/megasas.c +1 -1
@@ -504,7 +504,7 @@ static MegasasCmd *megasas_enqueue_frame(MegasasState *s, cmd->pa = frame;/* Map all possible frames */ cmd->frame =pci_dma_map (pcid, frame, &frame_size_p,0 ); -if (frame_size_p != frame_size) { +if (!cmd->frame || frame_size_p != frame_size) {trace_megasas_qf_map_failed (cmd->index, (unsigned long )frame);if (cmd->frame) {megasas_unmap_frame (s, cmd);
Signature · 1 line
2.26.2
[PULL 079/115] configure: Do not ignore malloc value
In reply to Paolo BonziniFrom: Leonid Bloch <[email protected]>
Not checking the value of malloc will cause a warning with GCC 10.1, which may result in configuration failure, with the following line in config.log:
config-temp/qemu-conf.c:2:18: error: ignoring return value of ‘malloc’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
2 | int main(void) { malloc(1); return 0; }
| ^~~~~~~~~Message-Id: <[email protected]>
--- configure | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
configure +17 -3
@@ -4587,7 +4587,13 @@ fi if test "$tcmalloc" = "yes" ; then cat > $TMPC << EOF #include <stdlib.h> -int main(void) { malloc(1); return 0; } +int main(void) { + void *tmp = malloc(1); + if (tmp != NULL) { + return 0; + } + return 1; +} EOF if compile_prog "" "-ltcmalloc" ; then
@@ -4603,7 +4609,13 @@ fi if test "$jemalloc" = "yes" ; then cat > $TMPC << EOF #include <stdlib.h> -int main(void) { malloc(1); return 0; } +int main(void) { + void *tmp = malloc(1); + if (tmp != NULL) { + return 0; + } + return 1; +} EOF if compile_prog "" "-ljemalloc" ; then
@@ -6164,7 +6176,9 @@ if test "$sanitizers" = "yes" ; then #include <stdlib.h> int main(void) { void *tmp = malloc(10); - return *(int *)(tmp + 2); + if (tmp != NULL) { + return *(int *)(tmp + 2); + } } EOF if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
Signature · 1 line
2.26.2
[PULL 059/115] hw/elf_ops: Do not ignore write failures when loading ELF
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Do not ignore the MemTxResult error type returned by address_space_write().
--- include/hw/elf_ops.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
include/hw/elf_ops.h +8 -3
@@ -553,9 +553,14 @@ static int glue(load_elf, SZ)(const char *name, int fd,rom_add_elf_program (label, mapped_file, data, file_size, mem_size, addr, as); }else { -address_space_write (as ? as : &address_space_memory, - addr,MEMTXATTRS_UNSPECIFIED , - data, file_size); +MemTxResult res; + + res =address_space_write (as ? as : &address_space_memory, + addr,MEMTXATTRS_UNSPECIFIED , + data, file_size); +if (res !=MEMTX_OK ) { + goto fail; + } } }
Signature · 1 line
2.26.2
[PULL 060/115] target/i386: fix floating-point load-constant rounding
In reply to Paolo BonziniFrom: Joseph Myers <[email protected]>
The implementations of the fldl2t, fldl2e, fldpi, fldlg2 and fldln2 instructions load fixed constants independent of the rounding mode. Fix them to load a value correctly rounded for the current rounding mode (but always rounded to 64-bit precision independent of the precision control, and without setting "inexact") as specified.
Message-Id: <[email protected]>
--- target/i386/fpu_helper.c | 54 +++++++- tests/tcg/i386/test-i386-fldcst.c | 199 ++++++++++++++++++++++++++++++ 2 files changed, 248 insertions(+), 5 deletions(-) create mode 100644 tests/tcg/i386/test-i386-fldcst.c
target/i386/fpu_helper.c +49 -5
@@ -59,8 +59,13 @@#define FPUC_EM 0x3f#define floatx80_lg2 make_floatx80(0x3ffd, 0x9a209a84fbcff799LL) +#define floatx80_lg2_d make_floatx80(0x3ffd, 0x9a209a84fbcff798LL)#define floatx80_l2e make_floatx80(0x3fff, 0xb8aa3b295c17f0bcLL) +#define floatx80_l2e_d make_floatx80(0x3fff, 0xb8aa3b295c17f0bbLL)#define floatx80_l2t make_floatx80(0x4000, 0xd49a784bcd1b8afeLL) +#define floatx80_l2t_u make_floatx80(0x4000, 0xd49a784bcd1b8affLL) +#define floatx80_ln2_d make_floatx80(0x3ffe, 0xb17217f7d1cf79abLL) +#define floatx80_pi_d make_floatx80(0x4000, 0xc90fdaa22168c234LL)#if !defined(CONFIG_USER_ONLY )static qemu_irq ferr_irq;
@@ -544,27 +549,66 @@ void helper_fld1_ST0(CPUX86State *env)void helper_fldl2t_ST0 (CPUX86State *env) { -ST0 = floatx80_l2t; +switch (env->fpuc &FPU_RC_MASK ) { +case FPU_RC_UP : +ST0 = floatx80_l2t_u; +break ; +default : +ST0 = floatx80_l2t; +break ; + } }void helper_fldl2e_ST0 (CPUX86State *env) { -ST0 = floatx80_l2e; +switch (env->fpuc &FPU_RC_MASK ) { +case FPU_RC_DOWN : +case FPU_RC_CHOP : +ST0 = floatx80_l2e_d; +break ; +default : +ST0 = floatx80_l2e; +break ; + } }void helper_fldpi_ST0 (CPUX86State *env) { -ST0 = floatx80_pi; +switch (env->fpuc &FPU_RC_MASK ) { +case FPU_RC_DOWN : +case FPU_RC_CHOP : +ST0 = floatx80_pi_d; +break ; +default : +ST0 = floatx80_pi; +break ; + } }void helper_fldlg2_ST0 (CPUX86State *env) { -ST0 = floatx80_lg2; +switch (env->fpuc &FPU_RC_MASK ) { +case FPU_RC_DOWN : +case FPU_RC_CHOP : +ST0 = floatx80_lg2_d; +break ; +default : +ST0 = floatx80_lg2; +break ; + } }void helper_fldln2_ST0 (CPUX86State *env) { -ST0 = floatx80_ln2; +switch (env->fpuc &FPU_RC_MASK ) { +case FPU_RC_DOWN : +case FPU_RC_CHOP : +ST0 = floatx80_ln2_d; +break ; +default : +ST0 = floatx80_ln2; +break ; + } }void helper_fldz_ST0 (CPUX86State *env)
tests/tcg/i386/test-i386-fldcst.c new file +199 -0
199 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 061/115] target/i386: fix fxam handling of invalid encodings
In reply to Paolo BonziniFrom: Joseph Myers <[email protected]>
The fxam implementation does not check for invalid encodings, instead treating them like NaN or normal numbers depending on the exponent. Fix it to check that the high bit of the significand is set before treating an encoding as NaN or normal, thus resulting in correct handling (all of C0, C2 and C3 cleared) for invalid encodings.
Message-Id: <[email protected]>
--- target/i386/fpu_helper.c | 4 +- tests/tcg/i386/test-i386-fxam.c | 143 ++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 tests/tcg/i386/test-i386-fxam.c
target/i386/fpu_helper.c +2 -2
@@ -1099,7 +1099,7 @@ void helper_fxam_ST0(CPUX86State *env)if (expdif ==MAXEXPD ) {if (MANTD (temp) ==0x8000000000000000ULL ) { env->fpus |=0x500 ;/* Infinity */ - }else { + }else if (MANTD (temp) &0x8000000000000000ULL ) { env->fpus |=0x100 ;/* NaN */ } }else if (expdif ==0 ) {
@@ -1108,7 +1108,7 @@ void helper_fxam_ST0(CPUX86State *env) }else { env->fpus |=0x4400 ;/* Denormal */ } - }else { + }else if (MANTD (temp) &0x8000000000000000ULL ) { env->fpus |=0x400 ; } }
tests/tcg/i386/test-i386-fxam.c new file +143 -0
143 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 074/115] i386: Remove unused define's from hax and hvf
In reply to Paolo BonziniFrom: Julio Faracco <[email protected]>
Commit acb9f95a removed boundary checks for ID and VCPU ID. After that, the max definitions of that boundaries are not required anymore. This commit is only a code cleanup.
Message-Id: <[email protected]>
--- target/i386/hax-i386.h | 2 -- target/i386/hvf/hvf-i386.h | 2 -- 2 files changed, 4 deletions(-)
target/i386/hax-i386.h +0 -2
@@ -41,8 +41,6 @@ struct hax_state { };#define HAX_MAX_VCPU 0x10 -#define MAX_VM_ID 0x40 -#define MAX_VCPU_ID 0x40struct hax_vm {hax_fd fd;
target/i386/hvf/hvf-i386.h +0 -2
@@ -21,8 +21,6 @@#include "x86.h" #define HVF_MAX_VCPU 0x10 -#define MAX_VM_ID 0x40 -#define MAX_VCPU_ID 0x40extern struct hvf_state hvf_global;
Signature · 1 line
2.26.2
[PULL 054/115] target/i386: fix fscale handling of infinite exponents
In reply to Paolo BonziniFrom: Joseph Myers <[email protected]>
The fscale implementation passes infinite exponents through to generic code that rounds the exponent to a 32-bit integer before using floatx80_scalbn. In round-to-nearest mode, and ignoring exceptions, this works in many cases. But it fails to handle the special cases of scaling 0 by a +Inf exponent or an infinity by a -Inf exponent, which should produce a NaN, and because it produces an inexact result for finite nonzero numbers being scaled, the result is sometimes incorrect in other rounding modes. Add appropriate handling of infinite exponents to produce a NaN or an appropriately signed exact zero or infinity as a result.
Message-Id: <[email protected]>
--- target/i386/fpu_helper.c | 22 ++++++++++++++++++++++ tests/tcg/i386/test-i386-fscale.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+)
target/i386/fpu_helper.c +22 -0
@@ -977,6 +977,28 @@ void helper_fscale(CPUX86State *env)float_raise (float_flag_invalid, &env->fp_status);ST0 =floatx80_silence_nan (ST0 , &env->fp_status); } + }else if (floatx80_is_infinity (ST1 ) && + !floatx80_invalid_encoding (ST0 ) && + !floatx80_is_any_nan (ST0 )) { +if (floatx80_is_neg (ST1 )) { +if (floatx80_is_infinity (ST0 )) { +float_raise (float_flag_invalid, &env->fp_status); +ST0 =floatx80_default_nan (&env->fp_status); + }else { +ST0 = (floatx80_is_neg (ST0 ) ? +floatx80_chs (floatx80_zero) : + floatx80_zero); + } + }else { +if (floatx80_is_zero (ST0 )) { +float_raise (float_flag_invalid, &env->fp_status); +ST0 =floatx80_default_nan (&env->fp_status); + }else { +ST0 = (floatx80_is_neg (ST0 ) ? +floatx80_chs (floatx80_infinity) : + floatx80_infinity); + } + } }else {int n =floatx80_to_int32_round_to_zero (ST1 , &env->fp_status);ST0 =floatx80_scalbn (ST0 , n, &env->fp_status);
tests/tcg/i386/test-i386-fscale.c +29 -0
@@ -31,6 +31,7 @@ int issignaling_ld(long double x)int main (void ) { +short cw;int ret =0 ; __asm__volatile ("fscale" :"=t" (ld_res) :"0" (2.5L ),"u" (__builtin_nansl ("" )));
@@ -62,5 +63,33 @@ int main(void)printf ("FAIL: fscale invalid 4\n" ); ret =1 ; } + __asm__volatile ("fscale" :"=t" (ld_res) : +"0" (0.0L ),"u" (__builtin_infl ())); +if (!isnan_ld (ld_res) ||issignaling_ld (ld_res)) { +printf ("FAIL: fscale 0 up inf\n" ); + ret =1 ; + } + __asm__volatile ("fscale" :"=t" (ld_res) : +"0" (__builtin_infl ()),"u" (-__builtin_infl ())); +if (!isnan_ld (ld_res) ||issignaling_ld (ld_res)) { +printf ("FAIL: fscale inf down inf\n" ); + ret =1 ; + } +/* Set round-downward. */ + __asm__volatile ("fnstcw %0" :"=m" (cw)); + cw = (cw & ~0xc00 ) |0x400 ; + __asm__volatile ("fldcw %0" : :"m" (cw)); + __asm__volatile ("fscale" :"=t" (ld_res) : +"0" (1.0L ),"u" (__builtin_infl ())); +if (ld_res !=__builtin_infl ()) { +printf ("FAIL: fscale finite up inf\n" ); + ret =1 ; + } + __asm__volatile ("fscale" :"=t" (ld_res) : +"0" (-1.0L ),"u" (-__builtin_infl ())); +if (ld_res !=-0.0L ||__builtin_copysignl (1.0L , ld_res) !=-1.0L ) { +printf ("FAIL: fscale finite down inf\n" ); + ret =1 ; + }return ret; }
Signature · 1 line
2.26.2
[PULL 017/115] hyperv: expose API to determine if synic is enabled
In reply to Paolo BonziniFrom: Jon Doron <[email protected]>
Message-Id: <[email protected]>
--- hw/hyperv/hyperv.c | 8 ++++++++ include/hw/hyperv/hyperv.h | 1 + 2 files changed, 9 insertions(+)
hw/hyperv/hyperv.c +8 -0
@@ -38,6 +38,13 @@ typedef struct SynICState {#define TYPE_SYNIC "hyperv-synic"#define SYNIC (obj) OBJECT_CHECK(SynICState, (obj), TYPE_SYNIC) +static bool synic_enabled; + +bool hyperv_is_synic_enabled (void ) +{ +return synic_enabled; +} +static SynICState *get_synic (CPUState *cs) {return SYNIC (object_resolve_path_component (OBJECT (cs),"synic" ));
@@ -134,6 +141,7 @@ void hyperv_synic_add(CPUState *cs)object_property_add_child (OBJECT (cs),"synic" , obj);object_unref (obj);object_property_set_bool (obj, true,"realized" , &error_abort); + synic_enabled = true; }void hyperv_synic_reset (CPUState *cs)
include/hw/hyperv/hyperv.h +1 -0
@@ -79,5 +79,6 @@ void hyperv_synic_add(CPUState *cs);void hyperv_synic_reset (CPUState *cs);void hyperv_synic_update (CPUState *cs,bool enable,hwaddr msg_page_addr,hwaddr event_page_addr); +bool hyperv_is_synic_enabled (void );#endif
Signature · 1 line
2.26.2
[PULL 077/115] memory: Make 'info mtree' not display disabled regions by default
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
We might have many disabled memory regions, making the 'info mtree' output too verbose to be useful.
Remove the disabled regions in the default output, but allow the monitor user to display them using the '-D' option.
Before:
(qemu) info mtree
memory-region: system
0000000000000000-ffffffffffffffff (prio 0, i/o): system
0000000000000000-0000000007ffffff (prio 0, ram): alias ram-below-4g @pc.ram 0000000000000000-0000000007ffffff
0000000000000000-ffffffffffffffff (prio -1, i/o): pci
00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem
00000000000c0000-00000000000dffff (prio 1, rom): pc.rom
00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios @pc.bios 0000000000020000-000000000003ffff
00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
00000000000a0000-00000000000bffff (prio 1, i/o): alias smram-region @pci 00000000000a0000-00000000000bffff
00000000000c0000-00000000000c3fff (prio 1, ram): alias pam-ram @pc.ram 00000000000c0000-00000000000c3fff [disabled]
00000000000c0000-00000000000c3fff (prio 1, ram): alias pam-pci @pc.ram 00000000000c0000-00000000000c3fff [disabled]
00000000000c0000-00000000000c3fff (prio 1, ram): alias pam-rom @pc.ram 00000000000c0000-00000000000c3fff [disabled]
00000000000c0000-00000000000c3fff (prio 1, i/o): alias pam-pci @pci 00000000000c0000-00000000000c3fff
00000000000c4000-00000000000c7fff (prio 1, ram): alias pam-ram @pc.ram 00000000000c4000-00000000000c7fff [disabled]
00000000000c4000-00000000000c7fff (prio 1, ram): alias pam-pci @pc.ram 00000000000c4000-00000000000c7fff [disabled]
00000000000c4000-00000000000c7fff (prio 1, ram): alias pam-rom @pc.ram 00000000000c4000-00000000000c7fff [disabled]
00000000000c4000-00000000000c7fff (prio 1, i/o): alias pam-pci @pci 00000000000c4000-00000000000c7fff
00000000000c8000-00000000000cbfff (prio 1, ram): alias pam-ram @pc.ram 00000000000c8000-00000000000cbfff [disabled]
00000000000c8000-00000000000cbfff (prio 1, ram): alias pam-pci @pc.ram 00000000000c8000-00000000000cbfff [disabled]
00000000000c8000-00000000000cbfff (prio 1, ram): alias pam-rom @pc.ram 00000000000c8000-00000000000cbfff [disabled]
00000000000c8000-00000000000cbfff (prio 1, i/o): alias pam-pci @pci 00000000000c8000-00000000000cbfff
00000000000cc000-00000000000cffff (prio 1, ram): alias pam-ram @pc.ram 00000000000cc000-00000000000cffff [disabled]
00000000000cc000-00000000000cffff (prio 1, ram): alias pam-pci @pc.ram 00000000000cc000-00000000000cffff [disabled]
00000000000cc000-00000000000cffff (prio 1, ram): alias pam-rom @pc.ram 00000000000cc000-00000000000cffff [disabled]
00000000000cc000-00000000000cffff (prio 1, i/o): alias pam-pci @pci 00000000000cc000-00000000000cffff
00000000000d0000-00000000000d3fff (prio 1, ram): alias pam-ram @pc.ram 00000000000d0000-00000000000d3fff [disabled]
00000000000d0000-00000000000d3fff (prio 1, ram): alias pam-pci @pc.ram 00000000000d0000-00000000000d3fff [disabled]
00000000000d0000-00000000000d3fff (prio 1, ram): alias pam-rom @pc.ram 00000000000d0000-00000000000d3fff [disabled]
00000000000d0000-00000000000d3fff (prio 1, i/o): alias pam-pci @pci 00000000000d0000-00000000000d3fff
00000000000d4000-00000000000d7fff (prio 1, ram): alias pam-ram @pc.ram 00000000000d4000-00000000000d7fff [disabled]
00000000000d4000-00000000000d7fff (prio 1, ram): alias pam-pci @pc.ram 00000000000d4000-00000000000d7fff [disabled]
00000000000d4000-00000000000d7fff (prio 1, ram): alias pam-rom @pc.ram 00000000000d4000-00000000000d7fff [disabled]
00000000000d4000-00000000000d7fff (prio 1, i/o): alias pam-pci @pci 00000000000d4000-00000000000d7fff
00000000000d8000-00000000000dbfff (prio 1, ram): alias pam-ram @pc.ram 00000000000d8000-00000000000dbfff [disabled]
00000000000d8000-00000000000dbfff (prio 1, ram): alias pam-pci @pc.ram 00000000000d8000-00000000000dbfff [disabled]
00000000000d8000-00000000000dbfff (prio 1, ram): alias pam-rom @pc.ram 00000000000d8000-00000000000dbfff [disabled]
00000000000d8000-00000000000dbfff (prio 1, i/o): alias pam-pci @pci 00000000000d8000-00000000000dbfff
00000000000dc000-00000000000dffff (prio 1, ram): alias pam-ram @pc.ram 00000000000dc000-00000000000dffff [disabled]
00000000000dc000-00000000000dffff (prio 1, ram): alias pam-pci @pc.ram 00000000000dc000-00000000000dffff [disabled]
00000000000dc000-00000000000dffff (prio 1, ram): alias pam-rom @pc.ram 00000000000dc000-00000000000dffff [disabled]
00000000000dc000-00000000000dffff (prio 1, i/o): alias pam-pci @pci 00000000000dc000-00000000000dffff
00000000000e0000-00000000000e3fff (prio 1, ram): alias pam-ram @pc.ram 00000000000e0000-00000000000e3fff [disabled]
00000000000e0000-00000000000e3fff (prio 1, ram): alias pam-pci @pc.ram 00000000000e0000-00000000000e3fff [disabled]
00000000000e0000-00000000000e3fff (prio 1, ram): alias pam-rom @pc.ram 00000000000e0000-00000000000e3fff [disabled]
00000000000e0000-00000000000e3fff (prio 1, i/o): alias pam-pci @pci 00000000000e0000-00000000000e3fff
00000000000e4000-00000000000e7fff (prio 1, ram): alias pam-ram @pc.ram 00000000000e4000-00000000000e7fff [disabled]
00000000000e4000-00000000000e7fff (prio 1, ram): alias pam-pci @pc.ram 00000000000e4000-00000000000e7fff [disabled]
00000000000e4000-00000000000e7fff (prio 1, ram): alias pam-rom @pc.ram 00000000000e4000-00000000000e7fff [disabled]
00000000000e4000-00000000000e7fff (prio 1, i/o): alias pam-pci @pci 00000000000e4000-00000000000e7fff
00000000000e8000-00000000000ebfff (prio 1, ram): alias pam-ram @pc.ram 00000000000e8000-00000000000ebfff [disabled]
00000000000e8000-00000000000ebfff (prio 1, ram): alias pam-pci @pc.ram 00000000000e8000-00000000000ebfff [disabled]
00000000000e8000-00000000000ebfff (prio 1, ram): alias pam-rom @pc.ram 00000000000e8000-00000000000ebfff [disabled]
00000000000e8000-00000000000ebfff (prio 1, i/o): alias pam-pci @pci 00000000000e8000-00000000000ebfff
00000000000ec000-00000000000effff (prio 1, ram): alias pam-ram @pc.ram 00000000000ec000-00000000000effff [disabled]
00000000000ec000-00000000000effff (prio 1, ram): alias pam-pci @pc.ram 00000000000ec000-00000000000effff [disabled]
00000000000ec000-00000000000effff (prio 1, ram): alias pam-rom @pc.ram 00000000000ec000-00000000000effff [disabled]
00000000000ec000-00000000000effff (prio 1, i/o): alias pam-pci @pci 00000000000ec000-00000000000effff
00000000000f0000-00000000000fffff (prio 1, ram): alias pam-ram @pc.ram 00000000000f0000-00000000000fffff [disabled]
00000000000f0000-00000000000fffff (prio 1, ram): alias pam-pci @pc.ram 00000000000f0000-00000000000fffff [disabled]
00000000000f0000-00000000000fffff (prio 1, ram): alias pam-rom @pc.ram 00000000000f0000-00000000000fffff [disabled]
00000000000f0000-00000000000fffff (prio 1, i/o): alias pam-pci @pci 00000000000f0000-00000000000fffff
00000000fec00000-00000000fec00fff (prio 0, i/o): ioapic
00000000fed00000-00000000fed003ff (prio 0, i/o): hpet
00000000fee00000-00000000feefffff (prio 4096, i/o): apic-msiAfter:
(qemu) info mtree
memory-region: system
0000000000000000-ffffffffffffffff (prio 0, i/o): system
0000000000000000-0000000007ffffff (prio 0, ram): alias ram-below-4g @pc.ram 0000000000000000-0000000007ffffff
0000000000000000-ffffffffffffffff (prio -1, i/o): pci
00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem
00000000000c0000-00000000000dffff (prio 1, rom): pc.rom
00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios @pc.bios 0000000000020000-000000000003ffff
00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
00000000000a0000-00000000000bffff (prio 1, i/o): alias smram-region @pci 00000000000a0000-00000000000bffff
00000000000c0000-00000000000c3fff (prio 1, i/o): alias pam-pci @pci 00000000000c0000-00000000000c3fff
00000000000c4000-00000000000c7fff (prio 1, i/o): alias pam-pci @pci 00000000000c4000-00000000000c7fff
00000000000c8000-00000000000cbfff (prio 1, i/o): alias pam-pci @pci 00000000000c8000-00000000000cbfff
00000000000cc000-00000000000cffff (prio 1, i/o): alias pam-pci @pci 00000000000cc000-00000000000cffff
00000000000d0000-00000000000d3fff (prio 1, i/o): alias pam-pci @pci 00000000000d0000-00000000000d3fff
00000000000d4000-00000000000d7fff (prio 1, i/o): alias pam-pci @pci 00000000000d4000-00000000000d7fff
00000000000d8000-00000000000dbfff (prio 1, i/o): alias pam-pci @pci 00000000000d8000-00000000000dbfff
00000000000dc000-00000000000dffff (prio 1, i/o): alias pam-pci @pci 00000000000dc000-00000000000dffff
00000000000e0000-00000000000e3fff (prio 1, i/o): alias pam-pci @pci 00000000000e0000-00000000000e3fff
00000000000e4000-00000000000e7fff (prio 1, i/o): alias pam-pci @pci 00000000000e4000-00000000000e7fff
00000000000e8000-00000000000ebfff (prio 1, i/o): alias pam-pci @pci 00000000000e8000-00000000000ebfff
00000000000ec000-00000000000effff (prio 1, i/o): alias pam-pci @pci 00000000000ec000-00000000000effff
00000000000f0000-00000000000fffff (prio 1, i/o): alias pam-pci @pci 00000000000f0000-00000000000fffff
00000000fec00000-00000000fec00fff (prio 0, i/o): ioapic
00000000fed00000-00000000fed003ff (prio 0, i/o): hpet
00000000fee00000-00000000feefffff (prio 4096, i/o): apic-msiThe old behavior is preserved using 'info mtree -D'.
--- hmp-commands-info.hx | 7 ++-- include/exec/memory.h | 2 +- memory.c | 75 +++++++++++++++++++++++-------------------- monitor/misc.c | 3 +- 4 files changed, 48 insertions(+), 39 deletions(-)
hmp-commands-info.hx +4 -3
@@ -254,11 +254,12 @@ ERST { .name = "mtree", - .args_type = "flatview:-f,dispatch_tree:-d,owner:-o", - .params = "[-f][-d][-o]", + .args_type = "flatview:-f,dispatch_tree:-d,owner:-o,disabled:-D", + .params = "[-f][-d][-o][-D]", .help = "show memory tree (-f: dump flat view for address spaces;" "-d: dump dispatch tree, valid with -f only);" - "-o: dump region owners/parents", + "-o: dump region owners/parents;" + "-D: dump disabled regions", .cmd = hmp_info_mtree, },
include/exec/memory.h +1 -1
@@ -1984,7 +1984,7 @@ void memory_global_dirty_log_start(void);*/ void memory_global_dirty_log_stop (void ); -void mtree_info (bool flatview,bool dispatch_tree,bool owner); +void mtree_info (bool flatview,bool dispatch_tree,bool owner,bool disabled);/** * memory_region_dispatch_read: perform a read directly to the specified
memory.c +41 -34
121 lines not on this page · raw message
monitor/misc.c +2 -1
@@ -957,8 +957,9 @@ static void hmp_info_mtree(Monitor *mon, const QDict *qdict)bool flatview =qdict_get_try_bool (qdict,"flatview" , false);bool dispatch_tree =qdict_get_try_bool (qdict,"dispatch_tree" , false);bool owner =qdict_get_try_bool (qdict,"owner" , false); +bool disabled =qdict_get_try_bool (qdict,"disabled" , false); -mtree_info (flatview, dispatch_tree, owner); +mtree_info (flatview, dispatch_tree, owner, disabled); }#ifdef CONFIG_PROFILER
Signature · 1 line
2.26.2
[PULL 047/115] i386/kvm: fix a use-after-free when vcpu plug/unplug
In reply to Paolo BonziniFrom: Pan Nengyuan <[email protected]>
When we hotplug vcpus, cpu_update_state is added to vm_change_state_head in kvm_arch_init_vcpu(). But it forgot to delete in kvm_arch_destroy_vcpu() after unplug. Then it will cause a use-after-free access. This patch delete it in kvm_arch_destroy_vcpu() to fix that.
Reproducer:
virsh setvcpus vm1 4 --live
virsh setvcpus vm1 2 --live
virsh suspend vm1
virsh resume vm1
The UAF stack:
==qemu-system-x86_64==28233==ERROR: AddressSanitizer: heap-use-after-free on address 0x62e00002e798 at pc 0x5573c6917d9e bp 0x7fff07139e50 sp 0x7fff07139e40 WRITE of size 1 at 0x62e00002e798 thread T0
#0 0x5573c6917d9d in cpu_update_state /mnt/sdb/qemu/target/i386/kvm.c:742
#1 0x5573c699121a in vm_state_notify /mnt/sdb/qemu/vl.c:1290
#2 0x5573c636287e in vm_prepare_start /mnt/sdb/qemu/cpus.c:2144
#3 0x5573c6362927 in vm_start /mnt/sdb/qemu/cpus.c:2150
#4 0x5573c71e8304 in qmp_cont /mnt/sdb/qemu/monitor/qmp-cmds.c:173
#5 0x5573c727cb1e in qmp_marshal_cont qapi/qapi-commands-misc.c:835
#6 0x5573c7694c7a in do_qmp_dispatch /mnt/sdb/qemu/qapi/qmp-dispatch.c:132
#7 0x5573c7694c7a in qmp_dispatch /mnt/sdb/qemu/qapi/qmp-dispatch.c:175
#8 0x5573c71d9110 in monitor_qmp_dispatch /mnt/sdb/qemu/monitor/qmp.c:145
#9 0x5573c71dad4f in monitor_qmp_bh_dispatcher /mnt/sdb/qemu/monitor/qmp.c:234Message-Id: <[email protected]>
--- target/i386/cpu.h | 1 + target/i386/kvm.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)
target/i386/cpu.h +1 -0
@@ -1634,6 +1634,7 @@ struct X86CPU {CPUNegativeOffsetState neg;CPUX86State env; +VMChangeStateEntry *vmsentry;uint64_t ucode_rev;
target/i386/kvm.c +3 -1
@@ -1741,7 +1741,7 @@ int kvm_arch_init_vcpu(CPUState *cs) } } -qemu_add_vm_change_state_handler (cpu_update_state, env); + cpu->vmsentry =qemu_add_vm_change_state_handler (cpu_update_state, env); c =cpuid_find_entry (&cpuid_data.cpuid,1 ,0 );if (c) {
@@ -1852,6 +1852,8 @@ int kvm_arch_destroy_vcpu(CPUState *cs) env->nested_state =NULL ; } +qemu_del_vm_change_state_handler (cpu->vmsentry); +return 0 ; }
Signature · 1 line
2.26.2
[PULL 065/115] hw/i386/vmport: Allow QTest use without crashing
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Trying libFuzzer on the vmport device, we get:
AddressSanitizer:DEADLYSIGNAL
=================================================================
==29476==ERROR: AddressSanitizer: SEGV on unknown address 0x000000008840 (pc 0x56448bec4d79 bp 0x7ffeec9741b0 sp 0x7ffeec9740e0 T0) ==29476==The signal is caused by a READ memory access.
#0 0x56448bec4d78 in vmport_ioport_read (qemu-fuzz-i386+0x1260d78)
#1 0x56448bb5f175 in memory_region_read_accessor (qemu-fuzz-i386+0xefb175)
#2 0x56448bb30c13 in access_with_adjusted_size (qemu-fuzz-i386+0xeccc13)
#3 0x56448bb2ea27 in memory_region_dispatch_read1 (qemu-fuzz-i386+0xecaa27)
#4 0x56448bb2e443 in memory_region_dispatch_read (qemu-fuzz-i386+0xeca443)
#5 0x56448b961ab1 in flatview_read_continue (qemu-fuzz-i386+0xcfdab1)
#6 0x56448b96336d in flatview_read (qemu-fuzz-i386+0xcff36d)
#7 0x56448b962ec4 in address_space_read_full (qemu-fuzz-i386+0xcfeec4)This is easily reproducible using:
$ echo inb 0x5658 | qemu-system-i386 -M isapc,accel=qtest -qtest stdio [I 1589796572.009763] OPENED [R +0.008069] inb 0x5658 Segmentation fault (core dumped)
$ coredumpctl gdb -q
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00005605b54d0f21 in vmport_ioport_read (opaque=0x5605b7531ce0, addr=0, size=4) at hw/i386/vmport.c:77
77 eax = env->regs[R_EAX];
(gdb) p cpu
$1 = (X86CPU *) 0x0
(gdb) bt
#0 0x00005605b54d0f21 in vmport_ioport_read (opaque=0x5605b7531ce0, addr=0, size=4) at hw/i386/vmport.c:77
#1 0x00005605b53db114 in memory_region_read_accessor (mr=0x5605b7531d80, addr=0, value=0x7ffc9d261a30, size=4, shift=0, mask=4294967295, attrs=...) at memory.c:434
#2 0x00005605b53db5d4 in access_with_adjusted_size (addr=0, value=0x7ffc9d261a30, size=1, access_size_min=4, access_size_max=4, access_fn=
0x5605b53db0d2 <memory_region_read_accessor>, mr=0x5605b7531d80, attrs=...) at memory.c:544
#3 0x00005605b53de156 in memory_region_dispatch_read1 (mr=0x5605b7531d80, addr=0, pval=0x7ffc9d261a30, size=1, attrs=...) at memory.c:1396
#4 0x00005605b53de228 in memory_region_dispatch_read (mr=0x5605b7531d80, addr=0, pval=0x7ffc9d261a30, op=MO_8, attrs=...) at memory.c:1424
#5 0x00005605b537c80a in flatview_read_continue (fv=0x5605b7650290, addr=22104, attrs=..., ptr=0x7ffc9d261b4b, len=1, addr1=0, l=1, mr=0x5605b7531d80) at exec.c:3200
#6 0x00005605b537c95d in flatview_read (fv=0x5605b7650290, addr=22104, attrs=..., buf=0x7ffc9d261b4b, len=1) at exec.c:3239
#7 0x00005605b537c9e6 in address_space_read_full (as=0x5605b5f74ac0 <address_space_io>, addr=22104, attrs=..., buf=0x7ffc9d261b4b, len=1) at exec.c:3252
#8 0x00005605b53d5a5d in address_space_read (len=1, buf=0x7ffc9d261b4b, attrs=..., addr=22104, as=0x5605b5f74ac0 <address_space_io>) at include/exec/memory.h:2401
#9 0x00005605b53d5a5d in cpu_inb (addr=22104) at ioport.c:88X86CPU is NULL because QTest accelerator does not use CPU. Fix by returning default values when QTest accelerator is used.
--- hw/i386/vmport.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
hw/i386/vmport.c +15 -1
@@ -34,6 +34,7 @@#include "hw/qdev-properties.h" #include "sysemu/sysemu.h" #include "sysemu/hw_accel.h" +#include "sysemu/qtest.h" #include "qemu/log.h" #include "cpu.h" #include "trace.h"
@@ -94,10 +95,14 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr addr,VMPortState *s = opaque;CPUState *cs = current_cpu;X86CPU *cpu =X86_CPU (cs); -CPUX86State *env = &cpu->env; +CPUX86State *env;unsigned char command;uint32_t eax; +if (qtest_enabled ()) { +return -1 ; + } + env = &cpu->env;cpu_synchronize_state (cs); eax = env->regs[R_EAX ];
@@ -142,6 +147,9 @@ static void vmport_ioport_write(void *opaque, hwaddr addr, {X86CPU *cpu =X86_CPU (current_cpu); +if (qtest_enabled ()) { +return ; + } cpu->env.regs[R_EAX ] =vmport_ioport_read (opaque, addr,4 ); }
@@ -149,6 +157,9 @@ static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr) {X86CPU *cpu =X86_CPU (current_cpu); +if (qtest_enabled ()) { +return -1 ; + } cpu->env.regs[R_EBX ] =VMPORT_MAGIC ;if (port_state->compat_flags &VMPORT_COMPAT_REPORT_VMX_TYPE ) { cpu->env.regs[R_ECX ] = port_state->vmware_vmx_type;
@@ -172,6 +183,9 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) {X86CPU *cpu =X86_CPU (current_cpu); +if (qtest_enabled ()) { +return -1 ; + } cpu->env.regs[R_EBX ] =0x1177 ;return ram_size; }
Signature · 1 line
2.26.2
[PULL 062/115] target/i386: fix fbstp handling of negative zero
In reply to Paolo BonziniFrom: Joseph Myers <[email protected]>
The fbstp implementation stores +0 when the rounded result should be -0 because it compares an integer value with 0 to determine the sign. Fix this by checking the sign bit of the operand instead.
Message-Id: <[email protected]>
--- target/i386/fpu_helper.c | 5 ++++- tests/tcg/i386/test-i386-fbstp.c | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/i386/test-i386-fbstp.c
target/i386/fpu_helper.c +4 -1
@@ -726,11 +726,14 @@ void helper_fbst_ST0(CPUX86State *env, target_ulong ptr)int v;target_ulong mem_ref, mem_end;int64_t val; +CPU_LDoubleU temp; + + temp.d =ST0 ; val =floatx80_to_int64 (ST0 , &env->fp_status); mem_ref = ptr; mem_end = mem_ref +9 ; -if (val <0 ) { +if (SIGND (temp)) {cpu_stb_data_ra (env, mem_end,0x80 ,GETPC ()); val = -val; }else {
tests/tcg/i386/test-i386-fbstp.c new file +25 -0
@@ -0,0 +1,25 @@ +/* Test fbstp instruction. */ + +#include <stdio.h> +#include <string.h> + +int main (void ) +{ +int ret =0 ; +unsigned char out[10 ]; +memset (out,0xfe ,sizeof out); + __asm__volatile ("fbstp %0" :"=m" (out) :"t" (-0.0L ) :"st" ); + out[9 ] &=0x80 ; +if (memcmp (out,"\0\0\0\0\0\0\0\0\0\x80" ,sizeof out) !=0 ) { +printf ("FAIL: fbstp -0\n" ); + ret =1 ; + } +memset (out,0x12 ,sizeof out); + __asm__volatile ("fbstp %0" :"=m" (out) :"t" (-0.1L ) :"st" ); + out[9 ] &=0x80 ; +if (memcmp (out,"\0\0\0\0\0\0\0\0\0\x80" ,sizeof out) !=0 ) { +printf ("FAIL: fbstp -0.1\n" ); + ret =1 ; + } +return ret; +}
Signature · 1 line
2.26.2
[PULL 078/115] qemu/thread: Mark qemu_thread_exit() with 'noreturn' attribute
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
After upgrading to Ubuntu 20.04 LTS, GCC 9.3 complains:
util/qemu-thread-posix.c: In function ‘qemu_thread_exit’:
util/qemu-thread-posix.c:577:6: error: function might be candidate for attribute ‘noreturn’ [-Werror=suggest-attribute=noreturn]
577 | void qemu_thread_exit(void *retval)
| ^~~~~~~~~~~~~~~~
Fix by marking the qemu_thread_exit function with QEMU_NORETURN to set the 'noreturn' attribute.
--- include/qemu/thread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/qemu/thread.h +1 -1
@@ -177,7 +177,7 @@ void qemu_thread_create(QemuThread *thread, const char *name,void *qemu_thread_join (QemuThread *thread);void qemu_thread_get_self (QemuThread *thread);bool qemu_thread_is_self (QemuThread *thread); -void qemu_thread_exit (void *retval); +void qemu_thread_exit(void *retval) QEMU_NORETURN;void qemu_thread_naming (bool enable);struct Notifier ;
Signature · 1 line
2.26.2
[PULL 076/115] util/oslib: Returns the real thread identifier on FreeBSD and NetBSD
In reply to Paolo BonziniFrom: David Carlier <[email protected]>
getpid is good enough in a mono thread context, however thr_self/_lwp_self reflects the real current thread identifier from a given process.
--- util/oslib-posix.c | 9 +++++++++ 1 file changed, 9 insertions(+)
util/oslib-posix.c +9 -0
@@ -48,11 +48,13 @@#ifdef __FreeBSD__#include <sys/sysctl.h> #include <sys/user.h> +#include <sys/thr.h> #include <libutil.h> #endif #ifdef __NetBSD__#include <sys/sysctl.h> +#include <lwp.h> #endif #include "qemu/mmap-alloc.h"
@@ -84,6 +86,13 @@ int qemu_get_thread_id(void) {#if defined(__linux__)return syscall (SYS_gettid); +#elif defined(__FreeBSD__) +/* thread id is up to INT_MAX */ +long tid; +thr_self (&tid); +return (int )tid; +#elif defined(__NetBSD__) +return _lwp_self ();#else return getpid ();#endif
Signature · 1 line
2.26.2
[PULL 030/115] hw/i386/vmport: Report vmware-vmx-type in CMD_GETVERSION
In reply to Paolo BonziniFrom: Liran Alon <[email protected]>
As can be seen from VmCheck_GetVersion() in open-vm-tools code, CMD_GETVERSION should return vmware-vmx-type in ECX register.
Default is to fake host as VMware ESX server. But user can control this value by "-global vmport.vmware-vmx-type=X".
Message-Id: <[email protected]>
--- hw/core/machine.c | 1 + hw/i386/vmport.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+)
hw/core/machine.c +1 -0
@@ -45,6 +45,7 @@ GlobalProperty hw_compat_4_2[] = { { "fw_cfg", "acpi-mr-restore", "false" }, { "vmport", "x-read-set-eax", "off" }, { "vmport", "x-signal-unsupported-cmd", "off" }, + { "vmport", "x-report-vmx-type", "off" }, };const size_t hw_compat_4_2_len =G_N_ELEMENTS (hw_compat_4_2);
hw/i386/vmport.c +27 -0
@@ -46,10 +46,13 @@/* Compatibility flags for migration */ #define VMPORT_COMPAT_READ_SET_EAX_BIT 0#define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT 1 +#define VMPORT_COMPAT_REPORT_VMX_TYPE_BIT 2#define VMPORT_COMPAT_READ_SET_EAX \ (1 << VMPORT_COMPAT_READ_SET_EAX_BIT)#define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD \ (1 << VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT) +#define VMPORT_COMPAT_REPORT_VMX_TYPE \ + (1 << VMPORT_COMPAT_REPORT_VMX_TYPE_BIT)#define VMPORT (obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT)
@@ -61,6 +64,7 @@ typedef struct VMPortState {void *opaque[VMPORT_ENTRIES ];uint32_t vmware_vmx_version; +uint8_t vmware_vmx_type;uint32_t compat_flags; } VMPortState;
@@ -140,6 +144,9 @@ static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr)X86CPU *cpu =X86_CPU (current_cpu); cpu->env.regs[R_EBX ] =VMPORT_MAGIC ; +if (port_state->compat_flags &VMPORT_COMPAT_REPORT_VMX_TYPE ) { + cpu->env.regs[R_ECX ] = port_state->vmware_vmx_type; + }return port_state->vmware_vmx_version; }
@@ -181,10 +188,30 @@ static Property vmport_properties[] = { VMPORT_COMPAT_READ_SET_EAX_BIT, true),DEFINE_PROP_BIT ("x-signal-unsupported-cmd" , VMPortState, compat_flags,VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT , true), +DEFINE_PROP_BIT ("x-report-vmx-type" , VMPortState, compat_flags, +VMPORT_COMPAT_REPORT_VMX_TYPE_BIT , true),/* Default value taken from open-vm-tools code VERSION_MAGIC definition */ DEFINE_PROP_UINT32 ("vmware-vmx-version" , VMPortState, vmware_vmx_version,6 ), +/* +* Value determines which VMware product type host report itself to guest. +* +* Most guests are fine with exposing host as VMware ESX server. +* Some legacy/proprietary guests hard-code a given type. +* +* For a complete list of values, refer to enum VMXType at open-vm-tools +* project (Defined at lib/include/vm_vmx_type.h). +* +* Reasonable options: +* 0 - Unset +* 1 - VMware Express (deprecated) +* 2 - VMware ESX Server +* 3 - VMware Server (Deprecated) +* 4 - VMware Workstation +* 5 - ACE 1.x (Deprecated) +*/ +DEFINE_PROP_UINT8 ("vmware-vmx-type" , VMPortState, vmware_vmx_type,2 ), DEFINE_PROP_END_OF_LIST(), };
Signature · 1 line
2.26.2
[PULL 063/115] target/i386: fix fbstp handling of out-of-range values
In reply to Paolo BonziniFrom: Joseph Myers <[email protected]>
The fbstp implementation fails to check for out-of-range and invalid values, instead just taking the result of conversion to int64_t and storing its sign and low 18 decimal digits. Fix this by checking for an out-of-range result (invalid conversions always result in INT64_MAX or INT64_MIN from the softfloat code, which are large enough to be considered as out-of-range by this code) and storing the packed BCD indefinite encoding in that case.
Message-Id: <[email protected]>
--- target/i386/fpu_helper.c | 10 +++ tests/tcg/i386/test-i386-fbstp.c | 115 +++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+)
target/i386/fpu_helper.c +10 -0
@@ -732,6 +732,16 @@ void helper_fbst_ST0(CPUX86State *env, target_ulong ptr) val =floatx80_to_int64 (ST0 , &env->fp_status); mem_ref = ptr; +if (val >=1000000000000000000LL || val <=-1000000000000000000LL ) { +float_raise (float_flag_invalid, &env->fp_status); +while (mem_ref < ptr +7 ) { +cpu_stb_data_ra (env, mem_ref++,0 ,GETPC ()); + } +cpu_stb_data_ra (env, mem_ref++,0xc0 ,GETPC ()); +cpu_stb_data_ra (env, mem_ref++,0xff ,GETPC ()); +cpu_stb_data_ra (env, mem_ref++,0xff ,GETPC ()); +return ; + } mem_end = mem_ref +9 ;if (SIGND (temp)) {cpu_stb_data_ra (env, mem_end,0x80 ,GETPC ());
tests/tcg/i386/test-i386-fbstp.c +115 -0
128 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 083/115] sysemu/accel: Restrict machine methods to system-mode
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Restrict init_machine(), setup_post() and has_memory() to system-mode.
Message-Id: <[email protected]>
--- include/sysemu/accel.h | 2 ++ 1 file changed, 2 insertions(+)
include/sysemu/accel.h +2 -0
@@ -37,10 +37,12 @@ typedef struct AccelClass {/*< public >*/ const char *name; +#ifndef CONFIG_USER_ONLY int (*init_machine)(MachineState *ms);void (*setup_post)(MachineState *ms,AccelState *accel);bool (*has_memory)(MachineState *ms,AddressSpace *as,hwaddr start_addr,hwaddr size); +#endif bool *allowed;/* * Array of global properties that would be applied when specific
Signature · 1 line
2.26.2
[PULL 075/115] target/i386: define a new MSR based feature word - FEAT_PERF_CAPABILITIES
In reply to Paolo BonziniFrom: Like Xu <[email protected]>
The Perfmon and Debug Capability MSR named IA32_PERF_CAPABILITIES is a feature-enumerating MSR, which only enumerates the feature full-width write (via bit 13) by now which indicates the processor supports IA32_A_PMCx interface for updating bits 32 and above of IA32_PMCx.
The existence of MSR IA32_PERF_CAPABILITIES is enumerated by CPUID.1:ECX[15].
Message-Id: <[email protected]>
--- target/i386/cpu.c | 23 +++++++++++++++++++++++ target/i386/cpu.h | 3 +++ target/i386/kvm.c | 20 ++++++++++++++++++++ 3 files changed, 46 insertions(+)
target/i386/cpu.c +23 -0
@@ -1139,6 +1139,22 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = { .index = MSR_IA32_CORE_CAPABILITY, }, }, + [FEAT_PERF_CAPABILITIES ] = { + .type =MSR_FEATURE_WORD , + .feat_names = { +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,"full-width-write" ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , + }, + .msr = { + .index =MSR_IA32_PERF_CAPABILITIES , + }, + }, [FEAT_VMX_PROCBASED_CTLS ] = { .type =MSR_FEATURE_WORD ,
@@ -1316,6 +1332,10 @@ static FeatureDep feature_dependencies[] = { .from = { FEAT_7_0_EDX, CPUID_7_0_EDX_CORE_CAPABILITY }, .to = { FEAT_CORE_CAPABILITY, ~0ull }, }, + { + .from = { FEAT_1_ECX, CPUID_EXT_PDCM }, + .to = { FEAT_PERF_CAPABILITIES, ~0ull }, + }, { .from = { FEAT_1_ECX, CPUID_EXT_VMX }, .to = { FEAT_VMX_PROCBASED_CTLS, ~0ull },
@@ -5488,6 +5508,9 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ebx |= (cs->nr_cores * cs->nr_threads) <<16 ; *edx |=CPUID_HT ; } +if (!cpu->enable_pmu) { + *ecx &= ~CPUID_EXT_PDCM ; + }break ;case 2 :/* cache info: needed for Pentium Pro compatibility */
target/i386/cpu.h +3 -0
@@ -356,6 +356,8 @@ typedef enum X86Seg {#define MSR_IA32_ARCH_CAPABILITIES 0x10a#define ARCH_CAP_TSX_CTRL_MSR (1<<7) +#define MSR_IA32_PERF_CAPABILITIES 0x345 +#define MSR_IA32_TSX_CTRL 0x122#define MSR_IA32_TSCDEADLINE 0x6e0
@@ -529,6 +531,7 @@ typedef enum FeatureWord {FEAT_XSAVE_COMP_HI ,/* CPUID[EAX=0xd,ECX=0].EDX */ FEAT_ARCH_CAPABILITIES ,FEAT_CORE_CAPABILITY , +FEAT_PERF_CAPABILITIES ,FEAT_VMX_PROCBASED_CTLS ,FEAT_VMX_SECONDARY_CTLS , FEAT_VMX_PINBASED_CTLS,
target/i386/kvm.c +20 -0
@@ -110,6 +110,7 @@ static bool has_msr_core_capabs;static bool has_msr_vmx_vmfunc;static bool has_msr_ucode_rev;static bool has_msr_vmx_procbased_ctls2; +static bool has_msr_perf_capabs;static uint32_t has_architectural_pmu_version;static uint32_t num_architectural_pmu_gp_counters;
@@ -2033,6 +2034,9 @@ static int kvm_get_supported_msrs(KVMState *s)case MSR_IA32_CORE_CAPABILITY : has_msr_core_capabs = true;break ; +case MSR_IA32_PERF_CAPABILITIES : + has_msr_perf_capabs = true; +break ;case MSR_IA32_VMX_VMFUNC : has_msr_vmx_vmfunc = true;break ;
@@ -2649,6 +2653,18 @@ static void kvm_msr_entry_add_vmx(X86CPU *cpu, FeatureWordArray f) VMCS12_MAX_FIELD_INDEX << 1); } +static void kvm_msr_entry_add_perf (X86CPU *cpu,FeatureWordArray f) +{ +uint64_t kvm_perf_cap = +kvm_arch_get_supported_msr_feature (kvm_state, +MSR_IA32_PERF_CAPABILITIES ); + +if (kvm_perf_cap) { +kvm_msr_entry_add (cpu,MSR_IA32_PERF_CAPABILITIES , + kvm_perf_cap & f[FEAT_PERF_CAPABILITIES ]); + } +} +static int kvm_buf_set_msrs (X86CPU *cpu) {int ret =kvm_vcpu_ioctl (CPU (cpu),KVM_SET_MSRS , cpu->kvm_msr_buf);
@@ -2681,6 +2697,10 @@ static void kvm_init_msrs(X86CPU *cpu) env->features[FEAT_CORE_CAPABILITY]); } +if (has_msr_perf_capabs && cpu->enable_pmu) { +kvm_msr_entry_add_perf (cpu, env->features); + } +if (has_msr_ucode_rev) {kvm_msr_entry_add (cpu,MSR_IA32_UCODE_REV , cpu->ucode_rev); }
Signature · 1 line
2.26.2
[PULL 067/115] vfio/pci: Use kvm_irqchip_add_irqfd_notifier_gsi() for irqfds
In reply to Paolo BonziniFrom: Peter Xu <[email protected]>
VFIO is currently the only one left that is not using the generic function (kvm_irqchip_add_irqfd_notifier_gsi()) to register irqfds. Let VFIO use the common framework too.
Follow up patches will introduce extra features for kvm irqfd, so that VFIO can easily leverage that after the switch.
Message-Id: <[email protected]>
--- hw/vfio/pci.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-)
hw/vfio/pci.c +15 -22
@@ -115,11 +115,7 @@ static void vfio_intx_eoi(VFIODevice *vbasedev)static void vfio_intx_enable_kvm (VFIOPCIDevice *vdev,Error **errp) {#ifdef CONFIG_KVM -struct kvm_irqfd irqfd = { - .fd =event_notifier_get_fd (&vdev->intx.interrupt), - .gsi = vdev->intx.route.irq, - .flags =KVM_IRQFD_FLAG_RESAMPLE , - }; +int irq_fd =event_notifier_get_fd (&vdev->intx.interrupt);Error *err =NULL ; if (vdev->no_kvm_intx || !kvm_irqfds_enabled() ||
@@ -129,7 +125,7 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp) }/* Get to a known interrupt state */ -qemu_set_fd_handler (irqfd.fd,NULL ,NULL , vdev); +qemu_set_fd_handler (irq_fd,NULL ,NULL , vdev);vfio_mask_single_irqindex (&vdev->vbasedev,VFIO_PCI_INTX_IRQ_INDEX ); vdev->intx.pending = false;pci_irq_deassert (&vdev->pdev);
@@ -140,17 +136,18 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp) goto fail; } -/* KVM triggers it, VFIO listens for it */ - irqfd.resamplefd =event_notifier_get_fd (&vdev->intx.unmask); - -if (kvm_vm_ioctl (kvm_state,KVM_IRQFD , &irqfd)) { +if (kvm_irqchip_add_irqfd_notifier_gsi (kvm_state, + &vdev->intx.interrupt, + &vdev->intx.unmask, + vdev->intx.route.irq)) {error_setg_errno (errp, errno,"failed to setup resample irqfd" ); goto fail_irqfd; }if (vfio_set_irq_signaling (&vdev->vbasedev,VFIO_PCI_INTX_IRQ_INDEX ,0 ,VFIO_IRQ_SET_ACTION_UNMASK , - irqfd.resamplefd, &err)) { +event_notifier_get_fd (&vdev->intx.unmask), + &err)) {error_propagate (errp, err); goto fail_vfio; }
@@ -165,12 +162,12 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp)return ; fail_vfio: - irqfd.flags =KVM_IRQFD_FLAG_DEASSIGN ; -kvm_vm_ioctl (kvm_state,KVM_IRQFD , &irqfd); +kvm_irqchip_remove_irqfd_notifier_gsi (kvm_state, &vdev->intx.interrupt, + vdev->intx.route.irq); fail_irqfd:event_notifier_cleanup (&vdev->intx.unmask); fail: -qemu_set_fd_handler (irqfd.fd, vfio_intx_interrupt,NULL , vdev); +qemu_set_fd_handler (irq_fd, vfio_intx_interrupt,NULL , vdev);vfio_unmask_single_irqindex (&vdev->vbasedev,VFIO_PCI_INTX_IRQ_INDEX );#endif }
@@ -178,12 +175,6 @@ fail:static void vfio_intx_disable_kvm (VFIOPCIDevice *vdev) {#ifdef CONFIG_KVM -struct kvm_irqfd irqfd = { - .fd =event_notifier_get_fd (&vdev->intx.interrupt), - .gsi = vdev->intx.route.irq, - .flags =KVM_IRQFD_FLAG_DEASSIGN , - }; -if (!vdev->intx.kvm_accel) {return ; }
@@ -197,7 +188,8 @@ static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev)pci_irq_deassert (&vdev->pdev);/* Tell KVM to stop listening for an INTx irqfd */ -if (kvm_vm_ioctl (kvm_state,KVM_IRQFD , &irqfd)) { +if (kvm_irqchip_remove_irqfd_notifier_gsi (kvm_state, &vdev->intx.interrupt, + vdev->intx.route.irq)) {error_report ("vfio: Error: Failed to disable INTx irqfd: %m" ); }
@@ -205,7 +197,8 @@ static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev)event_notifier_cleanup (&vdev->intx.unmask);/* QEMU starts listening for interrupt events. */ -qemu_set_fd_handler (irqfd.fd, vfio_intx_interrupt,NULL , vdev); +qemu_set_fd_handler (event_notifier_get_fd (&vdev->intx.interrupt), + vfio_intx_interrupt,NULL , vdev); vdev->intx.kvm_accel = false;
Signature · 1 line
2.26.2
[PULL 057/115] exec: Propagate cpu_memory_rw_debug() error
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Do not ignore the MemTxResult error type returned by the address_space_rw() API.
--- exec.c | 12 ++++++++---- include/exec/cpu-all.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-)
exec.c +8 -4
@@ -3771,6 +3771,7 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr,while (len >0 ) {int asidx;MemTxAttrs attrs; +MemTxResult res; page = addr &TARGET_PAGE_MASK ; phys_addr =cpu_get_phys_page_attrs_debug (cpu, page, &attrs);
@@ -3783,11 +3784,14 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr, l = len; phys_addr += (addr & ~TARGET_PAGE_MASK );if (is_write) { -address_space_write_rom (cpu->cpu_ases[asidx].as, phys_addr, - attrs, buf, l); + res =address_space_write_rom (cpu->cpu_ases[asidx].as, phys_addr, + attrs, buf, l); }else { -address_space_read (cpu->cpu_ases[asidx].as, phys_addr, attrs, buf, - l); + res =address_space_read (cpu->cpu_ases[asidx].as, phys_addr, + attrs, buf, l); + } +if (res !=MEMTX_OK ) { +return -1 ; } len -= l; buf += l;
include/exec/cpu-all.h +1 -0
@@ -413,6 +413,7 @@ void dump_exec_info(void);void dump_opcount_info (void );#endif /* !CONFIG_USER_ONLY */ +/* Returns: 0 on success, -1 on error */ int cpu_memory_rw_debug (CPUState *cpu,target_ulong addr,void *ptr,target_ulong len,bool is_write);
Signature · 1 line
2.26.2
[PULL 090/115] i386: hvf: Use ins_len to advance IP
In reply to Paolo BonziniFrom: Roman Bolshakov <[email protected]>
There's no need to read VMCS twice, instruction length is already available in ins_len.
Message-Id: <[email protected]>
--- target/i386/hvf/hvf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/hvf/hvf.c +1 -1
@@ -871,7 +871,7 @@ int hvf_vcpu_exec(CPUState *cpu) }else {simulate_wrmsr (cpu); } -RIP (env) +=rvmcs (cpu->hvf_fd,VMCS_EXIT_INSTRUCTION_LENGTH ); +RIP (env) += ins_len;store_regs (cpu);break ; }
Signature · 1 line
2.26.2
[PULL 095/115] i386: hvf: Drop regs in HVFX86EmulatorState
In reply to Paolo BonziniFrom: Roman Bolshakov <[email protected]>
HVFX86EmulatorState carries it's own copy of x86 registers. It can be dropped in favor of regs in generic CPUX86State.
Message-Id: <[email protected]>
--- target/i386/hvf/x86.h | 13 +++++++------ target/i386/hvf/x86_emu.c | 18 +++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-)
target/i386/hvf/x86.h +7 -6
@@ -235,13 +235,14 @@ typedef struct lazy_flags {/* Definition of hvf_x86_state is here */ struct HVFX86EmulatorState { -struct x86_register regs[16 ];struct lazy_flags lflags;uint8_t mmio_buf[4096 ]; };/* useful register access macros */ -#define RRX (cpu, reg) (cpu->hvf_emul->regs[reg].rrx) +#define x86_reg (cpu, reg) ((x86_register *) &cpu->regs[reg]) + +#define RRX (cpu, reg) (x86_reg(cpu, reg)->rrx)#define RAX (cpu) RRX(cpu, R_EAX)#define RCX (cpu) RRX(cpu, R_ECX)#define RDX (cpu) RRX(cpu, R_EDX)
@@ -259,7 +260,7 @@ struct HVFX86EmulatorState {#define R14 (cpu) RRX(cpu, R_R14)#define R15 (cpu) RRX(cpu, R_R15) -#define ERX (cpu, reg) (cpu->hvf_emul->regs[reg].erx) +#define ERX (cpu, reg) (x86_reg(cpu, reg)->erx)#define EAX (cpu) ERX(cpu, R_EAX)#define ECX (cpu) ERX(cpu, R_ECX)#define EDX (cpu) ERX(cpu, R_EDX)
@@ -269,7 +270,7 @@ struct HVFX86EmulatorState {#define ESI (cpu) ERX(cpu, R_ESI)#define EDI (cpu) ERX(cpu, R_EDI) -#define RX (cpu, reg) (cpu->hvf_emul->regs[reg].rx) +#define RX (cpu, reg) (x86_reg(cpu, reg)->rx)#define AX (cpu) RX(cpu, R_EAX)#define CX (cpu) RX(cpu, R_ECX)#define DX (cpu) RX(cpu, R_EDX)
@@ -279,13 +280,13 @@ struct HVFX86EmulatorState {#define SI (cpu) RX(cpu, R_ESI)#define DI (cpu) RX(cpu, R_EDI) -#define RL (cpu, reg) (cpu->hvf_emul->regs[reg].lx) +#define RL (cpu, reg) (x86_reg(cpu, reg)->lx)#define AL (cpu) RL(cpu, R_EAX)#define CL (cpu) RL(cpu, R_ECX)#define DL (cpu) RL(cpu, R_EDX)#define BL (cpu) RL(cpu, R_EBX) -#define RH (cpu, reg) (cpu->hvf_emul->regs[reg].hx) +#define RH (cpu, reg) (x86_reg(cpu, reg)->hx)#define AH (cpu) RH(cpu, R_EAX)#define CH (cpu) RH(cpu, R_ECX)#define DH (cpu) RH(cpu, R_EDX)
target/i386/hvf/x86_emu.c +9 -9
@@ -95,13 +95,13 @@ target_ulong read_reg(CPUX86State *env, int reg, int size) {switch (size) {case 1 : -return env->hvf_emul->regs[reg].lx; +return x86_reg (env, reg)->lx;case 2 : -return env->hvf_emul->regs[reg].rx; +return x86_reg (env, reg)->rx;case 4 : -return env->hvf_emul->regs[reg].erx; +return x86_reg (env, reg)->erx;case 8 : -return env->hvf_emul->regs[reg].rrx; +return x86_reg (env, reg)->rrx;default :abort (); }
@@ -112,16 +112,16 @@ void write_reg(CPUX86State *env, int reg, target_ulong val, int size) {switch (size) {case 1 : - env->hvf_emul->regs[reg].lx = val; +x86_reg (env, reg)->lx = val;break ;case 2 : - env->hvf_emul->regs[reg].rx = val; +x86_reg (env, reg)->rx = val;break ;case 4 : - env->hvf_emul->regs[reg].rrx = (uint32_t )val; +x86_reg (env, reg)->rrx = (uint32_t )val;break ;case 8 : - env->hvf_emul->regs[reg].rrx = val; +x86_reg (env, reg)->rrx = val;break ;default :abort ();
@@ -173,7 +173,7 @@ void write_val_to_reg(target_ulong reg_ptr, target_ulong val, int size)static bool is_host_reg (struct CPUX86State *env,target_ulong ptr) { -return (ptr - (target_ulong)&env->hvf_emul->regs[0 ]) <sizeof (env->hvf_emul->regs); +return (ptr - (target_ulong)&env->regs[0 ]) <sizeof (env->regs); }void write_val_ext (struct CPUX86State *env,target_ulong ptr,target_ulong val,int size)
Signature · 1 line
2.26.2
[PULL 019/115] vmbus: vmbus implementation
In reply to Paolo BonziniFrom: Jon Doron <[email protected]>
Add the VMBus infrastructure -- bus, devices, root bridge, vmbus state machine, vmbus channel interactions, etc.
VMBus is a collection of technologies. At its lowest layer, it's a message passing and signaling mechanism, allowing efficient passing of messages to and from guest VMs. A layer higher, it's a mechanism for defining channels of communication, where each channel is tagged with a type (which implies a protocol) and a instance ID. A layer higher than that, it's a bus driver, serving as the basis of device enumeration within a VM, where a channel can optionally be exposed as a paravirtual device. When a server-side (paravirtual back-end) component wishes to offer a channel to a guest VM, it does so by specifying a channel type, a mode, and an instance ID. VMBus then exposes this in the guest.
More information about VMBus can be found in the file vmbuskernelmodeclientlibapi.h in Microsoft's WDK.
TODO:
- split into smaller palatable pieces
- more comments
- check and handle corner cases
Kudos to Evgeny Yakovlev (formerly [email protected]) and Andrey Smetatin (formerly [email protected]) for research and prototyping.
Message-Id: <[email protected]>
--- Makefile.objs | 1 + hw/hyperv/Kconfig | 5 + hw/hyperv/Makefile.objs | 1 + hw/hyperv/trace-events | 18 + hw/hyperv/vmbus.c | 2672 ++++++++++++++++++++++++++++++ include/hw/hyperv/vmbus-bridge.h | 32 + include/hw/hyperv/vmbus.h | 227 +++ 7 files changed, 2956 insertions(+) create mode 100644 hw/hyperv/trace-events create mode 100644 hw/hyperv/vmbus.c create mode 100644 include/hw/hyperv/vmbus-bridge.h create mode 100644 include/hw/hyperv/vmbus.h
Makefile.objs +1 -0
@@ -150,6 +150,7 @@ trace-events-subdirs += hw/block/dataplane trace-events-subdirs += hw/char trace-events-subdirs += hw/dma trace-events-subdirs += hw/hppa +trace-events-subdirs += hw/hyperv trace-events-subdirs += hw/i2c trace-events-subdirs += hw/i386 trace-events-subdirs += hw/i386/xen
hw/hyperv/Kconfig +5 -0
@@ -6,3 +6,8 @@ config HYPERV_TESTDEV bool default y if TEST_DEVICES depends on HYPERV + +config VMBUS + bool + default y + depends on HYPERV
hw/hyperv/Makefile.objs +1 -0
@@ -1,2 +1,3 @@ obj-y += hyperv.o obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o +obj-$(CONFIG_VMBUS) += vmbus.o
hw/hyperv/trace-events new file +18 -0
@@ -0,0 +1,18 @@ +# vmbus +vmbus_recv_message(uint32_t type, uint32_t size) "type %d size %d" +vmbus_signal_event(void) "" +vmbus_channel_notify_guest(uint32_t chan_id) "channel #%d" +vmbus_post_msg(uint32_t type, uint32_t size) "type %d size %d" +vmbus_msg_cb(int status) "message status %d" +vmbus_process_incoming_message(uint32_t message_type) "type %d" +vmbus_initiate_contact(uint16_t major, uint16_t minor, uint32_t vcpu, uint64_t monitor_page1, uint64_t monitor_page2, uint64_t interrupt_page) "version %d.%d target vp %d mon pages 0x%"PRIx64",0x%"PRIx64" int page 0x%"PRIx64 +vmbus_send_offer(uint32_t chan_id, void *dev) "channel #%d dev %p" +vmbus_terminate_offers(void) "" +vmbus_gpadl_header(uint32_t gpadl_id, uint16_t num_gfns) "gpadl #%d gfns %d" +vmbus_gpadl_body(uint32_t gpadl_id) "gpadl #%d" +vmbus_gpadl_created(uint32_t gpadl_id) "gpadl #%d" +vmbus_gpadl_teardown(uint32_t gpadl_id) "gpadl #%d" +vmbus_gpadl_torndown(uint32_t gpadl_id) "gpadl #%d" +vmbus_open_channel(uint32_t chan_id, uint32_t gpadl_id, uint32_t target_vp) "channel #%d gpadl #%d target vp %d" +vmbus_channel_open(uint32_t chan_id, uint32_t status) "channel #%d status %d" +vmbus_close_channel(uint32_t chan_id) "channel #%d"
hw/hyperv/vmbus.c new file +2672 -0
2,672 lines not on this page · raw message
include/hw/hyperv/vmbus-bridge.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* QEMU Hyper-V VMBus root bridge +* +* Copyright (c) 2017-2018 Virtuozzo International GmbH. +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef HW_HYPERV_VMBUS_BRIDGE_H +#define HW_HYPERV_VMBUS_BRIDGE_H + +#include "hw/sysbus.h" + +#define TYPE_VMBUS_BRIDGE "vmbus-bridge" + +typedef struct VMBus VMBus ; + +typedef struct VMBusBridge { +SysBusDevice parent_obj; + +VMBus *bus; +}VMBusBridge ; + +#define VMBUS_BRIDGE (obj) OBJECT_CHECK(VMBusBridge, (obj), TYPE_VMBUS_BRIDGE) + +static inline VMBusBridge *vmbus_bridge_find (void ) +{ +return VMBUS_BRIDGE (object_resolve_path_type ("" ,TYPE_VMBUS_BRIDGE ,NULL )); +} + +#endif
include/hw/hyperv/vmbus.h new file +227 -0
227 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 072/115] hw/i386/amd_iommu: Fix the reserved bits definition of IOMMU commands
In reply to Paolo BonziniFrom: Wei Huang <[email protected]>
Many reserved bits of amd_iommu commands are defined incorrectly in QEMU. Because of it, QEMU incorrectly injects lots of illegal commands into guest VM's IOMMU event log.
Message-Id: <[email protected]>
--- hw/i386/amd_iommu.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
hw/i386/amd_iommu.c +10 -9
@@ -370,7 +370,7 @@ static void amdvi_completion_wait(AMDVIState *s, uint64_t *cmd)hwaddr addr =cpu_to_le64 (extract64 (cmd[0 ],3 ,49 )) <<3 ;uint64_t data =cpu_to_le64 (cmd[1 ]); -if (extract64 (cmd[0 ],51 ,8 )) { +if (extract64 (cmd[0 ],52 ,8 )) {amdvi_log_illegalcom_error (s,extract64 (cmd[0 ],60 ,4 ), s->cmdbuf + s->cmdbuf_head); }
@@ -395,7 +395,7 @@ static void amdvi_inval_devtab_entry(AMDVIState *s, uint64_t *cmd)uint16_t devid =cpu_to_le16 ((uint16_t )extract64 (cmd[0 ],0 ,16 ));/* This command should invalidate internal caches of which there isn't */ -if (extract64 (cmd[0 ],15 ,16 ) || cmd[1 ]) { +if (extract64 (cmd[0 ],16 ,44 ) || cmd[1 ]) {amdvi_log_illegalcom_error (s,extract64 (cmd[0 ],60 ,4 ), s->cmdbuf + s->cmdbuf_head); }
@@ -405,9 +405,9 @@ static void amdvi_inval_devtab_entry(AMDVIState *s, uint64_t *cmd)static void amdvi_complete_ppr (AMDVIState *s,uint64_t *cmd) { -if (extract64 (cmd[0 ],15 ,16 ) ||extract64 (cmd[0 ],19 ,8 ) || +if (extract64 (cmd[0 ],16 ,16 ) ||extract64 (cmd[0 ],52 ,8 ) ||extract64 (cmd[1 ],0 ,2 ) ||extract64 (cmd[1 ],3 ,29 ) - ||extract64 (cmd[1 ],47 ,16 )) { + ||extract64 (cmd[1 ],48 ,16 )) {amdvi_log_illegalcom_error (s,extract64 (cmd[0 ],60 ,4 ), s->cmdbuf + s->cmdbuf_head); }
@@ -438,8 +438,8 @@ static void amdvi_inval_pages(AMDVIState *s, uint64_t *cmd) {uint16_t domid =cpu_to_le16 ((uint16_t )extract64 (cmd[0 ],32 ,16 )); -if (extract64 (cmd[0 ],20 ,12 ) ||extract64 (cmd[0 ],16 ,12 ) || -extract64 (cmd[0 ],3 ,10 )) { +if (extract64 (cmd[0 ],20 ,12 ) ||extract64 (cmd[0 ],48 ,12 ) || +extract64 (cmd[1 ],3 ,9 )) {amdvi_log_illegalcom_error (s,extract64 (cmd[0 ],60 ,4 ), s->cmdbuf + s->cmdbuf_head); }
@@ -451,7 +451,7 @@ static void amdvi_inval_pages(AMDVIState *s, uint64_t *cmd)static void amdvi_prefetch_pages (AMDVIState *s,uint64_t *cmd) { -if (extract64 (cmd[0 ],16 ,8 ) ||extract64 (cmd[0 ],20 ,8 ) || +if (extract64 (cmd[0 ],16 ,8 ) ||extract64 (cmd[0 ],52 ,8 ) ||extract64 (cmd[1 ],1 ,1 ) ||extract64 (cmd[1 ],3 ,1 ) ||extract64 (cmd[1 ],5 ,7 )) { amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4),
@@ -463,7 +463,7 @@ static void amdvi_prefetch_pages(AMDVIState *s, uint64_t *cmd)static void amdvi_inval_inttable (AMDVIState *s,uint64_t *cmd) { -if (extract64 (cmd[0 ],16 ,16 ) || cmd[1 ]) { +if (extract64 (cmd[0 ],16 ,44 ) || cmd[1 ]) {amdvi_log_illegalcom_error (s,extract64 (cmd[0 ],60 ,4 ), s->cmdbuf + s->cmdbuf_head);return ;
@@ -479,7 +479,8 @@ static void iommu_inval_iotlb(AMDVIState *s, uint64_t *cmd) {uint16_t devid =extract64 (cmd[0 ],0 ,16 ); -if (extract64 (cmd[1 ],1 ,1 ) ||extract64 (cmd[1 ],3 ,9 )) { +if (extract64 (cmd[1 ],1 ,1 ) ||extract64 (cmd[1 ],3 ,1 ) || +extract64 (cmd[1 ],6 ,6 )) {amdvi_log_illegalcom_error (s,extract64 (cmd[0 ],60 ,4 ), s->cmdbuf + s->cmdbuf_head);return ;
Signature · 1 line
2.26.2
[PULL 087/115] i386: hvf: Move HVFState definition into hvf
In reply to Paolo BonziniFrom: Roman Bolshakov <[email protected]>
"sysemu/hvf.h" is intended for inclusion in generic code. However it also contains several hvf definitions and declarations, including HVFState that are used only inside "hvf.c". "hvf-i386.h" would be more appropriate place to define HVFState as it's only included by "hvf.c" and "x86_task.c".
Message-Id: <[email protected]>
--- include/sysemu/hvf.h | 37 ------------------------------------- target/i386/hvf/hvf-i386.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 37 deletions(-)
include/sysemu/hvf.h +0 -37
@@ -15,8 +15,6 @@#include "cpu.h" #include "qemu/bitops.h" -#include "exec/memory.h" -#include "sysemu/accel.h" #ifdef CONFIG_HVF #include <Hypervisor/hv.h>
@@ -32,41 +30,6 @@ extern bool hvf_allowed;#define hvf_get_supported_cpuid (func, idx, reg) 0#endif /* !CONFIG_HVF */ -/* hvf_slot flags */ -#define HVF_SLOT_LOG (1 << 0) - -typedef struct hvf_slot { -uint64_t start; -uint64_t size; -uint8_t *mem; -int slot_id; -uint32_t flags; -MemoryRegion *region; -}hvf_slot ; - -typedef struct hvf_vcpu_caps { -uint64_t vmx_cap_pinbased; -uint64_t vmx_cap_procbased; -uint64_t vmx_cap_procbased2; -uint64_t vmx_cap_entry; -uint64_t vmx_cap_exit; -uint64_t vmx_cap_preemption_timer; -}hvf_vcpu_caps ; - -typedef struct HVFState { -AccelState parent; -hvf_slot slots[32 ]; -int num_slots; - -hvf_vcpu_caps *hvf_caps; -}HVFState ; -extern HVFState *hvf_state; - -void hvf_set_phys_mem (MemoryRegionSection *,bool ); -void hvf_handle_io (CPUArchState *,uint16_t ,void *, -int ,int ,int ); -hvf_slot *hvf_find_overlap_slot (uint64_t ,uint64_t ); -/* Disable HVF if |disable| is 1, otherwise, enable it iff it is supported by * the host CPU. Use hvf_enabled() after this to get the result. */ void hvf_disable (int disable);
target/i386/hvf/hvf-i386.h +35 -0
@@ -16,6 +16,7 @@#ifndef HVF_I386_H #define HVF_I386_H +#include "sysemu/accel.h" #include "sysemu/hvf.h" #include "cpu.h" #include "x86.h"
@@ -35,6 +36,40 @@ struct hvf_state {uint64_t mem_quota; }; +/* hvf_slot flags */ +#define HVF_SLOT_LOG (1 << 0) + +typedef struct hvf_slot { +uint64_t start; +uint64_t size; +uint8_t *mem; +int slot_id; +uint32_t flags; +MemoryRegion *region; +}hvf_slot ; + +typedef struct hvf_vcpu_caps { +uint64_t vmx_cap_pinbased; +uint64_t vmx_cap_procbased; +uint64_t vmx_cap_procbased2; +uint64_t vmx_cap_entry; +uint64_t vmx_cap_exit; +uint64_t vmx_cap_preemption_timer; +}hvf_vcpu_caps ; + +typedef struct HVFState { +AccelState parent; +hvf_slot slots[32 ]; +int num_slots; + +hvf_vcpu_caps *hvf_caps; +}HVFState ; +extern HVFState *hvf_state; + +void hvf_set_phys_mem (MemoryRegionSection *,bool ); +void hvf_handle_io (CPUArchState *,uint16_t ,void *,int ,int ,int ); +hvf_slot *hvf_find_overlap_slot (uint64_t ,uint64_t ); +#ifdef NEED_CPU_H /* Functions exported to host specific mode */
Signature · 1 line
2.26.2
[PULL 097/115] i386: hvf: Move mmio_buf into CPUX86State
In reply to Paolo BonziniFrom: Roman Bolshakov <[email protected]>
There's no similar field in CPUX86State, but it's needed for MMIO traps.
Message-Id: <[email protected]>
--- target/i386/cpu.h | 1 + target/i386/hvf/hvf.c | 5 +++++ target/i386/hvf/x86.h | 1 - target/i386/hvf/x86_emu.c | 12 ++++++------ 4 files changed, 12 insertions(+), 7 deletions(-)
target/i386/cpu.h +1 -0
@@ -1599,6 +1599,7 @@ typedef struct CPUX86State {#endif #if defined(CONFIG_HVF )hvf_lazy_flags hvf_lflags; +void *hvf_mmio_buf;HVFX86EmulatorState *hvf_emul;#endif
target/i386/hvf/hvf.c +5 -0
@@ -533,7 +533,11 @@ void hvf_reset_vcpu(CPUState *cpu) {void hvf_vcpu_destroy (CPUState *cpu) { +X86CPU *x86_cpu =X86_CPU (cpu); +CPUX86State *env = &x86_cpu->env; +hv_return_t ret =hv_vcpu_destroy ((hv_vcpuid_t )cpu->hvf_fd); +g_free (env->hvf_mmio_buf);assert_hvf_ok (ret); }
@@ -563,6 +567,7 @@ int hvf_init_vcpu(CPUState *cpu)init_decoder (); hvf_state->hvf_caps = g_new0(struct hvf_vcpu_caps, 1); + env->hvf_mmio_buf =g_new (char,4096 ); env->hvf_emul =g_new0 (HVFX86EmulatorState,1 ); r =hv_vcpu_create ((hv_vcpuid_t *)&cpu->hvf_fd,HV_VCPU_DEFAULT );
target/i386/hvf/x86.h +0 -1
@@ -230,7 +230,6 @@ typedef struct x68_segment_selector {/* Definition of hvf_x86_state is here */ struct HVFX86EmulatorState { -uint8_t mmio_buf[4096 ]; };/* useful register access macros */
target/i386/hvf/x86_emu.c +6 -6
@@ -187,8 +187,8 @@ void write_val_ext(struct CPUX86State *env, target_ulong ptr, target_ulong val,uint8_t *read_mmio (struct CPUX86State *env,target_ulong ptr,int bytes) { -vmx_read_mem (env_cpu (env), env->hvf_emul->mmio_buf, ptr, bytes); -return env->hvf_emul->mmio_buf; +vmx_read_mem (env_cpu (env), env->hvf_mmio_buf, ptr, bytes); +return env->hvf_mmio_buf; }
@@ -489,9 +489,9 @@ static void exec_ins_single(struct CPUX86State *env, struct x86_decode *decode)target_ulong addr =linear_addr_size (env_cpu (env),RDI (env), decode->addressing_size,R_ES ); -hvf_handle_io (env_cpu (env),DX (env), env->hvf_emul->mmio_buf,0 , +hvf_handle_io (env_cpu (env),DX (env), env->hvf_mmio_buf,0 , decode->operand_size,1 ); -vmx_write_mem (env_cpu (env), addr, env->hvf_emul->mmio_buf, +vmx_write_mem (env_cpu (env), addr, env->hvf_mmio_buf, decode->operand_size);string_increment_reg (env,R_EDI , decode);
@@ -512,9 +512,9 @@ static void exec_outs_single(struct CPUX86State *env, struct x86_decode *decode) {target_ulong addr =decode_linear_addr (env, decode,RSI (env),R_DS ); -vmx_read_mem (env_cpu (env), env->hvf_emul->mmio_buf, addr, +vmx_read_mem (env_cpu (env), env->hvf_mmio_buf, addr, decode->operand_size); -hvf_handle_io (env_cpu (env),DX (env), env->hvf_emul->mmio_buf,1 , +hvf_handle_io (env_cpu (env),DX (env), env->hvf_mmio_buf,1 , decode->operand_size,1 );string_increment_reg (env,R_ESI , decode);
Signature · 1 line
2.26.2
[PULL 022/115] vmbus: add infrastructure to save/load vmbus requests
In reply to Paolo BonziniFrom: Jon Doron <[email protected]>
This can be allow to include controller-specific data while saving/loading in-flight scsi requests of the vmbus scsi controller.
Message-Id: <[email protected]>
--- hw/hyperv/vmbus.c | 99 +++++++++++++++++++++++++++++++++++++++ include/hw/hyperv/vmbus.h | 3 ++ 2 files changed, 102 insertions(+)
hw/hyperv/vmbus.c +99 -0
@@ -1272,6 +1272,105 @@ void vmbus_free_req(void *req)g_free (req); } +static const VMStateDescription vmstate_sgent = { + .name ="vmbus/sgentry" , + .version_id =0 , + .minimum_version_id =0 , + .fields = (VMStateField []) { +VMSTATE_UINT64 (base, ScatterGatherEntry), +VMSTATE_UINT64 (len, ScatterGatherEntry), +VMSTATE_END_OF_LIST () + } +}; + +typedef struct VMBusChanReqSave { +uint16_t chan_idx; +uint16_t pkt_type; +uint32_t msglen; +void *msg; +uint64_t transaction_id; +bool need_comp; +uint32_t num; +ScatterGatherEntry *sgl; +}VMBusChanReqSave ; + +static const VMStateDescription vmstate_vmbus_chan_req = { + .name ="vmbus/vmbus_chan_req" , + .version_id =0 , + .minimum_version_id =0 , + .fields = (VMStateField []) { +VMSTATE_UINT16 (chan_idx, VMBusChanReqSave), +VMSTATE_UINT16 (pkt_type, VMBusChanReqSave), +VMSTATE_UINT32 (msglen, VMBusChanReqSave), +VMSTATE_VBUFFER_ALLOC_UINT32 (msg, VMBusChanReqSave,0 ,NULL , msglen), +VMSTATE_UINT64 (transaction_id, VMBusChanReqSave), +VMSTATE_BOOL (need_comp, VMBusChanReqSave), +VMSTATE_UINT32 (num, VMBusChanReqSave), +VMSTATE_STRUCT_VARRAY_POINTER_UINT32 (sgl, VMBusChanReqSave, num, + vmstate_sgent, ScatterGatherEntry), +VMSTATE_END_OF_LIST () + } +}; + +void vmbus_save_req (QEMUFile *f,VMBusChanReq *req) +{ +VMBusChanReqSave req_save; + + req_save.chan_idx = req->chan->subchan_idx; + req_save.pkt_type = req->pkt_type; + req_save.msglen = req->msglen; + req_save.msg = req->msg; + req_save.transaction_id = req->transaction_id; + req_save.need_comp = req->need_comp; + req_save.num = req->sgl.nsg; + req_save.sgl =g_memdup (req->sgl.sg, + req_save.num *sizeof (ScatterGatherEntry)); + +vmstate_save_state (f, &vmstate_vmbus_chan_req, &req_save,NULL ); + +g_free (req_save.sgl); +} + +void *vmbus_load_req (QEMUFile *f,VMBusDevice *dev,uint32_t size) +{ +VMBusChanReqSave req_save; +VMBusChanReq *req =NULL ; +VMBusChannel *chan =NULL ; +uint32_t i; + +vmstate_load_state (f, &vmstate_vmbus_chan_req, &req_save,0 ); + +if (req_save.chan_idx >= dev->num_channels) { +error_report ("%s: %u(chan_idx) > %u(num_channels)" , __func__, + req_save.chan_idx, dev->num_channels); + goto out; + } + chan = &dev->channels[req_save.chan_idx]; + +if (vmbus_channel_reserve (chan,0 , req_save.msglen)) { + goto out; + } + + req =vmbus_alloc_req (chan, size, req_save.pkt_type, req_save.msglen, + req_save.transaction_id, req_save.need_comp); +if (req_save.msglen) { +memcpy (req->msg, req_save.msg, req_save.msglen); + } + +for (i =0 ; i < req_save.num; i++) { +qemu_sglist_add (&req->sgl, req_save.sgl[i].base, req_save.sgl[i].len); + } + +out: +if (req_save.msglen) { +g_free (req_save.msg); + } +if (req_save.num) { +g_free (req_save.sgl); + } +return req; +} +static void channel_event_cb (EventNotifier *e) {VMBusChannel *chan =container_of (e, VMBusChannel, notifier);
include/hw/hyperv/vmbus.h +3 -0
@@ -224,4 +224,7 @@ int vmbus_map_sgl(VMBusChanReq *req, DMADirection dir, struct iovec *iov,void vmbus_unmap_sgl (VMBusChanReq *req,DMADirection dir,struct iovec *iov,unsigned iov_cnt,size_t accessed); +void vmbus_save_req (QEMUFile *f,VMBusChanReq *req); +void *vmbus_load_req (QEMUFile *f,VMBusDevice *dev,uint32_t size); +#endif
Signature · 1 line
2.26.2
[PULL 071/115] tests: machine-none-test: Enable MicroBlaze testing
In reply to Paolo BonziniFrom: "Edgar E. Iglesias" <[email protected]>
Enable MicroBlaze testing.
Message-Id: <[email protected]>
--- tests/qtest/machine-none-test.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
tests/qtest/machine-none-test.c +4 -6
@@ -33,8 +33,8 @@ static struct arch2cpu cpus_map[] = { { "cris", "crisv32" }, { "lm32", "lm32-full" }, { "m68k", "m5206" }, -/* FIXME: { "microblaze", "any" }, doesn't work with -M none -cpu any */ -/* FIXME: { "microblazeel", "any" }, doesn't work with -M none -cpu any */ + { "microblaze", "any" }, + { "microblazeel", "any" }, { "mips", "4Kc" }, { "mipsel", "I7200" }, { "mips64", "20Kc" },
@@ -79,10 +79,8 @@ static void test_machine_cpu_cli(void)QTestState *qts;if (!cpu_model) { -if (!(!strcmp (arch,"microblaze" ) || !strcmp (arch,"microblazeel" ))) { -fprintf (stderr,"WARNING: cpu name for target '%s' isn't defined," -" add it to cpus_map\n" , arch); - } +fprintf (stderr,"WARNING: cpu name for target '%s' isn't defined," +" add it to cpus_map\n" , arch);return ;/* TODO: die here to force all targets have a test */ } qts =qtest_initf ("-machine none -cpu '%s'" , cpu_model);
Signature · 1 line
2.26.2
[PULL 098/115] i386: hvf: Drop HVFX86EmulatorState
In reply to Paolo BonziniFrom: Roman Bolshakov <[email protected]>
Message-Id: <[email protected]>
--- include/qemu/typedefs.h | 1 - target/i386/cpu.h | 1 - target/i386/hvf/hvf.c | 1 - target/i386/hvf/x86.h | 4 ---- 4 files changed, 7 deletions(-)
include/qemu/typedefs.h +0 -1
@@ -51,7 +51,6 @@ typedef struct FWCfgIoState FWCfgIoState;typedef struct FWCfgMemState FWCfgMemState ;typedef struct FWCfgState FWCfgState ;typedef struct HostMemoryBackend HostMemoryBackend ; -typedef struct HVFX86EmulatorState HVFX86EmulatorState ;typedef struct I2CBus I2CBus ;typedef struct I2SCodec I2SCodec ;typedef struct IOMMUMemoryRegion IOMMUMemoryRegion ;
target/i386/cpu.h +0 -1
@@ -1600,7 +1600,6 @@ typedef struct CPUX86State {#if defined(CONFIG_HVF )hvf_lazy_flags hvf_lflags;void *hvf_mmio_buf; -HVFX86EmulatorState *hvf_emul;#endif uint64_t mcg_cap;
target/i386/hvf/hvf.c +0 -1
@@ -568,7 +568,6 @@ int hvf_init_vcpu(CPUState *cpu) hvf_state->hvf_caps = g_new0(struct hvf_vcpu_caps, 1); env->hvf_mmio_buf =g_new (char,4096 ); - env->hvf_emul =g_new0 (HVFX86EmulatorState,1 ); r =hv_vcpu_create ((hv_vcpuid_t *)&cpu->hvf_fd,HV_VCPU_DEFAULT ); cpu->vcpu_dirty =1 ;
target/i386/hvf/x86.h +0 -4
@@ -228,10 +228,6 @@ typedef struct x68_segment_selector { }; } __attribute__ ((__packed__)) x68_segment_selector; -/* Definition of hvf_x86_state is here */ -struct HVFX86EmulatorState { -}; -/* useful register access macros */ #define x86_reg (cpu, reg) ((x86_register *) &cpu->regs[reg])
Signature · 1 line
2.26.2
[PULL 093/115] i386: hvf: Drop rflags from HVFX86EmulatorState
In reply to Paolo BonziniFrom: Roman Bolshakov <[email protected]>
HVFX86EmulatorState carries it's own copy of x86 flags. It can be dropped in favor of eflags in generic CPUX86State.
Message-Id: <[email protected]>
--- target/i386/hvf/hvf.c | 5 ++--- target/i386/hvf/x86.c | 2 +- target/i386/hvf/x86.h | 42 ------------------------------------- target/i386/hvf/x86_emu.c | 6 +++--- target/i386/hvf/x86_flags.c | 24 ++++++++++----------- target/i386/hvf/x86_task.c | 6 +++--- target/i386/hvf/x86hvf.c | 6 +++--- 7 files changed, 24 insertions(+), 67 deletions(-)
target/i386/hvf/hvf.c +2 -3
@@ -723,8 +723,7 @@ int hvf_vcpu_exec(CPUState *cpu)hvf_store_events (cpu, ins_len, idtvec_info); rip =rreg (cpu->hvf_fd,HV_X86_RIP ); -RFLAGS (env) =rreg (cpu->hvf_fd,HV_X86_RFLAGS ); - env->eflags =RFLAGS (env); + env->eflags =rreg (cpu->hvf_fd,HV_X86_RFLAGS );qemu_mutex_lock_iothread ();
@@ -736,7 +735,7 @@ int hvf_vcpu_exec(CPUState *cpu)case EXIT_REASON_HLT : {macvm_set_rip (cpu, rip + ins_len);if (!((cpu->interrupt_request &CPU_INTERRUPT_HARD ) && - (EFLAGS (env) &IF_MASK )) + (env->eflags &IF_MASK )) && !(cpu->interrupt_request &CPU_INTERRUPT_NMI ) && !(idtvec_info &VMCS_IDT_VEC_VALID )) { cpu->halted =1 ;
target/i386/hvf/x86.c +1 -1
@@ -131,7 +131,7 @@ bool x86_is_v8086(struct CPUState *cpu) {X86CPU *x86_cpu =X86_CPU (cpu);CPUX86State *env = &x86_cpu->env; -return x86_is_protected (cpu) && (RFLAGS (env) &RFLAGS_VM ); +return x86_is_protected (cpu) && (env->eflags &RFLAGS_VM ); }bool x86_is_long_mode (struct CPUState *cpu)
target/i386/hvf/x86.h +0 -42
59 lines not on this page · raw message
target/i386/hvf/x86_emu.c +3 -3
@@ -459,7 +459,7 @@ static inline void string_increment_reg(struct CPUX86State *env, int reg, struct x86_decode *decode) {target_ulong val =read_reg (env, reg, decode->addressing_size); -if (env->hvf_emul->rflags.df) { +if (env->eflags &DF_MASK ) { val -= decode->operand_size; }else { val += decode->operand_size;
@@ -1432,7 +1432,7 @@ void load_regs(struct CPUState *cpu)RRX (env, i) =rreg (cpu->hvf_fd,HV_X86_RAX + i); } -RFLAGS (env) =rreg (cpu->hvf_fd,HV_X86_RFLAGS ); + env->eflags =rreg (cpu->hvf_fd,HV_X86_RFLAGS );rflags_to_lflags (env); env->eip =rreg (cpu->hvf_fd,HV_X86_RIP ); }
@@ -1456,7 +1456,7 @@ void store_regs(struct CPUState *cpu) }lflags_to_rflags (env); -wreg (cpu->hvf_fd,HV_X86_RFLAGS ,RFLAGS (env)); +wreg (cpu->hvf_fd,HV_X86_RFLAGS , env->eflags);macvm_set_rip (cpu, env->eip); }
target/i386/hvf/x86_flags.c +12 -12
@@ -295,21 +295,21 @@ void set_SF(CPUX86State *env, bool val)void lflags_to_rflags (CPUX86State *env) { - env->hvf_emul->rflags.cf =get_CF (env); - env->hvf_emul->rflags.pf =get_PF (env); - env->hvf_emul->rflags.af =get_AF (env); - env->hvf_emul->rflags.zf =get_ZF (env); - env->hvf_emul->rflags.sf =get_SF (env); - env->hvf_emul->rflags.of =get_OF (env); + env->eflags |=get_CF (env) ?CC_C :0 ; + env->eflags |=get_PF (env) ?CC_P :0 ; + env->eflags |=get_AF (env) ?CC_A :0 ; + env->eflags |=get_ZF (env) ?CC_Z :0 ; + env->eflags |=get_SF (env) ?CC_S :0 ; + env->eflags |=get_OF (env) ?CC_O :0 ; }void rflags_to_lflags (CPUX86State *env) { env->hvf_emul->lflags.auxbits = env->hvf_emul->lflags.result =0 ; -set_OF (env, env->hvf_emul->rflags.of); -set_SF (env, env->hvf_emul->rflags.sf); -set_ZF (env, env->hvf_emul->rflags.zf); -set_AF (env, env->hvf_emul->rflags.af); -set_PF (env, env->hvf_emul->rflags.pf); -set_CF (env, env->hvf_emul->rflags.cf); +set_OF (env, env->eflags &CC_O ); +set_SF (env, env->eflags &CC_S ); +set_ZF (env, env->eflags &CC_Z ); +set_AF (env, env->eflags &CC_A ); +set_PF (env, env->eflags &CC_P ); +set_CF (env, env->eflags &CC_C ); }
target/i386/hvf/x86_task.c +3 -3
@@ -39,7 +39,7 @@ static void save_state_to_tss32(CPUState *cpu, struct x86_tss_segment32 *tss)/* CR3 and ldt selector are not saved intentionally */ tss->eip = (uint32_t )env->eip; - tss->eflags =EFLAGS (env); + tss->eflags = (uint32_t )env->eflags; tss->eax =EAX (env); tss->ecx =ECX (env); tss->edx =EDX (env);
@@ -65,7 +65,7 @@ static void load_state_from_tss32(CPUState *cpu, struct x86_tss_segment32 *tss)wvmcs (cpu->hvf_fd,VMCS_GUEST_CR3 , tss->cr3); env->eip = tss->eip; -EFLAGS (env) = tss->eflags |2 ; + env->eflags = tss->eflags |2 ;/* General purpose registers */ RAX (env) = tss->eax;
@@ -158,7 +158,7 @@ void vmx_handle_task_switch(CPUState *cpu, x68_segment_selector tss_sel, int rea }if (reason ==TSR_IRET ) -EFLAGS (env) &= ~RFLAGS_NT ; + env->eflags &= ~RFLAGS_NT ;if (reason !=TSR_CALL && reason !=TSR_IDT_GATE ) old_tss_sel.sel =0xffff ;
target/i386/hvf/x86hvf.c +3 -3
@@ -412,7 +412,7 @@ bool hvf_inject_interrupts(CPUState *cpu_state)if (!(env->hflags &HF_INHIBIT_IRQ_MASK ) && (cpu_state->interrupt_request &CPU_INTERRUPT_HARD ) && - (EFLAGS (env) &IF_MASK ) && !(info &VMCS_INTR_VALID )) { + (env->eflags &IF_MASK ) && !(info &VMCS_INTR_VALID )) {int line =cpu_get_pic_interrupt (&x86cpu->env); cpu_state->interrupt_request &= ~CPU_INTERRUPT_HARD ;if (line >=0 ) {
@@ -432,7 +432,7 @@ int hvf_process_events(CPUState *cpu_state)X86CPU *cpu =X86_CPU (cpu_state);CPUX86State *env = &cpu->env; -EFLAGS (env) =rreg (cpu_state->hvf_fd,HV_X86_RFLAGS ); + env->eflags =rreg (cpu_state->hvf_fd,HV_X86_RFLAGS );if (cpu_state->interrupt_request &CPU_INTERRUPT_INIT ) {hvf_cpu_synchronize_state (cpu_state);
@@ -444,7 +444,7 @@ int hvf_process_events(CPUState *cpu_state)apic_poll_irq (cpu->apic_state); }if (((cpu_state->interrupt_request &CPU_INTERRUPT_HARD ) && - (EFLAGS (env) &IF_MASK )) || + (env->eflags &IF_MASK )) || (cpu_state->interrupt_request &CPU_INTERRUPT_NMI )) { cpu_state->halted =0 ; }
Signature · 1 line
2.26.2
[PULL 040/115] qom: remove index from object_resolve_abs_path()
In reply to Paolo BonziniFrom: Masahiro Yamada <[email protected]>
You can advance 'parts' to track the current path fragment. The 'index' parameter is unneeded.
Message-Id: <[email protected]>
--- qom/object.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
qom/object.c +9 -10
@@ -1956,26 +1956,25 @@ Object *object_resolve_path_component(Object *parent, const char *part) }static Object *object_resolve_abs_path (Object *parent, -char **parts, -const char *typename, -int index) +char **parts, +const char *typename) {Object *child; -if (parts[index] ==NULL ) { +if (*parts ==NULL ) {return object_dynamic_cast (parent, typename); } -if (strcmp (parts[index],"" ) ==0 ) { -return object_resolve_abs_path (parent, parts, typename, index +1 ); +if (strcmp (*parts,"" ) ==0 ) { +return object_resolve_abs_path (parent, parts +1 , typename); } - child =object_resolve_path_component (parent, parts[index]); + child =object_resolve_path_component (parent, *parts);if (!child) {return NULL ; } -return object_resolve_abs_path (child, parts, typename, index +1 ); +return object_resolve_abs_path (child, parts +1 , typename); } static Object *object_resolve_partial_path(Object *parent,
@@ -1987,7 +1986,7 @@ static Object *object_resolve_partial_path(Object *parent,GHashTableIter iter;ObjectProperty *prop; - obj =object_resolve_abs_path (parent, parts, typename,0 ); + obj =object_resolve_abs_path (parent, parts, typename);g_hash_table_iter_init (&iter, parent->properties);while (g_hash_table_iter_next (&iter,NULL , (gpointer *)&prop)) {
@@ -2032,7 +2031,7 @@ Object *object_resolve_path_type(const char *path, const char *typename, *ambiguousp = ambiguous; } }else { - obj =object_resolve_abs_path (object_get_root (), parts, typename,1 ); + obj =object_resolve_abs_path (object_get_root (), parts +1 , typename); }g_strfreev (parts);
Signature · 1 line
2.26.2
[PULL 084/115] sysemu/tcg: Only declare tcg_allowed when TCG is available
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
When TCG is not available, the tcg_allowed variable does not exist.
Message-Id: <[email protected]>
--- include/sysemu/tcg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/sysemu/tcg.h +1 -1
@@ -8,9 +8,9 @@#ifndef SYSEMU_TCG_H #define SYSEMU_TCG_H -extern bool tcg_allowed;void tcg_exec_init (unsigned long tb_size);#ifdef CONFIG_TCG +extern bool tcg_allowed;#define tcg_enabled () (tcg_allowed)#else #define tcg_enabled () 0
Signature · 1 line
2.26.2
[PULL 104/115] target/i386: sev: Partial cleanup to sev_state global
In reply to Paolo BonziniFrom: David Gibson <[email protected]>
The SEV code uses a pretty ugly global to access its internal state. Now that SEVState is embedded in SevGuestState, we can avoid accessing it via the global in some cases. In the remaining cases use a new global referencing the containing SevGuestState which will simplify some future transformations.
Message-Id: <[email protected]>
--- target/i386/sev.c | 92 ++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 44 deletions(-)
target/i386/sev.c +48 -44
@@ -80,7 +80,7 @@ struct SevGuestState {#define DEFAULT_GUEST_POLICY 0x1/* disable debug */ #define DEFAULT_SEV_DEVICE "/dev/sev" -static SEVState *sev_state; +static SevGuestState *sev_guest;static Error *sev_mig_blocker;static const char *const sev_fw_errlist[] = {
@@ -159,21 +159,21 @@ fw_error_to_str(int code) }static bool -sev_check_state (SevState state) +sev_check_state (const SevGuestState *sev,SevState state) { -assert (sev_state); -return sev_state->state == state ? true : false; +assert (sev); +return sev->state.state == state ? true : false; }static void -sev_set_guest_state (SevState new_state) +sev_set_guest_state (SevGuestState *sev,SevState new_state) {assert (new_state <SEV_STATE__MAX ); -assert (sev_state); +assert (sev); -trace_kvm_sev_change_state (SevState_str (sev_state->state), +trace_kvm_sev_change_state (SevState_str (sev->state.state),SevState_str (new_state)); - sev_state->state = new_state; + sev->state.state = new_state; } static void
@@ -366,25 +366,25 @@ lookup_sev_guest_info(const char *id)bool sev_enabled (void ) { -return sev_state ? true : false; +return !!sev_guest; }uint64_t sev_get_me_mask (void ) { -return sev_state ? sev_state->me_mask : ~0 ; +return sev_guest ? sev_guest->state.me_mask : ~0 ; }uint32_t sev_get_cbit_position (void ) { -return sev_state ? sev_state->cbitpos :0 ; +return sev_guest ? sev_guest->state.cbitpos :0 ; }uint32_t sev_get_reduced_phys_bits (void ) { -return sev_state ? sev_state->reduced_phys_bits :0 ; +return sev_guest ? sev_guest->state.reduced_phys_bits :0 ; } SevInfo *
@@ -393,15 +393,15 @@ sev_get_info(void)SevInfo *info; info =g_new0 (SevInfo,1 ); - info->enabled = sev_state ? true : false; + info->enabled =sev_enabled ();if (info->enabled) { - info->api_major = sev_state->api_major; - info->api_minor = sev_state->api_minor; - info->build_id = sev_state->build_id; - info->policy = sev_state->policy; - info->state = sev_state->state; - info->handle = sev_state->handle; + info->api_major = sev_guest->state.api_major; + info->api_minor = sev_guest->state.api_minor; + info->build_id = sev_guest->state.build_id; + info->policy = sev_guest->state.policy; + info->state = sev_guest->state.state; + info->handle = sev_guest->state.handle; }return info;
@@ -550,7 +550,7 @@ sev_launch_start(SevGuestState *sev)object_property_set_int (OBJECT (sev), start->handle,"handle" , &error_abort); -sev_set_guest_state (SEV_STATE_LAUNCH_UPDATE ); +sev_set_guest_state (sev,SEV_STATE_LAUNCH_UPDATE ); s->handle = start->handle; s->policy = start->policy; ret =0 ;
@@ -563,7 +563,7 @@ out: }static int -sev_launch_update_data (uint8_t *addr,uint64_t len) +sev_launch_update_data (SevGuestState *sev,uint8_t *addr,uint64_t len) {int ret, fw_error;struct kvm_sev_launch_update_data update;
@@ -575,7 +575,7 @@ sev_launch_update_data(uint8_t *addr, uint64_t len) update.uaddr = (__u64 )(unsigned long )addr; update.len = len;trace_kvm_sev_launch_update_data (addr, len); - ret =sev_ioctl (sev_state->sev_fd,KVM_SEV_LAUNCH_UPDATE_DATA , + ret =sev_ioctl (sev->state.sev_fd,KVM_SEV_LAUNCH_UPDATE_DATA , &update, &fw_error);if (ret) { error_report("%s: LAUNCH_UPDATE ret=%d fw_error=%d '%s'",
@@ -588,19 +588,20 @@ sev_launch_update_data(uint8_t *addr, uint64_t len)static void sev_launch_get_measure (Notifier *notifier,void *unused) { +SevGuestState *sev = sev_guest;int ret, error;guchar *data; -SEVState *s = sev_state; +SEVState *s = &sev->state;struct kvm_sev_launch_measure *measurement; -if (!sev_check_state (SEV_STATE_LAUNCH_UPDATE )) { +if (!sev_check_state (sev,SEV_STATE_LAUNCH_UPDATE )) {return ; } measurement = g_new0(struct kvm_sev_launch_measure, 1);/* query the measurement blob length */ - ret =sev_ioctl (sev_state->sev_fd,KVM_SEV_LAUNCH_MEASURE , + ret =sev_ioctl (sev->state.sev_fd,KVM_SEV_LAUNCH_MEASURE , measurement, &error);if (!measurement->len) { error_report("%s: LAUNCH_MEASURE ret=%d fw_error=%d '%s'",
@@ -612,7 +613,7 @@ sev_launch_get_measure(Notifier *notifier, void *unused) measurement->uaddr = (unsigned long )data;/* get the measurement blob */ - ret =sev_ioctl (sev_state->sev_fd,KVM_SEV_LAUNCH_MEASURE , + ret =sev_ioctl (sev->state.sev_fd,KVM_SEV_LAUNCH_MEASURE , measurement, &error);if (ret) { error_report("%s: LAUNCH_MEASURE ret=%d fw_error=%d '%s'",
@@ -620,7 +621,7 @@ sev_launch_get_measure(Notifier *notifier, void *unused) goto free_data; } -sev_set_guest_state (SEV_STATE_LAUNCH_SECRET ); +sev_set_guest_state (sev,SEV_STATE_LAUNCH_SECRET );/* encode the measurement value and emit the event */ s->measurement =g_base64_encode (data, measurement->len);
@@ -635,9 +636,9 @@ free_measurement:char *sev_get_launch_measurement (void ) { -if (sev_state && - sev_state->state >=SEV_STATE_LAUNCH_SECRET ) { -return g_strdup (sev_state->measurement); +if (sev_guest && + sev_guest->state.state >=SEV_STATE_LAUNCH_SECRET ) { +return g_strdup (sev_guest->state.measurement); }return NULL ;
@@ -648,20 +649,21 @@ static Notifier sev_machine_done_notify = { };static void -sev_launch_finish (SEVState *s) +sev_launch_finish (SevGuestState *sev) { +SEVState *s = &sev->state;int ret, error;Error *local_err =NULL ;trace_kvm_sev_launch_finish (); - ret =sev_ioctl (sev_state->sev_fd,KVM_SEV_LAUNCH_FINISH ,0 , &error); + ret =sev_ioctl (s->sev_fd,KVM_SEV_LAUNCH_FINISH ,0 , &error);if (ret) {error_report ("%s: LAUNCH_FINISH ret=%d fw_error=%d '%s'" , __func__, ret, error,fw_error_to_str (error));exit (1 ); } -sev_set_guest_state (SEV_STATE_RUNNING ); +sev_set_guest_state (sev,SEV_STATE_RUNNING );/* add migration blocker */ error_setg(&sev_mig_blocker,
@@ -677,11 +679,11 @@ sev_launch_finish(SEVState *s)static void sev_vm_state_change (void *opaque,int running,RunState state) { -SEVState *s = opaque; +SevGuestState *sev = opaque;if (running) { -if (!sev_check_state (SEV_STATE_RUNNING )) { -sev_launch_finish (s); +if (!sev_check_state (sev,SEV_STATE_RUNNING )) { +sev_launch_finish (sev); } } }
@@ -704,7 +706,8 @@ sev_guest_init(const char *id) goto err; } - sev_state = s = &sev->state; + sev_guest = sev; + s = &sev->state; s->state =SEV_STATE_UNINIT ;host_cpuid (0x8000001F ,0 ,NULL , &ebx,NULL ,NULL );
@@ -766,23 +769,24 @@ sev_guest_init(const char *id)ram_block_notifier_add (&sev_ram_notifier);qemu_add_machine_init_done_notifier (&sev_machine_done_notify); -qemu_add_vm_change_state_handler (sev_vm_state_change, s); +qemu_add_vm_change_state_handler (sev_vm_state_change, sev); -return s; +return sev; err: -g_free (sev_state); - sev_state =NULL ; + sev_guest =NULL ;return NULL ; }int sev_encrypt_data (void *handle,uint8_t *ptr,uint64_t len) { -assert (handle); +SevGuestState *sev = handle; + +assert (sev);/* if SEV is in update state then encrypt the data else do nothing */ -if (sev_check_state (SEV_STATE_LAUNCH_UPDATE )) { -return sev_launch_update_data (ptr, len); +if (sev_check_state (sev,SEV_STATE_LAUNCH_UPDATE )) { +return sev_launch_update_data (sev, ptr, len); }return 0 ;
Signature · 1 line
2.26.2
[PULL 101/115] target/i386: sev: Move local structure definitions into .c file
In reply to Paolo BonziniFrom: David Gibson <[email protected]>
Neither QSevGuestInfo nor SEVState (not to be confused with SevState) is used anywhere outside target/i386/sev.c, so they might as well live in there rather than in a (somewhat) exposed header.
Message-Id: <[email protected]>
--- target/i386/sev.c | 44 ++++++++++++++++++++++++++++++++++++++++++ target/i386/sev_i386.h | 44 ------------------------------------------ 2 files changed, 44 insertions(+), 44 deletions(-)
target/i386/sev.c +44 -0
@@ -29,6 +29,50 @@#include "trace.h" #include "migration/blocker.h" +#define TYPE_QSEV_GUEST_INFO "sev-guest" +#define QSEV_GUEST_INFO (obj) \ + OBJECT_CHECK(QSevGuestInfo, (obj), TYPE_QSEV_GUEST_INFO) + +typedef struct QSevGuestInfo QSevGuestInfo ; + +/** +* QSevGuestInfo: +* +* The QSevGuestInfo object is used for creating a SEV guest. +* +* # $QEMU \ +* -object sev-guest,id=sev0 \ +* -machine ...,memory-encryption=sev0 +*/ +struct QSevGuestInfo { +Object parent_obj; + +char *sev_device; +uint32_t policy; +uint32_t handle; +char *dh_cert_file; +char *session_file; +uint32_t cbitpos; +uint32_t reduced_phys_bits; +}; + +struct SEVState { +QSevGuestInfo *sev_info; +uint8_t api_major; +uint8_t api_minor; +uint8_t build_id; +uint32_t policy; +uint64_t me_mask; +uint32_t cbitpos; +uint32_t reduced_phys_bits; +uint32_t handle; +int sev_fd; +SevState state; +gchar *measurement; +}; + +typedef struct SEVState SEVState ; +#define DEFAULT_GUEST_POLICY 0x1/* disable debug */ #define DEFAULT_SEV_DEVICE "/dev/sev"
target/i386/sev_i386.h +0 -44
54 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 070/115] chardev/char-socket: Properly make qio connections non blocking
In reply to Paolo BonziniFrom: Sai Pavan Boddu <[email protected]>
In tcp_chr_sync_read function, there is a possibility of socket disconnection during blocking read, then tcp_chr_hup function would clean up the qio channel pointers(i.e ioc, sioc).
Message-Id: <[email protected]>
--- chardev/char-socket.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
chardev/char-socket.c +3 -1
@@ -550,7 +550,9 @@ static int tcp_chr_sync_read(Chardev *chr, const uint8_t *buf, int len)qio_channel_set_blocking (s->ioc, true,NULL ); size =tcp_chr_recv (chr, (void *) buf, len); -qio_channel_set_blocking (s->ioc, false,NULL ); +if (s->state !=TCP_CHARDEV_STATE_DISCONNECTED ) { +qio_channel_set_blocking (s->ioc, false,NULL ); + }if (size ==0 ) {/* connection closed */ tcp_chr_disconnect (chr);
Signature · 1 line
2.26.2
[PULL 089/115] i386: hvf: Drop unused variable
In reply to Paolo BonziniFrom: Roman Bolshakov <[email protected]>
Message-Id: <[email protected]>
--- target/i386/hvf/x86.h | 1 - 1 file changed, 1 deletion(-)
target/i386/hvf/x86.h +0 -1
@@ -293,7 +293,6 @@ typedef struct lazy_flags {/* Definition of hvf_x86_state is here */ struct HVFX86EmulatorState { -int interruptable;uint64_t fetch_rip;uint64_t rip;struct x86_register regs[16 ];
Signature · 1 line
2.26.2
[PULL 073/115] replay: implement fair mutex
In reply to Paolo BonziniFrom: Pavel Dovgalyuk <[email protected]>
In record/replay icount mode main loop thread and vCPU thread do not perform simultaneously. They take replay mutex to synchronize the actions. Sometimes vCPU thread waits for locking the mutex for very long time, because main loop releases the mutex and takes it back again. Standard qemu mutex do not provide the ordering capabilities.
This patch adds a "queue" for replay mutex. Therefore thread ordering becomes more "fair". Threads are executed in the same order as they are trying to take the mutex.
Message-Id: <158823802979.28101.9340462887738957616.stgit@pasha-ThinkPad-X280>
--- replay/replay-internal.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
replay/replay-internal.c +14 -1
@@ -22,6 +22,9 @@It also protects replay events queue which stores events to be written or read to the log. */ static QemuMutex lock; +/* Condition and queue for fair ordering of mutex lock requests. */ +static QemuCond mutex_cond; +static unsigned long mutex_head, mutex_tail;/* File for replay writing */ static bool write_error;
@@ -197,9 +200,10 @@ static __thread bool replay_locked;void replay_mutex_init (void ) {qemu_mutex_init (&lock); +qemu_cond_init (&mutex_cond);/* Hold the mutex while we start-up */ -qemu_mutex_lock (&lock); replay_locked = true; + ++mutex_tail; }bool replay_mutex_locked (void )
@@ -211,10 +215,16 @@ bool replay_mutex_locked(void)void replay_mutex_lock (void ) {if (replay_mode !=REPLAY_MODE_NONE ) { +unsigned long id;g_assert (!qemu_mutex_iothread_locked ());g_assert (!replay_mutex_locked ());qemu_mutex_lock (&lock); + id = mutex_tail++; +while (id != mutex_head) { +qemu_cond_wait (&mutex_cond, &lock); + } replay_locked = true; +qemu_mutex_unlock (&lock); } }
@@ -222,7 +232,10 @@ void replay_mutex_unlock(void) {if (replay_mode !=REPLAY_MODE_NONE ) {g_assert (replay_mutex_locked ()); +qemu_mutex_lock (&lock); + ++mutex_head; replay_locked = false; +qemu_cond_broadcast (&mutex_cond);qemu_mutex_unlock (&lock); } }
Signature · 1 line
2.26.2
[PULL 100/115] target/i386: sev: Remove unused QSevGuestInfoClass
In reply to Paolo BonziniFrom: David Gibson <[email protected]>
This structure is nothing but an empty wrapper around the parent class, which by QOM conventions means we don't need it at all.
Message-Id: <[email protected]>
--- target/i386/sev.c | 1 - target/i386/sev_i386.h | 5 ----- 2 files changed, 6 deletions(-)
target/i386/sev.c +0 -1
@@ -287,7 +287,6 @@ static const TypeInfo qsev_guest_info = { .name = TYPE_QSEV_GUEST_INFO, .instance_size = sizeof(QSevGuestInfo), .instance_finalize = qsev_guest_finalize, - .class_size = sizeof(QSevGuestInfoClass), .class_init = qsev_guest_class_init, .instance_init = qsev_guest_init, .interfaces = (InterfaceInfo []) {
target/i386/sev_i386.h +0 -5
@@ -41,7 +41,6 @@ extern char *sev_get_launch_measurement(void);extern SevCapability *sev_get_capabilities (void );typedef struct QSevGuestInfo QSevGuestInfo ; -typedef struct QSevGuestInfoClass QSevGuestInfoClass ;/** * QSevGuestInfo:
@@ -64,10 +63,6 @@ struct QSevGuestInfo {uint32_t reduced_phys_bits; }; -struct QSevGuestInfoClass { -ObjectClass parent_class; -}; -struct SEVState {QSevGuestInfo *sev_info;uint8_t api_major;
Signature · 1 line
2.26.2
[PULL 082/115] target/i386: correct fix for pcmpxstrx substring search
In reply to Paolo BonziniFrom: Joseph Myers <[email protected]>
This corrects a bug introduced in my previous fix for SSE4.2 pcmpestri / pcmpestrm / pcmpistri / pcmpistrm substring search, commit ae35eea7e4a9f21dd147406dfbcd0c4c6aaf2a60.
That commit fixed a bug that showed up in four GCC tests with one libc implementation. The tests in question generate random inputs to the intrinsics and compare results to a C implementation, but they only test 1024 possible random inputs, and when the tests use the cases of those instructions that work with word rather than byte inputs, it's easy to have problematic cases that show up much less frequently than that. Thus, testing with a different libc implementation, and so a different random number generator, showed up a problem with the previous patch.
When investigating the previous test failures, I found the description of these instructions in the Intel manuals (starting from computing a 16x16 or 8x8 set of comparison results) confusing and hard to match up with the more optimized implementation in QEMU, and referred to AMD manuals which described the instructions in a different way. Those AMD descriptions are very explicit that the whole of the string being searched for must be found in the other operand, not running off the end of that operand; they say "If the prototype and the SUT are equal in length, the two strings must be identical for the comparison to be TRUE.". However, that statement is incorrect.
In my previous commit message, I noted:
The operation in this case is a search for a string (argument d to the helper) in another string (argument s to the helper); if a copy of d at a particular position would run off the end of s, the resulting output bit should be 0 whether or not the strings match in the region where they overlap, but the QEMU implementation was wrongly comparing only up to the point where s ends and counting it as a match if an initial segment of d matched a terminal segment of s. Here, "run off the end of s" means that some byte of d would overlap some byte outside of s; thus, if d has zero length, it is considered to match everywhere, including after the end of s.
The description "some byte of d would overlap some byte outside of s" is accurate only when understood to refer to overlapping some byte *within the 16-byte operand* but at or after the zero terminator; it is valid to run over the end of s if the end of s is the end of the 16-byte operand. So the fix in the previous patch for the case of d being empty was correct, but the other part of that patch was not correct (as it never allowed partial matches even at the end of the 16-byte operand). Nor was the code before the previous patch correct for the case of d nonempty, as it would always have allowed partial matches at the end of s.
Fix with a partial revert of my previous change, combined with inserting a check for the special case of s having maximum length to determine where it is necessary to check for matches.
In the added test, test 1 is for the case of empty strings, which failed before my 2017 patch, test 2 is for the bug introduced by my 2017 patch and test 3 deals with the case where a match of an initial segment at the end of the string is not valid when the string ends before the end of the 16-byte operand (that is, the case that would be broken by a simple revert of the non-empty-string part of my 2017 patch).
Message-Id: <[email protected]>
--- target/i386/ops_sse.h | 4 ++-- tests/tcg/i386/Makefile.target | 3 +++ tests/tcg/i386/test-i386-pcmpistri.c | 33 ++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/tcg/i386/test-i386-pcmpistri.c
target/i386/ops_sse.h +2 -2
@@ -2089,10 +2089,10 @@ static inline unsigned pcmpxstrx(CPUX86State *env, Reg *d, Reg *s, res = (2 << upper) -1 ;break ; } -for (j = valids - validd; j >=0 ; j--) { +for (j = valids == upper ? valids : valids - validd; j >=0 ; j--) { res <<=1 ; v =1 ; -for (i = validd; i >=0 ; i--) { +for (i =MIN (valids - j, validd); i >=0 ; i--) { v &= (pcmp_val (s, ctrl, i + j) ==pcmp_val (d, ctrl, i)); } res |= v;
tests/tcg/i386/Makefile.target +3 -0
@@ -10,6 +10,9 @@ ALL_X86_TESTS=$(I386_SRCS:.c=) SKIP_I386_TESTS=test-i386-ssse3 X86_64_TESTS:=$(filter test-i386-ssse3, $(ALL_X86_TESTS)) +test-i386-pcmpistri: CFLAGS += -msse4.2 +test-i386-pcmpistri: QEMU_OPTS += -cpu max + # # hello-i386 is a barebones app #
tests/tcg/i386/test-i386-pcmpistri.c new file +33 -0
@@ -0,0 +1,33 @@ +/* Test pcmpistri instruction. */ + +#include <nmmintrin.h> +#include <stdio.h> + +union u { +__m128i x; +unsigned char uc[16 ]; +}; + +union u s0 = { .uc = {0 } }; +union u s1 = { .uc ="abcdefghijklmnop" }; +union u s2 = { .uc ="bcdefghijklmnopa" }; +union u s3 = { .uc ="bcdefghijklmnab" }; + +int +main (void ) +{ +int ret =0 ; +if (_mm_cmpistri (s0.x, s0.x,0x4c ) !=15 ) { +printf ("FAIL: pcmpistri test 1\n" ); + ret =1 ; + } +if (_mm_cmpistri (s1.x, s2.x,0x4c ) !=15 ) { +printf ("FAIL: pcmpistri test 2\n" ); + ret =1 ; + } +if ("%d\n" ,_mm_cmpistri (s1.x, s3.x,0x4c ) !=16 ) { +printf ("FAIL: pcmpistri test 3\n" ); + ret =1 ; + } +return ret; +}
Signature · 1 line
2.26.2
[PULL 092/115] i386: hvf: Drop fetch_rip from HVFX86EmulatorState
In reply to Paolo BonziniFrom: Roman Bolshakov <[email protected]>
The field is used to print address of instructions that have no parser in decode_invalid(). RIP from VMCS is saved into fetch_rip before decoding starts but it's also saved into env->eip in load_regs(). Therefore env->eip can be used instead of fetch_rip.
While at it, correct address printed in decode_invalid(). It prints an address before the unknown instruction.
Message-Id: <[email protected]>
--- target/i386/hvf/hvf.c | 6 ------ target/i386/hvf/x86.h | 1 - target/i386/hvf/x86_decode.c | 3 +-- 3 files changed, 1 insertion(+), 9 deletions(-)
target/i386/hvf/hvf.c +0 -6
@@ -767,8 +767,6 @@ int hvf_vcpu_exec(CPUState *cpu)struct x86_decode decode;load_regs (cpu); - env->hvf_emul->fetch_rip = rip; -decode_instruction (env, &decode);exec_instruction (env, &decode);store_regs (cpu);
@@ -809,8 +807,6 @@ int hvf_vcpu_exec(CPUState *cpu)struct x86_decode decode;load_regs (cpu); - env->hvf_emul->fetch_rip = rip; -decode_instruction (env, &decode);assert (ins_len == decode.len);exec_instruction (env, &decode);
@@ -915,8 +911,6 @@ int hvf_vcpu_exec(CPUState *cpu)struct x86_decode decode;load_regs (cpu); - env->hvf_emul->fetch_rip = rip; -decode_instruction (env, &decode);exec_instruction (env, &decode);store_regs (cpu);
target/i386/hvf/x86.h +0 -1
@@ -293,7 +293,6 @@ typedef struct lazy_flags {/* Definition of hvf_x86_state is here */ struct HVFX86EmulatorState { -uint64_t fetch_rip;struct x86_register regs[16 ];struct x86_reg_flags rflags;struct lazy_flags lflags;
target/i386/hvf/x86_decode.c +1 -2
@@ -29,8 +29,7 @@static void decode_invalid (CPUX86State *env,struct x86_decode *decode) { -printf ("%llx: failed to decode instruction " , env->hvf_emul->fetch_rip - - decode->len); +printf ("%llx: failed to decode instruction " , env->eip);for (int i =0 ; i < decode->opcode_len; i++) {printf ("%x " , decode->opcode[i]); }
Signature · 1 line
2.26.2
[PULL 107/115] target/i386: sev: Remove redundant handle field
In reply to Paolo BonziniFrom: David Gibson <[email protected]>
The user can explicitly specify a handle via the "handle" property wired to SevGuestState::handle. That gets passed to the KVM_SEV_LAUNCH_START ioctl() which may update it, the final value being copied back to both SevGuestState::handle and SEVState::handle.
AFAICT, nothing will be looking SEVState::handle before it and SevGuestState::handle have been updated from the ioctl(). So, remove the field and just use SevGuestState::handle directly.
Message-Id: <[email protected]>
--- target/i386/sev.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
target/i386/sev.c +4 -8
@@ -40,7 +40,6 @@ struct SEVState {uint8_t api_minor;uint8_t build_id;uint64_t me_mask; -uint32_t handle;int sev_fd;SevState state;gchar *measurement;
@@ -64,13 +63,13 @@ struct SevGuestState {/* configuration parameters */ char *sev_device;uint32_t policy; -uint32_t handle;char *dh_cert_file;char *session_file;uint32_t cbitpos;uint32_t reduced_phys_bits;/* runtime state */ +uint32_t handle;SEVState state; };
@@ -398,7 +397,7 @@ sev_get_info(void) info->build_id = sev_guest->state.build_id; info->policy = sev_guest->policy; info->state = sev_guest->state.state; - info->handle = sev_guest->state.handle; + info->handle = sev_guest->handle; }return info;
@@ -517,8 +516,7 @@ sev_launch_start(SevGuestState *sev) start = g_new0(struct kvm_sev_launch_start, 1); - start->handle =object_property_get_int (OBJECT (sev),"handle" , - &error_abort); + start->handle = sev->handle; start->policy = sev->policy;if (sev->session_file) {if (sev_read_file_base64 (sev->session_file, &session, &sz) <0 ) {
@@ -544,10 +542,8 @@ sev_launch_start(SevGuestState *sev) goto out; } -object_property_set_int (OBJECT (sev), start->handle,"handle" , - &error_abort);sev_set_guest_state (sev,SEV_STATE_LAUNCH_UPDATE ); - s->handle = start->handle; + sev->handle = start->handle; ret =0 ; out:
Signature · 1 line
2.26.2
[PULL 058/115] disas: Let disas::read_memory() handler return EIO on error
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Both cpu_memory_rw_debug() and address_space_read() return an error on failed transaction. Check the returned value, and return EIO in case of error.
--- disas.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
disas.c +8 -5
@@ -39,9 +39,11 @@ target_read_memory (bfd_vma memaddr, struct disassemble_info *info) {CPUDebug *s =container_of (info, CPUDebug, info); +int r; -cpu_memory_rw_debug (s->cpu, memaddr, myaddr, length,0 ); -return 0 ; + r =cpu_memory_rw_debug (s->cpu, memaddr, myaddr, length,0 ); + +return r ?EIO :0 ; }/* Print an error message. We can assume that this is in response to
@@ -718,10 +720,11 @@ physical_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length, struct disassemble_info *info) {CPUDebug *s =container_of (info, CPUDebug, info); +MemTxResult res; -address_space_read (s->cpu->as, memaddr,MEMTXATTRS_UNSPECIFIED , - myaddr, length); -return 0 ; + res =address_space_read (s->cpu->as, memaddr,MEMTXATTRS_UNSPECIFIED , + myaddr, length); +return res ==MEMTX_OK ?0 :EIO ; }/* Disassembler for the monitor. */
Signature · 1 line
2.26.2
[PULL 081/115] target/i386: fix IEEE x87 floating-point exception raising
In reply to Paolo BonziniFrom: Joseph Myers <[email protected]>
Most x87 instruction implementations fail to raise the expected IEEE floating-point exceptions because they do nothing to convert the exception state from the softfloat machinery into the exception flags in the x87 status word. There is special-case handling of division to raise the divide-by-zero exception, but that handling is itself buggy:
it raises the exception in inappropriate cases (inf / 0 and nan / 0, which should not raise any exceptions, and 0 / 0, which should raise "invalid" instead).
Fix this by converting the floating-point exceptions raised during an operation by the softfloat machinery into exceptions in the x87 status word (passing through the existing fpu_set_exception function for handling related to trapping exceptions). There are special cases where some functions convert to integer internally but exceptions from that conversion are not always correct exceptions for the instruction to raise.
There might be scope for some simplification if the softfloat exception state either could always be assumed to be in sync with the state in the status word, or could always be ignored at the start of each instruction and just set to 0 then; I haven't looked into that in detail, and it might run into interactions with the various ways the emulation does not yet handle trapping exceptions properly. I think the approach taken here, of saving the softfloat state, setting exceptions there to 0 and then merging the old exceptions back in after carrying out the operation, is conservatively safe.
Message-Id: <[email protected]>
--- target/i386/fpu_helper.c | 126 +++- tests/tcg/i386/test-i386-fp-exceptions.c | 831 +++++++++++++++++++++++ 2 files changed, 926 insertions(+), 31 deletions(-) create mode 100644 tests/tcg/i386/test-i386-fp-exceptions.c
target/i386/fpu_helper.c +95 -31
@@ -161,12 +161,32 @@ static void fpu_set_exception(CPUX86State *env, int mask) } } +static inline uint8_t save_exception_flags (CPUX86State *env) +{ +uint8_t old_flags =get_float_exception_flags (&env->fp_status); +set_float_exception_flags (0 , &env->fp_status); +return old_flags; +} + +static void merge_exception_flags (CPUX86State *env,uint8_t old_flags) +{ +uint8_t new_flags =get_float_exception_flags (&env->fp_status); +float_raise (old_flags, &env->fp_status); +fpu_set_exception (env, + ((new_flags & float_flag_invalid ?FPUS_IE :0 ) | + (new_flags & float_flag_divbyzero ?FPUS_ZE :0 ) | + (new_flags & float_flag_overflow ?FPUS_OE :0 ) | + (new_flags & float_flag_underflow ?FPUS_UE :0 ) | + (new_flags & float_flag_inexact ?FPUS_PE :0 ) | + (new_flags & float_flag_input_denormal ?FPUS_DE :0 ))); +} +static inline floatx80 helper_fdiv (CPUX86State *env,floatx80 a,floatx80 b) { -if (floatx80_is_zero (b)) { -fpu_set_exception (env,FPUS_ZE ); - } -return floatx80_div (a, b, &env->fp_status); +uint8_t old_flags =save_exception_flags (env); +floatx80 ret =floatx80_div (a, b, &env->fp_status); +merge_exception_flags (env, old_flags); +return ret; }static void fpu_raise_exception (CPUX86State *env,uintptr_t retaddr)
@@ -183,6 +203,7 @@ static void fpu_raise_exception(CPUX86State *env, uintptr_t retaddr)void helper_flds_FT0 (CPUX86State *env,uint32_t val) { +uint8_t old_flags =save_exception_flags (env);union {float32 f;uint32_t i;
@@ -190,10 +211,12 @@ void helper_flds_FT0(CPUX86State *env, uint32_t val) u.i = val;FT0 =float32_to_floatx80 (u.f, &env->fp_status); +merge_exception_flags (env, old_flags); }void helper_fldl_FT0 (CPUX86State *env,uint64_t val) { +uint8_t old_flags =save_exception_flags (env);union {float64 f;uint64_t i;
@@ -201,6 +224,7 @@ void helper_fldl_FT0(CPUX86State *env, uint64_t val) u.i = val;FT0 =float64_to_floatx80 (u.f, &env->fp_status); +merge_exception_flags (env, old_flags); }void helper_fildl_FT0 (CPUX86State *env,int32_t val)
@@ -210,6 +234,7 @@ void helper_fildl_FT0(CPUX86State *env, int32_t val)void helper_flds_ST0 (CPUX86State *env,uint32_t val) { +uint8_t old_flags =save_exception_flags (env);int new_fpstt;union {float32 f;
@@ -221,10 +246,12 @@ void helper_flds_ST0(CPUX86State *env, uint32_t val) env->fpregs[new_fpstt].d =float32_to_floatx80 (u.f, &env->fp_status); env->fpstt = new_fpstt; env->fptags[new_fpstt] =0 ;/* validate stack entry */ +merge_exception_flags (env, old_flags); }void helper_fldl_ST0 (CPUX86State *env,uint64_t val) { +uint8_t old_flags =save_exception_flags (env);int new_fpstt;union {float64 f;
@@ -236,6 +263,7 @@ void helper_fldl_ST0(CPUX86State *env, uint64_t val) env->fpregs[new_fpstt].d =float64_to_floatx80 (u.f, &env->fp_status); env->fpstt = new_fpstt; env->fptags[new_fpstt] =0 ;/* validate stack entry */ +merge_exception_flags (env, old_flags); }void helper_fildl_ST0 (CPUX86State *env,int32_t val)
@@ -260,113 +288,107 @@ void helper_fildll_ST0(CPUX86State *env, int64_t val)uint32_t helper_fsts_ST0 (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);union {float32 f;uint32_t i; } u; u.f =floatx80_to_float32 (ST0 , &env->fp_status); +merge_exception_flags (env, old_flags);return u.i; }uint64_t helper_fstl_ST0 (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);union {float64 f;uint64_t i; } u; u.f =floatx80_to_float64 (ST0 , &env->fp_status); +merge_exception_flags (env, old_flags);return u.i; }int32_t helper_fist_ST0 (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);int32_t val; val =floatx80_to_int32 (ST0 , &env->fp_status);if (val != (int16_t )val) { +set_float_exception_flags (float_flag_invalid, &env->fp_status); val =-32768 ; } +merge_exception_flags (env, old_flags);return val; }int32_t helper_fistl_ST0 (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);int32_t val; -signed char old_exp_flags; - - old_exp_flags =get_float_exception_flags (&env->fp_status); -set_float_exception_flags (0 , &env->fp_status); val =floatx80_to_int32 (ST0 , &env->fp_status);if (get_float_exception_flags (&env->fp_status) & float_flag_invalid) { val =0x80000000 ; } -set_float_exception_flags (get_float_exception_flags (&env->fp_status) - | old_exp_flags, &env->fp_status); +merge_exception_flags (env, old_flags);return val; }int64_t helper_fistll_ST0 (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);int64_t val; -signed char old_exp_flags; - - old_exp_flags =get_float_exception_flags (&env->fp_status); -set_float_exception_flags (0 , &env->fp_status); val =floatx80_to_int64 (ST0 , &env->fp_status);if (get_float_exception_flags (&env->fp_status) & float_flag_invalid) { val =0x8000000000000000ULL ; } -set_float_exception_flags (get_float_exception_flags (&env->fp_status) - | old_exp_flags, &env->fp_status); +merge_exception_flags (env, old_flags);return val; }int32_t helper_fistt_ST0 (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);int32_t val; val =floatx80_to_int32_round_to_zero (ST0 , &env->fp_status);if (val != (int16_t )val) { +set_float_exception_flags (float_flag_invalid, &env->fp_status); val =-32768 ; } +merge_exception_flags (env, old_flags);return val; }int32_t helper_fisttl_ST0 (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);int32_t val; -signed char old_exp_flags; - - old_exp_flags =get_float_exception_flags (&env->fp_status); -set_float_exception_flags (0 , &env->fp_status); val =floatx80_to_int32_round_to_zero (ST0 , &env->fp_status);if (get_float_exception_flags (&env->fp_status) & float_flag_invalid) { val =0x80000000 ; } -set_float_exception_flags (get_float_exception_flags (&env->fp_status) - | old_exp_flags, &env->fp_status); +merge_exception_flags (env, old_flags);return val; }int64_t helper_fisttll_ST0 (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);int64_t val; -signed char old_exp_flags; - - old_exp_flags =get_float_exception_flags (&env->fp_status); -set_float_exception_flags (0 , &env->fp_status); val =floatx80_to_int64_round_to_zero (ST0 , &env->fp_status);if (get_float_exception_flags (&env->fp_status) & float_flag_invalid) { val =0x8000000000000000ULL ; } -set_float_exception_flags (get_float_exception_flags (&env->fp_status) - | old_exp_flags, &env->fp_status); +merge_exception_flags (env, old_flags);return val; }
@@ -449,24 +471,29 @@ static const int fcom_ccval[4] = {0x0100, 0x4000, 0x0000, 0x4500};void helper_fcom_ST0_FT0 (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);FloatRelation ret; ret =floatx80_compare (ST0 ,FT0 , &env->fp_status); env->fpus = (env->fpus & ~0x4500 ) | fcom_ccval[ret +1 ]; +merge_exception_flags (env, old_flags); }void helper_fucom_ST0_FT0 (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);FloatRelation ret; ret =floatx80_compare_quiet (ST0 ,FT0 , &env->fp_status); env->fpus = (env->fpus & ~0x4500 ) | fcom_ccval[ret +1 ]; +merge_exception_flags (env, old_flags); }static const int fcomi_ccval[4 ] = {CC_C ,CC_Z ,0 ,CC_Z |CC_P |CC_C };void helper_fcomi_ST0_FT0 (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);int eflags;FloatRelation ret;
@@ -474,10 +501,12 @@ void helper_fcomi_ST0_FT0(CPUX86State *env) eflags =cpu_cc_compute_all (env,CC_OP ); eflags = (eflags & ~(CC_Z |CC_P |CC_C )) | fcomi_ccval[ret +1 ];CC_SRC = eflags; +merge_exception_flags (env, old_flags); }void helper_fucomi_ST0_FT0 (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);int eflags;FloatRelation ret;
@@ -485,26 +514,35 @@ void helper_fucomi_ST0_FT0(CPUX86State *env) eflags =cpu_cc_compute_all (env,CC_OP ); eflags = (eflags & ~(CC_Z |CC_P |CC_C )) | fcomi_ccval[ret +1 ];CC_SRC = eflags; +merge_exception_flags (env, old_flags); }void helper_fadd_ST0_FT0 (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);ST0 =floatx80_add (ST0 ,FT0 , &env->fp_status); +merge_exception_flags (env, old_flags); }void helper_fmul_ST0_FT0 (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);ST0 =floatx80_mul (ST0 ,FT0 , &env->fp_status); +merge_exception_flags (env, old_flags); }void helper_fsub_ST0_FT0 (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);ST0 =floatx80_sub (ST0 ,FT0 , &env->fp_status); +merge_exception_flags (env, old_flags); }void helper_fsubr_ST0_FT0 (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);ST0 =floatx80_sub (FT0 ,ST0 , &env->fp_status); +merge_exception_flags (env, old_flags); }void helper_fdiv_ST0_FT0 (CPUX86State *env)
@@ -521,22 +559,30 @@ void helper_fdivr_ST0_FT0(CPUX86State *env)void helper_fadd_STN_ST0 (CPUX86State *env,int st_index) { +uint8_t old_flags =save_exception_flags (env);ST (st_index) =floatx80_add (ST (st_index),ST0 , &env->fp_status); +merge_exception_flags (env, old_flags); }void helper_fmul_STN_ST0 (CPUX86State *env,int st_index) { +uint8_t old_flags =save_exception_flags (env);ST (st_index) =floatx80_mul (ST (st_index),ST0 , &env->fp_status); +merge_exception_flags (env, old_flags); }void helper_fsub_STN_ST0 (CPUX86State *env,int st_index) { +uint8_t old_flags =save_exception_flags (env);ST (st_index) =floatx80_sub (ST (st_index),ST0 , &env->fp_status); +merge_exception_flags (env, old_flags); }void helper_fsubr_STN_ST0 (CPUX86State *env,int st_index) { +uint8_t old_flags =save_exception_flags (env);ST (st_index) =floatx80_sub (ST0 ,ST (st_index), &env->fp_status); +merge_exception_flags (env, old_flags); }void helper_fdiv_STN_ST0 (CPUX86State *env,int st_index)
@@ -747,6 +793,7 @@ void helper_fbld_ST0(CPUX86State *env, target_ulong ptr)void helper_fbst_ST0 (CPUX86State *env,target_ulong ptr) { +uint8_t old_flags =save_exception_flags (env);int v;target_ulong mem_ref, mem_end;int64_t val;
@@ -757,13 +804,14 @@ void helper_fbst_ST0(CPUX86State *env, target_ulong ptr) val =floatx80_to_int64 (ST0 , &env->fp_status); mem_ref = ptr;if (val >=1000000000000000000LL || val <=-1000000000000000000LL ) { -float_raise (float_flag_invalid, &env->fp_status); +set_float_exception_flags (float_flag_invalid, &env->fp_status);while (mem_ref < ptr +7 ) {cpu_stb_data_ra (env, mem_ref++,0 ,GETPC ()); }cpu_stb_data_ra (env, mem_ref++,0xc0 ,GETPC ());cpu_stb_data_ra (env, mem_ref++,0xff ,GETPC ());cpu_stb_data_ra (env, mem_ref++,0xff ,GETPC ()); +merge_exception_flags (env, old_flags);return ; } mem_end = mem_ref +9 ;
@@ -785,6 +833,7 @@ void helper_fbst_ST0(CPUX86State *env, target_ulong ptr)while (mem_ref < mem_end) {cpu_stb_data_ra (env, mem_ref++,0 ,GETPC ()); } +merge_exception_flags (env, old_flags); }void helper_f2xm1 (CPUX86State *env)
@@ -838,6 +887,7 @@ void helper_fpatan(CPUX86State *env)void helper_fxtract (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);CPU_LDoubleU temp; temp.d =ST0 ;
@@ -881,6 +931,7 @@ void helper_fxtract(CPUX86State *env)BIASEXPONENT (temp);ST0 = temp.d; } +merge_exception_flags (env, old_flags); }void helper_fprem1 (CPUX86State *env)
@@ -1020,11 +1071,13 @@ void helper_fyl2xp1(CPUX86State *env)void helper_fsqrt (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);if (floatx80_is_neg (ST0 )) { env->fpus &= ~0x4700 ;/* (C3,C2,C1,C0) <-- 0000 */ env->fpus |=0x400 ; }ST0 =floatx80_sqrt (ST0 , &env->fp_status); +merge_exception_flags (env, old_flags); }void helper_fsincos (CPUX86State *env)
@@ -1044,15 +1097,21 @@ void helper_fsincos(CPUX86State *env)void helper_frndint (CPUX86State *env) { +uint8_t old_flags =save_exception_flags (env);ST0 =floatx80_round_to_int (ST0 , &env->fp_status); +merge_exception_flags (env, old_flags); }void helper_fscale (CPUX86State *env) { -if (floatx80_invalid_encoding (ST1 )) { +uint8_t old_flags =save_exception_flags (env); +if (floatx80_invalid_encoding (ST1 ) ||floatx80_invalid_encoding (ST0 )) {float_raise (float_flag_invalid, &env->fp_status);ST0 =floatx80_default_nan (&env->fp_status); }else if (floatx80_is_any_nan (ST1 )) { +if (floatx80_is_signaling_nan (ST0 , &env->fp_status)) { +float_raise (float_flag_invalid, &env->fp_status); + }ST0 =ST1 ;if (floatx80_is_signaling_nan (ST0 , &env->fp_status)) {float_raise (float_flag_invalid, &env->fp_status);
@@ -1081,12 +1140,17 @@ void helper_fscale(CPUX86State *env) } } }else { -int n =floatx80_to_int32_round_to_zero (ST1 , &env->fp_status); +int n;signed char save = env->fp_status.floatx80_rounding_precision; +uint8_t save_flags =get_float_exception_flags (&env->fp_status); +set_float_exception_flags (0 , &env->fp_status); + n =floatx80_to_int32_round_to_zero (ST1 , &env->fp_status); +set_float_exception_flags (save_flags, &env->fp_status); env->fp_status.floatx80_rounding_precision =80 ;ST0 =floatx80_scalbn (ST0 , n, &env->fp_status); env->fp_status.floatx80_rounding_precision = save; } +merge_exception_flags (env, old_flags); }void helper_fsin (CPUX86State *env)
tests/tcg/i386/test-i386-fp-exceptions.c new file +831 -0
831 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 080/115] exec: set map length to zero when returning NULL
In reply to Paolo BonziniFrom: Prasad J Pandit <[email protected]>
When mapping physical memory into host's virtual address space, 'address_space_map' may return NULL if BounceBuffer is in_use. Set and return '*plen = 0' to avoid later NULL pointer dereference.
Message-Id: <[email protected]>
--- exec.c | 1 + include/exec/memory.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
exec.c +1 -0
@@ -3540,6 +3540,7 @@ void *address_space_map(AddressSpace *as,if (!memory_access_is_direct (mr, is_write)) {if (atomic_xchg (&bounce.in_use, true)) { + *plen =0 ;return NULL ; }/* Avoid unbounded allocations */
include/exec/memory.h +2 -1
@@ -2314,7 +2314,8 @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, hwaddr len,/* address_space_map: map a physical memory region into a host virtual address * * May map a subset of the requested range, given by and returned in @plen. -* May return %NULL if resources needed to perform the mapping are exhausted. +* May return %NULL and set *@plen to zero(0), if resources needed to perform +* the mapping are exhausted. * Use only for reads OR writes - not for read-modify-write operations. * Use cpu_register_map_client() to know when retrying the map operation is * likely to succeed.
Signature · 1 line
2.26.2
[PULL 112/115] exec/cpu-common: Move MUSB specific typedefs to 'hw/usb/hcd-musb.h'
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
The CPUReadMemoryFunc/CPUWriteMemoryFunc typedefs are legacy remnant from before the conversion to MemoryRegions. Since they are now only used in tusb6010.c and hcd-musb.c, move them to "hw/usb/musb.h" and rename them appropriately.
Message-Id: <[email protected]>
--- hw/usb/hcd-musb.c | 4 ++-- include/exec/cpu-common.h | 3 --- include/hw/usb/hcd-musb.h | 9 +++++---- 3 files changed, 7 insertions(+), 9 deletions(-)
hw/usb/hcd-musb.c +2 -2
@@ -1540,13 +1540,13 @@ static void musb_writew(void *opaque, hwaddr addr, uint32_t value) }; } -CPUReadMemoryFunc *const musb_read[] = { +MUSBReadFunc *const musb_read[] = { musb_readb, musb_readh, musb_readw, }; -CPUWriteMemoryFunc *const musb_write[] = { +MUSBWriteFunc *const musb_write[] = { musb_writeb, musb_writeh, musb_writew,
include/exec/cpu-common.h +0 -3
@@ -43,9 +43,6 @@ extern ram_addr_t ram_size;/* memory API */ -typedef void CPUWriteMemoryFunc (void *opaque,hwaddr addr,uint32_t value); -typedef uint32_t CPUReadMemoryFunc (void *opaque,hwaddr addr); -void qemu_ram_remap (ram_addr_t addr,ram_addr_t length);/* This should not be used by devices. */ ram_addr_t qemu_ram_addr_from_host (void *ptr);
include/hw/usb/hcd-musb.h +5 -4
@@ -13,8 +13,6 @@#ifndef HW_USB_MUSB_H #define HW_USB_MUSB_H -#include "exec/cpu-common.h" -enum musb_irq_source_e { musb_irq_suspend =0 , musb_irq_resume,
@@ -32,8 +30,11 @@ enum musb_irq_source_e { musb_irq_max /* total number of interrupts defined */ }; -extern CPUReadMemoryFunc *const musb_read[]; -extern CPUWriteMemoryFunc *const musb_write[]; +/* TODO convert hcd-musb to QOM/qdev and remove MUSBReadFunc/MUSBWriteFunc */ +typedef void MUSBWriteFunc (void *opaque,hwaddr addr,uint32_t value); +typedef uint32_t MUSBReadFunc (void *opaque,hwaddr addr); +extern MUSBReadFunc *const musb_read[]; +extern MUSBWriteFunc *const musb_write[];typedef struct MUSBState MUSBState ;
Signature · 1 line
2.26.2
[PULL 110/115] exec/memory: Remove unused MemoryRegionMmio type
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Since commit 62a0db942dec ('memory: Remove old_mmio accessors') this structure is unused. Remove it.
Message-Id: <[email protected]>
--- include/exec/memory.h | 6 ------ 1 file changed, 6 deletions(-)
include/exec/memory.h +0 -6
@@ -50,12 +50,6 @@extern bool global_dirty_log;typedef struct MemoryRegionOps MemoryRegionOps ; -typedef struct MemoryRegionMmio MemoryRegionMmio ; - -struct MemoryRegionMmio { -CPUReadMemoryFunc *read[3 ]; -CPUWriteMemoryFunc *write[3 ]; -};typedef struct IOMMUTLBEntry IOMMUTLBEntry ;
Signature · 1 line
2.26.2
[PULL 085/115] sysemu/hvf: Only declare hvf_allowed when HVF is available
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
When HVF is not available, the hvf_allowed variable does not exist.
Message-Id: <[email protected]>
--- include/sysemu/hvf.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/sysemu/hvf.h +3 -3
@@ -18,7 +18,6 @@#include "exec/memory.h" #include "sysemu/accel.h" -extern bool hvf_allowed;#ifdef CONFIG_HVF #include <Hypervisor/hv.h> #include <Hypervisor/hv_vmx.h>
@@ -26,11 +25,12 @@ extern bool hvf_allowed;#include "target/i386/cpu.h" uint32_t hvf_get_supported_cpuid (uint32_t func,uint32_t idx,int reg); +extern bool hvf_allowed;#define hvf_enabled () (hvf_allowed) -#else +#else /* !CONFIG_HVF */ #define hvf_enabled () 0#define hvf_get_supported_cpuid (func, idx, reg) 0 -#endif +#endif /* !CONFIG_HVF */ /* hvf_slot flags */ #define HVF_SLOT_LOG (1 << 0)
Signature · 1 line
2.26.2
[PULL 115/115] target/i386: Remove obsolete TODO file
In reply to Paolo BonziniFrom: Thomas Huth <[email protected]>
The last real change to this file is from 2012, so it is very likely that this file is completely out-of-date and ignored today. Let's simply remove it to avoid confusion if someone finds it by accident.
Message-Id: <[email protected]>
--- target/i386/TODO | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 target/i386/TODO
target/i386/TODO deleted +0 -31
@@ -1,31 +0,0 @@ -Correctness issues: - -- some eflags manipulation incorrectly reset the bit 0x2. -- SVM: test, cpu save/restore, SMM save/restore. -- x86_64: lcall/ljmp intel/amd differences ? -- better code fetch (different exception handling + CS.limit support) -- user/kernel PUSHL/POPL in helper.c -- add missing cpuid tests -- return UD exception if LOCK prefix incorrectly used -- test ldt limit < 7 ? -- fix some 16 bit sp push/pop overflow (pusha/popa, lcall lret) -- full support of segment limit/rights -- full x87 exception support -- improve x87 bit exactness (use bochs code ?) -- DRx register support -- CR0.AC emulation -- SSE alignment checks - -Optimizations/Features: - -- add SVM nested paging support -- add VMX support -- add AVX support -- add SSE5 support -- fxsave/fxrstor AMD extensions -- improve monitor/mwait support -- faster EFLAGS update: consider SZAP, C, O can be updated separately - with a bit field in CC_OP and more state variables. -- evaluate x87 stack pointer statically -- find a way to avoid translating several time the same TB if CR0.TS - is set or not.
Signature · 1 line
2.26.2
[PULL 114/115] stubs: move Xen stubs to accel/
In reply to Paolo BonziniKeep them close to the other accelerator-dependent stubs, so as to remove stubs that are not needed by tools.
--- accel/stubs/Makefile.objs | 1 + stubs/xen-hvm.c => accel/stubs/xen-stub.c | 14 +++++++------- stubs/Makefile.objs | 2 -- stubs/xen-common.c | 13 ------------- 4 files changed, 8 insertions(+), 22 deletions(-) rename stubs/xen-hvm.c => accel/stubs/xen-stub.c (74%) delete mode 100644 stubs/xen-common.c
accel/stubs/Makefile.objs +1 -0
@@ -3,3 +3,4 @@ obj-$(call lnot,$(CONFIG_HVF)) += hvf-stub.o obj-$(call lnot,$(CONFIG_WHPX)) += whpx-stub.o obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o obj-$(call lnot,$(CONFIG_TCG)) += tcg-stub.o +obj-$(call lnot,$(CONFIG_XEN)) += xen-stub.o
accel/stubs/xen-stub.c renamed from stubs/xen-hvm.c +7 -7
@@ -1,18 +1,18 @@/* -* Copyright (C) 2010 Citrix Ltd. +* Copyright (C) 2014 Citrix Systems UK Ltd. * -* This work is licensed under the terms of the GNU GPL, version 2. See -* the COPYING file in the top-level directory. -* -* Contributions after 2012-01-13 are licensed under the terms of the -* GNU GPL, version 2 or (at your option) any later version. +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. */ #include "qemu/osdep.h" #include "hw/xen/xen.h" -#include "exec/memory.h" #include "qapi/qapi-commands-misc.h" +void xenstore_store_pv_console_info (int i,Chardev *chr) +{ +} +int xen_pci_slot_get_pirq (PCIDevice *pci_dev,int irq_num) {return -1 ;
stubs/Makefile.objs +0 -2
@@ -49,7 +49,5 @@ stub-obj-y += target-get-monitor-def.o stub-obj-y += target-monitor-defs.o stub-obj-y += uuid.o stub-obj-y += vm-stop.o -stub-obj-y += xen-common.o -stub-obj-y += xen-hvm.o endif # CONFIG_SOFTMMU || CONFIG_TOOLS
stubs/xen-common.c deleted +0 -13
@@ -1,13 +0,0 @@ -/* -* Copyright (C) 2014 Citrix Systems UK Ltd. -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#include "qemu/osdep.h" -#include "hw/xen/xen.h" - -void xenstore_store_pv_console_info (int i,Chardev *chr) -{ -}
Signature · 1 line
2.26.2
[PULL 099/115] xen: fix build without pci passthrough
In reply to Paolo BonziniFrom: Anthony PERARD <[email protected]>
Xen PCI passthrough support may not be available and thus the global variable "has_igd_gfx_passthru" might be compiled out. Common code should not access it in that case.
Unfortunately, we can't use CONFIG_XEN_PCI_PASSTHROUGH directly in xen-common.c so this patch instead move access to the has_igd_gfx_passthru variable via function and those functions are also implemented as stubs. The stubs will be used when QEMU is built without passthrough support.
Now, when one will want to enable igd-passthru via the -machine property, they will get an error message if QEMU is built without passthrough support.
Message-Id: <[email protected]>
--- accel/xen/xen-all.c | 4 ++-- hw/Makefile.objs | 2 +- hw/i386/pc_piix.c | 2 +- hw/xen/Makefile.objs | 3 ++- hw/xen/xen_pt.c | 12 +++++++++++- hw/xen/xen_pt.h | 6 ++++-- hw/xen/xen_pt_stub.c | 22 ++++++++++++++++++++++ 7 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 hw/xen/xen_pt_stub.c
accel/xen/xen-all.c +2 -2
@@ -137,12 +137,12 @@ static void xen_change_state_handler(void *opaque, int running,static bool xen_get_igd_gfx_passthru (Object *obj,Error **errp) { -return has_igd_gfx_passthru; +return xen_igd_gfx_pt_enabled (); }static void xen_set_igd_gfx_passthru (Object *obj,bool value,Error **errp) { - has_igd_gfx_passthru = value; +xen_igd_gfx_pt_set (value, errp); }static void xen_setup_post (MachineState *ms,AccelState *accel)
hw/Makefile.objs +1 -1
@@ -35,7 +35,7 @@ devices-dirs-y += usb/ devices-dirs-$(CONFIG_VFIO) += vfio/ devices-dirs-y += virtio/ devices-dirs-y += watchdog/ -devices-dirs-y += xen/ +devices-dirs-$(CONFIG_XEN) += xen/ devices-dirs-$(CONFIG_MEM_DEVICE) += mem/ devices-dirs-$(CONFIG_NUBUS) += nubus/ devices-dirs-y += semihosting/
hw/i386/pc_piix.c +1 -1
@@ -377,7 +377,7 @@ static void pc_init_isa(MachineState *machine)#ifdef CONFIG_XEN static void pc_xen_hvm_init_pci (MachineState *machine) { -const char *pci_type = has_igd_gfx_passthru ? +const char *pci_type =xen_igd_gfx_pt_enabled () ?TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE :TYPE_I440FX_PCI_DEVICE ; pc_init1(machine,
hw/xen/Makefile.objs +2 -1
@@ -1,6 +1,7 @@ # xen backend driver support -common-obj-$(CONFIG_XEN) += xen-legacy-backend.o xen_devconfig.o xen_pvdev.o xen-bus.o xen-bus-helper.o xen-backend.o +common-obj-y += xen-legacy-backend.o xen_devconfig.o xen_pvdev.o xen-bus.o xen-bus-helper.o xen-backend.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen-host-pci-device.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_graphics.o xen_pt_msi.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt_load_rom.o +obj-$(call $(lnot, $(CONFIG_XEN_PCI_PASSTHROUGH))) += xen_pt_stub.o
hw/xen/xen_pt.c +11 -1
@@ -65,7 +65,17 @@#include "qemu/range.h" #include "exec/address-spaces.h" -bool has_igd_gfx_passthru; +static bool has_igd_gfx_passthru; + +bool xen_igd_gfx_pt_enabled (void ) +{ +return has_igd_gfx_passthru; +} + +void xen_igd_gfx_pt_set (bool value,Error **errp) +{ + has_igd_gfx_passthru = value; +}#define XEN_PT_NR_IRQS (256)static uint8_t xen_pt_mapped_machine_irq[XEN_PT_NR_IRQS ] = {0 };
hw/xen/xen_pt.h +4 -2
@@ -5,6 +5,9 @@#include "hw/pci/pci.h" #include "xen-host-pci-device.h" +bool xen_igd_gfx_pt_enabled (void ); +void xen_igd_gfx_pt_set (bool value,Error **errp); + void xen_pt_log(const PCIDevice *d, const char *f, ...) GCC_FMT_ATTR(2, 3); #define XEN_PT_ERR(d, _f, _a...) xen_pt_log(d, "%s: Error: "_f, __func__, ##_a)
@@ -322,10 +325,9 @@ extern void *pci_assign_dev_load_option_rom(PCIDevice *dev,unsigned int domain, unsigned int bus, unsigned int slot, unsigned int function); -extern bool has_igd_gfx_passthru;static inline bool is_igd_vga_passthrough (XenHostPCIDevice *dev) { -return (has_igd_gfx_passthru +return (xen_igd_gfx_pt_enabled () && ((dev->class_code >>0x8 ) ==PCI_CLASS_DISPLAY_VGA )); }int xen_pt_register_vga_regions (XenHostPCIDevice *dev);
hw/xen/xen_pt_stub.c new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright (C) 2020 Citrix Systems UK Ltd. +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "hw/xen/xen_pt.h" +#include "qapi/error.h" + +bool xen_igd_gfx_pt_enabled (void ) +{ +return false; +} + +void xen_igd_gfx_pt_set (bool value,Error **errp) +{ +if (value) { +error_setg (errp,"Xen PCI passthrough support not built in" ); + } +}
Signature · 1 line
2.26.2
[PULL 086/115] target/ppc: Restrict PPCVirtualHypervisorClass to system-mode
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
The code related to PPC Virtual Hypervisor is pointless in user-mode.
Message-Id: <[email protected]>
--- target/ppc/cpu.h | 4 ++-- target/ppc/kvm_ppc.h | 22 +++++++++++----------- target/ppc/translate_init.inc.c | 4 ++++ 3 files changed, 17 insertions(+), 13 deletions(-)
target/ppc/cpu.h +2 -2
@@ -1202,6 +1202,7 @@ PowerPCCPUClass *ppc_cpu_class_by_pvr(uint32_t pvr);PowerPCCPUClass *ppc_cpu_class_by_pvr_mask (uint32_t pvr);PowerPCCPUClass *ppc_cpu_get_family_class (PowerPCCPUClass *pcc); +#ifndef CONFIG_USER_ONLY struct PPCVirtualHypervisorClass { InterfaceClass parent; void (*hypercall)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);
@@ -1215,10 +1216,8 @@ struct PPCVirtualHypervisorClass {void (*hpte_set_r)(PPCVirtualHypervisor *vhyp,hwaddr ptex,uint64_t pte1);void (*get_pate)(PPCVirtualHypervisor *vhyp,ppc_v3_pate_t *entry);target_ulong (*encode_hpt_for_kvm_pr)(PPCVirtualHypervisor *vhyp); -#ifndef CONFIG_USER_ONLY void (*cpu_exec_enter)(PPCVirtualHypervisor *vhyp,PowerPCCPU *cpu);void (*cpu_exec_exit)(PPCVirtualHypervisor *vhyp,PowerPCCPU *cpu); -#endif };#define TYPE_PPC_VIRTUAL_HYPERVISOR "ppc-virtual-hypervisor"
@@ -1230,6 +1229,7 @@ struct PPCVirtualHypervisorClass {#define PPC_VIRTUAL_HYPERVISOR_GET_CLASS (obj) \ OBJECT_GET_CLASS(PPCVirtualHypervisorClass, (obj), \ TYPE_PPC_VIRTUAL_HYPERVISOR) +#endif /* CONFIG_USER_ONLY */ void ppc_cpu_do_interrupt (CPUState *cpu);bool ppc_cpu_exec_interrupt (CPUState *cpu,int int_req);
target/ppc/kvm_ppc.h +11 -11
@@ -280,6 +280,17 @@ static inline bool kvmppc_has_cap_spapr_vfio(void) return false; } +static inline void kvmppc_read_hptes (ppc_hash_pte64_t *hptes, +hwaddr ptex,int n) +{ +abort (); +} + +static inline void kvmppc_write_hpte (hwaddr ptex,uint64_t pte0,uint64_t pte1) +{ +abort (); +} +#endif /* !CONFIG_USER_ONLY */ static inline bool kvmppc_has_cap_epr (void )
@@ -310,17 +321,6 @@ static inline int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index,abort (); } -static inline void kvmppc_read_hptes (ppc_hash_pte64_t *hptes, -hwaddr ptex,int n) -{ -abort (); -} - -static inline void kvmppc_write_hpte (hwaddr ptex,uint64_t pte0,uint64_t pte1) -{ -abort (); -} -static inline bool kvmppc_has_cap_fixup_hcalls (void ) {abort ();
target/ppc/translate_init.inc.c +4 -0
@@ -10942,16 +10942,20 @@ static const TypeInfo ppc_cpu_type_info = { .class_init = ppc_cpu_class_init, }; +#ifndef CONFIG_USER_ONLY static const TypeInfo ppc_vhyp_type_info = { .name =TYPE_PPC_VIRTUAL_HYPERVISOR , .parent =TYPE_INTERFACE , .class_size =sizeof (PPCVirtualHypervisorClass), }; +#endif static void ppc_cpu_register_types (void ) {type_register_static (&ppc_cpu_type_info); +#ifndef CONFIG_USER_ONLY type_register_static (&ppc_vhyp_type_info); +#endif }type_init (ppc_cpu_register_types)
Signature · 1 line
2.26.2
[PULL 050/115] megasas: use unsigned type for positive numeric fields
In reply to Paolo BonziniFrom: Prasad J Pandit <[email protected]>
Use unsigned type for the MegasasState fields which hold positive numeric values.
Message-Id: <[email protected]>
--- hw/scsi/megasas.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
hw/scsi/megasas.c +19 -19
@@ -86,34 +86,34 @@ typedef struct MegasasState {MemoryRegion queue_io;uint32_t frame_hi; -int fw_state; +uint32_t fw_state;uint32_t fw_sge;uint32_t fw_cmds;uint32_t flags; -int fw_luns; -int intr_mask; -int doorbell; -int busy; -int diag; -int adp_reset; +uint32_t fw_luns; +uint32_t intr_mask; +uint32_t doorbell; +uint32_t busy; +uint32_t diag; +uint32_t adp_reset;OnOffAuto msi;OnOffAuto msix;MegasasCmd *event_cmd; -int event_locale; +uint16_t event_locale;int event_class; -int event_count; -int shutdown_event; -int boot_event; +uint32_t event_count; +uint32_t shutdown_event; +uint32_t boot_event;uint64_t sas_addr;char *hba_serial;uint64_t reply_queue_pa;void *reply_queue; -int reply_queue_len; +uint16_t reply_queue_len;uint16_t reply_queue_head; -int reply_queue_tail; +uint16_t reply_queue_tail;uint64_t consumer_pa;uint64_t producer_pa;
@@ -2259,9 +2259,9 @@ static const VMStateDescription vmstate_megasas_gen1 = {VMSTATE_PCI_DEVICE (parent_obj, MegasasState),VMSTATE_MSIX (parent_obj, MegasasState), -VMSTATE_INT32 (fw_state, MegasasState), -VMSTATE_INT32 (intr_mask, MegasasState), -VMSTATE_INT32 (doorbell, MegasasState), +VMSTATE_UINT32 (fw_state, MegasasState), +VMSTATE_UINT32 (intr_mask, MegasasState), +VMSTATE_UINT32 (doorbell, MegasasState),VMSTATE_UINT64 (reply_queue_pa, MegasasState),VMSTATE_UINT64 (consumer_pa, MegasasState), VMSTATE_UINT64(producer_pa, MegasasState),
@@ -2278,9 +2278,9 @@ static const VMStateDescription vmstate_megasas_gen2 = {VMSTATE_PCI_DEVICE (parent_obj, MegasasState),VMSTATE_MSIX (parent_obj, MegasasState), -VMSTATE_INT32 (fw_state, MegasasState), -VMSTATE_INT32 (intr_mask, MegasasState), -VMSTATE_INT32 (doorbell, MegasasState), +VMSTATE_UINT32 (fw_state, MegasasState), +VMSTATE_UINT32 (intr_mask, MegasasState), +VMSTATE_UINT32 (doorbell, MegasasState),VMSTATE_UINT64 (reply_queue_pa, MegasasState),VMSTATE_UINT64 (consumer_pa, MegasasState), VMSTATE_UINT64(producer_pa, MegasasState),
Signature · 1 line
2.26.2
[PULL 111/115] hw/usb: Move device-specific declarations to new 'hcd-musb.h' header
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Move the declarations for the MUSB-HDRC USB2.0 OTG compliant core into a separate header.
Message-Id: <[email protected]>
--- hw/usb/hcd-musb.c | 1 + hw/usb/tusb6010.c | 1 + include/hw/usb.h | 30 ------------------------- include/hw/usb/hcd-musb.h | 46 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 30 deletions(-) create mode 100644 include/hw/usb/hcd-musb.h
hw/usb/hcd-musb.c +1 -0
@@ -23,6 +23,7 @@#include "qemu/osdep.h" #include "qemu/timer.h" #include "hw/usb.h" +#include "hw/usb/hcd-musb.h" #include "hw/irq.h" #include "hw/hw.h"
hw/usb/tusb6010.c +1 -0
@@ -23,6 +23,7 @@#include "qemu/module.h" #include "qemu/timer.h" #include "hw/usb.h" +#include "hw/usb/hcd-musb.h" #include "hw/arm/omap.h" #include "hw/hw.h" #include "hw/irq.h"
include/hw/usb.h +0 -30
@@ -474,36 +474,6 @@ bool usb_host_dev_is_scsi_storage(USBDevice *usbdev);#define VM_USB_HUB_SIZE 8 -/* hw/usb/hdc-musb.c */ - -enum musb_irq_source_e { - musb_irq_suspend =0 , - musb_irq_resume, - musb_irq_rst_babble, - musb_irq_sof, - musb_irq_connect, - musb_irq_disconnect, - musb_irq_vbus_request, - musb_irq_vbus_error, - musb_irq_rx, - musb_irq_tx, - musb_set_vbus, - musb_set_session, -/* Add new interrupts here */ - musb_irq_max,/* total number of interrupts defined */ -}; - -typedef struct MUSBState MUSBState ; - -extern CPUReadMemoryFunc *const musb_read[]; -extern CPUWriteMemoryFunc *const musb_write[]; - -MUSBState *musb_init (DeviceState *parent_device,int gpio_base); -void musb_reset (MUSBState *s); -uint32_t musb_core_intr_get (MUSBState *s); -void musb_core_intr_clear (MUSBState *s,uint32_t mask); -void musb_set_size (MUSBState *s,int epnum,int size,int is_tx); -/* usb-bus.c */ #define TYPE_USB_BUS "usb-bus"
include/hw/usb/hcd-musb.h new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 088/115] i386: hvf: Drop useless declarations in sysemu
In reply to Paolo BonziniFrom: Roman Bolshakov <[email protected]>
They're either declared elsewhere or have no use.
While at it, rename _hvf_cpu_synchronize_post_init() to do_hvf_cpu_synchronize_post_init().
Message-Id: <[email protected]>
--- include/sysemu/hvf.h | 22 ---------------------- target/i386/hvf/hvf.c | 7 ++++--- 2 files changed, 4 insertions(+), 25 deletions(-)
include/sysemu/hvf.h +0 -22
@@ -30,35 +30,13 @@ extern bool hvf_allowed;#define hvf_get_supported_cpuid (func, idx, reg) 0#endif /* !CONFIG_HVF */ -/* Disable HVF if |disable| is 1, otherwise, enable it iff it is supported by -* the host CPU. Use hvf_enabled() after this to get the result. */ -void hvf_disable (int disable); - -/* Returns non-0 if the host CPU supports the VMX "unrestricted guest" feature -* which allows the virtual CPU to directly run in "real mode". If true, this -* allows QEMU to run several vCPU threads in parallel (see cpus.c). Otherwise, -* only a a single TCG thread can run, and it will call HVF to run the current -* instructions, except in case of "real mode" (paging disabled, typically at -* boot time), or MMIO operations. */ - -int hvf_sync_vcpus (void ); -int hvf_init_vcpu (CPUState *);int hvf_vcpu_exec (CPUState *); -int hvf_smp_cpu_exec (CPUState *);void hvf_cpu_synchronize_state (CPUState *);void hvf_cpu_synchronize_post_reset (CPUState *);void hvf_cpu_synchronize_post_init (CPUState *); -void _hvf_cpu_synchronize_post_init (CPUState *,run_on_cpu_data ); -void hvf_vcpu_destroy (CPUState *); -void hvf_raise_event (CPUState *); -/* void hvf_reset_vcpu_state(void *opaque); */ void hvf_reset_vcpu (CPUState *); -void vmx_update_tpr (CPUState *); -void update_apic_tpr (CPUState *); -int hvf_put_registers (CPUState *); -void vmx_clear_int_window_exiting (CPUState *cpu);#define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")
target/i386/hvf/hvf.c +4 -3
@@ -251,7 +251,7 @@ void vmx_update_tpr(CPUState *cpu) } } -void update_apic_tpr (CPUState *cpu) +static void update_apic_tpr (CPUState *cpu) {X86CPU *x86_cpu =X86_CPU (cpu);int tpr =rreg (cpu->hvf_fd,HV_X86_TPR ) >>4 ;
@@ -312,7 +312,8 @@ void hvf_cpu_synchronize_post_reset(CPUState *cpu_state)run_on_cpu (cpu_state, do_hvf_cpu_synchronize_post_reset,RUN_ON_CPU_NULL ); } -void _hvf_cpu_synchronize_post_init (CPUState *cpu,run_on_cpu_data arg) +static void do_hvf_cpu_synchronize_post_init (CPUState *cpu, +run_on_cpu_data arg) {CPUState *cpu_state = cpu;hvf_put_registers (cpu_state);
@@ -321,7 +322,7 @@ void _hvf_cpu_synchronize_post_init(CPUState *cpu, run_on_cpu_data arg)void hvf_cpu_synchronize_post_init (CPUState *cpu_state) { -run_on_cpu (cpu_state, _hvf_cpu_synchronize_post_init,RUN_ON_CPU_NULL ); +run_on_cpu (cpu_state, do_hvf_cpu_synchronize_post_init,RUN_ON_CPU_NULL ); }static bool ept_emulation_fault (hvf_slot *slot,uint64_t gpa,uint64_t ept_qual)
Signature · 1 line
2.26.2
[PULL 069/115] KVM: Kick resamplefd for split kernel irqchip
In reply to Paolo BonziniFrom: Peter Xu <[email protected]>
This is majorly only for X86 because that's the only one that supports split irqchip for now.
When the irqchip is split, we face a dilemma that KVM irqfd will be enabled, however the slow irqchip is still running in the userspace. It means that the resamplefd in the kernel irqfds won't take any effect and it will miss to ack INTx interrupts on EOIs.
One example is split irqchip with VFIO INTx, which will break if we use the VFIO INTx fast path.
This patch can potentially supports the VFIO fast path again for INTx, that the IRQ delivery will still use the fast path, while we don't need to trap MMIOs in QEMU for the device to emulate the EIOs (see the callers of vfio_eoi() hook). However the EOI of the INTx will still need to be done from the userspace by caching all the resamplefds in QEMU and kick properly for IOAPIC EOI broadcast.
This is tricky because in this case the userspace ioapic irr & remote-irr will be bypassed. However such a change will greatly boost performance for assigned devices using INTx irqs (TCP_RR boosts 46% after this patch applied).
When the userspace is responsible for the resamplefd kickup, don't register it on the kvm_irqfd anymore, because on newer kernels (after commit 654f1f13ea56, 5.2+) the KVM_IRQFD will fail if with both split irqchip and resamplefd. This will make sure that the fast path will work for all supported kernels.
https://patchwork.kernel.org/patch/10738541/#22609933
Message-Id: <[email protected]>
--- accel/kvm/kvm-all.c | 79 ++++++++++++++++++++++++++++++++++++++++-- accel/kvm/trace-events | 1 + hw/intc/ioapic.c | 19 ++++++++++ include/sysemu/kvm.h | 4 +++ 4 files changed, 101 insertions(+), 2 deletions(-)
accel/kvm/kvm-all.c +77 -2
@@ -160,9 +160,59 @@ static const KVMCapabilityInfo kvm_required_capabilites[] = {static NotifierList kvm_irqchip_change_notifiers =NOTIFIER_LIST_INITIALIZER (kvm_irqchip_change_notifiers); +struct KVMResampleFd { +int gsi; +EventNotifier *resample_event; +QLIST_ENTRY (KVMResampleFd) node; +}; +typedef struct KVMResampleFd KVMResampleFd ; + +/* +* Only used with split irqchip where we need to do the resample fd +* kick for the kernel from userspace. +*/ +static QLIST_HEAD(, KVMResampleFd) kvm_resample_fd_list = +QLIST_HEAD_INITIALIZER (kvm_resample_fd_list); +#define kvm_slots_lock (kml) qemu_mutex_lock(&(kml)->slots_lock)#define kvm_slots_unlock (kml) qemu_mutex_unlock(&(kml)->slots_lock) +static inline void kvm_resample_fd_remove (int gsi) +{ +KVMResampleFd *rfd; + + QLIST_FOREACH(rfd, &kvm_resample_fd_list, node) { +if (rfd->gsi == gsi) { +QLIST_REMOVE (rfd, node); +g_free (rfd); +break ; + } + } +} + +static inline void kvm_resample_fd_insert (int gsi,EventNotifier *event) +{ +KVMResampleFd *rfd =g_new0 (KVMResampleFd,1 ); + + rfd->gsi = gsi; + rfd->resample_event = event; + +QLIST_INSERT_HEAD (&kvm_resample_fd_list, rfd, node); +} + +void kvm_resample_fd_notify (int gsi) +{ +KVMResampleFd *rfd; + + QLIST_FOREACH(rfd, &kvm_resample_fd_list, node) { +if (rfd->gsi == gsi) { +event_notifier_set (rfd->resample_event); +trace_kvm_resample_fd_notify (gsi); +return ; + } + } +} +int kvm_get_max_memslots (void ) {KVMState *s =KVM_STATE (current_accel ());
@@ -1676,8 +1726,33 @@ static int kvm_irqchip_assign_irqfd(KVMState *s, EventNotifier *event, };if (rfd !=-1 ) { - irqfd.flags |=KVM_IRQFD_FLAG_RESAMPLE ; - irqfd.resamplefd = rfd; +assert (assign); +if (kvm_irqchip_is_split ()) { +/* +* When the slow irqchip (e.g. IOAPIC) is in the +* userspace, KVM kernel resamplefd will not work because +* the EOI of the interrupt will be delivered to userspace +* instead, so the KVM kernel resamplefd kick will be +* skipped. The userspace here mimics what the kernel +* provides with resamplefd, remember the resamplefd and +* kick it when we receive EOI of this IRQ. +* +* This is hackery because IOAPIC is mostly bypassed +* (except EOI broadcasts) when irqfd is used. However +* this can bring much performance back for split irqchip +* with INTx IRQs (for VFIO, this gives 93% perf of the +* full fast path, which is 46% perf boost comparing to +* the INTx slow path). +*/ +kvm_resample_fd_insert (virq, resample); + }else { + irqfd.flags |=KVM_IRQFD_FLAG_RESAMPLE ; + irqfd.resamplefd = rfd; + } + }else if (!assign) { +if (kvm_irqchip_is_split ()) { +kvm_resample_fd_remove (virq); + } }if (!kvm_irqfds_enabled ()) {
accel/kvm/trace-events +1 -0
@@ -16,4 +16,5 @@ kvm_set_ioeventfd_mmio(int fd, uint64_t addr, uint32_t val, bool assign, uint32_ kvm_set_ioeventfd_pio(int fd, uint16_t addr, uint32_t val, bool assign, uint32_t size, bool datamatch) "fd: %d @0x%x val=0x%x assign: %d size: %d match: %d" kvm_set_user_memory(uint32_t slot, uint32_t flags, uint64_t guest_phys_addr, uint64_t memory_size, uint64_t userspace_addr, int ret) "Slot#%d flags=0x%x gpa=0x%"PRIx64 " size=0x%"PRIx64 " ua=0x%"PRIx64 " ret=%d" kvm_clear_dirty_log(uint32_t slot, uint64_t start, uint32_t size) "slot#%"PRId32" start 0x%"PRIx64" size 0x%"PRIx32 +kvm_resample_fd_notify(int gsi) "gsi %d"
hw/intc/ioapic.c +19 -0
@@ -241,6 +241,25 @@ void ioapic_eoi_broadcast(int vector)continue ; } +#ifdef CONFIG_KVM +/* +* When IOAPIC is in the userspace while APIC is still in +* the kernel (i.e., split irqchip), we have a trick to +* kick the resamplefd logic for registered irqfds from +* userspace to deactivate the IRQ. When that happens, it +* means the irq bypassed userspace IOAPIC (so the irr and +* remote-irr of the table entry should be bypassed too +* even if interrupt come). Still kick the resamplefds if +* they're bound to the IRQ, to make sure to EOI the +* interrupt for the hardware correctly. +* +* Note: We still need to go through the irr & remote-irr +* operations below because we don't know whether there're +* emulated devices that are using/sharing the same IRQ. +*/ +kvm_resample_fd_notify (n); +#endif +if (!(entry &IOAPIC_LVT_REMOTE_IRR )) {continue ; }
include/sysemu/kvm.h +4 -0
@@ -554,4 +554,8 @@ int kvm_set_one_reg(CPUState *cs, uint64_t id, void *source);int kvm_get_one_reg (CPUState *cs,uint64_t id,void *target);struct ppc_radix_page_info *kvm_get_radix_page_info (void );int kvm_get_max_memslots (void ); + +/* Notify resamplefd for EOI of specific interrupts. */ +void kvm_resample_fd_notify (int gsi); +#endif
Signature · 1 line
2.26.2
[PULL 091/115] i386: hvf: Use IP from CPUX86State
In reply to Paolo BonziniFrom: Roman Bolshakov <[email protected]>
Drop and replace rip field from HVFX86EmulatorState in favor of eip from common CPUX86State.
Message-Id: <[email protected]>
--- target/i386/hvf/hvf.c | 6 +-- target/i386/hvf/x86.h | 3 -- target/i386/hvf/x86_decode.c | 6 +-- target/i386/hvf/x86_emu.c | 86 ++++++++++++++++++------------------ target/i386/hvf/x86_task.c | 4 +- 5 files changed, 51 insertions(+), 54 deletions(-)
target/i386/hvf/hvf.c +3 -3
@@ -797,7 +797,7 @@ int hvf_vcpu_exec(CPUState *cpu) }else {RAX (env) = (uint64_t )val; } -RIP (env) += ins_len; + env->eip += ins_len;store_regs (cpu);break ; }else if (!string && !in) {
@@ -871,7 +871,7 @@ int hvf_vcpu_exec(CPUState *cpu) }else {simulate_wrmsr (cpu); } -RIP (env) += ins_len; + env->eip += ins_len;store_regs (cpu);break ; }
@@ -907,7 +907,7 @@ int hvf_vcpu_exec(CPUState *cpu)error_report ("Unrecognized CR %d" , cr);abort (); } -RIP (env) += ins_len; + env->eip += ins_len;store_regs (cpu);break ; }
target/i386/hvf/x86.h +0 -3
@@ -294,7 +294,6 @@ typedef struct lazy_flags {/* Definition of hvf_x86_state is here */ struct HVFX86EmulatorState {uint64_t fetch_rip; -uint64_t rip;struct x86_register regs[16 ];struct x86_reg_flags rflags;struct lazy_flags lflags;
@@ -302,8 +301,6 @@ struct HVFX86EmulatorState { };/* useful register access macros */ -#define RIP (cpu) (cpu->hvf_emul->rip) -#define EIP (cpu) ((uint32_t)cpu->hvf_emul->rip)#define RFLAGS (cpu) (cpu->hvf_emul->rflags.rflags)#define EFLAGS (cpu) (cpu->hvf_emul->rflags.eflags)
target/i386/hvf/x86_decode.c +3 -3
@@ -75,7 +75,7 @@ static inline uint64_t decode_bytes(CPUX86State *env, struct x86_decode *decode,VM_PANIC_EX ("%s invalid size %d\n" , __func__, size);break ; } -target_ulong va =linear_rip (env_cpu (env),RIP (env)) + decode->len; +target_ulong va =linear_rip (env_cpu (env), env->eip) + decode->len;vmx_read_mem (env_cpu (env), &val, va, size); decode->len += size;
@@ -1771,7 +1771,7 @@ void calc_modrm_operand32(CPUX86State *env, struct x86_decode *decode, ptr +=get_sib_val (env, decode, &seg); }else if (!decode->modrm.mod &&5 == decode->modrm.rm) {if (x86_is_long_mode (env_cpu (env))) { - ptr +=RIP (env) + decode->len; + ptr += env->eip + decode->len; }else { ptr = decode->displacement; }
@@ -1807,7 +1807,7 @@ void calc_modrm_operand64(CPUX86State *env, struct x86_decode *decode,if (4 == rm) { ptr =get_sib_val (env, decode, &seg) + offset; }else if (0 == mod &&5 == rm) { - ptr =RIP (env) + decode->len + (int32_t ) offset; + ptr = env->eip + decode->len + (int32_t ) offset; }else { ptr =get_reg_val (env, src, decode->rex.rex, decode->rex.b,8 ) + (int64_t ) offset;
target/i386/hvf/x86_emu.c +43 -43
324 lines not on this page · raw message
target/i386/hvf/x86_task.c +2 -2
@@ -38,7 +38,7 @@ static void save_state_to_tss32(CPUState *cpu, struct x86_tss_segment32 *tss)CPUX86State *env = &x86_cpu->env;/* CR3 and ldt selector are not saved intentionally */ - tss->eip =EIP (env); + tss->eip = (uint32_t )env->eip; tss->eflags =EFLAGS (env); tss->eax =EAX (env); tss->ecx =ECX (env);
@@ -64,7 +64,7 @@ static void load_state_from_tss32(CPUState *cpu, struct x86_tss_segment32 *tss)wvmcs (cpu->hvf_fd,VMCS_GUEST_CR3 , tss->cr3); -RIP (env) = tss->eip; + env->eip = tss->eip;EFLAGS (env) = tss->eflags |2 ;/* General purpose registers */
Signature · 1 line
2.26.2
[PULL 094/115] i386: hvf: Drop copy of RFLAGS defines
In reply to Paolo BonziniFrom: Roman Bolshakov <[email protected]>
Use the ones provided in target/i386/cpu.h instead.
Message-Id: <[email protected]>
--- target/i386/hvf/x86.c | 2 +- target/i386/hvf/x86.h | 20 -------------------- target/i386/hvf/x86_decode.c | 16 +++++++--------- target/i386/hvf/x86_task.c | 2 +- 4 files changed, 9 insertions(+), 31 deletions(-)
target/i386/hvf/x86.c +1 -1
@@ -131,7 +131,7 @@ bool x86_is_v8086(struct CPUState *cpu) {X86CPU *x86_cpu =X86_CPU (cpu);CPUX86State *env = &x86_cpu->env; -return x86_is_protected (cpu) && (env->eflags &RFLAGS_VM ); +return x86_is_protected (cpu) && (env->eflags &VM_MASK ); }bool x86_is_long_mode (struct CPUState *cpu)
target/i386/hvf/x86.h +0 -20
@@ -42,26 +42,6 @@ typedef struct x86_register { }; } __attribute__ ((__packed__)) x86_register; -typedef enum x86_rflags { -RFLAGS_CF = (1L <<0 ), -RFLAGS_PF = (1L <<2 ), -RFLAGS_AF = (1L <<4 ), -RFLAGS_ZF = (1L <<6 ), -RFLAGS_SF = (1L <<7 ), -RFLAGS_TF = (1L <<8 ), -RFLAGS_IF = (1L <<9 ), -RFLAGS_DF = (1L <<10 ), -RFLAGS_OF = (1L <<11 ), -RFLAGS_IOPL = (3L <<12 ), -RFLAGS_NT = (1L <<14 ), -RFLAGS_RF = (1L <<16 ), -RFLAGS_VM = (1L <<17 ), -RFLAGS_AC = (1L <<18 ), -RFLAGS_VIF = (1L <<19 ), -RFLAGS_VIP = (1L <<20 ), -RFLAGS_ID = (1L <<21 ), -}x86_rflags ; - typedef enum x86_reg_cr0 { CR0_PE = (1L << 0), CR0_MP = (1L << 1),
target/i386/hvf/x86_decode.c +7 -9
@@ -697,15 +697,13 @@ static void decode_db_4(CPUX86State *env, struct x86_decode *decode)#define RFLAGS_MASK_NONE 0 -#define RFLAGS_MASK_OSZAPC (RFLAGS_OF | RFLAGS_SF | RFLAGS_ZF | RFLAGS_AF | \ - RFLAGS_PF | RFLAGS_CF) -#define RFLAGS_MASK_LAHF (RFLAGS_SF | RFLAGS_ZF | RFLAGS_AF | RFLAGS_PF | \ - RFLAGS_CF) -#define RFLAGS_MASK_CF (RFLAGS_CF) -#define RFLAGS_MASK_IF (RFLAGS_IF) -#define RFLAGS_MASK_TF (RFLAGS_TF) -#define RFLAGS_MASK_DF (RFLAGS_DF) -#define RFLAGS_MASK_ZF (RFLAGS_ZF) +#define RFLAGS_MASK_OSZAPC (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C) +#define RFLAGS_MASK_LAHF (CC_S | CC_Z | CC_A | CC_P | CC_C) +#define RFLAGS_MASK_CF (CC_C) +#define RFLAGS_MASK_IF (IF_MASK) +#define RFLAGS_MASK_TF (TF_MASK) +#define RFLAGS_MASK_DF (DF_MASK) +#define RFLAGS_MASK_ZF (CC_Z)struct decode_tbl _1op_inst[] = { {0x0 ,X86_DECODE_CMD_ADD ,1 , true, decode_modrm_rm, decode_modrm_reg,NULL ,
target/i386/hvf/x86_task.c +1 -1
@@ -158,7 +158,7 @@ void vmx_handle_task_switch(CPUState *cpu, x68_segment_selector tss_sel, int rea }if (reason ==TSR_IRET ) - env->eflags &= ~RFLAGS_NT ; + env->eflags &= ~NT_MASK ;if (reason !=TSR_CALL && reason !=TSR_IDT_GATE ) old_tss_sel.sel =0xffff ;
Signature · 1 line
2.26.2
[PULL 096/115] i386: hvf: Move lazy_flags into CPUX86State
In reply to Paolo BonziniFrom: Roman Bolshakov <[email protected]>
The lazy flags are still needed for instruction decoder.
Message-Id: <[email protected]>
--- include/sysemu/hvf.h | 7 +++++ target/i386/cpu.h | 2 ++ target/i386/hvf/x86.h | 6 ---- target/i386/hvf/x86_flags.c | 57 ++++++++++++++++++------------------- 4 files changed, 37 insertions(+), 35 deletions(-)
include/sysemu/hvf.h +7 -0
@@ -21,10 +21,17 @@#include <Hypervisor/hv_vmx.h> #include <Hypervisor/hv_error.h> #include "target/i386/cpu.h" +#include "exec/cpu-defs.h" +uint32_t hvf_get_supported_cpuid (uint32_t func,uint32_t idx,int reg);extern bool hvf_allowed;#define hvf_enabled () (hvf_allowed) + +typedef struct hvf_lazy_flags { +target_ulong result; +target_ulong auxbits; +}hvf_lazy_flags ;#else /* !CONFIG_HVF */ #define hvf_enabled () 0#define hvf_get_supported_cpuid (func, idx, reg) 0
target/i386/cpu.h +2 -0
@@ -20,6 +20,7 @@#ifndef I386_CPU_H #define I386_CPU_H +#include "sysemu/hvf.h" #include "sysemu/tcg.h" #include "cpu-qom.h" #include "hyperv-proto.h"
@@ -1597,6 +1598,7 @@ typedef struct CPUX86State {struct kvm_nested_state *nested_state;#endif #if defined(CONFIG_HVF ) +hvf_lazy_flags hvf_lflags;HVFX86EmulatorState *hvf_emul;#endif
target/i386/hvf/x86.h +0 -6
@@ -228,14 +228,8 @@ typedef struct x68_segment_selector { }; } __attribute__ ((__packed__)) x68_segment_selector; -typedef struct lazy_flags { -target_ulong result; -target_ulong auxbits; -}lazy_flags ; -/* Definition of hvf_x86_state is here */ struct HVFX86EmulatorState { -struct lazy_flags lflags;uint8_t mmio_buf[4096 ]; };
target/i386/hvf/x86_flags.c +28 -29
140 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 102/115] target/i386: sev: Rename QSevGuestInfo
In reply to Paolo BonziniFrom: David Gibson <[email protected]>
At the moment this is a purely passive object which is just a container for information used elsewhere, hence the name. I'm going to change that though, so as a preliminary rename it to SevGuestState.
That name risks confusion with both SEVState and SevState, but I'll be working on that in following patches.
Message-Id: <[email protected]>
--- target/i386/sev.c | 87 ++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 43 deletions(-)
target/i386/sev.c +44 -43
@@ -29,22 +29,23 @@#include "trace.h" #include "migration/blocker.h" -#define TYPE_QSEV_GUEST_INFO "sev-guest" -#define QSEV_GUEST_INFO (obj) \ - OBJECT_CHECK(QSevGuestInfo, (obj), TYPE_QSEV_GUEST_INFO) +#define TYPE_SEV_GUEST "sev-guest" +#define SEV_GUEST (obj) \ + OBJECT_CHECK(SevGuestState, (obj), TYPE_SEV_GUEST) -typedef struct QSevGuestInfo QSevGuestInfo ; +typedef struct SevGuestState SevGuestState ;/** -* QSevGuestInfo: +* SevGuestState: * -* The QSevGuestInfo object is used for creating a SEV guest. +* The SevGuestState object is used for creating and managing a SEV +* guest. * * # $QEMU \ * -object sev-guest,id=sev0 \ * -machine ...,memory-encryption=sev0 */ -struct QSevGuestInfo { +struct SevGuestState {Object parent_obj;char *sev_device;
@@ -57,7 +58,7 @@ struct QSevGuestInfo { };struct SEVState { -QSevGuestInfo *sev_info; +SevGuestState *sev_info;uint8_t api_major;uint8_t api_minor;uint8_t build_id;
@@ -235,82 +236,82 @@ static struct RAMBlockNotifier sev_ram_notifier = { };static void -qsev_guest_finalize (Object *obj) +sev_guest_finalize (Object *obj) { }static char * -qsev_guest_get_session_file (Object *obj,Error **errp) +sev_guest_get_session_file (Object *obj,Error **errp) { -QSevGuestInfo *s =QSEV_GUEST_INFO (obj); +SevGuestState *s =SEV_GUEST (obj);return s->session_file ?g_strdup (s->session_file) :NULL ; }static void -qsev_guest_set_session_file (Object *obj,const char *value,Error **errp) +sev_guest_set_session_file (Object *obj,const char *value,Error **errp) { -QSevGuestInfo *s =QSEV_GUEST_INFO (obj); +SevGuestState *s =SEV_GUEST (obj); s->session_file =g_strdup (value); }static char * -qsev_guest_get_dh_cert_file (Object *obj,Error **errp) +sev_guest_get_dh_cert_file (Object *obj,Error **errp) { -QSevGuestInfo *s =QSEV_GUEST_INFO (obj); +SevGuestState *s =SEV_GUEST (obj);return g_strdup (s->dh_cert_file); }static void -qsev_guest_set_dh_cert_file (Object *obj,const char *value,Error **errp) +sev_guest_set_dh_cert_file (Object *obj,const char *value,Error **errp) { -QSevGuestInfo *s =QSEV_GUEST_INFO (obj); +SevGuestState *s =SEV_GUEST (obj); s->dh_cert_file =g_strdup (value); }static char * -qsev_guest_get_sev_device (Object *obj,Error **errp) +sev_guest_get_sev_device (Object *obj,Error **errp) { -QSevGuestInfo *sev =QSEV_GUEST_INFO (obj); +SevGuestState *sev =SEV_GUEST (obj);return g_strdup (sev->sev_device); }static void -qsev_guest_set_sev_device (Object *obj,const char *value,Error **errp) +sev_guest_set_sev_device (Object *obj,const char *value,Error **errp) { -QSevGuestInfo *sev =QSEV_GUEST_INFO (obj); +SevGuestState *sev =SEV_GUEST (obj); sev->sev_device =g_strdup (value); }static void -qsev_guest_class_init (ObjectClass *oc,void *data) +sev_guest_class_init (ObjectClass *oc,void *data) {object_class_property_add_str (oc,"sev-device" , - qsev_guest_get_sev_device, - qsev_guest_set_sev_device); + sev_guest_get_sev_device, + sev_guest_set_sev_device);object_class_property_set_description (oc,"sev-device" ,"SEV device to use" );object_class_property_add_str (oc,"dh-cert-file" , - qsev_guest_get_dh_cert_file, - qsev_guest_set_dh_cert_file); + sev_guest_get_dh_cert_file, + sev_guest_set_dh_cert_file);object_class_property_set_description (oc,"dh-cert-file" ,"guest owners DH certificate (encoded with base64)" );object_class_property_add_str (oc,"session-file" , - qsev_guest_get_session_file, - qsev_guest_set_session_file); + sev_guest_get_session_file, + sev_guest_set_session_file);object_class_property_set_description (oc,"session-file" ,"guest owners session parameters (encoded with base64)" ); }static void -qsev_guest_init (Object *obj) +sev_guest_instance_init (Object *obj) { -QSevGuestInfo *sev =QSEV_GUEST_INFO (obj); +SevGuestState *sev =SEV_GUEST (obj); sev->sev_device =g_strdup (DEFAULT_SEV_DEVICE ); sev->policy =DEFAULT_GUEST_POLICY ;
@@ -326,32 +327,32 @@ qsev_guest_init(Object *obj) }/* sev guest info */ -static const TypeInfo qsev_guest_info = { +static const TypeInfo sev_guest_info = { .parent =TYPE_OBJECT , - .name =TYPE_QSEV_GUEST_INFO , - .instance_size =sizeof (QSevGuestInfo), - .instance_finalize = qsev_guest_finalize, - .class_init = qsev_guest_class_init, - .instance_init = qsev_guest_init, + .name =TYPE_SEV_GUEST , + .instance_size =sizeof (SevGuestState), + .instance_finalize = sev_guest_finalize, + .class_init = sev_guest_class_init, + .instance_init = sev_guest_instance_init, .interfaces = (InterfaceInfo []) { {TYPE_USER_CREATABLE }, { } } }; -static QSevGuestInfo * +static SevGuestState *lookup_sev_guest_info (const char *id) {Object *obj; -QSevGuestInfo *info; +SevGuestState *info; obj =object_resolve_path_component (object_get_objects_root (), id);if (!obj) {return NULL ; } - info = (QSevGuestInfo *) -object_dynamic_cast (obj,TYPE_QSEV_GUEST_INFO ); + info = (SevGuestState *) +object_dynamic_cast (obj,TYPE_SEV_GUEST );if (!info) {return NULL ; }
@@ -510,7 +511,7 @@ sev_launch_start(SEVState *s)gsize sz;int ret =1 ;int fw_error, rc; -QSevGuestInfo *sev = s->sev_info; +SevGuestState *sev = s->sev_info;struct kvm_sev_launch_start *start;guchar *session =NULL , *dh_cert =NULL ;
@@ -696,7 +697,7 @@ sev_guest_init(const char *id) s->sev_info =lookup_sev_guest_info (id);if (!s->sev_info) {error_report ("%s: '%s' is not a valid '%s' object" , - __func__, id,TYPE_QSEV_GUEST_INFO ); + __func__, id,TYPE_SEV_GUEST ); goto err; }
@@ -786,7 +787,7 @@ sev_encrypt_data(void *handle, uint8_t *ptr, uint64_t len)static void sev_register_types (void ) { -type_register_static (&qsev_guest_info); +type_register_static (&sev_guest_info); }type_init (sev_register_types);
Signature · 1 line
2.26.2
[PULL 105/115] target/i386: sev: Remove redundant cbitpos and reduced_phys_bits fields
In reply to Paolo BonziniFrom: David Gibson <[email protected]>
The SEVState structure has cbitpos and reduced_phys_bits fields which are simply copied from the SevGuestState structure and never changed. Now that SEVState is embedded in SevGuestState we can just access the original copy directly.
Message-Id: <[email protected]>
--- target/i386/sev.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
target/i386/sev.c +7 -12
@@ -41,8 +41,6 @@ struct SEVState {uint8_t build_id;uint32_t policy;uint64_t me_mask; -uint32_t cbitpos; -uint32_t reduced_phys_bits;uint32_t handle;int sev_fd;SevState state;
@@ -378,13 +376,13 @@ sev_get_me_mask(void)uint32_t sev_get_cbit_position (void ) { -return sev_guest ? sev_guest->state.cbitpos :0 ; +return sev_guest ? sev_guest->cbitpos :0 ; }uint32_t sev_get_reduced_phys_bits (void ) { -return sev_guest ? sev_guest->state.reduced_phys_bits :0 ; +return sev_guest ? sev_guest->reduced_phys_bits :0 ; } SevInfo *
@@ -713,22 +711,19 @@ sev_guest_init(const char *id)host_cpuid (0x8000001F ,0 ,NULL , &ebx,NULL ,NULL ); host_cbitpos = ebx &0x3f ; - s->cbitpos =object_property_get_int (OBJECT (sev),"cbitpos" ,NULL ); -if (host_cbitpos != s->cbitpos) { +if (host_cbitpos != sev->cbitpos) {error_report ("%s: cbitpos check failed, host '%d' requested '%d'" , - __func__, host_cbitpos, s->cbitpos); + __func__, host_cbitpos, sev->cbitpos); goto err; } - s->reduced_phys_bits =object_property_get_int (OBJECT (sev), -"reduced-phys-bits" ,NULL ); -if (s->reduced_phys_bits <1 ) { +if (sev->reduced_phys_bits <1 ) {error_report ("%s: reduced_phys_bits check failed, it should be >=1," -" requested '%d'" , __func__, s->reduced_phys_bits); +" requested '%d'" , __func__, sev->reduced_phys_bits); goto err; } - s->me_mask = ~(1UL << s->cbitpos); + s->me_mask = ~(1UL << sev->cbitpos); devname =object_property_get_str (OBJECT (sev),"sev-device" ,NULL ); s->sev_fd =open (devname,O_RDWR );
Signature · 1 line
2.26.2
[PULL 103/115] target/i386: sev: Embed SEVState in SevGuestState
In reply to Paolo BonziniFrom: David Gibson <[email protected]>
Currently SevGuestState contains only configuration information. For runtime state another non-QOM struct SEVState is allocated separately.
Simplify things by instead embedding the SEVState structure in SevGuestState.
Message-Id: <[email protected]>
--- target/i386/sev.c | 54 +++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 25 deletions(-)
target/i386/sev.c +29 -25
@@ -35,6 +35,22 @@typedef struct SevGuestState SevGuestState ; +struct SEVState { +uint8_t api_major; +uint8_t api_minor; +uint8_t build_id; +uint32_t policy; +uint64_t me_mask; +uint32_t cbitpos; +uint32_t reduced_phys_bits; +uint32_t handle; +int sev_fd; +SevState state; +gchar *measurement; +}; + +typedef struct SEVState SEVState ; +/** * SevGuestState: *
@@ -48,6 +64,7 @@ typedef struct SevGuestState SevGuestState;struct SevGuestState {Object parent_obj; +/* configuration parameters */ char *sev_device;uint32_t policy;uint32_t handle;
@@ -55,25 +72,11 @@ struct SevGuestState {char *session_file;uint32_t cbitpos;uint32_t reduced_phys_bits; -}; -struct SEVState { -SevGuestState *sev_info; -uint8_t api_major; -uint8_t api_minor; -uint8_t build_id; -uint32_t policy; -uint64_t me_mask; -uint32_t cbitpos; -uint32_t reduced_phys_bits; -uint32_t handle; -int sev_fd; -SevState state; -gchar *measurement; +/* runtime state */ +SEVState state; }; -typedef struct SEVState SEVState ; -#define DEFAULT_GUEST_POLICY 0x1/* disable debug */ #define DEFAULT_SEV_DEVICE "/dev/sev"
@@ -506,12 +509,12 @@ sev_read_file_base64(const char *filename, guchar **data, gsize *len) }static int -sev_launch_start (SEVState *s) +sev_launch_start (SevGuestState *sev) { +SEVState *s = &sev->state;gsize sz;int ret =1 ;int fw_error, rc; -SevGuestState *sev = s->sev_info;struct kvm_sev_launch_start *start;guchar *session =NULL , *dh_cert =NULL ;
@@ -686,6 +689,7 @@ sev_vm_state_change(void *opaque, int running, RunState state)void *sev_guest_init (const char *id) { +SevGuestState *sev;SEVState *s;char *devname;int ret, fw_error;
@@ -693,27 +697,27 @@ sev_guest_init(const char *id)uint32_t host_cbitpos;struct sev_user_data_status status = {}; - sev_state = s =g_new0 (SEVState,1 ); - s->sev_info =lookup_sev_guest_info (id); -if (!s->sev_info) { + sev =lookup_sev_guest_info (id); +if (!sev) {error_report ("%s: '%s' is not a valid '%s' object" , __func__, id,TYPE_SEV_GUEST ); goto err; } + sev_state = s = &sev->state; s->state =SEV_STATE_UNINIT ;host_cpuid (0x8000001F ,0 ,NULL , &ebx,NULL ,NULL ); host_cbitpos = ebx &0x3f ; - s->cbitpos =object_property_get_int (OBJECT (s->sev_info),"cbitpos" ,NULL ); + s->cbitpos =object_property_get_int (OBJECT (sev),"cbitpos" ,NULL );if (host_cbitpos != s->cbitpos) {error_report ("%s: cbitpos check failed, host '%d' requested '%d'" , __func__, host_cbitpos, s->cbitpos); goto err; } - s->reduced_phys_bits =object_property_get_int (OBJECT (s->sev_info), + s->reduced_phys_bits =object_property_get_int (OBJECT (sev),"reduced-phys-bits" ,NULL );if (s->reduced_phys_bits <1 ) { error_report("%s: reduced_phys_bits check failed, it should be >=1,"
@@ -723,7 +727,7 @@ sev_guest_init(const char *id) s->me_mask = ~(1UL << s->cbitpos); - devname =object_property_get_str (OBJECT (s->sev_info),"sev-device" ,NULL ); + devname =object_property_get_str (OBJECT (sev),"sev-device" ,NULL ); s->sev_fd =open (devname,O_RDWR );if (s->sev_fd <0 ) { error_report("%s: Failed to open %s '%s'", __func__,
@@ -754,7 +758,7 @@ sev_guest_init(const char *id) goto err; } - ret =sev_launch_start (s); + ret =sev_launch_start (sev);if (ret) {error_report ("%s: failed to create encryption context" , __func__); goto err;
Signature · 1 line
2.26.2
[PULL 108/115] target/i386: sev: Unify SEVState and SevGuestState
In reply to Paolo BonziniFrom: David Gibson <[email protected]>
SEVState is contained with SevGuestState. We've now fixed redundancies and name conflicts, so there's no real point to the nested structure. Just move all the fields of SEVState into SevGuestState.
This eliminates the SEVState structure, which as a bonus removes the confusion with the SevState enum.
Message-Id: <[email protected]>
--- target/i386/sev.c | 79 ++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 45 deletions(-)
target/i386/sev.c +34 -45
@@ -35,18 +35,6 @@typedef struct SevGuestState SevGuestState ; -struct SEVState { -uint8_t api_major; -uint8_t api_minor; -uint8_t build_id; -uint64_t me_mask; -int sev_fd; -SevState state; -gchar *measurement; -}; - -typedef struct SEVState SEVState ; -/** * SevGuestState: *
@@ -70,7 +58,13 @@ struct SevGuestState {/* runtime state */ uint32_t handle; -SEVState state; +uint8_t api_major; +uint8_t api_minor; +uint8_t build_id; +uint64_t me_mask; +int sev_fd; +SevState state; +gchar *measurement; };#define DEFAULT_GUEST_POLICY 0x1/* disable debug */
@@ -158,7 +152,7 @@ static bool sev_check_state(const SevGuestState *sev, SevState state) {assert (sev); -return sev->state.state == state ? true : false; +return sev->state == state ? true : false; } static void
@@ -167,9 +161,9 @@ sev_set_guest_state(SevGuestState *sev, SevState new_state)assert (new_state <SEV_STATE__MAX );assert (sev); -trace_kvm_sev_change_state (SevState_str (sev->state.state), +trace_kvm_sev_change_state (SevState_str (sev->state),SevState_str (new_state)); - sev->state.state = new_state; + sev->state = new_state; } static void
@@ -368,7 +362,7 @@ sev_enabled(void)uint64_t sev_get_me_mask (void ) { -return sev_guest ? sev_guest->state.me_mask : ~0 ; +return sev_guest ? sev_guest->me_mask : ~0 ; }uint32_t
@@ -392,11 +386,11 @@ sev_get_info(void) info->enabled =sev_enabled ();if (info->enabled) { - info->api_major = sev_guest->state.api_major; - info->api_minor = sev_guest->state.api_minor; - info->build_id = sev_guest->state.build_id; + info->api_major = sev_guest->api_major; + info->api_minor = sev_guest->api_minor; + info->build_id = sev_guest->build_id; info->policy = sev_guest->policy; - info->state = sev_guest->state.state; + info->state = sev_guest->state; info->handle = sev_guest->handle; }
@@ -507,7 +501,6 @@ sev_read_file_base64(const char *filename, guchar **data, gsize *len)static int sev_launch_start (SevGuestState *sev) { -SEVState *s = &sev->state;gsize sz;int ret =1 ;int fw_error, rc;
@@ -535,7 +528,7 @@ sev_launch_start(SevGuestState *sev) }trace_kvm_sev_launch_start (start->policy, session, dh_cert); - rc =sev_ioctl (s->sev_fd,KVM_SEV_LAUNCH_START , start, &fw_error); + rc =sev_ioctl (sev->sev_fd,KVM_SEV_LAUNCH_START , start, &fw_error);if (rc <0 ) {error_report ("%s: LAUNCH_START ret=%d fw_error=%d '%s'" , __func__, ret, fw_error,fw_error_to_str (fw_error));
@@ -566,7 +559,7 @@ sev_launch_update_data(SevGuestState *sev, uint8_t *addr, uint64_t len) update.uaddr = (__u64 )(unsigned long )addr; update.len = len;trace_kvm_sev_launch_update_data (addr, len); - ret =sev_ioctl (sev->state.sev_fd,KVM_SEV_LAUNCH_UPDATE_DATA , + ret =sev_ioctl (sev->sev_fd,KVM_SEV_LAUNCH_UPDATE_DATA , &update, &fw_error);if (ret) { error_report("%s: LAUNCH_UPDATE ret=%d fw_error=%d '%s'",
@@ -582,7 +575,6 @@ sev_launch_get_measure(Notifier *notifier, void *unused)SevGuestState *sev = sev_guest;int ret, error;guchar *data; -SEVState *s = &sev->state;struct kvm_sev_launch_measure *measurement;if (!sev_check_state (sev,SEV_STATE_LAUNCH_UPDATE )) {
@@ -592,7 +584,7 @@ sev_launch_get_measure(Notifier *notifier, void *unused) measurement = g_new0(struct kvm_sev_launch_measure, 1);/* query the measurement blob length */ - ret =sev_ioctl (sev->state.sev_fd,KVM_SEV_LAUNCH_MEASURE , + ret =sev_ioctl (sev->sev_fd,KVM_SEV_LAUNCH_MEASURE , measurement, &error);if (!measurement->len) { error_report("%s: LAUNCH_MEASURE ret=%d fw_error=%d '%s'",
@@ -604,7 +596,7 @@ sev_launch_get_measure(Notifier *notifier, void *unused) measurement->uaddr = (unsigned long )data;/* get the measurement blob */ - ret =sev_ioctl (sev->state.sev_fd,KVM_SEV_LAUNCH_MEASURE , + ret =sev_ioctl (sev->sev_fd,KVM_SEV_LAUNCH_MEASURE , measurement, &error);if (ret) { error_report("%s: LAUNCH_MEASURE ret=%d fw_error=%d '%s'",
@@ -615,8 +607,8 @@ sev_launch_get_measure(Notifier *notifier, void *unused)sev_set_guest_state (sev,SEV_STATE_LAUNCH_SECRET );/* encode the measurement value and emit the event */ - s->measurement =g_base64_encode (data, measurement->len); -trace_kvm_sev_launch_measurement (s->measurement); + sev->measurement =g_base64_encode (data, measurement->len); +trace_kvm_sev_launch_measurement (sev->measurement); free_data:g_free (data);
@@ -628,8 +620,8 @@ char *sev_get_launch_measurement (void) {if (sev_guest && - sev_guest->state.state >=SEV_STATE_LAUNCH_SECRET ) { -return g_strdup (sev_guest->state.measurement); + sev_guest->state >=SEV_STATE_LAUNCH_SECRET ) { +return g_strdup (sev_guest->measurement); }return NULL ;
@@ -642,12 +634,11 @@ static Notifier sev_machine_done_notify = {static void sev_launch_finish (SevGuestState *sev) { -SEVState *s = &sev->state;int ret, error;Error *local_err =NULL ;trace_kvm_sev_launch_finish (); - ret =sev_ioctl (s->sev_fd,KVM_SEV_LAUNCH_FINISH ,0 , &error); + ret =sev_ioctl (sev->sev_fd,KVM_SEV_LAUNCH_FINISH ,0 , &error);if (ret) {error_report ("%s: LAUNCH_FINISH ret=%d fw_error=%d '%s'" , __func__, ret, error,fw_error_to_str (error));
@@ -683,7 +674,6 @@ void * sev_guest_init(const char *id) {SevGuestState *sev; -SEVState *s;char *devname;int ret, fw_error;uint32_t ebx;
@@ -698,8 +688,7 @@ sev_guest_init(const char *id) } sev_guest = sev; - s = &sev->state; - s->state =SEV_STATE_UNINIT ; + sev->state =SEV_STATE_UNINIT ;host_cpuid (0x8000001F ,0 ,NULL , &ebx,NULL ,NULL ); host_cbitpos = ebx &0x3f ;
@@ -716,20 +705,20 @@ sev_guest_init(const char *id) goto err; } - s->me_mask = ~(1UL << sev->cbitpos); + sev->me_mask = ~(1UL << sev->cbitpos); devname =object_property_get_str (OBJECT (sev),"sev-device" ,NULL ); - s->sev_fd =open (devname,O_RDWR ); -if (s->sev_fd <0 ) { + sev->sev_fd =open (devname,O_RDWR ); +if (sev->sev_fd <0 ) {error_report ("%s: Failed to open %s '%s'" , __func__, devname,strerror (errno)); }g_free (devname); -if (s->sev_fd <0 ) { +if (sev->sev_fd <0 ) { goto err; } - ret =sev_platform_ioctl (s->sev_fd,SEV_PLATFORM_STATUS , &status, + ret =sev_platform_ioctl (sev->sev_fd,SEV_PLATFORM_STATUS , &status, &fw_error);if (ret) { error_report("%s: failed to get platform status ret=%d "
@@ -737,12 +726,12 @@ sev_guest_init(const char *id) fw_error_to_str(fw_error)); goto err; } - s->build_id = status.build; - s->api_major = status.api_major; - s->api_minor = status.api_minor; + sev->build_id = status.build; + sev->api_major = status.api_major; + sev->api_minor = status.api_minor;trace_kvm_sev_init (); - ret =sev_ioctl (s->sev_fd,KVM_SEV_INIT ,NULL , &fw_error); + ret =sev_ioctl (sev->sev_fd,KVM_SEV_INIT ,NULL , &fw_error);if (ret) {error_report ("%s: failed to initialize ret=%d fw_error=%d '%s'" , __func__, ret, fw_error,fw_error_to_str (fw_error));
Signature · 1 line
2.26.2
[PULL 109/115] checkpatch: reversed logic with acpi test checks
In reply to Paolo BonziniFrom: "Michael S. Tsirkin" <[email protected]>
Logic reversed: allowed list should just be ignored. Instead we only take that into account :(
Message-Id: <[email protected]>
--- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +1 -1
@@ -1267,7 +1267,7 @@ sub checkfilename { # files and when changing tests. if ($name =~ m#^tests/data/acpi/# and not $name =~ m#^\.sh$#) { $$acpi_testexpected = $name; - } elsif ($name =~ m#^tests/qtest/bios-tables-test-allowed-diff.h$#) { + } elsif ($name !~ m#^tests/qtest/bios-tables-test-allowed-diff.h$#) { $$acpi_nontestexpected = $name; } if (defined $$acpi_testexpected and defined $$acpi_nontestexpected) {
Signature · 1 line
2.26.2
[PULL 113/115] replay: fix replay shutdown for console mode
In reply to Paolo BonziniFrom: Pavel Dovgalyuk <[email protected]>
When QEMU is used without any graphical window, QEMU execution is terminated with the signal (e.g., Ctrl-C). Signal processing in QEMU does not include qemu_system_shutdown_request call. That is why shutdown event is not recorded by record/replay in this case. This patch adds shutdown event to the end of the record log. Now every replay will shutdown the machine at the end.
Message-Id: <159012995470.27967.18129611453659045726.stgit@pasha-ThinkPad-X280>
--- replay/replay.c | 5 +++++ 1 file changed, 5 insertions(+)
replay/replay.c +5 -0
@@ -366,6 +366,11 @@ void replay_finish(void)/* finalize the file */ if (replay_file) {if (replay_mode ==REPLAY_MODE_RECORD ) { +/* +* Can't do it in the signal handler, therefore +* add shutdown event here for the case of Ctrl-C. +*/ +replay_shutdown_request (SHUTDOWN_CAUSE_HOST_SIGNAL );/* write end event */ replay_put_event (EVENT_END );
Signature · 1 line
2.26.2
[PULL 106/115] target/i386: sev: Remove redundant policy field
In reply to Paolo BonziniFrom: David Gibson <[email protected]>
SEVState::policy is set from the final value of the policy field in the parameter structure for the KVM_SEV_LAUNCH_START ioctl(). But, AFAICT that ioctl() won't ever change it from the original supplied value which comes from SevGuestState::policy.
So, remove this field and just use SevGuestState::policy directly.
Message-Id: <[email protected]>
--- target/i386/sev.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
target/i386/sev.c +2 -5
@@ -39,7 +39,6 @@ struct SEVState {uint8_t api_major;uint8_t api_minor;uint8_t build_id; -uint32_t policy;uint64_t me_mask;uint32_t handle;int sev_fd;
@@ -397,7 +396,7 @@ sev_get_info(void) info->api_major = sev_guest->state.api_major; info->api_minor = sev_guest->state.api_minor; info->build_id = sev_guest->state.build_id; - info->policy = sev_guest->state.policy; + info->policy = sev_guest->policy; info->state = sev_guest->state.state; info->handle = sev_guest->state.handle; }
@@ -520,8 +519,7 @@ sev_launch_start(SevGuestState *sev) start->handle =object_property_get_int (OBJECT (sev),"handle" , &error_abort); - start->policy =object_property_get_int (OBJECT (sev),"policy" , - &error_abort); + start->policy = sev->policy;if (sev->session_file) {if (sev_read_file_base64 (sev->session_file, &session, &sz) <0 ) { goto out;
@@ -550,7 +548,6 @@ sev_launch_start(SevGuestState *sev) &error_abort);sev_set_guest_state (sev,SEV_STATE_LAUNCH_UPDATE ); s->handle = start->handle; - s->policy = start->policy; ret =0 ; out:
Signature · 1 line
2.26.2
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Message-id: [email protected]
Subject: [PULL 000/115] Huge miscellaneous pull request for 2020-06-11
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
b258374 target/i386: Remove obsolete TODO file
ed8ffec stubs: move Xen stubs to accel/
9da3214 replay: fix replay shutdown for console mode
8cf1910 exec/cpu-common: Move MUSB specific typedefs to 'hw/usb/hcd-musb.h' b4bf922 hw/usb: Move device-specific declarations to new 'hcd-musb.h' header 5988475 exec/memory: Remove unused MemoryRegionMmio type
79d4c74 checkpatch: reversed logic with acpi test checks
11943a6 target/i386: sev: Unify SEVState and SevGuestState
722d1df target/i386: sev: Remove redundant handle field
ef7e4eb target/i386: sev: Remove redundant policy field
c0fa653 target/i386: sev: Remove redundant cbitpos and reduced_phys_bits fields 832d459 target/i386: sev: Partial cleanup to sev_state global
560d42b target/i386: sev: Embed SEVState in SevGuestState
56fe4d8 target/i386: sev: Rename QSevGuestInfo
4902392 target/i386: sev: Move local structure definitions into .c file b8dc835 target/i386: sev: Remove unused QSevGuestInfoClass
5ec6d66 xen: fix build without pci passthrough
93262a0 i386: hvf: Drop HVFX86EmulatorState
b52a4bf i386: hvf: Move mmio_buf into CPUX86State
20208b4 i386: hvf: Move lazy_flags into CPUX86State
df05641 i386: hvf: Drop regs in HVFX86EmulatorState
e978983 i386: hvf: Drop copy of RFLAGS defines
0141723 i386: hvf: Drop rflags from HVFX86EmulatorState
e1de961 i386: hvf: Drop fetch_rip from HVFX86EmulatorState
ed88ce7 i386: hvf: Use IP from CPUX86State
ddb005d i386: hvf: Use ins_len to advance IP
c4d282b i386: hvf: Drop unused variable
b587a1b i386: hvf: Drop useless declarations in sysemu
7e1a493 i386: hvf: Move HVFState definition into hvf
709b437 target/ppc: Restrict PPCVirtualHypervisorClass to system-mode 238000a sysemu/hvf: Only declare hvf_allowed when HVF is available 3b8e276 sysemu/tcg: Only declare tcg_allowed when TCG is available acb8d15 sysemu/accel: Restrict machine methods to system-mode
f9bd95e target/i386: correct fix for pcmpxstrx substring search
136df11 target/i386: fix IEEE x87 floating-point exception raising f843bd2 exec: set map length to zero when returning NULL
3bd81db configure: Do not ignore malloc value
98e8ed2 qemu/thread: Mark qemu_thread_exit() with 'noreturn' attribute 3f5bb0f memory: Make 'info mtree' not display disabled regions by default a3aaf5e util/oslib: Returns the real thread identifier on FreeBSD and NetBSD 6aa0a68 target/i386: define a new MSR based feature word - FEAT_PERF_CAPABILITIES f21430a i386: Remove unused define's from hax and hvf
c130d2b replay: implement fair mutex
06644d9 hw/i386/amd_iommu: Fix the reserved bits definition of IOMMU commands 0abe63e tests: machine-none-test: Enable MicroBlaze testing
85f319e chardev/char-socket: Properly make qio connections non blocking d0110c6 KVM: Kick resamplefd for split kernel irqchip
1ead965 KVM: Pass EventNotifier into kvm_irqchip_assign_irqfd
2b7dab6 vfio/pci: Use kvm_irqchip_add_irqfd_notifier_gsi() for irqfds dd32581 x86/cpu: Enable AVX512_VP2INTERSECT cpu feature
7ee3b5d hw/i386/vmport: Allow QTest use without crashing
c79f240 target/i386: fix fisttpl, fisttpll handling of out-of-range values 7e360a8 target/i386: fix fbstp handling of out-of-range values
9f11ae8 target/i386: fix fbstp handling of negative zero
59ce66a target/i386: fix fxam handling of invalid encodings
68d8ffc target/i386: fix floating-point load-constant rounding
8d4006e hw/elf_ops: Do not ignore write failures when loading ELF
3a3c475 disas: Let disas::read_memory() handler return EIO on error 6bfda5f exec: Propagate cpu_memory_rw_debug() error
63d6911 exec: Let address_space_read/write_cached() propagate MemTxResult 85733ec target/i386: fix fscale handling of rounding precision
22d5344 target/i386: fix fscale handling of infinite exponents
d9e4f5b target/i386: fix fscale handling of invalid exponent encodings 23a2034 target/i386: fix fscale handling of signaling NaN
e197304 target/i386: implement special cases for fxtract
3aed295 megasas: use unsigned type for positive numeric fields
ca61e75 megasas: avoid NULL pointer dereference
dc1d959 megasas: use unsigned type for reply_queue_head and check index 7af8d9c i386/kvm: fix a use-after-free when vcpu plug/unplug
e79558f hax: Dynamic allocate vcpu state structure
04d77de cpus: Fix botched configure_icount() error API violation fix 538a83f qom/container: remove .instance_size initializer from container_info c49bd3d qom/object: pass (Object *) to object_initialize_with_type() 3e9db3f qom/object: simplify type_initialize_interface()
f76ef9d qom/object: factor out the initialization of hash table of properties 28278b9 qom: remove index from object_resolve_abs_path()
db672e1 accel: Move Xen accelerator code under accel/xen/
a46ccc2 hw/i386/vmport: Assert vmport initialized before registering commands fc3c919 hw/i386/vmport: Add support for CMD_GETHZ
806f934 i386/cpu: Store LAPIC bus frequency in CPU structure
7798d77 hw/i386/vmport: Allow x2apic without IR
f87ad26 hw/i386/vmport: Add support for CMD_GET_VCPU_INFO
bbd5878 hw/i386/vmport: Add support for CMD_GETBIOSUUID
bb5bcad hw/i386/vmport: Define enum for all commands
2253a04 hw/i386/vmport: Introduce vmport.h
e88c358 hw/i386/vmport: Report vmware-vmx-type in CMD_GETVERSION
797442e hw/i386/vmport: Introduce vmware-vmx-version property
48cd9ce hw/i386/vmport: Set EAX to -1 on failed and unsupported commands 562b30f hw/i386/vmport: Propagate IOPort read to vCPU EAX register 1232e46 hw/i386/vmport: Add device properties
d7df941 hw/i386/vmport: Add reference to VMware open-vm-tools
45adc60 target/i386: fix phadd* with identical destination and source register 5350585 target/i386: Fix the CPUID leaf CPUID_Fn80000008
3fbb68b vmbus: add infrastructure to save/load vmbus requests
df61787 i386: Hyper-V VMBus ACPI DSDT entry
a018f5e i386:pc: whitelist dynamic vmbus-bridge
9ebd496 vmbus: vmbus implementation
a547e98 vmbus: add vmbus protocol definitions
a7a963e hyperv: expose API to determine if synic is enabled
1dbe145 Makefile: Let the 'help' target list the helper targets
e144bcf io/task: Move 'qom/object.h' header to source
359ba29 qom/object: Move Object typedef to 'qemu/typedefs.h'
9533078 target/i386: Fix OUTL debug output
c0b28e6 qom/object: Fix object_child_foreach_recursive() return value 386d522 icount: fix shift=auto for record/replay
a0f1875 numa: prevent usage of -M memory-backend and -numa memdev at the same time 561b3f3 vl.c: run preconfig loop before creating default RAM backend 0eeaed9 run-coverity-scan: support --update-tools-only --docker
c96d7fe run-coverity-scan: download tools outside the container
3e647fb run-coverity-scan: use --no-update-tools in docker run
8d61426 run-coverity-scan: add --no-update-tools option
d4fa635 run-coverity-scan: use docker.py
9e4f18d run-coverity-scan: get Coverity token and email from special git config section 4a5b4f8 docker.py/build: support binary files in --extra-files
ed203cb docker.py/build: support -t and -f arguments
=== OUTPUT BEGIN ===
1/115 Checking commit ed203cb565bc (docker.py/build: support -t and -f arguments)
2/115 Checking commit 4a5b4f82cf06 (docker.py/build: support binary files in --extra-files)
3/115 Checking commit 9e4f18d15693 (run-coverity-scan: get Coverity token and email from special git config section) 4/115 Checking commit d4fa6352af61 (run-coverity-scan: use docker.py)
5/115 Checking commit 8d61426da8be (run-coverity-scan: add --no-update-tools option)
6/115 Checking commit 3e647fb8c66b (run-coverity-scan: use --no-update-tools in docker run)
7/115 Checking commit c96d7fea1d40 (run-coverity-scan: download tools outside the container) 8/115 Checking commit 0eeaed9046f6 (run-coverity-scan: support --update-tools-only --docker) 9/115 Checking commit 561b3f3dbb49 (vl.c: run preconfig loop before creating default RAM backend) 10/115 Checking commit a0f187582a43 (numa: prevent usage of -M memory-backend and -numa memdev at the same time) 11/115 Checking commit 386d52235555 (icount: fix shift=auto for record/replay)
12/115 Checking commit c0b28e67ae8f (qom/object: Fix object_child_foreach_recursive() return value) 13/115 Checking commit 953307832f9e (target/i386: Fix OUTL debug output)
14/115 Checking commit 359ba29d91a1 (qom/object: Move Object typedef to 'qemu/typedefs.h')
15/115 Checking commit e144bcf27354 (io/task: Move 'qom/object.h' header to source)
16/115 Checking commit 1dbe1451b554 (Makefile: Let the 'help' target list the helper targets) 17/115 Checking commit a7a963e82034 (hyperv: expose API to determine if synic is enabled)
18/115 Checking commit a547e987c3ee (vmbus: add vmbus protocol definitions)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#20:
new file mode 100644
total: 0 errors, 1 warnings, 222 lines checked
Patch 18/115 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
19/115 Checking commit 9ebd496e40c2 (vmbus: vmbus implementation)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #74:
new file mode 100644
total: 0 errors, 1 warnings, 2967 lines checked
Patch 19/115 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
20/115 Checking commit a018f5e83e64 (i386:pc: whitelist dynamic vmbus-bridge)
21/115 Checking commit df6178722e55 (i386: Hyper-V VMBus ACPI DSDT entry)
22/115 Checking commit 3fbb68b67d01 (vmbus: add infrastructure to save/load vmbus requests) 23/115 Checking commit 535058507f56 (target/i386: Fix the CPUID leaf CPUID_Fn80000008) 24/115 Checking commit 45adc6000beb (target/i386: fix phadd* with identical destination and source register) 25/115 Checking commit d7df941d2c4b (hw/i386/vmport: Add reference to VMware open-vm-tools) 26/115 Checking commit 1232e46cf2cd (hw/i386/vmport: Add device properties)
27/115 Checking commit 562b30f77b70 (hw/i386/vmport: Propagate IOPort read to vCPU EAX register) 28/115 Checking commit 48cd9ce82c8e (hw/i386/vmport: Set EAX to -1 on failed and unsupported commands) 29/115 Checking commit 797442eea681 (hw/i386/vmport: Introduce vmware-vmx-version property) 30/115 Checking commit e88c3580bd95 (hw/i386/vmport: Report vmware-vmx-type in CMD_GETVERSION) 31/115 Checking commit 2253a0464ff4 (hw/i386/vmport: Introduce vmport.h)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#69:
deleted file mode 100644
total: 0 errors, 1 warnings, 52 lines checked
Patch 31/115 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
32/115 Checking commit bb5bcadd8302 (hw/i386/vmport: Define enum for all commands)
33/115 Checking commit bbd587829c2c (hw/i386/vmport: Add support for CMD_GETBIOSUUID) 34/115 Checking commit f87ad2639f79 (hw/i386/vmport: Add support for CMD_GET_VCPU_INFO) 35/115 Checking commit 7798d770a7ad (hw/i386/vmport: Allow x2apic without IR)
36/115 Checking commit 806f934798ef (i386/cpu: Store LAPIC bus frequency in CPU structure) 37/115 Checking commit fc3c919c32df (hw/i386/vmport: Add support for CMD_GETHZ)
38/115 Checking commit a46ccc2d17e3 (hw/i386/vmport: Assert vmport initialized before registering commands) 39/115 Checking commit db672e10246c (accel: Move Xen accelerator code under accel/xen/)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#48:
new file mode 100644
total: 0 errors, 1 warnings, 241 lines checked
Patch 39/115 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
40/115 Checking commit 28278b9fb847 (qom: remove index from object_resolve_abs_path()) 41/115 Checking commit f76ef9d0f6dd (qom/object: factor out the initialization of hash table of properties) 42/115 Checking commit 3e9db3fc4df1 (qom/object: simplify type_initialize_interface()) 43/115 Checking commit c49bd3d36a29 (qom/object: pass (Object *) to object_initialize_with_type())
WARNING: line over 80 characters
#24: FILE: qom/object.c:497:
+static void object_initialize_with_type(Object *obj, size_t size, TypeImpl *type)
total: 0 errors, 1 warnings, 11 lines checked
Patch 43/115 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
44/115 Checking commit 538a83f883df (qom/container: remove .instance_size initializer from container_info) 45/115 Checking commit 04d77deecb37 (cpus: Fix botched configure_icount() error API violation fix) 46/115 Checking commit e79558f9f424 (hax: Dynamic allocate vcpu state structure)
WARNING: line over 80 characters
#51: FILE: target/i386/hax-all.c:249:
+ fprintf(stderr, "Maximum VCPU number QEMU supported is %d\n", HAX_MAX_VCPU);
total: 0 errors, 1 warnings, 91 lines checked
Patch 46/115 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
47/115 Checking commit 7af8d9ce700a (i386/kvm: fix a use-after-free when vcpu plug/unplug) 48/115 Checking commit dc1d959c2a13 (megasas: use unsigned type for reply_queue_head and check index) 49/115 Checking commit ca61e75559d9 (megasas: avoid NULL pointer dereference)
50/115 Checking commit 3aed295ae3fd (megasas: use unsigned type for positive numeric fields) 51/115 Checking commit e1973044bdf8 (target/i386: implement special cases for fxtract)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#58:
new file mode 100644
ERROR: Use of volatile is usually wrong, please add a comment #73: FILE: tests/tcg/i386/test-i386-fxtract.c:11:
+volatile union u ld_pseudo_m16382 = { .s = { UINT64_C(1) << 63, 0 } };
ERROR: Use of volatile is usually wrong, please add a comment #74: FILE: tests/tcg/i386/test-i386-fxtract.c:12:
+volatile union u ld_invalid_1 = { .s = { 1, 1234 } };
ERROR: Use of volatile is usually wrong, please add a comment #75: FILE: tests/tcg/i386/test-i386-fxtract.c:13:
+volatile union u ld_invalid_2 = { .s = { 0, 1234 } };
ERROR: Use of volatile is usually wrong, please add a comment #76: FILE: tests/tcg/i386/test-i386-fxtract.c:14:
+volatile union u ld_invalid_3 = { .s = { 0, 0x7fff } };
ERROR: Use of volatile is usually wrong, please add a comment #77: FILE: tests/tcg/i386/test-i386-fxtract.c:15:
+volatile union u ld_invalid_4 = { .s = { (UINT64_C(1) << 63) - 1, 0x7fff } };
ERROR: Use of volatile is usually wrong, please add a comment #79: FILE: tests/tcg/i386/test-i386-fxtract.c:17:
+volatile long double ld_sig, ld_exp;
ERROR: spaces required around that '-' (ctx:VxV) #142: FILE: tests/tcg/i386/test-i386-fxtract.c:80:
+ "0" (0x1p-16445L));
^total: 7 errors, 1 warnings, 154 lines checked
Patch 51/115 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
52/115 Checking commit 23a20346b53f (target/i386: fix fscale handling of signaling NaN)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #32:
new file mode 100644
ERROR: Use of volatile is usually wrong, please add a comment #47: FILE: tests/tcg/i386/test-i386-fscale.c:11:
+volatile long double ld_res;
total: 1 errors, 1 warnings, 47 lines checked
Patch 52/115 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
53/115 Checking commit d9e4f5b12c80 (target/i386: fix fscale handling of invalid exponent encodings)
ERROR: Use of volatile is usually wrong, please add a comment
#42: FILE: tests/tcg/i386/test-i386-fscale.c:11:
+volatile union u ld_invalid_1 = { .s = { 1, 1234 } };
ERROR: Use of volatile is usually wrong, please add a comment #43: FILE: tests/tcg/i386/test-i386-fscale.c:12:
+volatile union u ld_invalid_2 = { .s = { 0, 1234 } };
ERROR: Use of volatile is usually wrong, please add a comment #44: FILE: tests/tcg/i386/test-i386-fscale.c:13:
+volatile union u ld_invalid_3 = { .s = { 0, 0x7fff } };
ERROR: Use of volatile is usually wrong, please add a comment #45: FILE: tests/tcg/i386/test-i386-fscale.c:14:
+volatile union u ld_invalid_4 = { .s = { (UINT64_C(1) << 63) - 1, 0x7fff } };
total: 4 errors, 0 warnings, 51 lines checked
Patch 53/115 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
54/115 Checking commit 22d5344df5fa (target/i386: fix fscale handling of infinite exponents) 55/115 Checking commit 85733ec01504 (target/i386: fix fscale handling of rounding precision)
ERROR: Use of volatile is usually wrong, please add a comment
#43: FILE: tests/tcg/i386/test-i386-fscale.c:11:
+volatile long double ld_third = 1.0L / 3.0L;
ERROR: Use of volatile is usually wrong, please add a comment #44: FILE: tests/tcg/i386/test-i386-fscale.c:12:
+volatile long double ld_four_thirds = 4.0L / 3.0L;
total: 2 errors, 0 warnings, 34 lines checked
Patch 55/115 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
56/115 Checking commit 63d6911369e9 (exec: Let address_space_read/write_cached() propagate MemTxResult) 57/115 Checking commit 6bfda5fdb0a5 (exec: Propagate cpu_memory_rw_debug() error) 58/115 Checking commit 3a3c475947e2 (disas: Let disas::read_memory() handler return EIO on error) 59/115 Checking commit 8d4006e2c26f (hw/elf_ops: Do not ignore write failures when loading ELF) 60/115 Checking commit 68d8ffcd5bdb (target/i386: fix floating-point load-constant rounding)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#110:
new file mode 100644
ERROR: Use of volatile is usually wrong, please add a comment #120: FILE: tests/tcg/i386/test-i386-fldcst.c:6:
+volatile long double ld_res;
ERROR: spaces required around that '+' (ctx:VxV)
#132: FILE: tests/tcg/i386/test-i386-fldcst.c:18:
+ if (ld_res != 0x3.5269e12f346e2bf8p+0L) {
^ERROR: spaces required around that '+' (ctx:VxV)
#141: FILE: tests/tcg/i386/test-i386-fldcst.c:27:
+ if (ld_res != 0x3.5269e12f346e2bf8p+0L) {
^ERROR: spaces required around that '+' (ctx:VxV)
#150: FILE: tests/tcg/i386/test-i386-fldcst.c:36:
+ if (ld_res != 0x3.5269e12f346e2bf8p+0L) {
^ERROR: spaces required around that '+' (ctx:VxV)
#159: FILE: tests/tcg/i386/test-i386-fldcst.c:45:
+ if (ld_res != 0x3.5269e12f346e2bfcp+0L) {
^ERROR: spaces required around that '+' (ctx:VxV)
#169: FILE: tests/tcg/i386/test-i386-fldcst.c:55:
+ if (ld_res != 0x1.71547652b82fe178p+0L) {
^ERROR: spaces required around that '+' (ctx:VxV)
#178: FILE: tests/tcg/i386/test-i386-fldcst.c:64:
+ if (ld_res != 0x1.71547652b82fe176p+0L) {
^ERROR: spaces required around that '+' (ctx:VxV)
#187: FILE: tests/tcg/i386/test-i386-fldcst.c:73:
+ if (ld_res != 0x1.71547652b82fe176p+0L) {
^ERROR: spaces required around that '+' (ctx:VxV)
#196: FILE: tests/tcg/i386/test-i386-fldcst.c:82:
+ if (ld_res != 0x1.71547652b82fe178p+0L) {
^ERROR: spaces required around that '+' (ctx:VxV)
#206: FILE: tests/tcg/i386/test-i386-fldcst.c:92:
+ if (ld_res != 0x3.243f6a8885a308d4p+0L) {
^ERROR: spaces required around that '+' (ctx:VxV) #215: FILE: tests/tcg/i386/test-i386-fldcst.c:101:
+ if (ld_res != 0x3.243f6a8885a308dp+0L) {
^ERROR: spaces required around that '+' (ctx:VxV) #224: FILE: tests/tcg/i386/test-i386-fldcst.c:110:
+ if (ld_res != 0x3.243f6a8885a308dp+0L) {
^ERROR: spaces required around that '+' (ctx:VxV) #233: FILE: tests/tcg/i386/test-i386-fldcst.c:119:
+ if (ld_res != 0x3.243f6a8885a308d4p+0L) {
^ERROR: spaces required around that '-' (ctx:VxV) #243: FILE: tests/tcg/i386/test-i386-fldcst.c:129:
+ if (ld_res != 0x4.d104d427de7fbcc8p-4L) {
^ERROR: spaces required around that '-' (ctx:VxV) #252: FILE: tests/tcg/i386/test-i386-fldcst.c:138:
+ if (ld_res != 0x4.d104d427de7fbccp-4L) {
^ERROR: spaces required around that '-' (ctx:VxV) #261: FILE: tests/tcg/i386/test-i386-fldcst.c:147:
+ if (ld_res != 0x4.d104d427de7fbccp-4L) {
^ERROR: spaces required around that '-' (ctx:VxV) #270: FILE: tests/tcg/i386/test-i386-fldcst.c:156:
+ if (ld_res != 0x4.d104d427de7fbcc8p-4L) {
^ERROR: spaces required around that '-' (ctx:VxV) #280: FILE: tests/tcg/i386/test-i386-fldcst.c:166:
+ if (ld_res != 0xb.17217f7d1cf79acp-4L) {
^ERROR: spaces required around that '-' (ctx:VxV) #289: FILE: tests/tcg/i386/test-i386-fldcst.c:175:
+ if (ld_res != 0xb.17217f7d1cf79abp-4L) {
^ERROR: spaces required around that '-' (ctx:VxV) #298: FILE: tests/tcg/i386/test-i386-fldcst.c:184:
+ if (ld_res != 0xb.17217f7d1cf79abp-4L) {
^ERROR: spaces required around that '-' (ctx:VxV) #307: FILE: tests/tcg/i386/test-i386-fldcst.c:193:
+ if (ld_res != 0xb.17217f7d1cf79acp-4L) {
^total: 21 errors, 1 warnings, 283 lines checked
Patch 60/115 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
61/115 Checking commit 59ce66a8ea73 (target/i386: fix fxam handling of invalid encodings)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #41:
new file mode 100644
ERROR: Use of volatile is usually wrong, please add a comment #56: FILE: tests/tcg/i386/test-i386-fxam.c:11:
+volatile union u ld_pseudo_m16382 = { .s = { UINT64_C(1) << 63, 0 } };
ERROR: Use of volatile is usually wrong, please add a comment #57: FILE: tests/tcg/i386/test-i386-fxam.c:12:
+volatile union u ld_pseudo_nm16382 = { .s = { UINT64_C(1) << 63, 0x8000 } };
ERROR: Use of volatile is usually wrong, please add a comment #58: FILE: tests/tcg/i386/test-i386-fxam.c:13:
+volatile union u ld_invalid_1 = { .s = { 1, 1234 } };
ERROR: Use of volatile is usually wrong, please add a comment #59: FILE: tests/tcg/i386/test-i386-fxam.c:14:
+volatile union u ld_invalid_2 = { .s = { 0, 1234 } };
ERROR: Use of volatile is usually wrong, please add a comment #60: FILE: tests/tcg/i386/test-i386-fxam.c:15:
+volatile union u ld_invalid_3 = { .s = { 0, 0x7fff } };
ERROR: Use of volatile is usually wrong, please add a comment #61: FILE: tests/tcg/i386/test-i386-fxam.c:16:
+volatile union u ld_invalid_4 = { .s = { (UINT64_C(1) << 63) - 1, 0x7fff } };
ERROR: Use of volatile is usually wrong, please add a comment #62: FILE: tests/tcg/i386/test-i386-fxam.c:17:
+volatile union u ld_invalid_n1 = { .s = { 1, 0x8123 } };
ERROR: Use of volatile is usually wrong, please add a comment #63: FILE: tests/tcg/i386/test-i386-fxam.c:18:
+volatile union u ld_invalid_n2 = { .s = { 0, 0x8123 } };
ERROR: Use of volatile is usually wrong, please add a comment #64: FILE: tests/tcg/i386/test-i386-fxam.c:19:
+volatile union u ld_invalid_n3 = { .s = { 0, 0xffff } };
ERROR: Use of volatile is usually wrong, please add a comment
#65: FILE: tests/tcg/i386/test-i386-fxam.c:20:
+volatile union u ld_invalid_n4 = { .s = { (UINT64_C(1) << 63) - 1, 0xffff } };
ERROR: spaces required around that '-' (ctx:VxV)
#127: FILE: tests/tcg/i386/test-i386-fxam.c:82:
+ __asm__ volatile ("fxam\nfnstsw" : "=a" (sw) : "t" (0x1p-16445L));
^ERROR: spaces required around that '-' (ctx:VxV)
#132: FILE: tests/tcg/i386/test-i386-fxam.c:87:
+ __asm__ volatile ("fxam\nfnstsw" : "=a" (sw) : "t" (-0x1p-16445L));
^total: 12 errors, 1 warnings, 159 lines checked
Patch 61/115 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
62/115 Checking commit 9f11ae8877f2 (target/i386: fix fbstp handling of negative zero)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #37:
new file mode 100644
total: 0 errors, 1 warnings, 40 lines checked
Patch 62/115 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
63/115 Checking commit 7e360a8876fe (target/i386: fix fbstp handling of out-of-range values)
ERROR: Use of volatile is usually wrong, please add a comment
#57: FILE: tests/tcg/i386/test-i386-fbstp.c:12:
+volatile union u ld_invalid_1 = { .s = { 1, 1234 } };
ERROR: Use of volatile is usually wrong, please add a comment #58: FILE: tests/tcg/i386/test-i386-fbstp.c:13:
+volatile union u ld_invalid_2 = { .s = { 0, 1234 } };
ERROR: Use of volatile is usually wrong, please add a comment #59: FILE: tests/tcg/i386/test-i386-fbstp.c:14:
+volatile union u ld_invalid_3 = { .s = { 0, 0x7fff } };
ERROR: Use of volatile is usually wrong, please add a comment #60: FILE: tests/tcg/i386/test-i386-fbstp.c:15:
+volatile union u ld_invalid_4 = { .s = { (UINT64_C(1) << 63) - 1, 0x7fff } };
total: 4 errors, 0 warnings, 144 lines checked
Patch 63/115 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
64/115 Checking commit c79f240a3d83 (target/i386: fix fisttpl, fisttpll handling of out-of-range values)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#66:
new file mode 100644
ERROR: Use of volatile is usually wrong, please add a comment #82: FILE: tests/tcg/i386/test-i386-fisttp.c:12:
+volatile union u ld_invalid_1 = { .s = { 1, 1234 } };
total: 1 errors, 1 warnings, 138 lines checked
Patch 64/115 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
65/115 Checking commit 7ee3b5d1c152 (hw/i386/vmport: Allow QTest use without crashing)
66/115 Checking commit dd325815af06 (x86/cpu: Enable AVX512_VP2INTERSECT cpu feature)
67/115 Checking commit 2b7dab66301d (vfio/pci: Use kvm_irqchip_add_irqfd_notifier_gsi() for irqfds) 68/115 Checking commit 1ead9654de7d (KVM: Pass EventNotifier into kvm_irqchip_assign_irqfd) 69/115 Checking commit d0110c612071 (KVM: Kick resamplefd for split kernel irqchip)
70/115 Checking commit 85f319e7f251 (chardev/char-socket: Properly make qio connections non blocking) 71/115 Checking commit 0abe63e4908f (tests: machine-none-test: Enable MicroBlaze testing) 72/115 Checking commit 06644d9db286 (hw/i386/amd_iommu: Fix the reserved bits definition of IOMMU commands) 73/115 Checking commit c130d2b31ab2 (replay: implement fair mutex)
74/115 Checking commit f21430a7fd25 (i386: Remove unused define's from hax and hvf)
75/115 Checking commit 6aa0a6817b14 (target/i386: define a new MSR based feature word - FEAT_PERF_CAPABILITIES) 76/115 Checking commit a3aaf5e4e5a6 (util/oslib: Returns the real thread identifier on FreeBSD and NetBSD) 77/115 Checking commit 3f5bb0f0819a (memory: Make 'info mtree' not display disabled regions by default) 78/115 Checking commit 98e8ed2cf4c1 (qemu/thread: Mark qemu_thread_exit() with 'noreturn' attribute) 79/115 Checking commit 3bd81dbdd79f (configure: Do not ignore malloc value)
80/115 Checking commit f843bd2eae6d (exec: set map length to zero when returning NULL)
81/115 Checking commit 136df11a66e3 (target/i386: fix IEEE x87 floating-point exception raising)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#485:
new file mode 100644
ERROR: Use of volatile is usually wrong, please add a comment #501: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:12:
+volatile float f_res;
ERROR: Use of volatile is usually wrong, please add a comment #502: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:13:
+volatile double d_res;
ERROR: Use of volatile is usually wrong, please add a comment #503: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:14:
+volatile long double ld_res;
ERROR: Use of volatile is usually wrong, please add a comment #504: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:15:
+volatile long double ld_res2;
ERROR: Use of volatile is usually wrong, please add a comment #506: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:17:
+volatile union u ld_invalid_1 = { .s = { 1, 1234 } };
ERROR: Use of volatile is usually wrong, please add a comment #507: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:18:
+volatile float f_snan = __builtin_nansf("");
ERROR: Use of volatile is usually wrong, please add a comment #508: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:19:
+volatile double d_snan = __builtin_nans("");
ERROR: Use of volatile is usually wrong, please add a comment #509: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:20:
+volatile long double ld_third = 1.0L / 3.0L;
ERROR: Use of volatile is usually wrong, please add a comment #510: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:21:
+volatile long double ld_snan = __builtin_nansl("");
ERROR: Use of volatile is usually wrong, please add a comment #511: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:22:
+volatile long double ld_nan = __builtin_nanl("");
ERROR: Use of volatile is usually wrong, please add a comment #512: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:23:
+volatile long double ld_inf = __builtin_infl();
ERROR: Use of volatile is usually wrong, please add a comment #513: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:24:
+volatile long double ld_ninf = -__builtin_infl();
ERROR: Use of volatile is usually wrong, please add a comment #514: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:25:
+volatile long double ld_one = 1.0L;
ERROR: Use of volatile is usually wrong, please add a comment #515: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:26:
+volatile long double ld_zero = 0.0L;
ERROR: Use of volatile is usually wrong, please add a comment #516: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:27:
+volatile long double ld_nzero = -0.0L;
ERROR: Use of volatile is usually wrong, please add a comment #517: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:28:
+volatile long double ld_min = LDBL_MIN;
ERROR: Use of volatile is usually wrong, please add a comment #518: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:29:
+volatile long double ld_max = LDBL_MAX;
ERROR: Use of volatile is usually wrong, please add a comment #519: FILE: tests/tcg/i386/test-i386-fp-exceptions.c:30:
+volatile long double ld_nmax = -LDBL_MAX;
total: 18 errors, 1 warnings, 1252 lines checked
Patch 81/115 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
82/115 Checking commit f9bd95ecf731 (target/i386: correct fix for pcmpxstrx substring search)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #105:
new file mode 100644
total: 0 errors, 1 warnings, 54 lines checked
Patch 82/115 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
83/115 Checking commit acb8d158c8e6 (sysemu/accel: Restrict machine methods to system-mode) 84/115 Checking commit 3b8e276cc23c (sysemu/tcg: Only declare tcg_allowed when TCG is available) 85/115 Checking commit 238000a0d14a (sysemu/hvf: Only declare hvf_allowed when HVF is available) 86/115 Checking commit 709b437b9793 (target/ppc: Restrict PPCVirtualHypervisorClass to system-mode) 87/115 Checking commit 7e1a49323f54 (i386: hvf: Move HVFState definition into hvf) 88/115 Checking commit b587a1b3d465 (i386: hvf: Drop useless declarations in sysemu) 89/115 Checking commit c4d282b6e889 (i386: hvf: Drop unused variable)
90/115 Checking commit ddb005dacbe6 (i386: hvf: Use ins_len to advance IP)
91/115 Checking commit ed88ce7c455e (i386: hvf: Use IP from CPUX86State)
ERROR: unnecessary whitespace before a quoted newline
#447: FILE: target/i386/hvf/x86_emu.c:1470:
+ printf("Unimplemented handler (%llx) for %d (%x %x) \n", env->eip,
total: 1 errors, 0 warnings, 403 lines checked
Patch 91/115 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
92/115 Checking commit e1de961f37f8 (i386: hvf: Drop fetch_rip from HVFX86EmulatorState) 93/115 Checking commit 014172380927 (i386: hvf: Drop rflags from HVFX86EmulatorState) 94/115 Checking commit e978983f7245 (i386: hvf: Drop copy of RFLAGS defines) 95/115 Checking commit df05641db746 (i386: hvf: Drop regs in HVFX86EmulatorState) 96/115 Checking commit 20208b4ea9b2 (i386: hvf: Move lazy_flags into CPUX86State) 97/115 Checking commit b52a4bf0b053 (i386: hvf: Move mmio_buf into CPUX86State) 98/115 Checking commit 93262a0ad3a1 (i386: hvf: Drop HVFX86EmulatorState) 99/115 Checking commit 5ec6d66e0735 (xen: fix build without pci passthrough)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #136:
new file mode 100644
total: 0 errors, 1 warnings, 98 lines checked
Patch 99/115 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
100/115 Checking commit b8dc835d0135 (target/i386: sev: Remove unused QSevGuestInfoClass) 101/115 Checking commit 4902392cbf95 (target/i386: sev: Move local structure definitions into .c file) 102/115 Checking commit 56fe4d8d689c (target/i386: sev: Rename QSevGuestInfo)
103/115 Checking commit 560d42bf0947 (target/i386: sev: Embed SEVState in SevGuestState) 104/115 Checking commit 832d4593f6cb (target/i386: sev: Partial cleanup to sev_state global) 105/115 Checking commit c0fa65326d38 (target/i386: sev: Remove redundant cbitpos and reduced_phys_bits fields) 106/115 Checking commit ef7e4eba2d42 (target/i386: sev: Remove redundant policy field) 107/115 Checking commit 722d1df382df (target/i386: sev: Remove redundant handle field) 108/115 Checking commit 11943a666921 (target/i386: sev: Unify SEVState and SevGuestState) 109/115 Checking commit 79d4c74905c8 (checkpatch: reversed logic with acpi test checks) 110/115 Checking commit 598847535a01 (exec/memory: Remove unused MemoryRegionMmio type) 111/115 Checking commit b4bf922f7e8a (hw/usb: Move device-specific declarations to new 'hcd-musb.h' header)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#83:
new file mode 100644
total: 0 errors, 1 warnings, 96 lines checked
Patch 111/115 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
112/115 Checking commit 8cf1910b2046 (exec/cpu-common: Move MUSB specific typedefs to 'hw/usb/hcd-musb.h') 113/115 Checking commit 9da3214af6d1 (replay: fix replay shutdown for console mode) 114/115 Checking commit ed8ffece50a9 (stubs: move Xen stubs to accel/)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#24:
rename from stubs/xen-hvm.c
total: 0 errors, 1 warnings, 36 lines checked
Patch 114/115 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
115/115 Checking commit b258374fbf01 (target/i386: Remove obsolete TODO file)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #17:
deleted file mode 100644
total: 0 errors, 1 warnings, 0 lines checked
Patch 115/115 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Quoted 13 lines · Paolo Bonzini
The following changes since commit
31d321c2b3574dcc74e9f6411af06bca6b5d10f4:Merge remote-tracking branch 'remotes/philmd-gitlab/tags/sparc-next-20200609' into staging (2020-06-09 17:29:47 +0100)
are available in the Git repository at:
git://github.com/bonzini/qemu.gittags/for-upstreamfor you to fetch changes up to
d3ffb42f3fbe24c29a2bd7806dab1dd521b4d59c:target/i386: Remove obsolete TODO file (2020-06-11 14:08:59 -0400)
Quoted 14 lines
----------------------------------------------------------------
* Miscellaneous fixes and feature enablement (many)
* SEV refactoring (David)
* Hyper-V initial support (Jon)
* i386 TCG fixes (x87 and SSE, Joseph)
* vmport cleanup and improvements (Philippe, Liran)
* Use-after-free with vCPU hot-unplug (Nengyuan)
* run-coverity-scan improvements (myself)
* Record/replay fixes (Pavel)
* -machine kernel_irqchip=split improvements for INTx (Peter)
* Code cleanups (Philippe)
* Crash and security fixes (PJP)
* HVF cleanups (Roman)
Hi; I'm afraid this fails to build on OSX, and has a check-tcg failure on x86-64 Linux.
OSX:
In file included from /Users/pm215/src/qemu-for-merges/target/i386/hvf/hvf.c:53:
In file included from /Users/pm215/src/qemu-for-merges/include/sysemu/hvf.h:16:
/Users/pm215/src/qemu-for-merges/target/i386/cpu.h:1601:5: error:
unknown type name 'hvf_lazy_flags'
hvf_lazy_flags hvf_lflags;
^In file included from /Users/pm215/src/qemu-for-merges/target/i386/hvf/hvf.c:53:
In file included from /Users/pm215/src/qemu-for-merges/include/sysemu/hvf.h:16:
In file included from /Users/pm215/src/qemu-for-merges/target/i386/cpu.h:2021:
/Users/pm215/src/qemu-for-merges/include/exec/cpu-all.h:442:12: error:
returning 'void' from a function with incompatible result type 'ArchCPU *' (aka 'struct X86CPU *')
return container_of(env, ArchCPU, env);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/pm215/src/qemu-for-merges/include/qemu/compiler.h:56:41: note:
expanded from macro 'container_of'
#define container_of(ptr, type, member) ({ \
^~~~~~~~~~~~~~~~~~~~~~~~~In file included from /Users/pm215/src/qemu-for-merges/target/i386/hvf/hvf.c:53:
In file included from /Users/pm215/src/qemu-for-merges/include/sysemu/hvf.h:16:
In file included from /Users/pm215/src/qemu-for-merges/target/i386/cpu.h:2021:
/Users/pm215/src/qemu-for-merges/include/exec/cpu-all.h:464:14: error:
initializing 'ArchCPU *' (aka 'struct X86CPU *') with an expression of incompatible type 'void'
ArchCPU *arch_cpu = container_of(env, ArchCPU, env);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~3 errors generated.
On x86-64 Linux host, running the check-tcg tests on the static linux-user build:
BUILD i386-linux-user guest-tests with docker qemu:fedora-i386-cross/home/petmay01/linaro/qemu-for-merges/tests/tcg/i386/test-i386-pcmpistri.c:
In function 'main':/home/petmay01/linaro/qemu-for-merges/tests/tcg/i386/test-i386-pcmpistri.c:28:15:
warning: left-hand operand of comma expression has no effect [-Wunused-value]
28 | if ("%d\n", _mm_cmpistri(s1.x, s3.x, 0x4c) != 16) {
| ^
(only a warning because we don't seem to be using -Werror here?)
and then the test crashed at runtime:
TEST test-i386-pcmpistri on i386
qemu: uncaught target signal 4 (Illegal instruction) - core dumped
timeout: the monitored command dumped core
Illegal instruction
../Makefile.target:151: recipe for target 'run-test-i386-pcmpistri' failed
thanks
-- PMM
Quoted 48 lines · Peter Maydell
Hi; I'm afraid this fails to build on OSX, and has a check-tcg failure on x86-64 Linux.
OSX:
In file included from /Users/pm215/src/qemu-for-merges/target/i386/hvf/hvf.c:53:
In file included from /Users/pm215/src/qemu-for-merges/include/sysemu/hvf.h:16:
/Users/pm215/src/qemu-for-merges/target/i386/cpu.h:1601:5: error:
unknown type name 'hvf_lazy_flags'hvf_lazy_flags hvf_lflags; ^In file included from /Users/pm215/src/qemu-for-merges/target/i386/hvf/hvf.c:53:
In file included from /Users/pm215/src/qemu-for-merges/include/sysemu/hvf.h:16:
In file included from /Users/pm215/src/qemu-for-merges/target/i386/cpu.h:2021:
/Users/pm215/src/qemu-for-merges/include/exec/cpu-all.h:442:12: error:
returning 'void' from a function with incompatible result type 'ArchCPU *' (aka 'struct X86CPU *')return container_of(env, ArchCPU, env); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/pm215/src/qemu-for-merges/include/qemu/compiler.h:56:41: note: expanded from macro 'container_of' #define container_of(ptr, type, member) ({ \ ^~~~~~~~~~~~~~~~~~~~~~~~~In file included from /Users/pm215/src/qemu-for-merges/target/i386/hvf/hvf.c:53:
In file included from /Users/pm215/src/qemu-for-merges/include/sysemu/hvf.h:16:
In file included from /Users/pm215/src/qemu-for-merges/target/i386/cpu.h:2021:
/Users/pm215/src/qemu-for-merges/include/exec/cpu-all.h:464:14: error:
initializing 'ArchCPU *' (aka 'struct X86CPU *') with an expression of incompatible type 'void'ArchCPU *arch_cpu = container_of(env, ArchCPU, env); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~3 errors generated.
On x86-64 Linux host, running the check-tcg tests on the static linux-user build:
BUILD i386-linux-user guest-tests with docker qemu:fedora-i386-cross
/home/petmay01/linaro/qemu-for-merges/tests/tcg/i386/test-i386-pcmpistri.c:
In function 'main':/home/petmay01/linaro/qemu-for-merges/tests/tcg/i386/test-i386-pcmpistri.c:28:15:
warning: left-hand operand of comma expression has no effect [-Wunused-value]
28 | if ("%d\n",_mm_cmpistri(s1.x, s3.x, 0x4c)!= 16) {
| ^(only a warning because we don't seem to be using -Werror here?)
Quoted 7 lines
and then the test crashed at runtime:
TEST test-i386-pcmpistri on i386
qemu: uncaught target signal 4 (Illegal instruction) - core dumped
timeout: the monitored command dumped core
Illegal instruction
../Makefile.target:151: recipe for target 'run-test-i386-pcmpistri' failed
I'll resend without the offending patch. Roman, Joseph, please take a look and (especially for the OS X) please check if your series need a rebase.
Thanks,
Paolo
Quoted 57 lines · Paolo Bonzini
Quoted 48 lines · Peter Maydell
Hi; I'm afraid this fails to build on OSX, and has a check-tcg failure on x86-64 Linux.
OSX:
In file included from /Users/pm215/src/qemu-for-merges/target/i386/hvf/hvf.c:53:
In file included from /Users/pm215/src/qemu-for-merges/include/sysemu/hvf.h:16:
/Users/pm215/src/qemu-for-merges/target/i386/cpu.h:1601:5: error:
unknown type name 'hvf_lazy_flags'hvf_lazy_flags hvf_lflags; ^In file included from /Users/pm215/src/qemu-for-merges/target/i386/hvf/hvf.c:53:
In file included from /Users/pm215/src/qemu-for-merges/include/sysemu/hvf.h:16:
In file included from /Users/pm215/src/qemu-for-merges/target/i386/cpu.h:2021:
/Users/pm215/src/qemu-for-merges/include/exec/cpu-all.h:442:12: error:
returning 'void' from a function with incompatible result type 'ArchCPU *' (aka 'struct X86CPU *')return container_of(env, ArchCPU, env); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/pm215/src/qemu-for-merges/include/qemu/compiler.h:56:41: note: expanded from macro 'container_of' #define container_of(ptr, type, member) ({ \ ^~~~~~~~~~~~~~~~~~~~~~~~~In file included from /Users/pm215/src/qemu-for-merges/target/i386/hvf/hvf.c:53:
In file included from /Users/pm215/src/qemu-for-merges/include/sysemu/hvf.h:16:
In file included from /Users/pm215/src/qemu-for-merges/target/i386/cpu.h:2021:
/Users/pm215/src/qemu-for-merges/include/exec/cpu-all.h:464:14: error:
initializing 'ArchCPU *' (aka 'struct X86CPU *') with an expression of incompatible type 'void'ArchCPU *arch_cpu = container_of(env, ArchCPU, env); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~3 errors generated.
On x86-64 Linux host, running the check-tcg tests on the static linux-user build:
BUILD i386-linux-user guest-tests with docker qemu:fedora-i386-cross
/home/petmay01/linaro/qemu-for-merges/tests/tcg/i386/test-i386-pcmpistri.c:
In function 'main':/home/petmay01/linaro/qemu-for-merges/tests/tcg/i386/test-i386-pcmpistri.c:28:15:
warning: left-hand operand of comma expression has no effect [-Wunused-value]
28 | if ("%d\n",_mm_cmpistri(s1.x, s3.x, 0x4c)!= 16) {
| ^(only a warning because we don't seem to be using -Werror here?)
Quoted 7 lines
and then the test crashed at runtime:
TEST test-i386-pcmpistri on i386
qemu: uncaught target signal 4 (Illegal instruction) - core dumped
timeout: the monitored command dumped core
Illegal instruction
../Makefile.target:151: recipe for target 'run-test-i386-pcmpistri' failed
Quoted 8 lines
I'll resend without the offending patch. Roman, Joseph, please take a look and (especially for the OS X) please check if your series need a rebase.
Thanks,
Paolo
Hi Paolo,
I'm looking at it.
Regards,
Roman
Quoted 57 lines · Paolo Bonzini
Quoted 48 lines · Peter Maydell
Hi; I'm afraid this fails to build on OSX, and has a check-tcg failure on x86-64 Linux.
OSX:
In file included from /Users/pm215/src/qemu-for-merges/target/i386/hvf/hvf.c:53:
In file included from /Users/pm215/src/qemu-for-merges/include/sysemu/hvf.h:16:
/Users/pm215/src/qemu-for-merges/target/i386/cpu.h:1601:5: error:
unknown type name 'hvf_lazy_flags'hvf_lazy_flags hvf_lflags; ^In file included from /Users/pm215/src/qemu-for-merges/target/i386/hvf/hvf.c:53:
In file included from /Users/pm215/src/qemu-for-merges/include/sysemu/hvf.h:16:
In file included from /Users/pm215/src/qemu-for-merges/target/i386/cpu.h:2021:
/Users/pm215/src/qemu-for-merges/include/exec/cpu-all.h:442:12: error:
returning 'void' from a function with incompatible result type 'ArchCPU *' (aka 'struct X86CPU *')return container_of(env, ArchCPU, env); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/pm215/src/qemu-for-merges/include/qemu/compiler.h:56:41: note: expanded from macro 'container_of' #define container_of(ptr, type, member) ({ \ ^~~~~~~~~~~~~~~~~~~~~~~~~In file included from /Users/pm215/src/qemu-for-merges/target/i386/hvf/hvf.c:53:
In file included from /Users/pm215/src/qemu-for-merges/include/sysemu/hvf.h:16:
In file included from /Users/pm215/src/qemu-for-merges/target/i386/cpu.h:2021:
/Users/pm215/src/qemu-for-merges/include/exec/cpu-all.h:464:14: error:
initializing 'ArchCPU *' (aka 'struct X86CPU *') with an expression of incompatible type 'void'ArchCPU *arch_cpu = container_of(env, ArchCPU, env); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~3 errors generated.
On x86-64 Linux host, running the check-tcg tests on the static linux-user build:
BUILD i386-linux-user guest-tests with docker qemu:fedora-i386-cross
/home/petmay01/linaro/qemu-for-merges/tests/tcg/i386/test-i386-pcmpistri.c:
In function 'main':/home/petmay01/linaro/qemu-for-merges/tests/tcg/i386/test-i386-pcmpistri.c:28:15:
warning: left-hand operand of comma expression has no effect [-Wunused-value]
28 | if ("%d\n",_mm_cmpistri(s1.x, s3.x, 0x4c)!= 16) {
| ^(only a warning because we don't seem to be using -Werror here?)
Quoted 7 lines
and then the test crashed at runtime:
TEST test-i386-pcmpistri on i386
qemu: uncaught target signal 4 (Illegal instruction) - core dumped
timeout: the monitored command dumped core
Illegal instruction
../Makefile.target:151: recipe for target 'run-test-i386-pcmpistri' failed
Quoted 8 lines
I'll resend without the offending patch. Roman, Joseph, please take a look and (especially for the OS X) please check if your series need a rebase.
Thanks,
Paolo
It seems rebase is not needed. The queue doesn't include the patch:
https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg08076.html
Regards,
Roman
Quoted 2 lines · Roman Bolshakov
It seems rebase is not needed. The queue doesn't include the patch:
https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg08076.html
Thanks, it had a conflict with
commit f291cf54148e5b9e51c55b9056e4be546492a9ca
Author: Philippe Mathieu-Daudé <[email protected]> Date: Tue May 26 19:24:23 2020 +0200
sysemu/hvf: Only declare hvf_allowed when HVF is available
When HVF is not available, the hvf_allowed variable does not exist.
Message-Id: <[email protected]>
but I've fixed it up now. (It wasn't clear from the commit message that this patch could not simply be dropped. Unfortunately I didn't have an OS X installation to test it).
Paolo