From patchwork Thu Jan 23 23:44:14 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: 859418 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:18c8:b0:385:e875:8a9e with SMTP id w8csp532609wrq; Thu, 23 Jan 2025 15:49:16 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVvmfN2exdZmT2g/8NrP+bfZ83GgbF3kcLjvr+hATEb8s7cnRxLALZ4xXt2mmoz9i+HIMi/vw==@linaro.org X-Google-Smtp-Source: AGHT+IFY2ffC6ZvJOseK50j7Ohuw/Dg0oKTffpr1KJdt9TCVrU4CBcjl5Ky24eBvs4PiO8afoFmp X-Received: by 2002:a05:622a:549:b0:467:86a9:f7d4 with SMTP id d75a77b69052e-46e12a55d3dmr448522791cf.16.1737676156408; Thu, 23 Jan 2025 15:49:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1737676156; cv=none; d=google.com; s=arc-20240605; b=IOlNAxOgkQwPTZ/HL342mJ3lbztTr2GZmdj9vxP5EyxEMx0eEUtzum98k/m23wKgj5 OhgK1KMfmDpcYd2XD/bgS4cxt2OjsuJf60w9doWRBYmOUrUqN1hAH8Hvfdb/fx09+MwK T6xTG/Vj6oZWQXiCFpiLdOA4ov+NHKHY0FNRlugg6+g2Chor6izNI5umh/sQ++xpdx+t uteD6fiW2DXuJd1RrQQGQ5er1SzAdTYdgfDkSIifi+m2tYewQ5wxunrc1s4ZF8sJiXYA 5IeC85CWEJPtR2UhYHMp/nHRTmDbSQSfLj19+VPXhz4hNLIWa4X4WmuVLFbMs6vZpNo4 hoBQ== 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=xSu/7xOdAlhOhpGqndt0dd/xIMB7MzmL+xgNpZ/1JvM=; fh=n8P8n8mjPTF98Ox3aCUz2zCvv5jUpnKQrp7JPLvRSRI=; b=boB6onwPPExgZsc9Jylfsnyb2ZroI8e3hfnTrdwHe0lurzrajknSw6M2y32PYw7Sq/ kRNYemccWVk4mgMpFA4oE+Z0VgLWaJN89zcMahv4rVDJbye7bXCu/KE1Gr/J+rjDo9QZ 2c+Vw0PkIofU2hrVSwCyIjdWC8Fbz1yVJ8TTAVl3soP+xTE5dji5fB5XV2obdxrGe2uh MTzwx1sqz2D6eWvXllUbEXihhoFZE2KLhzHfyUN1s33rzUl89YC+qmfsUDPjlhSkEXjh 037aur6dy2iXrSskdC0/nB8JisK8OhVEvszktED7Ezt10oTQY/9DZkQLozgQVPsqpQAZ F2mA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D8TpQ3ld; 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 d75a77b69052e-46e6686eb36si10747671cf.102.2025.01.23.15.49.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Jan 2025 15:49:16 -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=D8TpQ3ld; 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 1tb6uN-0002s7-QG; Thu, 23 Jan 2025 18:46:47 -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 1tb6tx-0000t8-Bt for qemu-devel@nongnu.org; Thu, 23 Jan 2025 18:46:22 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tb6to-0004YU-QD for qemu-devel@nongnu.org; Thu, 23 Jan 2025 18:46:20 -0500 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-385e0e224cbso878632f8f.2 for ; Thu, 23 Jan 2025 15:46:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737675971; x=1738280771; 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=xSu/7xOdAlhOhpGqndt0dd/xIMB7MzmL+xgNpZ/1JvM=; b=D8TpQ3ldiIUxakZQwnr1yZJRyuTjRVD02UOr3G/KjTXqztQUCGeIpYAmQSwD5Zw2UN o7pk04ABeEvcTiAyHIfndE8Y5tntlBsV1IQx5oCG2vO1md7cB0mEalMtgcrqi9jfI8Vn ruFXrczHqIA2sr8LBq0EOTldUsK4kmlSRdsjQ4rRP9GztGd8624S0BKkY5QSzE2iozey z4oIgIO1JVNLT8s5S2faUTK8tEDVwEESlQmI0yPRUYw9wJOCgapV+jvk1tGoIeuENfRA sO3LX5Jn6IgATCAg7lqEhgiMsp8Cr8TwZS6b1xgQ34PfGOYyElS2zpGJVD3BUjYFgBnL hKHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737675971; x=1738280771; 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=xSu/7xOdAlhOhpGqndt0dd/xIMB7MzmL+xgNpZ/1JvM=; b=smnAaw7Lwo3pZTL4ojQP6ZNsRzzSH5QjUQYOuTOZiop3z1d8rYf287V5pUOgRUDNzo a2gYvP5kOZyUaptEJRhm3r4LOZu7hMQ/qq8DEoYtEkYf0rdsTFyv9obmnoTbfqxPPre0 lLC8Uagnr8CLr7hsf+8LMm69okszojzgRUDnmnwQEOAU98kgFuVMkTtNAKcxVMIAFrH0 BAWphtPC1dNj0hUexcAyUhh3P7tDIevUzgjtcvQIN+f4HJxbIa9SAlKbcBVEhMwVEKMM 8fDqZNm33w11ah8RSG4Rf7A/Dt6fo+ZRRHA2gAniX/zOkA5ZEE9D6hCkClOkubdPcIWJ rv8A== X-Gm-Message-State: AOJu0Yykv6VkaT8KNftjHvdnz31bkFOKPltDQPZJUiFmnshg/sBJryqj ygkY8jam6odC/nqgNRBSS8xRCbne+QZZHZl6391JUmcF8btppPb+xP68iRp8Mkxyt0mnMAhkgWL HSvc= X-Gm-Gg: ASbGnct0/nM3KVeM//BFkWfWWDe/Y9FW0Ev80GtTtAyk7NAI70aRaz+41B0PciOP0SM WHOJOBtiBUjbn0Tius4+W3QK4qif+Omm5vb4nEsNirsrm9+kurGB1ryuWazfzkgkuW8/IoWwicV 3jPWUc9A+LQ+jT30hkgiD6ALXJ7fzRoHpa5zKiF7PeB7lhqpambrXjLu0cCQUCpPZKobWEjjAJa V8vZUn1uIJTHoSK+NLfEoKK26NMi9IqmFnoxwa4rP8slGEzHn9101EWgZ3jox4vVWqV5MFl95WW plbGdxh3v14egNavbRyRQpa8FoHJievCBg7F8jgEiYXRuEWeAnuNNE8= X-Received: by 2002:a05:6000:e4a:b0:385:ed16:c91 with SMTP id ffacd0b85a97d-38bf566f3bemr20406552f8f.24.1737675970851; Thu, 23 Jan 2025 15:46:10 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438bd4d34e3sm6953255e9.39.2025.01.23.15.46.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 23 Jan 2025 15:46:10 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Bonzini , qemu-arm@nongnu.org, Igor Mammedov , =?utf-8?q?Alex_Benn=C3=A9e?= , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, David Hildenbrand , qemu-s390x@nongnu.org, xen-devel@lists.xenproject.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH 20/20] cpus: Build cpu_exec_[un]realizefn() methods once Date: Fri, 24 Jan 2025 00:44:14 +0100 Message-ID: <20250123234415.59850-21-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250123234415.59850-1-philmd@linaro.org> References: <20250123234415.59850-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.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=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 Now that cpu_exec_realizefn() and cpu_exec_unrealizefn() methods don't use any target specific definition anymore, we can move them to cpu-common.c to be able to build them once. Signed-off-by: Philippe Mathieu-Daudé --- Eventually they'll be absorbed within cpu_common_[un]realizefn(). --- cpu-target.c | 30 ------------------------------ hw/core/cpu-common.c | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/cpu-target.c b/cpu-target.c index bfcd48f9ae2..8f4477be417 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -19,43 +19,13 @@ #include "qemu/osdep.h" #include "qapi/error.h" -#include "qemu/error-report.h" #include "qemu/qemu-print.h" #include "system/accel-ops.h" #include "system/cpus.h" #include "exec/replay-core.h" -#include "exec/cpu-common.h" #include "exec/log.h" #include "accel/accel-cpu-target.h" #include "trace/trace-root.h" -#include "qemu/accel.h" -#include "hw/core/cpu.h" - -bool cpu_exec_realizefn(CPUState *cpu, Error **errp) -{ - if (!accel_cpu_common_realize(cpu, errp)) { - return false; - } - - /* Wait until cpu initialization complete before exposing cpu. */ - cpu_list_add(cpu); - - cpu_vmstate_register(cpu); - - return true; -} - -void cpu_exec_unrealizefn(CPUState *cpu) -{ - cpu_vmstate_unregister(cpu); - - cpu_list_remove(cpu); - /* - * Now that the vCPU has been removed from the RCU list, we can call - * accel_cpu_common_unrealize, which may free fields using call_rcu. - */ - accel_cpu_common_unrealize(cpu); -} char *cpu_model_from_type(const char *typename) { diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 71425cb7422..c5382a350fc 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -193,6 +193,20 @@ static void cpu_common_parse_features(const char *typename, char *features, } } +bool cpu_exec_realizefn(CPUState *cpu, Error **errp) +{ + if (!accel_cpu_common_realize(cpu, errp)) { + return false; + } + + /* Wait until cpu initialization complete before exposing cpu. */ + cpu_list_add(cpu); + + cpu_vmstate_register(cpu); + + return true; +} + static void cpu_common_realizefn(DeviceState *dev, Error **errp) { CPUState *cpu = CPU(dev); @@ -234,6 +248,18 @@ static void cpu_common_unrealizefn(DeviceState *dev) cpu_exec_unrealizefn(cpu); } +void cpu_exec_unrealizefn(CPUState *cpu) +{ + cpu_vmstate_unregister(cpu); + + cpu_list_remove(cpu); + /* + * Now that the vCPU has been removed from the RCU list, we can call + * accel_cpu_common_unrealize, which may free fields using call_rcu. + */ + accel_cpu_common_unrealize(cpu); +} + static void cpu_common_initfn(Object *obj) { CPUState *cpu = CPU(obj);