From patchwork Tue Oct 3 12:30:25 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: 728739 Delivered-To: patch@linaro.org Received: by 2002:a5d:60c8:0:b0:31d:da82:a3b4 with SMTP id x8csp2116063wrt; Tue, 3 Oct 2023 05:32:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFc9L0QBt5U9cSQXjnqG8UeqXVeJad0/YwGdrGfUgEPdcOQZMqepBvX1WbD4r0eGb4KMEBS X-Received: by 2002:a05:6214:4606:b0:65d:178:15a0 with SMTP id oq6-20020a056214460600b0065d017815a0mr16236034qvb.36.1696336326548; Tue, 03 Oct 2023 05:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696336326; cv=none; d=google.com; s=arc-20160816; b=C3SBaf3h1I3h6n2lkADb21nzRe8vGvmNGNpIIL8Js5jFbQNR/pEgnDHPCbf71dUsXP rGYOcmiszcBHTVKPUWIQwYNfeO+gbqI0ekoecY6PbirP1aZd83UoR/RpH78LSZfbixrr ozV7ZFOvAAa0vphinCd96YqcW3GqPbOTcE3nn9THqGXOnm02riNMmTdhIEuaH0ESjQng aNwVRP/5T7MEaWt0BimNyw0izRZvMg6qrPJNHtN6wJy+314lBAkI6LJu/g/je+SniVSt 1jZVKKiJ09FA8g1VCb1e0fNgSSxD0zAOwmaS34h+quFjKWCTpJZKJtgiDWe9yRnxZXGk gavg== 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=YCJq244pl4+8992N+SUfSZJnXy6q+2iGjPbprJxjpgU=; fh=CVJQstyUWDliy7yeWt2k56tVqQKxFVNP1RtQ0M0BBPc=; b=iQE16qkmOvGkf3xm7YWDspyHqUn2/tbPkiGVVmBwKPtb9z5Gl0JOrfAfBTOJ8fVRIA 9W/iCFeBJQsDRRXV6WhmmXF+aSugIAtGfRiABj9HgXJo3847EXIdySIEhL4NvHlWWI3O iR/0Epf7WcPGZzsJucYadDuqht6bwBY22KUMNdat158RP12VUXJ2Ggo4OGPZCgXAgyNB k3jUjnM7FfRAlLfs1LpK6en/2W63iTc0aO7p2GqxORS0JfPVIhzmCdL6NPKB0dAmjraB EJ3Nu6KX1yEwm4Fi+3Biab1TGL9f5ON2I+LdRDy4D8Qth+WlctO4HGFFqTzttn3p3ruW 49jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kYm7nGry; 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 w2-20020a0ca802000000b00668da56152csi452343qva.506.2023.10.03.05.32.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Oct 2023 05:32:06 -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=kYm7nGry; 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 1qneYx-0001IV-6V; Tue, 03 Oct 2023 08:31:43 -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 1qneYd-0000tH-Q5 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 08:31:26 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qneYW-0007mg-Ua for qemu-devel@nongnu.org; Tue, 03 Oct 2023 08:31:23 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-32157c8e4c7so913898f8f.1 for ; Tue, 03 Oct 2023 05:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696336274; x=1696941074; 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=YCJq244pl4+8992N+SUfSZJnXy6q+2iGjPbprJxjpgU=; b=kYm7nGryxgvS+7f6kjDbCqKJ9aC6sz4BmDYIPgotRv0Fu3X3wymqeuUnQiXEgqpEJl 0ARJi3vOd4Xl0FjFc019DhYZfa3IjbpIBG12kTiWhC62DSBiR/owDwwjPV6jmkwqxgoD PoPUv3n8AMX5QzW+fsncSR0qgFwJDWDadD5DisXN15PVY0xohKtX1g/vt0rGU1sKWiel Y2y6sahoVg0X0VWlHSgopzBpXBnV0xZmIKgKPfUJNf2hWhEgkczcXI0Ssh+qlKnUzXbU AZ2s5pypAH8b2ozm8KMsgk5tSiJcHaieXXJXnL6PTCa5azuHs411xsIgh8SKIda37Wwf PSZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696336274; x=1696941074; 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=YCJq244pl4+8992N+SUfSZJnXy6q+2iGjPbprJxjpgU=; b=NxNzyspLQ96XfEw041UcIyOoZYjbsoZ+m3ipaoVTd6uWukcMHgd6o9R2aHY3ZblRrH uXqkJ90khfrEaCTtrhkTjVZwUlG7f+pFCAGXt1qbCSbV5yNHf0BbwouoEZmR+446VGyF lZCC5FH89BgbZ4fcRSTdT3RL/MLQHnNEL+57v47WuLLE0QoHDCx/UK0Q78KGqBOIkJ64 K6fwCRfn62Cjkia8jAOTFl2Wm30mDZoWhH56h4wm4TlGsHavIsIwihwlm6YxaQA55x6A Ap8wL/jmhB5OAkZZ1qqIB03RrxGY8/EQArP/XS831nhV6uRqQaaseV1uXnIkgG1C5Htz QNhA== X-Gm-Message-State: AOJu0YzEzHC3G5wOE3x0AuK0OYHqRF3lZ2NcrBP+55atGGvFp6Eho+yC pP9EZje4dK5sFlMEtUMpFhpwhCFZZb5AgPTnmRnZ8g== X-Received: by 2002:adf:e852:0:b0:323:2038:944 with SMTP id d18-20020adfe852000000b0032320380944mr13304917wrn.58.1696336274319; Tue, 03 Oct 2023 05:31:14 -0700 (PDT) Received: from m1x-phil.lan (176-131-222-246.abo.bbox.fr. [176.131.222.246]) by smtp.gmail.com with ESMTPSA id j14-20020a5d464e000000b0031f8a59dbeasm1478930wrs.62.2023.10.03.05.31.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 03 Oct 2023 05:31:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Yanan Wang , Paolo Bonzini , kvm@vger.kernel.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Claudio Fontana , Richard Henderson , Marcelo Tosatti , Roman Bolshakov , Fabiano Rosas , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Cameron Esfahani Subject: [PATCH v2 7/7] accel/tcg: Restrict tcg_exec_[un]realizefn() to TCG Date: Tue, 3 Oct 2023 14:30:25 +0200 Message-ID: <20231003123026.99229-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003123026.99229-1-philmd@linaro.org> References: <20231003123026.99229-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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 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 | 9 --------- 4 files changed, 5 insertions(+), 11 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..8ab873a5ab 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->cpu_common_realize = tcg_exec_realizefn; + ac->cpu_common_unrealize = 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 2a1eff948b..658d179582 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); @@ -187,13 +182,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 and * accel_cpu_common_unrealize, which may free fields using call_rcu. */ accel_cpu_common_unrealize(cpu); - if (tcg_enabled()) { - tcg_exec_unrealizefn(cpu); - } } /*