From patchwork Thu Oct 12 04:10:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13418264 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D281ECDB46E for ; Thu, 12 Oct 2023 04:13:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qqn4B-0003Bb-Az; Thu, 12 Oct 2023 00:12:55 -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 1qqn48-00036x-Hn for qemu-devel@nongnu.org; Thu, 12 Oct 2023 00:12:52 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qqn45-0002YL-GY for qemu-devel@nongnu.org; Thu, 12 Oct 2023 00:12:52 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c888b3a25aso4806035ad.0 for ; Wed, 11 Oct 2023 21:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697083967; x=1697688767; 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=FISUM8C238VwtcyK4LjobR0ms9Q9ZXZpCUD5vDVe7iY=; b=bfxce6ZMUxxmEaw12L83R/EN/CYds0fe+jAR75TL074BtV3WbLqUGi16LfPy8+S5Nq ZcEGZjWAAwT92nvCQ3Xl4TIWFv5SkysIP5+HTtSHUi3LIiO4OOPdUT/2h0zMe34OdN4m PlKrImh1RqAteESHEv/zp+8AxC4mhy7VkGp2HKOw1G+lL/xeugHY5T5Uunz9kkfqW9I0 g6HLGHWUdGR4Q4r5kKJFm4uteK3rPPLWIzU9uFVLhULAsbGn20uBhu1IpkDsC5Boi5i7 Zj1yRkIo9zXHzhvvR1cSGoGV3hMp7cll3ZBN+UCXVztm8bsku+lSYItVENAllVRoPf2E CiDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697083967; x=1697688767; 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=FISUM8C238VwtcyK4LjobR0ms9Q9ZXZpCUD5vDVe7iY=; b=Wh5IjRXnbv5BJMCjZYAaHGN6Ny1YzCobfAp+jkvrlWyce+M//21xMcPfhQCa8qMWdH amU17bKB6Swm6XKfdpSf5kLwKraGphZ6FAEY07iVM39H3dfV4ineuyCD6jy0fOkbcZ04 1oXCfDa5E3dgIO6rAcnEd1eS1xcH1koe7oLM485qk2/cTG5siOAJgfHDLujHkSHf+YQA Zx2hXOP4uEmqgBNFhB9DJdigcJ23b855EHNyI70gkh74rQEruWdeeC0/39Na+GTtG0s2 e58LJI/kyM5GghtX57iHiDpQse/Np+B/hx7e83ZKC6mskpTTNa42jJ214/7bVlssSj4G yZcA== X-Gm-Message-State: AOJu0Ywt8faMFppJHGPmVBlzRnZmt1t11K7Pglnfer6gCJgSjn+jWUqt jMLKzDLN4Jn2iLCOD2M5Lo7A8oN7jlxmRA== X-Google-Smtp-Source: AGHT+IF6EMhEDxCZaJQf3VrHR3hY6MDG0ZisZOi1iHMn6RkPLgkCHBjj8jS5fAvywTWaojHq7sPc6A== X-Received: by 2002:a17:903:246:b0:1c0:b84d:3f73 with SMTP id j6-20020a170903024600b001c0b84d3f73mr23645112plh.53.1697083966781; Wed, 11 Oct 2023 21:12:46 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id ja20-20020a170902efd400b001c1f4edfb9csm726348plb.173.2023.10.11.21.12.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 21:12:45 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Andrew Jones , LIU Zhiwei , Alistair Francis Subject: [PULL 29/54] target/riscv/cpu.c: mark extensions arrays as 'const' Date: Thu, 12 Oct 2023 14:10:26 +1000 Message-ID: <20231012041051.2572507-30-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012041051.2572507-1-alistair.francis@wdc.com> References: <20231012041051.2572507-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=alistair23@gmail.com; helo=mail-pl1-x636.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel Henrique Barboza We'll need to export these arrays to the accelerator classes in the next patches. Mark them as 'const' now because they should not be modified at runtime. Note that 'riscv_cpu_options' will also be exported, but can't be marked as 'const', because the properties are changed via qdev_property_add_static(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Message-ID: <20230925175709.35696-8-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index d78f73aa55..d831dc375b 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1403,7 +1403,7 @@ typedef struct RISCVCPUMultiExtConfig { {.name = _name, .offset = CPU_CFG_OFFSET(_prop), \ .enabled = _defval} -static RISCVCPUMultiExtConfig riscv_cpu_extensions[] = { +static const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = { /* Defaults for standard extensions */ MULTI_EXT_CFG_BOOL("sscofpmf", ext_sscofpmf, false), MULTI_EXT_CFG_BOOL("Zifencei", ext_ifencei, true), @@ -1465,7 +1465,7 @@ static RISCVCPUMultiExtConfig riscv_cpu_extensions[] = { DEFINE_PROP_END_OF_LIST(), }; -static RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[] = { +static const RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[] = { MULTI_EXT_CFG_BOOL("xtheadba", ext_xtheadba, false), MULTI_EXT_CFG_BOOL("xtheadbb", ext_xtheadbb, false), MULTI_EXT_CFG_BOOL("xtheadbs", ext_xtheadbs, false), @@ -1483,7 +1483,7 @@ static RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[] = { }; /* These are experimental so mark with 'x-' */ -static RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] = { +static const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] = { /* ePMP 0.9.3 */ MULTI_EXT_CFG_BOOL("x-epmp", epmp, false), MULTI_EXT_CFG_BOOL("x-smaia", ext_smaia, false), @@ -1554,7 +1554,7 @@ static void cpu_get_multi_ext_cfg(Object *obj, Visitor *v, const char *name, } static void cpu_add_multi_ext_prop(Object *cpu_obj, - RISCVCPUMultiExtConfig *multi_cfg) + const RISCVCPUMultiExtConfig *multi_cfg) { object_property_add(cpu_obj, multi_cfg->name, "bool", cpu_get_multi_ext_cfg, @@ -1571,11 +1571,13 @@ static void cpu_add_multi_ext_prop(Object *cpu_obj, } static void riscv_cpu_add_multiext_prop_array(Object *obj, - RISCVCPUMultiExtConfig *array) + const RISCVCPUMultiExtConfig *array) { + const RISCVCPUMultiExtConfig *prop; + g_assert(array); - for (RISCVCPUMultiExtConfig *prop = array; prop && prop->name; prop++) { + for (prop = array; prop && prop->name; prop++) { cpu_add_multi_ext_prop(obj, prop); } } @@ -1616,11 +1618,13 @@ static void riscv_cpu_add_kvm_unavail_prop(Object *obj, const char *prop_name) } static void riscv_cpu_add_kvm_unavail_prop_array(Object *obj, - RISCVCPUMultiExtConfig *array) + const RISCVCPUMultiExtConfig *array) { + const RISCVCPUMultiExtConfig *prop; + g_assert(array); - for (RISCVCPUMultiExtConfig *prop = array; prop && prop->name; prop++) { + for (prop = array; prop && prop->name; prop++) { riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } } @@ -1683,7 +1687,7 @@ static void riscv_init_max_cpu_extensions(Object *obj) { RISCVCPU *cpu = RISCV_CPU(obj); CPURISCVState *env = &cpu->env; - RISCVCPUMultiExtConfig *prop; + const RISCVCPUMultiExtConfig *prop; /* Enable RVG, RVJ and RVV that are disabled by default */ set_misa(env, env->misa_mxl, env->misa_ext | RVG | RVJ | RVV);