From patchwork Fri Jun 6 16:44:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 894465 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:ecd:b0:3a4:ee3f:8f15 with SMTP id ea13csp614929wrb; Fri, 6 Jun 2025 09:47:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUHSVHB174Dut1//yUw60bLY7dRnwKhmwXGcz7VivK3tA3JZfazKc+8WGu5aAEG26ZS/2X19g==@linaro.org X-Google-Smtp-Source: AGHT+IGmSWszxWw9Lzx8x77HCakVq+JRPgEy7OaWAigW5XayGP370ANGTC05LQFd+GwygceEnL91 X-Received: by 2002:a05:620a:191a:b0:7d0:984a:d1b4 with SMTP id af79cd13be357-7d22995cecbmr468613285a.17.1749228423003; Fri, 06 Jun 2025 09:47:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1749228422; cv=none; d=google.com; s=arc-20240605; b=h6JkSn0N3O2UEMgqKlMvUe/ZyE5dBEsNF+t/PBzMS7OSs6PzyCsqyrBB/7bYM/aj3h +39K+8EU99+xh5n6fUqlDCql0fI18Acakt7pCepOCIi0LDben19vHvjUmWjeM7g+BR2e rBJJKY33+2yVIyKGoFIEd3iKziRAx6mQjspsP6JBHtAira35psKb5Y9ggAOxhFXc2HFZ wLPxj8PvZOIMtgnCWpTzePC22tbcDn/V5QB5xLVJPOtkAE1mMBwnVY6p+s6yreRht1zy GhGglVxzc9Kzork3xle1/LNYHKiU8vf+D7r5E2R0MdyYJEV8JaPqhHpVa4E7UgmJfh8m xUMw== 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=UaqgBc+8IPd+F+DKqw2/dlO2PgT1d6b4+qh/jcNGS0o=; fh=t8eU813ECvXfe9r8ZA9SxVxC1Zyy8joF+mf6kT3Em/U=; b=i5ebyXLcbatYs8TOGB+8GIWlOpjsSSDb7n4LElo2UITVrIVK8fNy0CrnU/cBFuQ3xP DJFj0JfdnATQo5Pp+z3cSt+CejD8MS+yQeLmOs6jsbRnFc1kwQBCqgnlED2/LnzocUXR TzIDiEQBALv5cavfFe06N1YNGfEOEOPDLXcGnAUCJ/lKJ8UrwUaYVcrz1FVdFXPox472 Y6qYeUx2q44jU/ol8il5awwsxoHu9PVgIEitDH6G/v4hvtHWblOv7FYPAblbo2fqRK7A f8cVX+bzJ3IG2tT/3itbaY5Om08SSIxaxMtU/H9dI8UYlymyGKXRkMaU1FEJAvEL7zk9 mBtg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ztDm1INr; 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 af79cd13be357-7d24b3cb5fdsi203233285a.80.2025.06.06.09.47.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Jun 2025 09:47:02 -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=ztDm1INr; 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 1uNaCh-0005xA-V2; Fri, 06 Jun 2025 12:46:04 -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 1uNaCZ-0005YT-My for qemu-devel@nongnu.org; Fri, 06 Jun 2025 12:45:57 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uNaCX-0003RC-Ll for qemu-devel@nongnu.org; Fri, 06 Jun 2025 12:45:55 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3a522224582so1435798f8f.3 for ; Fri, 06 Jun 2025 09:45:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749228351; x=1749833151; 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=UaqgBc+8IPd+F+DKqw2/dlO2PgT1d6b4+qh/jcNGS0o=; b=ztDm1INrsjBP4xUKGJhwETQGgiILgQ5uD+cVjqufE1UqGW7May8UivU2CgGFMxT6CK iW/qCOafAJlNu7QBB9jWISRgCrAyDJOn2Vej5CZxPp1XhpUsf1xLTJNkhQWnbgdsKBFH YfpvQjfm1cmA5PIwnAfAmKyp9dOceOLUmwhXYoGsCuseHhqwTxkUjAtGdKuHkEvVTPiF brjNskbZ2DLOL/hig57eUTG6SBUAwT32HjDpK17XIdaFUbAp2sMBeM2tRszsXrnqEYVI zU/ZGeNWqOtPbe2za+To/z6lx7ZAk0e432BnnOKFK6nDKC1WZZPDxR5TAwEk8aSaPJ9w nYMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749228351; x=1749833151; 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=UaqgBc+8IPd+F+DKqw2/dlO2PgT1d6b4+qh/jcNGS0o=; b=JrCiuB2eWP6GqCechsbaAcYZkuHkvpCep3ZY1cZXlzZOPMgL0zrecPbmta5U2H0oko ftFdPHf1UZRFAloWmTJsQu0I5ORXZZjHaoneqrJ6i1ft2lz1xkSxXfJaDxWAiHclSTZX xtb+DpIch0MZ44MbQhqcdU2kls4TU8Uauds+kyxR5lOAaT/D+kAQUOGjtVNU4Elb2rNW kJ2wlX2IY9HID/3gRYbJIK3kT/CabmMyWoEhkJXFPnCCRv0frxXypbAOSjmbsn14uP68 IXokIBaC5MkR2xIBXPc8joMOoJU2vlTPFq+OOHGCZueod2Ffz0HrDgA7bKPZcumifETw mV1A== X-Gm-Message-State: AOJu0YyIFiVltjumqosUO2pNVQjt5hGMX37Z0A3JDeYtIPFd3m+GWxLM vszPXuy4HlVbGm4qQlA6wmJ/zRMfvmR56EkOt0wLpGSgmLKex9tU0NdbZ/dqCZ2zto3O5eOX3QJ RGDHAxcXydg== X-Gm-Gg: ASbGncv4dCT/yMIpa+eufhWWcDDGDOeL+2odoD56sY6GIdC0a9DDUSDMF7juRIQtUwq Ni1sw64WM9/IJ+R3PZ9h+Q/jCcMPYFZWCf39NgxlQ9H72LnO5gCuowJvxvmBNFx25TLpQvCUUvR IiLNlhrcyjGR2tLlUXx+wBulwbXa3FnmCPRx7hxW5k8L8A+l+2l4HJPVFpQ5vaRckm+rI7jrHqt 9tMBhDX3kF8gLXxnfR8xMgww4Jq3Ie1EJd42z8xonim3bczffbRWa0HcwzojUl4ElDaR50ruRHm Gdb9UycrmTzKrEfHju6U/APiier6yEGL+Rf98HENw5aPBSW+hYsORzwK1ObjItvGOCtq/L1H5Uu chW0JxhPJryh6X2ip7o8TR/+BQzGWMx1xkj6efg== X-Received: by 2002:a05:6000:2c11:b0:3a4:e393:11e2 with SMTP id ffacd0b85a97d-3a5318a9b08mr3551108f8f.34.1749228351303; Fri, 06 Jun 2025 09:45:51 -0700 (PDT) Received: from localhost.localdomain (59.red-95-127-62.dynamicip.rima-tde.net. [95.127.62.59]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a53244fd02sm2330320f8f.75.2025.06.06.09.45.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Jun 2025 09:45:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , Pierrick Bouvier Subject: [RFC PATCH 12/19] accel: Factor accel_create_vcpu_thread() out Date: Fri, 6 Jun 2025 18:44:11 +0200 Message-ID: <20250606164418.98655-13-philmd@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250606164418.98655-1-philmd@linaro.org> References: <20250606164418.98655-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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 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 Factor accel_create_vcpu_thread() out of system/cpus.c to be able to access accel/ internal definitions. Signed-off-by: Philippe Mathieu-Daudé --- include/qemu/accel.h | 2 ++ accel/accel-common.c | 20 ++++++++++++++++++++ system/cpus.c | 4 +--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/include/qemu/accel.h b/include/qemu/accel.h index 3c9aaf9523c..a351eebe567 100644 --- a/include/qemu/accel.h +++ b/include/qemu/accel.h @@ -93,6 +93,8 @@ void accel_cpu_instance_init(CPUState *cpu); bool accel_cpu_realize(AccelState *accel, CPUState *cpu, Error **errp); +void accel_create_vcpu_thread(AccelState *accel, CPUState *cpu); + /** * accel_cpu_common_realize: * @cpu: The CPU that needs to call accel-specific cpu realization. diff --git a/accel/accel-common.c b/accel/accel-common.c index 4f3b42e7112..6bd4ef47c2c 100644 --- a/accel/accel-common.c +++ b/accel/accel-common.c @@ -10,6 +10,7 @@ #include "qemu/osdep.h" #include "qemu/accel.h" #include "qemu/target-info.h" +#include "system/accel-ops.h" #include "accel/accel-cpu.h" #include "accel-internal.h" @@ -88,6 +89,25 @@ void accel_cpu_instance_init(CPUState *cpu) } } +void accel_create_vcpu_thread(AccelState *accel, CPUState *cpu) +{ + AccelClass *ac; + + if (!accel) { + accel = current_accel(); + } + ac = ACCEL_GET_CLASS(accel); + + /* accelerators all implement the AccelOpsClass */ + g_assert(ac->ops); + + if (ac->ops->create_vcpu_thread != NULL) { + ac->ops->create_vcpu_thread(cpu); + } else { + g_assert_not_reached(); + } +} + bool accel_cpu_realize(AccelState *accel, CPUState *cpu, Error **errp) { AccelClass *acc; diff --git a/system/cpus.c b/system/cpus.c index 4835e5ced48..b6dff01c7ea 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -709,9 +709,7 @@ void qemu_init_vcpu(CPUState *cpu) cpu_address_space_init(cpu, 0, "cpu-memory", cpu->memory); } - /* accelerators all implement the AccelOpsClass */ - g_assert(cpus_accel != NULL && cpus_accel->create_vcpu_thread != NULL); - cpus_accel->create_vcpu_thread(cpu); + accel_create_vcpu_thread(NULL, cpu); while (!cpu->created) { qemu_cond_wait(&qemu_cpu_cond, &bql);