From patchwork Fri Jun 14 17:11:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166857 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2342516ilk; Fri, 14 Jun 2019 10:44:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHjNr7j2fqOjWr2Z3uS/54vEEr0UZba2vqk9F1WK7cm4+Imzw99t4uNOrubXub/50/3YOZ X-Received: by 2002:ae9:f20c:: with SMTP id m12mr76958152qkg.58.1560534268377; Fri, 14 Jun 2019 10:44:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534268; cv=none; d=google.com; s=arc-20160816; b=vPbJyYll0PI7cDk1lR8Sg83zDsVS8FGuKz2kVKmtI3X9rF0YE/Kc+pluMmvqNWt9sB 6OmuqsziJuXYKPph+JHMRmsWGgTBjI644cFTvybf4Bcm6ZroAb9n9GSoeT4mpj0QbdjU Dya+T0eHgddlNMfxR1OG4jXsMqEsODa4djtrI2RFrjVuWQ5SFmcoX0qB09+IeWmx7Vm7 300990b17CJ5bSq0GJs4pQ2k9t2Ma7aK7CHrjQsJr2PevetgLdmredp27aitfbalYWE6 CdwaIuccZvAj/eOoDgGoBABl6flb/2zwig96lT1O1rukIwZidBfXuxhhrLPmIoXND1z9 3UZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=IwZdpz8vUj//qW3TG8z9CwKHzzC4bqX+Vltp43bJ1yk=; b=YncL+aogkxAEp8iPbJPa9DDQqoGQa5c8fOFThE2OZXoYx7CnowV8Odd52BrMFgW908 6HvR42oI8SOUYRusNzu7Y8xibifSlmAFLxao+RdJhuvBur83r74WN+BMrP7NqqIW4Mlm KHUnw1ZXFHDTb6Hk7+dv54ApZlY9ZIp8fAJey5rgJslYrlazEWUL30Ec7+dTpiYxfSB5 IJ9lFQ9trTds49xGg+6ihQsou1K/wDuU7e0xvvoMBJTubG/xH291Kk9CRhlgo4auxQ4n f3Ox9+eTW7Wg02Ja5+u+oyq0yV2gxXx9Q21pSLP0mJyVZ+YR1ge/nhHwx9ccFqy2lXkK 1byA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=o3sZ4Pnp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o9si2098466qvs.65.2019.06.14.10.44.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:44:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=o3sZ4Pnp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqFX-00021f-W2 for patch@linaro.org; Fri, 14 Jun 2019 13:44:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58595) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqh-0005ap-3b for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqe-00077D-Bx for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:46 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:39168) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqd-0006b4-T2 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:44 -0400 Received: by mail-wr1-x441.google.com with SMTP id x4so3333234wrt.6 for ; Fri, 14 Jun 2019 10:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IwZdpz8vUj//qW3TG8z9CwKHzzC4bqX+Vltp43bJ1yk=; b=o3sZ4PnpU7FHbCcoy45V70DS9r+zSw5ECniTV+Evo0WkDiAXXUAan11CUevOdMEY8n Nai+SerQO/wxlFsTX1Pr5YgRozUk4r9KbBlyEO3VNzQRFQszReDQ93r0H6fTkOzrtPGl XBTDQIvJmwhuL4bPnmk5p3Ri8cPANLkvz1fFcCWZ0AApk4fvr6FwyhJ+N1Q4H5GpZvi1 HqWPCy1XJY+UiQ1BZ0h4Sb6XP82C7rrQ8VWioBrnY28FrFgVfQgvgd53nzGiFQVs8Kdy MJVkRe+HRUOCN9NP6fz5/JO2muJQDyTbKBPs8fgVhTTND0cnKJYiqGt0Rhx/eXMeob0L 6LrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IwZdpz8vUj//qW3TG8z9CwKHzzC4bqX+Vltp43bJ1yk=; b=fMoMXNbzt/1Kkb+BP1A8dRv3yHHEMfbyNgjGflLOGGVBO6F6sABZOgj1opCutxp2M3 5haXsz+dpvbgSveMoXf4jn5OsF3M0dOCqZMOYzbyQr7JKgRF40WqYhe4aLQccg2OkWY3 AL6J/7QiL28GUYv9CPbuvZMHReo6iDE+wgPBlc67isvRDYvFiWu/uV87i4v7CovOAa9q gCF/lbzWpfwzAc33OGLBSWzqU0FRuNTD18eUDfJAQqr3utc4Qv9+c9IYZDsuK0FXJVuV td0CUUAbvHT+jBCB7TK4btf+NajEEYa8E/Jnx3PeIEiuTp+mrOUa/TFtkMBYl5XyU7l0 8hjg== X-Gm-Message-State: APjAAAXSHkAykLCe9J3qoiVtwXbYqs/Qqgs0Dd548HYOSN2cVh2Ostet /P1TJ79jWNswSx8Kqu9RDgwJNw== X-Received: by 2002:a5d:4008:: with SMTP id n8mr6522617wrp.353.1560532707867; Fri, 14 Jun 2019 10:18:27 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id q20sm6518030wra.36.2019.06.14.10.18.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:26 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9594B1FFAB; Fri, 14 Jun 2019 18:12:02 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:33 +0100 Message-Id: <20190614171200.21078-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PATCH v3 23/50] cpu: hook plugin vcpu events X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , "Emilio G. Cota" , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota --- cpus.c | 10 ++++++++++ exec.c | 2 ++ qom/cpu.c | 2 ++ 3 files changed, 14 insertions(+) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/cpus.c b/cpus.c index dde3b7b981..2f86af9a87 100644 --- a/cpus.c +++ b/cpus.c @@ -46,6 +46,7 @@ #include "exec/exec-all.h" #include "qemu/thread.h" +#include "qemu/plugin.h" #include "sysemu/cpus.h" #include "sysemu/qtest.h" #include "qemu/main-loop.h" @@ -1243,9 +1244,18 @@ static void qemu_tcg_rr_wait_io_event(void) static void qemu_wait_io_event(CPUState *cpu) { + bool slept = false; + while (cpu_thread_is_idle(cpu)) { + if (!slept) { + slept = true; + qemu_plugin_vcpu_idle_cb(cpu); + } qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex); } + if (slept) { + qemu_plugin_vcpu_resume_cb(cpu); + } #ifdef _WIN32 /* Eat dummy APC queued by qemu_cpu_kick_thread. */ diff --git a/exec.c b/exec.c index e7622d1956..4a29471c3d 100644 --- a/exec.c +++ b/exec.c @@ -974,6 +974,8 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) } tlb_init(cpu); + qemu_plugin_vcpu_init_hook(cpu); + #ifndef CONFIG_USER_ONLY if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu); diff --git a/qom/cpu.c b/qom/cpu.c index f376f782d8..90ebb214bb 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -33,6 +33,7 @@ #include "hw/boards.h" #include "hw/qdev-properties.h" #include "trace-root.h" +#include "qemu/plugin.h" CPUInterruptHandler cpu_interrupt_handler; @@ -354,6 +355,7 @@ static void cpu_common_unrealizefn(DeviceState *dev, Error **errp) CPUState *cpu = CPU(dev); /* NOTE: latest generic point before the cpu is fully unrealized */ trace_fini_vcpu(cpu); + qemu_plugin_vcpu_exit_hook(cpu); cpu_exec_unrealizefn(cpu); }