From patchwork Wed Mar 13 10:55:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 780026 Delivered-To: patch@linaro.org Received: by 2002:adf:f741:0:b0:33e:7753:30bd with SMTP id z1csp112577wrp; Wed, 13 Mar 2024 03:56:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXUndYHQV3v9fVJQZuuPwKJmRAcqfxWh7KHiqGvk6RPNcMhJfzvNi/jXORSp7kMmcJjrK06ou0M86iEe6UzAWoN X-Google-Smtp-Source: AGHT+IEXzcFLJ6erxApeazFZEmsWJ1fIKpFpiNDjIoHyuSLW2rcwLC2IOfr7VV2ndTLQWqsNvpAp X-Received: by 2002:ac8:5f53:0:b0:42f:208b:cb0d with SMTP id y19-20020ac85f53000000b0042f208bcb0dmr15815030qta.50.1710327378269; Wed, 13 Mar 2024 03:56:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710327378; cv=none; d=google.com; s=arc-20160816; b=iPTnm07+TPG4typXfc6D5WSEs5XcfhuUCXVaLdHVp5+aDY/cCR/9GVbe0xLnCvmm78 HDBaa8FgnDQEC45FbpcvztKYwgXu5L8O272pSKu5DKuh4sB8NMd+Mbgsnd87qIEg320S Y56DEBLZ7SrQrmpJH2X3l1RC4mdM+XCgLCa9hixz90qggU+do+/i2j2Wlb7Rna1aHMhJ Rqf39OLhd0dXzEZtdLbT+cKiGE640k7Im+17OjYMtazQYLHB69WUAzkTXhjF45sqJGWy zTHA1AS6X4EqN0KuXH1IKQcSXtByVrY1jU9XQ2P776elbfftapVYmqxHKcvnIJRqa5lE /Dyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=2A4y2sEoIfQRif0BIyFTxg0vj8eN3cypCY900sTp17U=; fh=SOx5jGRISimNYto+GAJnnbqozdA4y+bYXtSuueN6vdQ=; b=uY9/jRkRRkMLvKVKYvtjwshzxcpWCMF9mLWvxV66SKKroqpqvjZj8j23fngPypaA5U PI0ofPUh8yqmJ1k+dFroLKsNUGGXsUuTG/bpH1QnIQ5kxDQ8QNoIqhqz2uUcRR4+2hOS qsI1gxUjlORghTiOyxmTC8/8e0sJIoBojHB3dqBQ5esc8J0c1Ett43f80+1qch0InRVd Oj8KJJGuYNyAYGmm/tJgYB+f9O71uRpgJC6p7GVRQhtv+CE0Q/HmycJKVTIx4UZyMHGy JAeCi6JinA/Mm9sgQkhDZGoEZFODSSLcIgAFNw0iVXSfHLnw529mt0h8r7HgZA4+xkoT SLcQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HTXeTRGS; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b16-20020a05620a127000b00788584df56fsi9447257qkl.173.2024.03.13.03.56.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Mar 2024 03:56:18 -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=pass header.i=@linaro.org header.s=google header.b=HTXeTRGS; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkMH1-0005Nc-A4; Wed, 13 Mar 2024 06:55:51 -0400 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 1rkMGs-0005Fy-Id for qemu-devel@nongnu.org; Wed, 13 Mar 2024 06:55:46 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rkMGe-00079b-5L for qemu-devel@nongnu.org; Wed, 13 Mar 2024 06:55:40 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-413e7b96403so3864095e9.3 for ; Wed, 13 Mar 2024 03:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710327324; x=1710932124; 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=2A4y2sEoIfQRif0BIyFTxg0vj8eN3cypCY900sTp17U=; b=HTXeTRGSsRV0o18Homys9BVeMWwuwI0EZrS+bEb85KxUCpdOOHI679UVO8YRyL/g2h O1Rz8z0h5UsWZvuN+QNNtPeW67lARBSEE4/zWOK7NPj/1/tjy5ZFUJzBwZZdSfor8Pf6 dwn6WM3NkTZus9Gl0Sda9KQVa/hzutd27+vY++uAB1e909AqtKd2SonDwuHt/kTOVVxH RuovVmpvLda/356V2NIt2StY+zcU+DfiM1l8HONOo+BKZWGzdzL9VtJFE/fg0InroX+E fGGMAA3BPW6LMKnA9lU2jBuzTNndh91RUvE7QVtCmehX5JAN/dAPFu2rpt9S298/tDtR C+rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710327324; x=1710932124; 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=2A4y2sEoIfQRif0BIyFTxg0vj8eN3cypCY900sTp17U=; b=RRt2fWTxx+8We8ip9rf2o9q2v1GI8FKJBWHZ86pvKdjtrCjOOv5t773Z+Iw/1QPmkJ boHw9m1Oa4+paS6K42KijG4BK+k9/7EvPAuDR2SIud3eIrMztJdkRq6zZOIlC+YWms8a Bfa++5s/kQv4jTD1hGfMYuItyOAr0cZE1PPJofaUbsT8dVWPNh2tMaC4stkRqN9/uLZ7 cbtUPgdXYOKZxJjEYpgGigBv0kTpv+N4f8aABo1tuTGPP9WBDCD3DhHXQLuIat+B5b+P YaFLzICyEh6DGihF73g/6oFd+UKutga+ASFv8Dbw9hTUkC10BD69BWWbD1Fek/GiP2Zw WvYw== X-Gm-Message-State: AOJu0Yz0kDG3YK+uCxRKTLeNDld/WG37rYl15l0j/I8AIUiLjCPcIKqo AJU/wO4xvEzkLs8SbVbiQFiOTPF8rUur1XktvshD8UzZ1xrh3a8PzYVosJ2vVYqBXGG7hg+BCrx n22M= X-Received: by 2002:a05:600c:1e29:b0:413:32ff:2000 with SMTP id ay41-20020a05600c1e2900b0041332ff2000mr3764796wmb.36.1710327324258; Wed, 13 Mar 2024 03:55:24 -0700 (PDT) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id w17-20020adfee51000000b0033e1be7f3d8sm11390338wro.70.2024.03.13.03.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 03:55:24 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Alexandre Iooss , Richard Henderson , Laurent Vivier , Thomas Huth , Pierrick Bouvier , Mahmoud Mandour , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [RFC PATCH 2/5] qtest: use cpu interface in qtest_clock_warp Date: Wed, 13 Mar 2024 14:55:01 +0400 Message-Id: <20240313105504.341875-3-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313105504.341875-1-pierrick.bouvier@linaro.org> References: <20240313105504.341875-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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 From: Alex Bennée This generalises the qtest_clock_warp code to use the AccelOps handlers for updating its own sense of time. This will make the next patch which moves the warp code closer to pure code motion. Signed-off-by: Alex Bennée Acked-by: Thomas Huth --- include/sysemu/qtest.h | 1 + accel/qtest/qtest.c | 1 + system/qtest.c | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/sysemu/qtest.h b/include/sysemu/qtest.h index b5d5fd34637..45f3b7e1df5 100644 --- a/include/sysemu/qtest.h +++ b/include/sysemu/qtest.h @@ -36,6 +36,7 @@ void qtest_server_set_send_handler(void (*send)(void *, const char *), void qtest_server_inproc_recv(void *opaque, const char *buf); int64_t qtest_get_virtual_clock(void); +void qtest_set_virtual_clock(int64_t count); #endif #endif diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c index f6056ac8361..53182e6c2ae 100644 --- a/accel/qtest/qtest.c +++ b/accel/qtest/qtest.c @@ -52,6 +52,7 @@ static void qtest_accel_ops_class_init(ObjectClass *oc, void *data) ops->create_vcpu_thread = dummy_start_vcpu_thread; ops->get_virtual_clock = qtest_get_virtual_clock; + ops->set_virtual_clock = qtest_set_virtual_clock; }; static const TypeInfo qtest_accel_ops_type = { diff --git a/system/qtest.c b/system/qtest.c index 6da58b3874e..ee8b139e982 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -332,14 +332,14 @@ int64_t qtest_get_virtual_clock(void) return qatomic_read_i64(&qtest_clock_counter); } -static void qtest_set_virtual_clock(int64_t count) +void qtest_set_virtual_clock(int64_t count) { qatomic_set_i64(&qtest_clock_counter, count); } static void qtest_clock_warp(int64_t dest) { - int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + int64_t clock = cpus_get_virtual_clock(); AioContext *aio_context; assert(qtest_enabled()); aio_context = qemu_get_aio_context(); @@ -348,7 +348,7 @@ static void qtest_clock_warp(int64_t dest) QEMU_TIMER_ATTR_ALL); int64_t warp = qemu_soonest_timeout(dest - clock, deadline); - qtest_set_virtual_clock(qtest_get_virtual_clock() + warp); + cpus_set_virtual_clock(cpus_get_virtual_clock() + warp); qemu_clock_run_timers(QEMU_CLOCK_VIRTUAL); timerlist_run_timers(aio_context->tlg.tl[QEMU_CLOCK_VIRTUAL]);