From nobody Fri Dec 19 17:23:50 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1601566902; cv=none; d=zohomail.com; s=zohoarc; b=n38hKqlY8F/Q/iW+DObCbU+hyok2XaSZLqd0ymNU47tst88JDNJWo/74rVWjcWfDrxIIof+3a5pUIqLorkakqdWI01qDTk5jEuBPo+Nsa9O/OnJRglaIB8S0La4j389vlNnF7vO3wZsD9sssZVE6YYmzZqoDErJmqOewVEpHtGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601566902; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cvsmXOGHcKXV23YMgllN9zrk0dtzY5vA/uGDuKWBck8=; b=X9V70vmGuOuezWf/aqzpbPywKSYv3ecPnNzd/zI0pBNhVCbh5s9j9vJo144ZOgp4CC7dfEH9qFipnDw0d2iBebK41pLaO0p7fJpBYQ+Ut9BgFxJcGL/k7O+tP80L/ag6uYKvtrQf51xXYu0Xpa8sFZHpbJESqAWGyQ16Tcq9How= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160156690219959.160794938864; Thu, 1 Oct 2020 08:41:42 -0700 (PDT) Received: from localhost ([::1]:35934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kO02t-00034H-9I for importer@patchew.org; Thu, 01 Oct 2020 10:58:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNzse-0005EW-Qf for qemu-devel@nongnu.org; Thu, 01 Oct 2020 10:48:24 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:44852) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kNzsc-0002zr-S3 for qemu-devel@nongnu.org; Thu, 01 Oct 2020 10:48:24 -0400 Received: by mail-wr1-x443.google.com with SMTP id s12so6113675wrw.11 for ; Thu, 01 Oct 2020 07:48:22 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id 70sm342052wme.15.2020.10.01.07.48.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 07:48:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=cvsmXOGHcKXV23YMgllN9zrk0dtzY5vA/uGDuKWBck8=; b=TJm5QYdNe3lXkg6MpbgWYTioDHbyP06pyn8G1twFFoBqi2d0jXjwRKeMTuTqc5oZdO tabtPc/vSqEnDkuuMgEevfXJdgLjwoQWbJdc1VnikwIZXO2jlGPVzTsQb4zHazbQe6HQ WUMrnPn2kGLXBcMAfDK7O5KceU3RmvFCBIqEU3ukBvZa0xNsaU10Kv0rNto4o/hJ9gTe PxUVgR4gynmYnivdF9HsdZblOry5UjjiHIrJk+jyqWJk/Pa6uyeEVIGGJ9+sr/FyX4Ii G2jyXNAUFFR7kf3Pgntc4W3+3d8jL6lyYN+fnFP7MaU2VcqB8JcEOgBuivwv9t+RaJCp Bt8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cvsmXOGHcKXV23YMgllN9zrk0dtzY5vA/uGDuKWBck8=; b=jiCNrOrugtAJL3iw4vCv/ZS7p0cMgyKaZuVR0sBw/r7lBOwUxg1GOtYFgdcVz0pjfd byEadiBOAZUgV/l86kJuiBq43xS8s/wuSqdJlAWpSChd2PChDlFhB3dV0JgsAXL5h9tT jgz/OktylwcwoRKmvWcfB+P8RDu15f9Bgm4uNa9mymPZUqYtM0z1/LYMiUMM1+ajqnMv hnKgRLP47IVGaF6lm77in6AA884+VIGdzpp44ttwWeQgRIZPaKfeMHyDR6SBLs/DKiIF YSevYMCeg0rQzrKJvkIBfLZVdznL5sdUm1bEucahq3NCnK2NwrNW6uUnjE14qQ9fT7lQ 1KUQ== X-Gm-Message-State: AOAM532MhlKUmmlwzvtNJmL3ubCQ5/pwH1tWSVhRq0lQIuJlr1uc4qGA 1ENNNJuumI7QqFsZ1Q25F3/8LW1DNvzZSh4h X-Google-Smtp-Source: ABdhPJwVMoKJ1IVjhoDzyTolI04T8O66N3oMED+KNcJD381YwcRYGZDbWeNq8N0B+gIAktS1Fgbs0w== X-Received: by 2002:adf:dcc7:: with SMTP id x7mr9599452wrm.203.1601563701171; Thu, 01 Oct 2020 07:48:21 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 14/18] hw/arm/raspi: Avoid using TypeInfo::class_data pointer Date: Thu, 1 Oct 2020 15:47:55 +0100 Message-Id: <20201001144759.5964-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201001144759.5964-1-peter.maydell@linaro.org> References: <20201001144759.5964-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Philippe Mathieu-Daud=C3=A9 Using class_data pointer to create a MachineClass is not the recommended way anymore. The correct way is to open-code the MachineClass::fields in the class_init() method. We can not use TYPE_RASPI_MACHINE::class_base_init() because it is called *before* each machine class_init(), therefore the board_rev field is not populated. We have to manually call raspi_machine_class_common_init() for each machine. This partly reverts commit a03bde3674e. Suggested-by: Igor Mammedov Reviewed-by: Richard Henderson Reviewed-by: Igor Mammedov Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20200924111808.77168-5-f4bug@amsat.org Signed-off-by: Peter Maydell --- hw/arm/raspi.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 16e6c83c925..3000e6d57e6 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -306,13 +306,9 @@ static void raspi_machine_init(MachineState *machine) setup_boot(machine, version, machine->ram_size - vcram_size); } =20 -static void raspi_machine_class_init(ObjectClass *oc, void *data) +static void raspi_machine_class_common_init(MachineClass *mc, + uint32_t board_rev) { - MachineClass *mc =3D MACHINE_CLASS(oc); - RaspiMachineClass *rmc =3D RASPI_MACHINE_CLASS(oc); - uint32_t board_rev =3D (uint32_t)(uintptr_t)data; - - rmc->board_rev =3D board_rev; mc->desc =3D g_strdup_printf("Raspberry Pi %s (revision 1.%u)", board_type(board_rev), FIELD_EX32(board_rev, REV_CODE, REVISION)); @@ -326,18 +322,36 @@ static void raspi_machine_class_init(ObjectClass *oc,= void *data) mc->default_ram_id =3D "ram"; }; =20 +static void raspi2b_machine_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + RaspiMachineClass *rmc =3D RASPI_MACHINE_CLASS(oc); + + rmc->board_rev =3D 0xa21041; + raspi_machine_class_common_init(mc, rmc->board_rev); +}; + +#ifdef TARGET_AARCH64 +static void raspi3b_machine_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + RaspiMachineClass *rmc =3D RASPI_MACHINE_CLASS(oc); + + rmc->board_rev =3D 0xa02082; + raspi_machine_class_common_init(mc, rmc->board_rev); +}; +#endif /* TARGET_AARCH64 */ + static const TypeInfo raspi_machine_types[] =3D { { .name =3D MACHINE_TYPE_NAME("raspi2"), .parent =3D TYPE_RASPI_MACHINE, - .class_init =3D raspi_machine_class_init, - .class_data =3D (void *)0xa21041, + .class_init =3D raspi2b_machine_class_init, #ifdef TARGET_AARCH64 }, { .name =3D MACHINE_TYPE_NAME("raspi3"), .parent =3D TYPE_RASPI_MACHINE, - .class_init =3D raspi_machine_class_init, - .class_data =3D (void *)0xa02082, + .class_init =3D raspi3b_machine_class_init, #endif }, { .name =3D TYPE_RASPI_MACHINE, --=20 2.20.1