From patchwork Tue Jan 3 18:16:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638724 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1390647pvb; Tue, 3 Jan 2023 10:18:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXu3oj0qSna26by3PsxbFMleCbPOl7DeVycLlmHVOz3B8ndgn70MfAogYrujjUEcvdN9M2Id X-Received: by 2002:a05:622a:2605:b0:3ab:a1cf:b2ca with SMTP id ci5-20020a05622a260500b003aba1cfb2camr31013926qtb.27.1672769901940; Tue, 03 Jan 2023 10:18:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672769901; cv=none; d=google.com; s=arc-20160816; b=bcUCp8Vjoi60E6Zk9N9hFtCtWmzA2tFoC7lmaVnZzdWoA8C7G8z6FDlxiXpiMhLY7e RaXTqonxoYQ6SqJ+JMIf0L63SFkOuEOl5YUNd3R9FlNMdWeQgS9r0fZX26mDsn+/cmbx fuZsvvTdO34eFl6UvmqJzHIdkAafK3CWTyRORzxIYmVRjih2CgRKkuzlGfcfYd9H8gTI a/0uWL4XNORVsrewj31X3eCA1QDotwTWbRjmYe8O7jOMLS/dijLcHgQ6qtNsXRmGGKwq bhiRT9ZO7CS1CRdAbwIeX+GbJ1TtR4BJleZLqHcPRHG8+UXGVk0PcXnHQ+t7eb/dZwq7 BkUA== 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=XAGObJvGqrVWdz2gSKRqPWH5ISliRfssMEo9w+SvRe8=; b=A0+Maj+ko4l0wg+TL0xHjxdWNbajXEkSd9gViVzW6JeE0cKdx1D6wRKgStE6scT4wo PM75oLz1ShASvYrPSnchl0vRGoDwCH1d6tI/vvN0kQxa+r6ZIvW72hXcSofsX0t/9BzV X7Rptojgp5vetM73Y7cP2/McDiLbOw1q2nBiRUrCkjMtaDELcwVj9mwVO81U34P0+HA/ QZ/222AeyxFOwQSHOOTnCrlvRj+tu/pd/vxidwK/r9yixi05t5zVO72+4LYMUrmboApk jYoVDmI7Aft7KLibHkeNGj4tby3W25x95adQg3FjPeY8jYmULVUnvdHZthBzvO8hhZ1D KGmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LSS15VX8; 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 fw4-20020a05622a4a8400b0039ce973b0ebsi17178194qtb.486.2023.01.03.10.18.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:18:21 -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=LSS15VX8; 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 1pClrX-0008Sn-By; Tue, 03 Jan 2023 13:18:11 -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 1pClqg-0008I4-3r for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:22 -0500 Received: from mail-vs1-xe31.google.com ([2607:f8b0:4864:20::e31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClqd-0005CK-OG for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:17 -0500 Received: by mail-vs1-xe31.google.com with SMTP id p30so26963198vsr.1 for ; Tue, 03 Jan 2023 10:17:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=XAGObJvGqrVWdz2gSKRqPWH5ISliRfssMEo9w+SvRe8=; b=LSS15VX8SvVQ+6ffZOzSViYP69YP+saEqdoygB8fwAc6jswtQeJSJ6qJloX7DYA2Zy YblpNcvR4aUxzxgtCDs8LI9+U8K9ZjZClFS/sgHjptiN6CqhLHOs4kj1NI4wJhcXfE7Y B1+3PVaB55jCD+rNEF4sIx+7poEl+7VxbvdV4tN56VgfqVzpz01eerbTUtiqEN5PvYmO WQ8joL72c7SROTgmin2IJ/Km7JNXEuyEDKjmRXecMERKhWqYNfb2NtVUs426OM8sg8yB AGOzJQZZr+BJr/x2u2zdhf3lN0ZSIVf7IysOdcn1nI3htifxCvU9lqLYGIgrZpTMPH1v oCCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=XAGObJvGqrVWdz2gSKRqPWH5ISliRfssMEo9w+SvRe8=; b=I22wefYmUr/93AiRNf5Hh/aN5mWAvPXb6/cTVON09HJvCWXWlyOxvRvy+ghmWdId1P mzkvj4wnOQLE4swRD9GJLAtREQWdxVdVw/MKW/EkphOqrPNjufesG19k41yN4Y+0Njeh Qd/FLfb89GHOJSbsoeEI4nE9+DmHLw3XedDsMHzUmrU+LxQ7Ixp4Dg0TtjI65lNJZqzF YLAp3N479xnicFtkGcSrCYw52uhbd0AgPUulY5LD3RzeMn9/937/zlvlMh+u+WHrrqNe DrVQu9d0vdrw92STHR6rbjoK6dvNf2WDyff6kr+vdXfE3PDSYxH18Nn/peUC4TqdyUY4 iEtQ== X-Gm-Message-State: AFqh2konLigUG7Crqs/cCcq4R6ROP6tv7KmvwaO0Pj6CAUYr4bZ0+WYR 5FdHyULaAxttJcj2t8nyV5f/NN76Yx4LkC+3CGA= X-Received: by 2002:a05:6102:a4a:b0:3cb:93d:406f with SMTP id i10-20020a0561020a4a00b003cb093d406fmr12585208vss.32.1672769834757; Tue, 03 Jan 2023 10:17:14 -0800 (PST) Received: from stoup.. ([2607:fb90:8060:51a2:184b:6e49:c396:be2]) by smtp.gmail.com with ESMTPSA id v2-20020a05620a440200b006fed2788751sm23042354qkp.76.2023.01.03.10.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:14 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net, armbru@redhat.com, ajones@ventanamicro.com, alex.bennee@linaro.org Subject: [RFC PATCH 08/40] target/arm: Pass ARMCPUClass to ARMCPUInfo.class_init Date: Tue, 3 Jan 2023 10:16:14 -0800 Message-Id: <20230103181646.55711-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230103181646.55711-1-richard.henderson@linaro.org> References: <20230103181646.55711-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::e31; envelope-from=richard.henderson@linaro.org; helo=mail-vs1-xe31.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 Streamline new instances of this hook, so that we always go through arm_cpu_leaf_class_init first, performing common tasks, and have resolved the ARMCPUClass. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/arm/cpu-qom.h | 2 +- target/arm/cpu.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index ae31289582..057978b9db 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -36,7 +36,7 @@ OBJECT_DECLARE_CPU_TYPE(ARMCPU, ARMCPUClass, ARM_CPU) typedef struct ARMCPUInfo { const char *name; void (*initfn)(Object *obj); - void (*class_init)(ObjectClass *oc, void *data); + void (*class_init)(ARMCPUClass *acc); } ARMCPUInfo; void arm_cpu_register_parent(const ARMCPUInfo *info, const char *parent); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index a2f59ac378..b16d9bbe47 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2253,11 +2253,15 @@ static void arm_cpu_instance_init(Object *obj) arm_cpu_post_init(obj); } -static void cpu_register_class_init(ObjectClass *oc, void *data) +static void arm_cpu_leaf_class_init(ObjectClass *oc, void *data) { ARMCPUClass *acc = ARM_CPU_CLASS(oc); + const ARMCPUInfo *info = data; - acc->info = data; + acc->info = info; + if (info->class_init) { + info->class_init(acc); + } } void arm_cpu_register_parent(const ARMCPUInfo *info, const char *parent) @@ -2268,7 +2272,7 @@ void arm_cpu_register_parent(const ARMCPUInfo *info, const char *parent) .instance_align = __alignof__(ARMCPU), .instance_init = arm_cpu_instance_init, .class_size = sizeof(ARMCPUClass), - .class_init = info->class_init ?: cpu_register_class_init, + .class_init = arm_cpu_leaf_class_init, .class_data = (void *)info, };