Commit b5fe11a4 authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging



* new QMP command qom-list-properties (Alexey)
* TCG cleanups (David)
* use g_path_get_basename/g_path_get_dirname when useful (Julia)
* WHPX fixes (Justin)
* ASAN fixes (Marc-André)
* g364fb memory leak fix, address_space_to_flatview RCU fixes (me)
* chardev memory leak fix (Peter)
* checkpatch improvements (Julia, Su Hang)
* next round of deprecation patches (Thomas)

# gpg: Signature made Tue 06 Mar 2018 13:11:58 GMT
# gpg:                using RSA key BFFBD25F78C7AE83
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>"
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>"
# 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

* remotes/bonzini/tags/for-upstream: (34 commits)
  use g_path_get_basename instead of basename
  balloon: Fix documentation of the --balloon parameter and deprecate it
  WHPX improve interrupt notification registration
  WHXP Removes the use of WHvGetExitContextSize
  Fix WHPX issue leaking tpr values
  Fix WHPX typo in 'mmio'
  Fix WHPX additional lock acquisition
  Remove unnecessary WHPX __debugbreak();
  Resolves WHPX breaking changes in SDK 17095
  Fixing WHPX casing to match SDK
  Revert "build-sys: compile with -Og or -O1 when --enable-debug"
  checkpatch: add check for `while` and `for`
  checkpatch: add a warning for basename/dirname
  address_space_rw: address_space_to_flatview needs RCU lock
  address_space_map: address_space_to_flatview needs RCU lock
  address_space_access_valid: address_space_to_flatview needs RCU lock
  address_space_read: address_space_to_flatview needs RCU lock
  address_space_write: address_space_to_flatview needs RCU lock
  memory: inline some performance-sensitive accessors
  openpic_kvm: drop address_space_to_flatview call
  ...

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 58e2e17d 3e015d81
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -592,19 +592,23 @@ static gboolean tcp_chr_telnet_init_io(QIOChannel *ioc,
            ret = 0;
        } else {
            tcp_chr_disconnect(init->chr);
            return FALSE;
            goto end;
        }
    }
    init->buflen -= ret;

    if (init->buflen == 0) {
        tcp_chr_connect(init->chr);
        return FALSE;
        goto end;
    }

    memmove(init->buf, init->buf + ret, init->buflen);

    return TRUE;
    return G_SOURCE_CONTINUE;

end:
    g_free(init);
    return G_SOURCE_REMOVE;
}

static void tcp_chr_telnet_init(Chardev *chr)
+19 −28
Original line number Diff line number Diff line
@@ -2486,20 +2486,20 @@ fi
if test "$whpx" != "no" ; then
    cat > $TMPC << EOF
#include <windows.h>
#include <winhvplatform.h>
#include <winhvemulation.h>
#include <WinHvPlatform.h>
#include <WinHvEmulation.h>
int main(void) {
    WHV_CAPABILITY whpx_cap;
    WHvGetCapability(WHvCapabilityCodeFeatures, &whpx_cap, sizeof(whpx_cap));
    return 0;
}
EOF
    if compile_prog "" "-lwinhvplatform -lwinhvemulation" ; then
        libs_softmmu="$libs_softmmu -lwinhvplatform -lwinhvemulation"
    if compile_prog "" "-lWinHvPlatform -lWinHvEmulation" ; then
        libs_softmmu="$libs_softmmu -lWinHvPlatform -lWinHvEmulation"
        whpx="yes"
    else
        if test "$whpx" = "yes"; then
            feature_not_found "winhvplatform" "winhvemulation is not installed"
            feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
        fi
        whpx="no"
    fi
@@ -5316,25 +5316,27 @@ fi
##########################################
# checks for sanitizers

# we could use a simple skeleton for flags checks, but this also
# detect the static linking issue of ubsan, see also:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
cat > $TMPC << EOF
#include <stdint.h>
int main(void) {
  return INT32_MIN / -1;
}
EOF

have_asan=no
have_ubsan=no
have_asan_iface_h=no
have_asan_iface_fiber=no

if test "$sanitizers" = "yes" ; then
  write_c_skeleton
  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
      have_asan=yes
  fi

  # we could use a simple skeleton for flags checks, but this also
  # detect the static linking issue of ubsan, see also:
  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
  cat > $TMPC << EOF
#include <stdlib.h>
int main(void) {
    void *tmp = malloc(10);
    return *(int *)(tmp + 2);
}
EOF
  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
      have_ubsan=yes
  fi
@@ -5366,18 +5368,7 @@ if test "$gcov" = "yes" ; then
  LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
elif test "$fortify_source" = "yes" ; then
  CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
elif test "$debug" = "yes"; then
  if compile_prog "-Og" ""; then
      CFLAGS="-Og $CFLAGS"
  elif compile_prog "-O1" ""; then
      CFLAGS="-O1 $CFLAGS"
  fi
  # Workaround GCC false-positive Wuninitialized bugs with Og or O1:
  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
  if cc_has_warning_flag "-Wno-maybe-uninitialized"; then
      CFLAGS="-Wno-maybe-uninitialized $CFLAGS"
  fi
else
elif test "$debug" = "no"; then
  CFLAGS="-O2 $CFLAGS"
fi

+10 −23
Original line number Diff line number Diff line
@@ -1383,11 +1383,9 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg)
    qemu_mutex_lock_iothread();
    qemu_thread_get_self(cpu->thread);

    CPU_FOREACH(cpu) {
    cpu->thread_id = qemu_get_thread_id();
    cpu->created = true;
    cpu->can_do_io = 1;
    }
    qemu_cond_signal(&qemu_cpu_cond);

    /* wait for initial kick-off after machine start */
@@ -1856,13 +1854,13 @@ static void qemu_tcg_init_vcpu(CPUState *cpu)
#ifdef _WIN32
        cpu->hThread = qemu_thread_get_handle(cpu->thread);
#endif
        while (!cpu->created) {
            qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
        }
    } else {
        /* For non-MTTCG cases we share the thread */
        cpu->thread = single_tcg_cpu_thread;
        cpu->halt_cond = single_tcg_halt_cond;
        cpu->thread_id = first_cpu->thread_id;
        cpu->can_do_io = 1;
        cpu->created = true;
    }
}

@@ -1881,9 +1879,6 @@ static void qemu_hax_start_vcpu(CPUState *cpu)
#ifdef _WIN32
    cpu->hThread = qemu_thread_get_handle(cpu->thread);
#endif
    while (!cpu->created) {
        qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
    }
}

static void qemu_kvm_start_vcpu(CPUState *cpu)
@@ -1897,9 +1892,6 @@ static void qemu_kvm_start_vcpu(CPUState *cpu)
             cpu->cpu_index);
    qemu_thread_create(cpu->thread, thread_name, qemu_kvm_cpu_thread_fn,
                       cpu, QEMU_THREAD_JOINABLE);
    while (!cpu->created) {
        qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
    }
}

static void qemu_hvf_start_vcpu(CPUState *cpu)
@@ -1918,9 +1910,6 @@ static void qemu_hvf_start_vcpu(CPUState *cpu)
             cpu->cpu_index);
    qemu_thread_create(cpu->thread, thread_name, qemu_hvf_cpu_thread_fn,
                       cpu, QEMU_THREAD_JOINABLE);
    while (!cpu->created) {
        qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
    }
}

static void qemu_whpx_start_vcpu(CPUState *cpu)
@@ -1937,9 +1926,6 @@ static void qemu_whpx_start_vcpu(CPUState *cpu)
#ifdef _WIN32
    cpu->hThread = qemu_thread_get_handle(cpu->thread);
#endif
    while (!cpu->created) {
        qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
    }
}

static void qemu_dummy_start_vcpu(CPUState *cpu)
@@ -1953,9 +1939,6 @@ static void qemu_dummy_start_vcpu(CPUState *cpu)
             cpu->cpu_index);
    qemu_thread_create(cpu->thread, thread_name, qemu_dummy_cpu_thread_fn, cpu,
                       QEMU_THREAD_JOINABLE);
    while (!cpu->created) {
        qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
    }
}

void qemu_init_vcpu(CPUState *cpu)
@@ -1985,6 +1968,10 @@ void qemu_init_vcpu(CPUState *cpu)
    } else {
        qemu_dummy_start_vcpu(cpu);
    }

    while (!cpu->created) {
        qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
    }
}

void cpu_stop_current(void)
+53 −37
Original line number Diff line number Diff line
@@ -2616,6 +2616,8 @@ static const MemoryRegionOps watch_mem_ops = {
    },
};

static MemTxResult flatview_read(FlatView *fv, hwaddr addr,
                                      MemTxAttrs attrs, uint8_t *buf, int len);
static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
                                  const uint8_t *buf, int len);
static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
@@ -3078,6 +3080,7 @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr,
    return result;
}

/* Called from RCU critical section.  */
static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
                                  const uint8_t *buf, int len)
{
@@ -3086,25 +3089,14 @@ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
    MemoryRegion *mr;
    MemTxResult result = MEMTX_OK;

    if (len > 0) {
        rcu_read_lock();
    l = len;
    mr = flatview_translate(fv, addr, &addr1, &l, true);
    result = flatview_write_continue(fv, addr, attrs, buf, len,
                                     addr1, l, mr);
        rcu_read_unlock();
    }

    return result;
}

MemTxResult address_space_write(AddressSpace *as, hwaddr addr,
                                              MemTxAttrs attrs,
                                              const uint8_t *buf, int len)
{
    return flatview_write(address_space_to_flatview(as), addr, attrs, buf, len);
}

/* Called within RCU critical section.  */
MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr,
                                   MemTxAttrs attrs, uint8_t *buf,
@@ -3175,42 +3167,61 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr,
    return result;
}

MemTxResult flatview_read_full(FlatView *fv, hwaddr addr,
/* Called from RCU critical section.  */
static MemTxResult flatview_read(FlatView *fv, hwaddr addr,
                                 MemTxAttrs attrs, uint8_t *buf, int len)
{
    hwaddr l;
    hwaddr addr1;
    MemoryRegion *mr;
    MemTxResult result = MEMTX_OK;

    if (len > 0) {
        rcu_read_lock();
    l = len;
    mr = flatview_translate(fv, addr, &addr1, &l, false);
        result = flatview_read_continue(fv, addr, attrs, buf, len,
    return flatview_read_continue(fv, addr, attrs, buf, len,
                                  addr1, l, mr);
}

MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr,
                                    MemTxAttrs attrs, uint8_t *buf, int len)
{
    MemTxResult result = MEMTX_OK;
    FlatView *fv;

    if (len > 0) {
        rcu_read_lock();
        fv = address_space_to_flatview(as);
        result = flatview_read(fv, addr, attrs, buf, len);
        rcu_read_unlock();
    }

    return result;
}

static MemTxResult flatview_rw(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
                               uint8_t *buf, int len, bool is_write)
MemTxResult address_space_write(AddressSpace *as, hwaddr addr,
                                MemTxAttrs attrs,
                                const uint8_t *buf, int len)
{
    if (is_write) {
        return flatview_write(fv, addr, attrs, (uint8_t *)buf, len);
    } else {
        return flatview_read(fv, addr, attrs, (uint8_t *)buf, len);
    MemTxResult result = MEMTX_OK;
    FlatView *fv;

    if (len > 0) {
        rcu_read_lock();
        fv = address_space_to_flatview(as);
        result = flatview_write(fv, addr, attrs, buf, len);
        rcu_read_unlock();
    }

    return result;
}

MemTxResult address_space_rw(AddressSpace *as, hwaddr addr,
                             MemTxAttrs attrs, uint8_t *buf,
                             int len, bool is_write)
MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs,
                             uint8_t *buf, int len, bool is_write)
{
    return flatview_rw(address_space_to_flatview(as),
                       addr, attrs, buf, len, is_write);
    if (is_write) {
        return address_space_write(as, addr, attrs, buf, len);
    } else {
        return address_space_read_full(as, addr, attrs, buf, len);
    }
}

void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf,
@@ -3376,7 +3387,6 @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
    MemoryRegion *mr;
    hwaddr l, xlat;

    rcu_read_lock();
    while (len > 0) {
        l = len;
        mr = flatview_translate(fv, addr, &xlat, &l, is_write);
@@ -3391,15 +3401,20 @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
        len -= l;
        addr += l;
    }
    rcu_read_unlock();
    return true;
}

bool address_space_access_valid(AddressSpace *as, hwaddr addr,
                                int len, bool is_write)
{
    return flatview_access_valid(address_space_to_flatview(as),
                                 addr, len, is_write);
    FlatView *fv;
    bool result;

    rcu_read_lock();
    fv = address_space_to_flatview(as);
    result = flatview_access_valid(fv, addr, len, is_write);
    rcu_read_unlock();
    return result;
}

static hwaddr
@@ -3445,7 +3460,7 @@ void *address_space_map(AddressSpace *as,
    hwaddr l, xlat;
    MemoryRegion *mr;
    void *ptr;
    FlatView *fv = address_space_to_flatview(as);
    FlatView *fv;

    if (len == 0) {
        return NULL;
@@ -3453,6 +3468,7 @@ void *address_space_map(AddressSpace *as,

    l = len;
    rcu_read_lock();
    fv = address_space_to_flatview(as);
    mr = flatview_translate(fv, addr, &xlat, &l, is_write);

    if (!memory_access_is_direct(mr, is_write)) {
+9 −6
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ static struct option helper_opts[] = {

static bool is_daemon;
static bool get_version; /* IOC getversion IOCTL supported */
static char *prog_name;

static void GCC_FMT_ATTR(2, 3) do_log(int loglevel, const char *format, ...)
{
@@ -785,7 +786,7 @@ error:
    return -1;
}

static void usage(char *prog)
static void usage(void)
{
    fprintf(stderr, "usage: %s\n"
            " -p|--path <path> 9p path to export\n"
@@ -795,7 +796,7 @@ static void usage(char *prog)
            " access to this socket\n"
            " \tNote: -s & -f can not be used together\n"
            " [-n|--nodaemon] Run as a normal program\n",
            basename(prog));
            prog_name);
}

static int process_reply(int sock, int type,
@@ -1045,6 +1046,8 @@ int main(int argc, char **argv)
    struct statfs st_fs;
#endif

    prog_name = g_path_get_basename(argv[0]);

    is_daemon = true;
    sock = -1;
    own_u = own_g = -1;
@@ -1077,7 +1080,7 @@ int main(int argc, char **argv)
        case '?':
        case 'h':
        default:
            usage(argv[0]);
            usage();
            exit(EXIT_FAILURE);
        }
    }
@@ -1085,13 +1088,13 @@ int main(int argc, char **argv)
    /* Parameter validation */
    if ((sock_name == NULL && sock == -1) || rpath == NULL) {
        fprintf(stderr, "socket, socket descriptor or path not specified\n");
        usage(argv[0]);
        usage();
        return -1;
    }

    if (sock_name && sock != -1) {
        fprintf(stderr, "both named socket and socket descriptor specified\n");
        usage(argv[0]);
        usage();
        exit(EXIT_FAILURE);
    }

@@ -1099,7 +1102,7 @@ int main(int argc, char **argv)
        fprintf(stderr, "owner uid:gid not specified, ");
        fprintf(stderr,
                "owner uid:gid specifies who can access the socket file\n");
        usage(argv[0]);
        usage();
        exit(EXIT_FAILURE);
    }

Loading