From nobody Thu Apr 3 11:41:33 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1741139996; cv=none; d=zohomail.com; s=zohoarc; b=AXIF3UDyd4LDLaXFqvGtjo8iyOtNaYVtjy9U/KsVYzKaGu9KYMNfkSBXjc+mO0O4mA9SCCMy7odQ8e44uoLLjBrnNFs9r72D6YxoeBxnxR3OnV/oQkixuicpbSx/xxfGZx0LVORuQfUSAo0gL11QZEf/MBE+wmjNKxGV/L5xsIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741139996; 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=O4wTDWyRukJNFQg7ktARpeS3eUQxJqwAuPTgYYQtFxQ=; b=nY6YpV8xFsBnh53TU+0FEYulZzlTYgHfyeKsOkL1So7Shxvs3Z9Zur+E3/E5KiUhlFKgyxQQa0cJIYOSd+9uNnQlhePlG5fduNJwccsaWg8HS42za6tYllHkP8GLNKLD3V+MoAoM8FaYnNVKpBp+LEhYVKobMPAsu/3GPQfVZsE= 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 1741139996802509.5624342476797; Tue, 4 Mar 2025 17:59:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tpdxP-00024Q-5h; Tue, 04 Mar 2025 20:53:59 -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 1tpdxL-0001wg-U8 for qemu-devel@nongnu.org; Tue, 04 Mar 2025 20:53:56 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tpdxK-0008Q8-5E for qemu-devel@nongnu.org; Tue, 04 Mar 2025 20:53:55 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-22339936bbfso93833725ad.1 for ; Tue, 04 Mar 2025 17:53:53 -0800 (PST) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-223501f9e04sm102583695ad.87.2025.03.04.17.53.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Mar 2025 17:53:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741139632; x=1741744432; 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=O4wTDWyRukJNFQg7ktARpeS3eUQxJqwAuPTgYYQtFxQ=; b=b7IYSkREh0KJaxIzS0UAmdKrdo6XKtET5NjtFS84jLFk0Bv71095713VZ6zokj6qz1 2AdGwyoHJfkrpgrgTjC/lVpqGjwQ7g5YEiGRhCnJTFockQbUFahOYkLElt9frDhP9Vc1 My6T55a1uhtVigpF2FzpEn42yiF1doORm0BgTGIibUz10OLRGDLHJ2YmJMjDNk+sC4Ly VHuoWr4cHTGGUZucgtfz6EhcOwqfe8V2KNuzrTef/DgL9lXceqB3LbD1Rh1nSM9o7y2U uCVQ3YfjJMTwY5mqIsMgLMFGaxElRE1EwJz2NqH6A9inJmLxNbtRO07ImrpLOXc26UHa AkcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741139632; x=1741744432; 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=O4wTDWyRukJNFQg7ktARpeS3eUQxJqwAuPTgYYQtFxQ=; b=QbKCP+352B5+D6mCgMSG1jyBvGkckNmr83BQA1yF2ZrvZhAObFYIX4JnryenOQBYnk cxLlVli0mWPtNokRnAS8VlmHKeQSewgprcSK220lJGuz6GPOAWT55TO57TS7wDurDFc6 4opzh+EWllcbzOxzSCSTLMzcKOK2YDVYzUaG7XZ4+2bmdqGAI3xSjrl+0S/QMGmbSgKW t4nWYNeUANbz7zzooyW+Kpq7MIsLYh/19q+v4IdgG5m8QD2we+427psnlvP+oRpxLnM7 G82zysSieidCv9TUiGbbomjYvyXKGlRw4+yTfg9MepnU+SwfPxqGLqKh8b0Yb5xlGgTY 68wQ== X-Gm-Message-State: AOJu0YwqNeMbS9FUHWVL5/rmSlqISpSvI1jfLgCpayZaR1Em+qblanMG pMApN6SpUTgYb7MZwYHRB39bLGENY9YN/8g01+As28njPWjAzYmbg6r5IjMVOYg= X-Gm-Gg: ASbGncsQp4BT/8/nPEsnCUe4Aw6PQ882CCRBQgrJJ9NTJouKzN3FPF2OmIvba0vQwtA J4pmTGj9bRKVRqrZfv5UVnciTE90WUzLRkwy7rjU9ypOrc7xqcF7oIstn+9q2uKZmePIWMMIyCI m1nh0dn+FU0gjcFevBZENltuxsuK2gYRNgMv7qUtDCqers8Zn0sGc9oblS3qAH6qQiiX+Dm8vY0 Zo/qEGzHHOQcJp8U7h6cqbVNrT5uhvc+kkVnW9ox8p0lVwOECeYF3WN4KC9lCIjFYqZg1zp9sQd EWad0/XSKIEdIRxiVsbAxinAYno4JJLsE2f0RHHsudLmXcM/d6KdUPJY0TJ7SAQCwxtW2PJ8sCx IRLFtFEo7DqmkSS3DXLnjxqEAgEQrBH+Azd7Jkw86K/pRvE0wOLA= X-Google-Smtp-Source: AGHT+IF68F3AuHg0GczcHwvN7WSGgFCnnjrkmQWCgJuyfSdY/kdmKtMe1f+tcL46B4VTrZwki741dA== X-Received: by 2002:a17:902:ec82:b0:223:66bb:8995 with SMTP id d9443c01a7336-223f1c95124mr19962015ad.20.1741139632443; Tue, 04 Mar 2025 17:53:52 -0800 (PST) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Andrew Jones , Alistair Francis Subject: [PULL 13/59] target/riscv: add profile u_parent and s_parent Date: Wed, 5 Mar 2025 11:52:21 +1000 Message-ID: <20250305015307.1463560-14-alistair.francis@wdc.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250305015307.1463560-1-alistair.francis@wdc.com> References: <20250305015307.1463560-1-alistair.francis@wdc.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::629; envelope-from=alistair23@gmail.com; helo=mail-pl1-x629.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1741139998054019100 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza The current 'parent' mechanic for profiles allows for one profile to be a child of a previous/older profile, enabling all its extensions (and the parent profile itself) and sparing us from tediously listing all extensions for every profile. This works fine for u-mode profiles. For s-mode profiles this is not enough: a s-mode profile extends not only his equivalent u-mode profile but also the previous s-mode profile. This means, for example, that RVA23S64 extends both RVA23U64 and RVA22S64. To fit this usage, rename the existing 'parent' to 'u_parent' and add a new 's_parent' attribute for profiles. Handle both like we were doing with the previous 'parent' attribute, i.e. if set, enable it. This change does nothing for the existing profiles but will make RVA23S64 simpler. Suggested-by: Andrew Jones Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Alistair Francis Message-ID: <20250115184316.2344583-4-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 3 ++- target/riscv/cpu.c | 6 ++++-- target/riscv/tcg/tcg-cpu.c | 35 ++++++++++++++++++++++++++--------- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 97713681cb..986131a191 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -81,7 +81,8 @@ const char *riscv_get_misa_ext_description(uint32_t bit); #define CPU_CFG_OFFSET(_prop) offsetof(struct RISCVCPUConfig, _prop) =20 typedef struct riscv_cpu_profile { - struct riscv_cpu_profile *parent; + struct riscv_cpu_profile *u_parent; + struct riscv_cpu_profile *s_parent; const char *name; uint32_t misa_ext; bool enabled; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 578bc95652..7b708bd010 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -2343,7 +2343,8 @@ static const PropertyInfo prop_marchid =3D { * doesn't need to be manually enabled by the profile. */ static RISCVCPUProfile RVA22U64 =3D { - .parent =3D NULL, + .u_parent =3D NULL, + .s_parent =3D NULL, .name =3D "rva22u64", .misa_ext =3D RVI | RVM | RVA | RVF | RVD | RVC | RVB | RVU, .priv_spec =3D RISCV_PROFILE_ATTR_UNUSED, @@ -2375,7 +2376,8 @@ static RISCVCPUProfile RVA22U64 =3D { * The remaining features/extensions comes from RVA22U64. */ static RISCVCPUProfile RVA22S64 =3D { - .parent =3D &RVA22U64, + .u_parent =3D &RVA22U64, + .s_parent =3D NULL, .name =3D "rva22s64", .misa_ext =3D RVS, .priv_spec =3D PRIV_VERSION_1_12_0, diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index d7e694fdb3..2b21942ef2 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -713,13 +713,29 @@ static bool riscv_cpu_validate_profile_satp(RISCVCPU = *cpu, } #endif =20 +static void riscv_cpu_check_parent_profile(RISCVCPU *cpu, + RISCVCPUProfile *profile, + RISCVCPUProfile *parent) +{ + const char *parent_name; + bool parent_enabled; + + if (!profile->enabled || !parent) { + return; + } + + parent_name =3D parent->name; + parent_enabled =3D object_property_get_bool(OBJECT(cpu), parent_name, = NULL); + profile->enabled =3D parent_enabled; +} + static void riscv_cpu_validate_profile(RISCVCPU *cpu, RISCVCPUProfile *profile) { CPURISCVState *env =3D &cpu->env; const char *warn_msg =3D "Profile %s mandates disabled extension %s"; bool send_warn =3D profile->user_set && profile->enabled; - bool parent_enabled, profile_impl =3D true; + bool profile_impl =3D true; int i; =20 #ifndef CONFIG_USER_ONLY @@ -773,12 +789,8 @@ static void riscv_cpu_validate_profile(RISCVCPU *cpu, =20 profile->enabled =3D profile_impl; =20 - if (profile->parent !=3D NULL) { - parent_enabled =3D object_property_get_bool(OBJECT(cpu), - profile->parent->name, - NULL); - profile->enabled =3D profile->enabled && parent_enabled; - } + riscv_cpu_check_parent_profile(cpu, profile, profile->u_parent); + riscv_cpu_check_parent_profile(cpu, profile, profile->s_parent); } =20 static void riscv_cpu_validate_profiles(RISCVCPU *cpu) @@ -1190,8 +1202,13 @@ static void cpu_set_profile(Object *obj, Visitor *v,= const char *name, profile->user_set =3D true; profile->enabled =3D value; =20 - if (profile->parent !=3D NULL) { - object_property_set_bool(obj, profile->parent->name, + if (profile->u_parent !=3D NULL) { + object_property_set_bool(obj, profile->u_parent->name, + profile->enabled, NULL); + } + + if (profile->s_parent !=3D NULL) { + object_property_set_bool(obj, profile->s_parent->name, profile->enabled, NULL); } =20 --=20 2.48.1