From patchwork Wed Feb 26 14:03:41 2025 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: 868517 Delivered-To: patch@linaro.org Received: by 2002:a5d:5f56:0:b0:38f:210b:807b with SMTP id cm22csp816473wrb; Wed, 26 Feb 2025 06:05:40 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVWolSwsaJ9gy1OphoKg3NMdyt5aPDilBG0NIRoudGQSGZijagni/VylusMukz/8Z2RXxjzwg==@linaro.org X-Google-Smtp-Source: AGHT+IFWO+ciNWg5E1RnTQIAcNVdi+V6wLOwrv3BpYYJVj2GJgJbVq2vebXYSCa14J/Uy1HVzFvP X-Received: by 2002:a05:6102:2b85:b0:4bb:e6bc:e164 with SMTP id ada2fe7eead31-4c00ae76dd5mr4883656137.25.1740578739979; Wed, 26 Feb 2025 06:05:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1740578739; cv=none; d=google.com; s=arc-20240605; b=fcyx8xc0YeMRpIZpZhK/UkmVYdKJ7BJ9IatJQR9Zhk1BbMQaBvS+MvY6T7uGELSvi2 KvX2zPaxqAhdW7p28TuhKWXK8VGn/ILutNGilzs+HXxvR4lBQwDlFMsC2vmWdduvTvi/ nsIYZ+znqT+jnbfy6ykG3PODtnTHjHwStjkAW0eDh/USNeVZRqmfsSnp3PSnQf3vMWlo kPU5KFXI9Eyp42lrwNOFmUlBEU7+1V25sBoovjhH+QyG0DJtJPi9rk53Cp2p59zGWnYB ZtmSry2dObbral70/ju/EFsucMY4lLXsZZLrtJs7sb496m8DsNyU/IrqyDI+Chf3HGBh 3lyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=j3uOOlAeKCJac1lfZ8pMilX54y2FsqgRLkG3Q0WCNcI=; fh=fySNGfDYHed5hYuWeyYWBmz9AHLCfB1G33J0dTYFdV4=; b=W+UvLDT42EfpAlsRJ+dy+VZPbjm82xIefcqnKJt0A7kTfP0XaFxyMISsSjLVBL6hrA bMIxrwkYod1syTe1NYXFy/6TDF0Zcs8frMS+qqh8wWf9aO/f+4LaqrSdMS6h0Kdkbnx8 T+uZ7oTkxqu7Dur6ReVVq06c9WYJdCxXZmxJqc1hsDRuc8ctHW3jgaf0cDcBm2JxfLCG IPoAoWGbEENKQMk6GT8z2HMwI3maj7k5B6+IIUD20G7H5gZUq4XxMZlK9iVymeFrIV7S hHbME8QKtvP/JZkX5u74g6bHpSIDwhizq4LJtQSs8zo99q6AdY4MYVM25MXvfbv+w+a5 k5/Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ntEWogRF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4c00c74b9e9si734925137.572.2025.02.26.06.05.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Feb 2025 06:05:39 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b=ntEWogRF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tnI1z-00025D-OO; Wed, 26 Feb 2025 09:04:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnI1M-0001Dq-6q for qemu-devel@nongnu.org; Wed, 26 Feb 2025 09:04:23 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tnI1F-0005qZ-EE for qemu-devel@nongnu.org; Wed, 26 Feb 2025 09:04:17 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-43989226283so47091945e9.1 for ; Wed, 26 Feb 2025 06:04:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1740578649; x=1741183449; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j3uOOlAeKCJac1lfZ8pMilX54y2FsqgRLkG3Q0WCNcI=; b=ntEWogRFVmn8tSKvkSTwriYCHQoGwBbtQzk+XS5r/ADe5EhM0rYB2KPP30wy7HFUfi 2Xc6zqEiILcnbIzKy3koyTBB6oWWpDy7DlW1ePlKuNiGWSahAUzK6bqpdtb5WfBi+Gtc r7dPzSthYkjvnlzu8yETZouhoR5xTiOqgrS9phyJQQwjv6j259MUbqXz2ygCITFCSpJH te7dKkDq1+ldhfJ9qpjBS+ea0vHN6+QAexBTJPdUeFmORlfTnAJgOTeREabK821BZL9Z tmX3mzN01gtgRRqUmApCJrEYWTPJ1OOJmBGKwhQ6NRAGfHo173lFoBuyI6gL28fgmwVW xOzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740578649; x=1741183449; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j3uOOlAeKCJac1lfZ8pMilX54y2FsqgRLkG3Q0WCNcI=; b=ZuhbjRKyFtDElhn2I98H2GyT9vw/Ycu3BVwab7U803LQpWMt6USSz0JziovDpToiQS HPo5PESgMCYX3agLYKnXZIY673C6w+RDcvtfTLrkZNc3baEAj9rWGVxzKDibkBUd5rWB jmSYjq+Yvglzxsm7Ox2uPawwQKFM5OQ9tJakwUSjfWL/1D+3Sjp0KkVWvllXl7B442uU mYwfAaRncywj1jsZoDxlrTvlx982fFUC8yzTux1B+JoYMHZF7iF7qu0/hLoNhnxzvp4b P2UdIxmBwi+Ef7r4kfsRGCETOZY0Irk21/qCnqu/NFrbTU0ffiKdq/p19Rd+6+87QtpW 0epw== X-Gm-Message-State: AOJu0YwS30gIXf4ptE2B49FmPYaoMEoDdtYXvXpSU7FQFOutpXz28ycK QQIEP2DTE8B3G/7AGO+Q8a3UcLnrLPgkOGzKVdXEMLGtq281mtKQRmdJvZlL8DQ= X-Gm-Gg: ASbGncscWhWnsDS0d4JbAi9jp26fv6hqxIT2zWanQbH6b8h2423cNRufvCInHmFwUlU yvrVgoBEiUHJxvRm+CQD78bOZGFl2r5KpwMAwKkyqhvf8VCSckNiaUt67NY9TZPZ9DN25HoaHn+ xnhYUBkH7ZU1rGICtvo/hmNKvz7RyCScSoCiytS1fUFpyXIxxPMcbc1dSSPhMC3rh/qxr2RUMuc ztUuhFVih22Lz9z9Bv5G38kqecz7jBNUTl1TaFciYnwevp2mYWZgmVdA9FGBnyYZL+hbhodHCSY nyXAYEXNR6V0KTYaztM6gZIDrwsa X-Received: by 2002:a5d:5849:0:b0:390:df7f:c20a with SMTP id ffacd0b85a97d-390df7fc33bmr583361f8f.33.1740578648457; Wed, 26 Feb 2025 06:04:08 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-390dfab57b9sm371164f8f.68.2025.02.26.06.03.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Feb 2025 06:04:07 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 36ECE601A1; Wed, 26 Feb 2025 14:03:46 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Peter Maydell , Kyle Evans , Eduardo Habkost , Alexandre Iooss , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Laurent Vivier , Mahmoud Mandour , Paolo Bonzini , Li-Wen Hsu , Riku Voipio , =?utf-8?q?Alex_Benn=C3=A9e?= , Warner Losh , Pierrick Bouvier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Ed Maste , Thomas Huth Subject: [PATCH 23/25] plugins/api: split out time control helpers Date: Wed, 26 Feb 2025 14:03:41 +0000 Message-Id: <20250226140343.3907080-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250226140343.3907080-1-alex.bennee@linaro.org> References: <20250226140343.3907080-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These are only usable in system mode where we control the timer. For user-mode make them NOPs. Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20250225110844.3296991-10-alex.bennee@linaro.org> --- plugins/api-system.c | 34 ++++++++++++++++++++++++++++++++++ plugins/api-user.c | 17 +++++++++++++++++ plugins/api.c | 41 ----------------------------------------- 3 files changed, 51 insertions(+), 41 deletions(-) diff --git a/plugins/api-system.c b/plugins/api-system.c index 38560de342..cc190b167e 100644 --- a/plugins/api-system.c +++ b/plugins/api-system.c @@ -95,3 +95,37 @@ const char *qemu_plugin_hwaddr_device_name(const struct qemu_plugin_hwaddr *h) return g_intern_static_string("RAM"); } } + +/* + * Time control + */ +static bool has_control; +static Error *migration_blocker; + +const void *qemu_plugin_request_time_control(void) +{ + if (!has_control) { + has_control = true; + error_setg(&migration_blocker, + "TCG plugin time control does not support migration"); + migrate_add_blocker(&migration_blocker, NULL); + return &has_control; + } + return NULL; +} + +static void advance_virtual_time__async(CPUState *cpu, run_on_cpu_data data) +{ + int64_t new_time = data.host_ulong; + qemu_clock_advance_virtual_time(new_time); +} + +void qemu_plugin_update_ns(const void *handle, int64_t new_time) +{ + if (handle == &has_control) { + /* Need to execute out of cpu_exec, so bql can be locked. */ + async_run_on_cpu(current_cpu, + advance_virtual_time__async, + RUN_ON_CPU_HOST_ULONG(new_time)); + } +} diff --git a/plugins/api-user.c b/plugins/api-user.c index 867b420339..28704a89e8 100644 --- a/plugins/api-user.c +++ b/plugins/api-user.c @@ -12,6 +12,7 @@ #include "qemu/osdep.h" #include "qemu/plugin.h" +#include "exec/log.h" /* * Virtual Memory queries - these are all NOPs for user-mode which @@ -38,3 +39,19 @@ const char *qemu_plugin_hwaddr_device_name(const struct qemu_plugin_hwaddr *h) { return g_intern_static_string("Invalid"); } + +/* + * Time control - for user mode the only real time is wall clock time + * so realistically all you can do in user mode is slow down execution + * which doesn't require the ability to mess with the clock. + */ + +const void *qemu_plugin_request_time_control(void) +{ + return NULL; +} + +void qemu_plugin_update_ns(const void *handle, int64_t new_time) +{ + qemu_log_mask(LOG_UNIMP, "user-mode can't control time"); +} diff --git a/plugins/api.c b/plugins/api.c index 82241699a5..832bf6ee5e 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -526,44 +526,3 @@ uint64_t qemu_plugin_u64_sum(qemu_plugin_u64 entry) return total; } -/* - * Time control - */ -static bool has_control; -#ifdef CONFIG_SOFTMMU -static Error *migration_blocker; -#endif - -const void *qemu_plugin_request_time_control(void) -{ - if (!has_control) { - has_control = true; -#ifdef CONFIG_SOFTMMU - error_setg(&migration_blocker, - "TCG plugin time control does not support migration"); - migrate_add_blocker(&migration_blocker, NULL); -#endif - return &has_control; - } - return NULL; -} - -#ifdef CONFIG_SOFTMMU -static void advance_virtual_time__async(CPUState *cpu, run_on_cpu_data data) -{ - int64_t new_time = data.host_ulong; - qemu_clock_advance_virtual_time(new_time); -} -#endif - -void qemu_plugin_update_ns(const void *handle, int64_t new_time) -{ -#ifdef CONFIG_SOFTMMU - if (handle == &has_control) { - /* Need to execute out of cpu_exec, so bql can be locked. */ - async_run_on_cpu(current_cpu, - advance_virtual_time__async, - RUN_ON_CPU_HOST_ULONG(new_time)); - } -#endif -}