From nobody Fri Apr 4 05:39:01 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1740738570; cv=none; d=zohomail.com; s=zohoarc; b=SBS1MfvmYip/xCF6te0eNszyYd3+4coV0wae+P3cHNomOVZOop4sIFVKcv5m4tZrCkcge/N7JjaFKia8/N2ZM+duUR5Lv3RxCRQtzg9ZqSNc30RTRBXefywYoead9jeNyj8nyjUTtrTo23WlJeKX/MPgDi5p2S6pyN4qj2QiETw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1740738570; 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=JG12sEMPjVACJGQCfzGpQgx6hIJs69slmn7iwrCF27A=; b=mIxNtOFNwOR9xqWh8OZduBNikAwE4PNBxvA0PEXvhptRjVdPhxGCqty1O0anBKOR48+dj0+yzBitrojznEs4DjQ5tqidKQJrBVqdLO4lXrl5+ZrkgDXDM1uW+74oRYB7FJIkjGydMVc/JyGUJrOYyTgD6hynqx4VmauDL9bjubc= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1740738570333920.7235408119298; Fri, 28 Feb 2025 02:29:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tnxcE-0003Yb-Np; Fri, 28 Feb 2025 05:29:10 -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 1tnxbT-0002Qq-Pm for qemu-devel@nongnu.org; Fri, 28 Feb 2025 05:28:26 -0500 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 1tnxbR-00030E-NT for qemu-devel@nongnu.org; Fri, 28 Feb 2025 05:28:23 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-145-eRi6356MMFmGYVBaR3ybeA-1; Fri, 28 Feb 2025 05:28:19 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4393b6763a3so8276395e9.2 for ; Fri, 28 Feb 2025 02:28:18 -0800 (PST) Received: from [192.168.10.48] ([151.95.152.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43b7a28b6fbsm50902975e9.35.2025.02.28.02.28.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2025 02:28:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1740738501; 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=JG12sEMPjVACJGQCfzGpQgx6hIJs69slmn7iwrCF27A=; b=fohxVBJ9aQayRFbEIJWGarCRm7d84K8K1mJWBVtTzTEKhavzFS5PcC2jgtnQhBdGzigFWK 1kN986m8/tFPkXqA1urITf7yEfSwhu0LMIqpFcaagFz8qgfrf0HIHPpTwemb9GrJj42HvM QDrbtgI8qi3m1hd5CQW8OsoKqrA6j7A= X-MC-Unique: eRi6356MMFmGYVBaR3ybeA-1 X-Mimecast-MFC-AGG-ID: eRi6356MMFmGYVBaR3ybeA_1740738498 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740738497; x=1741343297; 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=JG12sEMPjVACJGQCfzGpQgx6hIJs69slmn7iwrCF27A=; b=LHgx1bORY1S7Eppiba5H9vazrnTRPThXESeEn6d1nHs4wrRI/4dgYSFZ/fflATuz/U c1sr5eB5n4koHQDRzKzF8EnrUyvukFb7Cd0FpSoTS/RtUH+44cWHEHuCLm9svUAatteG 8CydeQfCKUIWfpUbdnvuhZgWqPpXLVbDQZoDi9YZIFsfPvBG8VHctvz7w6RgFVFONHWH U8I9SqmOEOyIxJhP3lmM7s746k3vKzuIP5K41T23KORI0nNxsvm8wWtlLLKxpXCG6Spk PmWx5BP3Wu688b08kKo9U+UyvGvOaN7tL9FZ4YVreRKy+qEJSGLR0GrFOYgV5BV4mJPG rxsw== X-Gm-Message-State: AOJu0Yy0c0qtR9eXoUwy+0X8rASArXGdNYLShAE27yV6J6PGWz3t3Q0X WjiC4+ZZ4ciIMErQZzg7hY098kXOFySCrlfjW+UrFPAG6upXKcRWDaonXxRhgJrleYGMsUXx8n0 12lwjSs1KGKQ5SCCFZE2NK0uTrIGg+mH/U5fH+13ADAbEN5QL954erynBLFwSZXo/Pc56NY2C4c Lxy5zPgLPJntWhd92ld7XvtNjKyuoR75NM7kab2J8= X-Gm-Gg: ASbGnctE84a4Z41LFfZjWRnuaG8sKqPxs8a7KUUmXTnH17+2+KTf0t0dhYBDvsKEg3R tQsC8wjAWknBEzuvZAsmLOslhm3AzxM01sT2oDmXU+OljDHnqLGh4vRXeG3IoKqmeJJ2ngEykhj i29oBBL5+ItgSh8HitovD/cRiwuWI0dpNYeSdkbBBuW7oR/CA68HOkyLllPKg0+sWqoxLV+YBtQ ILVWPuJDZ8zlib4Hl518sTw2IA1qceLHAKePjBbSzn7Iv8NArwQMHz9UqRfv+1K2DrTUoh/+CKB I5m2LU4E0Xr9ftEySkwd X-Received: by 2002:a05:600c:3b0d:b0:439:88bb:d02d with SMTP id 5b1f17b1804b1-43ba66da7eemr19905135e9.2.1740738496615; Fri, 28 Feb 2025 02:28:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUggkzzfDrHhS+kyvlQShWY99m7oXONZTA5IDHUawzSwnaxSwcZg8rRQLU4muyZ7laTX0bzw== X-Received: by 2002:a05:600c:3b0d:b0:439:88bb:d02d with SMTP id 5b1f17b1804b1-43ba66da7eemr19904855e9.2.1740738496111; Fri, 28 Feb 2025 02:28:16 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 12/22] target/riscv: convert dynamic CPU models to RISCVCPUDef Date: Fri, 28 Feb 2025 11:27:36 +0100 Message-ID: <20250228102747.867770-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250228102747.867770-1-pbonzini@redhat.com> References: <20250228102747.867770-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.438, 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=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1740738572578019100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- target/riscv/cpu.c | 110 +++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 80 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index feff1c91a00..c605efa2b92 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -483,38 +483,7 @@ static void set_satp_mode_default_map(RISCVCPU *cpu) } #endif =20 -static void riscv_max_cpu_init(Object *obj) -{ - RISCVCPU *cpu =3D RISCV_CPU(obj); - CPURISCVState *env =3D &cpu->env; - - cpu->cfg.mmu =3D true; - cpu->cfg.pmp =3D true; - - env->priv_ver =3D PRIV_VERSION_LATEST; -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(RISCV_CPU(obj), - riscv_cpu_mxl(&RISCV_CPU(obj)->env) =3D=3D MXL_RV32 ? - VM_1_10_SV32 : VM_1_10_SV57); -#endif -} - #if defined(TARGET_RISCV64) -static void rv64_base_cpu_init(Object *obj) -{ - RISCVCPU *cpu =3D RISCV_CPU(obj); - CPURISCVState *env =3D &cpu->env; - - cpu->cfg.mmu =3D true; - cpu->cfg.pmp =3D true; - - /* Set latest version of privileged specification */ - env->priv_ver =3D PRIV_VERSION_LATEST; -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV57); -#endif -} - static void rv64_sifive_u_cpu_init(Object *obj) { RISCVCPU *cpu =3D RISCV_CPU(obj); @@ -715,43 +684,11 @@ static void rv64_xiangshan_nanhu_cpu_init(Object *obj) #endif } =20 -#ifdef CONFIG_TCG -static void rv128_base_cpu_init(Object *obj) -{ - RISCVCPU *cpu =3D RISCV_CPU(obj); - CPURISCVState *env =3D &cpu->env; - - cpu->cfg.mmu =3D true; - cpu->cfg.pmp =3D true; - - /* Set latest version of privileged specification */ - env->priv_ver =3D PRIV_VERSION_LATEST; -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV57); -#endif -} -#endif /* CONFIG_TCG */ - #endif /* !TARGET_RISCV64 */ =20 #if defined(TARGET_RISCV32) || \ (defined(TARGET_RISCV64) && !defined(CONFIG_USER_ONLY)) =20 -static void rv32_base_cpu_init(Object *obj) -{ - RISCVCPU *cpu =3D RISCV_CPU(obj); - CPURISCVState *env =3D &cpu->env; - - cpu->cfg.mmu =3D true; - cpu->cfg.pmp =3D true; - - /* Set latest version of privileged specification */ - env->priv_ver =3D PRIV_VERSION_LATEST; -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV32); -#endif -} - static void rv32_sifive_u_cpu_init(Object *obj) { RISCVCPU *cpu =3D RISCV_CPU(obj); @@ -3054,16 +2991,6 @@ void riscv_isa_write_fdt(RISCVCPU *cpu, void *fdt, c= har *nodename) } #endif =20 -#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_data =3D (void*) &((const RISCVCPUDef) { \ - .misa_mxl_max =3D (misa_mxl_max_), \ - }), \ - } - #define DEFINE_VENDOR_CPU(type_name, misa_mxl_max_, initfn) \ { \ .name =3D (type_name), \ @@ -3115,7 +3042,12 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .class_base_init =3D riscv_cpu_class_base_init, }, =20 - DEFINE_ABSTRACT_RISCV_CPU(TYPE_RISCV_DYNAMIC_CPU, TYPE_RISCV_CPU), + DEFINE_ABSTRACT_RISCV_CPU(TYPE_RISCV_DYNAMIC_CPU, TYPE_RISCV_CPU, + .cfg.mmu =3D true, + .cfg.pmp =3D true, + .priv_spec =3D PRIV_VERSION_LATEST, + ), + DEFINE_ABSTRACT_RISCV_CPU(TYPE_RISCV_VENDOR_CPU, TYPE_RISCV_CPU), DEFINE_ABSTRACT_RISCV_CPU(TYPE_RISCV_BARE_CPU, TYPE_RISCV_CPU, /* @@ -3143,15 +3075,23 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { #endif ), =20 + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_MAX, TYPE_RISCV_DYNAMIC_CPU, #if defined(TARGET_RISCV32) - DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_MAX, MXL_RV32, riscv_max_cpu_= init), + .misa_mxl_max =3D MXL_RV32, + .cfg.max_satp_mode =3D VM_1_10_SV32, #elif defined(TARGET_RISCV64) - DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_MAX, MXL_RV64, riscv_max_cpu_= init), + .misa_mxl_max =3D MXL_RV64, + .cfg.max_satp_mode =3D VM_1_10_SV57, #endif + ), =20 #if defined(TARGET_RISCV32) || \ (defined(TARGET_RISCV64) && !defined(CONFIG_USER_ONLY)) - DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_BASE32, MXL_RV32, rv32_base_cpu_= init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_BASE32, TYPE_RISCV_DYNAMIC_CPU, + .cfg.max_satp_mode =3D VM_1_10_SV32, + .misa_mxl_max =3D MXL_RV32, + ), + DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_IBEX, MXL_RV32, rv32_ibex_cpu_= init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_E31, MXL_RV32, rv32_sifive_e_= cpu_init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_E34, MXL_RV32, rv32_imafcu_no= mmu_cpu_init), @@ -3168,11 +3108,18 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { #endif =20 #if (defined(TARGET_RISCV64) && !defined(CONFIG_USER_ONLY)) - DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_MAX32, MXL_RV32, riscv_max_cpu_= init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_MAX32, TYPE_RISCV_DYNAMIC_CPU, + .cfg.max_satp_mode =3D VM_1_10_SV32, + .misa_mxl_max =3D MXL_RV32, + ), #endif =20 #if defined(TARGET_RISCV64) - DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_BASE64, MXL_RV64, rv64_base_cpu_= init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_BASE64, TYPE_RISCV_DYNAMIC_CPU, + .cfg.max_satp_mode =3D VM_1_10_SV57, + .misa_mxl_max =3D MXL_RV64, + ), + DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_E51, MXL_RV64, rv64_sifive_e_= cpu_init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_U54, MXL_RV64, rv64_sifive_u_= cpu_init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SHAKTI_C, MXL_RV64, rv64_sifive_u_= cpu_init), @@ -3182,7 +3129,10 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_XIANGSHAN_NANHU, MXL_RV64, rv64_xiangshan_= nanhu_cpu_init), #ifdef CONFIG_TCG - DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_BASE128, MXL_RV128, rv128_base_cpu= _init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_BASE128, TYPE_RISCV_DYNAMIC_CPU, + .cfg.max_satp_mode =3D VM_1_10_SV57, + .misa_mxl_max =3D MXL_RV128, + ), #endif /* CONFIG_TCG */ DEFINE_RISCV_CPU(TYPE_RISCV_CPU_RV64I, TYPE_RISCV_BARE_CPU, .misa_mxl_max =3D MXL_RV64, --=20 2.48.1