aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2022-04-19 18:22:15 -0700
committerRichard Henderson <richard.henderson@linaro.org>2022-04-19 18:22:16 -0700
commit1be5a765c08cee3a9587c8a8d3fc2ea247b13f9c (patch)
tree30ace22866ea218524bf1a64818fc20a93a414e3 /hw
parent3202995c13a7484b7d69c43f148354c537bf87de (diff)
parentc9e28ae7972a10fdf09b7ebd8046840d1101b8ce (diff)
downloadqemu-1be5a765c08cee3a9587c8a8d3fc2ea247b13f9c.zip
qemu-1be5a765c08cee3a9587c8a8d3fc2ea247b13f9c.tar.gz
qemu-1be5a765c08cee3a9587c8a8d3fc2ea247b13f9c.tar.bz2
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* Add cpu0-id to query-sev-capabilities * whpx support for breakpoints and stepping * initial support for Hyper-V Synthetic Debugging * use monotonic clock for QemuCond and QemuSemaphore * Remove qemu-common.h include from most units and lots of other clenaups * do not include headers for all virtio devices in virtio-ccw.h # -----BEGIN PGP SIGNATURE----- # # iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmJXCQAUHHBib256aW5p # QHJlZGhhdC5jb20ACgkQv/vSX3jHroNT6wf+NHDJUEdDiwaVGVTGXgHuiaycsymi # FpNPiw/+XxSGN5xF3fkUGgqaDrcwIYwVfnXlghKSz8kp1cP3cjxa5CzNMLGTp5je # N6BxFbD7yC6dhagGm3mj32jlsptv3M38OHqKc3t+RaUAotP5RF2VdCyfUBLG6vU0 # aMzvMfMtB5aG0D8Fr5EV63t1JMTceFU0YxsG73UCFs2Yx4Z0cGBbNxMbHweRhd1q # tPeVDS46MFPM3/2cGGHpeeqxkoCTU7A9j1VuNQI3k+Kg+6W5YVxiK/UP7bw77E/a # yAHsmIVTNro8ajMBch73weuHtGtdfFLvCKc6QX6aVjzK4dF1voQ01E7gPQ== # =rMle # -----END PGP SIGNATURE----- # gpg: Signature made Wed 13 Apr 2022 10:31:44 AM PDT # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "pbonzini@redhat.com" # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [undefined] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [undefined] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * tag 'for-upstream' of https://gitlab.com/bonzini/qemu: (53 commits) target/i386: Remove unused XMMReg, YMMReg types and CPUState fields target/i386: do not access beyond the low 128 bits of SSE registers virtio-ccw: do not include headers for all virtio devices virtio-ccw: move device type declarations to .c files virtio-ccw: move vhost_ccw_scsi to a separate file s390x: follow qdev tree to detect SCSI device on a CCW bus hw: hyperv: Initial commit for Synthetic Debugging device hyperv: Add support to process syndbg commands hyperv: Add definitions for syndbg hyperv: SControl is optional to enable SynIc thread-posix: optimize qemu_sem_timedwait with zero timeout thread-posix: implement Semaphore with QemuCond and QemuMutex thread-posix: use monotonic clock for QemuCond and QemuSemaphore thread-posix: remove the posix semaphore support whpx: Added support for breakpoints and stepping build-sys: simplify AF_VSOCK check build-sys: drop ntddscsi.h check Remove qemu-common.h include from most units qga: remove explicit environ argument from exec/spawn Move fcntl_setfl() to oslib-posix ... Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r--hw/9pfs/9p-proxy.c1
-rw-r--r--hw/alpha/dp264.c1
-rw-r--r--hw/arm/armv7m.c2
-rw-r--r--hw/avr/boot.c1
-rw-r--r--hw/core/loader.c5
-rw-r--r--hw/display/artist.c7
-rw-r--r--hw/display/cg3.c1
-rw-r--r--hw/display/pl110_template.h6
-rw-r--r--hw/display/pxa2xx_lcd.c2
-rw-r--r--hw/display/qxl.c2
-rw-r--r--hw/display/tcx.c1
-rw-r--r--hw/display/vga.c14
-rw-r--r--hw/display/virtio-gpu-gl.c2
-rw-r--r--hw/display/virtio-gpu-udmabuf.c1
-rw-r--r--hw/dma/pl330.c1
-rw-r--r--hw/dma/xlnx_dpdma.c2
-rw-r--r--hw/hppa/machine.c1
-rw-r--r--hw/hyperv/Kconfig5
-rw-r--r--hw/hyperv/hyperv.c352
-rw-r--r--hw/hyperv/meson.build1
-rw-r--r--hw/hyperv/syndbg.c402
-rw-r--r--hw/i386/pc_sysfw.c1
-rw-r--r--hw/i386/x86.c1
-rw-r--r--hw/input/vhost-user-input.c1
-rw-r--r--hw/intc/s390_flic_kvm.c2
-rw-r--r--hw/intc/xics_kvm.c1
-rw-r--r--hw/m68k/mcf5208.c1
-rw-r--r--hw/m68k/q800.c1
-rw-r--r--hw/m68k/virt.c1
-rw-r--r--hw/microblaze/boot.c3
-rw-r--r--hw/mips/fuloong2e.c1
-rw-r--r--hw/mips/gt64xxx_pci.c6
-rw-r--r--hw/mips/jazz.c3
-rw-r--r--hw/mips/loongson3_virt.c1
-rw-r--r--hw/mips/malta.c25
-rw-r--r--hw/mips/mipssim.c3
-rw-r--r--hw/misc/sbsa_ec.c1
-rw-r--r--hw/net/can/ctucan_core.h2
-rw-r--r--hw/net/fsl_etsec/etsec.c1
-rw-r--r--hw/net/fsl_etsec/rings.c1
-rw-r--r--hw/net/msf2-emac.c1
-rw-r--r--hw/net/npcm7xx_emc.c1
-rw-r--r--hw/net/vmxnet3.h4
-rw-r--r--hw/nios2/boot.c3
-rw-r--r--hw/nios2/generic_nommu.c1
-rw-r--r--hw/nvram/fw_cfg.c7
-rw-r--r--hw/pci-host/mv64361.c1
-rw-r--r--hw/pci-host/pnv_phb3.c1
-rw-r--r--hw/pci-host/pnv_phb3_msi.c1
-rw-r--r--hw/pci-host/pnv_phb3_pbcq.c1
-rw-r--r--hw/pci-host/pnv_phb4.c1
-rw-r--r--hw/pci-host/pnv_phb4_pec.c1
-rw-r--r--hw/pci-host/raven.c1
-rw-r--r--hw/pci-host/remote.c1
-rw-r--r--hw/pci/pci.c1
-rw-r--r--hw/ppc/e500.c1
-rw-r--r--hw/ppc/mac_newworld.c3
-rw-r--r--hw/ppc/mac_oldworld.c1
-rw-r--r--hw/ppc/pegasos2.c1
-rw-r--r--hw/ppc/pnv.c1
-rw-r--r--hw/ppc/pnv_bmc.c1
-rw-r--r--hw/ppc/ppc405_boards.c1
-rw-r--r--hw/ppc/ppc440_bamboo.c1
-rw-r--r--hw/ppc/sam460ex.c1
-rw-r--r--hw/ppc/spapr.c1
-rw-r--r--hw/ppc/spapr_numa.c1
-rw-r--r--hw/ppc/spapr_pci.c2
-rw-r--r--hw/ppc/spapr_pci_nvlink2.c1
-rw-r--r--hw/ppc/spapr_tpm_proxy.c1
-rw-r--r--hw/ppc/spapr_vof.c1
-rw-r--r--hw/ppc/virtex_ml507.c1
-rw-r--r--hw/ppc/vof.c1
-rw-r--r--hw/rdma/vmw/pvrdma_main.c2
-rw-r--r--hw/remote/iohub.c1
-rw-r--r--hw/remote/machine.c1
-rw-r--r--hw/remote/memory.c1
-rw-r--r--hw/remote/message.c1
-rw-r--r--hw/remote/mpqemu-link.c1
-rw-r--r--hw/remote/proxy-memory-listener.c1
-rw-r--r--hw/remote/proxy.c1
-rw-r--r--hw/remote/remote-obj.c1
-rw-r--r--hw/riscv/boot.c1
-rw-r--r--hw/rtc/m41t80.c6
-rw-r--r--hw/rx/rx-gdbsim.c1
-rw-r--r--hw/s390x/event-facility.c2
-rw-r--r--hw/s390x/ipl.c24
-rw-r--r--hw/s390x/meson.build1
-rw-r--r--hw/s390x/s390-virtio-ccw.c1
-rw-r--r--hw/s390x/vhost-scsi-ccw.c73
-rw-r--r--hw/s390x/vhost-vsock-ccw.c9
-rw-r--r--hw/s390x/virtio-ccw-9p.c9
-rw-r--r--hw/s390x/virtio-ccw-balloon.c9
-rw-r--r--hw/s390x/virtio-ccw-blk.c9
-rw-r--r--hw/s390x/virtio-ccw-crypto.c9
-rw-r--r--hw/s390x/virtio-ccw-gpu.c9
-rw-r--r--hw/s390x/virtio-ccw-input.c20
-rw-r--r--hw/s390x/virtio-ccw-net.c9
-rw-r--r--hw/s390x/virtio-ccw-rng.c9
-rw-r--r--hw/s390x/virtio-ccw-scsi.c56
-rw-r--r--hw/s390x/virtio-ccw-serial.c9
-rw-r--r--hw/s390x/virtio-ccw.c2
-rw-r--r--hw/s390x/virtio-ccw.h149
-rw-r--r--hw/scsi/scsi-generic.c2
-rw-r--r--hw/sd/sd.c1
-rw-r--r--hw/sparc/leon3.c1
-rw-r--r--hw/sparc/sun4m.c1
-rw-r--r--hw/sparc64/sun4u.c1
-rw-r--r--hw/tpm/tpm_ppi.c2
-rw-r--r--hw/usb/ccid-card-passthru.c2
-rw-r--r--hw/usb/dev-mtp.c1
-rw-r--r--hw/usb/dev-smartcard-reader.c2
-rw-r--r--hw/usb/redirect.c2
-rw-r--r--hw/vfio/common.c24
-rw-r--r--hw/vfio/pci.c10
-rw-r--r--hw/vfio/spapr.c8
-rw-r--r--hw/virtio/vhost-iova-tree.c4
-rw-r--r--hw/virtio/vhost-shadow-virtqueue.c8
-rw-r--r--hw/virtio/vhost-user.c4
-rw-r--r--hw/virtio/vhost-vdpa.c8
-rw-r--r--hw/virtio/vhost.c2
-rw-r--r--hw/virtio/virtio-balloon.c9
-rw-r--r--hw/virtio/virtio-iommu.c1
-rw-r--r--hw/virtio/virtio-mem.c11
-rw-r--r--hw/virtio/virtio-pmem.c1
-rw-r--r--hw/xtensa/sim.c2
-rw-r--r--hw/xtensa/xtfpga.c4
126 files changed, 1030 insertions, 420 deletions
diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c
index 4c5e0fc..99d115f 100644
--- a/hw/9pfs/9p-proxy.c
+++ b/hw/9pfs/9p-proxy.c
@@ -18,7 +18,6 @@
#include "qemu/osdep.h"
#include <sys/socket.h>
#include <sys/un.h>
-#include "qemu-common.h"
#include "9p.h"
#include "qapi/error.h"
#include "qemu/cutils.h"
diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c
index c78ed96..f4349eb 100644
--- a/hw/alpha/dp264.c
+++ b/hw/alpha/dp264.c
@@ -7,7 +7,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "cpu.h"
#include "elf.h"
#include "hw/loader.h"
diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index 41cfca0..32349ec 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -577,7 +577,7 @@ void armv7m_load_kernel(ARMCPU *cpu, const char *kernel_filename, int mem_size)
int asidx;
CPUState *cs = CPU(cpu);
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
big_endian = 1;
#else
big_endian = 0;
diff --git a/hw/avr/boot.c b/hw/avr/boot.c
index cbede77..617f3a1 100644
--- a/hw/avr/boot.c
+++ b/hw/avr/boot.c
@@ -9,7 +9,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "hw/loader.h"
#include "elf.h"
diff --git a/hw/core/loader.c b/hw/core/loader.c
index ca2f243..8167301 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -43,7 +43,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-machine.h"
@@ -474,7 +473,7 @@ ssize_t load_elf_ram_sym(const char *filename,
ret = ELF_LOAD_NOT_ELF;
goto fail;
}
-#ifdef HOST_WORDS_BIGENDIAN
+#if HOST_BIG_ENDIAN
data_order = ELFDATA2MSB;
#else
data_order = ELFDATA2LSB;
@@ -511,7 +510,7 @@ ssize_t load_elf_ram_sym(const char *filename,
static void bswap_uboot_header(uboot_image_header_t *hdr)
{
-#ifndef HOST_WORDS_BIGENDIAN
+#if !HOST_BIG_ENDIAN
bswap32s(&hdr->ih_magic);
bswap32s(&hdr->ih_hcrc);
bswap32s(&hdr->ih_time);
diff --git a/hw/display/artist.c b/hw/display/artist.c
index 1d87799..8e121bb 100644
--- a/hw/display/artist.c
+++ b/hw/display/artist.c
@@ -7,7 +7,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/error-report.h"
#include "qemu/log.h"
#include "qemu/module.h"
@@ -26,7 +25,7 @@
#define TYPE_ARTIST "artist"
OBJECT_DECLARE_SIMPLE_TYPE(ARTISTState, ARTIST)
-#ifdef HOST_WORDS_BIGENDIAN
+#if HOST_BIG_ENDIAN
#define ROP8OFF(_i) (3 - (_i))
#else
#define ROP8OFF
@@ -712,7 +711,7 @@ static void combine_write_reg(hwaddr addr, uint64_t val, int size, void *out)
* FIXME: is there a qemu helper for this?
*/
-#ifndef HOST_WORDS_BIGENDIAN
+#if !HOST_BIG_ENDIAN
addr ^= 3;
#endif
@@ -1087,7 +1086,7 @@ static uint64_t combine_read_reg(hwaddr addr, int size, void *in)
* FIXME: is there a qemu helper for this?
*/
-#ifndef HOST_WORDS_BIGENDIAN
+#if !HOST_BIG_ENDIAN
addr ^= 3;
#endif
diff --git a/hw/display/cg3.c b/hw/display/cg3.c
index 4b7e78d..2e9656a 100644
--- a/hw/display/cg3.c
+++ b/hw/display/cg3.c
@@ -24,7 +24,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
diff --git a/hw/display/pl110_template.h b/hw/display/pl110_template.h
index 877419a..0087785 100644
--- a/hw/display/pl110_template.h
+++ b/hw/display/pl110_template.h
@@ -15,18 +15,18 @@
#if ORDER == 0
#define NAME glue(lblp_, BORDER)
-#ifdef HOST_WORDS_BIGENDIAN
+#if HOST_BIG_ENDIAN
#define SWAP_WORDS 1
#endif
#elif ORDER == 1
#define NAME glue(bbbp_, BORDER)
-#ifndef HOST_WORDS_BIGENDIAN
+#if !HOST_BIG_ENDIAN
#define SWAP_WORDS 1
#endif
#else
#define SWAP_PIXELS 1
#define NAME glue(lbbp_, BORDER)
-#ifdef HOST_WORDS_BIGENDIAN
+#if HOST_BIG_ENDIAN
#define SWAP_WORDS 1
#endif
#endif
diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c
index 0f06ed6..7859c5d 100644
--- a/hw/display/pxa2xx_lcd.c
+++ b/hw/display/pxa2xx_lcd.c
@@ -199,7 +199,7 @@ typedef struct QEMU_PACKED {
SKIP_PIXEL(to); \
} while (0)
-#ifdef HOST_WORDS_BIGENDIAN
+#if HOST_BIG_ENDIAN
# define SWAP_WORDS 1
#endif
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index adbdbca..2db3471 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -320,7 +320,7 @@ static ram_addr_t qxl_rom_size(void)
#define QXL_ROM_SZ 8192
QEMU_BUILD_BUG_ON(QXL_REQUIRED_SZ > QXL_ROM_SZ);
- return QEMU_ALIGN_UP(QXL_REQUIRED_SZ, qemu_real_host_page_size);
+ return QEMU_ALIGN_UP(QXL_REQUIRED_SZ, qemu_real_host_page_size());
}
static void init_qxl_rom(PCIQXLDevice *d)
diff --git a/hw/display/tcx.c b/hw/display/tcx.c
index d4d09d0..1b27b64 100644
--- a/hw/display/tcx.c
+++ b/hw/display/tcx.c
@@ -23,7 +23,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qapi/error.h"
#include "ui/console.h"
diff --git a/hw/display/vga.c b/hw/display/vga.c
index a7a291f..5dca2d1 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -94,19 +94,19 @@ const uint8_t gr_mask[16] = {
(((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \
(((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) ))
-#ifdef HOST_WORDS_BIGENDIAN
+#if HOST_BIG_ENDIAN
#define PAT(x) cbswap_32(x)
#else
#define PAT(x) (x)
#endif
-#ifdef HOST_WORDS_BIGENDIAN
+#if HOST_BIG_ENDIAN
#define BIG 1
#else
#define BIG 0
#endif
-#ifdef HOST_WORDS_BIGENDIAN
+#if HOST_BIG_ENDIAN
#define GET_PLANE(data, p) (((data) >> (24 - (p) * 8)) & 0xff)
#else
#define GET_PLANE(data, p) (((data) >> ((p) * 8)) & 0xff)
@@ -133,7 +133,7 @@ static const uint32_t mask16[16] = {
#undef PAT
-#ifdef HOST_WORDS_BIGENDIAN
+#if HOST_BIG_ENDIAN
#define PAT(x) (x)
#else
#define PAT(x) cbswap_32(x)
@@ -1296,7 +1296,7 @@ static void vga_draw_text(VGACommonState *s, int full_update)
if (cx > cx_max)
cx_max = cx;
*ch_attr_ptr = ch_attr;
-#ifdef HOST_WORDS_BIGENDIAN
+#if HOST_BIG_ENDIAN
ch = ch_attr >> 8;
cattr = ch_attr & 0xff;
#else
@@ -1477,7 +1477,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
vga_draw_line_func *vga_draw_line = NULL;
bool share_surface, force_shadow = false;
pixman_format_code_t format;
-#ifdef HOST_WORDS_BIGENDIAN
+#if HOST_BIG_ENDIAN
bool byteswap = !s->big_endian_fb;
#else
bool byteswap = s->big_endian_fb;
@@ -2242,7 +2242,7 @@ bool vga_common_init(VGACommonState *s, Object *obj, Error **errp)
* into a device attribute set by the machine/platform to remove
* all target endian dependencies from this file.
*/
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
s->default_endian_fb = true;
#else
s->default_endian_fb = false;
diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index 6cc4313..0bca887 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -108,7 +108,7 @@ static void virtio_gpu_gl_device_realize(DeviceState *qdev, Error **errp)
{
VirtIOGPU *g = VIRTIO_GPU(qdev);
-#if defined(HOST_WORDS_BIGENDIAN)
+#if HOST_BIG_ENDIAN
error_setg(errp, "virgl is not supported on bigendian platforms");
return;
#endif
diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabuf.c
index 1597921..8bdf4ba 100644
--- a/hw/display/virtio-gpu-udmabuf.c
+++ b/hw/display/virtio-gpu-udmabuf.c
@@ -13,7 +13,6 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
-#include "qemu-common.h"
#include "qemu/iov.h"
#include "ui/console.h"
#include "hw/virtio/virtio-gpu.h"
diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c
index 31ce01b..08e5938 100644
--- a/hw/dma/pl330.c
+++ b/hw/dma/pl330.c
@@ -15,7 +15,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "hw/irq.h"
#include "hw/qdev-properties.h"
#include "hw/sysbus.h"
diff --git a/hw/dma/xlnx_dpdma.c b/hw/dma/xlnx_dpdma.c
index 2d7eae7..dd66be5 100644
--- a/hw/dma/xlnx_dpdma.c
+++ b/hw/dma/xlnx_dpdma.c
@@ -23,7 +23,7 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qemu/log.h"
#include "qemu/module.h"
#include "hw/dma/xlnx_dpdma.h"
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 98b30e0..f7595c0 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -4,7 +4,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "cpu.h"
#include "elf.h"
diff --git a/hw/hyperv/Kconfig b/hw/hyperv/Kconfig
index 3fbfe41..fcf6590 100644
--- a/hw/hyperv/Kconfig
+++ b/hw/hyperv/Kconfig
@@ -11,3 +11,8 @@ config VMBUS
bool
default y
depends on HYPERV
+
+config SYNDBG
+ bool
+ default y
+ depends on VMBUS
diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
index cb1074f..4a1b59c 100644
--- a/hw/hyperv/hyperv.c
+++ b/hw/hyperv/hyperv.c
@@ -27,13 +27,16 @@ struct SynICState {
CPUState *cs;
- bool enabled;
+ bool sctl_enabled;
hwaddr msg_page_addr;
hwaddr event_page_addr;
MemoryRegion msg_page_mr;
MemoryRegion event_page_mr;
struct hyperv_message_page *msg_page;
struct hyperv_event_flags_page *event_page;
+
+ QemuMutex sint_routes_mutex;
+ QLIST_HEAD(, HvSintRoute) sint_routes;
};
#define TYPE_SYNIC "hyperv-synic"
@@ -51,11 +54,11 @@ static SynICState *get_synic(CPUState *cs)
return SYNIC(object_resolve_path_component(OBJECT(cs), "synic"));
}
-static void synic_update(SynICState *synic, bool enable,
+static void synic_update(SynICState *synic, bool sctl_enable,
hwaddr msg_page_addr, hwaddr event_page_addr)
{
- synic->enabled = enable;
+ synic->sctl_enabled = sctl_enable;
if (synic->msg_page_addr != msg_page_addr) {
if (synic->msg_page_addr) {
memory_region_del_subregion(get_system_memory(),
@@ -80,7 +83,7 @@ static void synic_update(SynICState *synic, bool enable,
}
}
-void hyperv_synic_update(CPUState *cs, bool enable,
+void hyperv_synic_update(CPUState *cs, bool sctl_enable,
hwaddr msg_page_addr, hwaddr event_page_addr)
{
SynICState *synic = get_synic(cs);
@@ -89,7 +92,7 @@ void hyperv_synic_update(CPUState *cs, bool enable,
return;
}
- synic_update(synic, enable, msg_page_addr, event_page_addr);
+ synic_update(synic, sctl_enable, msg_page_addr, event_page_addr);
}
static void synic_realize(DeviceState *dev, Error **errp)
@@ -110,16 +113,20 @@ static void synic_realize(DeviceState *dev, Error **errp)
sizeof(*synic->event_page), &error_abort);
synic->msg_page = memory_region_get_ram_ptr(&synic->msg_page_mr);
synic->event_page = memory_region_get_ram_ptr(&synic->event_page_mr);
+ qemu_mutex_init(&synic->sint_routes_mutex);
+ QLIST_INIT(&synic->sint_routes);
g_free(msgp_name);
g_free(eventp_name);
}
+
static void synic_reset(DeviceState *dev)
{
SynICState *synic = SYNIC(dev);
memset(synic->msg_page, 0, sizeof(*synic->msg_page));
memset(synic->event_page, 0, sizeof(*synic->event_page));
synic_update(synic, false, 0, 0);
+ assert(QLIST_EMPTY(&synic->sint_routes));
}
static void synic_class_init(ObjectClass *klass, void *data)
@@ -214,6 +221,7 @@ struct HvSintRoute {
HvSintStagedMessage *staged_msg;
unsigned refcount;
+ QLIST_ENTRY(HvSintRoute) link;
};
static CPUState *hyperv_find_vcpu(uint32_t vp_index)
@@ -259,7 +267,7 @@ static void cpu_post_msg(CPUState *cs, run_on_cpu_data data)
assert(staged_msg->state == HV_STAGED_MSG_BUSY);
- if (!synic->enabled || !synic->msg_page_addr) {
+ if (!synic->msg_page_addr) {
staged_msg->status = -ENXIO;
goto posted;
}
@@ -343,7 +351,7 @@ int hyperv_set_event_flag(HvSintRoute *sint_route, unsigned eventno)
if (eventno > HV_EVENT_FLAGS_COUNT) {
return -EINVAL;
}
- if (!synic->enabled || !synic->event_page_addr) {
+ if (!synic->sctl_enabled || !synic->event_page_addr) {
return -ENXIO;
}
@@ -364,11 +372,12 @@ int hyperv_set_event_flag(HvSintRoute *sint_route, unsigned eventno)
HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
HvSintMsgCb cb, void *cb_data)
{
- HvSintRoute *sint_route;
- EventNotifier *ack_notifier;
+ HvSintRoute *sint_route = NULL;
+ EventNotifier *ack_notifier = NULL;
int r, gsi;
CPUState *cs;
SynICState *synic;
+ bool ack_event_initialized = false;
cs = hyperv_find_vcpu(vp_index);
if (!cs) {
@@ -381,57 +390,77 @@ HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
}
sint_route = g_new0(HvSintRoute, 1);
- r = event_notifier_init(&sint_route->sint_set_notifier, false);
- if (r) {
- goto err;
+ if (!sint_route) {
+ return NULL;
}
+ sint_route->synic = synic;
+ sint_route->sint = sint;
+ sint_route->refcount = 1;
ack_notifier = cb ? &sint_route->sint_ack_notifier : NULL;
if (ack_notifier) {
sint_route->staged_msg = g_new0(HvSintStagedMessage, 1);
+ if (!sint_route->staged_msg) {
+ goto cleanup_err_sint;
+ }
sint_route->staged_msg->cb = cb;
sint_route->staged_msg->cb_data = cb_data;
r = event_notifier_init(ack_notifier, false);
if (r) {
- goto err_sint_set_notifier;
+ goto cleanup_err_sint;
}
-
event_notifier_set_handler(ack_notifier, sint_ack_handler);
+ ack_event_initialized = true;
+ }
+
+ /* See if we are done or we need to setup a GSI for this SintRoute */
+ if (!synic->sctl_enabled) {
+ goto cleanup;
+ }
+
+ /* We need to setup a GSI for this SintRoute */
+ r = event_notifier_init(&sint_route->sint_set_notifier, false);
+ if (r) {
+ goto cleanup_err_sint;
}
gsi = kvm_irqchip_add_hv_sint_route(kvm_state, vp_index, sint);
if (gsi < 0) {
- goto err_gsi;
+ goto cleanup_err_sint_notifier;
}
r = kvm_irqchip_add_irqfd_notifier_gsi(kvm_state,
&sint_route->sint_set_notifier,
ack_notifier, gsi);
if (r) {
- goto err_irqfd;
+ goto cleanup_err_irqfd;
}
sint_route->gsi = gsi;
- sint_route->synic = synic;
- sint_route->sint = sint;
- sint_route->refcount = 1;
-
+cleanup:
+ qemu_mutex_lock(&synic->sint_routes_mutex);
+ QLIST_INSERT_HEAD(&synic->sint_routes, sint_route, link);
+ qemu_mutex_unlock(&synic->sint_routes_mutex);
return sint_route;
-err_irqfd:
+cleanup_err_irqfd:
kvm_irqchip_release_virq(kvm_state, gsi);
-err_gsi:
+
+cleanup_err_sint_notifier:
+ event_notifier_cleanup(&sint_route->sint_set_notifier);
+
+cleanup_err_sint:
if (ack_notifier) {
- event_notifier_set_handler(ack_notifier, NULL);
- event_notifier_cleanup(ack_notifier);
+ if (ack_event_initialized) {
+ event_notifier_set_handler(ack_notifier, NULL);
+ event_notifier_cleanup(ack_notifier);
+ }
+
g_free(sint_route->staged_msg);
}
-err_sint_set_notifier:
- event_notifier_cleanup(&sint_route->sint_set_notifier);
-err:
- g_free(sint_route);
+ g_free(sint_route);
return NULL;
}
@@ -442,6 +471,8 @@ void hyperv_sint_route_ref(HvSintRoute *sint_route)
void hyperv_sint_route_unref(HvSintRoute *sint_route)
{
+ SynICState *synic;
+
if (!sint_route) {
return;
}
@@ -452,21 +483,33 @@ void hyperv_sint_route_unref(HvSintRoute *sint_route)
return;
}
- kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state,
- &sint_route->sint_set_notifier,
- sint_route->gsi);
- kvm_irqchip_release_virq(kvm_state, sint_route->gsi);
+ synic = sint_route->synic;
+ qemu_mutex_lock(&synic->sint_routes_mutex);
+ QLIST_REMOVE(sint_route, link);
+ qemu_mutex_unlock(&synic->sint_routes_mutex);
+
+ if (sint_route->gsi) {
+ kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state,
+ &sint_route->sint_set_notifier,
+ sint_route->gsi);
+ kvm_irqchip_release_virq(kvm_state, sint_route->gsi);
+ event_notifier_cleanup(&sint_route->sint_set_notifier);
+ }
+
if (sint_route->staged_msg) {
event_notifier_set_handler(&sint_route->sint_ack_notifier, NULL);
event_notifier_cleanup(&sint_route->sint_ack_notifier);
g_free(sint_route->staged_msg);
}
- event_notifier_cleanup(&sint_route->sint_set_notifier);
g_free(sint_route);
}
int hyperv_sint_route_set_sint(HvSintRoute *sint_route)
{
+ if (!sint_route->gsi) {
+ return 0;
+ }
+
return event_notifier_set(&sint_route->sint_set_notifier);
}
@@ -661,3 +704,246 @@ uint16_t hyperv_hcall_signal_event(uint64_t param, bool fast)
}
return HV_STATUS_INVALID_CONNECTION_ID;
}
+
+static HvSynDbgHandler hv_syndbg_handler;
+static void *hv_syndbg_context;
+
+void hyperv_set_syndbg_handler(HvSynDbgHandler handler, void *context)
+{
+ assert(!hv_syndbg_handler);
+ hv_syndbg_handler = handler;
+ hv_syndbg_context = context;
+}
+
+uint16_t hyperv_hcall_reset_dbg_session(uint64_t outgpa)
+{
+ uint16_t ret;
+ HvSynDbgMsg msg;
+ struct hyperv_reset_debug_session_output *reset_dbg_session = NULL;
+ hwaddr len;
+
+ if (!hv_syndbg_handler) {
+ ret = HV_STATUS_INVALID_HYPERCALL_CODE;
+ goto cleanup;
+ }
+
+ len = sizeof(*reset_dbg_session);
+ reset_dbg_session = cpu_physical_memory_map(outgpa, &len, 1);
+ if (!reset_dbg_session || len < sizeof(*reset_dbg_session)) {
+ ret = HV_STATUS_INSUFFICIENT_MEMORY;
+ goto cleanup;
+ }
+
+ msg.type = HV_SYNDBG_MSG_CONNECTION_INFO;
+ ret = hv_syndbg_handler(hv_syndbg_context, &msg);
+ if (ret) {
+ goto cleanup;
+ }
+
+ reset_dbg_session->host_ip = msg.u.connection_info.host_ip;
+ reset_dbg_session->host_port = msg.u.connection_info.host_port;
+ /* The following fields are only used as validation for KDVM */
+ memset(&reset_dbg_session->host_mac, 0,
+ sizeof(reset_dbg_session->host_mac));
+ reset_dbg_session->target_ip = msg.u.connection_info.host_ip;
+ reset_dbg_session->target_port = msg.u.connection_info.host_port;
+ memset(&reset_dbg_session->target_mac, 0,
+ sizeof(reset_dbg_session->target_mac));
+cleanup:
+ if (reset_dbg_session) {
+ cpu_physical_memory_unmap(reset_dbg_session,
+ sizeof(*reset_dbg_session), 1, len);
+ }
+
+ return ret;
+}
+
+uint16_t hyperv_hcall_retreive_dbg_data(uint64_t ingpa, uint64_t outgpa,
+ bool fast)
+{
+ uint16_t ret;
+ struct hyperv_retrieve_debug_data_input *debug_data_in = NULL;
+ struct hyperv_retrieve_debug_data_output *debug_data_out = NULL;
+ hwaddr in_len, out_len;
+ HvSynDbgMsg msg;
+
+ if (fast || !hv_syndbg_handler) {
+ ret = HV_STATUS_INVALID_HYPERCALL_CODE;
+ goto cleanup;
+ }
+
+ in_len = sizeof(*debug_data_in);
+ debug_data_in = cpu_physical_memory_map(ingpa, &in_len, 0);
+ if (!debug_data_in || in_len < sizeof(*debug_data_in)) {
+ ret = HV_STATUS_INSUFFICIENT_MEMORY;
+ goto cleanup;
+ }
+
+ out_len = sizeof(*debug_data_out);
+ debug_data_out = cpu_physical_memory_map(outgpa, &out_len, 1);
+ if (!debug_data_out || out_len < sizeof(*debug_data_out)) {
+ ret = HV_STATUS_INSUFFICIENT_MEMORY;
+ goto cleanup;
+ }
+
+ msg.type = HV_SYNDBG_MSG_RECV;
+ msg.u.recv.buf_gpa = outgpa + sizeof(*debug_data_out);
+ msg.u.recv.count = TARGET_PAGE_SIZE - sizeof(*debug_data_out);
+ msg.u.recv.options = debug_data_in->options;
+ msg.u.recv.timeout = debug_data_in->timeout;
+ msg.u.recv.is_raw = true;
+ ret = hv_syndbg_handler(hv_syndbg_context, &msg);
+ if (ret == HV_STATUS_NO_DATA) {
+ debug_data_out->retrieved_count = 0;
+ debug_data_out->remaining_count = debug_data_in->count;
+ goto cleanup;
+ } else if (ret != HV_STATUS_SUCCESS) {
+ goto cleanup;
+ }
+
+ debug_data_out->retrieved_count = msg.u.recv.retrieved_count;
+ debug_data_out->remaining_count =
+ debug_data_in->count - msg.u.recv.retrieved_count;
+cleanup:
+ if (debug_data_out) {
+ cpu_physical_memory_unmap(debug_data_out, sizeof(*debug_data_out), 1,
+ out_len);
+ }
+
+ if (debug_data_in) {
+ cpu_physical_memory_unmap(debug_data_in, sizeof(*debug_data_in), 0,
+ in_len);
+ }
+
+ return ret;
+}
+
+uint16_t hyperv_hcall_post_dbg_data(uint64_t ingpa, uint64_t outgpa, bool fast)
+{
+ uint16_t ret;
+ struct hyperv_post_debug_data_input *post_data_in = NULL;
+ struct hyperv_post_debug_data_output *post_data_out = NULL;
+ hwaddr in_len, out_len;
+ HvSynDbgMsg msg;
+
+ if (fast || !hv_syndbg_handler) {
+ ret = HV_STATUS_INVALID_HYPERCALL_CODE;
+ goto cleanup;
+ }
+
+ in_len = sizeof(*post_data_in);
+ post_data_in = cpu_physical_memory_map(ingpa, &in_len, 0);
+ if (!post_data_in || in_len < sizeof(*post_data_in)) {
+ ret = HV_STATUS_INSUFFICIENT_MEMORY;
+ goto cleanup;
+ }
+
+ if (post_data_in->count > TARGET_PAGE_SIZE - sizeof(*post_data_in)) {
+ ret = HV_STATUS_INVALID_PARAMETER;
+ goto cleanup;
+ }
+
+ out_len = sizeof(*post_data_out);
+ post_data_out = cpu_physical_memory_map(outgpa, &out_len, 1);
+ if (!post_data_out || out_len < sizeof(*post_data_out)) {
+ ret = HV_STATUS_INSUFFICIENT_MEMORY;
+ goto cleanup;
+ }
+
+ msg.type = HV_SYNDBG_MSG_SEND;
+ msg.u.send.buf_gpa = ingpa + sizeof(*post_data_in);
+ msg.u.send.count = post_data_in->count;
+ msg.u.send.is_raw = true;
+ ret = hv_syndbg_handler(hv_syndbg_context, &msg);
+ if (ret != HV_STATUS_SUCCESS) {
+ goto cleanup;
+ }
+
+ post_data_out->pending_count = msg.u.send.pending_count;
+ ret = post_data_out->pending_count ? HV_STATUS_INSUFFICIENT_BUFFERS :
+ HV_STATUS_SUCCESS;
+cleanup:
+ if (post_data_out) {
+ cpu_physical_memory_unmap(post_data_out,
+ sizeof(*post_data_out), 1, out_len);
+ }
+
+ if (post_data_in) {
+ cpu_physical_memory_unmap(post_data_in,
+ sizeof(*post_data_in), 0, in_len);
+ }
+
+ return ret;
+}
+
+uint32_t hyperv_syndbg_send(uint64_t ingpa, uint32_t count)
+{
+ HvSynDbgMsg msg;
+
+ if (!hv_syndbg_handler) {
+ return HV_SYNDBG_STATUS_INVALID;
+ }
+
+ msg.type = HV_SYNDBG_MSG_SEND;
+ msg.u.send.buf_gpa = ingpa;
+ msg.u.send.count = count;
+ msg.u.send.is_raw = false;
+ if (hv_syndbg_handler(hv_syndbg_context, &msg)) {
+ return HV_SYNDBG_STATUS_INVALID;
+ }
+
+ return HV_SYNDBG_STATUS_SEND_SUCCESS;
+}
+
+uint32_t hyperv_syndbg_recv(uint64_t ingpa, uint32_t count)
+{
+ uint16_t ret;
+ HvSynDbgMsg msg;
+
+ if (!hv_syndbg_handler) {
+ return HV_SYNDBG_STATUS_INVALID;
+ }
+
+ msg.type = HV_SYNDBG_MSG_RECV;
+ msg.u.recv.buf_gpa = ingpa;
+ msg.u.recv.count = count;
+ msg.u.recv.options = 0;
+ msg.u.recv.timeout = 0;
+ msg.u.recv.is_raw = false;
+ ret = hv_syndbg_handler(hv_syndbg_context, &msg);
+ if (ret != HV_STATUS_SUCCESS) {
+ return 0;
+ }
+
+ return HV_SYNDBG_STATUS_SET_SIZE(HV_SYNDBG_STATUS_RECV_SUCCESS,
+ msg.u.recv.retrieved_count);
+}
+
+void hyperv_syndbg_set_pending_page(uint64_t ingpa)
+{
+ HvSynDbgMsg msg;
+
+ if (!hv_syndbg_handler) {
+ return;
+ }
+
+ msg.type = HV_SYNDBG_MSG_SET_PENDING_PAGE;
+ msg.u.pending_page.buf_gpa = ingpa;
+ hv_syndbg_handler(hv_syndbg_context, &msg);
+}
+
+uint64_t hyperv_syndbg_query_options(void)
+{
+ HvSynDbgMsg msg;
+
+ if (!hv_syndbg_handler) {
+ return 0;
+ }
+
+ msg.type = HV_SYNDBG_MSG_QUERY_OPTIONS;
+ if (hv_syndbg_handler(hv_syndbg_context, &msg) != HV_STATUS_SUCCESS) {
+ return 0;
+ }
+
+ return msg.u.query_options.options;
+}
diff --git a/hw/hyperv/meson.build b/hw/hyperv/meson.build
index 1367e29..b43f119 100644
--- a/hw/hyperv/meson.build
+++ b/hw/hyperv/meson.build
@@ -1,3 +1,4 @@
specific_ss.add(when: 'CONFIG_HYPERV', if_true: files('hyperv.c'))
specific_ss.add(when: 'CONFIG_HYPERV_TESTDEV', if_true: files('hyperv_testdev.c'))
specific_ss.add(when: 'CONFIG_VMBUS', if_true: files('vmbus.c'))
+specific_ss.add(when: 'CONFIG_SYNDBG', if_true: files('syndbg.c'))
diff --git a/hw/hyperv/syndbg.c b/hw/hyperv/syndbg.c
new file mode 100644
index 0000000..89ae19b
--- /dev/null
+++ b/hw/hyperv/syndbg.c
@@ -0,0 +1,402 @@
+/*
+ * QEMU Hyper-V Synthetic Debugging device
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/ctype.h"
+#include "qemu/osdep.h"
+#include "qemu/error-report.h"
+#include "qemu/main-loop.h"
+#include "qemu/sockets.h"
+#include "qemu-common.h"
+#include "qapi/error.h"
+#include "migration/vmstate.h"
+#include "hw/qdev-properties.h"
+#include "hw/loader.h"
+#include "cpu.h"
+#include "hw/hyperv/hyperv.h"
+#include "hw/hyperv/vmbus-bridge.h"
+#include "hw/hyperv/hyperv-proto.h"
+#include "net/net.h"
+#include "net/eth.h"
+#include "net/checksum.h"
+#include "trace.h"
+
+#define TYPE_HV_SYNDBG "hv-syndbg"
+
+typedef struct HvSynDbg {
+ DeviceState parent_obj;
+
+ char *host_ip;
+ uint16_t host_port;
+ bool use_hcalls;
+
+ uint32_t target_ip;
+ struct sockaddr_in servaddr;
+ int socket;
+ bool has_data_pending;
+ uint64_t pending_page_gpa;
+} HvSynDbg;
+
+#define HVSYNDBG(obj) OBJECT_CHECK(HvSynDbg, (obj), TYPE_HV_SYNDBG)
+
+/* returns NULL unless there is exactly one HV Synth debug device */
+static HvSynDbg *hv_syndbg_find(void)
+{
+ /* Returns NULL unless there is exactly one hvsd device */
+ return HVSYNDBG(object_resolve_path_type("", TYPE_HV_SYNDBG, NULL));
+}
+
+static void set_pending_state(HvSynDbg *syndbg, bool has_pending)
+{
+ hwaddr out_len;
+ void *out_data;
+
+ syndbg->has_data_pending = has_pending;
+
+ if (!syndbg->pending_page_gpa) {
+ return;
+ }
+
+ out_len = 1;
+ out_data = cpu_physical_memory_map(syndbg->pending_page_gpa, &out_len, 1);
+ if (out_data) {
+ *(uint8_t *)out_data = !!has_pending;
+ cpu_physical_memory_unmap(out_data, out_len, 1, out_len);
+ }
+}
+
+static bool get_udb_pkt_data(void *p, uint32_t len, uint32_t *data_ofs,
+ uint32_t *src_ip)
+{
+ uint32_t offset, curr_len = len;
+
+ if (curr_len < sizeof(struct eth_header) ||
+ (be16_to_cpu(PKT_GET_ETH_HDR(p)->h_proto) != ETH_P_IP)) {
+ return false;
+ }
+ offset = sizeof(struct eth_header);
+ curr_len -= sizeof(struct eth_header);
+
+ if (curr_len < sizeof(struct ip_header) ||
+ PKT_GET_IP_HDR(p)->ip_p != IP_PROTO_UDP) {
+ return false;
+ }
+ offset += PKT_GET_IP_HDR_LEN(p);
+ curr_len -= PKT_GET_IP_HDR_LEN(p);
+
+ if (curr_len < sizeof(struct udp_header)) {
+ return false;
+ }
+
+ offset += sizeof(struct udp_header);
+ *data_ofs = offset;
+ *src_ip = PKT_GET_IP_HDR(p)->ip_src;
+ return true;
+}
+
+static uint16_t handle_send_msg(HvSynDbg *syndbg, uint64_t ingpa,
+ uint32_t count, bool is_raw,
+ uint32_t *pending_count)
+{
+ uint16_t ret;
+ hwaddr data_len;
+ void *debug_data = NULL;
+ uint32_t udp_data_ofs = 0;
+ const void *pkt_data;
+ int sent_count;
+
+ data_len = count;
+ debug_data = cpu_physical_memory_map(ingpa, &data_len, 0);
+ if (!debug_data || data_len < count) {
+ ret = HV_STATUS_INSUFFICIENT_MEMORY;
+ goto cleanup;
+ }
+
+ if (is_raw &&
+ !get_udb_pkt_data(debug_data, count, &udp_data_ofs,
+ &syndbg->target_ip)) {
+ ret = HV_STATUS_SUCCESS;
+ goto cleanup;
+ }
+
+ pkt_data = (const void *)((uintptr_t)debug_data + udp_data_ofs);
+ sent_count = sendto(syndbg->socket, pkt_data, count - udp_data_ofs,
+ MSG_NOSIGNAL, NULL, 0);
+ if (sent_count == -1) {
+ ret = HV_STATUS_INSUFFICIENT_MEMORY;
+ goto cleanup;
+ }
+
+ *pending_count = count - (sent_count + udp_data_ofs);
+ ret = HV_STATUS_SUCCESS;
+cleanup:
+ if (debug_data) {
+ cpu_physical_memory_unmap(debug_data, count, 0, data_len);
+ }
+
+ return ret;
+}
+
+#define UDP_PKT_HEADER_SIZE \
+ (sizeof(struct eth_header) + sizeof(struct ip_header) +\
+ sizeof(struct udp_header))
+
+static bool create_udp_pkt(HvSynDbg *syndbg, void *pkt, uint32_t pkt_len,
+ void *udp_data, uint32_t udp_data_len)
+{
+ struct udp_header *udp_part;
+
+ if (pkt_len < (UDP_PKT_HEADER_SIZE + udp_data_len)) {
+ return false;
+ }
+
+ /* Setup the eth */
+ memset(&PKT_GET_ETH_HDR(pkt)->h_source, 0, ETH_ALEN);
+ memset(&PKT_GET_ETH_HDR(pkt)->h_dest, 0, ETH_ALEN);
+ PKT_GET_ETH_HDR(pkt)->h_proto = cpu_to_be16(ETH_P_IP);
+
+ /* Setup the ip */
+ PKT_GET_IP_HDR(pkt)->ip_ver_len =
+ (4 << 4) | (sizeof(struct ip_header) >> 2);
+ PKT_GET_IP_HDR(pkt)->ip_tos = 0;
+ PKT_GET_IP_HDR(pkt)->ip_id = 0;
+ PKT_GET_IP_HDR(pkt)->ip_off = 0;
+ PKT_GET_IP_HDR(pkt)->ip_ttl = 64; /* IPDEFTTL */
+ PKT_GET_IP_HDR(pkt)->ip_p = IP_PROTO_UDP;
+ PKT_GET_IP_HDR(pkt)->ip_src = syndbg->servaddr.sin_addr.s_addr;
+ PKT_GET_IP_HDR(pkt)->ip_dst = syndbg->target_ip;
+ PKT_GET_IP_HDR(pkt)->ip_len =
+ cpu_to_be16(sizeof(struct ip_header) + sizeof(struct udp_header) +
+ udp_data_len);
+ eth_fix_ip4_checksum(PKT_GET_IP_HDR(pkt), PKT_GET_IP_HDR_LEN(pkt));
+
+ udp_part = (struct udp_header *)((uintptr_t)pkt +
+ sizeof(struct eth_header) +
+ PKT_GET_IP_HDR_LEN(pkt));
+ udp_part->uh_sport = syndbg->servaddr.sin_port;
+ udp_part->uh_dport = syndbg->servaddr.sin_port;
+ udp_part->uh_ulen = cpu_to_be16(sizeof(struct udp_header) + udp_data_len);
+ memcpy(udp_part + 1, udp_data, udp_data_len);
+ net_checksum_calculate(pkt, UDP_PKT_HEADER_SIZE + udp_data_len, CSUM_ALL);
+ return true;
+}
+
+static uint16_t handle_recv_msg(HvSynDbg *syndbg, uint64_t outgpa,
+ uint32_t count, bool is_raw, uint32_t options,
+ uint64_t timeout, uint32_t *retrieved_count)
+{
+ uint16_t ret;
+ uint8_t data_buf[TARGET_PAGE_SIZE - UDP_PKT_HEADER_SIZE];
+ hwaddr out_len;
+ void *out_data;
+ ssize_t recv_byte_count;
+
+ /* TODO: Handle options and timeout */
+ (void)options;
+ (void)timeout;
+
+ if (!syndbg->has_data_pending) {
+ recv_byte_count = 0;
+ } else {
+ recv_byte_count = recv(syndbg->socket, data_buf,
+ MIN(sizeof(data_buf), count), MSG_WAITALL);
+ if (recv_byte_count == -1) {
+ return HV_STATUS_INVALID_PARAMETER;
+ }
+ }
+
+ if (!recv_byte_count) {
+ *retrieved_count = 0;
+ return HV_STATUS_NO_DATA;
+ }
+
+ set_pending_state(syndbg, false);
+
+ out_len = recv_byte_count;
+ if (is_raw) {
+ out_len += UDP_PKT_HEADER_SIZE;
+ }
+ out_data = cpu_physical_memory_map(outgpa, &out_len, 1);
+ if (!out_data) {
+ return HV_STATUS_INSUFFICIENT_MEMORY;
+ }
+
+ if (is_raw &&
+ !create_udp_pkt(syndbg, out_data,
+ recv_byte_count + UDP_PKT_HEADER_SIZE,
+ data_buf, recv_byte_count)) {
+ ret = HV_STATUS_INSUFFICIENT_MEMORY;
+ goto cleanup_out_data;
+ } else if (!is_raw) {
+ memcpy(out_data, data_buf, recv_byte_count);
+ }
+
+ *retrieved_count = recv_byte_count;
+ if (is_raw) {
+ *retrieved_count += UDP_PKT_HEADER_SIZE;
+ }
+ ret = HV_STATUS_SUCCESS;
+
+cleanup_out_data:
+ cpu_physical_memory_unmap(out_data, out_len, 1, out_len);
+ return ret;
+}
+
+static uint16_t hv_syndbg_handler(void *context, HvSynDbgMsg *msg)
+{
+ HvSynDbg *syndbg = context;
+ uint16_t ret = HV_STATUS_INVALID_HYPERCALL_CODE;
+
+ switch (msg->type) {
+ case HV_SYNDBG_MSG_CONNECTION_INFO:
+ msg->u.connection_info.host_ip =
+ ntohl(syndbg->servaddr.sin_addr.s_addr);
+ msg->u.connection_info.host_port =
+ ntohs(syndbg->servaddr.sin_port);
+ ret = HV_STATUS_SUCCESS;
+ break;
+ case HV_SYNDBG_MSG_SEND:
+ ret = handle_send_msg(syndbg, msg->u.send.buf_gpa, msg->u.send.count,
+ msg->u.send.is_raw, &msg->u.send.pending_count);
+ break;
+ case HV_SYNDBG_MSG_RECV:
+ ret = handle_recv_msg(syndbg, msg->u.recv.buf_gpa, msg->u.recv.count,
+ msg->u.recv.is_raw, msg->u.recv.options,
+ msg->u.recv.timeout,
+ &msg->u.recv.retrieved_count);
+ break;
+ case HV_SYNDBG_MSG_SET_PENDING_PAGE:
+ syndbg->pending_page_gpa = msg->u.pending_page.buf_gpa;
+ ret = HV_STATUS_SUCCESS;
+ break;
+ case HV_SYNDBG_MSG_QUERY_OPTIONS:
+ msg->u.query_options.options = 0;
+ if (syndbg->use_hcalls) {
+ msg->u.query_options.options = HV_X64_SYNDBG_OPTION_USE_HCALLS;
+ }
+ ret = HV_STATUS_SUCCESS;
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+}
+
+static void hv_syndbg_recv_event(void *opaque)
+{
+ HvSynDbg *syndbg = opaque;
+ struct timeval tv;
+ fd_set rfds;
+
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ FD_ZERO(&rfds);
+ FD_SET(syndbg->socket, &rfds);
+ if (select(syndbg->socket + 1, &rfds, NULL, NULL, &tv) > 0) {
+ set_pending_state(syndbg, true);
+ }
+}
+
+static void hv_syndbg_realize(DeviceState *dev, Error **errp)
+{
+ HvSynDbg *syndbg = HVSYNDBG(dev);
+
+ if (!hv_syndbg_find()) {
+ error_setg(errp, "at most one %s device is permitted", TYPE_HV_SYNDBG);
+ return;
+ }
+
+ if (!vmbus_bridge_find()) {
+ error_setg(errp, "%s device requires vmbus-bridge device",
+ TYPE_HV_SYNDBG);
+ return;
+ }
+
+ /* Parse and host_ip */
+ if (qemu_isdigit(syndbg->host_ip[0])) {
+ syndbg->servaddr.sin_addr.s_addr = inet_addr(syndbg->host_ip);
+ } else {
+ struct hostent *he = gethostbyname(syndbg->host_ip);
+ if (!he) {
+ error_setg(errp, "%s failed to resolve host name %s",
+ TYPE_HV_SYNDBG, syndbg->host_ip);
+ return;
+ }
+ syndbg->servaddr.sin_addr = *(struct in_addr *)he->h_addr;
+ }
+
+ syndbg->socket = socket(AF_INET, SOCK_DGRAM, 0);
+ if (syndbg->socket < 0) {
+ error_setg(errp, "%s failed to create socket", TYPE_HV_SYNDBG);
+ return;
+ }
+
+ qemu_set_nonblock(syndbg->socket);
+
+ syndbg->servaddr.sin_port = htons(syndbg->host_port);
+ syndbg->servaddr.sin_family = AF_INET;
+ if (connect(syndbg->socket, (struct sockaddr *)&syndbg->servaddr,
+ sizeof(syndbg->servaddr)) < 0) {
+ closesocket(syndbg->socket);
+ error_setg(errp, "%s failed to connect to socket", TYPE_HV_SYNDBG);
+ return;
+ }
+
+ syndbg->pending_page_gpa = 0;
+ syndbg->has_data_pending = false;
+ hyperv_set_syndbg_handler(hv_syndbg_handler, syndbg);
+ qemu_set_fd_handler(syndbg->socket, hv_syndbg_recv_event, NULL, syndbg);
+}
+
+static void hv_syndbg_unrealize(DeviceState *dev)
+{
+ HvSynDbg *syndbg = HVSYNDBG(dev);
+
+ if (syndbg->socket > 0) {
+ qemu_set_fd_handler(syndbg->socket, NULL, NULL, NULL);
+ closesocket(syndbg->socket);
+ }
+}
+
+static const VMStateDescription vmstate_hv_syndbg = {
+ .name = TYPE_HV_SYNDBG,
+ .unmigratable = 1,
+};
+
+static Property hv_syndbg_properties[] = {
+ DEFINE_PROP_STRING("host_ip", HvSynDbg, host_ip),
+ DEFINE_PROP_UINT16("host_port", HvSynDbg, host_port, 50000),
+ DEFINE_PROP_BOOL("use_hcalls", HvSynDbg, use_hcalls, false),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void hv_syndbg_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+
+ device_class_set_props(dc, hv_syndbg_properties);
+ dc->fw_name = TYPE_HV_SYNDBG;
+ dc->vmsd = &vmstate_hv_syndbg;
+ dc->realize = hv_syndbg_realize;
+ dc->unrealize = hv_syndbg_unrealize;
+ dc->user_creatable = true;
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+}
+
+static const TypeInfo hv_syndbg_type_info = {
+ .name = TYPE_HV_SYNDBG,
+ .parent = TYPE_DEVICE,
+ .instance_size = sizeof(HvSynDbg),
+ .class_init = hv_syndbg_class_init,
+};
+
+static void hv_syndbg_register_types(void)
+{
+ type_register_static(&hv_syndbg_type_info);
+}
+
+type_init(hv_syndbg_register_types)
diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
index c8b17af..0540047 100644
--- a/hw/i386/pc_sysfw.c
+++ b/hw/i386/pc_sysfw.c
@@ -24,7 +24,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qapi/error.h"
#include "sysemu/block-backend.h"
#include "qemu/error-report.h"
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 4cf107b..bb67272 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -25,7 +25,6 @@
#include "qemu/option.h"
#include "qemu/cutils.h"
#include "qemu/units.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qapi/error.h"
#include "qapi/qmp/qerror.h"
diff --git a/hw/input/vhost-user-input.c b/hw/input/vhost-user-input.c
index 273e96a..aeb0624 100644
--- a/hw/input/vhost-user-input.c
+++ b/hw/input/vhost-user-input.c
@@ -7,7 +7,6 @@
#include "qemu/osdep.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "hw/virtio/virtio-input.h"
diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c
index efe5054..4e86d2d 100644
--- a/hw/intc/s390_flic_kvm.c
+++ b/hw/intc/s390_flic_kvm.c
@@ -24,7 +24,7 @@
#include "trace.h"
#include "qom/object.h"
-#define FLIC_SAVE_INITIAL_SIZE qemu_real_host_page_size
+#define FLIC_SAVE_INITIAL_SIZE qemu_real_host_page_size()
#define FLIC_FAILED (-1UL)
#define FLIC_SAVEVM_VERSION 1
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index f5bfc50..9719d98 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -27,7 +27,6 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "trace.h"
#include "sysemu/kvm.h"
#include "hw/ppc/spapr.h"
diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c
index 93812ee..655207e 100644
--- a/hw/m68k/mcf5208.c
+++ b/hw/m68k/mcf5208.c
@@ -11,7 +11,6 @@
#include "qemu/error-report.h"
#include "qemu/log.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "cpu.h"
#include "hw/irq.h"
diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index 66ca5c0..099a758 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -22,7 +22,6 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "sysemu/sysemu.h"
#include "cpu.h"
diff --git a/hw/m68k/virt.c b/hw/m68k/virt.c
index 8e63028..7de8b5f 100644
--- a/hw/m68k/virt.c
+++ b/hw/m68k/virt.c
@@ -9,7 +9,6 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
-#include "qemu-common.h"
#include "sysemu/sysemu.h"
#include "cpu.h"
#include "hw/boards.h"
diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c
index 8821d00..8b92a98 100644
--- a/hw/microblaze/boot.c
+++ b/hw/microblaze/boot.c
@@ -25,7 +25,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "cpu.h"
#include "qemu/option.h"
@@ -138,7 +137,7 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base,
uint32_t base32;
int big_endian = 0;
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
big_endian = 1;
#endif
diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
index c9f14e7..7b13098 100644
--- a/hw/mips/fuloong2e.c
+++ b/hw/mips/fuloong2e.c
@@ -19,7 +19,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qemu/units.h"
#include "qapi/error.h"
diff --git a/hw/mips/gt64xxx_pci.c b/hw/mips/gt64xxx_pci.c
index e0ff1b5..19d0d98 100644
--- a/hw/mips/gt64xxx_pci.c
+++ b/hw/mips/gt64xxx_pci.c
@@ -986,7 +986,7 @@ static void gt64120_reset(DeviceState *dev)
/* FIXME: Malta specific hw assumptions ahead */
/* CPU Configuration */
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
s->regs[GT_CPU] = 0x00000000;
#else
s->regs[GT_CPU] = 0x00001000;
@@ -1097,7 +1097,7 @@ static void gt64120_reset(DeviceState *dev)
s->regs[GT_TC_CONTROL] = 0x00000000;
/* PCI Internal */
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
s->regs[GT_PCI0_CMD] = 0x00000000;
#else
s->regs[GT_PCI0_CMD] = 0x00010001;
@@ -1118,7 +1118,7 @@ static void gt64120_reset(DeviceState *dev)
s->regs[GT_PCI0_SSCS10_BAR] = 0x00000000;
s->regs[GT_PCI0_SSCS32_BAR] = 0x01000000;
s->regs[GT_PCI0_SCS3BT_BAR] = 0x1f000000;
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
s->regs[GT_PCI1_CMD] = 0x00000000;
#else
s->regs[GT_PCI1_CMD] = 0x00010001;
diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c
index 44f0d48..6598d7d 100644
--- a/hw/mips/jazz.c
+++ b/hw/mips/jazz.c
@@ -23,7 +23,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "hw/clock.h"
#include "hw/mips/mips.h"
@@ -158,7 +157,7 @@ static void mips_jazz_init(MachineState *machine,
[JAZZ_PICA61] = {33333333, 4},
};
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
big_endian = 1;
#else
big_endian = 0;
diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
index ae192db..2553428 100644
--- a/hw/mips/loongson3_virt.c
+++ b/hw/mips/loongson3_virt.c
@@ -24,7 +24,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/units.h"
#include "qemu/cutils.h"
#include "qemu/datadir.h"
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index 6288511..9ffdc5b 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -25,7 +25,6 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
#include "qemu/bitops.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "hw/clock.h"
#include "hw/southbridge/piix.h"
@@ -367,7 +366,7 @@ static uint64_t malta_fpga_read(void *opaque, hwaddr addr,
/* STATUS Register */
case 0x00208:
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
val = 0x00000012;
#else
val = 0x00000010;
@@ -695,7 +694,7 @@ static void write_bootloader_nanomips(uint8_t *base, uint64_t run_addr,
stw_p(p++, 0xe040); stw_p(p++, 0x0681);
/* lui t1, %hi(0xb4000000) */
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
stw_p(p++, 0xe020); stw_p(p++, 0x0be1);
/* lui t0, %hi(0xdf000000) */
@@ -894,7 +893,7 @@ static void write_bootloader(uint8_t *base, uint64_t run_addr,
/* Load BAR registers as done by YAMON */
stl_p(p++, 0x3c09b400); /* lui t1, 0xb400 */
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
stl_p(p++, 0x3c08df00); /* lui t0, 0xdf00 */
#else
stl_p(p++, 0x340800df); /* ori t0, r0, 0x00df */
@@ -903,39 +902,39 @@ static void write_bootloader(uint8_t *base, uint64_t run_addr,
stl_p(p++, 0x3c09bbe0); /* lui t1, 0xbbe0 */
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
stl_p(p++, 0x3c08c000); /* lui t0, 0xc000 */
#else
stl_p(p++, 0x340800c0); /* ori t0, r0, 0x00c0 */
#endif
stl_p(p++, 0xad280048); /* sw t0, 0x0048(t1) */
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
stl_p(p++, 0x3c084000); /* lui t0, 0x4000 */
#else
stl_p(p++, 0x34080040); /* ori t0, r0, 0x0040 */
#endif
stl_p(p++, 0xad280050); /* sw t0, 0x0050(t1) */
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
stl_p(p++, 0x3c088000); /* lui t0, 0x8000 */
#else
stl_p(p++, 0x34080080); /* ori t0, r0, 0x0080 */
#endif
stl_p(p++, 0xad280058); /* sw t0, 0x0058(t1) */
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
stl_p(p++, 0x3c083f00); /* lui t0, 0x3f00 */
#else
stl_p(p++, 0x3408003f); /* ori t0, r0, 0x003f */
#endif
stl_p(p++, 0xad280060); /* sw t0, 0x0060(t1) */
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
stl_p(p++, 0x3c08c100); /* lui t0, 0xc100 */
#else
stl_p(p++, 0x340800c1); /* ori t0, r0, 0x00c1 */
#endif
stl_p(p++, 0xad280080); /* sw t0, 0x0080(t1) */
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
stl_p(p++, 0x3c085e00); /* lui t0, 0x5e00 */
#else
stl_p(p++, 0x3408005e); /* ori t0, r0, 0x005e */
@@ -1030,7 +1029,7 @@ static uint64_t load_kernel(void)
int prom_index = 0;
uint64_t (*xlate_to_kseg0) (void *opaque, uint64_t addr);
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
big_endian = 1;
#else
big_endian = 0;
@@ -1272,7 +1271,7 @@ void mips_malta_init(MachineState *machine)
ram_low_postio);
}
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
be = 1;
#else
be = 0;
@@ -1353,7 +1352,7 @@ void mips_malta_init(MachineState *machine)
* In little endian mode the 32bit words in the bios are swapped,
* a neat trick which allows bi-endian firmware.
*/
-#ifndef TARGET_WORDS_BIGENDIAN
+#if !TARGET_BIG_ENDIAN
{
uint32_t *end, *addr;
const size_t swapsize = MIN(bios_size, 0x3e0000);
diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c
index 27a46bd..39f6444 100644
--- a/hw/mips/mipssim.c
+++ b/hw/mips/mipssim.c
@@ -27,7 +27,6 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "hw/clock.h"
#include "hw/mips/mips.h"
@@ -65,7 +64,7 @@ static uint64_t load_kernel(void)
ram_addr_t initrd_offset;
int big_endian;
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
big_endian = 1;
#else
big_endian = 0;
diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c
index 83020fe..8d939fe 100644
--- a/hw/misc/sbsa_ec.c
+++ b/hw/misc/sbsa_ec.c
@@ -11,7 +11,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/log.h"
#include "hw/sysbus.h"
#include "sysemu/runstate.h"
diff --git a/hw/net/can/ctucan_core.h b/hw/net/can/ctucan_core.h
index bbc09ae..608307a 100644
--- a/hw/net/can/ctucan_core.h
+++ b/hw/net/can/ctucan_core.h
@@ -31,7 +31,7 @@
#include "exec/hwaddr.h"
#include "net/can_emu.h"
-#ifndef HOST_WORDS_BIGENDIAN
+#if !HOST_BIG_ENDIAN
#define __LITTLE_ENDIAN_BITFIELD 1
#endif
diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c
index e7fc082..6d50c39 100644
--- a/hw/net/fsl_etsec/etsec.c
+++ b/hw/net/fsl_etsec/etsec.c
@@ -27,7 +27,6 @@
*/
#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 8f08446..a32589e 100644
--- a/hw/net/fsl_etsec/rings.c
+++ b/hw/net/fsl_etsec/rings.c
@@ -22,7 +22,6 @@
* 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/net/msf2-emac.c b/hw/net/msf2-emac.c
index 9278fdc..7ccd3e5 100644
--- a/hw/net/msf2-emac.c
+++ b/hw/net/msf2-emac.c
@@ -29,7 +29,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/log.h"
#include "qapi/error.h"
#include "hw/registerfields.h"
diff --git a/hw/net/npcm7xx_emc.c b/hw/net/npcm7xx_emc.c
index 9a23289..7c86bb5 100644
--- a/hw/net/npcm7xx_emc.c
+++ b/hw/net/npcm7xx_emc.c
@@ -32,7 +32,6 @@
/* For crc32 */
#include <zlib.h>
-#include "qemu-common.h"
#include "hw/irq.h"
#include "hw/qdev-clock.h"
#include "hw/qdev-properties.h"
diff --git a/hw/net/vmxnet3.h b/hw/net/vmxnet3.h
index 5b3b76b..bf4f6de 100644
--- a/hw/net/vmxnet3.h
+++ b/hw/net/vmxnet3.h
@@ -35,7 +35,7 @@
#define __le32 uint32_t
#define __le64 uint64_t
-#if defined(HOST_WORDS_BIGENDIAN)
+#if HOST_BIG_ENDIAN
#define __BIG_ENDIAN_BITFIELD
#else
#endif
@@ -800,7 +800,7 @@ struct Vmxnet3_DriverShared {
#undef __le16
#undef __le32
#undef __le64
-#if defined(HOST_WORDS_BIGENDIAN)
+#if HOST_BIG_ENDIAN
#undef __BIG_ENDIAN_BITFIELD
#endif
diff --git a/hw/nios2/boot.c b/hw/nios2/boot.c
index 5b3e4ef..07b8d87 100644
--- a/hw/nios2/boot.c
+++ b/hw/nios2/boot.c
@@ -30,7 +30,6 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
@@ -140,7 +139,7 @@ void nios2_load_kernel(Nios2CPU *cpu, hwaddr ddr_base,
uint64_t entry, high;
int big_endian = 0;
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
big_endian = 1;
#endif
diff --git a/hw/nios2/generic_nommu.c b/hw/nios2/generic_nommu.c
index fbc18db..48edb3a 100644
--- a/hw/nios2/generic_nommu.c
+++ b/hw/nios2/generic_nommu.c
@@ -28,7 +28,6 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "hw/char/serial.h"
#include "hw/boards.h"
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index e5f3c981..4125cbe 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -23,7 +23,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "sysemu/sysemu.h"
#include "sysemu/dma.h"
@@ -622,9 +621,9 @@ static bool fw_cfg_acpi_mr_restore(void *opaque)
FWCfgState *s = opaque;
bool mr_aligned;
- mr_aligned = QEMU_IS_ALIGNED(s->table_mr_size, qemu_real_host_page_size) &&
- QEMU_IS_ALIGNED(s->linker_mr_size, qemu_real_host_page_size) &&
- QEMU_IS_ALIGNED(s->rsdp_mr_size, qemu_real_host_page_size);
+ mr_aligned = QEMU_IS_ALIGNED(s->table_mr_size, qemu_real_host_page_size()) &&
+ QEMU_IS_ALIGNED(s->linker_mr_size, qemu_real_host_page_size()) &&
+ QEMU_IS_ALIGNED(s->rsdp_mr_size, qemu_real_host_page_size());
return s->acpi_mr_restore && !mr_aligned;
}
diff --git a/hw/pci-host/mv64361.c b/hw/pci-host/mv64361.c
index 00b3ff7..cc9c4d6 100644
--- a/hw/pci-host/mv64361.c
+++ b/hw/pci-host/mv64361.c
@@ -9,7 +9,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/units.h"
#include "qapi/error.h"
#include "hw/hw.h"
diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c
index 6e9aa9d..4e68ad4 100644
--- a/hw/pci-host/pnv_phb3.c
+++ b/hw/pci-host/pnv_phb3.c
@@ -10,7 +10,6 @@
#include "qemu/log.h"
#include "qapi/visitor.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "hw/pci-host/pnv_phb3_regs.h"
#include "hw/pci-host/pnv_phb3.h"
#include "hw/pci/pcie_host.h"
diff --git a/hw/pci-host/pnv_phb3_msi.c b/hw/pci-host/pnv_phb3_msi.c
index 8bcbc2c..2f41129 100644
--- a/hw/pci-host/pnv_phb3_msi.c
+++ b/hw/pci-host/pnv_phb3_msi.c
@@ -9,7 +9,6 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "hw/pci-host/pnv_phb3_regs.h"
#include "hw/pci-host/pnv_phb3.h"
#include "hw/ppc/pnv.h"
diff --git a/hw/pci-host/pnv_phb3_pbcq.c b/hw/pci-host/pnv_phb3_pbcq.c
index c7426cd..82f70ef 100644
--- a/hw/pci-host/pnv_phb3_pbcq.c
+++ b/hw/pci-host/pnv_phb3_pbcq.c
@@ -8,7 +8,6 @@
*/
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "qemu/log.h"
#include "target/ppc/cpu.h"
#include "hw/ppc/fdt.h"
diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c
index 11c97e2..3c4c2da 100644
--- a/hw/pci-host/pnv_phb4.c
+++ b/hw/pci-host/pnv_phb4.c
@@ -10,7 +10,6 @@
#include "qemu/log.h"
#include "qapi/visitor.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "monitor/monitor.h"
#include "target/ppc/cpu.h"
#include "hw/pci-host/pnv_phb4_regs.h"
diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c
index 6f1121a..61bc0b5 100644
--- a/hw/pci-host/pnv_phb4_pec.c
+++ b/hw/pci-host/pnv_phb4_pec.c
@@ -8,7 +8,6 @@
*/
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "qemu/log.h"
#include "target/ppc/cpu.h"
#include "hw/ppc/fdt.h"
diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c
index 6e514f7..7a105e4 100644
--- a/hw/pci-host/raven.c
+++ b/hw/pci-host/raven.c
@@ -24,7 +24,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qemu/units.h"
#include "qemu/log.h"
diff --git a/hw/pci-host/remote.c b/hw/pci-host/remote.c
index eee4544..bfb25ef 100644
--- a/hw/pci-host/remote.c
+++ b/hw/pci-host/remote.c
@@ -22,7 +22,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "hw/pci/pci.h"
#include "hw/pci/pci_host.h"
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index dae9119..e99417e 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -23,7 +23,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qemu/units.h"
#include "hw/irq.h"
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index c7e6767..2bc3dce 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -15,7 +15,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qemu/units.h"
#include "qapi/error.h"
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 4bddb52..e8ef1a9 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -47,7 +47,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qapi/error.h"
#include "hw/ppc/ppc.h"
@@ -456,7 +455,7 @@ static void ppc_core99_init(MachineState *machine)
}
/* The NewWorld NVRAM is not located in the MacIO device */
- if (kvm_enabled() && qemu_real_host_page_size > 4096) {
+ if (kvm_enabled() && qemu_real_host_page_size() > 4096) {
/* We can't combine read-write and read-only in a single page, so
move the NVRAM out of ROM again for KVM */
nvram_addr = 0xFFE00000;
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index 7016979..fe2adb0 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -25,7 +25,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qemu/units.h"
#include "qapi/error.h"
diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
index d45008a..56bf203 100644
--- a/hw/ppc/pegasos2.c
+++ b/hw/ppc/pegasos2.c
@@ -8,7 +8,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/units.h"
#include "qapi/error.h"
#include "hw/hw.h"
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 00f57c9..c5e4899 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -18,7 +18,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qemu/units.h"
#include "qemu/cutils.h"
diff --git a/hw/ppc/pnv_bmc.c b/hw/ppc/pnv_bmc.c
index 75a22ce..99f1e8d 100644
--- a/hw/ppc/pnv_bmc.c
+++ b/hw/ppc/pnv_bmc.c
@@ -17,7 +17,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qapi/error.h"
#include "target/ppc/cpu.h"
#include "qemu/log.h"
diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c
index 7e1a4ac..32013b8 100644
--- a/hw/ppc/ppc405_boards.c
+++ b/hw/ppc/ppc405_boards.c
@@ -25,7 +25,6 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "cpu.h"
#include "hw/ppc/ppc.h"
diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
index 7fb620b..efa90ef 100644
--- a/hw/ppc/ppc440_bamboo.c
+++ b/hw/ppc/ppc440_bamboo.c
@@ -14,7 +14,6 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
#include "qemu/error-report.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qemu/error-report.h"
#include "net/net.h"
diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
index 0737234..2f24598 100644
--- a/hw/ppc/sam460ex.c
+++ b/hw/ppc/sam460ex.c
@@ -13,7 +13,6 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index a4372ba..cc11fcc 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -25,7 +25,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qemu/memalign.h"
#include "qapi/error.h"
diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c
index d7c0e21..a64098c 100644
--- a/hw/ppc/spapr_numa.c
+++ b/hw/ppc/spapr_numa.c
@@ -11,7 +11,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "hw/ppc/spapr_numa.h"
#include "hw/pci-host/spapr.h"
#include "hw/ppc/fdt.h"
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 5bfd4aa..b2f5fbe 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1978,7 +1978,7 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
* our memory slot is of page size granularity.
*/
if (kvm_enabled()) {
- msi_window_size = qemu_real_host_page_size;
+ msi_window_size = qemu_real_host_page_size();
}
memory_region_init_io(&sphb->msiwindow, OBJECT(sphb), &spapr_msi_ops, spapr,
diff --git a/hw/ppc/spapr_pci_nvlink2.c b/hw/ppc/spapr_pci_nvlink2.c
index 4678c79..63b476c 100644
--- a/hw/ppc/spapr_pci_nvlink2.c
+++ b/hw/ppc/spapr_pci_nvlink2.c
@@ -23,7 +23,6 @@
*/
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "hw/pci/pci.h"
#include "hw/pci-host/spapr.h"
#include "hw/ppc/spapr_numa.h"
diff --git a/hw/ppc/spapr_tpm_proxy.c b/hw/ppc/spapr_tpm_proxy.c
index 2454086..e10af35 100644
--- a/hw/ppc/spapr_tpm_proxy.c
+++ b/hw/ppc/spapr_tpm_proxy.c
@@ -11,7 +11,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "sysemu/reset.h"
diff --git a/hw/ppc/spapr_vof.c b/hw/ppc/spapr_vof.c
index a33f940..09f29be 100644
--- a/hw/ppc/spapr_vof.c
+++ b/hw/ppc/spapr_vof.c
@@ -4,7 +4,6 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qapi/error.h"
#include "hw/ppc/spapr.h"
#include "hw/ppc/spapr_vio.h"
diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
index 9c57540..b67a709 100644
--- a/hw/ppc/virtex_ml507.c
+++ b/hw/ppc/virtex_ml507.c
@@ -23,7 +23,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qemu/units.h"
#include "cpu.h"
diff --git a/hw/ppc/vof.c b/hw/ppc/vof.c
index 2b63a62..8d96593 100644
--- a/hw/ppc/vof.c
+++ b/hw/ppc/vof.c
@@ -10,7 +10,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/timer.h"
#include "qemu/range.h"
#include "qemu/units.h"
diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c
index 91206db..27a7622 100644
--- a/hw/rdma/vmw/pvrdma_main.c
+++ b/hw/rdma/vmw/pvrdma_main.c
@@ -608,7 +608,7 @@ static void pvrdma_realize(PCIDevice *pdev, Error **errp)
rdma_info_report("Initializing device %s %x.%x", pdev->name,
PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
- if (TARGET_PAGE_SIZE != qemu_real_host_page_size) {
+ if (TARGET_PAGE_SIZE != qemu_real_host_page_size()) {
error_setg(errp, "Target page size must be the same as host page size");
return;
}
diff --git a/hw/remote/iohub.c b/hw/remote/iohub.c
index 547d597..40dfee4 100644
--- a/hw/remote/iohub.c
+++ b/hw/remote/iohub.c
@@ -9,7 +9,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "hw/pci/pci.h"
#include "hw/pci/pci_ids.h"
diff --git a/hw/remote/machine.c b/hw/remote/machine.c
index 952105e..92d71d4 100644
--- a/hw/remote/machine.c
+++ b/hw/remote/machine.c
@@ -14,7 +14,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "hw/remote/machine.h"
#include "exec/memory.h"
diff --git a/hw/remote/memory.c b/hw/remote/memory.c
index 6e21ab1..6d60da9 100644
--- a/hw/remote/memory.c
+++ b/hw/remote/memory.c
@@ -9,7 +9,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "hw/remote/memory.h"
#include "exec/ram_addr.h"
diff --git a/hw/remote/message.c b/hw/remote/message.c
index 11d7298..50f6bf2 100644
--- a/hw/remote/message.c
+++ b/hw/remote/message.c
@@ -8,7 +8,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "hw/remote/machine.h"
#include "io/channel.h"
diff --git a/hw/remote/mpqemu-link.c b/hw/remote/mpqemu-link.c
index 7e84182..2a4aa65 100644
--- a/hw/remote/mpqemu-link.c
+++ b/hw/remote/mpqemu-link.c
@@ -9,7 +9,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/module.h"
#include "hw/remote/mpqemu-link.h"
diff --git a/hw/remote/proxy-memory-listener.c b/hw/remote/proxy-memory-listener.c
index 0e893f3..eb9918f 100644
--- a/hw/remote/proxy-memory-listener.c
+++ b/hw/remote/proxy-memory-listener.c
@@ -7,7 +7,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/compiler.h"
#include "qemu/int128.h"
diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c
index bad1642..1c7786b 100644
--- a/hw/remote/proxy.c
+++ b/hw/remote/proxy.c
@@ -7,7 +7,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "hw/remote/proxy.h"
#include "hw/pci/pci.h"
diff --git a/hw/remote/remote-obj.c b/hw/remote/remote-obj.c
index 4f21254..333e5ac 100644
--- a/hw/remote/remote-obj.c
+++ b/hw/remote/remote-obj.c
@@ -8,7 +8,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/error-report.h"
#include "qemu/notify.h"
diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
index cae74fc..0f179d3 100644
--- a/hw/riscv/boot.c
+++ b/hw/riscv/boot.c
@@ -18,7 +18,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qemu/units.h"
#include "qemu/error-report.h"
diff --git a/hw/rtc/m41t80.c b/hw/rtc/m41t80.c
index a00971a..e045c86 100644
--- a/hw/rtc/m41t80.c
+++ b/hw/rtc/m41t80.c
@@ -47,7 +47,7 @@ static uint8_t m41t80_recv(I2CSlave *i2c)
{
M41t80State *s = M41T80(i2c);
struct tm now;
- qemu_timeval tv;
+ int64_t rt;
if (s->addr < 0) {
s->addr = 0;
@@ -57,8 +57,8 @@ static uint8_t m41t80_recv(I2CSlave *i2c)
}
switch (s->addr++) {
case 0:
- qemu_gettimeofday(&tv);
- return to_bcd(tv.tv_usec / 10000);
+ rt = g_get_real_time();
+ return to_bcd((rt % G_USEC_PER_SEC) / 10000);
case 1:
return to_bcd(now.tm_sec);
case 2:
diff --git a/hw/rx/rx-gdbsim.c b/hw/rx/rx-gdbsim.c
index 75d1fec..64f897e 100644
--- a/hw/rx/rx-gdbsim.c
+++ b/hw/rx/rx-gdbsim.c
@@ -20,7 +20,6 @@
#include "qemu/cutils.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "hw/loader.h"
#include "hw/rx/rx62n.h"
#include "sysemu/qtest.h"
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index 6fa47b8..faa51aa 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -28,7 +28,7 @@ typedef struct SCLPEventsBus {
} SCLPEventsBus;
/* we need to save 32 bit chunks for compatibility */
-#ifdef HOST_WORDS_BIGENDIAN
+#if HOST_BIG_ENDIAN
#define RECV_MASK_LOWER 1
#define RECV_MASK_UPPER 0
#else /* little endian host */
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index eb7fc4c..4b5eb77 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -13,7 +13,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qapi/error.h"
#include "sysemu/reset.h"
@@ -28,11 +27,14 @@
#include "hw/s390x/css.h"
#include "hw/s390x/ebcdic.h"
#include "hw/s390x/pv.h"
+#include "hw/scsi/scsi.h"
+#include "hw/virtio/virtio-net.h"
#include "ipl.h"
#include "qemu/error-report.h"
#include "qemu/config-file.h"
#include "qemu/cutils.h"
#include "qemu/option.h"
+#include "standard-headers/linux/virtio_ids.h"
#include "exec/exec-all.h"
#define KERN_IMAGE_START 0x010000UL
@@ -376,14 +378,18 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype)
object_dynamic_cast(OBJECT(dev_st),
TYPE_SCSI_DEVICE);
if (sd) {
- SCSIBus *bus = scsi_bus_from_device(sd);
- VirtIOSCSI *vdev = container_of(bus, VirtIOSCSI, bus);
- VirtIOSCSICcw *scsi_ccw = container_of(vdev, VirtIOSCSICcw,
- vdev);
-
- ccw_dev = (CcwDevice *)object_dynamic_cast(OBJECT(scsi_ccw),
- TYPE_CCW_DEVICE);
- tmp_dt = CCW_DEVTYPE_SCSI;
+ SCSIBus *sbus = scsi_bus_from_device(sd);
+ VirtIODevice *vdev = (VirtIODevice *)
+ object_dynamic_cast(OBJECT(sbus->qbus.parent),
+ TYPE_VIRTIO_DEVICE);
+ if (vdev) {
+ ccw_dev = (CcwDevice *)
+ object_dynamic_cast(OBJECT(qdev_get_parent_bus(DEVICE(vdev))->parent),
+ TYPE_CCW_DEVICE);
+ if (ccw_dev) {
+ tmp_dt = CCW_DEVTYPE_SCSI;
+ }
+ }
}
}
}
diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build
index 2848425..feefe07 100644
--- a/hw/s390x/meson.build
+++ b/hw/s390x/meson.build
@@ -44,6 +44,7 @@ virtio_ss.add(when: 'CONFIG_VIRTIO_SERIAL', if_true: files('virtio-ccw-serial.c'
if have_virtfs
virtio_ss.add(when: 'CONFIG_VIRTIO_9P', if_true: files('virtio-ccw-9p.c'))
endif
+virtio_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-ccw.c'))
virtio_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-ccw.c'))
virtio_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs-ccw.c'))
s390x_ss.add_all(when: 'CONFIG_VIRTIO_CCW', if_true: virtio_ss)
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 90480e7..2d32647 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -25,6 +25,7 @@
#include "qemu/error-report.h"
#include "qemu/option.h"
#include "qemu/qemu-print.h"
+#include "qemu/units.h"
#include "hw/s390x/s390-pci-bus.h"
#include "sysemu/reset.h"
#include "hw/s390x/storage-keys.h"
diff --git a/hw/s390x/vhost-scsi-ccw.c b/hw/s390x/vhost-scsi-ccw.c
new file mode 100644
index 0000000..40dc14b
--- /dev/null
+++ b/hw/s390x/vhost-scsi-ccw.c
@@ -0,0 +1,73 @@
+/*
+ * vhost ccw scsi implementation
+ *
+ * Copyright 2012, 2015 IBM Corp.
+ * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
+ * your option) any later version. See the COPYING file in the top-level
+ * directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/qdev-properties.h"
+#include "hw/virtio/virtio.h"
+#include "qapi/error.h"
+#include "qemu/module.h"
+#include "virtio-ccw.h"
+#include "hw/virtio/vhost-scsi.h"
+
+#define TYPE_VHOST_SCSI_CCW "vhost-scsi-ccw"
+OBJECT_DECLARE_SIMPLE_TYPE(VHostSCSICcw, VHOST_SCSI_CCW)
+
+struct VHostSCSICcw {
+ VirtioCcwDevice parent_obj;
+ VHostSCSI vdev;
+};
+
+static void vhost_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp)
+{
+ VHostSCSICcw *dev = VHOST_SCSI_CCW(ccw_dev);
+ DeviceState *vdev = DEVICE(&dev->vdev);
+
+ qdev_realize(vdev, BUS(&ccw_dev->bus), errp);
+}
+
+static void vhost_ccw_scsi_instance_init(Object *obj)
+{
+ VHostSCSICcw *dev = VHOST_SCSI_CCW(obj);
+
+ virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
+ TYPE_VHOST_SCSI);
+}
+
+static Property vhost_ccw_scsi_properties[] = {
+ DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
+ VIRTIO_CCW_MAX_REV),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void vhost_ccw_scsi_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
+
+ k->realize = vhost_ccw_scsi_realize;
+ device_class_set_props(dc, vhost_ccw_scsi_properties);
+ set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
+}
+
+static const TypeInfo vhost_ccw_scsi = {
+ .name = TYPE_VHOST_SCSI_CCW,
+ .parent = TYPE_VIRTIO_CCW_DEVICE,
+ .instance_size = sizeof(VHostSCSICcw),
+ .instance_init = vhost_ccw_scsi_instance_init,
+ .class_init = vhost_ccw_scsi_class_init,
+};
+
+static void virtio_ccw_scsi_register(void)
+{
+ type_register_static(&vhost_ccw_scsi);
+}
+
+type_init(virtio_ccw_scsi_register)
diff --git a/hw/s390x/vhost-vsock-ccw.c b/hw/s390x/vhost-vsock-ccw.c
index 246416a..07845a9 100644
--- a/hw/s390x/vhost-vsock-ccw.c
+++ b/hw/s390x/vhost-vsock-ccw.c
@@ -12,6 +12,15 @@
#include "qapi/error.h"
#include "qemu/module.h"
#include "virtio-ccw.h"
+#include "hw/virtio/vhost-vsock.h"
+
+#define TYPE_VHOST_VSOCK_CCW "vhost-vsock-ccw"
+OBJECT_DECLARE_SIMPLE_TYPE(VHostVSockCCWState, VHOST_VSOCK_CCW)
+
+struct VHostVSockCCWState {
+ VirtioCcwDevice parent_obj;
+ VHostVSock vdev;
+};
static Property vhost_vsock_ccw_properties[] = {
DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
diff --git a/hw/s390x/virtio-ccw-9p.c b/hw/s390x/virtio-ccw-9p.c
index 88c8884..6f931f5 100644
--- a/hw/s390x/virtio-ccw-9p.c
+++ b/hw/s390x/virtio-ccw-9p.c
@@ -15,6 +15,15 @@
#include "qapi/error.h"
#include "qemu/module.h"
#include "virtio-ccw.h"
+#include "hw/9pfs/virtio-9p.h"
+
+#define TYPE_VIRTIO_9P_CCW "virtio-9p-ccw"
+OBJECT_DECLARE_SIMPLE_TYPE(V9fsCCWState, VIRTIO_9P_CCW)
+
+struct V9fsCCWState {
+ VirtioCcwDevice parent_obj;
+ V9fsVirtioState vdev;
+};
static void virtio_ccw_9p_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
diff --git a/hw/s390x/virtio-ccw-balloon.c b/hw/s390x/virtio-ccw-balloon.c
index 4c7631a..44287b9 100644
--- a/hw/s390x/virtio-ccw-balloon.c
+++ b/hw/s390x/virtio-ccw-balloon.c
@@ -15,6 +15,15 @@
#include "qapi/error.h"
#include "qemu/module.h"
#include "virtio-ccw.h"
+#include "hw/virtio/virtio-balloon.h"
+
+#define TYPE_VIRTIO_BALLOON_CCW "virtio-balloon-ccw"
+OBJECT_DECLARE_SIMPLE_TYPE(VirtIOBalloonCcw, VIRTIO_BALLOON_CCW)
+
+struct VirtIOBalloonCcw {
+ VirtioCcwDevice parent_obj;
+ VirtIOBalloon vdev;
+};
static void virtio_ccw_balloon_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
diff --git a/hw/s390x/virtio-ccw-blk.c b/hw/s390x/virtio-ccw-blk.c
index 2294ce1..8e0e58b 100644
--- a/hw/s390x/virtio-ccw-blk.c
+++ b/hw/s390x/virtio-ccw-blk.c
@@ -15,6 +15,15 @@
#include "qapi/error.h"
#include "qemu/module.h"
#include "virtio-ccw.h"
+#include "hw/virtio/virtio-blk.h"
+
+#define TYPE_VIRTIO_BLK_CCW "virtio-blk-ccw"
+OBJECT_DECLARE_SIMPLE_TYPE(VirtIOBlkCcw, VIRTIO_BLK_CCW)
+
+struct VirtIOBlkCcw {
+ VirtioCcwDevice parent_obj;
+ VirtIOBlock vdev;
+};
static void virtio_ccw_blk_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
diff --git a/hw/s390x/virtio-ccw-crypto.c b/hw/s390x/virtio-ccw-crypto.c
index 358c74f..0fa2f89 100644
--- a/hw/s390x/virtio-ccw-crypto.c
+++ b/hw/s390x/virtio-ccw-crypto.c
@@ -14,6 +14,15 @@
#include "qapi/error.h"
#include "qemu/module.h"
#include "virtio-ccw.h"
+#include "hw/virtio/virtio-crypto.h"
+
+#define TYPE_VIRTIO_CRYPTO_CCW "virtio-crypto-ccw"
+OBJECT_DECLARE_SIMPLE_TYPE(VirtIOCryptoCcw, VIRTIO_CRYPTO_CCW)
+
+struct VirtIOCryptoCcw {
+ VirtioCcwDevice parent_obj;
+ VirtIOCrypto vdev;
+};
static void virtio_ccw_crypto_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
diff --git a/hw/s390x/virtio-ccw-gpu.c b/hw/s390x/virtio-ccw-gpu.c
index 5868a2a..8d995fc 100644
--- a/hw/s390x/virtio-ccw-gpu.c
+++ b/hw/s390x/virtio-ccw-gpu.c
@@ -14,6 +14,15 @@
#include "qapi/error.h"
#include "qemu/module.h"
#include "virtio-ccw.h"
+#include "hw/virtio/virtio-gpu.h"
+
+#define TYPE_VIRTIO_GPU_CCW "virtio-gpu-ccw"
+OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUCcw, VIRTIO_GPU_CCW)
+
+struct VirtIOGPUCcw {
+ VirtioCcwDevice parent_obj;
+ VirtIOGPU vdev;
+};
static void virtio_ccw_gpu_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
diff --git a/hw/s390x/virtio-ccw-input.c b/hw/s390x/virtio-ccw-input.c
index 83136fb..61a07ba 100644
--- a/hw/s390x/virtio-ccw-input.c
+++ b/hw/s390x/virtio-ccw-input.c
@@ -14,6 +14,26 @@
#include "qapi/error.h"
#include "qemu/module.h"
#include "virtio-ccw.h"
+#include "hw/virtio/virtio-input.h"
+
+#define TYPE_VIRTIO_INPUT_CCW "virtio-input-ccw"
+OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputCcw, VIRTIO_INPUT_CCW)
+
+struct VirtIOInputCcw {
+ VirtioCcwDevice parent_obj;
+ VirtIOInput vdev;
+};
+
+#define TYPE_VIRTIO_INPUT_HID_CCW "virtio-input-hid-ccw"
+#define TYPE_VIRTIO_KEYBOARD_CCW "virtio-keyboard-ccw"
+#define TYPE_VIRTIO_MOUSE_CCW "virtio-mouse-ccw"
+#define TYPE_VIRTIO_TABLET_CCW "virtio-tablet-ccw"
+OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHIDCcw, VIRTIO_INPUT_HID_CCW)
+
+struct VirtIOInputHIDCcw {
+ VirtioCcwDevice parent_obj;
+ VirtIOInputHID vdev;
+};
static void virtio_ccw_input_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
diff --git a/hw/s390x/virtio-ccw-net.c b/hw/s390x/virtio-ccw-net.c
index 3860d4e..484e617 100644
--- a/hw/s390x/virtio-ccw-net.c
+++ b/hw/s390x/virtio-ccw-net.c
@@ -15,6 +15,15 @@
#include "qapi/error.h"
#include "qemu/module.h"
#include "virtio-ccw.h"
+#include "hw/virtio/virtio-net.h"
+
+#define TYPE_VIRTIO_NET_CCW "virtio-net-ccw"
+OBJECT_DECLARE_SIMPLE_TYPE(VirtIONetCcw, VIRTIO_NET_CCW)
+
+struct VirtIONetCcw {
+ VirtioCcwDevice parent_obj;
+ VirtIONet vdev;
+};
static void virtio_ccw_net_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
diff --git a/hw/s390x/virtio-ccw-rng.c b/hw/s390x/virtio-ccw-rng.c
index 2e3a9da..a3fffb5 100644
--- a/hw/s390x/virtio-ccw-rng.c
+++ b/hw/s390x/virtio-ccw-rng.c
@@ -15,6 +15,15 @@
#include "qapi/error.h"
#include "qemu/module.h"
#include "virtio-ccw.h"
+#include "hw/virtio/virtio-rng.h"
+
+#define TYPE_VIRTIO_RNG_CCW "virtio-rng-ccw"
+OBJECT_DECLARE_SIMPLE_TYPE(VirtIORNGCcw, VIRTIO_RNG_CCW)
+
+struct VirtIORNGCcw {
+ VirtioCcwDevice parent_obj;
+ VirtIORNG vdev;
+};
static void virtio_ccw_rng_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
diff --git a/hw/s390x/virtio-ccw-scsi.c b/hw/s390x/virtio-ccw-scsi.c
index 6e4beef..d003f89 100644
--- a/hw/s390x/virtio-ccw-scsi.c
+++ b/hw/s390x/virtio-ccw-scsi.c
@@ -15,6 +15,15 @@
#include "qapi/error.h"
#include "qemu/module.h"
#include "virtio-ccw.h"
+#include "hw/virtio/virtio-scsi.h"
+
+#define TYPE_VIRTIO_SCSI_CCW "virtio-scsi-ccw"
+OBJECT_DECLARE_SIMPLE_TYPE(VirtIOSCSICcw, VIRTIO_SCSI_CCW)
+
+struct VirtIOSCSICcw {
+ VirtioCcwDevice parent_obj;
+ VirtIOSCSI vdev;
+};
static void virtio_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
@@ -70,56 +79,9 @@ static const TypeInfo virtio_ccw_scsi = {
.class_init = virtio_ccw_scsi_class_init,
};
-#ifdef CONFIG_VHOST_SCSI
-
-static void vhost_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp)
-{
- VHostSCSICcw *dev = VHOST_SCSI_CCW(ccw_dev);
- DeviceState *vdev = DEVICE(&dev->vdev);
-
- qdev_realize(vdev, BUS(&ccw_dev->bus), errp);
-}
-
-static void vhost_ccw_scsi_instance_init(Object *obj)
-{
- VHostSCSICcw *dev = VHOST_SCSI_CCW(obj);
-
- virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
- TYPE_VHOST_SCSI);
-}
-
-static Property vhost_ccw_scsi_properties[] = {
- DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
- VIRTIO_CCW_MAX_REV),
- DEFINE_PROP_END_OF_LIST(),
-};
-
-static void vhost_ccw_scsi_class_init(ObjectClass *klass, void *data)
-{
- DeviceClass *dc = DEVICE_CLASS(klass);
- VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
-
- k->realize = vhost_ccw_scsi_realize;
- device_class_set_props(dc, vhost_ccw_scsi_properties);
- set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-}
-
-static const TypeInfo vhost_ccw_scsi = {
- .name = TYPE_VHOST_SCSI_CCW,
- .parent = TYPE_VIRTIO_CCW_DEVICE,
- .instance_size = sizeof(VHostSCSICcw),
- .instance_init = vhost_ccw_scsi_instance_init,
- .class_init = vhost_ccw_scsi_class_init,
-};
-
-#endif
-
static void virtio_ccw_scsi_register(void)
{
type_register_static(&virtio_ccw_scsi);
-#ifdef CONFIG_VHOST_SCSI
- type_register_static(&vhost_ccw_scsi);
-#endif
}
type_init(virtio_ccw_scsi_register)
diff --git a/hw/s390x/virtio-ccw-serial.c b/hw/s390x/virtio-ccw-serial.c
index 6195822..bf80578 100644
--- a/hw/s390x/virtio-ccw-serial.c
+++ b/hw/s390x/virtio-ccw-serial.c
@@ -15,6 +15,15 @@
#include "hw/qdev-properties.h"
#include "hw/virtio/virtio-serial.h"
#include "virtio-ccw.h"
+#include "hw/virtio/virtio-serial.h"
+
+#define TYPE_VIRTIO_SERIAL_CCW "virtio-serial-ccw"
+OBJECT_DECLARE_SIMPLE_TYPE(VirtioSerialCcw, VIRTIO_SERIAL_CCW)
+
+struct VirtioSerialCcw {
+ VirtioCcwDevice parent_obj;
+ VirtIOSerial vdev;
+};
static void virtio_ccw_serial_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index c845a92..15b4585 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -12,6 +12,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
+#include "exec/address-spaces.h"
#include "sysemu/kvm.h"
#include "net/net.h"
#include "hw/virtio/virtio.h"
@@ -19,6 +20,7 @@
#include "hw/virtio/virtio-net.h"
#include "qemu/bitops.h"
#include "qemu/error-report.h"
+#include "qemu/log.h"
#include "qemu/module.h"
#include "hw/virtio/virtio-access.h"
#include "hw/virtio/virtio-bus.h"
diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h
index 0168232..fac186c 100644
--- a/hw/s390x/virtio-ccw.h
+++ b/hw/s390x/virtio-ccw.h
@@ -13,24 +13,8 @@
#ifndef HW_S390X_VIRTIO_CCW_H
#define HW_S390X_VIRTIO_CCW_H
-#include "hw/virtio/virtio-blk.h"
-#include "hw/virtio/virtio-net.h"
-#include "hw/virtio/virtio-serial.h"
-#include "hw/virtio/virtio-scsi.h"
#include "qom/object.h"
-#ifdef CONFIG_VHOST_SCSI
-#include "hw/virtio/vhost-scsi.h"
-#endif
-#include "hw/virtio/virtio-balloon.h"
-#include "hw/virtio/virtio-rng.h"
-#include "hw/virtio/virtio-crypto.h"
#include "hw/virtio/virtio-bus.h"
-#ifdef CONFIG_VHOST_VSOCK
-#include "hw/virtio/vhost-vsock.h"
-#endif /* CONFIG_VHOST_VSOCK */
-#include "hw/virtio/virtio-gpu.h"
-#include "hw/virtio/virtio-input.h"
-
#include "hw/s390x/s390_flic.h"
#include "hw/s390x/css.h"
#include "ccw-device.h"
@@ -104,139 +88,6 @@ static inline int virtio_ccw_rev_max(VirtioCcwDevice *dev)
return dev->max_rev;
}
-/* virtio-scsi-ccw */
-
-#define TYPE_VIRTIO_SCSI_CCW "virtio-scsi-ccw"
-OBJECT_DECLARE_SIMPLE_TYPE(VirtIOSCSICcw, VIRTIO_SCSI_CCW)
-
-struct VirtIOSCSICcw {
- VirtioCcwDevice parent_obj;
- VirtIOSCSI vdev;
-};
-
-#ifdef CONFIG_VHOST_SCSI
-/* vhost-scsi-ccw */
-
-#define TYPE_VHOST_SCSI_CCW "vhost-scsi-ccw"
-OBJECT_DECLARE_SIMPLE_TYPE(VHostSCSICcw, VHOST_SCSI_CCW)
-
-struct VHostSCSICcw {
- VirtioCcwDevice parent_obj;
- VHostSCSI vdev;
-};
-#endif
-
-/* virtio-blk-ccw */
-
-#define TYPE_VIRTIO_BLK_CCW "virtio-blk-ccw"
-OBJECT_DECLARE_SIMPLE_TYPE(VirtIOBlkCcw, VIRTIO_BLK_CCW)
-
-struct VirtIOBlkCcw {
- VirtioCcwDevice parent_obj;
- VirtIOBlock vdev;
-};
-
-/* virtio-balloon-ccw */
-
-#define TYPE_VIRTIO_BALLOON_CCW "virtio-balloon-ccw"
-OBJECT_DECLARE_SIMPLE_TYPE(VirtIOBalloonCcw, VIRTIO_BALLOON_CCW)
-
-struct VirtIOBalloonCcw {
- VirtioCcwDevice parent_obj;
- VirtIOBalloon vdev;
-};
-
-/* virtio-serial-ccw */
-
-#define TYPE_VIRTIO_SERIAL_CCW "virtio-serial-ccw"
-OBJECT_DECLARE_SIMPLE_TYPE(VirtioSerialCcw, VIRTIO_SERIAL_CCW)
-
-struct VirtioSerialCcw {
- VirtioCcwDevice parent_obj;
- VirtIOSerial vdev;
-};
-
-/* virtio-net-ccw */
-
-#define TYPE_VIRTIO_NET_CCW "virtio-net-ccw"
-OBJECT_DECLARE_SIMPLE_TYPE(VirtIONetCcw, VIRTIO_NET_CCW)
-
-struct VirtIONetCcw {
- VirtioCcwDevice parent_obj;
- VirtIONet vdev;
-};
-
-/* virtio-rng-ccw */
-
-#define TYPE_VIRTIO_RNG_CCW "virtio-rng-ccw"
-OBJECT_DECLARE_SIMPLE_TYPE(VirtIORNGCcw, VIRTIO_RNG_CCW)
-
-struct VirtIORNGCcw {
- VirtioCcwDevice parent_obj;
- VirtIORNG vdev;
-};
-
-/* virtio-crypto-ccw */
-
-#define TYPE_VIRTIO_CRYPTO_CCW "virtio-crypto-ccw"
-OBJECT_DECLARE_SIMPLE_TYPE(VirtIOCryptoCcw, VIRTIO_CRYPTO_CCW)
-
-struct VirtIOCryptoCcw {
- VirtioCcwDevice parent_obj;
- VirtIOCrypto vdev;
-};
-
VirtIODevice *virtio_ccw_get_vdev(SubchDev *sch);
-#ifdef CONFIG_VIRTFS
-#include "hw/9pfs/virtio-9p.h"
-
-#define TYPE_VIRTIO_9P_CCW "virtio-9p-ccw"
-OBJECT_DECLARE_SIMPLE_TYPE(V9fsCCWState, VIRTIO_9P_CCW)
-
-struct V9fsCCWState {
- VirtioCcwDevice parent_obj;
- V9fsVirtioState vdev;
-};
-
-#endif /* CONFIG_VIRTFS */
-
-#ifdef CONFIG_VHOST_VSOCK
-#define TYPE_VHOST_VSOCK_CCW "vhost-vsock-ccw"
-OBJECT_DECLARE_SIMPLE_TYPE(VHostVSockCCWState, VHOST_VSOCK_CCW)
-
-struct VHostVSockCCWState {
- VirtioCcwDevice parent_obj;
- VHostVSock vdev;
-};
-
-#endif /* CONFIG_VHOST_VSOCK */
-
-#define TYPE_VIRTIO_GPU_CCW "virtio-gpu-ccw"
-OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUCcw, VIRTIO_GPU_CCW)
-
-struct VirtIOGPUCcw {
- VirtioCcwDevice parent_obj;
- VirtIOGPU vdev;
-};
-
-#define TYPE_VIRTIO_INPUT_CCW "virtio-input-ccw"
-OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputCcw, VIRTIO_INPUT_CCW)
-
-struct VirtIOInputCcw {
- VirtioCcwDevice parent_obj;
- VirtIOInput vdev;
-};
-
-#define TYPE_VIRTIO_INPUT_HID_CCW "virtio-input-hid-ccw"
-#define TYPE_VIRTIO_KEYBOARD_CCW "virtio-keyboard-ccw"
-#define TYPE_VIRTIO_MOUSE_CCW "virtio-mouse-ccw"
-#define TYPE_VIRTIO_TABLET_CCW "virtio-tablet-ccw"
-OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHIDCcw, VIRTIO_INPUT_HID_CCW)
-
-struct VirtIOInputHIDCcw {
- VirtioCcwDevice parent_obj;
- VirtIOInputHID vdev;
-};
-
#endif
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 0306ccc..0ab00ef 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -183,7 +183,7 @@ static int scsi_handle_inquiry_reply(SCSIGenericReq *r, SCSIDevice *s, int len)
uint32_t max_iov = blk_get_max_hw_iov(s->conf.blk);
assert(max_transfer);
- max_transfer = MIN_NON_ZERO(max_transfer, max_iov * qemu_real_host_page_size)
+ max_transfer = MIN_NON_ZERO(max_transfer, max_iov * qemu_real_host_page_size())
/ s->blocksize;
stl_be_p(&r->buf[8], max_transfer);
/* Also take care of the opt xfer len. */
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index cd67a7b..8e6fa09 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -47,7 +47,6 @@
#include "qemu/timer.h"
#include "qemu/log.h"
#include "qemu/module.h"
-#include "qemu-common.h"
#include "sdmmc-internal.h"
#include "trace.h"
diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
index a9f2496..1e39d2e 100644
--- a/hw/sparc/leon3.c
+++ b/hw/sparc/leon3.c
@@ -26,7 +26,6 @@
#include "qemu/units.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "cpu.h"
#include "hw/irq.h"
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 7f3a7c0..fccaed1 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -26,7 +26,6 @@
#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu/datadir.h"
-#include "qemu-common.h"
#include "cpu.h"
#include "hw/sysbus.h"
#include "qemu/error-report.h"
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index cda7df3..6fd08e2 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -26,7 +26,6 @@
#include "qemu/units.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "qemu/datadir.h"
#include "cpu.h"
#include "hw/pci/pci.h"
diff --git a/hw/tpm/tpm_ppi.c b/hw/tpm/tpm_ppi.c
index c89ac53..7f74e26 100644
--- a/hw/tpm/tpm_ppi.c
+++ b/hw/tpm/tpm_ppi.c
@@ -47,7 +47,7 @@ void tpm_ppi_reset(TPMPPI *tpmppi)
void tpm_ppi_init(TPMPPI *tpmppi, MemoryRegion *m,
hwaddr addr, Object *obj)
{
- tpmppi->buf = qemu_memalign(qemu_real_host_page_size,
+ tpmppi->buf = qemu_memalign(qemu_real_host_page_size(),
HOST_PAGE_ALIGN(TPM_PPI_ADDR_SIZE));
memory_region_init_ram_device_ptr(&tpmppi->ram, obj, "tpm-ppi",
TPM_PPI_ADDR_SIZE, tpmppi->buf);
diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
index fa3040f..f530ab2 100644
--- a/hw/usb/ccid-card-passthru.c
+++ b/hw/usb/ccid-card-passthru.c
@@ -9,7 +9,7 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qemu/units.h"
#include <libcacard.h>
#include "chardev/char-fe.h"
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index e6b77a2..5831395 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -10,7 +10,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include <wchar.h>
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 91ffd9f..28164d8 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -37,7 +37,7 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
#include "qapi/error.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qemu/error-report.h"
#include "qemu/module.h"
#include "hw/qdev-properties.h"
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 8692ea2..3bc4dee 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -26,7 +26,7 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu/timer.h"
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 080046e..2b1f78f 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -397,7 +397,7 @@ static int vfio_dma_unmap_bitmap(VFIOContainer *container,
{
struct vfio_iommu_type1_dma_unmap *unmap;
struct vfio_bitmap *bitmap;
- uint64_t pages = REAL_HOST_PAGE_ALIGN(size) / qemu_real_host_page_size;
+ uint64_t pages = REAL_HOST_PAGE_ALIGN(size) / qemu_real_host_page_size();
int ret;
unmap = g_malloc0(sizeof(*unmap) + sizeof(*bitmap));
@@ -414,7 +414,7 @@ static int vfio_dma_unmap_bitmap(VFIOContainer *container,
* to qemu_real_host_page_size.
*/
- bitmap->pgsize = qemu_real_host_page_size;
+ bitmap->pgsize = qemu_real_host_page_size();
bitmap->size = ROUND_UP(pages, sizeof(__u64) * BITS_PER_BYTE) /
BITS_PER_BYTE;
@@ -882,8 +882,8 @@ static void vfio_listener_region_add(MemoryListener *listener,
}
if (unlikely((section->offset_within_address_space &
- ~qemu_real_host_page_mask) !=
- (section->offset_within_region & ~qemu_real_host_page_mask))) {
+ ~qemu_real_host_page_mask()) !=
+ (section->offset_within_region & ~qemu_real_host_page_mask()))) {
error_report("%s received unaligned region", __func__);
return;
}
@@ -891,7 +891,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
iova = REAL_HOST_PAGE_ALIGN(section->offset_within_address_space);
llend = int128_make64(section->offset_within_address_space);
llend = int128_add(llend, section->size);
- llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask));
+ llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask()));
if (int128_ge(int128_make64(iova), llend)) {
if (memory_region_is_ram_device(section->mr)) {
@@ -899,7 +899,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
memory_region_name(section->mr),
section->offset_within_address_space,
int128_getlo(section->size),
- qemu_real_host_page_size);
+ qemu_real_host_page_size());
}
return;
}
@@ -1118,8 +1118,8 @@ static void vfio_listener_region_del(MemoryListener *listener,
}
if (unlikely((section->offset_within_address_space &
- ~qemu_real_host_page_mask) !=
- (section->offset_within_region & ~qemu_real_host_page_mask))) {
+ ~qemu_real_host_page_mask()) !=
+ (section->offset_within_region & ~qemu_real_host_page_mask()))) {
error_report("%s received unaligned region", __func__);
return;
}
@@ -1150,7 +1150,7 @@ static void vfio_listener_region_del(MemoryListener *listener,
iova = REAL_HOST_PAGE_ALIGN(section->offset_within_address_space);
llend = int128_make64(section->offset_within_address_space);
llend = int128_add(llend, section->size);
- llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask));
+ llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask()));
if (int128_ge(int128_make64(iova), llend)) {
return;
@@ -1272,9 +1272,9 @@ static int vfio_get_dirty_bitmap(VFIOContainer *container, uint64_t iova,
* qemu_real_host_page_size to mark those dirty. Hence set bitmap's pgsize
* to qemu_real_host_page_size.
*/
- range->bitmap.pgsize = qemu_real_host_page_size;
+ range->bitmap.pgsize = qemu_real_host_page_size();
- pages = REAL_HOST_PAGE_ALIGN(range->size) / qemu_real_host_page_size;
+ pages = REAL_HOST_PAGE_ALIGN(range->size) / qemu_real_host_page_size();
range->bitmap.size = ROUND_UP(pages, sizeof(__u64) * BITS_PER_BYTE) /
BITS_PER_BYTE;
range->bitmap.data = g_try_malloc0(range->bitmap.size);
@@ -1970,7 +1970,7 @@ static void vfio_get_iommu_info_migration(VFIOContainer *container,
* cpu_physical_memory_set_dirty_lebitmap() supports pages in bitmap of
* qemu_real_host_page_size to mark those dirty.
*/
- if (cap_mig->pgsize_bitmap & qemu_real_host_page_size) {
+ if (cap_mig->pgsize_bitmap & qemu_real_host_page_size()) {
container->dirty_pages_supported = true;
container->max_dirty_bitmap_size = cap_mig->max_dirty_bitmap_size;
container->dirty_pgsizes = cap_mig->pgsize_bitmap;
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 67a183f..9fd9fae 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1087,8 +1087,8 @@ static void vfio_sub_page_bar_update_mapping(PCIDevice *pdev, int bar)
/* If BAR is mapped and page aligned, update to fill PAGE_SIZE */
if (bar_addr != PCI_BAR_UNMAPPED &&
- !(bar_addr & ~qemu_real_host_page_mask)) {
- size = qemu_real_host_page_size;
+ !(bar_addr & ~qemu_real_host_page_mask())) {
+ size = qemu_real_host_page_size();
}
memory_region_transaction_begin();
@@ -1204,7 +1204,7 @@ void vfio_pci_write_config(PCIDevice *pdev,
for (bar = 0; bar < PCI_ROM_SLOT; bar++) {
if (old_addr[bar] != pdev->io_regions[bar].addr &&
vdev->bars[bar].region.size > 0 &&
- vdev->bars[bar].region.size < qemu_real_host_page_size) {
+ vdev->bars[bar].region.size < qemu_real_host_page_size()) {
vfio_sub_page_bar_update_mapping(pdev, bar);
}
}
@@ -1292,7 +1292,7 @@ static void vfio_pci_fixup_msix_region(VFIOPCIDevice *vdev)
}
/* MSI-X table start and end aligned to host page size */
- start = vdev->msix->table_offset & qemu_real_host_page_mask;
+ start = vdev->msix->table_offset & qemu_real_host_page_mask();
end = REAL_HOST_PAGE_ALIGN((uint64_t)vdev->msix->table_offset +
(vdev->msix->entries * PCI_MSIX_ENTRY_SIZE));
@@ -2478,7 +2478,7 @@ static int vfio_pci_load_config(VFIODevice *vbasedev, QEMUFile *f)
*/
if (old_addr[bar] != pdev->io_regions[bar].addr &&
vdev->bars[bar].region.size > 0 &&
- vdev->bars[bar].region.size < qemu_real_host_page_size) {
+ vdev->bars[bar].region.size < qemu_real_host_page_size()) {
vfio_sub_page_bar_update_mapping(pdev, bar);
}
}
diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
index 04c6e67..9ec1e95 100644
--- a/hw/vfio/spapr.c
+++ b/hw/vfio/spapr.c
@@ -44,7 +44,7 @@ static void vfio_prereg_listener_region_add(MemoryListener *listener,
const hwaddr gpa = section->offset_within_address_space;
hwaddr end;
int ret;
- hwaddr page_mask = qemu_real_host_page_mask;
+ hwaddr page_mask = qemu_real_host_page_mask();
struct vfio_iommu_spapr_register_memory reg = {
.argsz = sizeof(reg),
.flags = 0,
@@ -102,7 +102,7 @@ static void vfio_prereg_listener_region_del(MemoryListener *listener,
const hwaddr gpa = section->offset_within_address_space;
hwaddr end;
int ret;
- hwaddr page_mask = qemu_real_host_page_mask;
+ hwaddr page_mask = qemu_real_host_page_mask();
struct vfio_iommu_spapr_register_memory reg = {
.argsz = sizeof(reg),
.flags = 0,
@@ -199,12 +199,12 @@ int vfio_spapr_create_window(VFIOContainer *container,
* Below we look at qemu_real_host_page_size as TCEs are allocated from
* system pages.
*/
- bits_per_level = ctz64(qemu_real_host_page_size) + 8;
+ bits_per_level = ctz64(qemu_real_host_page_size()) + 8;
create.levels = bits_total / bits_per_level;
if (bits_total % bits_per_level) {
++create.levels;
}
- max_levels = (64 - create.page_shift) / ctz64(qemu_real_host_page_size);
+ max_levels = (64 - create.page_shift) / ctz64(qemu_real_host_page_size());
for ( ; create.levels <= max_levels; ++create.levels) {
ret = ioctl(container->fd, VFIO_IOMMU_SPAPR_TCE_CREATE, &create);
if (!ret) {
diff --git a/hw/virtio/vhost-iova-tree.c b/hw/virtio/vhost-iova-tree.c
index 55fed1f..67bf6d5 100644
--- a/hw/virtio/vhost-iova-tree.c
+++ b/hw/virtio/vhost-iova-tree.c
@@ -11,7 +11,7 @@
#include "qemu/iova-tree.h"
#include "vhost-iova-tree.h"
-#define iova_min_addr qemu_real_host_page_size
+#define iova_min_addr qemu_real_host_page_size()
/**
* VhostIOVATree, able to:
@@ -86,7 +86,7 @@ const DMAMap *vhost_iova_tree_find_iova(const VhostIOVATree *tree,
int vhost_iova_tree_map_alloc(VhostIOVATree *tree, DMAMap *map)
{
/* Some vhost devices do not like addr 0. Skip first page */
- hwaddr iova_first = tree->iova_first ?: qemu_real_host_page_size;
+ hwaddr iova_first = tree->iova_first ?: qemu_real_host_page_size();
if (map->translated_addr + map->size < map->translated_addr ||
map->perm == IOMMU_NONE) {
diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
index b232803..1e5cfe2 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -471,14 +471,14 @@ size_t vhost_svq_driver_area_size(const VhostShadowVirtqueue *svq)
size_t avail_size = offsetof(vring_avail_t, ring) +
sizeof(uint16_t) * svq->vring.num;
- return ROUND_UP(desc_size + avail_size, qemu_real_host_page_size);
+ return ROUND_UP(desc_size + avail_size, qemu_real_host_page_size());
}
size_t vhost_svq_device_area_size(const VhostShadowVirtqueue *svq)
{
size_t used_size = offsetof(vring_used_t, ring) +
sizeof(vring_used_elem_t) * svq->vring.num;
- return ROUND_UP(used_size, qemu_real_host_page_size);
+ return ROUND_UP(used_size, qemu_real_host_page_size());
}
/**
@@ -533,11 +533,11 @@ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev,
svq->vring.num = virtio_queue_get_num(vdev, virtio_get_queue_index(vq));
driver_size = vhost_svq_driver_area_size(svq);
device_size = vhost_svq_device_area_size(svq);
- svq->vring.desc = qemu_memalign(qemu_real_host_page_size, driver_size);
+ svq->vring.desc = qemu_memalign(qemu_real_host_page_size(), driver_size);
desc_size = sizeof(vring_desc_t) * svq->vring.num;
svq->vring.avail = (void *)((char *)svq->vring.desc + desc_size);
memset(svq->vring.desc, 0, driver_size);
- svq->vring.used = qemu_memalign(qemu_real_host_page_size, device_size);
+ svq->vring.used = qemu_memalign(qemu_real_host_page_size(), device_size);
memset(svq->vring.used, 0, device_size);
svq->ring_id_maps = g_new0(VirtQueueElement *, svq->vring.num);
for (unsigned i = 0; i < svq->vring.num - 1; i++) {
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 6abbc9d..9c4f84f 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1166,7 +1166,7 @@ static int vhost_user_set_vring_num(struct vhost_dev *dev,
static void vhost_user_host_notifier_free(VhostUserHostNotifier *n)
{
assert(n && n->unmap_addr);
- munmap(n->unmap_addr, qemu_real_host_page_size);
+ munmap(n->unmap_addr, qemu_real_host_page_size());
n->unmap_addr = NULL;
}
@@ -1503,7 +1503,7 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev,
int fd)
{
int queue_idx = area->u64 & VHOST_USER_VRING_IDX_MASK;
- size_t page_size = qemu_real_host_page_size;
+ size_t page_size = qemu_real_host_page_size();
struct vhost_user *u = dev->opaque;
VhostUserState *user = u->user;
VirtIODevice *vdev = dev->vdev;
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 8adf7c0..b57be52 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -20,10 +20,10 @@
#include "hw/virtio/vhost-shadow-virtqueue.h"
#include "hw/virtio/vhost-vdpa.h"
#include "exec/address-spaces.h"
+#include "qemu/cutils.h"
#include "qemu/main-loop.h"
#include "cpu.h"
#include "trace.h"
-#include "qemu-common.h"
#include "qapi/error.h"
/*
@@ -468,7 +468,7 @@ err:
static void vhost_vdpa_host_notifier_uninit(struct vhost_dev *dev,
int queue_index)
{
- size_t page_size = qemu_real_host_page_size;
+ size_t page_size = qemu_real_host_page_size();
struct vhost_vdpa *v = dev->opaque;
VirtIODevice *vdev = dev->vdev;
VhostVDPAHostNotifier *n;
@@ -485,7 +485,7 @@ static void vhost_vdpa_host_notifier_uninit(struct vhost_dev *dev,
static int vhost_vdpa_host_notifier_init(struct vhost_dev *dev, int queue_index)
{
- size_t page_size = qemu_real_host_page_size;
+ size_t page_size = qemu_real_host_page_size();
struct vhost_vdpa *v = dev->opaque;
VirtIODevice *vdev = dev->vdev;
VhostVDPAHostNotifier *n;
@@ -875,7 +875,7 @@ static bool vhost_vdpa_svq_unmap_ring(struct vhost_vdpa *v,
return false;
}
- size = ROUND_UP(result->size, qemu_real_host_page_size);
+ size = ROUND_UP(result->size, qemu_real_host_page_size());
r = vhost_vdpa_dma_unmap(v, result->iova, size);
return r == 0;
}
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index b643f42..e55ac32 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -989,7 +989,7 @@ static inline bool vhost_needs_vring_endian(VirtIODevice *vdev)
if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
return false;
}
-#ifdef HOST_WORDS_BIGENDIAN
+#if HOST_BIG_ENDIAN
return vdev->device_endian == VIRTIO_DEVICE_ENDIAN_LITTLE;
#else
return vdev->device_endian == VIRTIO_DEVICE_ENDIAN_BIG;
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 163d244..8f1b38e 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -452,7 +452,6 @@ static void virtio_balloon_receive_stats(VirtIODevice *vdev, VirtQueue *vq)
VirtQueueElement *elem;
VirtIOBalloonStat stat;
size_t offset = 0;
- qemu_timeval tv;
elem = virtqueue_pop(vq, sizeof(VirtQueueElement));
if (!elem) {
@@ -484,13 +483,7 @@ static void virtio_balloon_receive_stats(VirtIODevice *vdev, VirtQueue *vq)
s->stats[tag] = val;
}
s->stats_vq_offset = offset;
-
- if (qemu_gettimeofday(&tv) < 0) {
- warn_report("%s: failed to get time of day", __func__);
- goto out;
- }
-
- s->stats_last_update = tv.tv_sec;
+ s->stats_last_update = g_get_real_time() / G_USEC_PER_SEC;
out:
if (balloon_stats_enabled(s)) {
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
index 6d5ea0b..57c09d9 100644
--- a/hw/virtio/virtio-iommu.c
+++ b/hw/virtio/virtio-iommu.c
@@ -20,7 +20,6 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu/iov.h"
-#include "qemu-common.h"
#include "hw/qdev-properties.h"
#include "hw/virtio/virtio.h"
#include "sysemu/kvm.h"
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index f55dcf6..5aca408 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -11,7 +11,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/iov.h"
#include "qemu/cutils.h"
#include "qemu/error-report.h"
@@ -53,11 +52,11 @@ static uint32_t virtio_mem_default_thp_size(void)
#if defined(__x86_64__) || defined(__arm__) || defined(__powerpc64__)
default_thp_size = 2 * MiB;
#elif defined(__aarch64__)
- if (qemu_real_host_page_size == 4 * KiB) {
+ if (qemu_real_host_page_size() == 4 * KiB) {
default_thp_size = 2 * MiB;
- } else if (qemu_real_host_page_size == 16 * KiB) {
+ } else if (qemu_real_host_page_size() == 16 * KiB) {
default_thp_size = 32 * MiB;
- } else if (qemu_real_host_page_size == 64 * KiB) {
+ } else if (qemu_real_host_page_size() == 64 * KiB) {
default_thp_size = 512 * MiB;
}
#endif
@@ -120,7 +119,7 @@ static uint64_t virtio_mem_default_block_size(RAMBlock *rb)
const uint64_t page_size = qemu_ram_pagesize(rb);
/* We can have hugetlbfs with a page size smaller than the THP size. */
- if (page_size == qemu_real_host_page_size) {
+ if (page_size == qemu_real_host_page_size()) {
return MAX(page_size, virtio_mem_thp_size());
}
return MAX(page_size, VIRTIO_MEM_MIN_BLOCK_SIZE);
@@ -135,7 +134,7 @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb)
* fresh page, consuming actual memory.
*/
return !qemu_ram_is_shared(rb) && rb->fd < 0 &&
- qemu_ram_pagesize(rb) == qemu_real_host_page_size;
+ qemu_ram_pagesize(rb) == qemu_real_host_page_size();
}
#endif /* VIRTIO_MEM_HAS_LEGACY_GUESTS */
diff --git a/hw/virtio/virtio-pmem.c b/hw/virtio/virtio-pmem.c
index 5419dca..5dd21c2 100644
--- a/hw/virtio/virtio-pmem.c
+++ b/hw/virtio/virtio-pmem.c
@@ -13,7 +13,6 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "hw/virtio/virtio-pmem.h"
diff --git a/hw/xtensa/sim.c b/hw/xtensa/sim.c
index 2028fe7..946c71c 100644
--- a/hw/xtensa/sim.c
+++ b/hw/xtensa/sim.c
@@ -96,7 +96,7 @@ XtensaCPU *xtensa_sim_common_init(MachineState *machine)
void xtensa_sim_load_kernel(XtensaCPU *cpu, MachineState *machine)
{
const char *kernel_filename = machine->kernel_filename;
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
int big_endian = true;
#else
int big_endian = false;
diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index c1e004e..2a5556a 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -219,7 +219,7 @@ static const MemoryRegionOps xtfpga_io_ops = {
static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)
{
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
int be = 1;
#else
int be = 0;
@@ -430,7 +430,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)
}
if (entry_point != env->pc) {
uint8_t boot[] = {
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
0x60, 0x00, 0x08, /* j 1f */
0x00, /* .literal_position */
0x00, 0x00, 0x00, 0x00, /* .literal entry_pc */