From patchwork Sat Sep 16 21:41:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 723605 Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1028831wro; Sat, 16 Sep 2023 14:44:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0UDrc2CUWlCyyAOQMujv4Cc4BQuH3kX2JPpCeyWNTkVyJEhv9IpKvsvrK6XY+ReDklolW X-Received: by 2002:a0c:f0c5:0:b0:655:decd:c35d with SMTP id d5-20020a0cf0c5000000b00655decdc35dmr4960529qvl.5.1694900683812; Sat, 16 Sep 2023 14:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694900683; cv=none; d=google.com; s=arc-20160816; b=lKAfdu2FGkGM3iIY2XtddgahdtXryspwu+E9w4f40KpPgYsLrU5uoihkudC51fepxM fpih3rHZG3rs/eXjGmOScuyKBVNzRW/EsW3qlql079Xdtdp/UrPfMlZCkY+jzJjU5tor zO/RH7lrAOOBIWkkb0CNGxcvO6odVRFCOlKIGcPGxDrcRIp7Nl6zZVe1+JpwF7FQFvMb hUOoZqzBG0DFqkwioaTUGkdP+Jy6af97ndGBZjyEYdvy+WKCvR4g8EqgJpNYfDh3/v8a c3XXhA8ywHfLclpQC6DzlKxfqf1qg5Oz+unjuBcocVtMz11XmLtspawddPMgwewmXBRe KQlw== 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=9frgVbpvR/cKhB4Eeaz6aEQy82XBehF08OdWl52rupE=; fh=d3q967Ss27yOZEBNWb7WV1pwIIYORDjfLhLmomzC17w=; b=aTe5cIpSrWKAG7c0lzLVGmAa80U0J1KdA6AeBsojuc8euv1nhvt0Gcag83F+X6gGPZ MF+1hDmMy/JBVWTGeNGaSbQncEMvFv4rLZiMmAHaoqbzGx767JEyuaiigkKC8gBCfVTH BxOlK59j9F10IaErK18QoRl9eOZ0PQ42ONj9hwfYgc2wojd/ENquMgo199pYyTb/mrSi v+4Tb+73Oqrw6AY8SaEqzyglIhwIZ6C49xq7vDp2dgZkBI1X59d/GOcL5LAx8b72IO8w +BiDDKkzuSVQndXZx+WaWXnYtNvZ4sb4VQYj7Jt3/YrUnZ/+2961GwP4oYMehigMwlH7 oTlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yo3+1zJb; 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 q6-20020a0cf5c6000000b0063cd763767esi4124533qvm.123.2023.09.16.14.44.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 16 Sep 2023 14:44:43 -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=Yo3+1zJb; 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 1qhd3u-0007TN-69; Sat, 16 Sep 2023 17:42:46 -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 1qhd3D-0005Ey-DS for qemu-devel@nongnu.org; Sat, 16 Sep 2023 17:42:04 -0400 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhd3B-0000Wl-Hi for qemu-devel@nongnu.org; Sat, 16 Sep 2023 17:42:03 -0400 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-1d643db2c98so1640346fac.0 for ; Sat, 16 Sep 2023 14:42:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694900520; x=1695505320; 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=9frgVbpvR/cKhB4Eeaz6aEQy82XBehF08OdWl52rupE=; b=Yo3+1zJb4yxuZE9XIRgHbZuTIgu5F67ksKyYPS4JT8QZjMKSuI06v9vQjjKCXFbht1 yiGOY8D9Ct4kaHOtK+1j6Qr0x4zLbzkRMjqQd0TdqCLL1ktoFOgpqTPbt5QzxaOhe8ni g3unY/McDRCAZ+tlGgTmVJ3NQ3UdXTddbEP4JLTowZYGNCxwC8SK6ttmYCnXtx2W8+nd zZLctXIsd27I8jw7EdxL8zurSfVa+gM7FOlvZh2Dg4c2IwuqnI64lkENlw3O/ATDaYr4 H0rZPFr1nVfcrBpdE6R+RBgpjpEvEDDuD6e2zMZqgytnHOLUrWdEhkoDz3Y9JfNBa68/ A37Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694900520; x=1695505320; 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=9frgVbpvR/cKhB4Eeaz6aEQy82XBehF08OdWl52rupE=; b=A00EiEfXHQJ4L5T5UXlaX8ZEiEVT3hewd8Srh3U45uUFJvfBpxoszj8F1tmI5SKZhy 7pLWstBqPQOpInMc+4ESuyY1rFB98fN4WDPsvZ8RRJO+Cxkw+ZjTJxTfSPNJ6egX1ZzU BxU8yO4y/+/Xla7G+d+z63H2tBU4/YdzR7r6IH+ZEkQpcllwF7XPDFr75e1XtB5i8XxY 8PufjsBT9TckEpbHqjZB/j777zK4fqpoMVs6OO58QYxQiao8SZN3mSMkHvDHQw21ormg pmWst9m8Oul5Cv2iajHdq84dOm8UkmKaYtzaYhzu59JrDa+6/h7JHzrr9Wa+wIiDLLm3 n48A== X-Gm-Message-State: AOJu0YwnA6NmS9WHmf3t+Pw0//nA3Kak+/s07Q+OyXlhEgmLFCLEoJlv nknArHomCX7CHclKn20EoMdcTGZDa2B0w6lJkkc= X-Received: by 2002:a05:6870:95aa:b0:1ba:d044:8a4 with SMTP id k42-20020a05687095aa00b001bad04408a4mr6774135oao.18.1694900519795; Sat, 16 Sep 2023 14:41:59 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id n21-20020aa79055000000b0068fde95aa93sm4871708pfo.135.2023.09.16.14.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 14:41:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, anjo@rev.ng Subject: [PATCH v3 37/39] accel: Declare AccelClass::[un]realize_cpu() handlers Date: Sat, 16 Sep 2023 14:41:21 -0700 Message-Id: <20230916214123.525796-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230916214123.525796-1-richard.henderson@linaro.org> References: <20230916214123.525796-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::2f; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2f.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 From: Philippe Mathieu-Daudé 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é Message-Id: <20230915190009.68404-4-philmd@linaro.org> Signed-off-by: Richard Henderson --- include/qemu/accel.h | 2 ++ accel/accel-target.c | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/qemu/accel.h b/include/qemu/accel.h index 7b02cb40e5..0b6031bd82 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-target.c b/accel/accel-target.c index cc3a45e663..6d427f2b9d 100644 --- a/accel/accel-target.c +++ b/accel/accel-target.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)