From patchwork Wed Feb 28 11:56:51 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: 776480 Delivered-To: patch@linaro.org Received: by 2002:adf:e94d:0:b0:33d:f458:43ce with SMTP id m13csp254822wrn; Wed, 28 Feb 2024 04:06:33 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWLDyO3lhDUkavVX3xu9gaiTIz/jmPBeX0gudTp4AVYSFma+oT84AKmCWV7YIDaMYlAc44igxH1haLM7cVLxRmq X-Google-Smtp-Source: AGHT+IF49wEGNu59k50usQCYnhYpaxJ7c/gyfqvjV2GDuM2KiJmMJtnVyhxs/WUWu42Fp/fsNXmW X-Received: by 2002:a05:6358:726:b0:17b:c1e6:c4de with SMTP id e38-20020a056358072600b0017bc1e6c4demr3165584rwj.14.1709121993472; Wed, 28 Feb 2024 04:06:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709121993; cv=none; d=google.com; s=arc-20160816; b=sCBCeC1qrYCtkpUhbc2blbW0tPaCAKHtSYWZPEQQWbYk4Or6YJiCuIv6AT/sr+y+TE bHWIqMOh+mDKUm1YjIiccKgVfIkFvgJecvHQ12307XzNOJ6nF1rAF8YU7Ma4hk4tGwTh Nmq011Rs/zxLluXCc8tZeb65hE/QkR9ntxP03ilohkslM8ZiaaljVjS2eZ8iV0pZJf2p hyzeg6EjaVix9AsEfInuCKsXr4VtX/6cGafkeKqYhg5t2YUzyFuRFum7h6x/YqwflsmJ URVWo90T8LP59rINO4jpduUQFULNjizwwNjjqz0UluDlED19Hckp9MYYKEPHmF4R+ITh Fb6g== 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=p+CwTreRkCfrSZnPVcfTsMUgX3CVXEY/vFHik/E/mjA=; fh=Z10CJok2AG8ZQlEfwg3IWupzqdA1R4wHf1sF/OcGomk=; b=ggar1Fp9w670I7waHaTpXjzuijFq0qkrH1HoifoEe9hxjsuId87dtVnSEuiyKj7qZn Fgc1lr9YBomKYch0AsFtMYj0Lncl0if2X1K8oJ0VeanJ6hAXRFjekXJANrKRVtkMDZJa v7O7crac1QhVCqeyh5SfVf1cr66TAVSrbFLZZIxjXTU8lrljtps4SByp/R4/+WBUa0fh yYMqG2is5a69vOydZbUgbS5aYb57zWVXnUIcAe/eIxiqE0N+r57XlJnfjILeK1YPbumu zIxW+sbTGql+2EwjpDmSD+NFwP3wWAwhUFN99/XquDuwb6AFGgFeKMNpu/4qevYrxmaU nWYg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E6HXij9p; 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 gw13-20020a0562140f0d00b0068f85ca0a1asi9372830qvb.231.2024.02.28.04.06.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Feb 2024 04:06:33 -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=E6HXij9p; 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 1rfIea-0005Km-D9; Wed, 28 Feb 2024 07:03:16 -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 1rfIeR-0004qn-MU for qemu-devel@nongnu.org; Wed, 28 Feb 2024 07:03:09 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rfIeP-000368-5B for qemu-devel@nongnu.org; Wed, 28 Feb 2024 07:03:07 -0500 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-33de64c91abso1498901f8f.1 for ; Wed, 28 Feb 2024 04:03:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709121783; x=1709726583; 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=p+CwTreRkCfrSZnPVcfTsMUgX3CVXEY/vFHik/E/mjA=; b=E6HXij9pDarR8WFjK7MfS2Ma8Lwak6J7kuk1KhJK9L4xrwj8K+6/xiF6ofPUYIveLM cdoV4p7xKKZRvS3OG2p5EZBbQ2uHUAAr0H5j7OwpNkHly4wKMw0EYMzAV/DpP0U/Qggf WwF4kO2VF1YO+nFop3VmIrqf3ittMgrrZnfL+f+2gStjIL/fNzxH0ZMU2AVA8HE8yH8O isf/5HiEJB36PI3Wmn0IekRV4bW/E0NsZRDjOV3tjRRRqHSvGJEcHSBUeFxlpc9EXiCi H83A+6TqYAp31iKcyMehcMX4R5ycf499JkT6UHxFJCXg7xWeufcf6Gmj8fmGbA7xqMqJ sRYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709121783; x=1709726583; 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=p+CwTreRkCfrSZnPVcfTsMUgX3CVXEY/vFHik/E/mjA=; b=vQImUcCoD2l/4RwgR1G4Lco0ejt80ESauCZRChzlyvEgWWsk+FBhHN49fSpiM2OdKq DskdBzxo14XV9P46m/+K4k9mPpgx1FWYRxKmTLym9sLHfd3K/IGMJLMHb4JlGQ0MZxEz ob7Prp7g3vLHgZ1uNX4WRt13y19iD0Uee7+ajDr1yLQckPDL8Tz+U+pEndiTJbsTjRPU 3dNTR7tUG5pLCfcAr2pmjx8EhbDhApM60FEHWDNBVhJchw8bat3+pQFjx65cJ31W5DXv zHqZ+Vsk1qGBkpoOMqzk1lNM/+07nieRIUQTsk1O9WLLVVXE3U2qAQc++UdQmweqEXdu Jn6g== X-Gm-Message-State: AOJu0Yy0CZPml2oIdoTFeKNl+iu9HueV5se4BpcRqu0zNIJj9eikFEuZ HVjaThbnvwxl7hkbVeTZ9G8WZ59wxOMpk8TUrSAYq36lR42eX8wYqg6O/vtwnnQ= X-Received: by 2002:a5d:6649:0:b0:33d:aa78:ed82 with SMTP id f9-20020a5d6649000000b0033daa78ed82mr9214879wrw.34.1709121783637; Wed, 28 Feb 2024 04:03:03 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a10-20020a5d4d4a000000b0033d13530134sm14173688wru.106.2024.02.28.04.02.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 04:02:59 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C5A4D5F923; Wed, 28 Feb 2024 11:57:03 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang Subject: [PULL 19/29] cpu: call plugin init hook asynchronously Date: Wed, 28 Feb 2024 11:56:51 +0000 Message-Id: <20240228115701.1416107-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240228115701.1416107-1-alex.bennee@linaro.org> References: <20240228115701.1416107-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x430.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 Message-Id: <20240227144335.1196131-20-alex.bennee@linaro.org> 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 */