From patchwork Mon Oct 14 10:49:14 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: 176150 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4345267ill; Mon, 14 Oct 2019 03:57:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFIwAnyMJNNkgC60nY6jMJ4A9fG2FkuubMX+LVeqXK0JD/8Ae2KYdNUM6Gu3wWkxM5Ibq1 X-Received: by 2002:ac8:1409:: with SMTP id k9mr11012369qtj.123.1571050658847; Mon, 14 Oct 2019 03:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571050658; cv=none; d=google.com; s=arc-20160816; b=ETND6x08yZrSjWxOKzqwNvvidciLg8udPxz+Vqd/Ha29Q7PLjDI0Znk3ngP+u7SYuE OeIPYJ7wx2I7FvxpYlRh6X/tZNZ+JhtJ5bUtYET8Op+1f5q8WYFBvxFNBmBf0vzEZG3P RHx5cs8IlNFpY8GKuIKuqB+fZ1XUJGEVOEAidsXyz3DYuMfjvcDHcooYwEDuIrc2I/fT iH3C9pOtGWGD9NQ3dazSJwDUPuptB5ZyC2oxsfxueXDrl2FFWkSKs2972LVxE7FDSfGI t8pzXvKiikUsk4JYIfdqSFLWVEk7NoAEcUM7Hsu/OL/pjUVl78v9RLbFZRm4BpS+5y5M oWcw== 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=uvacSGmjYgiAWweJmrehENexJyDt68fPjc90zp076LQ=; b=UjvHWieYAqCdBHW93DyEpWKzi7c6unFLBG6RKSZa/WGJ8tKNyUV73BJ+LXvZiiMrHI 9m83ZOsojDivvqZmrwG0j59ptBiNAyscvqwxjjw4DciFyozADhjVKU9zesN8hRg0Kwcc 8MX3OL0PDZIBQMa7Z3ApfqglLOTyEtEPB2YwSbYcd2gRiCX9OloipJZJgQXG/sZFIGUO LXJkVElz2FE4kbA8E2GC8JFOEoaYFIi40lXJK+Mil6jmS8VJ2XHY7AgmriGrGObVAQ8+ l/pbBUVLco1j0kVXJL+ypt9hWTqGLJdpJHgC4FhSz5s3OqGkf6fytRIh7OAX3p1QbDFK C93A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZV4UF0qW; 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 e34si17611394qtc.268.2019.10.14.03.57.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 03:57:38 -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=ZV4UF0qW; 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]:47152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy2j-000718-TW for patch@linaro.org; Mon, 14 Oct 2019 06:57:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44713) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvV-0007YQ-2d for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvQ-0006C6-05 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:08 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:45687) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvP-0006Aj-Pm for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:03 -0400 Received: by mail-wr1-x442.google.com with SMTP id r5so19091396wrm.12 for ; Mon, 14 Oct 2019 03:50:03 -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=uvacSGmjYgiAWweJmrehENexJyDt68fPjc90zp076LQ=; b=ZV4UF0qWD7rw1Lw82K8YUQjXqUDe1AKrCsnHw50HvXWPYaQmmSaNZhtUgPXXEzlrCK JK7Mw4FcSBiyOObR3orFFGTyq6iMk3UVWfrY7EZc4R7zMYyWsWR1+0PSy5+B8+LtnNcd Gk0c63zJJA/1ImzoQ7eMSPIqp17sicz6sBVBh5QwJ8FFjJAx+NoVolZBhG4NzK0Gk14V ddoAkoZk2m/nLB0MI3LB2fAuxQgwxSoyOmnkO63z151aIdbekXuycKcXCMEimKuJ6WHP +lq40Tu4dbXiV3B2ded3RbyQXCjrT8aqAJIAarmZUpvdibVov8sHuwSBO+LZZ5Jz4Ri4 Ih9g== 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=uvacSGmjYgiAWweJmrehENexJyDt68fPjc90zp076LQ=; b=CcsxH+nF7PRmN/FX3BJ905VWQPP7sqYpj9D/24RDyI+O8kxRLxw8RhDq0XrVf+eVQR i0AnWy43lKBH1rbw3QiYrovRRCLWrgBIk+UzsJS2bBnBSzRb2Uu+frxUSHtexYE0tBcN AAydYqUp5NO6O0l5+DlUZji6HuoVd/E3QfjGp4xi+YKMUWRzpyEkAErYgmtSvYv4KZR8 pr0JH2fwwOuxgI19b/H++Ln7WdT33JeIHRh5gkbQetb8RPVedlZ7+ERwruan9G0Kg1YB r0/BRJ+3z3gsp8C+ZPNUd5n/3uk1hbepVxQuojHthr+O/L2ZGkQ2kKno70kiP1ohu8mH iz8g== X-Gm-Message-State: APjAAAVTPS6+nHBjj5VtSLZ8//vVe9wRy/8p4UJCX5CuYcUmKFuYOAh5 +3amugwSolpaOooq1PDy5zRWjg== X-Received: by 2002:a5d:6a02:: with SMTP id m2mr539987wru.120.1571050202758; Mon, 14 Oct 2019 03:50:02 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f143sm30441224wme.40.2019.10.14.03.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:59 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3099B1FFAA; Mon, 14 Oct 2019 11:49:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 21/55] cpu: hook plugin vcpu events Date: Mon, 14 Oct 2019 11:49:14 +0100 Message-Id: <20191014104948.4291-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-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::442 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 d2c61ff155..98f00ffba7 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" @@ -1255,9 +1256,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 bdcfcdff3f..7be7adb8f5 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); }