From nobody Tue Dec 16 11:42:44 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1745826128; cv=none; d=zohomail.com; s=zohoarc; b=a8MrbwgKS3QRm2ZStwW7YUlioyabgCvboGseNCouNybu6YattlXqLFktPua3wjB+Fs4Zoh8UYq/mryurxWZqEulvQE4bKg4VEnWbFJ3RPpOBFbyxRp/C6iDR4bEtkGNVkJdiOg29b9EEfnAX3lxJckFqZtGTlJKk5Ci1pP4oohg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745826128; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tf6Wtd7Zeg686LjseDJ7I7VG+SHXJ9oiE4YrRyhx9/Y=; b=ayWCZrrbCMHFjLH5fB6BvFtfJ/ePCPEuJmxnaxIVSRePbixAF+WzCG4C9C8CpZ2MVuCdDXbj6iTWPj0O0w3VMTGR1TPUiHj6XK64wtmKljtVNH1OeFPMm2Zr23Wm/c7TU6vyK7tshGXltIKptP7kiiXbZ98Q+m1F8a9Jh00U3JU= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174582612875235.33351416088715; Mon, 28 Apr 2025 00:42:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9J1V-0006IF-1Z; Mon, 28 Apr 2025 03:35:32 -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 1u9J1C-0005rm-I9 for qemu-devel@nongnu.org; Mon, 28 Apr 2025 03:35:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9J1A-00019V-TG for qemu-devel@nongnu.org; Mon, 28 Apr 2025 03:35:10 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-427-wBeNztlGMrW2rW3vLid-KQ-1; Mon, 28 Apr 2025 03:35:04 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-39c1b1c0969so2714317f8f.1 for ; Mon, 28 Apr 2025 00:35:04 -0700 (PDT) Received: from [192.168.122.1] ([151.95.54.106]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a073cbedb9sm10138452f8f.44.2025.04.28.00.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Apr 2025 00:35:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1745825706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tf6Wtd7Zeg686LjseDJ7I7VG+SHXJ9oiE4YrRyhx9/Y=; b=VptWn7Wx586UQQlxxRB9diS0PcFDF+q+9qnhSEnf3pH0gI+i4vXciUsH2zCJLdk0q9Faj6 R8y9RvG7pYvhEeEYGocxcdFcQdvmK8Yxa8qptfOSTfvu8jMmgWOlMsmn5ZYV/DsDJg72jI VimEsxf0+WEvQG0Nuk/05n5xJx62r2I= X-MC-Unique: wBeNztlGMrW2rW3vLid-KQ-1 X-Mimecast-MFC-AGG-ID: wBeNztlGMrW2rW3vLid-KQ_1745825703 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745825702; x=1746430502; 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=tf6Wtd7Zeg686LjseDJ7I7VG+SHXJ9oiE4YrRyhx9/Y=; b=Pa+HOx/9UK7QYXB1vqinN2wP2lDv+nAfjDhqNRaCWS0XfLZJvTD9VhfwWm41QvWg3o 746JbaTX3QwL5nueJ2S2/RFncky3fJZJIM5laBhlxOfGV1avKNjEQv19+HhwaPezbDqt 5Wj+xF3EdVdALYMA6R8mQk+H0OHvVYaOP1f0cwito8ZPpzpSe8EL2lZX6su7s6A68cHn pHKxaSxuX51HZQ499BN8vSSYiLh8OMiPn4Cmt79LKaAnB/DRTxWSFbFtgZbIYD7NEQkq R9sefrqFH81lyAkLjs5wMxSgnIrBUOklQMn93xLGjmr9nukOQVaN8khYnvl5TAMPweeP KxWw== X-Gm-Message-State: AOJu0YzriIEqaBPDfj8dTT+p0W5A2ctDgBqiZ5i1VNefSTWm/FSng1WL WSLos2I5bbsFFugR6ekUqlXFPcwRx5K0mQhrspHgyZLK/SX5VtkDsKb+xjCPwXs/34kJjvYbpS5 /6uhTeF7luJfEGTOJmhAoiOBUUcweXCey90REUuRjbgiU+ouKGKRILNw6uEg2SOM5V7rWHde6og FrcFK0Nzm9iW4Tn5JMoOtoG1vBzeJjoaJljRpC X-Gm-Gg: ASbGnct9bZCX/Kg2gtm8CkgMxBEKCkdSfef+X658qxGVjdWoZy6Uu9qQF1ba+U8ERK6 toDpyFC/MbxPMkML+QmzxJOPf1eqWF+7ZL0kArCyuiOzEOlG+Fz4DEsWsAWgPjEAFyta17+3H2g IQWcNIvFfnO5dYVoox4NJgTBdbP1i1Z0+zQznRXwm2dlfB/lotEux4inKiGbA20OTf2e5rZxzS8 aHOjt5NE+Qr6YXqu90TNPelVgSydAzqnUfgoiCJtKXgtEC/pbSKeUinPKcobkSeYzp/j9FNuhz8 rn4IagLnJC+aZ1M= X-Received: by 2002:a05:6000:2905:b0:390:e7c1:59c4 with SMTP id ffacd0b85a97d-3a07aa690bamr5589045f8f.13.1745825702586; Mon, 28 Apr 2025 00:35:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHoZYpKyKXQO3ty2aokjOl7KorbPq4HOTB0XCyztA4KbJ3SdqYEe7/rZvcEi3+Qk6VkATTIqA== X-Received: by 2002:a05:6000:2905:b0:390:e7c1:59c4 with SMTP id ffacd0b85a97d-3a07aa690bamr5589005f8f.13.1745825702027; Mon, 28 Apr 2025 00:35:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, dbarboza@ventanamicro.com Subject: [PATCH 07/26] target/riscv: introduce RISCVCPUDef Date: Mon, 28 Apr 2025 09:34:22 +0200 Message-ID: <20250428073442.315770-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250428073442.315770-1-pbonzini@redhat.com> References: <20250428073442.315770-1-pbonzini@redhat.com> MIME-Version: 1.0 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.492, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1745826218737019100 Content-Type: text/plain; charset="utf-8" Start putting all the CPU definitions in a struct. Later this will replace instance_init functions with declarative code, for now just remove the ugly cast of class_data. Reviewed-by: Alistair Francis Signed-off-by: Paolo Bonzini --- target/riscv/cpu.h | 4 ++++ target/riscv/cpu.c | 27 ++++++++++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 97dc3ba7811..62e303f0635 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -537,6 +537,10 @@ struct ArchCPU { const GPtrArray *decoders; }; =20 +typedef struct RISCVCPUDef { + RISCVMXL misa_mxl_max; /* max mxl for this cpu */ +} RISCVCPUDef; + /** * RISCVCPUClass: * @parent_realize: The parent class' realize handler. diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index ab6ee39d304..f30cf1b532b 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -3074,8 +3074,9 @@ static void riscv_cpu_common_class_init(ObjectClass *= c, const void *data) static void riscv_cpu_class_init(ObjectClass *c, const void *data) { RISCVCPUClass *mcc =3D RISCV_CPU_CLASS(c); + const RISCVCPUDef *def =3D data; =20 - mcc->misa_mxl_max =3D (RISCVMXL)GPOINTER_TO_UINT(data); + mcc->misa_mxl_max =3D def->misa_mxl_max; riscv_cpu_validate_misa_mxl(mcc); } =20 @@ -3171,40 +3172,48 @@ void riscv_isa_write_fdt(RISCVCPU *cpu, void *fdt, = char *nodename) } #endif =20 -#define DEFINE_DYNAMIC_CPU(type_name, misa_mxl_max, initfn) \ +#define DEFINE_DYNAMIC_CPU(type_name, misa_mxl_max_, initfn) \ { \ .name =3D (type_name), \ .parent =3D TYPE_RISCV_DYNAMIC_CPU, \ .instance_init =3D (initfn), \ .class_init =3D riscv_cpu_class_init, \ - .class_data =3D GUINT_TO_POINTER(misa_mxl_max) \ + .class_data =3D &((const RISCVCPUDef) { \ + .misa_mxl_max =3D (misa_mxl_max_), \ + }), \ } =20 -#define DEFINE_VENDOR_CPU(type_name, misa_mxl_max, initfn) \ +#define DEFINE_VENDOR_CPU(type_name, misa_mxl_max_, initfn) \ { \ .name =3D (type_name), \ .parent =3D TYPE_RISCV_VENDOR_CPU, \ .instance_init =3D (initfn), \ .class_init =3D riscv_cpu_class_init, \ - .class_data =3D GUINT_TO_POINTER(misa_mxl_max) \ + .class_data =3D &((const RISCVCPUDef) { \ + .misa_mxl_max =3D (misa_mxl_max_), \ + }), \ } =20 -#define DEFINE_BARE_CPU(type_name, misa_mxl_max, initfn) \ +#define DEFINE_BARE_CPU(type_name, misa_mxl_max_, initfn) \ { \ .name =3D (type_name), \ .parent =3D TYPE_RISCV_BARE_CPU, \ .instance_init =3D (initfn), \ .class_init =3D riscv_cpu_class_init, \ - .class_data =3D GUINT_TO_POINTER(misa_mxl_max) \ + .class_data =3D &((const RISCVCPUDef) { \ + .misa_mxl_max =3D (misa_mxl_max_), \ + }), \ } =20 -#define DEFINE_PROFILE_CPU(type_name, misa_mxl_max, initfn) \ +#define DEFINE_PROFILE_CPU(type_name, misa_mxl_max_, initfn) \ { \ .name =3D (type_name), \ .parent =3D TYPE_RISCV_BARE_CPU, \ .instance_init =3D (initfn), \ .class_init =3D riscv_cpu_class_init, \ - .class_data =3D GUINT_TO_POINTER(misa_mxl_max) \ + .class_data =3D &((const RISCVCPUDef) { \ + .misa_mxl_max =3D (misa_mxl_max_), \ + }), \ } =20 static const TypeInfo riscv_cpu_type_infos[] =3D { --=20 2.49.0