From nobody Tue Nov 26 22:25:44 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=1704303889; cv=none; d=zohomail.com; s=zohoarc; b=L1ekz4iLaxxUgMTSRuwrZTzjslO2lTzs0FviUhDAI+TFozb+XQq0s+brrXWYRGb88VbuAgcYCUkVrh2P5w7HB3JgMAMDU7pNzYcyfqIcUPcW5TvuNKDcokLOl19VOtZGRZfFl1/TLXc4ADjKHWngQpWHzi8ZQ+mvAOfTMYNv91c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704303889; 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=P47JvB6Aj0fl5W0avy5vyCnxmg8G6WNczQqsL8+H3h8=; b=D1q8GoQ8vZ73HA1Z3zTh2nfI7uNm4le2I33VE+Y8ITDzmj4ZOdXiAk1TMYYcEONaAqH8K0A8jy3ZL24uxK26G4q8hS44nq0d5uQeKcJcVvdzNW/Sn4A9+QT+cR4eb7xTvy9FZJXAs6T8da78tFSZJ0Tv5JDpCTpAajYWWE/dmLY= 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 1704303889251920.7145762732978; Wed, 3 Jan 2024 09:44:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rL5Eg-00044z-HK; Wed, 03 Jan 2024 12:40:58 -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 1rL5ET-0002dD-JD for qemu-devel@nongnu.org; Wed, 03 Jan 2024 12:40:46 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rL5ER-0001cw-Vj for qemu-devel@nongnu.org; Wed, 03 Jan 2024 12:40:45 -0500 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6da4a923b1bso1434204b3a.2 for ; Wed, 03 Jan 2024 09:40:43 -0800 (PST) Received: from grind.. ([189.79.21.107]) by smtp.gmail.com with ESMTPSA id v3-20020aa78503000000b006d7f1ae421csm24042050pfn.145.2024.01.03.09.40.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 09:40:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1704303640; x=1704908440; 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=P47JvB6Aj0fl5W0avy5vyCnxmg8G6WNczQqsL8+H3h8=; b=hEc1mPU1/KBHEjewKhZBmnn4AcU/DPC6yp2eR+sLAEEPPYboar+hbtpLjdomESzMMh n0wbgPL6IC4eyb6JgRKvZt5kbrl/DM8QfvU661N8TjNXRUt7V5CmuiK3gm0gKA5UsfFu XvybqEhr2g8nQ50i3IPDIJU6v9wis/MVEYCEvIqT7LZNxRfzl3iWPYGkDyTYqtmSKDGS cACjzXYRNPcpb7NKwQySyDPR8RKKDQ5gz57JwHMmso0HzH0Sbc3MRdDS/oQ8GpXW3qv+ 4I/tNkbVpvcGOufiWA0EuZ8RVAigK/lmZPzSR7qBTlPFWNCDThipoOesw4pcjpL8rKmK xv4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704303640; x=1704908440; 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=P47JvB6Aj0fl5W0avy5vyCnxmg8G6WNczQqsL8+H3h8=; b=Pw3zPuiLc2df4NspVUDsHaF8x6ui6AFbRX+B2348JQ4mSiB9Dh6q0CslXvfeWKB+Wn hyQ6OynQUWCgbIdnwc6LO8bxZ14mspOPVSixQyd/wMmGKhxKymUwMQJ8rMepxTO9gU+E x/mccmzE+847L2MZGkg7GDXaZJo27wP+5JbHxiaY0lsezieRZgIlZYjmfqHOefl8/GaG ahxOxwSDKM0HsHrZw3wYzLl4rMJEx568bfoYtgcNCh5qT1bJ25ADC2cJiOCqYGy5X3Q4 h6vd3k/JivIHSEB8imlUrhPnjchyiraV3Wz4k2EP2j+BfDL30bGfYI9Tc6qQb11zdC9P 7PPQ== X-Gm-Message-State: AOJu0YwErHGYKVd5h8OvXHZGRcCiHZzE3XYrVUoOHBs/yT23Or7bVstm 994Kq9sbeM2YfdrcdBFaf5Z8/8kV620heOajQ9arzWZpg5DL+g== X-Google-Smtp-Source: AGHT+IHttDU/YhKaWoA/ylMBkfm9rzgHOYvBgFx5NXAngAqcnieC4a+nU3efuNM69s82WG0q5RvbQg== X-Received: by 2002:a62:5f86:0:b0:6d9:c16b:207c with SMTP id t128-20020a625f86000000b006d9c16b207cmr5616662pfb.10.1704303640157; Wed, 03 Jan 2024 09:40:40 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, vladimir.isaev@syntacore.com, Daniel Henrique Barboza Subject: [PATCH v3 05/16] target/riscv: move 'pmp' to riscv_cpu_properties[] Date: Wed, 3 Jan 2024 14:40:02 -0300 Message-ID: <20240103174013.147279-6-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103174013.147279-1-dbarboza@ventanamicro.com> References: <20240103174013.147279-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::431; envelope-from=dbarboza@ventanamicro.com; helo=mail-pf1-x431.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1704303890098100001 Content-Type: text/plain; charset="utf-8" Move 'pmp' to riscv_cpu_properties[], creating a new setter() for it that forbids 'pmp' to be changed in vendor CPUs, like we did with the 'mmu' option. We'll also have to manually set 'pmp =3D true' to generic CPUs that were still relying on the previous default to set it. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 9f1407b73f..01b3b57cee 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -420,6 +420,7 @@ static void riscv_max_cpu_init(Object *obj) RISCVMXL mlx =3D MXL_RV64; =20 cpu->cfg.mmu =3D true; + cpu->cfg.pmp =3D true; =20 #ifdef TARGET_RISCV32 mlx =3D MXL_RV32; @@ -439,6 +440,7 @@ static void rv64_base_cpu_init(Object *obj) CPURISCVState *env =3D &cpu->env; =20 cpu->cfg.mmu =3D true; + cpu->cfg.pmp =3D true; =20 /* We set this in the realise function */ riscv_cpu_set_misa(env, MXL_RV64, 0); @@ -568,6 +570,7 @@ static void rv128_base_cpu_init(Object *obj) } =20 cpu->cfg.mmu =3D true; + cpu->cfg.pmp =3D true; =20 /* We set this in the realise function */ riscv_cpu_set_misa(env, MXL_RV128, 0); @@ -584,6 +587,7 @@ static void rv32_base_cpu_init(Object *obj) CPURISCVState *env =3D &cpu->env; =20 cpu->cfg.mmu =3D true; + cpu->cfg.pmp =3D true; =20 /* We set this in the realise function */ riscv_cpu_set_misa(env, MXL_RV32, 0); @@ -1596,9 +1600,38 @@ static const PropertyInfo prop_mmu =3D { .set =3D prop_mmu_set, }; =20 -Property riscv_cpu_options[] =3D { - DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), +static void prop_pmp_set(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + bool value; + + visit_type_bool(v, name, &value, errp); =20 + if (cpu->cfg.pmp !=3D value && riscv_cpu_is_vendor(obj)) { + cpu_set_prop_err(cpu, name, errp); + return; + } + + cpu_option_add_user_setting(name, value); + cpu->cfg.pmp =3D value; +} + +static void prop_pmp_get(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + bool value =3D RISCV_CPU(obj)->cfg.pmp; + + visit_type_bool(v, name, &value, errp); +} + +static const PropertyInfo prop_pmp =3D { + .name =3D "pmp", + .get =3D prop_pmp_get, + .set =3D prop_pmp_set, +}; + +Property riscv_cpu_options[] =3D { DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), DEFINE_PROP_STRING("vext_spec", RISCVCPU, cfg.vext_spec), =20 @@ -1618,6 +1651,7 @@ static Property riscv_cpu_properties[] =3D { {.name =3D "pmu-num", .info =3D &prop_pmu_num}, /* Deprecated */ =20 {.name =3D "mmu", .info =3D &prop_mmu}, + {.name =3D "pmp", .info =3D &prop_pmp}, =20 #ifndef CONFIG_USER_ONLY DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC), --=20 2.43.0