diff options
109 files changed, 1014 insertions, 557 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index 7da465dcdb..8e9f0d591e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1869,7 +1869,7 @@ S: Odd Fixes F: hw/9pfs/ X: hw/9pfs/xen-9p* F: fsdev/ -F: docs/interop/virtfs-proxy-helper.rst +F: docs/tools/virtfs-proxy-helper.rst F: tests/qtest/virtio-9p-test.c T: git https://gitlab.com/gkurz/qemu.git 9p-next T: git https://github.com/cschoenebeck/qemu.git 9p.next @@ -1900,7 +1900,7 @@ S: Supported F: tools/virtiofsd/* F: hw/virtio/vhost-user-fs* F: include/hw/virtio/vhost-user-fs.h -F: docs/interop/virtiofsd.rst +F: docs/tools/virtiofsd.rst virtio-input M: Gerd Hoffmann <kraxel@redhat.com> @@ -2214,7 +2214,7 @@ F: block/ F: hw/block/ F: include/block/ F: qemu-img* -F: docs/interop/qemu-img.rst +F: docs/tools/qemu-img.rst F: qemu-io* F: tests/qemu-iotests/ F: util/qemu-progress.c @@ -2671,7 +2671,7 @@ F: qapi/trace.json F: scripts/tracetool.py F: scripts/tracetool/ F: scripts/qemu-trace-stap* -F: docs/interop/qemu-trace-stap.rst +F: docs/tools/qemu-trace-stap.rst F: docs/devel/tracing.txt T: git https://github.com/stefanha/qemu.git tracing @@ -3066,7 +3066,7 @@ F: include/block/nbd* F: qemu-nbd.* F: blockdev-nbd.c F: docs/interop/nbd.txt -F: docs/interop/qemu-nbd.rst +F: docs/tools/qemu-nbd.rst T: git https://repo.or.cz/qemu/ericb.git nbd T: git https://src.openvz.org/scm/~vsementsov/qemu.git nbd diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c index e9d2d6aaaa..69aa7d018b 100644 --- a/accel/xen/xen-all.c +++ b/accel/xen/xen-all.c @@ -122,7 +122,7 @@ static void xenstore_record_dm_state(struct xs_handle *xs, const char *state) } -static void xen_change_state_handler(void *opaque, int running, +static void xen_change_state_handler(void *opaque, bool running, RunState state) { if (running) { diff --git a/audio/audio.c b/audio/audio.c index 6734c8af70..534278edfe 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1540,7 +1540,7 @@ static int audio_driver_init(AudioState *s, struct audio_driver *drv, } } -static void audio_vm_change_state_handler (void *opaque, int running, +static void audio_vm_change_state_handler (void *opaque, bool running, RunState state) { AudioState *s = opaque; diff --git a/backends/dbus-vmstate.c b/backends/dbus-vmstate.c index bd050e8e9c..2a0d2e4a31 100644 --- a/backends/dbus-vmstate.c +++ b/backends/dbus-vmstate.c @@ -229,7 +229,10 @@ static int dbus_vmstate_post_load(void *opaque, int version_id) &bytes_read, NULL, &err)) { goto error; } - g_return_val_if_fail(bytes_read == len, -1); + if (bytes_read != len) { + error_report("%s: Short read", __func__); + return -1; + } id[len] = 0; trace_dbus_vmstate_loading(id); diff --git a/block/block-backend.c b/block/block-backend.c index e493f17515..413af51f3b 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -163,7 +163,7 @@ static const char *blk_root_get_name(BdrvChild *child) return blk_name(child->opaque); } -static void blk_vm_state_changed(void *opaque, int running, RunState state) +static void blk_vm_state_changed(void *opaque, bool running, RunState state) { Error *local_err = NULL; BlockBackend *blk = opaque; diff --git a/default-configs/devices/lm32-softmmu.mak b/default-configs/devices/lm32-softmmu.mak index 115b3e34c9..1bce3f6e8b 100644 --- a/default-configs/devices/lm32-softmmu.mak +++ b/default-configs/devices/lm32-softmmu.mak @@ -8,5 +8,5 @@ CONFIG_SEMIHOSTING=y # Boards: # -CONFIG_LM32=y +CONFIG_LM32_EVR=y CONFIG_MILKYMIST=y diff --git a/disas/nanomips.cpp b/disas/nanomips.cpp index 90e63b8367..2b09655271 100644 --- a/disas/nanomips.cpp +++ b/disas/nanomips.cpp @@ -837,7 +837,7 @@ int NMD::Disassemble(const uint16 * data, std::string & dis, * an ASE attribute and the requested version * not having that attribute */ - dis = "ASE attribute missmatch"; + dis = "ASE attribute mismatch"; return -5; } disassembly_function dis_fn = table[i].disassembly; diff --git a/docs/system/ppc/embedded.rst b/docs/system/ppc/embedded.rst new file mode 100644 index 0000000000..cfffbda24d --- /dev/null +++ b/docs/system/ppc/embedded.rst @@ -0,0 +1,10 @@ +Embedded family boards +====================== + +- ``bamboo`` bamboo +- ``mpc8544ds`` mpc8544ds +- ``ppce500`` generic paravirt e500 platform +- ``ref405ep`` ref405ep +- ``sam460ex`` aCube Sam460ex +- ``taihu`` taihu +- ``virtex-ml507`` Xilinx Virtex ML507 reference design diff --git a/docs/system/ppc/powermac.rst b/docs/system/ppc/powermac.rst new file mode 100644 index 0000000000..04334ba210 --- /dev/null +++ b/docs/system/ppc/powermac.rst @@ -0,0 +1,34 @@ +PowerMac family boards (``g3beige``, ``mac99``) +================================================================== + +Use the executable ``qemu-system-ppc`` to simulate a complete PowerMac +PowerPC system. + +- ``g3beige`` Heathrow based PowerMAC +- ``mac99`` Mac99 based PowerMAC + +Supported devices +----------------- + +QEMU emulates the following PowerMac peripherals: + + * UniNorth or Grackle PCI Bridge + * PCI VGA compatible card with VESA Bochs Extensions + * 2 PMAC IDE interfaces with hard disk and CD-ROM support + * NE2000 PCI adapters + * Non Volatile RAM + * VIA-CUDA with ADB keyboard and mouse. + + +Missing devices +--------------- + + * To be identified + +Firmware +-------- + +Since version 0.9.1, QEMU uses OpenBIOS https://www.openbios.org/ for +the g3beige and mac99 PowerMac and the 40p machines. OpenBIOS is a free +(GPL v2) portable firmware implementation. The goal is to implement a +100% IEEE 1275-1994 (referred to as Open Firmware) compliant firmware. diff --git a/docs/system/ppc/powernv.rst b/docs/system/ppc/powernv.rst new file mode 100644 index 0000000000..43c58bc32e --- /dev/null +++ b/docs/system/ppc/powernv.rst @@ -0,0 +1,193 @@ +PowerNV family boards (``powernv8``, ``powernv9``) +================================================================== + +PowerNV (as Non-Virtualized) is the "baremetal" platform using the +OPAL firmware. It runs Linux on IBM and OpenPOWER systems and it can +be used as an hypervisor OS, running KVM guests, or simply as a host +OS. + +The PowerNV QEMU machine tries to emulate a PowerNV system at the +level of the skiboot firmware, which loads the OS and provides some +runtime services. Power Systems have a lower firmware (HostBoot) that +does low level system initialization, like DRAM training. This is +beyond the scope of what QEMU addresses today. + +Supported devices +----------------- + + * Multi processor support for POWER8, POWER8NVL and POWER9. + * XSCOM, serial communication sideband bus to configure chiplets + * Simple LPC Controller + * Processor Service Interface (PSI) Controller + * Interrupt Controller, XICS (POWER8) and XIVE (POWER9) + * POWER8 PHB3 PCIe Host bridge and POWER9 PHB4 PCIe Host bridge + * Simple OCC is an on-chip microcontroller used for power management + tasks + * iBT device to handle BMC communication, with the internal BMC + simulator provided by QEMU or an external BMC such as an Aspeed + QEMU machine. + * PNOR containing the different firmware partitions. + +Missing devices +--------------- + +A lot is missing, among which : + + * POWER10 processor + * XIVE2 (POWER10) interrupt controller + * I2C controllers (yet to be merged) + * NPU/NPU2/NPU3 controllers + * EEH support for PCIe Host bridge controllers + * NX controller + * VAS controller + * chipTOD (Time Of Day) + * Self Boot Engine (SBE). + * FSI bus + +Firmware +-------- + +The OPAL firmware (OpenPower Abstraction Layer) for OpenPower systems +includes the runtime services `skiboot` and the bootloader kernel and +initramfs `skiroot`. Source code can be found on GitHub: + + https://github.com/open-power. + +Prebuilt images of `skiboot` and `skiboot` are made available on the `OpenPOWER <https://openpower.xyz/job/openpower/job/openpower-op-build/>`__ site. To boot a POWER9 machine, use the `witherspoon <https://openpower.xyz/job/openpower/job/openpower-op-build/label=slave,target=witherspoon/lastSuccessfulBuild/>`__ images. For POWER8, use +the `palmetto <https://openpower.xyz/job/openpower/job/openpower-op-build/label=slave,target=palmetto/lastSuccessfulBuild/>`__ images. + +QEMU includes a prebuilt image of `skiboot` which is updated when a +more recent version is required by the models. + +Boot options +------------ + +Here is a simple setup with one e1000e NIC : + +.. code-block:: bash + + $ qemu-system-ppc64 -m 2G -machine powernv9 -smp 2,cores=2,threads=1 \ + -accel tcg,thread=single \ + -device e1000e,netdev=net0,mac=C0:FF:EE:00:00:02,bus=pcie.0,addr=0x0 \ + -netdev user,id=net0,hostfwd=::20022-:22,hostname=pnv \ + -kernel ./zImage.epapr \ + -initrd ./rootfs.cpio.xz \ + -nographic + +and a SATA disk : + +.. code-block:: bash + + -device ich9-ahci,id=sata0,bus=pcie.1,addr=0x0 \ + -drive file=./ubuntu-ppc64le.qcow2,if=none,id=drive0,format=qcow2,cache=none \ + -device ide-hd,bus=sata0.0,unit=0,drive=drive0,id=ide,bootindex=1 \ + +Complex PCIe configuration +~~~~~~~~~~~~~~~~~~~~~~~~~~ +Six PHBs are defined per chip (POWER9) but no default PCI layout is +provided (to be compatible with libvirt). One PCI device can be added +on any of the available PCIe slots using command line options such as: + +.. code-block:: bash + + -device e1000e,netdev=net0,mac=C0:FF:EE:00:00:02,bus=pcie.0,addr=0x0 + -netdev bridge,id=net0,helper=/usr/libexec/qemu-bridge-helper,br=virbr0,id=hostnet0 + + -device megasas,id=scsi0,bus=pcie.0,addr=0x0 + -drive file=./ubuntu-ppc64le.qcow2,if=none,id=drive-scsi0-0-0-0,format=qcow2,cache=none + -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=2 + +Here is a full example with two different storage controllers on +different PHBs, each with a disk, the second PHB is empty : + +.. code-block:: bash + + $ qemu-system-ppc64 -m 2G -machine powernv9 -smp 2,cores=2,threads=1 -accel tcg,thread=single \ + -kernel ./zImage.epapr -initrd ./rootfs.cpio.xz -bios ./skiboot.lid \ + \ + -device megasas,id=scsi0,bus=pcie.0,addr=0x0 \ + -drive file=./rhel7-ppc64le.qcow2,if=none,id=drive-scsi0-0-0-0,format=qcow2,cache=none \ + -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=2 \ + \ + -device pcie-pci-bridge,id=bridge1,bus=pcie.1,addr=0x0 \ + \ + -device ich9-ahci,id=sata0,bus=bridge1,addr=0x1 \ + -drive file=./ubuntu-ppc64le.qcow2,if=none,id=drive0,format=qcow2,cache=none \ + -device ide-hd,bus=sata0.0,unit=0,drive=drive0,id=ide,bootindex=1 \ + -device e1000e,netdev=net0,mac=C0:FF:EE:00:00:02,bus=bridge1,addr=0x2 \ + -netdev bridge,helper=/usr/libexec/qemu-bridge-helper,br=virbr0,id=net0 \ + -device nec-usb-xhci,bus=bridge1,addr=0x7 \ + \ + -serial mon:stdio -nographic + +You can also use VIRTIO devices : + +.. code-block:: bash + + -drive file=./fedora-ppc64le.qcow2,if=none,snapshot=on,id=drive0 \ + -device virtio-blk-pci,drive=drive0,id=blk0,bus=pcie.0 \ + \ + -netdev tap,helper=/usr/lib/qemu/qemu-bridge-helper,br=virbr0,id=netdev0 \ + -device virtio-net-pci,netdev=netdev0,id=net0,bus=pcie.1 \ + \ + -fsdev local,id=fsdev0,path=$HOME,security_model=passthrough \ + -device virtio-9p-pci,fsdev=fsdev0,mount_tag=host,bus=pcie.2 + +Multi sockets +~~~~~~~~~~~~~ + +The number of sockets is deduced from the number of CPUs and the +number of cores. ``-smp 2,cores=1`` will define a machine with 2 +sockets of 1 core, whereas ``-smp 2,cores=2`` will define a machine +with 1 socket of 2 cores. ``-smp 8,cores=2``, 4 sockets of 2 cores. + +BMC configuration +~~~~~~~~~~~~~~~~~ + +OpenPOWER systems negotiate the shutdown and reboot with their +BMC. The QEMU PowerNV machine embeds an IPMI BMC simulator using the +iBT interface and should offer the same power features. + +If you want to define your own BMC, use ``-nodefaults`` and specify +one on the command line : + +.. code-block:: bash + + -device ipmi-bmc-sim,id=bmc0 -device isa-ipmi-bt,bmc=bmc0,irq=10 + +The files `palmetto-SDR.bin <http://www.kaod.org/qemu/powernv/palmetto-SDR.bin>`__ +and `palmetto-FRU.bin <http://www.kaod.org/qemu/powernv/palmetto-FRU.bin>`__ +define a Sensor Data Record repository and a Field Replaceable Unit +inventory for a palmetto BMC. They can be used to extend the QEMU BMC +simulator. + +.. code-block:: bash + + -device ipmi-bmc-sim,sdrfile=./palmetto-SDR.bin,fruareasize=256,frudatafile=./palmetto-FRU.bin,id=bmc0 \ + -device isa-ipmi-bt,bmc=bmc0,irq=10 + +The PowerNV machine can also be run with an external IPMI BMC device +connected to a remote QEMU machine acting as BMC, using these options +: + +.. code-block:: bash + + -chardev socket,id=ipmi0,host=localhost,port=9002,reconnect=10 \ + -device ipmi-bmc-extern,id=bmc0,chardev=ipmi0 \ + -device isa-ipmi-bt,bmc=bmc0,irq=10 \ + -nodefaults + +NVRAM +~~~~~ + +Use a MTD drive to add a PNOR to the machine, and get a NVRAM : + +.. code-block:: bash + + -drive file=./witherspoon.pnor,format=raw,if=mtd + +CAVEATS +------- + + * No support for multiple HW threads (SMT=1). Same as pseries. + * CPU can hang when doing intensive I/Os. Use ``-append powersave=off`` in that case. diff --git a/docs/system/ppc/prep.rst b/docs/system/ppc/prep.rst new file mode 100644 index 0000000000..bd9eb8eabd --- /dev/null +++ b/docs/system/ppc/prep.rst @@ -0,0 +1,18 @@ +Prep machine (``40p``) +================================================================== + +Use the executable ``qemu-system-ppc`` to simulate a complete 40P (PREP) + +Supported devices +----------------- + +QEMU emulates the following 40P (PREP) peripherals: + + * PCI Bridge + * PCI VGA compatible card with VESA Bochs Extensions + * 2 IDE interfaces with hard disk and CD-ROM support + * Floppy disk + * PCnet network adapters + * Serial port + * PREP Non Volatile RAM + * PC compatible keyboard and mouse. diff --git a/docs/system/ppc/pseries.rst b/docs/system/ppc/pseries.rst new file mode 100644 index 0000000000..932d4dd17d --- /dev/null +++ b/docs/system/ppc/pseries.rst @@ -0,0 +1,12 @@ +pSeries family boards (``pseries``) +=================================== + +Supported devices +----------------- + +Missing devices +--------------- + + +Firmware +-------- diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst index 4dcf4f924c..83148dcfda 100644 --- a/docs/system/removed-features.rst +++ b/docs/system/removed-features.rst @@ -26,8 +26,8 @@ The ``-no-kvm`` argument was a synonym for setting ``-machine accel=tcg``. The ``-realtime mlock=on|off`` argument has been replaced by the ``-overcommit mem-lock=on|off`` argument. -``-show-cursor`` option (since 5.0) -''''''''''''''''''''''''''''''''''' +``-show-cursor`` option (removed in 6.0) +'''''''''''''''''''''''''''''''''''''''' Use ``-display sdl,show-cursor=on``, ``-display gtk,show-cursor=on`` or ``-display default,show-cursor=on`` instead. diff --git a/docs/system/target-ppc.rst b/docs/system/target-ppc.rst index a2f04c533c..67905b8f2a 100644 --- a/docs/system/target-ppc.rst +++ b/docs/system/target-ppc.rst @@ -3,45 +3,22 @@ PowerPC System emulator ----------------------- -Use the executable ``qemu-system-ppc`` to simulate a complete 40P (PREP) -or PowerMac PowerPC system. +Board-specific documentation +============================ -QEMU emulates the following PowerMac peripherals: +You can get a complete list by running ``qemu-system-ppc64 --machine +help``. -- UniNorth or Grackle PCI Bridge +.. + This table of contents should be kept sorted alphabetically + by the title text of each file, which isn't the same ordering + as an alphabetical sort by filename. -- PCI VGA compatible card with VESA Bochs Extensions +.. toctree:: + :maxdepth: 1 -- 2 PMAC IDE interfaces with hard disk and CD-ROM support - -- NE2000 PCI adapters - -- Non Volatile RAM - -- VIA-CUDA with ADB keyboard and mouse. - -QEMU emulates the following 40P (PREP) peripherals: - -- PCI Bridge - -- PCI VGA compatible card with VESA Bochs Extensions - -- 2 IDE interfaces with hard disk and CD-ROM support - -- Floppy disk - -- PCnet network adapters - -- Serial port - -- PREP Non Volatile RAM - -- PC compatible keyboard and mouse. - -Since version 0.9.1, QEMU uses OpenBIOS https://www.openbios.org/ for -the g3beige and mac99 PowerMac and the 40p machines. OpenBIOS is a free -(GPL v2) portable firmware implementation. The goal is to implement a -100% IEEE 1275-1994 (referred to as Open Firmware) compliant firmware. - -More information is available at -http://perso.magic.fr/l_indien/qemu-ppc/. + ppc/embedded + ppc/powermac + ppc/powernv + ppc/prep + ppc/pseries @@ -2754,7 +2754,7 @@ void gdb_set_stop_cpu(CPUState *cpu) } #ifndef CONFIG_USER_ONLY -static void gdb_vm_state_change(void *opaque, int running, RunState state) +static void gdb_vm_state_change(void *opaque, bool running, RunState state) { CPUState *cpu = gdbserver_state.c_cpu; g_autoptr(GString) buf = g_string_new(NULL); diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 22287a1522..526b70417d 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -1014,7 +1014,7 @@ void pflash_cfi01_legacy_drive(PFlashCFI01 *fl, DriveInfo *dinfo) loc_pop(&loc); } -static void postload_update_cb(void *opaque, int running, RunState state) +static void postload_update_cb(void *opaque, bool running, RunState state) { PFlashCFI01 *pfl = opaque; diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index e8600b069d..3d2072cf75 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -870,7 +870,7 @@ static void virtio_blk_dma_restart_bh(void *opaque) virtio_blk_process_queued_requests(s, true); } -static void virtio_blk_dma_restart_cb(void *opaque, int running, +static void virtio_blk_dma_restart_cb(void *opaque, bool running, RunState state) { VirtIOBlock *s = opaque; diff --git a/hw/char/meson.build b/hw/char/meson.build index afe9a0af88..7ba38dbd96 100644 --- a/hw/char/meson.build +++ b/hw/char/meson.build @@ -8,8 +8,8 @@ softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('imx_serial.c')) softmmu_ss.add(when: 'CONFIG_IPACK', if_true: files('ipoctal232.c')) softmmu_ss.add(when: 'CONFIG_ISA_BUS', if_true: files('parallel-isa.c')) softmmu_ss.add(when: 'CONFIG_ISA_DEBUG', if_true: files('debugcon.c')) -softmmu_ss.add(when: 'CONFIG_LM32', if_true: files('lm32_juart.c')) -softmmu_ss.add(when: 'CONFIG_LM32', if_true: files('lm32_uart.c')) +softmmu_ss.add(when: 'CONFIG_LM32_DEVICES', if_true: files('lm32_juart.c')) +softmmu_ss.add(when: 'CONFIG_LM32_DEVICES', if_true: files('lm32_uart.c')) softmmu_ss.add(when: 'CONFIG_MILKYMIST', if_true: files('milkymist-uart.c')) softmmu_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_uart.c')) softmmu_ss.add(when: 'CONFIG_PARALLEL', if_true: files('parallel.c')) diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 6784d32920..93907e82a3 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -1992,7 +1992,7 @@ static void qxl_dirty_surfaces(PCIQXLDevice *qxl) } } -static void qxl_vm_change_state_handler(void *opaque, int running, +static void qxl_vm_change_state_handler(void *opaque, bool running, RunState state) { PCIQXLDevice *qxl = opaque; diff --git a/hw/display/sm501.c b/hw/display/sm501.c index 8966b69bc7..8789722ef2 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -1558,86 +1558,85 @@ typedef void draw_hwc_line_func(uint8_t *d, const uint8_t *s, int width, const uint8_t *palette, int c_x, int c_y); -#define DEPTH 8 -#include "sm501_template.h" - -#define DEPTH 15 -#include "sm501_template.h" - -#define BGR_FORMAT -#define DEPTH 15 -#include "sm501_template.h" - -#define DEPTH 16 -#include "sm501_template.h" - -#define BGR_FORMAT -#define DEPTH 16 -#include "sm501_template.h" - -#define DEPTH 32 -#include "sm501_template.h" - -#define BGR_FORMAT -#define DEPTH 32 -#include "sm501_template.h" - -static draw_line_func *draw_line8_funcs[] = { - draw_line8_8, - draw_line8_15, - draw_line8_16, - draw_line8_32, - draw_line8_32bgr, - draw_line8_15bgr, - draw_line8_16bgr, -}; - -static draw_line_func *draw_line16_funcs[] = { - draw_line16_8, - draw_line16_15, - draw_line16_16, - draw_line16_32, - draw_line16_32bgr, - draw_line16_15bgr, - draw_line16_16bgr, -}; +static void draw_line8_32(uint8_t *d, const uint8_t *s, int width, + const uint32_t *pal) +{ + uint8_t v, r, g, b; + do { + v = ldub_p(s); + r = (pal[v] >> 16) & 0xff; + g = (pal[v] >> 8) & 0xff; + b = (pal[v] >> 0) & 0xff; + *(uint32_t *)d = rgb_to_pixel32(r, g, b); + s++; + d += 4; + } while (--width != 0); +} -static draw_line_func *draw_line32_funcs[] = { - draw_line32_8, - draw_line32_15, - draw_line32_16, - draw_line32_32, - draw_line32_32bgr, - draw_line32_15bgr, - draw_line32_16bgr, -}; +static void draw_line16_32(uint8_t *d, const uint8_t *s, int width, + const uint32_t *pal) +{ + uint16_t rgb565; + uint8_t r, g, b; + + do { + rgb565 = lduw_le_p(s); + r = (rgb565 >> 8) & 0xf8; + g = (rgb565 >> 3) & 0xfc; + b = (rgb565 << 3) & 0xf8; + *(uint32_t *)d = rgb_to_pixel32(r, g, b); + s += 2; + d += 4; + } while (--width != 0); +} -static draw_hwc_line_func *draw_hwc_line_funcs[] = { - draw_hwc_line_8, - draw_hwc_line_15, - draw_hwc_line_16, - draw_hwc_line_32, - draw_hwc_line_32bgr, - draw_hwc_line_15bgr, - draw_hwc_line_16bgr, -}; +static void draw_line32_32(uint8_t *d, const uint8_t *s, int width, + const uint32_t *pal) +{ + uint8_t r, g, b; + + do { + r = s[2]; + g = s[1]; + b = s[0]; + *(uint32_t *)d = rgb_to_pixel32(r, g, b); + s += 4; + d += 4; + } while (--width != 0); +} -static inline int get_depth_index(DisplaySurface *surface) +/** + * Draw hardware cursor image on the given line. + */ +static void draw_hwc_line_32(uint8_t *d, const uint8_t *s, int width, + const uint8_t *palette, int c_x, int c_y) { - switch (surface_bits_per_pixel(surface)) { - default: - case 8: - return 0; - case 15: - return 1; - case 16: - return 2; - case 32: - if (is_surface_bgr(surface)) { - return 4; - } else { - return 3; + int i; + uint8_t r, g, b, v, bitset = 0; + + /* get cursor position */ + assert(0 <= c_y && c_y < SM501_HWC_HEIGHT); + s += SM501_HWC_WIDTH * c_y / 4; /* 4 pixels per byte */ + d += c_x * 4; + + for (i = 0; i < SM501_HWC_WIDTH && c_x + i < width; i++) { + /* get pixel value */ + if (i % 4 == 0) { + bitset = ldub_p(s); + s++; } + v = bitset & 3; + bitset >>= 2; + + /* write pixel */ + if (v) { + v--; + r = palette[v * 3 + 0]; + g = palette[v * 3 + 1]; + b = palette[v * 3 + 2]; + *(uint32_t *)d = rgb_to_pixel32(r, g, b); + } + d += 4; } } @@ -1652,7 +1651,6 @@ static void sm501_update_display(void *opaque) int height = get_height(s, crt); int src_bpp = get_bpp(s, crt); int dst_bpp = surface_bytes_per_pixel(surface); - int dst_depth_index = get_depth_index(surface); draw_line_func *draw_line = NULL; draw_hwc_line_func *draw_hwc_line = NULL; int full_update = 0; @@ -1662,6 +1660,8 @@ static void sm501_update_display(void *opaque) uint8_t hwc_palette[3 * 3]; uint8_t *hwc_src = NULL; + assert(dst_bpp == 4); /* Output is always 32-bit RGB */ + if (!((crt ? s->dc_crt_control : s->dc_panel_control) & SM501_DC_CRT_CONTROL_ENABLE)) { return; @@ -1674,13 +1674,13 @@ static void sm501_update_display(void *opaque) /* choose draw_line function */ switch (src_bpp) { case 1: - draw_line = draw_line8_funcs[dst_depth_index]; + draw_line = draw_line8_32; break; case 2: - draw_line = draw_line16_funcs[dst_depth_index]; + draw_line = draw_line16_32; break; case 4: - draw_line = draw_line32_funcs[dst_depth_index]; + draw_line = draw_line32_32; break; default: qemu_log_mask(LOG_GUEST_ERROR, "sm501: update display" @@ -1691,7 +1691,7 @@ static void sm501_update_display(void *opaque) /* set up to draw hardware cursor */ if (is_hwc_enabled(s, crt)) { /* choose cursor draw line function */ - draw_hwc_line = draw_hwc_line_funcs[dst_depth_index]; + draw_hwc_line = draw_hwc_line_32; hwc_src = get_hwc_address(s, crt); c_x = get_hwc_x(s, crt); c_y = get_hwc_y(s, crt); diff --git a/hw/display/sm501_template.h b/hw/display/sm501_template.h deleted file mode 100644 index a60abad019..0000000000 --- a/hw/display/sm501_template.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Pixel drawing function templates for QEMU SM501 Device - * - * Copyright (c) 2008 Shin-ichiro KAWASAKI - * - * 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. - */ - -#if DEPTH == 8 -#define BPP 1 -#define PIXEL_TYPE uint8_t -#elif DEPTH == 15 || DEPTH == 16 -#define BPP 2 -#define PIXEL_TYPE uint16_t -#elif DEPTH == 32 -#define BPP 4 -#define PIXEL_TYPE uint32_t -#else -#error unsupport depth -#endif - -#ifdef BGR_FORMAT -#define PIXEL_NAME glue(DEPTH, bgr) -#else -#define PIXEL_NAME DEPTH -#endif /* BGR_FORMAT */ - - -static void glue(draw_line8_, PIXEL_NAME)( - uint8_t *d, const uint8_t *s, int width, const uint32_t *pal) -{ - uint8_t v, r, g, b; - do { - v = ldub_p(s); - r = (pal[v] >> 16) & 0xff; - g = (pal[v] >> 8) & 0xff; - b = (pal[v] >> 0) & 0xff; - *(PIXEL_TYPE *)d = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b); - s++; - d += BPP; - } while (--width != 0); -} - -static void glue(draw_line16_, PIXEL_NAME)( - uint8_t *d, const uint8_t *s, int width, const uint32_t *pal) -{ - uint16_t rgb565; - uint8_t r, g, b; - - do { - rgb565 = lduw_le_p(s); - r = (rgb565 >> 8) & 0xf8; - g = (rgb565 >> 3) & 0xfc; - b = (rgb565 << 3) & 0xf8; - *(PIXEL_TYPE *)d = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b); - s += 2; - d += BPP; - } while (--width != 0); -} - -static void glue(draw_line32_, PIXEL_NAME)( - uint8_t *d, const uint8_t *s, int width, const uint32_t *pal) -{ - uint8_t r, g, b; - - do { - r = s[2]; - g = s[1]; - b = s[0]; - *(PIXEL_TYPE *)d = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b); - s += 4; - d += BPP; - } while (--width != 0); -} - -/** - * Draw hardware cursor image on the given line. - */ -static void glue(draw_hwc_line_, PIXEL_NAME)(uint8_t *d, const uint8_t *s, - int width, const uint8_t *palette, int c_x, int c_y) -{ - int i; - uint8_t r, g, b, v, bitset = 0; - - /* get cursor position */ - assert(0 <= c_y && c_y < SM501_HWC_HEIGHT); - s += SM501_HWC_WIDTH * c_y / 4; /* 4 pixels per byte */ - d += c_x * BPP; - - for (i = 0; i < SM501_HWC_WIDTH && c_x + i < width; i++) { - /* get pixel value */ - if (i % 4 == 0) { - bitset = ldub_p(s); - s++; - } - v = bitset & 3; - bitset >>= 2; - - /* write pixel */ - if (v) { - v--; - r = palette[v * 3 + 0]; - g = palette[v * 3 + 1]; - b = palette[v * 3 + 2]; - *(PIXEL_TYPE *)d = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b); - } - d += BPP; - } -} - -#undef DEPTH -#undef BPP -#undef PIXEL_TYPE -#undef PIXEL_NAME -#undef BGR_FORMAT diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index a01f9315e1..6cdaa1c73b 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -325,7 +325,6 @@ vhost_user_gpu_chr_read(void *opaque) } msg = g_malloc(VHOST_USER_GPU_HDR_SIZE + size); - g_return_if_fail(msg != NULL); r = qemu_chr_fe_read_all(&g->vhost_chr, (uint8_t *)&msg->payload, size); diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c index 9eb489077b..d98964858e 100644 --- a/hw/display/virtio-gpu-3d.c +++ b/hw/display/virtio-gpu-3d.c @@ -438,7 +438,7 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, break; case VIRTIO_GPU_CMD_RESOURCE_FLUSH: virgl_cmd_resource_flush(g, cmd); - break; + break; case VIRTIO_GPU_CMD_RESOURCE_UNREF: virgl_cmd_resource_unref(g, cmd); break; @@ -456,7 +456,6 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, case VIRTIO_GPU_CMD_GET_CAPSET: virgl_cmd_get_capset(g, cmd); break; - case VIRTIO_GPU_CMD_GET_DISPLAY_INFO: virtio_gpu_get_display_info(g, cmd); break; diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c index 2d8a366369..51872dd84c 100644 --- a/hw/i386/kvm/clock.c +++ b/hw/i386/kvm/clock.c @@ -162,7 +162,7 @@ static void do_kvmclock_ctrl(CPUState *cpu, run_on_cpu_data data) } } -static void kvmclock_vm_state_change(void *opaque, int running, +static void kvmclock_vm_state_change(void *opaque, bool running, RunState state) { KVMClockState *s = opaque; diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c index c73254e886..c558893961 100644 --- a/hw/i386/kvm/i8254.c +++ b/hw/i386/kvm/i8254.c @@ -239,7 +239,7 @@ static void kvm_pit_irq_control(void *opaque, int n, int enable) kvm_pit_put(pit); } -static void kvm_pit_vm_state_change(void *opaque, int running, +static void kvm_pit_vm_state_change(void *opaque, bool running, RunState state) { KVMPITState *s = opaque; diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c index 2c1898032e..46315445d2 100644 --- a/hw/i386/kvmvapic.c +++ b/hw/i386/kvmvapic.c @@ -748,7 +748,7 @@ static void do_vapic_enable(CPUState *cs, run_on_cpu_data data) s->state = VAPIC_ACTIVE; } -static void kvmvapic_vm_state_change(void *opaque, int running, +static void kvmvapic_vm_state_change(void *opaque, bool running, RunState state) { MachineState *ms = MACHINE(qdev_get_machine()); diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 68821d90f5..7ce672e5a5 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -1235,7 +1235,7 @@ static void xen_main_loop_prepare(XenIOState *state) } -static void xen_hvm_change_state_handler(void *opaque, int running, +static void xen_hvm_change_state_handler(void *opaque, bool running, RunState rstate) { XenIOState *state = opaque; diff --git a/hw/ide/core.c b/hw/ide/core.c index 81db2c95de..fd69ca3167 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2677,7 +2677,7 @@ static void ide_restart_bh(void *opaque) } } -static void ide_restart_cb(void *opaque, int running, RunState state) +static void ide_restart_cb(void *opaque, bool running, RunState state) { IDEBus *bus = opaque; diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c index 057cb53f13..b554d2ede0 100644 --- a/hw/intc/arm_gicv3_its_kvm.c +++ b/hw/intc/arm_gicv3_its_kvm.c @@ -71,7 +71,7 @@ static int kvm_its_send_msi(GICv3ITSState *s, uint32_t value, uint16_t devid) * * The tables get flushed to guest RAM whenever the VM gets stopped. */ -static void vm_change_state_handler(void *opaque, int running, +static void vm_change_state_handler(void *opaque, bool running, RunState state) { GICv3ITSState *s = (GICv3ITSState *)opaque; diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index d040a5d1e9..65a4c880a3 100644 --- a/hw/intc/arm_gicv3_kvm.c +++ b/hw/intc/arm_gicv3_kvm.c @@ -743,7 +743,7 @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = { * * The tables get flushed to guest RAM whenever the VM gets stopped. */ -static void vm_change_state_handler(void *opaque, int running, +static void vm_change_state_handler(void *opaque, bool running, RunState state) { GICv3State *s = (GICv3State *)opaque; diff --git a/hw/intc/meson.build b/hw/intc/meson.build index b3d9345a0d..8df3656419 100644 --- a/hw/intc/meson.build +++ b/hw/intc/meson.build @@ -14,7 +14,7 @@ softmmu_ss.add(when: 'CONFIG_HEATHROW_PIC', if_true: files('heathrow_pic.c')) softmmu_ss.add(when: 'CONFIG_I8259', if_true: files('i8259_common.c', 'i8259.c')) softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('imx_avic.c', 'imx_gpcv2.c')) softmmu_ss.add(when: 'CONFIG_IOAPIC', if_true: files('ioapic_common.c')) -softmmu_ss.add(when: 'CONFIG_LM32', if_true: files('lm32_pic.c')) +softmmu_ss.add(when: 'CONFIG_LM32_DEVICES', if_true: files('lm32_pic.c')) softmmu_ss.add(when: 'CONFIG_OPENPIC', if_true: files('openpic.c')) softmmu_ss.add(when: 'CONFIG_PL190', if_true: files('pl190.c')) softmmu_ss.add(when: 'CONFIG_PUV3', if_true: files('puv3_intc.c')) diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index acc8c3650c..c008331160 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -504,7 +504,7 @@ static int kvmppc_xive_get_queues(SpaprXive *xive, Error **errp) * runs again. If an interrupt was queued while the VM was stopped, * simply generate a trigger. */ -static void kvmppc_xive_change_state_handler(void *opaque, int running, +static void kvmppc_xive_change_state_handler(void *opaque, bool running, RunState state) { SpaprXive *xive = opaque; diff --git a/hw/lm32/Kconfig b/hw/lm32/Kconfig index ed2e3060b0..8ac94205d7 100644 --- a/hw/lm32/Kconfig +++ b/hw/lm32/Kconfig @@ -1,14 +1,18 @@ -config LM32 +config LM32_DEVICES bool select PTIMER - select PFLASH_CFI02 config MILKYMIST bool # FIXME: disabling it results in compile-time errors select MILKYMIST_TMU2 if OPENGL && X11 - select PTIMER select PFLASH_CFI01 select FRAMEBUFFER select SD select USB_OHCI + select LM32_DEVICES + +config LM32_EVR + bool + select LM32_DEVICES + select PFLASH_CFI02 diff --git a/hw/lm32/meson.build b/hw/lm32/meson.build index 8caf0a727f..42d6f8db3d 100644 --- a/hw/lm32/meson.build +++ b/hw/lm32/meson.build @@ -1,6 +1,6 @@ lm32_ss = ss.source_set() # LM32 boards -lm32_ss.add(when: 'CONFIG_LM32', if_true: files('lm32_boards.c')) +lm32_ss.add(when: 'CONFIG_LM32_EVR', if_true: files('lm32_boards.c')) lm32_ss.add(when: 'CONFIG_MILKYMIST', if_true: files('milkymist.c')) hw_arch += {'lm32': lm32_ss} diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index 488d086a17..ca2f939dd5 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -1098,7 +1098,7 @@ static void mac_via_init(Object *obj) TYPE_ADB_BUS, DEVICE(obj), "adb.0"); } -static void postload_update_cb(void *opaque, int running, RunState state) +static void postload_update_cb(void *opaque, bool running, RunState state) { MacVIAState *m = MAC_VIA(opaque); diff --git a/hw/misc/trace-events b/hw/misc/trace-events index 4b15db8ca4..cae005549e 100644 --- a/hw/misc/trace-events +++ b/hw/misc/trace-events @@ -127,7 +127,7 @@ npcm7xx_pwm_update_freq(const char *id, uint8_t index, uint32_t old_value, uint3 npcm7xx_pwm_update_duty(const char *id, uint8_t index, uint32_t old_value, uint32_t new_value) "%s pwm[%u] Update Duty: old_duty: %u, new_duty: %u" # stm32f4xx_syscfg.c -stm32f4xx_syscfg_set_irq(int gpio, int line, int level) "Interupt: GPIO: %d, Line: %d; Level: %d" +stm32f4xx_syscfg_set_irq(int gpio, int line, int level) "Interrupt: GPIO: %d, Line: %d; Level: %d" stm32f4xx_pulse_exti(int irq) "Pulse EXTI: %d" stm32f4xx_syscfg_read(uint64_t addr) "reg read: addr: 0x%" PRIx64 " " stm32f4xx_syscfg_write(uint64_t addr, uint64_t data) "reg write: addr: 0x%" PRIx64 " val: 0x%" PRIx64 "" diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c index 042768922c..bf91803d65 100644 --- a/hw/net/allwinner-sun8i-emac.c +++ b/hw/net/allwinner-sun8i-emac.c @@ -579,7 +579,7 @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset, case REG_INT_STA: /* Interrupt Status */ value = s->int_sta; break; - case REG_INT_EN: /* Interupt Enable */ + case REG_INT_EN: /* Interrupt Enable */ value = s->int_en; break; case REG_TX_CTL_0: /* Transmit Control 0 */ diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 4dcb92d966..b75f2ab8fc 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -3298,7 +3298,7 @@ e1000e_autoneg_resume(E1000ECore *core) } static void -e1000e_vm_state_change(void *opaque, int running, RunState state) +e1000e_vm_state_change(void *opaque, bool running, RunState state) { E1000ECore *core = opaque; diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c index 93886bba60..bd9d62b559 100644 --- a/hw/net/fsl_etsec/etsec.c +++ b/hw/net/fsl_etsec/etsec.c @@ -27,6 +27,7 @@ */ #include "qemu/osdep.h" +#include "qemu-common.h" #include "hw/sysbus.h" #include "hw/irq.h" #include "hw/ptimer.h" diff --git a/hw/net/fsl_etsec/rings.c b/hw/net/fsl_etsec/rings.c index fe055d3381..d6be0d7d18 100644 --- a/hw/net/fsl_etsec/rings.c +++ b/hw/net/fsl_etsec/rings.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" +#include "qemu-common.h" #include "net/checksum.h" #include "qemu/log.h" #include "etsec.h" diff --git a/hw/nvram/spapr_nvram.c b/hw/nvram/spapr_nvram.c index 9e51bc82ae..01f7752014 100644 --- a/hw/nvram/spapr_nvram.c +++ b/hw/nvram/spapr_nvram.c @@ -217,7 +217,7 @@ static int spapr_nvram_pre_load(void *opaque) return 0; } -static void postload_update_cb(void *opaque, int running, RunState state) +static void postload_update_cb(void *opaque, bool running, RunState state) { SpaprNvram *nvram = opaque; diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 01517a6c6c..1d94485ac8 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -231,6 +231,7 @@ static int create_devtree_etsec(SysBusDevice *sbdev, PlatformDevtreeData *data) assert(irq2 >= 0); qemu_fdt_add_subnode(fdt, node); + qemu_fdt_setprop(fdt, node, "ranges", NULL, 0); qemu_fdt_setprop_string(fdt, node, "device_type", "network"); qemu_fdt_setprop_string(fdt, node, "compatible", "fsl,etsec2"); qemu_fdt_setprop_string(fdt, node, "model", "eTSEC"); diff --git a/hw/ppc/pnv_bmc.c b/hw/ppc/pnv_bmc.c index b9bf5735ea..75a22ce50b 100644 --- a/hw/ppc/pnv_bmc.c +++ b/hw/ppc/pnv_bmc.c @@ -233,7 +233,7 @@ static void hiomap_cmd(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len, case HIOMAP_C_RESET: case HIOMAP_C_LOCK: default: - qemu_log_mask(LOG_GUEST_ERROR, "HIOMAP: unknow command %02X\n", cmd[2]); + qemu_log_mask(LOG_GUEST_ERROR, "HIOMAP: unknown command %02X\n", cmd[2]); break; } } diff --git a/hw/ppc/pnv_xscom.c b/hw/ppc/pnv_xscom.c index e9ae1569ff..be7018e8ac 100644 --- a/hw/ppc/pnv_xscom.c +++ b/hw/ppc/pnv_xscom.c @@ -308,7 +308,7 @@ void pnv_xscom_add_subregion(PnvChip *chip, hwaddr offset, MemoryRegion *mr) } void pnv_xscom_region_init(MemoryRegion *mr, - struct Object *owner, + Object *owner, const MemoryRegionOps *ops, void *opaque, const char *name, diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index 5cbbff1f8d..bf28d6bfc8 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -1059,7 +1059,7 @@ static void timebase_load(PPCTimebase *tb) } } -void cpu_ppc_clock_vm_state_change(void *opaque, int running, +void cpu_ppc_clock_vm_state_change(void *opaque, bool running, RunState state) { PPCTimebase *tb = opaque; diff --git a/hw/ppc/ppc_booke.c b/hw/ppc/ppc_booke.c index 652a21b806..974c0c8a75 100644 --- a/hw/ppc/ppc_booke.c +++ b/hw/ppc/ppc_booke.c @@ -317,7 +317,7 @@ static void ppc_booke_timer_reset_handle(void *opaque) * action will be taken. To avoid this we always clear the watchdog state when * state changes to running. */ -static void cpu_state_change_handler(void *opaque, int running, RunState state) +static void cpu_state_change_handler(void *opaque, bool running, RunState state) { PowerPCCPU *cpu = opaque; CPUPPCState *env = &cpu->env; diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 85fe65f894..d56418ca29 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -28,6 +28,7 @@ #include "qemu-common.h" #include "qemu/datadir.h" #include "qapi/error.h" +#include "qapi/qapi-events-machine.h" #include "qapi/visitor.h" #include "sysemu/sysemu.h" #include "sysemu/hostmem.h" @@ -3575,6 +3576,57 @@ static SpaprDimmState *spapr_recover_pending_dimm_state(SpaprMachineState *ms, return spapr_pending_dimm_unplugs_add(ms, avail_lmbs, dimm); } +void spapr_memory_unplug_rollback(SpaprMachineState *spapr, DeviceState *dev) +{ + SpaprDimmState *ds; + PCDIMMDevice *dimm; + SpaprDrc *drc; + uint32_t nr_lmbs; + uint64_t size, addr_start, addr; + g_autofree char *qapi_error = NULL; + int i; + + if (!dev) { + return; + } + + dimm = PC_DIMM(dev); + ds = spapr_pending_dimm_unplugs_find(spapr, dimm); + + /* + * 'ds == NULL' would mean that the DIMM doesn't have a pending + * unplug state, but one of its DRC is marked as unplug_requested. + * This is bad and weird enough to g_assert() out. + */ + g_assert(ds); + + spapr_pending_dimm_unplugs_remove(spapr, ds); + + size = memory_device_get_region_size(MEMORY_DEVICE(dimm), &error_abort); + nr_lmbs = size / SPAPR_MEMORY_BLOCK_SIZE; + + addr_start = object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PROP, + &error_abort); + + addr = addr_start; + for (i = 0; i < nr_lmbs; i++) { + drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB, + addr / SPAPR_MEMORY_BLOCK_SIZE); + g_assert(drc); + + drc->unplug_requested = false; + addr += SPAPR_MEMORY_BLOCK_SIZE; + } + + /* + * Tell QAPI that something happened and the memory + * hotunplug wasn't successful. + */ + qapi_error = g_strdup_printf("Memory hotunplug rejected by the guest " + "for device %s", dev->id); + qapi_event_send_mem_unplug_error(dev->id, qapi_error); +} + /* Callback to be called during DRC release. */ void spapr_lmb_release(DeviceState *dev) { @@ -3654,13 +3706,12 @@ static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev, addr / SPAPR_MEMORY_BLOCK_SIZE); g_assert(drc); - spapr_drc_detach(drc); + spapr_drc_unplug_request(drc); addr += SPAPR_MEMORY_BLOCK_SIZE; } drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB, addr_start / SPAPR_MEMORY_BLOCK_SIZE); - g_assert(drc); spapr_hotplug_req_remove_by_count_indexed(SPAPR_DR_CONNECTOR_TYPE_LMB, nr_lmbs, spapr_drc_index(drc)); } @@ -3722,8 +3773,12 @@ void spapr_core_unplug_request(HotplugHandler *hotplug_dev, DeviceState *dev, g_assert(drc); if (!spapr_drc_unplug_requested(drc)) { - spapr_drc_detach(drc); + spapr_drc_unplug_request(drc); spapr_hotplug_req_remove_by_index(drc); + } else { + error_setg(errp, "core-id %d unplug is still pending, %d seconds " + "timeout remaining", + cc->core_id, spapr_drc_unplug_timeout_remaining_sec(drc)); } } @@ -3985,8 +4040,12 @@ static void spapr_phb_unplug_request(HotplugHandler *hotplug_dev, assert(drc); if (!spapr_drc_unplug_requested(drc)) { - spapr_drc_detach(drc); + spapr_drc_unplug_request(drc); spapr_hotplug_req_remove_by_index(drc); + } else { + error_setg(errp, + "PCI Host Bridge unplug already in progress for device %s", + dev->id); } } diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 8571d5bafe..8a71b03800 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -50,6 +50,22 @@ uint32_t spapr_drc_index(SpaprDrc *drc) | (drc->id & DRC_INDEX_ID_MASK); } +static void spapr_drc_release(SpaprDrc *drc) +{ + SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); + + drck->release(drc->dev); + + drc->unplug_requested = false; + timer_del(drc->unplug_timeout_timer); + + g_free(drc->fdt); + drc->fdt = NULL; + drc->fdt_start_offset = 0; + object_property_del(OBJECT(drc), "device"); + drc->dev = NULL; +} + static uint32_t drc_isolate_physical(SpaprDrc *drc) { switch (drc->state) { @@ -68,7 +84,7 @@ static uint32_t drc_isolate_physical(SpaprDrc *drc) if (drc->unplug_requested) { uint32_t drc_index = spapr_drc_index(drc); trace_spapr_drc_set_isolation_state_finalizing(drc_index); - spapr_drc_detach(drc); + spapr_drc_release(drc); } return RTAS_OUT_SUCCESS; @@ -132,19 +148,6 @@ static uint32_t drc_isolate_logical(SpaprDrc *drc) drc->state = SPAPR_DRC_STATE_LOGICAL_AVAILABLE; - /* if we're awaiting release, but still in an unconfigured state, - * it's likely the guest is still in the process of configuring - * the device and is transitioning the devices to an ISOLATED - * state as a part of that process. so we only complete the - * removal when this transition happens for a device in a - * configured state, as suggested by the state diagram from PAPR+ - * 2.7, 13.4 - */ - if (drc->unplug_requested) { - uint32_t drc_index = spapr_drc_index(drc); - trace_spapr_drc_set_isolation_state_finalizing(drc_index); - spapr_drc_detach(drc); - } return RTAS_OUT_SUCCESS; } @@ -222,7 +225,7 @@ static uint32_t drc_set_unusable(SpaprDrc *drc) if (drc->unplug_requested) { uint32_t drc_index = spapr_drc_index(drc); trace_spapr_drc_set_allocation_state_finalizing(drc_index); - spapr_drc_detach(drc); + spapr_drc_release(drc); } return RTAS_OUT_SUCCESS; @@ -369,6 +372,17 @@ static void prop_get_fdt(Object *obj, Visitor *v, const char *name, } while (fdt_depth != 0); } +static void spapr_drc_start_unplug_timeout_timer(SpaprDrc *drc) +{ + SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); + + if (drck->unplug_timeout_seconds != 0) { + timer_mod(drc->unplug_timeout_timer, + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + + drck->unplug_timeout_seconds * 1000); + } +} + void spapr_drc_attach(SpaprDrc *drc, DeviceState *d) { trace_spapr_drc_attach(spapr_drc_index(drc)); @@ -385,30 +399,18 @@ void spapr_drc_attach(SpaprDrc *drc, DeviceState *d) NULL, 0); } -static void spapr_drc_release(SpaprDrc *drc) -{ - SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); - - drck->release(drc->dev); - - drc->unplug_requested = false; - g_free(drc->fdt); - drc->fdt = NULL; - drc->fdt_start_offset = 0; - object_property_del(OBJECT(drc), "device"); - drc->dev = NULL; -} - -void spapr_drc_detach(SpaprDrc *drc) +void spapr_drc_unplug_request(SpaprDrc *drc) { SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); - trace_spapr_drc_detach(spapr_drc_index(drc)); + trace_spapr_drc_unplug_request(spapr_drc_index(drc)); g_assert(drc->dev); drc->unplug_requested = true; + spapr_drc_start_unplug_timeout_timer(drc); + if (drc->state != drck->empty_state) { trace_spapr_drc_awaiting_quiesce(spapr_drc_index(drc)); return; @@ -417,6 +419,15 @@ void spapr_drc_detach(SpaprDrc *drc) spapr_drc_release(drc); } +int spapr_drc_unplug_timeout_remaining_sec(SpaprDrc *drc) +{ + if (drc->unplug_requested) { + return timer_deadline_ms(drc->unplug_timeout_timer) / 1000; + } + + return 0; +} + bool spapr_drc_reset(SpaprDrc *drc) { SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); @@ -488,11 +499,23 @@ static bool spapr_drc_needed(void *opaque) spapr_drc_unplug_requested(drc); } +static int spapr_drc_post_load(void *opaque, int version_id) +{ + SpaprDrc *drc = opaque; + + if (drc->unplug_requested) { + spapr_drc_start_unplug_timeout_timer(drc); + } + + return 0; +} + static const VMStateDescription vmstate_spapr_drc = { .name = "spapr_drc", .version_id = 1, .minimum_version_id = 1, .needed = spapr_drc_needed, + .post_load = spapr_drc_post_load, .fields = (VMStateField []) { VMSTATE_UINT32(state, SpaprDrc), VMSTATE_END_OF_LIST() @@ -503,6 +526,15 @@ static const VMStateDescription vmstate_spapr_drc = { } }; +static void drc_unplug_timeout_cb(void *opaque) +{ + SpaprDrc *drc = opaque; + + if (drc->unplug_requested) { + drc->unplug_requested = false; + } +} + static void drc_realize(DeviceState *d, Error **errp) { SpaprDrc *drc = SPAPR_DR_CONNECTOR(d); @@ -525,6 +557,11 @@ static void drc_realize(DeviceState *d, Error **errp) object_property_add_alias(root_container, link_name, drc->owner, child_name); g_free(link_name); + + drc->unplug_timeout_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, + drc_unplug_timeout_cb, + drc); + vmstate_register(VMSTATE_IF(drc), spapr_drc_index(drc), &vmstate_spapr_drc, drc); trace_spapr_drc_realize_complete(spapr_drc_index(drc)); @@ -542,6 +579,7 @@ static void drc_unrealize(DeviceState *d) name = g_strdup_printf("%x", spapr_drc_index(drc)); object_property_del(root_container, name); g_free(name); + timer_free(drc->unplug_timeout_timer); } SpaprDrc *spapr_dr_connector_new(Object *owner, const char *type, @@ -683,6 +721,7 @@ static void spapr_drc_cpu_class_init(ObjectClass *k, void *data) drck->drc_name_prefix = "CPU "; drck->release = spapr_core_release; drck->dt_populate = spapr_core_dt_populate; + drck->unplug_timeout_seconds = 15; } static void spapr_drc_pci_class_init(ObjectClass *k, void *data) @@ -1190,6 +1229,15 @@ static void rtas_ibm_configure_connector(PowerPCCPU *cpu, drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); + /* + * This indicates that the kernel is reconfiguring a LMB due to + * a failed hotunplug. Rollback the DIMM unplug process. + */ + if (spapr_drc_type(drc) == SPAPR_DR_CONNECTOR_TYPE_LMB && + drc->unplug_requested) { + spapr_memory_unplug_rollback(spapr, drc->dev); + } + if (!drc->fdt) { void *fdt; int fdt_size; diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index f1c7479816..feba18cb12 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1723,12 +1723,12 @@ static void spapr_pci_unplug_request(HotplugHandler *plug_handler, * functions, even if their unplug weren't requested * beforehand. */ - spapr_drc_detach(func_drc); + spapr_drc_unplug_request(func_drc); } } } - spapr_drc_detach(drc); + spapr_drc_unplug_request(drc); /* if this isn't func 0, defer unplug event. otherwise signal removal * for all present functions @@ -1743,6 +1743,10 @@ static void spapr_pci_unplug_request(HotplugHandler *plug_handler, } } } + } else { + error_setg(errp, + "PCI device unplug already in progress for device %s", + drc->dev->id); } } diff --git a/hw/ppc/trace-events b/hw/ppc/trace-events index 1e91984526..b4bbfbb013 100644 --- a/hw/ppc/trace-events +++ b/hw/ppc/trace-events @@ -50,7 +50,7 @@ spapr_drc_set_allocation_state(uint32_t index, int state) "drc: 0x%"PRIx32", sta spapr_drc_set_allocation_state_finalizing(uint32_t index) "drc: 0x%"PRIx32 spapr_drc_set_configured(uint32_t index) "drc: 0x%"PRIx32 spapr_drc_attach(uint32_t index) "drc: 0x%"PRIx32 -spapr_drc_detach(uint32_t index) "drc: 0x%"PRIx32 +spapr_drc_unplug_request(uint32_t index) "drc: 0x%"PRIx32 spapr_drc_awaiting_quiesce(uint32_t index) "drc: 0x%"PRIx32 spapr_drc_reset(uint32_t index) "drc: 0x%"PRIx32 spapr_drc_realize(uint32_t index) "drc: 0x%"PRIx32 diff --git a/hw/s390x/tod-kvm.c b/hw/s390x/tod-kvm.c index 6e21d83181..0b94477486 100644 --- a/hw/s390x/tod-kvm.c +++ b/hw/s390x/tod-kvm.c @@ -78,7 +78,7 @@ static void kvm_s390_tod_set(S390TODState *td, const S390TOD *tod, Error **errp) } } -static void kvm_s390_tod_vm_state_change(void *opaque, int running, +static void kvm_s390_tod_vm_state_change(void *opaque, bool running, RunState state) { S390TODState *td = opaque; diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 2d674f94d7..2a0a98cac9 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -181,7 +181,7 @@ void scsi_req_retry(SCSIRequest *req) req->retry = true; } -static void scsi_dma_restart_cb(void *opaque, int running, RunState state) +static void scsi_dma_restart_cb(void *opaque, bool running, RunState state) { SCSIDevice *s = opaque; diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index bd7103cd0e..2eaea7e637 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2565,6 +2565,7 @@ static void scsi_disk_new_request_dump(uint32_t lun, uint32_t tag, uint8_t *buf) int len = scsi_cdb_length(buf); char *line_buffer, *p; + assert(len > 0 && len <= 16); line_buffer = g_malloc(len * 5 + 1); for (i = 0, p = line_buffer; i < len; i++) { diff --git a/hw/timer/meson.build b/hw/timer/meson.build index a429792b08..598d058506 100644 --- a/hw/timer/meson.build +++ b/hw/timer/meson.build @@ -19,7 +19,7 @@ softmmu_ss.add(when: 'CONFIG_HPET', if_true: files('hpet.c')) softmmu_ss.add(when: 'CONFIG_I8254', if_true: files('i8254_common.c', 'i8254.c')) softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('imx_epit.c')) softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('imx_gpt.c')) -softmmu_ss.add(when: 'CONFIG_LM32', if_true: files('lm32_timer.c')) +softmmu_ss.add(when: 'CONFIG_LM32_DEVICES', if_true: files('lm32_timer.c')) softmmu_ss.add(when: 'CONFIG_MILKYMIST', if_true: files('milkymist-sysctl.c')) softmmu_ss.add(when: 'CONFIG_MIPS_CPS', if_true: files('mips_gictimer.c')) softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('mss-timer.c')) diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c index 2d566f7db1..5c76bed77a 100644 --- a/hw/usb/ccid-card-emulated.c +++ b/hw/usb/ccid-card-emulated.c @@ -301,7 +301,7 @@ static void *event_thread(void *arg) } else { if (event->reader != card->reader) { fprintf(stderr, - "ERROR: wrong reader: quiting event_thread\n"); + "ERROR: wrong reader: quitting event_thread\n"); break; } } diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 212eb05d3d..f71af0ad2d 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -2436,7 +2436,7 @@ static int usb_ehci_post_load(void *opaque, int version_id) return 0; } -static void usb_ehci_vm_state_change(void *opaque, int running, RunState state) +static void usb_ehci_vm_state_change(void *opaque, bool running, RunState state) { EHCIState *ehci = opaque; diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index f8c64c8b95..1cf2816772 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -1126,7 +1126,7 @@ static int ohci_service_td(OHCIState *ohci, struct ohci_ed *ed) OHCI_SET_BM(td.flags, TD_EC, 3); break; } - /* An error occured so we have to clear the interrupt counter. See + /* An error occurred so we have to clear the interrupt counter. See * spec at 6.4.4 on page 104 */ ohci->done_count = 0; } diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index 354713a77d..2518306f52 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -1783,7 +1783,7 @@ type_init(usb_host_register_types) static QEMUTimer *usb_auto_timer; static VMChangeStateEntry *usb_vmstate; -static void usb_host_vm_state(void *unused, int running, RunState state) +static void usb_host_vm_state(void *unused, bool running, RunState state) { if (running) { usb_host_auto_check(unused); diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 7e9e3fecbf..17f06f3417 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -1395,7 +1395,7 @@ static void usbredir_chardev_event(void *opaque, QEMUChrEvent event) * init + destroy */ -static void usbredir_vm_state_change(void *priv, int running, RunState state) +static void usbredir_vm_state_change(void *priv, bool running, RunState state) { USBRedirDevice *dev = priv; diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 00daa50ed8..134bdccc4f 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -727,7 +727,7 @@ static SaveVMHandlers savevm_vfio_handlers = { /* ---------------------------------------------------------------------- */ -static void vfio_vmstate_change(void *opaque, int running, RunState state) +static void vfio_vmstate_change(void *opaque, bool running, RunState state) { VFIODevice *vbasedev = opaque; VFIOMigration *migration = vbasedev->migration; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 2a01662b08..e2163a0d63 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -909,7 +909,7 @@ check_dev_state: r = 0; } if (r) { - /* An error is occured. */ + /* An error occurred. */ dev->log_enabled = false; } diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index 76ce937693..cc8e9f775d 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -133,7 +133,7 @@ static uint64_t get_features(VirtIODevice *vdev, uint64_t f, Error **errp) return f; } -static void virtio_rng_vm_state_change(void *opaque, int running, +static void virtio_rng_vm_state_change(void *opaque, bool running, RunState state) { VirtIORNG *vrng = opaque; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 1fd1917ca0..07f4e60b30 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3208,7 +3208,7 @@ void virtio_cleanup(VirtIODevice *vdev) qemu_del_vm_change_state_handler(vdev->vmstate); } -static void virtio_vmstate_change(void *opaque, int running, RunState state) +static void virtio_vmstate_change(void *opaque, bool running, RunState state) { VirtIODevice *vdev = opaque; BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); diff --git a/include/exec/memory.h b/include/exec/memory.h index c6fb714e49..54ccf1a5f0 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -828,7 +828,7 @@ static inline bool MemoryRegionSection_eq(MemoryRegionSection *a, * @size: size of the region; any subregions beyond this size will be clipped */ void memory_region_init(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, uint64_t size); @@ -876,7 +876,7 @@ void memory_region_unref(MemoryRegion *mr); * @size: size of the region. */ void memory_region_init_io(MemoryRegion *mr, - struct Object *owner, + Object *owner, const MemoryRegionOps *ops, void *opaque, const char *name, @@ -898,7 +898,7 @@ void memory_region_init_io(MemoryRegion *mr, * RAM memory region to be migrated; that is the responsibility of the caller. */ void memory_region_init_ram_nomigrate(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, uint64_t size, Error **errp); @@ -920,7 +920,7 @@ void memory_region_init_ram_nomigrate(MemoryRegion *mr, * The only difference is part of the RAM region can be remapped. */ void memory_region_init_ram_shared_nomigrate(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, uint64_t size, bool share, @@ -946,7 +946,7 @@ void memory_region_init_ram_shared_nomigrate(MemoryRegion *mr, * RAM memory region to be migrated; that is the responsibility of the caller. */ void memory_region_init_resizeable_ram(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, uint64_t size, uint64_t max_size, @@ -979,7 +979,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr, * RAM memory region to be migrated; that is the responsibility of the caller. */ void memory_region_init_ram_from_file(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, uint64_t size, uint64_t align, @@ -1005,7 +1005,7 @@ void memory_region_init_ram_from_file(MemoryRegion *mr, * RAM memory region to be migrated; that is the responsibility of the caller. */ void memory_region_init_ram_from_fd(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, uint64_t size, bool share, @@ -1030,7 +1030,7 @@ void memory_region_init_ram_from_fd(MemoryRegion *mr, * RAM memory region to be migrated; that is the responsibility of the caller. */ void memory_region_init_ram_ptr(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, uint64_t size, void *ptr); @@ -1058,7 +1058,7 @@ void memory_region_init_ram_ptr(MemoryRegion *mr, * (For RAM device memory regions, migrating the contents rarely makes sense.) */ void memory_region_init_ram_device_ptr(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, uint64_t size, void *ptr); @@ -1076,7 +1076,7 @@ void memory_region_init_ram_device_ptr(MemoryRegion *mr, * @size: size of the region. */ void memory_region_init_alias(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, MemoryRegion *orig, hwaddr offset, @@ -1101,7 +1101,7 @@ void memory_region_init_alias(MemoryRegion *mr, * @errp: pointer to Error*, to store an error if it happens. */ void memory_region_init_rom_nomigrate(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, uint64_t size, Error **errp); @@ -1124,7 +1124,7 @@ void memory_region_init_rom_nomigrate(MemoryRegion *mr, * @errp: pointer to Error*, to store an error if it happens. */ void memory_region_init_rom_device_nomigrate(MemoryRegion *mr, - struct Object *owner, + Object *owner, const MemoryRegionOps *ops, void *opaque, const char *name, @@ -1183,7 +1183,7 @@ void memory_region_init_iommu(void *_iommu_mr, * If you pass a non-NULL non-device @owner then we will assert. */ void memory_region_init_ram(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, uint64_t size, Error **errp); @@ -1210,7 +1210,7 @@ void memory_region_init_ram(MemoryRegion *mr, * @errp: pointer to Error*, to store an error if it happens. */ void memory_region_init_rom(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, uint64_t size, Error **errp); @@ -1241,7 +1241,7 @@ void memory_region_init_rom(MemoryRegion *mr, * @errp: pointer to Error*, to store an error if it happens. */ void memory_region_init_rom_device(MemoryRegion *mr, - struct Object *owner, + Object *owner, const MemoryRegionOps *ops, void *opaque, const char *name, @@ -1254,7 +1254,7 @@ void memory_region_init_rom_device(MemoryRegion *mr, * * @mr: the memory region being queried. */ -struct Object *memory_region_owner(MemoryRegion *mr); +Object *memory_region_owner(MemoryRegion *mr); /** * memory_region_size: get a memory region's size. diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h index 78409ab34a..6ee458e7bc 100644 --- a/include/hw/elf_ops.h +++ b/include/hw/elf_ops.h @@ -417,7 +417,7 @@ static int glue(load_elf, SZ)(const char *name, int fd, /* * Since we want to be able to modify the mapped buffer, we set the - * 'writeble' parameter to 'true'. Modifications to the buffer are not + * 'writable' parameter to 'true'. Modifications to the buffer are not * written back to the file. */ mapped_file = g_mapped_file_new_from_fd(fd, true, NULL); diff --git a/include/hw/ppc/pnv_xscom.h b/include/hw/ppc/pnv_xscom.h index 8578f5a207..2ff9f7a8d6 100644 --- a/include/hw/ppc/pnv_xscom.h +++ b/include/hw/ppc/pnv_xscom.h @@ -139,7 +139,7 @@ int pnv_dt_xscom(PnvChip *chip, void *fdt, int root_offset, void pnv_xscom_add_subregion(PnvChip *chip, hwaddr offset, MemoryRegion *mr); void pnv_xscom_region_init(MemoryRegion *mr, - struct Object *owner, + Object *owner, const MemoryRegionOps *ops, void *opaque, const char *name, diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index ccbeeca1de..47cebaf3ac 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -847,6 +847,7 @@ int spapr_hpt_shift_for_ramsize(uint64_t ramsize); int spapr_reallocate_hpt(SpaprMachineState *spapr, int shift, Error **errp); void spapr_clear_pending_events(SpaprMachineState *spapr); void spapr_clear_pending_hotplug_events(SpaprMachineState *spapr); +void spapr_memory_unplug_rollback(SpaprMachineState *spapr, DeviceState *dev); int spapr_max_server_number(SpaprMachineState *spapr); void spapr_store_hpte(PowerPCCPU *cpu, hwaddr ptex, uint64_t pte0, uint64_t pte1); diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index 8982927d5c..26599c385a 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -187,6 +187,8 @@ typedef struct SpaprDrc { bool unplug_requested; void *fdt; int fdt_start_offset; + + QEMUTimer *unplug_timeout_timer; } SpaprDrc; struct SpaprMachineState; @@ -209,6 +211,8 @@ typedef struct SpaprDrcClass { int (*dt_populate)(SpaprDrc *drc, struct SpaprMachineState *spapr, void *fdt, int *fdt_start_offset, Error **errp); + + int unplug_timeout_seconds; } SpaprDrcClass; typedef struct SpaprDrcPhysical { @@ -243,7 +247,8 @@ int spapr_dt_drc(void *fdt, int offset, Object *owner, uint32_t drc_type_mask); * beforehand (eg. check drc->dev at pre-plug). */ void spapr_drc_attach(SpaprDrc *drc, DeviceState *d); -void spapr_drc_detach(SpaprDrc *drc); +void spapr_drc_unplug_request(SpaprDrc *drc); +int spapr_drc_unplug_timeout_remaining_sec(SpaprDrc *drc); /* * Reset all DRCs, causing pending hot-plug/unplug requests to complete. diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index 08c869ab0a..7901ab276c 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -133,7 +133,7 @@ struct SubchDev { bool ccw_fmt_1; bool thinint_active; uint8_t ccw_no_data_cnt; - uint16_t migrated_schid; /* used for missmatch detection */ + uint16_t migrated_schid; /* used for mismatch detection */ CcwDataStream cds; /* transport-provided data: */ int (*ccw_cb) (SubchDev *, CCW1); diff --git a/include/qemu-common.h b/include/qemu-common.h index 654621444e..73bcf763ed 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -13,7 +13,7 @@ #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR) /* Copyright string for -version arguments, About dialogs, etc */ -#define QEMU_COPYRIGHT "Copyright (c) 2003-2020 " \ +#define QEMU_COPYRIGHT "Copyright (c) 2003-2021 " \ "Fabrice Bellard and the QEMU Project developers" /* Bug reporting information for --help arguments, About dialogs, etc */ diff --git a/include/qemu/id.h b/include/qemu/id.h index b55c406e69..46b759b284 100644 --- a/include/qemu/id.h +++ b/include/qemu/id.h @@ -5,6 +5,7 @@ typedef enum IdSubSystems { ID_QDEV, ID_BLOCK, ID_CHR, + ID_NET, ID_MAX /* last element, used as array size */ } IdSubSystems; diff --git a/include/qemu/timer.h b/include/qemu/timer.h index 1678238384..5e76e3f8c2 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -795,6 +795,14 @@ static inline int64_t get_max_clock_jump(void) return 60 * NANOSECONDS_PER_SECOND; } +/** + * timer_deadline_ms: + * + * Returns the remaining miliseconds for @timer to expire, or zero + * if the timer is no longer pending. + */ +int64_t timer_deadline_ms(QEMUTimer *timer); + /* * Low level clock functions */ diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index e557f470d4..a535691573 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -6,11 +6,11 @@ bool runstate_check(RunState state); void runstate_set(RunState new_state); -int runstate_is_running(void); +bool runstate_is_running(void); bool runstate_needs_reset(void); bool runstate_store(char *str, size_t size); -typedef void VMChangeStateHandler(void *opaque, int running, RunState state); +typedef void VMChangeStateHandler(void *opaque, bool running, RunState state); VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, void *opaque); @@ -20,7 +20,13 @@ VMChangeStateEntry *qdev_add_vm_change_state_handler(DeviceState *dev, VMChangeStateHandler *cb, void *opaque); void qemu_del_vm_change_state_handler(VMChangeStateEntry *e); -void vm_state_notify(int running, RunState state); +/** + * vm_state_notify: Notify the state of the VM + * + * @running: whether the VM is running or not. + * @state: the #RunState of the VM. + */ +void vm_state_notify(bool running, RunState state); static inline bool shutdown_caused_by_guest(ShutdownCause cause) { @@ -43,6 +43,7 @@ #include "qemu/cutils.h" #include "qemu/config-file.h" #include "qemu/ctype.h" +#include "qemu/id.h" #include "qemu/iov.h" #include "qemu/qemu-print.h" #include "qemu/main-loop.h" @@ -1110,8 +1111,7 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp) /* Create an ID for -net if the user did not specify one */ if (!is_netdev && !qemu_opts_id(opts)) { - static int idx; - qemu_opts_set_id(opts, g_strdup_printf("__org.qemu.net%i", idx++)); + qemu_opts_set_id(opts, id_generate(ID_NET)); } if (visit_type_Netdev(v, NULL, &object, errp)) { @@ -1349,7 +1349,7 @@ void qmp_set_link(const char *name, bool up, Error **errp) } } -static void net_vm_change_state_handler(void *opaque, int running, +static void net_vm_change_state_handler(void *opaque, bool running, RunState state) { NetClientState *nc; @@ -1466,7 +1466,7 @@ static int net_param_nic(void *dummy, QemuOpts *opts, Error **errp) /* Create an ID if the user did not specify one */ nd_id = g_strdup(qemu_opts_id(opts)); if (!nd_id) { - nd_id = g_strdup_printf("__org.qemu.nic%i", idx); + nd_id = id_generate(ID_NET); qemu_opts_set_id(opts, nd_id); } diff --git a/pc-bios/README b/pc-bios/README index db7129ef64..c101c9a04f 100644 --- a/pc-bios/README +++ b/pc-bios/README @@ -14,7 +14,7 @@ - SLOF (Slimline Open Firmware) is a free IEEE 1275 Open Firmware implementation for certain IBM POWER hardware. The sources are at https://github.com/aik/SLOF, and the image currently in qemu is - built from git tag qemu-slof-20200717. + built from git tag qemu-slof-20210217. - sgabios (the Serial Graphics Adapter option ROM) provides a means for legacy x86 software to communicate with an attached serial console as diff --git a/pc-bios/slof.bin b/pc-bios/slof.bin Binary files differindex 448dcada36..3f3918a9e1 100644 --- a/pc-bios/slof.bin +++ b/pc-bios/slof.bin diff --git a/qemu-options.hx b/qemu-options.hx index 90801286c6..622d3bfa5a 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -176,7 +176,7 @@ SRST ``thread=single|multi`` Controls number of TCG threads. When the TCG is multi-threaded - there will be one thread per vCPU therefor taking advantage of + there will be one thread per vCPU therefore taking advantage of additional host cores. The default is to enable multi-threading where both the back-end and front-ends support it and no incompatible TCG features have been enabled (e.g. @@ -2445,7 +2445,7 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, " use 'vhostfd=h' to connect to an already opened vhost net device\n" " use 'vhostfds=x:y:...:z to connect to multiple already opened vhost net devices\n" " use 'queues=n' to specify the number of queues to be created for multiqueue TAP\n" - " use 'poll-us=n' to speciy the maximum number of microseconds that could be\n" + " use 'poll-us=n' to specify the maximum number of microseconds that could be\n" " spent on busy polling for vhost net\n" "-netdev bridge,id=str[,br=bridge][,helper=helper]\n" " configure a host TAP network backend with ID 'str' that is\n" @@ -4299,12 +4299,12 @@ DEF("sandbox", HAS_ARG, QEMU_OPTION_sandbox, \ " use 'obsolete' to allow obsolete system calls that are provided\n" \ " by the kernel, but typically no longer used by modern\n" \ " C library implementations.\n" \ - " use 'elevateprivileges' to allow or deny QEMU process to elevate\n" \ - " its privileges by blacklisting all set*uid|gid system calls.\n" \ + " use 'elevateprivileges' to allow or deny the QEMU process ability\n" \ + " to elevate privileges using set*uid|gid system calls.\n" \ " The value 'children' will deny set*uid|gid system calls for\n" \ " main QEMU process but will allow forks and execves to run unprivileged\n" \ " use 'spawn' to avoid QEMU to spawn new threads or processes by\n" \ - " blacklisting *fork and execve\n" \ + " blocking *fork and execve\n" \ " use 'resourcecontrol' to disable process affinity and schedular priority\n", QEMU_ARCH_ALL) SRST diff --git a/roms/SLOF b/roms/SLOF -Subproject e18ddad8516ff2cfe36ec130200318f7251aa78 +Subproject 33a7322de13e9dca4b38851a345a58d37e7a441 diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index 96b1cd69a5..5bc94d95cf 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -100,7 +100,7 @@ def validate_type(name): if bit == "const": continue if bit not in ALLOWED_TYPES: - raise ValueError("Argument type '%s' is not in whitelist. " + raise ValueError("Argument type '%s' is not allowed. " "Only standard C types and fixed size integer " "types should be used. struct, union, and " "other complex pointer types should be " diff --git a/softmmu/memory.c b/softmmu/memory.c index 874a8fccde..9db47b7db6 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -1581,7 +1581,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr, #ifdef CONFIG_POSIX void memory_region_init_ram_from_file(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, uint64_t size, uint64_t align, @@ -1607,7 +1607,7 @@ void memory_region_init_ram_from_file(MemoryRegion *mr, } void memory_region_init_ram_from_fd(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, uint64_t size, bool share, @@ -1679,7 +1679,7 @@ void memory_region_init_alias(MemoryRegion *mr, } void memory_region_init_rom_nomigrate(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, uint64_t size, Error **errp) @@ -2679,7 +2679,7 @@ static void memory_global_dirty_log_do_stop(void) MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse); } -static void memory_vm_change_state_handler(void *opaque, int running, +static void memory_vm_change_state_handler(void *opaque, bool running, RunState state) { if (running) { @@ -3205,7 +3205,7 @@ void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabled) } void memory_region_init_ram(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, uint64_t size, Error **errp) @@ -3229,7 +3229,7 @@ void memory_region_init_ram(MemoryRegion *mr, } void memory_region_init_rom(MemoryRegion *mr, - struct Object *owner, + Object *owner, const char *name, uint64_t size, Error **errp) @@ -3253,7 +3253,7 @@ void memory_region_init_rom(MemoryRegion *mr, } void memory_region_init_rom_device(MemoryRegion *mr, - struct Object *owner, + Object *owner, const MemoryRegionOps *ops, void *opaque, const char *name, diff --git a/softmmu/qemu-seccomp.c b/softmmu/qemu-seccomp.c index 377ef6937c..9c29d9cf00 100644 --- a/softmmu/qemu-seccomp.c +++ b/softmmu/qemu-seccomp.c @@ -45,8 +45,8 @@ const struct scmp_arg_cmp sched_setscheduler_arg[] = { { .arg = 1, .op = SCMP_CMP_NE, .datum_a = SCHED_IDLE } }; -static const struct QemuSeccompSyscall blacklist[] = { - /* default set of syscalls to blacklist */ +static const struct QemuSeccompSyscall denylist[] = { + /* default set of syscalls that should get blocked */ { SCMP_SYS(reboot), QEMU_SECCOMP_SET_DEFAULT }, { SCMP_SYS(swapon), QEMU_SECCOMP_SET_DEFAULT }, { SCMP_SYS(swapoff), QEMU_SECCOMP_SET_DEFAULT }, @@ -175,18 +175,18 @@ static int seccomp_start(uint32_t seccomp_opts, Error **errp) goto seccomp_return; } - for (i = 0; i < ARRAY_SIZE(blacklist); i++) { + for (i = 0; i < ARRAY_SIZE(denylist); i++) { uint32_t action; - if (!(seccomp_opts & blacklist[i].set)) { + if (!(seccomp_opts & denylist[i].set)) { continue; } - action = qemu_seccomp_get_action(blacklist[i].set); - rc = seccomp_rule_add_array(ctx, action, blacklist[i].num, - blacklist[i].narg, blacklist[i].arg_cmp); + action = qemu_seccomp_get_action(denylist[i].set); + rc = seccomp_rule_add_array(ctx, action, denylist[i].num, + denylist[i].narg, denylist[i].arg_cmp); if (rc < 0) { error_setg_errno(errp, -rc, - "failed to add seccomp blacklist rules"); + "failed to add seccomp denylist rules"); goto seccomp_return; } } diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 2874417b61..ce8977c6a2 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -218,7 +218,7 @@ void runstate_set(RunState new_state) current_run_state = new_state; } -int runstate_is_running(void) +bool runstate_is_running(void) { return runstate_check(RUN_STATE_RUNNING); } @@ -317,7 +317,7 @@ void qemu_del_vm_change_state_handler(VMChangeStateEntry *e) g_free(e); } -void vm_state_notify(int running, RunState state) +void vm_state_notify(bool running, RunState state) { VMChangeStateEntry *e, *next; diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 00e124c812..bebea90122 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -844,7 +844,7 @@ MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run) return MEMTXATTRS_UNSPECIFIED; } -void kvm_arm_vm_state_change(void *opaque, int running, RunState state) +void kvm_arm_vm_state_change(void *opaque, bool running, RunState state) { CPUState *cs = opaque; ARMCPU *cpu = ARM_CPU(cs); diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index eb81b7059e..68ec970c4f 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -352,7 +352,7 @@ void kvm_arm_get_virtual_time(CPUState *cs); */ void kvm_arm_put_virtual_time(CPUState *cs); -void kvm_arm_vm_state_change(void *opaque, int running, RunState state); +void kvm_arm_vm_state_change(void *opaque, bool running, RunState state); int kvm_arm_vgic_probe(void); diff --git a/target/hexagon/gen_tcg_funcs.py b/target/hexagon/gen_tcg_funcs.py index fe4d8e5730..db9f663a77 100755 --- a/target/hexagon/gen_tcg_funcs.py +++ b/target/hexagon/gen_tcg_funcs.py @@ -35,7 +35,7 @@ def gen_decl_ea_tcg(f, tag): def gen_free_ea_tcg(f): f.write(" tcg_temp_free(EA);\n") -def genptr_decl_pair_writeble(f, tag, regtype, regid, regno): +def genptr_decl_pair_writable(f, tag, regtype, regid, regno): regN="%s%sN" % (regtype,regid) f.write(" TCGv_i64 %s%sV = tcg_temp_local_new_i64();\n" % \ (regtype, regid)) @@ -54,7 +54,7 @@ def genptr_decl_pair_writeble(f, tag, regtype, regid, regno): (regN, regN)) f.write(" }\n") -def genptr_decl_writeble(f, tag, regtype, regid, regno): +def genptr_decl_writable(f, tag, regtype, regid, regno): regN="%s%sN" % (regtype,regid) f.write(" TCGv %s%sV = tcg_temp_local_new();\n" % \ (regtype, regid)) @@ -78,12 +78,12 @@ def genptr_decl(f, tag, regtype, regid, regno): f.write(" const int %s = insn->regno[%d];\n" % \ (regN, regno)) elif (regid in {"dd", "ee", "xx", "yy"}): - genptr_decl_pair_writeble(f, tag, regtype, regid, regno) + genptr_decl_pair_writable(f, tag, regtype, regid, regno) elif (regid in {"s", "t", "u", "v"}): f.write(" TCGv %s%sV = hex_gpr[insn->regno[%d]];\n" % \ (regtype, regid, regno)) elif (regid in {"d", "e", "x", "y"}): - genptr_decl_writeble(f, tag, regtype, regid, regno) + genptr_decl_writable(f, tag, regtype, regid, regno) else: print("Bad register parse: ", regtype, regid) elif (regtype == "P"): @@ -91,7 +91,7 @@ def genptr_decl(f, tag, regtype, regid, regno): f.write(" TCGv %s%sV = hex_pred[insn->regno[%d]];\n" % \ (regtype, regid, regno)) elif (regid in {"d", "e", "x"}): - genptr_decl_writeble(f, tag, regtype, regid, regno) + genptr_decl_writable(f, tag, regtype, regid, regno) else: print("Bad register parse: ", regtype, regid) elif (regtype == "C"): @@ -101,14 +101,14 @@ def genptr_decl(f, tag, regtype, regid, regno): f.write(" const int %s = insn->regno[%d] + HEX_REG_SA0;\n" % \ (regN, regno)) elif (regid == "dd"): - genptr_decl_pair_writeble(f, tag, regtype, regid, regno) + genptr_decl_pair_writable(f, tag, regtype, regid, regno) elif (regid == "s"): f.write(" TCGv %s%sV = tcg_temp_local_new();\n" % \ (regtype, regid)) f.write(" const int %s%sN = insn->regno[%d] + HEX_REG_SA0;\n" % \ (regtype, regid, regno)) elif (regid == "d"): - genptr_decl_writeble(f, tag, regtype, regid, regno) + genptr_decl_writable(f, tag, regtype, regid, regno) else: print("Bad register parse: ", regtype, regid) elif (regtype == "M"): diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 50008431c3..ae9fd9f31d 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7081,7 +7081,7 @@ static void x86_cpu_get_crash_info_qom(Object *obj, Visitor *v, GuestPanicInformation *panic_info; if (!cs->crash_occurred) { - error_setg(errp, "No crash occured"); + error_setg(errp, "No crash occurred"); return; } diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index c8d61daf68..7fe9f52710 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -693,7 +693,7 @@ static int kvm_inject_mce_oldstyle(X86CPU *cpu) return 0; } -static void cpu_update_state(void *opaque, int running, RunState state) +static void cpu_update_state(void *opaque, bool running, RunState state) { CPUX86State *env = opaque; diff --git a/target/i386/machine.c b/target/i386/machine.c index 3768a753af..3967dfc257 100644 --- a/target/i386/machine.c +++ b/target/i386/machine.c @@ -1173,7 +1173,7 @@ static int nested_state_post_load(void *opaque, int version_id) return -EINVAL; } if (nested_state->size > max_nested_state_len) { - error_report("Recieved unsupported nested state size: " + error_report("Received unsupported nested state size: " "nested_state->size=%d, max=%d", nested_state->size, max_nested_state_len); return -EINVAL; diff --git a/target/i386/sev.c b/target/i386/sev.c index 0f414df02f..72b9e2ab40 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -691,7 +691,7 @@ sev_launch_finish(SevGuestState *sev) } static void -sev_vm_state_change(void *opaque, int running, RunState state) +sev_vm_state_change(void *opaque, bool running, RunState state) { SevGuestState *sev = opaque; diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index f0a35df3bb..f832f286ac 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -1318,7 +1318,7 @@ void whpx_cpu_synchronize_pre_loadvm(CPUState *cpu) static Error *whpx_migration_blocker; -static void whpx_cpu_update_state(void *opaque, int running, RunState state) +static void whpx_cpu_update_state(void *opaque, bool running, RunState state) { CPUX86State *env = opaque; diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c index 46ff81acc9..ae1ba4b437 100644 --- a/target/m68k/op_helper.c +++ b/target/m68k/op_helper.c @@ -117,7 +117,7 @@ static const char *m68k_exception_name(int index) case EXCP_FORMAT: return "Format Error"; case EXCP_UNINITIALIZED: - return "Unitialized Interruot"; + return "Uninitialized Interrupt"; case EXCP_SPURIOUS: return "Spurious Interrupt"; case EXCP_INT_LEVEL_1: diff --git a/target/mips/kvm.c b/target/mips/kvm.c index 123ec1be7e..086debd9f0 100644 --- a/target/mips/kvm.c +++ b/target/mips/kvm.c @@ -38,7 +38,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { KVM_CAP_LAST_INFO }; -static void kvm_mips_update_state(void *opaque, int running, RunState state); +static void kvm_mips_update_state(void *opaque, bool running, RunState state); unsigned long kvm_arch_vcpu_id(CPUState *cs) { @@ -553,7 +553,7 @@ static int kvm_mips_restore_count(CPUState *cs) /* * Handle the VM clock being started or stopped */ -static void kvm_mips_update_state(void *opaque, int running, RunState state) +static void kvm_mips_update_state(void *opaque, bool running, RunState state) { CPUState *cs = opaque; int ret; diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index 63b9e8632c..118baf8d41 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -218,7 +218,7 @@ extern const VMStateDescription vmstate_ppc_timebase; .offset = vmstate_offset_value(_state, _field, PPCTimebase), \ } -void cpu_ppc_clock_vm_state_change(void *opaque, int running, +void cpu_ppc_clock_vm_state_change(void *opaque, bool running, RunState state); #endif diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index 0b682a1f94..429de28494 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -2175,14 +2175,17 @@ static int bcd_cmp_mag(ppc_avr_t *a, ppc_avr_t *b) return 0; } -static void bcd_add_mag(ppc_avr_t *t, ppc_avr_t *a, ppc_avr_t *b, int *invalid, +static int bcd_add_mag(ppc_avr_t *t, ppc_avr_t *a, ppc_avr_t *b, int *invalid, int *overflow) { int carry = 0; int i; + int is_zero = 1; + for (i = 1; i <= 31; i++) { uint8_t digit = bcd_get_digit(a, i, invalid) + bcd_get_digit(b, i, invalid) + carry; + is_zero &= (digit == 0); if (digit > 9) { carry = 1; digit -= 10; @@ -2194,6 +2197,7 @@ static void bcd_add_mag(ppc_avr_t *t, ppc_avr_t *a, ppc_avr_t *b, int *invalid, } *overflow = carry; + return is_zero; } static void bcd_sub_mag(ppc_avr_t *t, ppc_avr_t *a, ppc_avr_t *b, int *invalid, @@ -2225,14 +2229,15 @@ uint32_t helper_bcdadd(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps) int sgnb = bcd_get_sgn(b); int invalid = (sgna == 0) || (sgnb == 0); int overflow = 0; + int zero = 0; uint32_t cr = 0; ppc_avr_t result = { .u64 = { 0, 0 } }; if (!invalid) { if (sgna == sgnb) { result.VsrB(BCD_DIG_BYTE(0)) = bcd_preferred_sgn(sgna, ps); - bcd_add_mag(&result, a, b, &invalid, &overflow); - cr = bcd_cmp_zero(&result); + zero = bcd_add_mag(&result, a, b, &invalid, &overflow); + cr = (sgna > 0) ? CRF_GT : CRF_LT; } else { int magnitude = bcd_cmp_mag(a, b); if (magnitude > 0) { @@ -2255,6 +2260,8 @@ uint32_t helper_bcdadd(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps) cr = CRF_SO; } else if (overflow) { cr |= CRF_SO; + } else if (zero) { + cr |= CRF_EQ; } *r = result; diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.inc index 108ff2be2b..c03a7c4f52 100644 --- a/target/ppc/translate_init.c.inc +++ b/target/ppc/translate_init.c.inc @@ -566,35 +566,71 @@ static void spr_write_601_ubatl(DisasContext *ctx, int sprn, int gprn) #if !defined(CONFIG_USER_ONLY) static void spr_read_40x_pit(DisasContext *ctx, int gprn, int sprn) { + if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { + gen_io_start(); + } gen_helper_load_40x_pit(cpu_gpr[gprn], cpu_env); + if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { + gen_stop_exception(ctx); + } } static void spr_write_40x_pit(DisasContext *ctx, int sprn, int gprn) { + if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { + gen_io_start(); + } gen_helper_store_40x_pit(cpu_env, cpu_gpr[gprn]); + if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { + gen_stop_exception(ctx); + } } static void spr_write_40x_dbcr0(DisasContext *ctx, int sprn, int gprn) { + if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { + gen_io_start(); + } gen_store_spr(sprn, cpu_gpr[gprn]); gen_helper_store_40x_dbcr0(cpu_env, cpu_gpr[gprn]); /* We must stop translation as we may have rebooted */ gen_stop_exception(ctx); + if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { + gen_stop_exception(ctx); + } } static void spr_write_40x_sler(DisasContext *ctx, int sprn, int gprn) { + if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { + gen_io_start(); + } gen_helper_store_40x_sler(cpu_env, cpu_gpr[gprn]); + if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { + gen_stop_exception(ctx); + } } static void spr_write_booke_tcr(DisasContext *ctx, int sprn, int gprn) { + if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { + gen_io_start(); + } gen_helper_store_booke_tcr(cpu_env, cpu_gpr[gprn]); + if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { + gen_stop_exception(ctx); + } } static void spr_write_booke_tsr(DisasContext *ctx, int sprn, int gprn) { + if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { + gen_io_start(); + } gen_helper_store_booke_tsr(cpu_env, cpu_gpr[gprn]); + if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { + gen_stop_exception(ctx); + } } #endif diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index ddea8fbeeb..2a990f6253 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -506,7 +506,7 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) return; } } else { - qemu_log("vector verison is not specified, " + qemu_log("vector version is not specified, " "use the default value v0.7.1\n"); } set_vext_version(env, vext_version); diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c index 06ffebd6db..5a4cad8c8b 100644 --- a/tests/fp/fp-test.c +++ b/tests/fp/fp-test.c @@ -123,7 +123,7 @@ static void not_implemented(void) fprintf(stderr, "Not implemented.\n"); } -static bool blacklisted(unsigned op, int rmode) +static bool is_allowed(unsigned op, int rmode) { /* odd has not been implemented for any 80-bit ops */ if (rmode == softfloat_round_odd) { @@ -161,10 +161,10 @@ static bool blacklisted(unsigned op, int rmode) case F32_TO_EXTF80: case F64_TO_EXTF80: case F128_TO_EXTF80: - return true; + return false; } } - return false; + return true; } static void do_testfloat(int op, int rmode, bool exact) @@ -194,7 +194,7 @@ static void do_testfloat(int op, int rmode, bool exact) verCases_writeFunctionName(stderr); fputs("\n", stderr); - if (blacklisted(op, rmode)) { + if (!is_allowed(op, rmode)) { not_implemented(); return; } diff --git a/tests/qtest/fuzz-test.c b/tests/qtest/fuzz-test.c index cdb1100a0b..6f161c93be 100644 --- a/tests/qtest/fuzz-test.c +++ b/tests/qtest/fuzz-test.c @@ -39,8 +39,7 @@ static void test_lp1878642_pci_bus_get_irq_level_assert(void) QTestState *s; s = qtest_init("-M pc-q35-5.0 " - "-nographic -monitor none -serial none " - "-d guest_errors -trace pci*"); + "-nographic -monitor none -serial none"); qtest_outl(s, 0xcf8, 0x8400f841); qtest_outl(s, 0xcfc, 0xebed205d); diff --git a/tests/tcg/configure.sh b/tests/tcg/configure.sh index 36b8a73a54..ce304f4933 100755 --- a/tests/tcg/configure.sh +++ b/tests/tcg/configure.sh @@ -251,6 +251,12 @@ for target in $target_list; do echo "CROSS_CC_HAS_ARMV8_MTE=y" >> $config_target_mak fi ;; + ppc*) + if do_compiler "$target_compiler" $target_compiler_cflags \ + -mpower8-vector -o $TMPE $TMPC; then + echo "CROSS_CC_HAS_POWER8_VECTOR=y" >> $config_target_mak + fi + ;; esac enabled_cross_compilers="$enabled_cross_compilers $target_compiler" diff --git a/tests/tcg/ppc64/Makefile.target b/tests/tcg/ppc64/Makefile.target new file mode 100644 index 0000000000..0c6a4585fc --- /dev/null +++ b/tests/tcg/ppc64/Makefile.target @@ -0,0 +1,13 @@ +# -*- Mode: makefile -*- +# +# ppc64 specific tweaks + +VPATH += $(SRC_PATH)/tests/tcg/ppc64 +VPATH += $(SRC_PATH)/tests/tcg/ppc64le + +ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_POWER8_VECTOR),) +PPC64_TESTS=bcdsub +endif +bcdsub: CFLAGS += -mpower8-vector + +TESTS += $(PPC64_TESTS) diff --git a/tests/tcg/ppc64le/Makefile.target b/tests/tcg/ppc64le/Makefile.target new file mode 100644 index 0000000000..1acfcff94a --- /dev/null +++ b/tests/tcg/ppc64le/Makefile.target @@ -0,0 +1,12 @@ +# -*- Mode: makefile -*- +# +# ppc64le specific tweaks + +VPATH += $(SRC_PATH)/tests/tcg/ppc64le + +ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_POWER8_VECTOR),) +PPC64LE_TESTS=bcdsub +endif +bcdsub: CFLAGS += -mpower8-vector + +TESTS += $(PPC64LE_TESTS) diff --git a/tests/tcg/ppc64le/bcdsub.c b/tests/tcg/ppc64le/bcdsub.c new file mode 100644 index 0000000000..8c188cae6d --- /dev/null +++ b/tests/tcg/ppc64le/bcdsub.c @@ -0,0 +1,130 @@ +#include <assert.h> +#include <unistd.h> +#include <signal.h> + +#define CRF_LT (1 << 3) +#define CRF_GT (1 << 2) +#define CRF_EQ (1 << 1) +#define CRF_SO (1 << 0) +#define UNDEF 0 + +#define BCDSUB(vra, vrb, ps) \ + asm ("bcdsub. %1,%2,%3,%4;" \ + "mfocrf %0,0b10;" \ + : "=r" (cr), "=v" (vrt) \ + : "v" (vra), "v" (vrb), "i" (ps) \ + : ); + +#define TEST(vra, vrb, ps, exp_res, exp_cr6) \ + do { \ + __int128 vrt = 0; \ + int cr = 0; \ + BCDSUB(vra, vrb, ps); \ + if (exp_res) \ + assert(vrt == exp_res); \ + assert((cr >> 4) == exp_cr6); \ + } while (0) + + +/* + * Unbounded result is equal to zero: + * sign = (PS) ? 0b1111 : 0b1100 + * CR6 = 0b0010 + */ +void test_bcdsub_eq(void) +{ + __int128 a, b; + + /* maximum positive BCD value */ + a = b = (((__int128) 0x9999999999999999) << 64 | 0x999999999999999c); + + TEST(a, b, 0, 0xc, CRF_EQ); + TEST(a, b, 1, 0xf, CRF_EQ); +} + +/* + * Unbounded result is greater than zero: + * sign = (PS) ? 0b1111 : 0b1100 + * CR6 = (overflow) ? 0b0101 : 0b0100 + */ +void test_bcdsub_gt(void) +{ + __int128 a, b, c; + + /* maximum positive BCD value */ + a = (((__int128) 0x9999999999999999) << 64 | 0x999999999999999c); + + /* negative one BCD value */ + b = (__int128) 0x1d; + + TEST(a, b, 0, 0xc, (CRF_GT | CRF_SO)); + TEST(a, b, 1, 0xf, (CRF_GT | CRF_SO)); + + c = (((__int128) 0x9999999999999999) << 64 | 0x999999999999998c); + + TEST(c, b, 0, a, CRF_GT); + TEST(c, b, 1, (a | 0x3), CRF_GT); +} + +/* + * Unbounded result is less than zero: + * sign = 0b1101 + * CR6 = (overflow) ? 0b1001 : 0b1000 + */ +void test_bcdsub_lt(void) +{ + __int128 a, b; + + /* positive zero BCD value */ + a = (__int128) 0xc; + + /* positive one BCD value */ + b = (__int128) 0x1c; + + TEST(a, b, 0, 0x1d, CRF_LT); + TEST(a, b, 1, 0x1d, CRF_LT); + + /* maximum negative BCD value */ + a = (((__int128) 0x9999999999999999) << 64 | 0x999999999999999d); + + /* positive one BCD value */ + b = (__int128) 0x1c; + + TEST(a, b, 0, 0xd, (CRF_LT | CRF_SO)); + TEST(a, b, 1, 0xd, (CRF_LT | CRF_SO)); +} + +void test_bcdsub_invalid(void) +{ + __int128 a, b; + + /* positive one BCD value */ + a = (__int128) 0x1c; + b = 0xf00; + + TEST(a, b, 0, UNDEF, CRF_SO); + TEST(a, b, 1, UNDEF, CRF_SO); + + TEST(b, a, 0, UNDEF, CRF_SO); + TEST(b, a, 1, UNDEF, CRF_SO); + + a = 0xbad; + + TEST(a, b, 0, UNDEF, CRF_SO); + TEST(a, b, 1, UNDEF, CRF_SO); +} + +int main(void) +{ + struct sigaction action; + + action.sa_handler = _exit; + sigaction(SIGABRT, &action, NULL); + + test_bcdsub_eq(); + test_bcdsub_gt(); + test_bcdsub_lt(); + test_bcdsub_invalid(); + + return 0; +} diff --git a/ui/cocoa.m b/ui/cocoa.m index f27beb30e6..a7848ae0a3 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -30,6 +30,7 @@ #include "qemu-common.h" #include "ui/console.h" #include "ui/input.h" +#include "ui/kbd-state.h" #include "sysemu/sysemu.h" #include "sysemu/runstate.h" #include "sysemu/cpu-throttle.h" @@ -39,6 +40,7 @@ #include "qapi/qapi-commands-misc.h" #include "sysemu/blockdev.h" #include "qemu-version.h" +#include "qemu/cutils.h" #include "qemu/main-loop.h" #include "qemu/module.h" #include <Carbon/Carbon.h> @@ -80,7 +82,7 @@ static void cocoa_switch(DisplayChangeListener *dcl, static void cocoa_refresh(DisplayChangeListener *dcl); -NSWindow *normalWindow, *about_window; +static NSWindow *normalWindow, *about_window; static const DisplayChangeListenerOps dcl_ops = { .dpy_name = "cocoa", .dpy_gfx_update = cocoa_update, @@ -93,11 +95,11 @@ static DisplayChangeListener dcl = { static int last_buttons; static int cursor_hide = 1; -int gArgc; -char **gArgv; -bool stretch_video; -NSTextField *pauseLabel; -NSArray * supportedImageFileTypes; +static int gArgc; +static char **gArgv; +static bool stretch_video; +static NSTextField *pauseLabel; +static NSArray * supportedImageFileTypes; static QemuSemaphore display_init_sem; static QemuSemaphore app_started_sem; @@ -135,7 +137,7 @@ static bool bool_with_iothread_lock(BoolCodeBlock block) } // Mac to QKeyCode conversion -const int mac_to_qkeycode_map[] = { +static const int mac_to_qkeycode_map[] = { [kVK_ANSI_A] = Q_KEY_CODE_A, [kVK_ANSI_B] = Q_KEY_CODE_B, [kVK_ANSI_C] = Q_KEY_CODE_C, @@ -189,14 +191,6 @@ const int mac_to_qkeycode_map[] = { [kVK_ANSI_Comma] = Q_KEY_CODE_COMMA, [kVK_ANSI_Period] = Q_KEY_CODE_DOT, [kVK_ANSI_Slash] = Q_KEY_CODE_SLASH, - [kVK_Shift] = Q_KEY_CODE_SHIFT, - [kVK_RightShift] = Q_KEY_CODE_SHIFT_R, - [kVK_Control] = Q_KEY_CODE_CTRL, - [kVK_RightControl] = Q_KEY_CODE_CTRL_R, - [kVK_Option] = Q_KEY_CODE_ALT, - [kVK_RightOption] = Q_KEY_CODE_ALT_R, - [kVK_Command] = Q_KEY_CODE_META_L, - [0x36] = Q_KEY_CODE_META_R, /* There is no kVK_RightCommand */ [kVK_Space] = Q_KEY_CODE_SPC, [kVK_ANSI_Keypad0] = Q_KEY_CODE_KP_0, @@ -306,11 +300,10 @@ static void handleAnyDeviceErrors(Error * err) NSWindow *fullScreenWindow; float cx,cy,cw,ch,cdx,cdy; pixman_image_t *pixman_image; - BOOL modifiers_state[256]; + QKbdState *kbd; BOOL isMouseGrabbed; BOOL isFullscreen; BOOL isAbsoluteEnabled; - BOOL isMouseDeassociated; } - (void) switchSurface:(pixman_image_t *)image; - (void) grabMouse; @@ -327,14 +320,9 @@ static void handleAnyDeviceErrors(Error * err) * isMouseGrabbed tracks whether GUI events are directed to the guest; * it controls whether special keys like Cmd get sent to the guest, * and whether we capture the mouse when in non-absolute mode. - * isMouseDeassociated tracks whether we've told MacOSX to disassociate - * the mouse and mouse cursor position by calling - * CGAssociateMouseAndMouseCursorPosition(FALSE) - * (which basically happens if we grab in non-absolute mode). */ - (BOOL) isMouseGrabbed; - (BOOL) isAbsoluteEnabled; -- (BOOL) isMouseDeassociated; - (float) cdx; - (float) cdy; - (QEMUScreen) gscreen; @@ -353,6 +341,7 @@ QemuCocoaView *cocoaView; screen.width = frameRect.size.width; screen.height = frameRect.size.height; + kbd = qkbd_state_init(dcl.con); } return self; @@ -366,6 +355,7 @@ QemuCocoaView *cocoaView; pixman_image_unref(pixman_image); } + qkbd_state_free(kbd); [super dealloc]; } @@ -463,13 +453,8 @@ QemuCocoaView *cocoaView; DIV_ROUND_UP(bitsPerPixel, 8) * 2, //bitsPerComponent bitsPerPixel, //bitsPerPixel stride, //bytesPerRow -#ifdef __LITTLE_ENDIAN__ - CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB), //colorspace for OS X >= 10.4 - kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst, -#else - CGColorSpaceCreateDeviceRGB(), //colorspace for OS X < 10.4 (actually ppc) - kCGImageAlphaNoneSkipFirst, //bitmapInfo -#endif + CGColorSpaceCreateWithName(kCGColorSpaceSRGB), //colorspace + kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst, //bitmapInfo dataProviderRef, //provider NULL, //decode 0, //interpolate @@ -608,19 +593,8 @@ QemuCocoaView *cocoaView; } } -- (void) toggleModifier: (int)keycode { - // Toggle the stored state. - modifiers_state[keycode] = !modifiers_state[keycode]; - // Send a keyup or keydown depending on the state. - qemu_input_event_send_key_qcode(dcl.con, keycode, modifiers_state[keycode]); -} - -- (void) toggleStatefulModifier: (int)keycode { - // Toggle the stored state. - modifiers_state[keycode] = !modifiers_state[keycode]; - // Generate keydown and keyup. - qemu_input_event_send_key_qcode(dcl.con, keycode, true); - qemu_input_event_send_key_qcode(dcl.con, keycode, false); +- (void) toggleKey: (int)keycode { + qkbd_state_key_event(kbd, keycode, !qkbd_state_key_get(kbd, keycode)); } // Does the work of sending input to the monitor @@ -714,57 +688,86 @@ QemuCocoaView *cocoaView; static bool switched_to_fullscreen = false; // Location of event in virtual screen coordinates NSPoint p = [self screenLocationOfEvent:event]; + NSUInteger modifiers = [event modifierFlags]; + + // emulate caps lock keydown and keyup + if (!!(modifiers & NSEventModifierFlagCapsLock) != + qkbd_state_modifier_get(kbd, QKBD_MOD_CAPSLOCK)) { + qkbd_state_key_event(kbd, Q_KEY_CODE_CAPS_LOCK, true); + qkbd_state_key_event(kbd, Q_KEY_CODE_CAPS_LOCK, false); + } + + if (!(modifiers & NSEventModifierFlagShift)) { + qkbd_state_key_event(kbd, Q_KEY_CODE_SHIFT, false); + qkbd_state_key_event(kbd, Q_KEY_CODE_SHIFT_R, false); + } + if (!(modifiers & NSEventModifierFlagControl)) { + qkbd_state_key_event(kbd, Q_KEY_CODE_CTRL, false); + qkbd_state_key_event(kbd, Q_KEY_CODE_CTRL_R, false); + } + if (!(modifiers & NSEventModifierFlagOption)) { + qkbd_state_key_event(kbd, Q_KEY_CODE_ALT, false); + qkbd_state_key_event(kbd, Q_KEY_CODE_ALT_R, false); + } + if (!(modifiers & NSEventModifierFlagCommand)) { + qkbd_state_key_event(kbd, Q_KEY_CODE_META_L, false); + qkbd_state_key_event(kbd, Q_KEY_CODE_META_R, false); + } switch ([event type]) { case NSEventTypeFlagsChanged: - if ([event keyCode] == 0) { - // When the Cocoa keyCode is zero that means keys should be - // synthesized based on the values in in the eventModifiers - // bitmask. - - if (qemu_console_is_graphic(NULL)) { - NSUInteger modifiers = [event modifierFlags]; + switch ([event keyCode]) { + case kVK_Shift: + if (!!(modifiers & NSEventModifierFlagShift)) { + [self toggleKey:Q_KEY_CODE_SHIFT]; + } + break; - if (!!(modifiers & NSEventModifierFlagCapsLock) != !!modifiers_state[Q_KEY_CODE_CAPS_LOCK]) { - [self toggleStatefulModifier:Q_KEY_CODE_CAPS_LOCK]; + case kVK_RightShift: + if (!!(modifiers & NSEventModifierFlagShift)) { + [self toggleKey:Q_KEY_CODE_SHIFT_R]; } - if (!!(modifiers & NSEventModifierFlagShift) != !!modifiers_state[Q_KEY_CODE_SHIFT]) { - [self toggleModifier:Q_KEY_CODE_SHIFT]; + break; + + case kVK_Control: + if (!!(modifiers & NSEventModifierFlagControl)) { + [self toggleKey:Q_KEY_CODE_CTRL]; } - if (!!(modifiers & NSEventModifierFlagControl) != !!modifiers_state[Q_KEY_CODE_CTRL]) { - [self toggleModifier:Q_KEY_CODE_CTRL]; + break; + + case kVK_RightControl: + if (!!(modifiers & NSEventModifierFlagControl)) { + [self toggleKey:Q_KEY_CODE_CTRL_R]; } - if (!!(modifiers & NSEventModifierFlagOption) != !!modifiers_state[Q_KEY_CODE_ALT]) { - [self toggleModifier:Q_KEY_CODE_ALT]; + break; + + case kVK_Option: + if (!!(modifiers & NSEventModifierFlagOption)) { + [self toggleKey:Q_KEY_CODE_ALT]; } - if (!!(modifiers & NSEventModifierFlagCommand) != !!modifiers_state[Q_KEY_CODE_META_L]) { - [self toggleModifier:Q_KEY_CODE_META_L]; + break; + + case kVK_RightOption: + if (!!(modifiers & NSEventModifierFlagOption)) { + [self toggleKey:Q_KEY_CODE_ALT_R]; } - } - } else { - keycode = cocoa_keycode_to_qemu([event keyCode]); - } + break; - if ((keycode == Q_KEY_CODE_META_L || keycode == Q_KEY_CODE_META_R) - && !isMouseGrabbed) { - /* Don't pass command key changes to guest unless mouse is grabbed */ - keycode = 0; - } + /* Don't pass command key changes to guest unless mouse is grabbed */ + case kVK_Command: + if (isMouseGrabbed && + !!(modifiers & NSEventModifierFlagCommand)) { + [self toggleKey:Q_KEY_CODE_META_L]; + } + break; - if (keycode) { - // emulate caps lock and num lock keydown and keyup - if (keycode == Q_KEY_CODE_CAPS_LOCK || - keycode == Q_KEY_CODE_NUM_LOCK) { - [self toggleStatefulModifier:keycode]; - } else if (qemu_console_is_graphic(NULL)) { - if (switched_to_fullscreen) { - switched_to_fullscreen = false; - } else { - [self toggleModifier:keycode]; + case kVK_RightCommand: + if (isMouseGrabbed && + !!(modifiers & NSEventModifierFlagCommand)) { + [self toggleKey:Q_KEY_CODE_META_R]; } - } + break; } - break; case NSEventTypeKeyDown: keycode = cocoa_keycode_to_qemu([event keyCode]); @@ -804,7 +807,7 @@ QemuCocoaView *cocoaView; } if (qemu_console_is_graphic(NULL)) { - qemu_input_event_send_key_qcode(dcl.con, keycode, true); + qkbd_state_key_event(kbd, keycode, true); } else { [self handleMonitorInput: event]; } @@ -819,7 +822,7 @@ QemuCocoaView *cocoaView; } if (qemu_console_is_graphic(NULL)) { - qemu_input_event_send_key_qcode(dcl.con, keycode, false); + qkbd_state_key_event(kbd, keycode, false); } break; case NSEventTypeMouseMoved: @@ -963,10 +966,7 @@ QemuCocoaView *cocoaView; [normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to release Mouse)"]; } [self hideCursor]; - if (!isAbsoluteEnabled) { - isMouseDeassociated = TRUE; - CGAssociateMouseAndMouseCursorPosition(FALSE); - } + CGAssociateMouseAndMouseCursorPosition(isAbsoluteEnabled); isMouseGrabbed = TRUE; // while isMouseGrabbed = TRUE, QemuCocoaApp sends all events to [cocoaView handleEvent:] } @@ -981,17 +981,18 @@ QemuCocoaView *cocoaView; [normalWindow setTitle:@"QEMU"]; } [self unhideCursor]; - if (isMouseDeassociated) { - CGAssociateMouseAndMouseCursorPosition(TRUE); - isMouseDeassociated = FALSE; - } + CGAssociateMouseAndMouseCursorPosition(TRUE); isMouseGrabbed = FALSE; } -- (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled {isAbsoluteEnabled = tIsAbsoluteEnabled;} +- (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled { + isAbsoluteEnabled = tIsAbsoluteEnabled; + if (isMouseGrabbed) { + CGAssociateMouseAndMouseCursorPosition(isAbsoluteEnabled); + } +} - (BOOL) isMouseGrabbed {return isMouseGrabbed;} - (BOOL) isAbsoluteEnabled {return isAbsoluteEnabled;} -- (BOOL) isMouseDeassociated {return isMouseDeassociated;} - (float) cdx {return cdx;} - (float) cdy {return cdy;} - (QEMUScreen) gscreen {return screen;} @@ -1003,17 +1004,8 @@ QemuCocoaView *cocoaView; */ - (void) raiseAllKeys { - const int max_index = ARRAY_SIZE(modifiers_state); - with_iothread_lock(^{ - int index; - - for (index = 0; index < max_index; index++) { - if (modifiers_state[index]) { - modifiers_state[index] = 0; - qemu_input_event_send_key_qcode(dcl.con, index, false); - } - } + qkbd_state_lift_all_keys(kbd); }); } @end @@ -1390,37 +1382,33 @@ QemuCocoaView *cocoaView; y = about_height - picture_height - 10; NSRect picture_rect = NSMakeRect(x, y, picture_width, picture_height); - /* Get the path to the QEMU binary */ - NSString *binary_name = [NSString stringWithCString: gArgv[0] - encoding: NSASCIIStringEncoding]; - binary_name = [binary_name lastPathComponent]; - NSString *program_path = [[NSString alloc] initWithFormat: @"%@/%@", - [[NSBundle mainBundle] bundlePath], binary_name]; - /* Make the picture of QEMU */ NSImageView *picture_view = [[NSImageView alloc] initWithFrame: picture_rect]; - NSImage *qemu_image = [[NSWorkspace sharedWorkspace] iconForFile: - program_path]; + char *qemu_image_path_c = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/512x512/apps/qemu.png"); + NSString *qemu_image_path = [NSString stringWithUTF8String:qemu_image_path_c]; + g_free(qemu_image_path_c); + NSImage *qemu_image = [[NSImage alloc] initWithContentsOfFile:qemu_image_path]; [picture_view setImage: qemu_image]; [picture_view setImageScaling: NSImageScaleProportionallyUpOrDown]; [superView addSubview: picture_view]; /* Make the name label */ - x = 0; - y = y - 25; - int name_width = about_width, name_height = 20; - NSRect name_rect = NSMakeRect(x, y, name_width, name_height); - NSTextField *name_label = [[NSTextField alloc] initWithFrame: name_rect]; - [name_label setEditable: NO]; - [name_label setBezeled: NO]; - [name_label setDrawsBackground: NO]; - [name_label setAlignment: NSTextAlignmentCenter]; - NSString *qemu_name = [[NSString alloc] initWithCString: gArgv[0] - encoding: NSASCIIStringEncoding]; - qemu_name = [qemu_name lastPathComponent]; - [name_label setStringValue: qemu_name]; - [superView addSubview: name_label]; + NSBundle *bundle = [NSBundle mainBundle]; + if (bundle) { + x = 0; + y = y - 25; + int name_width = about_width, name_height = 20; + NSRect name_rect = NSMakeRect(x, y, name_width, name_height); + NSTextField *name_label = [[NSTextField alloc] initWithFrame: name_rect]; + [name_label setEditable: NO]; + [name_label setBezeled: NO]; + [name_label setDrawsBackground: NO]; + [name_label setAlignment: NSTextAlignmentCenter]; + NSString *qemu_name = [[bundle executablePath] lastPathComponent]; + [name_label setStringValue: qemu_name]; + [superView addSubview: name_label]; + } /* Set the version label's attributes */ x = 0; diff --git a/ui/console.c b/ui/console.c index 171a7bf14b..c2fdf975b6 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1724,7 +1724,7 @@ bool dpy_gfx_check_format(QemuConsole *con, return false; } } else { - /* default is to whitelist native 32 bpp only */ + /* default is to allow native 32 bpp only */ if (format != qemu_default_pixman_format(32, true)) { return false; } @@ -547,9 +547,7 @@ static void gd_switch(DisplayChangeListener *dcl, VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); bool resized = true; - trace_gd_switch(vc->label, - surface ? surface_width(surface) : 0, - surface ? surface_height(surface) : 0); + trace_gd_switch(vc->label, surface_width(surface), surface_height(surface)); if (vc->gfx.surface) { cairo_surface_destroy(vc->gfx.surface); @@ -560,7 +558,7 @@ static void gd_switch(DisplayChangeListener *dcl, vc->gfx.convert = NULL; } - if (vc->gfx.ds && surface && + if (vc->gfx.ds && surface_width(vc->gfx.ds) == surface_width(surface) && surface_height(vc->gfx.ds) == surface_height(surface)) { resized = false; @@ -683,7 +681,7 @@ static const DisplayChangeListenerOps dcl_egl_ops = { /** QEMU Events **/ -static void gd_change_runstate(void *opaque, int running, RunState state) +static void gd_change_runstate(void *opaque, bool running, RunState state) { GtkDisplayState *s = opaque; diff --git a/ui/spice-core.c b/ui/spice-core.c index beee932f55..cadec766fe 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -615,7 +615,7 @@ static int add_channel(void *opaque, const char *name, const char *value, return 0; } -static void vm_change_state_handler(void *opaque, int running, +static void vm_change_state_handler(void *opaque, bool running, RunState state) { if (running) { diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c index f67111a366..df7dc08e9f 100644 --- a/ui/vnc-auth-sasl.c +++ b/ui/vnc-auth-sasl.c @@ -288,7 +288,7 @@ static int protocol_client_auth_sasl_step(VncState *vs, uint8_t *data, size_t le goto authreject; } - /* Check username whitelist ACL */ + /* Check the username access control list */ if (vnc_auth_sasl_check_access(vs) < 0) { goto authreject; } @@ -409,7 +409,7 @@ static int protocol_client_auth_sasl_start(VncState *vs, uint8_t *data, size_t l goto authreject; } - /* Check username whitelist ACL */ + /* Check the username access control list */ if (vnc_auth_sasl_check_access(vs) < 0) { goto authreject; } @@ -35,6 +35,7 @@ static const char *const id_subsys_str[ID_MAX] = { [ID_QDEV] = "qdev", [ID_BLOCK] = "block", [ID_CHR] = "chr", + [ID_NET] = "net", }; /* diff --git a/util/qemu-timer.c b/util/qemu-timer.c index f36c75e594..be529c1f65 100644 --- a/util/qemu-timer.c +++ b/util/qemu-timer.c @@ -242,6 +242,19 @@ int64_t timerlist_deadline_ns(QEMUTimerList *timer_list) return delta; } +/* + * Returns the time remaining for the deadline, in ms. + */ +int64_t timer_deadline_ms(QEMUTimer *timer) +{ + if (timer_pending(timer)) { + return qemu_timeout_ns_to_ms(timer->expire_time) - + qemu_clock_get_ms(timer->timer_list->clock->type); + } + + return 0; +} + /* Calculate the soonest deadline across all timerlists attached * to the clock. This is used for the icount timeout so we * ignore whether or not the clock should be used in deadline |