From patchwork Mon Feb 26 16:56:36 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: 775896 Delivered-To: patch@linaro.org Received: by 2002:ab3:621a:0:b0:258:3251:9e33 with SMTP id w26csp1479362lte; Mon, 26 Feb 2024 09:06:01 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWJfJqdIgXzG2BouxqBJukT5agPnh18ILi8YxG6Vgrkhfqs7YWoyv/hD9jWJSSZ2L6coeVryGndEkYEPL8VZoR/ X-Google-Smtp-Source: AGHT+IH/E0vlohBWoUvVJGA+VagQfpk7OV6qX/RNJSGCAe3U8/kOEPciEx4Oe68+/N9NKhK/qTKX X-Received: by 2002:a05:622a:30e:b0:42e:8b8b:8cb6 with SMTP id q14-20020a05622a030e00b0042e8b8b8cb6mr3116198qtw.13.1708967161370; Mon, 26 Feb 2024 09:06:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708967161; cv=none; d=google.com; s=arc-20160816; b=Zrbyym36rdJ6hjEwnQI/pSXYd7+7vzUFKQvjmCPmV7m0zMTS3GotHvzrU1WcBKAHXp Ck2GBM2+L1haZBFgMnNzQWxXLrzrKaaJ6EFQrfAdqrfi34YBH3WeCnA7XMbiA59fNTSl n2U6Z2aAhlpN9q2HcQs2jBSnsecRoVKtckiElVnuEB5KqoYHV6NtObW9fby2mhpuAw8l EHv4cPCmzcOhsdyUZ0lUZVDxubWDfZIwarWUen+TxMZOy9o0c8fUCvlHtRmvXjNu4OUk AbGmJ/CHm1+jqhYoyQGF9soHW8QVpp3Zb4TZHE7IYCH0m/CSoZXzSJr7uydhpdE9xq2u G3tg== 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=FlRWjczXzB3kjfNm0MZCBQ0e7zrqTwZz0mkKu1n+VQY=; b=Z7rTEoUKX5muFJAU1FN3YXiaocUy9R83SHv7rJbzIK1ZY862AHpIdDyTKLYSXK032k OKJ/0bfp8BOsTEuwA3tOwZn0O4mwGMlEo0V2E6ePLbtZK+eZ8yxp5p+3BEu8Kw/MLRS4 yBbig3OBs3C5DN2cMef1J787EYKyge8WaF4bMTrslJ7oy2eccEZ51LQXRzg9GsIszUM2 TLjL+GN4rRH6YLYzKnEzkCaMF3cGf2vjbk1Ji43k+2zC7vbJ07HGwYBslj7RVT4hXznV c0Za2MtV9CDh4sT4FU/sAUZQ3HMFDsyGSY1IQvC1vHgnlQ9aCayYY37GYnh4qLeSWSay 2JOQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qmJz8EAG; 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 c40-20020a05620a26a800b00787ddbf3461si925443qkp.481.2024.02.26.09.06.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Feb 2024 09:06:01 -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=qmJz8EAG; 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 1reeP3-0006m0-Ve; Mon, 26 Feb 2024 12:04:34 -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 1reeNb-0004Oy-9m for qemu-devel@nongnu.org; Mon, 26 Feb 2024 12:03:06 -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 1reeNN-0000ox-7J for qemu-devel@nongnu.org; Mon, 26 Feb 2024 12:03:02 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-412a87d5afcso4630105e9.3 for ; Mon, 26 Feb 2024 09:02:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708966967; x=1709571767; 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=qmJz8EAGLMrBpzzQlJde6dLRWZ6ui1KEKPPHyao4R6dgtPXibDIqfWQTSr1JTa1/8c LLcbcpGFWet8a5gQqaQUHGi9Z3EAjrSV49vAzMIcNQTJaQ/4cY8rT+ahE0SP+J72k2sf ge70sp76cWoldmeBNUwZSkQGfEIW8VEtBuXNM/M6kGkQV+Trc/rkTgsAK1we0QrP/DUK xP6hUbclfJM+YaKqNEYGPAnaJgADWO0oVka650sDf8AU00kaHtSSUce3sBAJ8RfSCi4g sz1eI69JGKsB5q0EYg3CfwntADNoL1ti1V1ru4Y7w5oVVeP2w4bAjwmk+PFmdeDAqtyS x+aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708966967; x=1709571767; 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=eX2fgw9gJOsGt/gxmIefEzGZYbsXXv++fPlmRA5urMCPWaxsc325KxAQMMpyxlhefP GX/wWY3IHRxxpBMwEwb7+/C7pj7Jt5xa/wahMMDBe1eM3b+a/n22ROJfUN9+ycew5lw4 ojyj+A7O3xNyJwR4JWNmfPRbfeLK56wiYR1r4bUN/DvjYLtJdbGOPf+G0GkX1yUrj7g0 ueHK1NuMW2CNWVfJXiqiqovBzXMu+t/MLywteaRzdVnyS46EmliO1dMWFuR1+G/XBgpa tOwkxrMPSyb5RYmOjq1+he9Mne+yRy5rFNDTS32K3J2/hGe1Qn5OyVGktS8KYpsvSCsY +esQ== X-Gm-Message-State: AOJu0YyNChQVs1o+TPZ8NByQl9InqOnYYpwgUk4GfyLy7zQ3IEngA71n vSx+0tLTUc465TXC7k8DSd8rlPaqa89wxA9JYFLXpVb/dNsxhQXe2a4qsiUAnQaiGKq8eYLbbXX v X-Received: by 2002:adf:f78d:0:b0:33d:1656:21fa with SMTP id q13-20020adff78d000000b0033d165621famr6367990wrp.24.1708966967537; Mon, 26 Feb 2024 09:02:47 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id k2-20020a5d6d42000000b0033b79d385f6sm8712423wri.47.2024.02.26.09.02.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:02:45 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 6E8165F92A; Mon, 26 Feb 2024 16:56:48 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Nicholas Piggin , Liu Zhiwei , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-riscv@nongnu.org, Michael Rolnik , Song Gao , Alexandre Iooss , Marcel Apfelbaum , David Hildenbrand , Pierrick Bouvier , John Snow , Eduardo Habkost , Mahmoud Mandour , qemu-arm@nongnu.org, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Cleber Rosa , qemu-ppc@nongnu.org, Richard Henderson , qemu-s390x@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Yoshinori Sato , Yanan Wang , Brian Cain , Ilya Leoshkevich , Weiwei Li , "Edgar E. Iglesias" , Bin Meng , Laurent Vivier , Palmer Dabbelt , Daniel Henrique Barboza , Alistair Francis Subject: [PATCH v3 17/27] cpu: call plugin init hook asynchronously Date: Mon, 26 Feb 2024 16:56:36 +0000 Message-Id: <20240226165646.425600-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240226165646.425600-1-alex.bennee@linaro.org> References: <20240226165646.425600-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=unavailable 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 */