From patchwork Fri Feb 23 16:21:52 2024 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: 775150 Delivered-To: patch@linaro.org Received: by 2002:adf:a356:0:b0:33b:4db1:f5b3 with SMTP id d22csp437989wrb; Fri, 23 Feb 2024 08:44:38 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUQnEVf8tlkYu4xApfLQ0BJdPITsKeuEbZ0L7yYIzu5da9ldInsogojk6/1PD8k/LBPusbOKxNE6UPQR0n74oLd X-Google-Smtp-Source: AGHT+IG2zY9xVkt9jhZbpTK1nndzs9dX58ehfTPknwwwGWgA1nKKraWKbkjU27ZO5p7h0IXMdi5y X-Received: by 2002:a05:622a:1744:b0:42e:696:2023 with SMTP id l4-20020a05622a174400b0042e06962023mr364006qtk.61.1708706678577; Fri, 23 Feb 2024 08:44:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708706678; cv=none; d=google.com; s=arc-20160816; b=P4RBXSfonXaAfj5xMFtslsP9Kn7TsZ3gsHZ/brKJrk9cXa1MkUKbj6REkgt9+tBLXW 4jINjlrngjZD4QNRgmioOU3h1AC+zOOKtkq1DmSsuXmw7rGM9xe2gUJ6+hkGhtUAtOAn UG/nztJPw27wegsOTaELtViRi0d03Xc23HeWdP7t4T9bUJ/AcBglQ0Y6kkuQdS0yDnkv Id2KNP7dXACYgOq8jT541XhNiOa2e5m9WS34EF5KloQZkWFc0XmZwNE1h5G2s4yqRP4r YpZU1CF+alvu65GsqR1CClfMprPhXR1v3Pj4qLj5B7bGuUW+QvrTXytC83FZnZXCFDgl 3qBg== 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=LY87PsqI5CseL6bunSV/a+wwJBYv7wofoTM3s0oA7jk=; fh=/YEu+IjZM84YWRDAuPeJeqMoLNTdSzM/iYv/jybOCWk=; b=fNDHfyh1/DOhf2TdPB78bgJSi3syfBkAS7usob4+WwXE+AowHLt7FVNxaThsxXpbxb FNOPwA+xPRzHPMD7T2ICNP/MiuHzOSKPhOFbL7NYIpYkSYKWL5mGEfjL0r1mBMhYZxkH rHFmw0d/WkZUAP/Rz+GUQHQGw83uidAmvdzB1JrTXw11H7J9qMA23ODfWC4O6zfPyorh QSZEgr9AduMOlKnCS0qYgYRuweQoHA5CzgqAKEDDkBEtdYyRFWCir4IP2Z8B+Ectp8G0 FVBYLoyoqB025ZPgZhvbeppTsMXVIYQFb6DkgMzk3cNzJakIoQj43Z2f/yBWuAfR4nCA kSZQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b4taVSx3; 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 8-20020ac85948000000b0042c1dd7b657si16374807qtz.103.2024.02.23.08.44.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Feb 2024 08:44:38 -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=b4taVSx3; 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 1rdYdN-0003mu-00; Fri, 23 Feb 2024 11:42:49 -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 1rdYK3-0004Og-GG for qemu-devel@nongnu.org; Fri, 23 Feb 2024 11:22:51 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdYJa-0006Ab-0t for qemu-devel@nongnu.org; Fri, 23 Feb 2024 11:22:51 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-41298411aefso974525e9.1 for ; Fri, 23 Feb 2024 08:22:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708705339; x=1709310139; 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=LY87PsqI5CseL6bunSV/a+wwJBYv7wofoTM3s0oA7jk=; b=b4taVSx3bMw9mGBzdThwAvQavpu0ylO00tdva45BOVxMZUawkN2tGu3L6lFov/pexD o5ZvOFg2XA29NUyjfeBioehLdyLUtTL4gG6M+2fzqI8VQtoRjF/79nWPA/k9EgGQjLE/ Q+xxhqXqKBcucdEIYbWg7nNBuCSI0Wcl8ZzlRmBO4V9QTt6o8P1OFdoAqPrDT7VLY0xb ECFeePeh8DKfOkkJxGs5bH0P9GrgmZtdg0juwojYN3HY1RWE2PDN1QIQ/WCtUViPn1LN hDrziiU5O1+QZXPsGhrawq3w7wbVDobR5eY1lZE/V3Teu/qW6uQmMQX3Ra8wnFaXtTbi pIdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708705339; x=1709310139; 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=LY87PsqI5CseL6bunSV/a+wwJBYv7wofoTM3s0oA7jk=; b=L9QnKNP0kwqhimmyBmmMtMwXEQ1GDndYlsX64UnIqQPfR7g8t/13Mb40aoosbkW/DM G6znT75QV6+4lhme06FkaOC+uVkVp+m6/QysvIN1KOntMZpqm1aVnVLUUVYlI9L0sAZn HTrInSdHE9+dMChtvFtAXVs1C/2eLOzlXTNdO9/eS3Mgskry729sRicGq3DYz0TsEqQL X7veW13yqH+2osGBqAuZ+9Hj4St+CbFr6pXYEnuvHwsI3eg+qGlLsp1YsxXGCwRcBH2p liC1ToGhGqW//QZCyei6EmMGX4Y8jCkiEF/y8ZY0XypO93EjYkFV44IqsPw/kqm3+N1e eUOQ== X-Gm-Message-State: AOJu0Yy88MIZ65bz0S8r2xlsymuq+RVDehSp9BjBfUB4BM1md8rYNcIw j+/WTeYr/wK4R25a0hkIhPU8MCZsZlJM+rBZewsrGJasdM+Fd3I4Hqjx3JCYAPg= X-Received: by 2002:a05:600c:46d0:b0:412:983c:be10 with SMTP id q16-20020a05600c46d000b00412983cbe10mr302101wmo.12.1708705339464; Fri, 23 Feb 2024 08:22:19 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id l28-20020a05600c1d1c00b0041276d96351sm3030084wms.3.2024.02.23.08.22.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 08:22:14 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 2D1255F932; Fri, 23 Feb 2024 16:22:04 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Song Gao , qemu-s390x@nongnu.org, Liu Zhiwei , Pierrick Bouvier , Thomas Huth , Daniel Henrique Barboza , Bin Meng , Yanan Wang , Laurent Vivier , qemu-ppc@nongnu.org, David Hildenbrand , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Ilya Leoshkevich , Cleber Rosa , Nicholas Piggin , Marcel Apfelbaum , Eduardo Habkost , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Alexandre Iooss , Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= , Daniel Henrique Barboza , qemu-arm@nongnu.org, qemu-riscv@nongnu.org, Palmer Dabbelt , Mahmoud Mandour , John Snow , Weiwei Li , Alistair Francis , Yoshinori Sato , Brian Cain , Paolo Bonzini , "Edgar E. Iglesias" , Michael Rolnik Subject: [PATCH v2 17/27] cpu: call plugin init hook asynchronously Date: Fri, 23 Feb 2024 16:21:52 +0000 Message-Id: <20240223162202.1936541-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223162202.1936541-1-alex.bennee@linaro.org> References: <20240223162202.1936541-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.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: Pierrick Bouvier This ensures we run during a cpu_exec, which allows to call start/end exclusive from this init hook (needed for new scoreboard API introduced later). async work is run before any tb is translated/executed, so we can guarantee plugin init will be called before any other hook. The previous change made sure that any idle/resume cb call will not be done before initializing plugin for a given vcpu. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20240213094009.150349-5-pierrick.bouvier@linaro.org> Signed-off-by: Alex Bennée --- hw/core/cpu-common.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index fe16d0d9df8..68786360ea5 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -194,6 +194,11 @@ static void cpu_common_parse_features(const char *typename, char *features, } } +static void qemu_plugin_vcpu_init__async(CPUState *cpu, run_on_cpu_data unused) +{ + qemu_plugin_vcpu_init_hook(cpu); +} + static void cpu_common_realizefn(DeviceState *dev, Error **errp) { CPUState *cpu = CPU(dev); @@ -217,9 +222,9 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp) cpu_resume(cpu); } - /* Plugin initialization must wait until the cpu is fully realized. */ + /* Plugin initialization must wait until the cpu start executing code */ if (tcg_enabled()) { - qemu_plugin_vcpu_init_hook(cpu); + async_run_on_cpu(cpu, qemu_plugin_vcpu_init__async, RUN_ON_CPU_NULL); } /* NOTE: latest generic point where the cpu is fully realized */