* 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-----

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>
This commit is contained in:
Richard Henderson 2022-04-19 18:22:15 -07:00
commit 1be5a765c0
515 changed files with 3179 additions and 1791 deletions

View File

@ -122,7 +122,7 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
MemoryRegion *area = section->mr;
bool writeable = !area->readonly && !area->rom_device;
hv_memory_flags_t flags;
uint64_t page_size = qemu_real_host_page_size;
uint64_t page_size = qemu_real_host_page_size();
if (!memory_region_is_ram(area)) {
if (writeable) {

View File

@ -9,7 +9,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qemu/error-report.h"
#include "sysemu/hvf.h"
#include "sysemu/hvf_int.h"

View File

@ -59,7 +59,7 @@
#ifdef PAGE_SIZE
#undef PAGE_SIZE
#endif
#define PAGE_SIZE qemu_real_host_page_size
#define PAGE_SIZE qemu_real_host_page_size()
#ifndef KVM_GUESTDBG_BLOCKIRQ
#define KVM_GUESTDBG_BLOCKIRQ 0
@ -324,14 +324,14 @@ static hwaddr kvm_align_section(MemoryRegionSection *section,
with sub-page size and unaligned start address. Pad the start
address to next and truncate size to previous page boundary. */
aligned = ROUND_UP(section->offset_within_address_space,
qemu_real_host_page_size);
qemu_real_host_page_size());
delta = aligned - section->offset_within_address_space;
*start = aligned;
if (delta > size) {
return 0;
}
return (size - delta) & qemu_real_host_page_mask;
return (size - delta) & qemu_real_host_page_mask();
}
int kvm_physical_memory_addr_from_host(KVMState *s, void *ram,
@ -626,7 +626,7 @@ static void kvm_log_stop(MemoryListener *listener,
static void kvm_slot_sync_dirty_pages(KVMSlot *slot)
{
ram_addr_t start = slot->ram_start_offset;
ram_addr_t pages = slot->memory_size / qemu_real_host_page_size;
ram_addr_t pages = slot->memory_size / qemu_real_host_page_size();
cpu_physical_memory_set_dirty_lebitmap(slot->dirty_bmap, start, pages);
}
@ -662,7 +662,7 @@ static void kvm_slot_init_dirty_bitmap(KVMSlot *mem)
* And mem->memory_size is aligned to it (otherwise this mem can't
* be registered to KVM).
*/
hwaddr bitmap_size = ALIGN(mem->memory_size / qemu_real_host_page_size,
hwaddr bitmap_size = ALIGN(mem->memory_size / qemu_real_host_page_size(),
/*HOST_LONG_BITS*/ 64) / 8;
mem->dirty_bmap = g_malloc0(bitmap_size);
mem->dirty_bmap_size = bitmap_size;
@ -707,7 +707,7 @@ static void kvm_dirty_ring_mark_page(KVMState *s, uint32_t as_id,
mem = &kml->slots[slot_id];
if (!mem->memory_size || offset >=
(mem->memory_size / qemu_real_host_page_size)) {
(mem->memory_size / qemu_real_host_page_size())) {
return;
}
@ -895,7 +895,7 @@ static void kvm_physical_sync_dirty_bitmap(KVMMemoryListener *kml,
/* Alignment requirement for KVM_CLEAR_DIRTY_LOG - 64 pages */
#define KVM_CLEAR_LOG_SHIFT 6
#define KVM_CLEAR_LOG_ALIGN (qemu_real_host_page_size << KVM_CLEAR_LOG_SHIFT)
#define KVM_CLEAR_LOG_ALIGN (qemu_real_host_page_size() << KVM_CLEAR_LOG_SHIFT)
#define KVM_CLEAR_LOG_MASK (-KVM_CLEAR_LOG_ALIGN)
static int kvm_log_clear_one_slot(KVMSlot *mem, int as_id, uint64_t start,
@ -904,7 +904,7 @@ static int kvm_log_clear_one_slot(KVMSlot *mem, int as_id, uint64_t start,
KVMState *s = kvm_state;
uint64_t end, bmap_start, start_delta, bmap_npages;
struct kvm_clear_dirty_log d;
unsigned long *bmap_clear = NULL, psize = qemu_real_host_page_size;
unsigned long *bmap_clear = NULL, psize = qemu_real_host_page_size();
int ret;
/*
@ -1202,8 +1202,8 @@ void kvm_hwpoison_page_add(ram_addr_t ram_addr)
static uint32_t adjust_ioeventfd_endianness(uint32_t val, uint32_t size)
{
#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
/* The kernel expects ioeventfd values in HOST_WORDS_BIGENDIAN
#if HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN
/* The kernel expects ioeventfd values in HOST_BIG_ENDIAN
* endianness, but the memory core hands them in target endianness.
* For example, PPC is always treated as big-endian even if running
* on KVM and on PPC64LE. Correct here.
@ -1335,7 +1335,7 @@ kvm_check_extension_list(KVMState *s, const KVMCapabilityInfo *list)
void kvm_set_max_memslot_size(hwaddr max_slot_size)
{
g_assert(
ROUND_UP(max_slot_size, qemu_real_host_page_size) == max_slot_size
ROUND_UP(max_slot_size, qemu_real_host_page_size()) == max_slot_size
);
kvm_max_slot_size = max_slot_size;
}
@ -2341,7 +2341,7 @@ static int kvm_init(MachineState *ms)
* even with KVM. TARGET_PAGE_SIZE is assumed to be the minimum
* page size for the system though.
*/
assert(TARGET_PAGE_SIZE <= qemu_real_host_page_size);
assert(TARGET_PAGE_SIZE <= qemu_real_host_page_size());
s->sigmask_len = 8;

View File

@ -63,7 +63,7 @@
the ATOMIC_NAME macro, and redefined below. */
#if DATA_SIZE == 1
# define END
#elif defined(HOST_WORDS_BIGENDIAN)
#elif HOST_BIG_ENDIAN
# define END _be
#else
# define END _le
@ -196,7 +196,7 @@ GEN_ATOMIC_HELPER_FN(umax_fetch, MAX, DATA_TYPE, new)
/* Define reverse-host-endian atomic operations. Note that END is used
within the ATOMIC_NAME macro. */
#ifdef HOST_WORDS_BIGENDIAN
#if HOST_BIG_ENDIAN
# define END _le
#else
# define END _be

View File

@ -18,7 +18,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qemu/qemu-print.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-machine.h"

View File

@ -24,7 +24,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "sysemu/tcg.h"
#include "sysemu/replay.h"
#include "sysemu/cpu-timers.h"

View File

@ -24,7 +24,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "sysemu/tcg.h"
#include "sysemu/replay.h"
#include "sysemu/cpu-timers.h"

View File

@ -24,7 +24,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "sysemu/tcg.h"
#include "sysemu/replay.h"
#include "sysemu/cpu-timers.h"

View File

@ -26,7 +26,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "sysemu/tcg.h"
#include "sysemu/replay.h"
#include "sysemu/cpu-timers.h"

View File

@ -24,7 +24,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "sysemu/tcg.h"
#include "sysemu/cpu-timers.h"
#include "tcg/tcg.h"

View File

@ -18,7 +18,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#define NO_CPU_IO_DEFS
#include "trace.h"

View File

@ -32,7 +32,7 @@
#include "qapi/qapi-visit-audio.h"
#include "qemu/cutils.h"
#include "qemu/module.h"
#include "qemu-common.h"
#include "sysemu/sysemu.h"
#include "sysemu/replay.h"
#include "sysemu/runstate.h"
#include "ui/qemu-spice.h"

View File

@ -32,7 +32,7 @@
typedef void (*audio_callback_fn) (void *opaque, int avail);
#ifdef HOST_WORDS_BIGENDIAN
#if HOST_BIG_ENDIAN
#define AUDIO_HOST_ENDIANNESS 1
#else
#define AUDIO_HOST_ENDIANNESS 0

View File

@ -1,7 +1,6 @@
/* public domain */
#include "qemu/osdep.h"
#include "qemu-common.h"
#define AUDIO_CAP "win-int"
#include <windows.h>

View File

@ -122,7 +122,7 @@ static size_t dbus_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size)
return size;
}
#ifdef HOST_WORDS_BIGENDIAN
#if HOST_BIG_ENDIAN
#define AUDIO_HOST_BE TRUE
#else
#define AUDIO_HOST_BE FALSE

View File

@ -12,7 +12,6 @@
#include <sys/ioctl.h>
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qom/object_interfaces.h"
#include "qapi/error.h"
#include "sysemu/hostmem.h"

View File

@ -319,7 +319,7 @@ size_t host_memory_backend_pagesize(HostMemoryBackend *memdev)
#else
size_t host_memory_backend_pagesize(HostMemoryBackend *memdev)
{
return qemu_real_host_page_size;
return qemu_real_host_page_size();
}
#endif

View File

@ -23,7 +23,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qemu/error-report.h"
#include "qemu/module.h"
#include "qemu/sockets.h"

View File

@ -135,7 +135,7 @@ size_t bdrv_opt_mem_align(BlockDriverState *bs)
{
if (!bs || !bs->drv) {
/* page size or 4k (hdd sector size) should be on the safe side */
return MAX(4096, qemu_real_host_page_size);
return MAX(4096, qemu_real_host_page_size());
}
IO_CODE();
@ -146,7 +146,7 @@ size_t bdrv_min_mem_align(BlockDriverState *bs)
{
if (!bs || !bs->drv) {
/* page size or 4k (hdd sector size) should be on the safe side */
return MAX(4096, qemu_real_host_page_size);
return MAX(4096, qemu_real_host_page_size());
}
IO_CODE();

View File

@ -23,7 +23,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qapi/error.h"
#include "qemu/cutils.h"
#include "qemu/error-report.h"
@ -386,7 +385,7 @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
{
BDRVRawState *s = bs->opaque;
char *buf;
size_t max_align = MAX(MAX_BLOCKSIZE, qemu_real_host_page_size);
size_t max_align = MAX(MAX_BLOCKSIZE, qemu_real_host_page_size());
size_t alignments[] = {1, 512, 1024, 2048, 4096};
/* For SCSI generic devices the alignment is not really used.
@ -1261,7 +1260,7 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
raw_probe_alignment(bs, s->fd, errp);
bs->bl.min_mem_alignment = s->buf_align;
bs->bl.opt_mem_alignment = MAX(s->buf_align, qemu_real_host_page_size);
bs->bl.opt_mem_alignment = MAX(s->buf_align, qemu_real_host_page_size());
/*
* Maximum transfers are best effort, so it is okay to ignore any
@ -1886,7 +1885,7 @@ static int allocate_first_block(int fd, size_t max_size)
size_t write_size = (max_size < MAX_BLOCKSIZE)
? BDRV_SECTOR_SIZE
: MAX_BLOCKSIZE;
size_t max_align = MAX(MAX_BLOCKSIZE, qemu_real_host_page_size);
size_t max_align = MAX(MAX_BLOCKSIZE, qemu_real_host_page_size());
void *buf;
ssize_t n;
int ret;

View File

@ -201,7 +201,7 @@ void bdrv_refresh_limits(BlockDriverState *bs, Transaction *tran, Error **errp)
if (!have_limits) {
bs->bl.min_mem_alignment = 512;
bs->bl.opt_mem_alignment = qemu_real_host_page_size;
bs->bl.opt_mem_alignment = qemu_real_host_page_size();
/* Safe default since most protocols use readv()/writev()/etc */
bs->bl.max_iov = IOV_MAX;

View File

@ -10,7 +10,6 @@
*/
#include "qemu/osdep.h"
#include <liburing.h>
#include "qemu-common.h"
#include "block/aio.h"
#include "qemu/queue.h"
#include "block/block.h"

View File

@ -28,7 +28,7 @@
#include <poll.h>
#include <math.h>
#include <arpa/inet.h>
#include "qemu-common.h"
#include "sysemu/sysemu.h"
#include "qemu/config-file.h"
#include "qemu/error-report.h"
#include "qemu/bitops.h"

View File

@ -169,9 +169,9 @@ static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
size_t bytes;
int r;
bytes = ROUND_UP(nentries * entry_bytes, qemu_real_host_page_size);
bytes = ROUND_UP(nentries * entry_bytes, qemu_real_host_page_size());
q->head = q->tail = 0;
q->queue = qemu_try_memalign(qemu_real_host_page_size, bytes);
q->queue = qemu_try_memalign(qemu_real_host_page_size(), bytes);
if (!q->queue) {
error_setg(errp, "Cannot allocate queue");
return false;
@ -232,8 +232,8 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
trace_nvme_create_queue_pair(idx, q, size, aio_context,
event_notifier_get_fd(s->irq_notifier));
bytes = QEMU_ALIGN_UP(s->page_size * NVME_NUM_REQS,
qemu_real_host_page_size);
q->prp_list_pages = qemu_try_memalign(qemu_real_host_page_size, bytes);
qemu_real_host_page_size());
q->prp_list_pages = qemu_try_memalign(qemu_real_host_page_size(), bytes);
if (!q->prp_list_pages) {
error_setg(errp, "Cannot allocate PRP page list");
goto fail;
@ -533,9 +533,9 @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
.opcode = NVME_ADM_CMD_IDENTIFY,
.cdw10 = cpu_to_le32(0x1),
};
size_t id_size = QEMU_ALIGN_UP(sizeof(*id), qemu_real_host_page_size);
size_t id_size = QEMU_ALIGN_UP(sizeof(*id), qemu_real_host_page_size());
id = qemu_try_memalign(qemu_real_host_page_size, id_size);
id = qemu_try_memalign(qemu_real_host_page_size(), id_size);
if (!id) {
error_setg(errp, "Cannot allocate buffer for identify response");
goto out;
@ -1048,7 +1048,7 @@ static coroutine_fn int nvme_cmd_map_qiov(BlockDriverState *bs, NvmeCmd *cmd,
bool retry = true;
uint64_t iova;
size_t len = QEMU_ALIGN_UP(qiov->iov[i].iov_len,
qemu_real_host_page_size);
qemu_real_host_page_size());
try_map:
r = qemu_vfio_dma_map(s->vfio,
qiov->iov[i].iov_base,
@ -1224,8 +1224,8 @@ static inline bool nvme_qiov_aligned(BlockDriverState *bs,
for (i = 0; i < qiov->niov; ++i) {
if (!QEMU_PTR_IS_ALIGNED(qiov->iov[i].iov_base,
qemu_real_host_page_size) ||
!QEMU_IS_ALIGNED(qiov->iov[i].iov_len, qemu_real_host_page_size)) {
qemu_real_host_page_size()) ||
!QEMU_IS_ALIGNED(qiov->iov[i].iov_len, qemu_real_host_page_size())) {
trace_nvme_qiov_unaligned(qiov, i, qiov->iov[i].iov_base,
qiov->iov[i].iov_len, s->page_size);
return false;
@ -1241,7 +1241,7 @@ static int nvme_co_prw(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
int r;
QEMU_AUTO_VFREE uint8_t *buf = NULL;
QEMUIOVector local_qiov;
size_t len = QEMU_ALIGN_UP(bytes, qemu_real_host_page_size);
size_t len = QEMU_ALIGN_UP(bytes, qemu_real_host_page_size());
assert(QEMU_IS_ALIGNED(offset, s->page_size));
assert(QEMU_IS_ALIGNED(bytes, s->page_size));
assert(bytes <= s->max_transfer);
@ -1251,7 +1251,7 @@ static int nvme_co_prw(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
}
s->stats.unaligned_accesses++;
trace_nvme_prw_buffered(s, offset, bytes, qiov->niov, is_write);
buf = qemu_try_memalign(qemu_real_host_page_size, len);
buf = qemu_try_memalign(qemu_real_host_page_size(), len);
if (!buf) {
return -ENOMEM;

View File

@ -870,7 +870,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
}
}
s->bat_dirty_block = 4 * qemu_real_host_page_size;
s->bat_dirty_block = 4 * qemu_real_host_page_size();
s->bat_dirty_bmap =
bitmap_new(DIV_ROUND_UP(s->header_size, s->bat_dirty_block));

View File

@ -75,7 +75,7 @@ static void qcow2_cache_table_release(Qcow2Cache *c, int i, int num_tables)
/* Using MADV_DONTNEED to discard memory is a Linux-specific feature */
#ifdef CONFIG_LINUX
void *t = qcow2_cache_get_table_addr(c, i);
int align = qemu_real_host_page_size;
int align = qemu_real_host_page_size();
size_t mem_size = (size_t) c->table_size * num_tables;
size_t offset = QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t;
size_t length = QEMU_ALIGN_DOWN(mem_size - offset, align);

View File

@ -1258,7 +1258,7 @@ static void internal_snapshot_prepare(BlkActionState *common,
BlockDriverState *bs;
QEMUSnapshotInfo old_sn, *sn;
bool ret;
qemu_timeval tv;
int64_t rt;
BlockdevSnapshotInternal *internal;
InternalSnapshotState *state;
AioContext *aio_context;
@ -1328,9 +1328,9 @@ static void internal_snapshot_prepare(BlkActionState *common,
/* 3. take the snapshot */
sn = &state->sn;
pstrcpy(sn->name, sizeof(sn->name), name);
qemu_gettimeofday(&tv);
sn->date_sec = tv.tv_sec;
sn->date_nsec = tv.tv_usec * 1000;
rt = g_get_real_time();
sn->date_sec = rt / G_USEC_PER_SEC;
sn->date_nsec = (rt % G_USEC_PER_SEC) * 1000;
sn->vm_clock_nsec = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
if (replay_mode != REPLAY_MODE_NONE) {
sn->icount = replay_get_current_icount();

View File

@ -246,7 +246,7 @@ static void padzero(abi_ulong elf_bss, abi_ulong last_bss)
* patch target_mmap(), but it is more complicated as the file
* size must be known.
*/
if (qemu_real_host_page_size < qemu_host_page_size) {
if (qemu_real_host_page_size() < qemu_host_page_size) {
abi_ulong end_addr, end_addr1;
end_addr1 = REAL_HOST_PAGE_ALIGN(elf_bss);
end_addr = HOST_PAGE_ALIGN(elf_bss);

View File

@ -37,7 +37,6 @@
#include <utime.h>
#include "qemu.h"
#include "qemu-common.h"
#include "signal-common.h"
#include "user/syscall-trace.h"

View File

@ -19,7 +19,6 @@
#include "qemu/osdep.h"
#include "qemu.h"
#include "qemu-common.h"
static pthread_mutex_t mmap_mutex = PTHREAD_MUTEX_INITIALIZER;
static __thread int mmap_lock_count;
@ -515,7 +514,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
* up to the targets page boundary.
*/
if ((qemu_real_host_page_size < qemu_host_page_size) && fd != -1) {
if ((qemu_real_host_page_size() < qemu_host_page_size) && fd != -1) {
struct stat sb;
if (fstat(fd, &sb) == -1) {

View File

@ -465,7 +465,7 @@ static inline void *lock_user_string(abi_ulong guest_addr)
static inline uint64_t target_arg64(uint32_t word0, uint32_t word1)
{
#if TARGET_ABI_BITS == 32
#ifdef TARGET_WORDS_BIGENDIAN
#if TARGET_BIG_ENDIAN
return ((uint64_t)word0 << 32) | word1;
#else
return ((uint64_t)word1 << 32) | word0;

View File

@ -23,7 +23,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qemu/module.h"
#include "qemu/sockets.h"
#include "qapi/error.h"

View File

@ -23,7 +23,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qapi/error.h"
#include "qemu/main-loop.h"
#include "qemu/module.h"

View File

@ -23,7 +23,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qapi/error.h"
#include "chardev/char.h"
#include "io/channel-file.h"
@ -197,6 +196,117 @@ static void char_pty_finalize(Object *obj)
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
}
#if defined HAVE_PTY_H
# include <pty.h>
#elif defined CONFIG_BSD
# include <termios.h>
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
# include <libutil.h>
# else
# include <util.h>
# endif
#elif defined CONFIG_SOLARIS
# include <termios.h>
# include <stropts.h>
#else
# include <termios.h>
#endif
#ifdef __sun__
#if !defined(HAVE_OPENPTY)
/* Once illumos has openpty(), this is going to be removed. */
static int openpty(int *amaster, int *aslave, char *name,
struct termios *termp, struct winsize *winp)
{
const char *slave;
int mfd = -1, sfd = -1;
*amaster = *aslave = -1;
mfd = open("/dev/ptmx", O_RDWR | O_NOCTTY);
if (mfd < 0) {
goto err;
}
if (grantpt(mfd) == -1 || unlockpt(mfd) == -1) {
goto err;
}
if ((slave = ptsname(mfd)) == NULL) {
goto err;
}
if ((sfd = open(slave, O_RDONLY | O_NOCTTY)) == -1) {
goto err;
}
if (ioctl(sfd, I_PUSH, "ptem") == -1 ||
(termp != NULL && tcgetattr(sfd, termp) < 0)) {
goto err;
}
*amaster = mfd;
*aslave = sfd;
if (winp) {
ioctl(sfd, TIOCSWINSZ, winp);
}
return 0;
err:
if (sfd != -1) {
close(sfd);
}
close(mfd);
return -1;
}
#endif
static void cfmakeraw (struct termios *termios_p)
{
termios_p->c_iflag &=
~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
termios_p->c_oflag &= ~OPOST;
termios_p->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
termios_p->c_cflag &= ~(CSIZE | PARENB);
termios_p->c_cflag |= CS8;
termios_p->c_cc[VMIN] = 0;
termios_p->c_cc[VTIME] = 0;
}
#endif
/* like openpty() but also makes it raw; return master fd */
static int qemu_openpty_raw(int *aslave, char *pty_name)
{
int amaster;
struct termios tty;
#if defined(__OpenBSD__) || defined(__DragonFly__)
char pty_buf[PATH_MAX];
#define q_ptsname(x) pty_buf
#else
char *pty_buf = NULL;
#define q_ptsname(x) ptsname(x)
#endif
if (openpty(&amaster, aslave, pty_buf, NULL, NULL) < 0) {
return -1;
}
/* Set raw attributes on the pty. */
tcgetattr(*aslave, &tty);
cfmakeraw(&tty);
tcsetattr(*aslave, TCSAFLUSH, &tty);
if (pty_name) {
strcpy(pty_name, q_ptsname(amaster));
}
return amaster;
}
static void char_pty_open(Chardev *chr,
ChardevBackend *backend,
bool *be_opened,

View File

@ -12,11 +12,11 @@ chardev_ss.add(files(
'char-udp.c',
'char.c',
))
chardev_ss.add(when: 'CONFIG_POSIX', if_true: files(
chardev_ss.add(when: 'CONFIG_POSIX', if_true: [files(
'char-fd.c',
'char-parallel.c',
'char-pty.c',
))
), util])
chardev_ss.add(when: 'CONFIG_WIN32', if_true: files(
'char-console.c',
'char-win-stdio.c',

View File

@ -1,6 +1,6 @@
TARGET_ARCH=aarch64
TARGET_BASE_ARCH=arm
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_XML_FILES= gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml
TARGET_HAS_BFLT=y
CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y

View File

@ -1,7 +1,7 @@
TARGET_ARCH=arm
TARGET_SYSTBL_ABI=common,oabi
TARGET_SYSTBL=syscall.tbl
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_XML_FILES= gdb-xml/arm-core.xml gdb-xml/arm-vfp.xml gdb-xml/arm-vfp3.xml gdb-xml/arm-vfp-sysregs.xml gdb-xml/arm-neon.xml gdb-xml/arm-m-profile.xml gdb-xml/arm-m-profile-mve.xml
TARGET_HAS_BFLT=y
CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y

View File

@ -2,4 +2,4 @@ TARGET_ARCH=hppa
TARGET_SYSTBL_ABI=common,32
TARGET_SYSTBL=syscall.tbl
TARGET_ALIGNED_ONLY=y
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y

View File

@ -1,4 +1,4 @@
TARGET_ARCH=hppa
TARGET_ALIGNED_ONLY=y
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_SUPPORTS_MTTCG=y

View File

@ -1,6 +1,6 @@
TARGET_ARCH=m68k
TARGET_SYSTBL_ABI=common
TARGET_SYSTBL=syscall.tbl
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_XML_FILES= gdb-xml/cf-core.xml gdb-xml/cf-fp.xml gdb-xml/m68k-core.xml gdb-xml/m68k-fp.xml
TARGET_HAS_BFLT=y

View File

@ -1,3 +1,3 @@
TARGET_ARCH=m68k
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_XML_FILES= gdb-xml/cf-core.xml gdb-xml/cf-fp.xml gdb-xml/m68k-core.xml gdb-xml/m68k-fp.xml

View File

@ -1,5 +1,5 @@
TARGET_ARCH=microblaze
TARGET_SYSTBL_ABI=common
TARGET_SYSTBL=syscall.tbl
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_HAS_BFLT=y

View File

@ -1,4 +1,4 @@
TARGET_ARCH=microblaze
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_SUPPORTS_MTTCG=y
TARGET_NEED_FDT=y

View File

@ -3,4 +3,4 @@ TARGET_ABI_MIPSO32=y
TARGET_SYSTBL_ABI=o32
TARGET_SYSTBL=syscall_o32.tbl
TARGET_ALIGNED_ONLY=y
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y

View File

@ -1,4 +1,4 @@
TARGET_ARCH=mips
TARGET_ALIGNED_ONLY=y
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_SUPPORTS_MTTCG=y

View File

@ -4,4 +4,4 @@ TARGET_BASE_ARCH=mips
TARGET_SYSTBL_ABI=n64
TARGET_SYSTBL=syscall_n64.tbl
TARGET_ALIGNED_ONLY=y
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y

View File

@ -1,4 +1,4 @@
TARGET_ARCH=mips64
TARGET_BASE_ARCH=mips
TARGET_ALIGNED_ONLY=y
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y

View File

@ -5,4 +5,4 @@ TARGET_BASE_ARCH=mips
TARGET_SYSTBL_ABI=n32
TARGET_SYSTBL=syscall_n32.tbl
TARGET_ALIGNED_ONLY=y
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y

View File

@ -1,2 +1,2 @@
TARGET_ARCH=openrisc
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y

View File

@ -1,3 +1,3 @@
TARGET_ARCH=openrisc
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_NEED_FDT=y

View File

@ -1,5 +1,5 @@
TARGET_ARCH=ppc
TARGET_SYSTBL_ABI=common,nospu,32
TARGET_SYSTBL=syscall.tbl
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_XML_FILES= gdb-xml/power-core.xml gdb-xml/power-fpu.xml gdb-xml/power-altivec.xml gdb-xml/power-spe.xml

View File

@ -1,4 +1,4 @@
TARGET_ARCH=ppc
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_XML_FILES= gdb-xml/power-core.xml gdb-xml/power-fpu.xml gdb-xml/power-altivec.xml gdb-xml/power-spe.xml
TARGET_NEED_FDT=y

View File

@ -3,5 +3,5 @@ TARGET_BASE_ARCH=ppc
TARGET_ABI_DIR=ppc
TARGET_SYSTBL_ABI=common,nospu,64
TARGET_SYSTBL=syscall.tbl
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_XML_FILES= gdb-xml/power64-core.xml gdb-xml/power-fpu.xml gdb-xml/power-altivec.xml gdb-xml/power-spe.xml gdb-xml/power-vsx.xml

View File

@ -1,6 +1,6 @@
TARGET_ARCH=ppc64
TARGET_BASE_ARCH=ppc
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_SUPPORTS_MTTCG=y
TARGET_XML_FILES= gdb-xml/power64-core.xml gdb-xml/power-fpu.xml gdb-xml/power-altivec.xml gdb-xml/power-spe.xml gdb-xml/power-vsx.xml
TARGET_NEED_FDT=y

View File

@ -1,5 +1,5 @@
TARGET_ARCH=s390x
TARGET_SYSTBL_ABI=common,64
TARGET_SYSTBL=syscall.tbl
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_XML_FILES= gdb-xml/s390x-core64.xml gdb-xml/s390-acr.xml gdb-xml/s390-fpr.xml gdb-xml/s390-vx.xml gdb-xml/s390-cr.xml gdb-xml/s390-virt.xml gdb-xml/s390-gs.xml

View File

@ -1,4 +1,4 @@
TARGET_ARCH=s390x
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_SUPPORTS_MTTCG=y
TARGET_XML_FILES= gdb-xml/s390x-core64.xml gdb-xml/s390-acr.xml gdb-xml/s390-fpr.xml gdb-xml/s390-vx.xml gdb-xml/s390-cr.xml gdb-xml/s390-virt.xml gdb-xml/s390-gs.xml

View File

@ -2,5 +2,5 @@ TARGET_ARCH=sh4
TARGET_SYSTBL_ABI=common
TARGET_SYSTBL=syscall.tbl
TARGET_ALIGNED_ONLY=y
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_HAS_BFLT=y

View File

@ -1,3 +1,3 @@
TARGET_ARCH=sh4
TARGET_ALIGNED_ONLY=y
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y

View File

@ -2,4 +2,4 @@ TARGET_ARCH=sparc
TARGET_SYSTBL_ABI=common,32
TARGET_SYSTBL=syscall.tbl
TARGET_ALIGNED_ONLY=y
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y

View File

@ -1,3 +1,3 @@
TARGET_ARCH=sparc
TARGET_ALIGNED_ONLY=y
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y

View File

@ -5,4 +5,4 @@ TARGET_ABI_DIR=sparc
TARGET_SYSTBL_ABI=common,32
TARGET_SYSTBL=syscall.tbl
TARGET_ALIGNED_ONLY=y
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y

View File

@ -4,4 +4,4 @@ TARGET_ABI_DIR=sparc
TARGET_SYSTBL_ABI=common,64
TARGET_SYSTBL=syscall.tbl
TARGET_ALIGNED_ONLY=y
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y

View File

@ -1,4 +1,4 @@
TARGET_ARCH=sparc64
TARGET_BASE_ARCH=sparc
TARGET_ALIGNED_ONLY=y
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y

View File

@ -1,5 +1,5 @@
TARGET_ARCH=xtensa
TARGET_SYSTBL_ABI=common
TARGET_SYSTBL=syscall.tbl
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_HAS_BFLT=y

View File

@ -1,3 +1,3 @@
TARGET_ARCH=xtensa
TARGET_WORDS_BIGENDIAN=y
TARGET_BIG_ENDIAN=y
TARGET_SUPPORTS_MTTCG=y

View File

@ -53,7 +53,7 @@ struct udmabuf_create {
static size_t
udmabuf_get_size(struct vugbm_buffer *buf)
{
return ROUND_UP(buf->width * buf->height * 4, qemu_real_host_page_size);
return ROUND_UP(buf->width * buf->height * 4, qemu_real_host_page_size());
}
static bool

5
cpu.c
View File

@ -18,7 +18,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qapi/error.h"
#include "exec/target_page.h"
@ -469,7 +468,7 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
bool target_words_bigendian(void)
{
#if defined(TARGET_WORDS_BIGENDIAN)
#if TARGET_BIG_ENDIAN
return true;
#else
return false;
@ -481,7 +480,7 @@ void page_size_init(void)
/* NOTE: we can always suppose that qemu_host_page_size >=
TARGET_PAGE_SIZE */
if (qemu_host_page_size == 0) {
qemu_host_page_size = qemu_real_host_page_size;
qemu_host_page_size = qemu_real_host_page_size();
}
if (qemu_host_page_size < TARGET_PAGE_SIZE) {
qemu_host_page_size = TARGET_PAGE_SIZE;

View File

@ -12,7 +12,6 @@
*/
#include "qemu/osdep.h"
#include "qemu/sockets.h"
#include "qemu-common.h"
#include "qapi/error.h"
#include "crypto/cipher.h"
#include "cipherpriv.h"

View File

@ -13,7 +13,6 @@
#include "qemu/osdep.h"
#include "qemu/iov.h"
#include "qemu/sockets.h"
#include "qemu-common.h"
#include "qapi/error.h"
#include "crypto/hash.h"
#include "crypto/hmac.h"

View File

@ -126,7 +126,7 @@ static void initialize_debug_target(CPUDebug *s, CPUState *cpu)
s->cpu = cpu;
s->info.read_memory_func = target_read_memory;
s->info.print_address_func = print_address;
#ifdef TARGET_WORDS_BIGENDIAN
#if TARGET_BIG_ENDIAN
s->info.endian = BFD_ENDIAN_BIG;
#else
s->info.endian = BFD_ENDIAN_LITTLE;
@ -144,7 +144,7 @@ static void initialize_debug_host(CPUDebug *s)
s->info.read_memory_func = host_read_memory;
s->info.print_address_func = host_print_address;
#ifdef HOST_WORDS_BIGENDIAN
#if HOST_BIG_ENDIAN
s->info.endian = BFD_ENDIAN_BIG;
#else
s->info.endian = BFD_ENDIAN_LITTLE;

View File

@ -275,7 +275,7 @@ called during the translator callback ``translate_insn``.
There is a set of functions ending in ``_swap`` which, if the parameter
is true, returns the value in the endianness that is the reverse of
the guest native endianness, as determined by ``TARGET_WORDS_BIGENDIAN``.
the guest native endianness, as determined by ``TARGET_BIG_ENDIAN``.
Function names follow the pattern:

View File

@ -225,6 +225,21 @@ default (WS2016).
Note: hv-version-id-* are not enlightenments and thus don't enable Hyper-V
identification when specified without any other enlightenments.
3.21. hv-syndbg
===============
Enables Hyper-V synthetic debugger interface, this is a special interface used
by Windows Kernel debugger to send the packets through, rather than sending
them via serial/network .
When enabled, this enlightenment provides additional communication facilities
to the guest: SynDbg messages.
This new communication is used by Windows Kernel debugger rather than sending
packets via serial/network, adding significant performance boost over the other
comm channels.
This enlightenment requires a VMBus device (-device vmbus-bridge,irq=15)
and the follow enlightenments to work:
hv-relaxed,hv_time,hv-vapic,hv-vpindex,hv-synic,hv-runtime,hv-stimer
4. Supplementary features
=========================

View File

@ -12,7 +12,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qemu/cutils.h"
#include "elf.h"
#include "exec/hwaddr.h"
@ -1564,7 +1563,7 @@ static void dump_state_prepare(DumpState *s)
*s = (DumpState) { .status = DUMP_STATUS_ACTIVE };
}
bool dump_in_progress(void)
bool qemu_system_dump_in_progress(void)
{
DumpState *state = &dump_state_global;
return (qatomic_read(&state->status) == DUMP_STATUS_ACTIVE);
@ -1930,7 +1929,7 @@ void qmp_dump_guest_memory(bool paging, const char *file,
/* if there is a dump in background, we should wait until the dump
* finished */
if (dump_in_progress()) {
if (qemu_system_dump_in_progress()) {
error_setg(errp, "There is a dump in process, please wait.");
return;
}

View File

@ -9,7 +9,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qemu/cutils.h"
#include "elf.h"
#include "exec/hwaddr.h"

View File

@ -21,7 +21,6 @@
#include <linux/magic.h>
#endif
#include <cap-ng.h>
#include "qemu-common.h"
#include "qemu/sockets.h"
#include "qemu/xattr.h"
#include "9p-iov-marshal.h"

View File

@ -24,7 +24,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "qemu/ctype.h"
@ -519,7 +518,15 @@ static int gdb_continue_partial(char *newstates)
int flag = 0;
if (!runstate_needs_reset()) {
if (vm_prepare_start()) {
bool step_requested = false;
CPU_FOREACH(cpu) {
if (newstates[cpu->cpu_index] == 's') {
step_requested = true;
break;
}
}
if (vm_prepare_start(step_requested)) {
return 0;
}

View File

@ -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"

View File

@ -7,7 +7,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "cpu.h"
#include "elf.h"
#include "hw/loader.h"

View File

@ -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;

View File

@ -9,7 +9,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qemu/datadir.h"
#include "hw/loader.h"
#include "elf.h"

View File

@ -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);

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -23,7 +23,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qapi/error.h"
#include "ui/console.h"

View File

@ -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;

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -4,7 +4,6 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qemu/datadir.h"
#include "cpu.h"
#include "elf.h"

View File

@ -11,3 +11,8 @@ config VMBUS
bool
default y
depends on HYPERV
config SYNDBG
bool
default y
depends on VMBUS

View File

@ -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;
}

View File

@ -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'))

402
hw/hyperv/syndbg.c Normal file
View File

@ -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)

View File

@ -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"

View File

@ -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"

View File

@ -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"

Some files were not shown because too many files have changed in this diff Show More