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: 723156 Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp550472wro; Fri, 15 Sep 2023 12:01:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdcu5W80dlYBJyjDv8Y5CLsadP5rN/AHiLxMZ0dC80OOScaBeHs4jOgDJIzxOoALyMbyM+ X-Received: by 2002:a67:b103:0:b0:44f:c528:6252 with SMTP id w3-20020a67b103000000b0044fc5286252mr2408818vsl.2.1694804465942; Fri, 15 Sep 2023 12:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694804465; cv=none; d=google.com; s=arc-20160816; b=yoZaj8hXsqTcPw2X2F5bhxWIGXrkxBCtKew5NTEsajDZwpiNOI2ZAZ3IL7BhTfv2Jq bDPjjhJL5d1p5NF7EEVJ5jR8lzIBUDvbprR2Mnr40eytOwnSQUsLVGM1Q+z0dpX0s4vo YfOIe236ryQRI1mWjlHtsCl9a22XDxHmlM9LVYUvGt0E4HPk4Ptghg6GD7mD96octR4h mmz8L2s8I7M4gBqDBDD3e9ixOTkWws0a4btZoKnL4xe+9cCv+2xmf8vSY206G/erk7VS x5wSpVYHMNArVk1x6D1Ij0gjYIJTvHWn2rYlG6jhFbmTSZKb5E+/keJRK2sL0AejcZb7 KUtQ== 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=WDSY0XDObgkxUL7brWiUxnx3rvK0ibvXtjHunMwb0Ko=; fh=waCo463KK/RPn5XMJMOOqmdDlsjWfqQaOVVDQpLbHvU=; b=tJOt/T6cnDPP0ErF6Zod3kdhFi2N15W64QneApL6yUpZqTwqLpZpD8ofQghqZF+nr5 xi7/q17ivhNXFXZJHKX4lbficA52B30Y24TEUyN08oE5QMNZPTDxxwiI5YhD6astc9TS TxAd37hQNgN/Fj1kKPH6Br0zrEYgTHFihOvLcEKUt/YvZNgmXvAeBb7p4rsLJZyeroWm uFVF+gvqPjnRoztNflBtupQ60VDVjXxTQ/EYQe4UZ5LhrYM2bd5vcKG5VoBxWXWVxUd0 Mhwv5oRQjWy8r5AScgNKhJwS3ty8GFZ+c26ERY/fRKboN/uiy2QD2JhL6MrBI6RcLCuR E5Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TB8etVMh; 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 n20-20020a67d614000000b0044d40c193fdsi351467vsj.410.2023.09.15.12.01.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Sep 2023 12:01:05 -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=TB8etVMh; 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 1qhE3X-0005rO-51; Fri, 15 Sep 2023 15:00:45 -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 1qhE3R-0005nC-Kk for qemu-devel@nongnu.org; Fri, 15 Sep 2023 15:00:37 -0400 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhE3N-0007a6-To for qemu-devel@nongnu.org; Fri, 15 Sep 2023 15:00:36 -0400 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-9a645e54806so302825666b.0 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=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=WDSY0XDObgkxUL7brWiUxnx3rvK0ibvXtjHunMwb0Ko=; b=TB8etVMhsM+4J4V2UVXxXPjrrXg4yXqt2v28ZznHuJ4DfAxUknz09wn7xBVbSn9Lv8 WtgdM3ggP1CYorgtkH+uhqACmZjf4oAYg6U+25ZA62gEmUOdyHdQJd5Qoi061m3Bw09C 3Ce9ISdU5sPdgjhiTpi6ZDAH1pLbmdQv6aEiKTOOkCWxyJx+a74sSh1Yw2b5a+nwl1wU sDSnUOlEulL9TavjUGZgETffQXPLxfxOr+drl1yGjQmz3PoUrD8AjybkOCmEF5U5NLsb m7QyFwNqEELCc/+skgLfQ/hrEdzWSuYOhLDfh4KBamA5RgC/1aXCqeCNWNIXYPUtSBPF c4ag== 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=OMJlpA9dAfaMAhh5X+kzd7H/ZnGUX+k2S1OwZuUZ/clAWVF0TIXe+A2iM2UhQxPpHw 3M3SPOqwGTz26Itynd/3XYPbl19jL/0pEDhX0Vf409AiLuzsMgw1VAxEegIRcsohHDRC XnzIB1qVnLmnKFCwhPCv0PcM6kGUCxAlb5/DZ69ETA88ulcKXZq/IAxm6qJ7vyjaNO8R 9mL3Kwthx4ytjqzmEUY6ocmJma9DbojPyxANnBV7Z59HPhFepehdA3RhK13cfDJQC8sG 4u3AEmUQpuE1ElgZRXO6k5/KfC2kuJ1G86Mm5Zb6J8twYJtAjJje9FeDbfg6a7bJZFyF P/2Q== X-Gm-Message-State: AOJu0Yy4u7QdV8LpMBnM64reggdUmxlSURxp8kY5TpomejQpNf88DY7v X4od96BxPQS3nzPC8AZpNmq3e1y2QOtpNU2NrA8= 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 Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=philmd@linaro.org; helo=mail-ej1-x631.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 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)