From nobody Thu Nov 28 10:38:03 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1693992078; cv=none; d=zohomail.com; s=zohoarc; b=Sxx1uAifvAtR/g33g5kO123plZGIWD7WK/perFASk012pgNeSH2EE990JuBG/46/XQrPP+ihh0+NG3Nb3d9L1SNOjl9uXBN1VrK6M4NHyRB08H5bo6JRXnrPMAy52E0lhNeBZjFVL8E/cYZfyvhwoX3kwgjs+5n/ZbTY0yn4RvE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693992078; h=Content-Transfer-Encoding:Cc: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=xYPq6qx4s6ZZjgcoC1MZVsiyv8qTGFaIklxyrZMhrc0=; b=A2iR6KD3H4WQVeU3m8vNEwcFIIX8xbP8u0eK0eP9Dyr1dIt0ol/VwhBDmzR8JQwjxZ85bzeVMeTSDJlVeTpnP6cUJl66vqe4pG5YYVMLwJOAkhFSvZqEZz+7+GlO7WjyaUU0WHmpuW5iBo866z0MNG16yUVj941hiNmEFzRamYc= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693992078770985.2990774926568; Wed, 6 Sep 2023 02:21:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qdogX-0005tO-BM; Wed, 06 Sep 2023 05:18:53 -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 1qdofh-0004CE-IV for qemu-devel@nongnu.org; Wed, 06 Sep 2023 05:18:02 -0400 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qdofW-0005qb-KO for qemu-devel@nongnu.org; Wed, 06 Sep 2023 05:18:00 -0400 Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-6c09d760cb9so707868a34.2 for ; Wed, 06 Sep 2023 02:17:48 -0700 (PDT) Received: from grind.. ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id n21-20020a9d6f15000000b006b75242d6c3sm6229228otq.38.2023.09.06.02.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Sep 2023 02:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693991867; x=1694596667; 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=xYPq6qx4s6ZZjgcoC1MZVsiyv8qTGFaIklxyrZMhrc0=; b=AS6E5weLSuASRrm5nA21qSRNEurmhLL93PKZlSTW+DQq+Hzfh6sU40MZliOMeGWXJM yjrgKG9WzwDtRrkHGHFQNCgY1W1Og7ychTIZmk6T1f5UQ3z4SVu8cxjVvLRrHotpeDPJ ar7MXS80/B9j34MNU9Vr/H3Avvb7PXP/BU49NRbMcbmDwD6AZcg7rcCw2OLAh2AuTrBX RdQIGh8iAsGjj2gbIGkALnfhrgKXxijWZV3k2MgyN8+6PCNMFE3kwapaRKiYGfkDJIfy d1z0vV0VqVt0eU914EA9FgBSWP+7OJsEyBpcm3V6MflokyAwxtDb0g7TWbvm/ffcRWXX yncA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693991867; x=1694596667; 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=xYPq6qx4s6ZZjgcoC1MZVsiyv8qTGFaIklxyrZMhrc0=; b=Yxo4jGanaU7PlThxEHnA7bLrmXTDyECbd6qBTeuc5Kfn3gCRpgHdNPtIID8Dj4jlGz /+slueUGPMjN9DYYIBSZ/mOPX91uBhr5rZlCwJEC06SoAB2vzgGLiUfX0Gv9jrUftWft 6Yyd/o56dYeB/oriLzfXJcXyKJ+h8CckKSLWvTi+WgioSCN0/4Yz8YVxakbhT9UYH/4k J942IPwqr7BjDgxaxJ2u6bTTLFUNkKR5mbfcrAPMwrAJiVbRISAfK2KrNE+u215KYAQw 47HNtnHk43gD7ROTuEGuAeNmYXoHTt5eVtJJJ53atSC6dLgjtLlYoficdcPerISAVWsJ 7E1Q== X-Gm-Message-State: AOJu0YzIaB7wYE6/dylpw1FRZFMJm7Z5NpQISqh6y4Jz1YEJ4HzsdlP1 FL/yZ9CEX+NIAIJfsEah0BTVKQHPZzyGKfFhfY8= X-Google-Smtp-Source: AGHT+IFZ0sGQG1die8gLsXN5BAHh3LA0SYSQa2CWTs8T0O+JktlLCdGtoHHuv9pQmHazuw6I+teLCA== X-Received: by 2002:a05:6830:1147:b0:6b0:c67c:96f3 with SMTP id x7-20020a056830114700b006b0c67c96f3mr14623549otq.18.1693991867380; Wed, 06 Sep 2023 02:17:47 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, philmd@linaro.org, Daniel Henrique Barboza Subject: [PATCH v2 16/19] target/riscv/cpu.c: make misa_ext_cfgs[] 'const' Date: Wed, 6 Sep 2023 06:16:43 -0300 Message-ID: <20230906091647.1667171-17-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230906091647.1667171-1-dbarboza@ventanamicro.com> References: <20230906091647.1667171-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::336; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x336.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=unavailable 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 @ventanamicro.com) X-ZM-MESSAGEID: 1693992080828100005 Content-Type: text/plain; charset="utf-8" The array isn't marked as 'const' because we're initializing their elements in riscv_cpu_add_misa_properties(), 'name' and 'description' fields. In a closer look we can see that we're not using these 2 fields after creating the MISA properties. And we can create the properties by using riscv_get_misa_ext_name() and riscv_get_misa_ext_description() directly. Remove the 'name' and 'description' fields from RISCVCPUMisaExtConfig and make misa_ext_cfgs[] a const array. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 8616c9e2f5..4875feded7 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1212,8 +1212,6 @@ static void riscv_cpu_init(Object *obj) } =20 typedef struct RISCVCPUMisaExtConfig { - const char *name; - const char *description; target_ulong misa_bit; bool enabled; } RISCVCPUMisaExtConfig; @@ -1317,7 +1315,7 @@ const char *riscv_get_misa_ext_description(uint32_t b= it) #define MISA_CFG(_bit, _enabled) \ {.misa_bit =3D _bit, .enabled =3D _enabled} =20 -static RISCVCPUMisaExtConfig misa_ext_cfgs[] =3D { +static const RISCVCPUMisaExtConfig misa_ext_cfgs[] =3D { MISA_CFG(RVA, true), MISA_CFG(RVC, true), MISA_CFG(RVD, true), @@ -1344,25 +1342,22 @@ void riscv_cpu_add_misa_properties(Object *cpu_obj) int i; =20 for (i =3D 0; i < ARRAY_SIZE(misa_ext_cfgs); i++) { - RISCVCPUMisaExtConfig *misa_cfg =3D &misa_ext_cfgs[i]; + const RISCVCPUMisaExtConfig *misa_cfg =3D &misa_ext_cfgs[i]; int bit =3D misa_cfg->misa_bit; - - misa_cfg->name =3D riscv_get_misa_ext_name(bit); - misa_cfg->description =3D riscv_get_misa_ext_description(bit); + const char *name =3D riscv_get_misa_ext_name(bit); + const char *desc =3D riscv_get_misa_ext_description(bit); =20 /* Check if KVM already created the property */ - if (object_property_find(cpu_obj, misa_cfg->name)) { + if (object_property_find(cpu_obj, name)) { continue; } =20 - object_property_add(cpu_obj, misa_cfg->name, "bool", + object_property_add(cpu_obj, name, "bool", cpu_get_misa_ext_cfg, cpu_set_misa_ext_cfg, NULL, (void *)misa_cfg); - object_property_set_description(cpu_obj, misa_cfg->name, - misa_cfg->description); - object_property_set_bool(cpu_obj, misa_cfg->name, - misa_cfg->enabled, NULL); + object_property_set_description(cpu_obj, name, desc); + object_property_set_bool(cpu_obj, name, misa_cfg->enabled, NULL); } } =20 --=20 2.41.0