From patchwork Fri Sep 15 19:00:04 2023 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: 13387549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27D87EEEC06 for ; Fri, 15 Sep 2023 19:01:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236959AbjIOTAx (ORCPT ); Fri, 15 Sep 2023 15:00:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236996AbjIOTA3 (ORCPT ); Fri, 15 Sep 2023 15:00:29 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E6AB268E for ; Fri, 15 Sep 2023 12:00:20 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-530a6cbbb47so664900a12.0 for ; Fri, 15 Sep 2023 12:00:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694804418; x=1695409218; darn=vger.kernel.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=Z/oPseRALW5l8mhzSg1GPJ0x0BU257Ov4LZVxdjT9FU=; b=GQoMpZdbrQ9ILKHGhmkCr/PjB/aoiNBE91zBd7cohwo9lgApLCXh0Rx1ALeF7hD9jK HJnYFXU7DNtY9nnDz1hCT1CxmJCEYUWFcuzrJt9JaVMeEVoNlmGlXd1YJC3Y3k0jRCi3 MHF6Kat2lVy8Z7AxG8X9eH8idix70IPMRxOiCx8+6NpgroyuITH36rThhDaocPf2aMos 1h7P3wK5Nqa0HIEROvnu3v0qLzSghGuFsn46pjXaJEGPp7hSaAU1Rbl4dGDGDSsinyvC rHSkLzx/B1Ujw8pEmQK/k8ntzotTdZlslKP2UpAFQsmmarvMFvjaYAD0kWkNpTXQGvrg hgNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694804418; x=1695409218; 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=Z/oPseRALW5l8mhzSg1GPJ0x0BU257Ov4LZVxdjT9FU=; b=OKNWTObI+vlZTEvF9UsT7uOOZc7KXKFCrXFG3G9iGEbuEhYaLtxhczRShAFzowQbK5 GgGxFEnmffE9DTsTVFu9yGkaKojPLJx8/CvWkG3lWXwIA2UJZTUVEmJbHaj9Qze3L7jD p9LdNV/YxPmlLL0+4CE9+ZeRNJpwiVDVlouGUpZwHwOevlSmcw1ePYsHOBMA5HVqf5fd dJExpcia8fHdvnIbRcOJUL+bW7hFGYnUMq7GlwMV7/GXJkbxhVbbmkDk9U/FBUozzmoj r+womnZWvN8D33U/N0QADpMqANy2zqVv5qnQQoPJ9wxIujntTBv2O8bsEsCpLzSm+pWY pH/Q== X-Gm-Message-State: AOJu0YxMdiHkwL4RC7NdLuvsVYMjQefUVwIcytp66hP3cyUd7lYjTpkk 0IXp37Q4zlJVpudhWB0xR8Z94w== X-Google-Smtp-Source: AGHT+IEbQAuDRA4Cf7TJdz/ag9Jfi6f6vhHvUllHoGBImu9i64hdmiTexC51Mb0Aga2sWMgRs5JN6w== X-Received: by 2002:aa7:caca:0:b0:523:387d:f5f1 with SMTP id l10-20020aa7caca000000b00523387df5f1mr2283637edt.24.1694804418561; Fri, 15 Sep 2023 12:00:18 -0700 (PDT) Received: from m1x-phil.lan (6lp61-h01-176-171-209-234.dsl.sta.abo.bbox.fr. [176.171.209.234]) by smtp.gmail.com with ESMTPSA id i8-20020a0564020f0800b005309eb7544fsm890148eda.45.2023.09.15.12.00.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 15 Sep 2023 12:00:18 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Fabiano Rosas , Marcelo Tosatti , Claudio Fontana , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , kvm@vger.kernel.org, Yanan Wang , Paolo Bonzini , Marcel Apfelbaum Subject: [PATCH 1/5] accel: Rename accel_cpu_realizefn() -> accel_cpu_realize() Date: Fri, 15 Sep 2023 21:00:04 +0200 Message-ID: <20230915190009.68404-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230915190009.68404-1-philmd@linaro.org> References: <20230915190009.68404-1-philmd@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We use the '*fn' suffix for handlers, this is a public method. Drop the suffix. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Claudio Fontana --- include/qemu/accel.h | 4 ++-- accel/accel-common.c | 2 +- cpu.c | 2 +- target/i386/kvm/kvm-cpu.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/qemu/accel.h b/include/qemu/accel.h index e84db2e3e5..cb64a07b84 100644 --- a/include/qemu/accel.h +++ b/include/qemu/accel.h @@ -90,11 +90,11 @@ void accel_setup_post(MachineState *ms); void accel_cpu_instance_init(CPUState *cpu); /** - * accel_cpu_realizefn: + * accel_cpu_realize: * @cpu: The CPU that needs to call accel-specific cpu realization. * @errp: currently unused. */ -bool accel_cpu_realizefn(CPUState *cpu, Error **errp); +bool accel_cpu_realize(CPUState *cpu, Error **errp); /** * accel_supported_gdbstub_sstep_flags: diff --git a/accel/accel-common.c b/accel/accel-common.c index df72cc989a..b953855e8b 100644 --- a/accel/accel-common.c +++ b/accel/accel-common.c @@ -119,7 +119,7 @@ void accel_cpu_instance_init(CPUState *cpu) } } -bool accel_cpu_realizefn(CPUState *cpu, Error **errp) +bool accel_cpu_realize(CPUState *cpu, Error **errp) { CPUClass *cc = CPU_GET_CLASS(cpu); diff --git a/cpu.c b/cpu.c index 0769b0b153..61c9760e62 100644 --- a/cpu.c +++ b/cpu.c @@ -136,7 +136,7 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) /* cache the cpu class for the hotpath */ cpu->cc = CPU_GET_CLASS(cpu); - if (!accel_cpu_realizefn(cpu, errp)) { + if (!accel_cpu_realize(cpu, errp)) { return; } diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index 7237378a7d..4474689f81 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -35,7 +35,7 @@ static bool kvm_cpu_realizefn(CPUState *cs, Error **errp) * x86_cpu_realize(): * -> x86_cpu_expand_features() * -> cpu_exec_realizefn(): - * -> accel_cpu_realizefn() + * -> accel_cpu_realize() * kvm_cpu_realizefn() -> host_cpu_realizefn() * -> check/update ucode_rev, phys_bits, mwait */ From patchwork Fri Sep 15 19:00:05 2023 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: 13387547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D317EEEC0C for ; Fri, 15 Sep 2023 19:01:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236980AbjIOTA4 (ORCPT ); Fri, 15 Sep 2023 15:00:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237046AbjIOTAj (ORCPT ); Fri, 15 Sep 2023 15:00:39 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABABD106 for ; Fri, 15 Sep 2023 12:00:26 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2bb9a063f26so39803131fa.2 for ; Fri, 15 Sep 2023 12:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694804425; x=1695409225; darn=vger.kernel.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=yj/VmI3CWTgvZ6wzrxeZ+28cs5rrw6eKGcMTnrAf39k=; b=N0L14Zk31IwymYZpFO3ROhfqNleikhrT9ZwQmeG+loVHwEUfwB8SL6hnjspX6M+0HB aHl5hT1f3lNtWzR3ejlJR9zcM+vAKi6gP1tbrynVtXS08pIyLczz94jjOVDcEGse8OOi 29k67BRRJ6C2A3xC45RJgjjUmcvJAXsBg/KwmE1uwVpvKnfB6xgk53leSROuvUHp03CO wEmKAKsEryhWzg1AllCOI+Ek+lT8+VUe9rsVzhEqLoTYWgEYyTvOcWanNd3DuegQDJei h1/E1uETG2QEK7JPomx4YvgaeA5f0xmkU7xx+5/9eDhSu4jbVTDFQfot2tLtlfoFdMTm KfAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694804425; x=1695409225; 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=yj/VmI3CWTgvZ6wzrxeZ+28cs5rrw6eKGcMTnrAf39k=; b=j+etZvctCzFDzfvsvrPGMCi5KgTzaGu5+O1KqL7H1c6PslF0BrBUCjdaAGWALYW46B ZIufZ8cNPpjoutFAcPzv//yhsr3YfpjNlZ/F/+RnZuc/9V03udM/FatJh2wJ8Kj67P3b 5z4MztHq9zS13DxZkRerao0Mwn6C+6vn3pOr8hhXAWtVvadhOc2Vev4C1NAx122S7EIx 35js4TYJEuhtRligOcpWOgvJB0abOkoJ+UjuDSQUMjW8Kf05HisYQQ+JcR5DHht9XE4V rP3qv8+FObRiICkmuiHRjT9bS5UWBd/OVlJGPEUcYT4xMaom+xeTZ2Cw9ho6jcdaTU7d NKgQ== X-Gm-Message-State: AOJu0YwlOEivOyCNwp+xKf1RwFbW6foSyI8RreMh2jMNXPg9ZcA5d2nY Q8Xs0gWNQpUXgVkH1kqSLL7lBA== X-Google-Smtp-Source: AGHT+IFqQLY3Tj7eqeOV4Qk/KF83QEwxNZjoYa3bqymzIJPp2j/TFg6tNe+VoWlEZLh1FUBo2pLong== X-Received: by 2002:a2e:3e0e:0:b0:2b6:bc30:7254 with SMTP id l14-20020a2e3e0e000000b002b6bc307254mr2206820lja.13.1694804424824; Fri, 15 Sep 2023 12:00:24 -0700 (PDT) Received: from m1x-phil.lan (6lp61-h01-176-171-209-234.dsl.sta.abo.bbox.fr. [176.171.209.234]) by smtp.gmail.com with ESMTPSA id lc25-20020a170906dff900b0099bd86f9248sm2776714ejc.63.2023.09.15.12.00.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 15 Sep 2023 12:00:24 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Fabiano Rosas , Marcelo Tosatti , Claudio Fontana , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , kvm@vger.kernel.org, Yanan Wang , Paolo Bonzini , Marcel Apfelbaum Subject: [PATCH 2/5] accel: Introduce accel_cpu_unrealize() stub Date: Fri, 15 Sep 2023 21:00:05 +0200 Message-ID: <20230915190009.68404-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230915190009.68404-1-philmd@linaro.org> References: <20230915190009.68404-1-philmd@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Prepare the stub for parity with accel_cpu_realize(). Signed-off-by: Philippe Mathieu-Daudé --- include/qemu/accel.h | 6 ++++++ accel/accel-common.c | 4 ++++ cpu.c | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/qemu/accel.h b/include/qemu/accel.h index cb64a07b84..23254c6c9c 100644 --- a/include/qemu/accel.h +++ b/include/qemu/accel.h @@ -96,6 +96,12 @@ void accel_cpu_instance_init(CPUState *cpu); */ bool accel_cpu_realize(CPUState *cpu, Error **errp); +/** + * accel_cpu_unrealizefn: + * @cpu: The CPU that needs to call accel-specific cpu unrealization. + */ +void accel_cpu_unrealize(CPUState *cpu); + /** * accel_supported_gdbstub_sstep_flags: * diff --git a/accel/accel-common.c b/accel/accel-common.c index b953855e8b..cc3a45e663 100644 --- a/accel/accel-common.c +++ b/accel/accel-common.c @@ -129,6 +129,10 @@ bool accel_cpu_realize(CPUState *cpu, Error **errp) return true; } +void accel_cpu_unrealize(CPUState *cpu) +{ +} + int accel_supported_gdbstub_sstep_flags(void) { AccelState *accel = current_accel(); diff --git a/cpu.c b/cpu.c index 61c9760e62..b928bbed50 100644 --- a/cpu.c +++ b/cpu.c @@ -187,8 +187,9 @@ void cpu_exec_unrealizefn(CPUState *cpu) cpu_list_remove(cpu); /* * Now that the vCPU has been removed from the RCU list, we can call - * tcg_exec_unrealizefn, which may free fields using call_rcu. + * accel_cpu_unrealize, which may free fields using call_rcu. */ + accel_cpu_unrealize(cpu); if (tcg_enabled()) { tcg_exec_unrealizefn(cpu); } From patchwork Fri Sep 15 19:00:06 2023 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: 13387550 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FA57EEEC01 for ; Fri, 15 Sep 2023 19:01:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236911AbjIOTBY (ORCPT ); Fri, 15 Sep 2023 15:01:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236924AbjIOTAw (ORCPT ); Fri, 15 Sep 2023 15:00:52 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B560A2710 for ; Fri, 15 Sep 2023 12:00:33 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-9a9d82d73f9so301138866b.3 for ; Fri, 15 Sep 2023 12:00:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694804432; x=1695409232; darn=vger.kernel.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=WDSY0XDObgkxUL7brWiUxnx3rvK0ibvXtjHunMwb0Ko=; b=ceKBQR1RegoWP4Ac7tjd7JjGTdW5GTQbrYzeSyO/j8Hok0f4+l6mYLWw+b4dEY7qv8 A/wneIGMpWxXm6xAXG2uYnLLRK/7kqCHAOe081gHgDRyS+5YLfWfCIU2ev2PwyD3fa6d JHV+u85xs6Xg4ldaxZg+N67SeoagY4m/kvz38PLeN+dKktu0GzKPdZhG3wY6Bqjm0Lmp cC3cE/BqTg1rcsrL9/GzGAOcvClsepFRixyuHuR4Jqo5di80wTMcb7NuJanu8L5t+MeB 22W4xQkBg6nxG20RIROdfgGanAQSUsExubaDpudUxWupknb6TpMiasWcqT1ZKhBsP5Oj s+pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694804432; x=1695409232; 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=WDSY0XDObgkxUL7brWiUxnx3rvK0ibvXtjHunMwb0Ko=; b=ihjYNEE2pFKL8qVSiR2AWHXrcyCblchTGAKgwx+fMkpjt5N/DWFDzOqGkuhTNuS7Y4 9Mwr7MDBpThz9Ahi53WUT46v1P73aWAwubeCv8IU0FPwlL/XSKtkFEuW2hL3EM66E4QL ef00r9azYb7Dmptgz2LlQ1aqxX03IVx4/YE08JIHgJhS123RJsXpHTE3rc61SbxoO2Ng yiax4EGPRHIfM1pZo4zBp6MlPidL7np1fc7y2qGKt8kA8s6FVUmLagUmh9HB5VL6YCF4 XADJxrvSXxFRUySotlcmJt3UtZIlb51cIJsbTnH0VJ4hLun6VYL3zXQP+kLhHnYNowTf JwJA== X-Gm-Message-State: AOJu0YxkHS738PQcU1DG1BwXGWNJe8FYFr6aGVV1uil3G67YINvQGVCE TwUkP8kNC102Nw/tm+K4/JbCzA== X-Google-Smtp-Source: AGHT+IGEP/lvi8q3j5fpuCxcqNS187PK1L6ySZKuoqbnVy4D7JQSt+RyvvPIVtxvhOTk4XTqtPcS7g== X-Received: by 2002:a17:906:76cc:b0:9a1:ddb9:654f with SMTP id q12-20020a17090676cc00b009a1ddb9654fmr1957052ejn.55.1694804432309; Fri, 15 Sep 2023 12:00:32 -0700 (PDT) Received: from m1x-phil.lan (6lp61-h01-176-171-209-234.dsl.sta.abo.bbox.fr. [176.171.209.234]) by smtp.gmail.com with ESMTPSA id lg13-20020a170906f88d00b009828e26e519sm2750934ejb.122.2023.09.15.12.00.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 15 Sep 2023 12:00:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Fabiano Rosas , Marcelo Tosatti , Claudio Fontana , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , kvm@vger.kernel.org, Yanan Wang , Paolo Bonzini , Marcel Apfelbaum Subject: [PATCH 3/5] accel: Declare AccelClass::[un]realize_cpu() handlers Date: Fri, 15 Sep 2023 21:00:06 +0200 Message-ID: <20230915190009.68404-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230915190009.68404-1-philmd@linaro.org> References: <20230915190009.68404-1-philmd@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Currently accel_cpu_realize() only performs target-specific realization. Introduce the [un]realize_cpu fields in the base AccelClass to be able to perform target-agnostic [un]realization of vCPUs. Signed-off-by: Philippe Mathieu-Daudé --- include/qemu/accel.h | 2 ++ accel/accel-common.c | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/qemu/accel.h b/include/qemu/accel.h index 23254c6c9c..7bd9907d2a 100644 --- a/include/qemu/accel.h +++ b/include/qemu/accel.h @@ -43,6 +43,8 @@ typedef struct AccelClass { bool (*has_memory)(MachineState *ms, AddressSpace *as, hwaddr start_addr, hwaddr size); #endif + bool (*realize_cpu)(CPUState *cpu, Error **errp); + void (*unrealize_cpu)(CPUState *cpu); /* gdbstub related hooks */ int (*gdbstub_supported_sstep_flags)(void); diff --git a/accel/accel-common.c b/accel/accel-common.c index cc3a45e663..6d427f2b9d 100644 --- a/accel/accel-common.c +++ b/accel/accel-common.c @@ -122,15 +122,32 @@ void accel_cpu_instance_init(CPUState *cpu) bool accel_cpu_realize(CPUState *cpu, Error **errp) { CPUClass *cc = CPU_GET_CLASS(cpu); + AccelState *accel = current_accel(); + AccelClass *acc = ACCEL_GET_CLASS(accel); - if (cc->accel_cpu && cc->accel_cpu->cpu_realizefn) { - return cc->accel_cpu->cpu_realizefn(cpu, errp); + /* target specific realization */ + if (cc->accel_cpu && cc->accel_cpu->cpu_realizefn + && !cc->accel_cpu->cpu_realizefn(cpu, errp)) { + return false; } + + /* generic realization */ + if (acc->realize_cpu && !acc->realize_cpu(cpu, errp)) { + return false; + } + return true; } void accel_cpu_unrealize(CPUState *cpu) { + AccelState *accel = current_accel(); + AccelClass *acc = ACCEL_GET_CLASS(accel); + + /* generic unrealization */ + if (acc->unrealize_cpu) { + acc->unrealize_cpu(cpu); + } } int accel_supported_gdbstub_sstep_flags(void) From patchwork Fri Sep 15 19:00:07 2023 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: 13387551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90A53EEEC03 for ; Fri, 15 Sep 2023 19:01:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236979AbjIOTB1 (ORCPT ); Fri, 15 Sep 2023 15:01:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236983AbjIOTA6 (ORCPT ); Fri, 15 Sep 2023 15:00:58 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80AF4AC for ; Fri, 15 Sep 2023 12:00:40 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2bcb89b4767so38397481fa.3 for ; Fri, 15 Sep 2023 12:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694804439; x=1695409239; darn=vger.kernel.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=YgOXTjMw7CegRZgzm9gZgaFqpfOBfIJY+75/jhEK298=; b=LKiLfr1gA2uMk24cNtxKfESvIJQ6xdrh5hc/p4ErYbucvmluCBLWXxH2M/+VkuZr52 nksjKV6JgkYJrPmj6B8oUxGXDyyhBaMBmQQL2n2H7cs7aVL8FxTHGDFj45r3riEWF/tz /j/XggP34YRIV2bQFxRGRcceAAC+wR8irVcemyIykDXTT79KW3SkzZQczZ8Oq07hdmZ8 DxL1dW0ROq6Jhre9F1BhrFxHgrIr2hLFoX6FdAugJpEHVediXTEN1pAFBl0N7O8QOwHf BlKTKKlZnw28GGk456k6xLdxAqAvrIDqrrPvl3fwHFiM8CmUdqXXStSh9WYXJ5Yeoh4v 62Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694804439; x=1695409239; 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=YgOXTjMw7CegRZgzm9gZgaFqpfOBfIJY+75/jhEK298=; b=lM1mwXRt/tD9HUe0kQv++7MN0XhaaamavOlESo1yJ/KGgueR9dk+lBBMGgXt7ebu5i gpR28dVJzDSATRU4e6VDsVLSAVwsFKqZjUf/WQ6YhqWo2BmdCZbbPbST1rv/P8gYCQZ1 oSzKOYRmTF6uHPasWmniNAjQJ+wkADAxxz30brflTt3Yj6fxMLhi0oHJQxA6GrQVbGDr sZ1m7AQryHeymLrnM1Y8Z5qaZQl3SyLsHOwCsUZd6CQP/mMhm/kGa+VXiMlMMvd6fgRE VjDPE9qHz2JBOobzS6YpUFfe3O6hQ6ezETnMvyZJCjIsiVtwYdHouskHMbWOf/H1NZ+1 C23A== X-Gm-Message-State: AOJu0Yy6tQQHtNe6oDOdPM4Emjo7rFVO+ZV44F0TidTqPput5S2KQRkR zoaNMRmN/d5G+OJgT3i+rLHmKg== X-Google-Smtp-Source: AGHT+IFb62BREUPfjWbOVNIJ5iUEG9onYwiuiWAr/WJWgO5E/Rw3dRu3NysvQrmCzHvFT+lowhetpw== X-Received: by 2002:a2e:b001:0:b0:2bc:b46b:686b with SMTP id y1-20020a2eb001000000b002bcb46b686bmr2330235ljk.34.1694804438711; Fri, 15 Sep 2023 12:00:38 -0700 (PDT) Received: from m1x-phil.lan (6lp61-h01-176-171-209-234.dsl.sta.abo.bbox.fr. [176.171.209.234]) by smtp.gmail.com with ESMTPSA id l21-20020a1709061c5500b009ad89697c86sm2771684ejg.144.2023.09.15.12.00.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 15 Sep 2023 12:00:38 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Fabiano Rosas , Marcelo Tosatti , Claudio Fontana , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , kvm@vger.kernel.org, Yanan Wang , Paolo Bonzini , Marcel Apfelbaum Subject: [PATCH 4/5] accel/tcg: Have tcg_exec_realizefn() return a boolean Date: Fri, 15 Sep 2023 21:00:07 +0200 Message-ID: <20230915190009.68404-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230915190009.68404-1-philmd@linaro.org> References: <20230915190009.68404-1-philmd@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), have tcg_exec_realizefn() return a boolean indicating whether an error is set or not. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Claudio Fontana --- include/exec/cpu-all.h | 2 +- accel/tcg/cpu-exec.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index c2c62160c6..1e5c530ee1 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -422,7 +422,7 @@ void dump_exec_info(GString *buf); /* accel/tcg/cpu-exec.c */ int cpu_exec(CPUState *cpu); -void tcg_exec_realizefn(CPUState *cpu, Error **errp); +bool tcg_exec_realizefn(CPUState *cpu, Error **errp); void tcg_exec_unrealizefn(CPUState *cpu); /** diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index e2c494e75e..fa97e9f191 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -1088,7 +1088,7 @@ int cpu_exec(CPUState *cpu) return ret; } -void tcg_exec_realizefn(CPUState *cpu, Error **errp) +bool tcg_exec_realizefn(CPUState *cpu, Error **errp) { static bool tcg_target_initialized; CPUClass *cc = CPU_GET_CLASS(cpu); @@ -1104,6 +1104,8 @@ void tcg_exec_realizefn(CPUState *cpu, Error **errp) tcg_iommu_init_notifier_list(cpu); #endif /* !CONFIG_USER_ONLY */ /* qemu_plugin_vcpu_init_hook delayed until cpu_index assigned. */ + + return true; } /* undo the initializations in reverse order */ From patchwork Fri Sep 15 19:00:08 2023 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: 13387552 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FE15EEEC00 for ; Fri, 15 Sep 2023 19:01:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236988AbjIOTBa (ORCPT ); Fri, 15 Sep 2023 15:01:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236834AbjIOTBE (ORCPT ); Fri, 15 Sep 2023 15:01:04 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7A162700 for ; Fri, 15 Sep 2023 12:00:49 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-9aa0495f9cfso775997866b.1 for ; Fri, 15 Sep 2023 12:00:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694804448; x=1695409248; darn=vger.kernel.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=oOpx/VA/+gwdtEbnTetIr2FQsXveadRswnAsnH4GXos=; b=BD3S+lptWgYbVUp07tAI39aXmGHExjkVI+ULI4guCoMcX2UaJt/VcJfNLn+L/kL2MP 1bQl/GaJ94PJuYfMHKdxw9xyA5C/5Ubxt7pmltSmvHLmgYGur6x1AZEQUOtYC0tOFoes 4HQYFD+xCXNX6/eiPMmyLkOHasgzkditqy+BMYmQ/TvskYQOVKyNpffdNzMDqG3FiVEL UtmbnIclVcnvBgtl8fNMYdiKcMNVrwNL8gDprbiG5p3TeHer/qN8Ih4n8p0pg2mhGvTO 5bpsuwiI6o6j7iOky8uNiDbKRtyFhlgpCcxh74KD2pImVLLZEQJ6KL118ZFcvP+dpeW5 HxoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694804448; x=1695409248; 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=oOpx/VA/+gwdtEbnTetIr2FQsXveadRswnAsnH4GXos=; b=fY/U9ioprgoL+pCD6ZsPi5C+zgJ0S6e9z3lAT0tqDfCOIXvI+83pIeY+NEv25Po6Ww 5ULzfRc/j8w67dycq2MNYnkRmrgFwxDckbweLhoZeHJGEv/nF4ItUl9prHp34azRdNEG H0PNgbagU/oCQ/u1kkqs09qszx+my3xTttlF+YWqAN9irK0WvcrIGb0UagRC4e3zvPRJ ro3i1C2bvhfkKfVU3LZp96MXzmhawx0Qc/KHuyf0vAYmrMVKtePcWf6cseruvavcV/J+ jdmrucnogm6MTx00Af0phMzN0gM50IhkkD1/q0XABr8LRrxDeJOLongbON9Ay72LzCej tjDg== X-Gm-Message-State: AOJu0YxKo9TB0U6vBuyjH4ZGBJKYrf0aXFA8eNHH70t/vwdL/kyTHvzD oXq2KucdD3Dbk7SSBW155C13WA== X-Google-Smtp-Source: AGHT+IELleuQSkuMS3U2vjtSOoyli3O0jtH4oH1By3hb7PvHE0MO+UI88qPm19yIOTSyq5wf6F29XQ== X-Received: by 2002:a17:907:3f91:b0:9a5:b247:3ab with SMTP id hr17-20020a1709073f9100b009a5b24703abmr9362665ejc.19.1694804445231; Fri, 15 Sep 2023 12:00:45 -0700 (PDT) Received: from m1x-phil.lan (6lp61-h01-176-171-209-234.dsl.sta.abo.bbox.fr. [176.171.209.234]) by smtp.gmail.com with ESMTPSA id mf13-20020a170906cb8d00b0099caf5bed64sm2735321ejb.57.2023.09.15.12.00.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 15 Sep 2023 12:00:44 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Fabiano Rosas , Marcelo Tosatti , Claudio Fontana , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , kvm@vger.kernel.org, Yanan Wang , Paolo Bonzini , Marcel Apfelbaum Subject: [PATCH 5/5] accel/tcg: Restrict tcg_exec_[un]realizefn() to TCG Date: Fri, 15 Sep 2023 21:00:08 +0200 Message-ID: <20230915190009.68404-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230915190009.68404-1-philmd@linaro.org> References: <20230915190009.68404-1-philmd@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We don't need to expose these TCG-specific methods to the whole code base. Register them as AccelClass handlers, they will be called by the generic accel_cpu_[un]realize() methods. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Claudio Fontana --- accel/tcg/internal.h | 3 +++ include/exec/cpu-all.h | 2 -- accel/tcg/tcg-all.c | 2 ++ cpu.c | 8 -------- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/accel/tcg/internal.h b/accel/tcg/internal.h index e8cbbde581..57ab397df1 100644 --- a/accel/tcg/internal.h +++ b/accel/tcg/internal.h @@ -80,6 +80,9 @@ bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc); void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, uintptr_t host_pc); +bool tcg_exec_realizefn(CPUState *cpu, Error **errp); +void tcg_exec_unrealizefn(CPUState *cpu); + /* Return the current PC from CPU, which may be cached in TB. */ static inline vaddr log_pc(CPUState *cpu, const TranslationBlock *tb) { diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 1e5c530ee1..230525ebf7 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -422,8 +422,6 @@ void dump_exec_info(GString *buf); /* accel/tcg/cpu-exec.c */ int cpu_exec(CPUState *cpu); -bool tcg_exec_realizefn(CPUState *cpu, Error **errp); -void tcg_exec_unrealizefn(CPUState *cpu); /** * cpu_set_cpustate_pointers(cpu) diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index 03dfd67e9e..6942a9766a 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -227,6 +227,8 @@ static void tcg_accel_class_init(ObjectClass *oc, void *data) AccelClass *ac = ACCEL_CLASS(oc); ac->name = "tcg"; ac->init_machine = tcg_init_machine; + ac->realize_cpu = tcg_exec_realizefn; + ac->unrealize_cpu = tcg_exec_unrealizefn; ac->allowed = &tcg_allowed; ac->gdbstub_supported_sstep_flags = tcg_gdbstub_supported_sstep_flags; diff --git a/cpu.c b/cpu.c index b928bbed50..1a8e730bed 100644 --- a/cpu.c +++ b/cpu.c @@ -140,11 +140,6 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) return; } - /* NB: errp parameter is unused currently */ - if (tcg_enabled()) { - tcg_exec_realizefn(cpu, errp); - } - /* Wait until cpu initialization complete before exposing cpu. */ cpu_list_add(cpu); @@ -190,9 +185,6 @@ void cpu_exec_unrealizefn(CPUState *cpu) * accel_cpu_unrealize, which may free fields using call_rcu. */ accel_cpu_unrealize(cpu); - if (tcg_enabled()) { - tcg_exec_unrealizefn(cpu); - } } /*