From patchwork Thu Oct 17 13:15:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176663 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1019867ill; Thu, 17 Oct 2019 07:36:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKJ3AVaVAgyHEnotWNISZyhIE4FsH8KVriBD01DXJog0dS8fZECEVqsfFn93u4ocz7kxEP X-Received: by 2002:a0c:e7ce:: with SMTP id c14mr4131438qvo.187.1571322973026; Thu, 17 Oct 2019 07:36:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571322973; cv=none; d=google.com; s=arc-20160816; b=OewQCEEmtJuJw+Cz9OiK6RSghhn0UcJ99eqxoo8TGQZddqG3cdDCKGRzl46KO07aC1 rpeh7VRy4jnzOgZe94Yp3ifOlJak1Ot3LkBUZ7mup+FIWV5OuZsbPVIKrtOPFw2gY+it PS6oTFM7FhF8sLCTzG+3J4zEd9Tr282Ugu6IXZ8jHKTW7BB4uJlf9ccSd5+i1I8VbHXM UeX29n+mQQufC77tgMro8YPEGAZr3R11CoUwJNgbrFj38ZQCQW2h/fi5cpL17dBz82D6 YPC1rOkAwkBDMJY9T7nijwcAw8BDDwo+ON9DQSQMmdhbYKhhghAawxbWp5xM/T32LT8G aM1w== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=G6i8iHuwznpz+U1YFqKClWDlEDl0r8YmQ0dBefcdrI8=; b=COG6imXkx3xq9QMybcdxOVzT/lXIsLFsfSo2jYcJFvfXE5ZTgjtSTGuKZIfFbS9pBy uAjSYlb4FYnxgIVcF8e/SygRjgKwM6gXtl9lyY/W0vviPspUKQoxZZSoa6OcD5yv+tjV O2Maa94hOPuQZfcJJG5uC4uR7EPcSlnmnEB1gxSx/b2MFXhJmJ2aE0rXxlpoTOVWOSqQ fWS0iTHGD4+YcPJHI0zh+p8A1t7DiUuaF7U193YBJfVLh5bVy/86uaQ772uff2Udyf4q Bhr8Es3aqcqMNuSyoDcdZ3lgq34gGlHd4bDFW6TLXBoFRpT6qMwp9o34CIBHC7QvxG/d SKqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SdiZc4vS; 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 f35si2045875qtb.181.2019.10.17.07.36.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:36:13 -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=SdiZc4vS; 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]:49436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6su-0003sL-Fb for patch@linaro.org; Thu, 17 Oct 2019 10:36:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37501) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5w7-0005xj-5c for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5w5-0004Qj-B0 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:27 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:44880) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5w5-0004Pw-4e for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:25 -0400 Received: by mail-wr1-x444.google.com with SMTP id z9so2373666wrl.11 for ; Thu, 17 Oct 2019 06:35:24 -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=G6i8iHuwznpz+U1YFqKClWDlEDl0r8YmQ0dBefcdrI8=; b=SdiZc4vSEfjoFdfXfkIQyfSdh7Ivxp2mD6QH58PL2jNUPKnFotm64MxgX+9lpWDl3H La5X6Z3dSrchs0lvo47nwJBynLwkuqglXyHIIFvMvCiBXmDAhkNA+ipGO7V3CKlEemQ/ txQS0Ksxzpa4ZwiLJcyI3FQOmQYUTOhlZfBX1MBAVqG1/1xS6f0k6E01Wk+G0kJ+AhAK 9eoJgoIkird8XuMXUgFEFwQFoDV1zE4aU7wSFqB7nIFhrAaHCdBw4/oZnY+9z6QSecVi i58+Kh8gmakXVFMjQtlHuSv9YQBiCvCBVanGU+1Q+BRHWgLWD+b74sLW5YIkSzdb+MCL cQcw== 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=G6i8iHuwznpz+U1YFqKClWDlEDl0r8YmQ0dBefcdrI8=; b=iObofW0oLaExZWuoiRV6OAP2nNslDVkzUiQWl8nV9VE46ziHqqTE5mg/r5C1Qoc8gE 1vuxGquu8Gd9Xe8yz7oW18/mSysl2R3MFVtvK1WKpUwMq9pBGoQthDlX9FXYCkMGYYuX rDdsBT4jrpi2c5QmP9fJ9DMlQLQR4fg5A8CnE3aoxXOXLoLUMKWdxSipQxHKmihqqo26 uDibNpRfWYMc3dj0OmCUjdR018Y0wFt0X9+ICmCEE7RaGmH4+IpnxrqpE/UsnyuyhUUR yLjyPsVGUOSbzdARn0YeKQrtA2hAU2Bxk8CmFtSKdERr95ujioNRd3rvLC5qoxesCTI8 uQUA== X-Gm-Message-State: APjAAAW8gzm0nFenbhKbRsY6VWzV+WVjjhzrgQJY3RwGM6El35ypD33y 9NqjonCQ4Ly26wavAjpHqhRSng== X-Received: by 2002:a05:6000:1190:: with SMTP id g16mr3038816wrx.133.1571319322805; Thu, 17 Oct 2019 06:35:22 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id o19sm2622802wmh.27.2019.10.17.06.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:35:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D41C11FFA6; Thu, 17 Oct 2019 14:16:17 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 20/54] cpu: hook plugin vcpu events Date: Thu, 17 Oct 2019 14:15:41 +0100 Message-Id: <20191017131615.19660-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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::444 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: Eduardo Habkost , robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , 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 Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- cpus.c | 10 ++++++++++ exec.c | 2 ++ hw/core/cpu.c | 2 ++ 3 files changed, 14 insertions(+) -- 2.20.1 diff --git a/cpus.c b/cpus.c index 367f0657c5..cdd2798c0a 100644 --- a/cpus.c +++ b/cpus.c @@ -45,6 +45,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" @@ -1254,9 +1255,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 fb0943cfed..1feda0ca76 100644 --- a/exec.c +++ b/exec.c @@ -975,6 +975,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/hw/core/cpu.c b/hw/core/cpu.c index 73b1ee34d0..db1a03c6bb 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -32,6 +32,7 @@ #include "hw/boards.h" #include "hw/qdev-properties.h" #include "trace-root.h" +#include "qemu/plugin.h" CPUInterruptHandler cpu_interrupt_handler; @@ -352,6 +353,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); }