From nobody Thu May 9 12:31:27 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=1694525483; cv=none; d=zohomail.com; s=zohoarc; b=awWSZqfUlr+Sz6Q2uM2xNbQ779TXPZbQrtifuIQBoCjn5euAi+7nIwjPYgO8ba3UgU8FNwbhuNoU4nSIQw5YQ9M1oh7XxVnOz3jPooO8trmvdHznDXt9/2XseVA4DG83JSoP+MZtxqv+m/YHL56u24shuyo+mWUCGnEfi7sjRAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525483; 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=0N0oTIyVCTE0+WINtqk5L95k/7qBHpAfwshUNyTE0mY=; b=hcx5lnmwWoS3QPmpyntSreDyfrPByr+w4wrBDD09F2rFK5qBxkF5gOolBKjES5+5q5ud1QA7CLd7fmaC0lmPaKX8F4/pcwqunGsQ9gu2r3QrqUkEg3PJetqE90PIX3EtqgqcwQBkFCzEWeHrCx0JF43n7cAU+kkNRieTGByXL6k= 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 1694525482890282.1295904819639; Tue, 12 Sep 2023 06:31:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3O8-0002kV-M8; Tue, 12 Sep 2023 09:25:08 -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 1qg3Nh-0002YS-GM for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:24:45 -0400 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3Nd-0003Um-IP for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:24:41 -0400 Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-573912a7b14so3535757eaf.1 for ; Tue, 12 Sep 2023 06:24:35 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.24.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525074; x=1695129874; 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=0N0oTIyVCTE0+WINtqk5L95k/7qBHpAfwshUNyTE0mY=; b=JhFrfgbQF9FrCz9P0TFrF0ClKKhTNRz1g6qFUMbPBzcdl3oIUzyZiDLNfSDRM3ofOy 2JJMB0MHLJnlop5R/QJF2UMebQPZavN66x+sEE7aHn4MmrvPzFWjFHzCHSel+1VqZ8Be BP404PjHZlJxENChL0I7UxlKWJHJwJvmkK9c4Jz8+EnSoC0BhLgrrW7TUAf69YsaET2H Y8YKxanjpb9SWgYvu37FypSGwv/LWxpoj9VnQon9skoHdIuBFe621gGl5HpbgFqFqzpe 69eIGnT0AAiQUVnSx0G/HcrUNeFem2mA1NTKCtxaEEDcbxIA/wmSlh/KAS7BEwgxXC6t 3jgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525074; x=1695129874; 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=0N0oTIyVCTE0+WINtqk5L95k/7qBHpAfwshUNyTE0mY=; b=uOmj4UZi9DWfujllW8KFqqkJxPvNROREjX3WkyxRYQje9lUHgaUrKgftnahWplKDTs q6ugwRIQmyiM5BUJ8X0gJuTal0GFpGudxLPEb6LvBnY4defxItB1lTFIP7CGb2Mc5Nba MyabCxotcdp2xYZxwTQssmLp83qktd53lLh+oQjUJqqrOt8eS+4VA1/BdchYV+fUX1kA ASjeyJ9WfrixMKUGhAgDqoyfywRSOR4pRMkZUX54a+/ZYCcop0JMuePeX34IMRONoqZb Ddy2QHI6ws8CYhQtz9NduIUyzNmHMONwqGQyzox1H80OKicbwoaod6SDb3PN0L51H6s6 hL6A== X-Gm-Message-State: AOJu0YyOCylJdmGrCDMUvuIdEQRl7dDUa2/PBA/66PMZ3aNZWugfdiJ2 xP0vIsFmp2WIdYKWMwSTh8xQi1yW60WK6pprzV8= X-Google-Smtp-Source: AGHT+IHQCtdSaOk1+WbI54J6w1CNzvRoVhL1theg7KIEUOr0guwEbB3d2U8n/tcYI+hrPbF9gMgSyg== X-Received: by 2002:a05:6820:410:b0:576:8ae8:5dfc with SMTP id o16-20020a056820041000b005768ae85dfcmr7784393oou.4.1694525074149; Tue, 12 Sep 2023 06:24:34 -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 v10 01/20] target/riscv/cpu.c: split CPU options from riscv_cpu_extensions[] Date: Tue, 12 Sep 2023 10:24:04 -0300 Message-ID: <20230912132423.268494-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-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::c30; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc30.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: 1694525484053100002 Content-Type: text/plain; charset="utf-8" We'll add a new CPU type that will enable a considerable amount of extensions. To make it easier for us we'll do a few cleanups in our existing riscv_cpu_extensions[] array. Start by splitting all CPU non-boolean options from it. Create a new riscv_cpu_options[] array for them. Add all these properties in riscv_cpu_add_user_properties() as it is already being done today. 'mmu' and 'pmp' aren't really extensions in the usual way we think about RISC-V extensions. These are closer to CPU features/options, so move both to riscv_cpu_options[] too. In the near future we'll need to match all extensions with all entries in isa_edata_arr[], and so it happens that both 'mmu' and 'pmp' do not have a riscv,isa string (thus, no priv spec version restriction). This further emphasizes the point that these are more a CPU option than an extension. No functional changes made. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index f227c7664e..fdbd8eb0b8 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1810,7 +1810,6 @@ static void riscv_cpu_add_misa_properties(Object *cpu= _obj) =20 static Property riscv_cpu_extensions[] =3D { /* Defaults for standard extensions */ - DEFINE_PROP_UINT8("pmu-num", RISCVCPU, cfg.pmu_num, 16), DEFINE_PROP_BOOL("sscofpmf", RISCVCPU, cfg.ext_sscofpmf, false), DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true), DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true), @@ -1823,15 +1822,8 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("Zve32f", RISCVCPU, cfg.ext_zve32f, false), DEFINE_PROP_BOOL("Zve64f", RISCVCPU, cfg.ext_zve64f, false), DEFINE_PROP_BOOL("Zve64d", RISCVCPU, cfg.ext_zve64d, false), - DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), - DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), DEFINE_PROP_BOOL("sstc", RISCVCPU, cfg.ext_sstc, true), =20 - DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), - DEFINE_PROP_STRING("vext_spec", RISCVCPU, cfg.vext_spec), - DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128), - DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64), - DEFINE_PROP_BOOL("smstateen", RISCVCPU, cfg.ext_smstateen, false), DEFINE_PROP_BOOL("svadu", RISCVCPU, cfg.ext_svadu, true), DEFINE_PROP_BOOL("svinval", RISCVCPU, cfg.ext_svinval, false), @@ -1862,9 +1854,7 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("zhinxmin", RISCVCPU, cfg.ext_zhinxmin, false), =20 DEFINE_PROP_BOOL("zicbom", RISCVCPU, cfg.ext_icbom, true), - DEFINE_PROP_UINT16("cbom_blocksize", RISCVCPU, cfg.cbom_blocksize, 64), DEFINE_PROP_BOOL("zicboz", RISCVCPU, cfg.ext_icboz, true), - DEFINE_PROP_UINT16("cboz_blocksize", RISCVCPU, cfg.cboz_blocksize, 64), =20 DEFINE_PROP_BOOL("zmmul", RISCVCPU, cfg.ext_zmmul, false), =20 @@ -1918,6 +1908,21 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +static Property riscv_cpu_options[] =3D { + DEFINE_PROP_UINT8("pmu-num", RISCVCPU, cfg.pmu_num, 16), + + DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), + DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), + + DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), + DEFINE_PROP_STRING("vext_spec", RISCVCPU, cfg.vext_spec), + + DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128), + DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64), + + DEFINE_PROP_UINT16("cbom_blocksize", RISCVCPU, cfg.cbom_blocksize, 64), + DEFINE_PROP_UINT16("cboz_blocksize", RISCVCPU, cfg.cboz_blocksize, 64), +}; =20 #ifndef CONFIG_USER_ONLY static void cpu_set_cfg_unavailable(Object *obj, Visitor *v, @@ -1986,6 +1991,14 @@ static void riscv_cpu_add_user_properties(Object *ob= j) #endif qdev_property_add_static(dev, prop); } + + for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { + /* Check if KVM created the property already */ + if (object_property_find(obj, riscv_cpu_options[i].name)) { + continue; + } + qdev_property_add_static(dev, &riscv_cpu_options[i]); + } } =20 static Property riscv_cpu_properties[] =3D { --=20 2.41.0 From nobody Thu May 9 12:31:27 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=1694527317; cv=none; d=zohomail.com; s=zohoarc; b=QbH0w/rS2KvEo98/63Ig8xs0szdQg8eUmtRiyu4oZ7vsxxsiPd63ii2TrdxLgPgalbrEESX40v6Mq0X6rYeXWc82Is67Y/GRAoEtnlRgOQmNcQVJ701p/4h1NblKi6atkrP//n7TX4qsYrz6m52f58xgLR0n5LG5fsNa0G/HiTM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694527317; 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=wQilM6mPMPBt/et0RgnK1omGUy9pg15ijboQ1qTt70s=; b=LTjn2grXEwwHG05SSdjFgXxnpZ6g8knh/9kAzWllgw+8hkL0bKr6zIgGShbmZaCu3oUdBIgYqxtjvR3fkplV+gdic8tYLq9WuEFIPHybbfA4faJB5UqxrIMeaIw/AWfOJFVBCKRb7Mbf+SNlXCtcYp7Tpd8eSUoeVEHklb3wrzE= 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 1694527317546649.8252443169979; Tue, 12 Sep 2023 07:01:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3O8-0002kU-Ld; Tue, 12 Sep 2023 09:25:08 -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 1qg3Nj-0002aw-Gn for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:24:48 -0400 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3Nf-0003VO-Fu for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:24:42 -0400 Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-573449a364fso3581284eaf.1 for ; Tue, 12 Sep 2023 06:24:38 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:24:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525077; x=1695129877; 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=wQilM6mPMPBt/et0RgnK1omGUy9pg15ijboQ1qTt70s=; b=WHRI4pVngeMuGjkDwP7Kaf8yVKBF0RgysxrA2ezJj/g99s/5C2TkbjNYa7/sHyjnFL fZcS15WILshYGDA0+ZtCYy6KXuknEznQ1gcvuGRZcvOjS7ZcD54wRng6zFZ7w9gzObby Ed9hvvfdqN+RMar/84mSBMp4b/OGaz0dvFHGzu5N/e4KjAB9AGZTnroJg73kck4/UoAC QJWbKKk9m357EqZhWl19hTaqn7m1T4Sz3l0kpwUYQrkPzIhKF9ztHwlBjJSfl9VKtLLx HhGj8OBNDDkh4oLNeP34tRimC+j2G4H5qixGEOjk3z8vbiNyieDy9O3x3MsDv63CG6tg 1SsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525077; x=1695129877; 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=wQilM6mPMPBt/et0RgnK1omGUy9pg15ijboQ1qTt70s=; b=INfC7VR18qE3rC/2+EMwMh67WyC4nTGJ+kl+6MRsyxzCz9A7erWSvmvRijl2rkvFwb y2KKozIj7hoiQd4wDnohgnhHM20N2Mc3OCtO8SfoRvrq95ydaAM/u1DdReQD6WYveo4q K7FuOQRY6zaoWUKtGZ2Vrjj7tSkyrAKSfYnPznc0aJBA4GNrDUyELV56TyAoL3SovGCL OYGnGusVcdqreGEXbEkOUOqEH2WP5FhJAlgtc6iM4Ko7nOciMIuKJnBwJbI4iCqDsITV Ez3D4V7mALxMAdUu08g/4nf9uyqTjqu2X841rWkic5hOBCrlPOQY6UHvPDPcentZfNIQ jqSw== X-Gm-Message-State: AOJu0YzNJfwbHOROyW5eaKfL3BuGa2DSHDU6y/L3RG+qu68C5hja/fa4 lnWSTSW3I1oF6Hq40ShQzBbLPEMK2gmGWvZkD5Q= X-Google-Smtp-Source: AGHT+IEhIRsjiBLGWqBkMGBIwsgZYVA2LFF+ugYIEGG/Pfex9f7/IBhZsIuzPts0KjCXVJa5IyiDow== X-Received: by 2002:a4a:340b:0:b0:571:1fad:ebe0 with SMTP id b11-20020a4a340b000000b005711fadebe0mr12910403ooa.3.1694525077567; Tue, 12 Sep 2023 06:24:37 -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 v10 02/20] target/riscv/cpu.c: skip 'bool' check when filtering KVM props Date: Tue, 12 Sep 2023 10:24:05 -0300 Message-ID: <20230912132423.268494-3-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-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::c2d; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc2d.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: 1694527337924100001 Content-Type: text/plain; charset="utf-8" After the introduction of riscv_cpu_options[] all properties in riscv_cpu_extensions[] are booleans. This check is now obsolete. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index fdbd8eb0b8..db640e7460 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1976,17 +1976,11 @@ static void riscv_cpu_add_user_properties(Object *o= bj) * Set the default to disabled for every extension * unknown to KVM and error out if the user attempts * to enable any of them. - * - * We're giving a pass for non-bool properties since they're - * not related to the availability of extensions and can be - * safely ignored as is. */ - if (prop->info =3D=3D &qdev_prop_bool) { - object_property_add(obj, prop->name, "bool", - NULL, cpu_set_cfg_unavailable, - NULL, (void *)prop->name); - continue; - } + object_property_add(obj, prop->name, "bool", + NULL, cpu_set_cfg_unavailable, + NULL, (void *)prop->name); + continue; } #endif qdev_property_add_static(dev, prop); --=20 2.41.0 From nobody Thu May 9 12:31:27 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=1694525273; cv=none; d=zohomail.com; s=zohoarc; b=ZnonTQdvQRVZ25hoUxMKTSqzQw9bWf8BxzX6OAsxvAMddfTczgoWgaar0AegCCK3k3/EVolPC4bt26V+X3Nmqq+WGSUbXZDV74Bu39ZBi1WV1RD8FqbevmsS6Z34sefPzUL2OFzY9APaW/KX/Cw/ShKXTAiPW8wA5lcTrQX15PU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525273; 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=xYMv3u9t6iklrr46zGtmAUTnviscaFaetm+bKYtnmrs=; b=VS1IXgzFDy9QYCmZNG47WIhpBFTW3dzQIONdNHFdPOkhdUtOvawwPenqyM6pqTFlyXczNJJIveaRbb9wCExpDGsYk6zGGFBoYvEYjAfFC0NbAtVQ7G/sGWlVl8BPo+TPQc0n5KteADkySc4HV9l8sfoLBaQ4x6GmA8+T6RzjcAc= 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 1694525273643335.66167152187313; Tue, 12 Sep 2023 06:27:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3OA-0002oI-Qw; Tue, 12 Sep 2023 09:25:10 -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 1qg3No-0002bj-Jo for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:24:49 -0400 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3Nj-0003Vx-9t for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:24:46 -0400 Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3ab7fb1172cso1812857b6e.3 for ; Tue, 12 Sep 2023 06:24:42 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525081; x=1695129881; 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=xYMv3u9t6iklrr46zGtmAUTnviscaFaetm+bKYtnmrs=; b=MMPm3SDer95yOX2xeSGtVQTU4C9Jtwhg0fx5wWcgVLeMsEIn4lH40mlfBluCkaVyC9 BF9n875qpj47SvUd4Ylo/tRSFnB4rkFpz3Vm3s7WuC49kly3bW6HlmHH3BaNIGx5ZrJh BXuwU5OQCLcw6P5b3Sl0Y2mvHpWD+lP3z23Y4ZUyUpvoLUAiaVVNTIU8InW7avK7c3t5 pFMoSY5zH8VZ2VrbAMXlxMN2u//s3DDMJYKFn8YQBKr57PnguWa2E4V8ppKvW38Mq5tv kBgm4zJ006Ew3qbfuvXa/4IFhCWpz0IkStR9fx3hcXbzdlJpwrmZHe0MC2Eq4m0Ilc9H YkIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525081; x=1695129881; 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=xYMv3u9t6iklrr46zGtmAUTnviscaFaetm+bKYtnmrs=; b=PqCNau3S0MCmKFJzgkrsyji4Ucc98QyoWhTpQ6liIpwn633XYA3wPQMB+FG1OFrosL ea26cRdXOW5pAQF8Bmk75KPVXiSchjCL0CIRPOqW0BTh42lEcc6TAKG5veGYVWj5BvdX n8IyPKaZifn+iZUU/nkIedaR9TqBQFSpE2lisqH7yEkK84u6KOicXajwWebd3wQUSRjY ezw+O+mCtX39O24iNC0WeYu9MPSmsuSVZXESSTv1GdQDKtHMdrLRCxkc59tuM/n58B2w 4nMtgS8Rt70p1U4Y3sCPaQFRoGPLN2lGsZm/YgkopKb8JBkqQ+2spYbddoi1CbPsrKeh tRCg== X-Gm-Message-State: AOJu0YzLlEUQbCPPG3sJsG4kwsOSByRyRVw3YBxXtCqeD+bkR5XwV0Gd o0V1kgB62W+/YcUhRq36z83eMRhZB88eJHXwTEI= X-Google-Smtp-Source: AGHT+IHsiC5EvG8vvqEh1WjSU5sh/C8MsoL8kwamCyYFlU8nZ18MLvcSuUN+5VtfXix5xQZPU/jfYQ== X-Received: by 2002:a05:6808:2099:b0:3a4:2941:b0d4 with SMTP id s25-20020a056808209900b003a42941b0d4mr15080289oiw.24.1694525080794; Tue, 12 Sep 2023 06:24:40 -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 v10 03/20] target/riscv/cpu.c: split kvm prop handling to its own helper Date: Tue, 12 Sep 2023 10:24:06 -0300 Message-ID: <20230912132423.268494-4-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-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::22f; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x22f.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: 1694525275046100003 Content-Type: text/plain; charset="utf-8" Future patches will split the existing Property arrays even further, and the existing code in riscv_cpu_add_user_properties() will start to scale bad with it because it's dealing with KVM constraints mixed in with TCG constraints. We're going to pay a high price to share a couple of common lines of code between the two. Create a new kvm_riscv_cpu_add_kvm_properties() helper that will be forked from riscv_cpu_add_user_properties() if we're running KVM. The helper includes all properties that a KVM CPU will add. The rest of riscv_cpu_add_user_properties() body will then be relieved from having to deal with KVM constraints. The helper was declared in kvm_stubs.h, while being implemented in cpu.c, to allow '--enable-debug' builds to work. The compiler won't remove the kvm_riscv_cpu_add_kvm_properties() reference when 'kvm_enabled()' is false if we end up with an unused function. Even though being a KVM only helper we can't implement it in kvm.c due to its many dependencies inside cpu.c, so make it public in kvm_riscv.h and keep its implementation in cpu.c for now. We'll move it to kvm.c in the near future. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 65 +++++++++++++++++++++++++--------------- target/riscv/kvm_riscv.h | 3 ++ 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index db640e7460..7b7c5649e7 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1924,7 +1924,7 @@ static Property riscv_cpu_options[] =3D { DEFINE_PROP_UINT16("cboz_blocksize", RISCVCPU, cfg.cboz_blocksize, 64), }; =20 -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_KVM static void cpu_set_cfg_unavailable(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -1941,6 +1941,44 @@ static void cpu_set_cfg_unavailable(Object *obj, Vis= itor *v, propname); } } + +static void riscv_cpu_add_kvm_unavail_prop(Object *obj, const char *prop_n= ame) +{ + /* Check if KVM created the property already */ + if (object_property_find(obj, prop_name)) { + return; + } + + /* + * Set the default to disabled for every extension + * unknown to KVM and error out if the user attempts + * to enable any of them. + */ + object_property_add(obj, prop_name, "bool", + NULL, cpu_set_cfg_unavailable, + NULL, (void *)prop_name); +} + +void kvm_riscv_cpu_add_kvm_properties(Object *obj) +{ + Property *prop; + DeviceState *dev =3D DEVICE(obj); + + kvm_riscv_init_user_properties(obj); + riscv_cpu_add_misa_properties(obj); + + for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { + riscv_cpu_add_kvm_unavail_prop(obj, prop->name); + } + + for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { + /* Check if KVM created the property already */ + if (object_property_find(obj, riscv_cpu_options[i].name)) { + continue; + } + qdev_property_add_static(dev, &riscv_cpu_options[i]); + } +} #endif =20 /* @@ -1958,39 +1996,18 @@ static void riscv_cpu_add_user_properties(Object *o= bj) riscv_add_satp_mode_properties(obj); =20 if (kvm_enabled()) { - kvm_riscv_init_user_properties(obj); + kvm_riscv_cpu_add_kvm_properties(obj); + return; } #endif =20 riscv_cpu_add_misa_properties(obj); =20 for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { -#ifndef CONFIG_USER_ONLY - if (kvm_enabled()) { - /* Check if KVM created the property already */ - if (object_property_find(obj, prop->name)) { - continue; - } - - /* - * Set the default to disabled for every extension - * unknown to KVM and error out if the user attempts - * to enable any of them. - */ - object_property_add(obj, prop->name, "bool", - NULL, cpu_set_cfg_unavailable, - NULL, (void *)prop->name); - continue; - } -#endif qdev_property_add_static(dev, prop); } =20 for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { - /* Check if KVM created the property already */ - if (object_property_find(obj, riscv_cpu_options[i].name)) { - continue; - } qdev_property_add_static(dev, &riscv_cpu_options[i]); } } diff --git a/target/riscv/kvm_riscv.h b/target/riscv/kvm_riscv.h index de8c209ebc..69e807fbfb 100644 --- a/target/riscv/kvm_riscv.h +++ b/target/riscv/kvm_riscv.h @@ -19,6 +19,9 @@ #ifndef QEMU_KVM_RISCV_H #define QEMU_KVM_RISCV_H =20 +/* Temporarily implemented in cpu.c */ +void kvm_riscv_cpu_add_kvm_properties(Object *obj); + void kvm_riscv_init_user_properties(Object *cpu_obj); void kvm_riscv_reset_vcpu(RISCVCPU *cpu); void kvm_riscv_set_irq(RISCVCPU *cpu, int irq, int level); --=20 2.41.0 From nobody Thu May 9 12:31:27 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=1694525212; cv=none; d=zohomail.com; s=zohoarc; b=THhTIwX8Nevx0qhyxIBh7l0C+Txw1QrTpeL6kYg8lyiTIvJkpK3XbQlpWSbYFrvGStqAfeD39vrm+ZzA7El4e00w2zzaHVd0m19UaG3f5GrA+ZdysjuinVGX0fD9L3XvtDbXzXEfIHPpZpvoeIYpWV46aXO9EB1uyBNflm7hfL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525212; h=Content-Type: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=WvsMcO8KkAzI7CkHtZ53zjQmejmQZZMo5A4ybg1pjI0=; b=k1sEdlt6RVTQimKd7QNKNthjY+Hw8NaRjmkuAqqNlMl1abcbJ5sQjWaieb/ZTtH88KkizSovAKtQcHLr0zPgJvY952iBi9dhjvkPi/BJ+YqPgwVA3kgyeZxscoItBKyJ5it315cYQIoT+ggjvoxd8lSBP5rVVVNpGkz4iWXzRK0= 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 1694525212557778.9810658428836; Tue, 12 Sep 2023 06:26:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3OB-0002pB-Kn; Tue, 12 Sep 2023 09:25:11 -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 1qg3Nr-0002dH-5A for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:24:57 -0400 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3Nl-0003Wq-PS for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:24:50 -0400 Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3a76d882052so3979048b6e.0 for ; Tue, 12 Sep 2023 06:24:45 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:24:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525084; x=1695129884; 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=WvsMcO8KkAzI7CkHtZ53zjQmejmQZZMo5A4ybg1pjI0=; b=onpdLreClKU1L0Dz8ZyMDYW/QA+zT8aDdhB5Y4FB8CR/zLjxuuYnhroZsr2mXTMR+/ SiJOQYY3uIcqM3dTpa6c5QEIrdj3UFRZ8+Q06RNO0QY5c6mOgmfFI2P7HipOS3i0JX97 tbpNFNv+Wc5r2sNCyt6KqXPjTyUzs24NIM7L3J3nL3Hn0yddeE7qRAHkMSOomstJAfds DgRtlipbc7/ZReZ1u8PtE9wkJvPPhCSHE0ah9eQk4G4Q1s9x6f/jzPJPg7CkJUPQTnFt pmZfctrLWRNyB6wyPnJg8DMilq39uWjPfKY5YDn13Cj0efig7PD4OjnrAjxUgGC36sNe Pemg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525084; x=1695129884; 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=WvsMcO8KkAzI7CkHtZ53zjQmejmQZZMo5A4ybg1pjI0=; b=vJftyIabCZ6wtRKtDFPHaNdVzZHuJwyLkiTdx/5T0z0gmuIRP+iP7MQa0HhVL0Ij4o mfOy6jjNc/482vUGIljA+HNeHXJDD3hOAbRXA17aoLNvS/hb5acf23NlFcAn//g1AlQg ul16Q9yVCwTeIHgjJ+XxOqLxb9L12SThw3clvKPjQMwG7Iv//xBrkDgc/ZoZQSyug3AD fDeBNbWBfz5Zcxg5QsWuiUltFJ28Q2JUvruv8N24zvtMPSv87OdVQ7s+lubnrO0tgQEz neu5SILrhwM29N2rRAidMSjtuCuyz1tq9+UyZevgPPLgaNvP2rBcVRNkSbp5VsFEJlC0 TWLA== X-Gm-Message-State: AOJu0YzjnQzxiJSuJRl5yDCsM2pfPCr6RjiJ9lwFmcPoDzdtSKurAWVx kxrXQDqM9HbC8pntGu61musCeDJqxj2ZuAbIbac= X-Google-Smtp-Source: AGHT+IE4OLN59CX5OVpwU8jOfnjJU2GCp9nne/ipDTQ2G8MOWrPRmSYPiz5Szi6Ih86TmjgTrzXvfQ== X-Received: by 2002:a54:4006:0:b0:3a7:3ea1:b597 with SMTP id x6-20020a544006000000b003a73ea1b597mr12683867oie.27.1694525084299; Tue, 12 Sep 2023 06:24:44 -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 v10 04/20] target/riscv: add DEFINE_PROP_END_OF_LIST() to riscv_cpu_options[] Date: Tue, 12 Sep 2023 10:24:07 -0300 Message-ID: <20230912132423.268494-5-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::22d; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x22d.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: 1694525214121100003 Add DEFINE_PROP_END_OF_LIST() and eliminate the ARRAY_SIZE() usage when iterating in the riscv_cpu_options[] array, making it similar to what we already do when working with riscv_cpu_extensions[]. We also have a more sophisticated motivation behind this change. In the future we might need to export riscv_cpu_options[] to other files, and ARRAY_LIST() doesn't work properly in that case because the array size isn't exposed to the header file. Here's a future sight of what we would deal with: ./target/riscv/kvm.c:1057:5: error: nested extern declaration of 'riscv_cpu= _add_misa_properties' [-Werror=3Dnested-externs] n file included from ../target/riscv/kvm.c:19: home/danielhb/work/qemu/include/qemu/osdep.h:473:31: error: invalid applica= tion of 'sizeof' to incomplete type 'const RISCVCPUMultiExtConfig[]' 473 | #define ARRAY_SIZE(x) ((sizeof(x) / sizeof((x)[0])) + \ | ^ ./target/riscv/kvm.c:1047:29: note: in expansion of macro 'ARRAY_SIZE' 1047 | for (int i =3D 0; i < ARRAY_SIZE(_array); i++) { \ | ^~~~~~~~~~ ./target/riscv/kvm.c:1059:5: note: in expansion of macro 'ADD_UNAVAIL_KVM_P= ROP_ARRAY' 1059 | ADD_UNAVAIL_KVM_PROP_ARRAY(obj, riscv_cpu_extensions); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ home/danielhb/work/qemu/include/qemu/osdep.h:473:31: error: invalid applica= tion of 'sizeof' to incomplete type 'const RISCVCPUMultiExtConfig[]' 473 | #define ARRAY_SIZE(x) ((sizeof(x) / sizeof((x)[0])) + \ | ^ ./target/riscv/kvm.c:1047:29: note: in expansion of macro 'ARRAY_SIZE' 1047 | for (int i =3D 0; i < ARRAY_SIZE(_array); i++) { \ Homogenize the present and change the future by using DEFINE_PROP_END_OF_LIST() in riscv_cpu_options[]. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/riscv/cpu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 7b7c5649e7..ad6ce2c2dc 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1922,6 +1922,8 @@ static Property riscv_cpu_options[] =3D { =20 DEFINE_PROP_UINT16("cbom_blocksize", RISCVCPU, cfg.cbom_blocksize, 64), DEFINE_PROP_UINT16("cboz_blocksize", RISCVCPU, cfg.cboz_blocksize, 64), + + DEFINE_PROP_END_OF_LIST(), }; =20 #ifdef CONFIG_KVM @@ -1971,12 +1973,12 @@ void kvm_riscv_cpu_add_kvm_properties(Object *obj) riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } =20 - for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { + for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { /* Check if KVM created the property already */ - if (object_property_find(obj, riscv_cpu_options[i].name)) { + if (object_property_find(obj, prop->name)) { continue; } - qdev_property_add_static(dev, &riscv_cpu_options[i]); + qdev_property_add_static(dev, prop); } } #endif @@ -2007,8 +2009,8 @@ static void riscv_cpu_add_user_properties(Object *obj) qdev_property_add_static(dev, prop); } =20 - for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { - qdev_property_add_static(dev, &riscv_cpu_options[i]); + for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { + qdev_property_add_static(dev, prop); } } =20 --=20 2.41.0 From nobody Thu May 9 12:31:27 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=1694525229; cv=none; d=zohomail.com; s=zohoarc; b=j4/6sgHXcpgkOYSaP0XNQomCHS2MwSPIutlUiBmzO7iU5ewZ3CjsEI5LvGvFbfUlBJ8a/E7GDqu2OSfpKlfMua8ef56OX5wT7MU+A9yloiUCApKTzeyO6sjdqQwMtRwc+t+NowG8Jhz+wmNr6i6+U7Kml+wgZJ5nYXwf0ZItW/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525229; 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=QaCaFXk3n/oGC56SB04wOyUmvqISdJZ1At/AtPnxTwI=; b=f39vmFkr08Y3amQjG5kAmy6okYsT7IEuCvxFiwboBape1ObqAyK76vtsCsf1Rl+VFNbc3jjs1gkFWnzNh0ERPJZI2+9igABiOOp2/Ht5NrKkS4+c9F7EcSBaXWbODLCRqLT1OAAPdZHtDe2l+5qnCmp07IvWyf8yMy2SK3uk5Pc= 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 1694525229456817.1106259147318; Tue, 12 Sep 2023 06:27:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3OA-0002oK-QY; Tue, 12 Sep 2023 09:25:10 -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 1qg3Nx-0002fS-GM for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:00 -0400 Received: from mail-ot1-x32e.google.com ([2607:f8b0:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3Nq-0003XR-QO for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:24:54 -0400 Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-6c07e122a78so3898305a34.2 for ; Tue, 12 Sep 2023 06:24:48 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:24:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525088; x=1695129888; 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=QaCaFXk3n/oGC56SB04wOyUmvqISdJZ1At/AtPnxTwI=; b=LzA/jlT3oxBa2wDvgLL4iAj86+2OYT5waQvD0MTuLTeDS4DfJbBeRAN+hKKporg+56 SYtpzRH3qxqUVLx6AgxMETGWGiUjBOKzxAwdyrPD5NpZm3eGM8qGAMW3fqaBz0gxlv6m hRpW8C0syQmJzrLvOAU5obGFILECSDF4lndU5EZqh0MFmYwnOzu/d/y/XArauEaCPBxP uHZTrLG5aNw6+FzOE35BQPuR3wpcmZ5HFPUKCDGBEfRN9+d2rQ6m1gAKU92a6PQ3WGwN LHQSOdClZWa/v+6hMKmM2DSdPtEYyEoxT8CwjquSCz5Cp5ZKP7MoiEio8b40H1Cx9WX+ 0RBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525088; x=1695129888; 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=QaCaFXk3n/oGC56SB04wOyUmvqISdJZ1At/AtPnxTwI=; b=n/HEJITUDHPBNjjQO406TQjK84/Mg+PfIObqY2PzKRIZHWM8obUJiY92tpVBZW8FLB lEkRh7KqETIpz7LSKBinFS6MVj0IfQBQaOGZMCllLG3qmhIxFoZCUwDQwTJbmXpFoZc2 Q7CW70wadAC5mrTILpCNuJoexryoztl4UNGqGuXMc1zC819m4qfD+2znnFkNSVRd2y/8 tPWLk6gRdnJueerjXzmSfk2k82rKgBVVbZR1F3SL+mY5P2m5+JkseBxU6JugUSHIVIp1 zRNg/7Bp2MduZhCgcVUJw/u/IFNowAO1z1oPJ2uYInjg14mCtA9GKI+vpbvFeH2hjhjI Rulg== X-Gm-Message-State: AOJu0Yx/ycRukv3l8JY+nvTrEnhThtV6EQQmZqa+ZvFSIi0OO8bc6s9e i3IxuJkO1XgvZWiIjdnNxiAjq2EYyvkTBEtPl3g= X-Google-Smtp-Source: AGHT+IHBGoGxIOSkUcF80+mHKflRSMIeRjUVju+eevyApYFSJHIspX5TLnAreckBL5UWEbeOYC8LWA== X-Received: by 2002:a9d:6653:0:b0:6b9:b1a7:1f92 with SMTP id q19-20020a9d6653000000b006b9b1a71f92mr14010786otm.8.1694525087740; Tue, 12 Sep 2023 06:24: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 v10 05/20] target/riscv/cpu.c: split non-ratified exts from riscv_cpu_extensions[] Date: Tue, 12 Sep 2023 10:24:08 -0300 Message-ID: <20230912132423.268494-6-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-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::32e; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x32e.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: 1694525231283100003 Content-Type: text/plain; charset="utf-8" Create a new riscv_cpu_experimental_exts[] to store the non-ratified extensions properties. Once they are ratified we'll move them back to riscv_cpu_extensions[]. riscv_cpu_add_user_properties() and riscv_cpu_add_kvm_properties() are changed to keep adding non-ratified properties to users. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index ad6ce2c2dc..83b44900a5 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1881,8 +1881,11 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("xtheadsync", RISCVCPU, cfg.ext_xtheadsync, false), DEFINE_PROP_BOOL("xventanacondops", RISCVCPU, cfg.ext_XVentanaCondOps,= false), =20 - /* These are experimental so mark with 'x-' */ + DEFINE_PROP_END_OF_LIST(), +}; =20 +/* These are experimental so mark with 'x-' */ +static Property riscv_cpu_experimental_exts[] =3D { /* ePMP 0.9.3 */ DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false), DEFINE_PROP_BOOL("x-smaia", RISCVCPU, cfg.ext_smaia, false), @@ -1973,6 +1976,10 @@ void kvm_riscv_cpu_add_kvm_properties(Object *obj) riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } =20 + for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { + riscv_cpu_add_kvm_unavail_prop(obj, prop->name); + } + for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { /* Check if KVM created the property already */ if (object_property_find(obj, prop->name)) { @@ -2012,6 +2019,10 @@ static void riscv_cpu_add_user_properties(Object *ob= j) for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { qdev_property_add_static(dev, prop); } + + for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { + qdev_property_add_static(dev, prop); + } } =20 static Property riscv_cpu_properties[] =3D { --=20 2.41.0 From nobody Thu May 9 12:31:27 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=1694525262; cv=none; d=zohomail.com; s=zohoarc; b=XBsVgdmJL/AdgOIFBYQ7inQ79L8yYRWoDJudTELQ6M9MmRnBU+/PzTi6qtAbXvcLzzZMEKhtOs+6Bu6hI69+wJGJLPnaTu7XLqIIFO0keUlTalbci0x3jV+ixCTbBC6ibjdHueCq1LA9CRy9hVlhbLW9kvmp/86ZqKC3/cYGvKA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525262; 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=PEnrPGnN8UgdKRZchTMIfrKsvseI97NnNCUUb/fgNms=; b=eti269eds6CUP/hkZuyFKNBW1FyMa1p3n5w+E9TguRRkzQr4fD6qUbaBL7STe6U7TNEYth+xfUkcOLW/sr/vhRBJNMN+qEAzRfuRl1314zp5nwWVMH/KRBqN/80AMAe3w3+waalfKCJTYt+JWuPXIKjTly2GANCAv0zhZbVJRCo= 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 1694525262644288.9203924930307; Tue, 12 Sep 2023 06:27:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3OB-0002pF-NK; Tue, 12 Sep 2023 09:25:11 -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 1qg3Nx-0002fV-HN for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:00 -0400 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3Ns-0003YO-Pg for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:24:54 -0400 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-6bdacc5ed66so2973548a34.1 for ; Tue, 12 Sep 2023 06:24:52 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525091; x=1695129891; 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=PEnrPGnN8UgdKRZchTMIfrKsvseI97NnNCUUb/fgNms=; b=kT5yyXRw3O+jCANVxE8bpkF4IIddQikPL8PGQZaStXGBp+nlVxUQxMUsjWjM2QGfxJ eykbNNGV8J7rFm7pSX4gGZCzNImGPSeRQ+zzLFSkLNOeuFQ2EjPhizazDQLPNadHFexD 1hrAElwIzwyuG4zjnsXaUM7j9S5UTE3mD6/M61mahs3YChugnHQSUTLhYU8VDNevuYVg G6+X5OgHFwaAtqp9vYAoC3DZReaE/axwOiqBe0Jc4FRh+QvtNDJ0CsDl1/avgCfa8IAt duQEBkwb85CUP1pWFrMH9MLYB4Xvr0vef2dLuOVcRx2OhgoIn7++IeW+BBMkfT/lXn0e nQ7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525091; x=1695129891; 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=PEnrPGnN8UgdKRZchTMIfrKsvseI97NnNCUUb/fgNms=; b=LJSzAojM8/h5aGQK0uCoQHHY7WqHswuRyoFpQHiybOypBHJItlkOlQMMNyqUROeg76 d8IjcPelSPvLH84yTMLTSmU+eVomA/prpr5Euga5fCgNlDuWMSv41BsSYWgRCBW5IhWR 0gJX+RhQu1WuUogNrAkvEDJbStr6cG+DSy3EcMgDJr1Gg7tgLotHUw6S7Cnz/yjIattT fBU+FBrx/JKXdCqH6mjxbEooHJKeWhMYbihzFmB65peHe8QM9DSZ0aVDR8zCuidamVru Iduws1RrdllpLpPB57aI+6UhtmBFiPcLjDkBVSBHuCY3sSMv87SwhBKW90yLxi4cOE22 7sGQ== X-Gm-Message-State: AOJu0Yz13C/rECqtE2tHSe5Z9jWWBty4SBdloON4mXG96mr8Ai6+Wfwk nbRTqQjFZI6ct5B2a5Qh+AF46C89mF4+D8ehAbs= X-Google-Smtp-Source: AGHT+IEOuOHUijHxMTiwgaTlUIIunTqeFOUKQU6g/1rWTeJZd/V5pJ+63gUbmGZXUuwU6DCpBO1HMQ== X-Received: by 2002:a05:6830:270b:b0:6bc:aec3:6eb1 with SMTP id j11-20020a056830270b00b006bcaec36eb1mr1722707otu.1.1694525091460; Tue, 12 Sep 2023 06:24:51 -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 v10 06/20] target/riscv/cpu.c: split vendor exts from riscv_cpu_extensions[] Date: Tue, 12 Sep 2023 10:24:09 -0300 Message-ID: <20230912132423.268494-7-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-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::32c; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x32c.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: 1694525263671100001 Content-Type: text/plain; charset="utf-8" Our goal is to make riscv_cpu_extensions[] hold only ratified, non-vendor extensions. Create a new riscv_cpu_vendor_exts[] array for them, changing riscv_cpu_add_user_properties() and riscv_cpu_add_kvm_properties() accordingly. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 83b44900a5..9111a83a02 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1867,7 +1867,10 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("zcmt", RISCVCPU, cfg.ext_zcmt, false), DEFINE_PROP_BOOL("zicond", RISCVCPU, cfg.ext_zicond, false), =20 - /* Vendor-specific custom extensions */ + DEFINE_PROP_END_OF_LIST(), +}; + +static Property riscv_cpu_vendor_exts[] =3D { DEFINE_PROP_BOOL("xtheadba", RISCVCPU, cfg.ext_xtheadba, false), DEFINE_PROP_BOOL("xtheadbb", RISCVCPU, cfg.ext_xtheadbb, false), DEFINE_PROP_BOOL("xtheadbs", RISCVCPU, cfg.ext_xtheadbs, false), @@ -1976,6 +1979,10 @@ void kvm_riscv_cpu_add_kvm_properties(Object *obj) riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } =20 + for (prop =3D riscv_cpu_vendor_exts; prop && prop->name; prop++) { + riscv_cpu_add_kvm_unavail_prop(obj, prop->name); + } + for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } @@ -2020,6 +2027,10 @@ static void riscv_cpu_add_user_properties(Object *ob= j) qdev_property_add_static(dev, prop); } =20 + for (prop =3D riscv_cpu_vendor_exts; prop && prop->name; prop++) { + qdev_property_add_static(dev, prop); + } + for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { qdev_property_add_static(dev, prop); } --=20 2.41.0 From nobody Thu May 9 12:31:27 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=1694525235; cv=none; d=zohomail.com; s=zohoarc; b=PkR66Nd0poM4axI2UbZ4kiLifj/iS4Z0BaEADYp5v8GzIV468D/x1FxoykTtLdcURF9QqmHVPHFpVCcgVYMv5qm/7DW7m0jB4HH2rPu1BZR0Bky4DT3+jWzuDBE7a81+4eEtD4t1ujRvFwwbMP7SoLGOJ9DhQpwJF7ACeoD1Qn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525235; h=Content-Type: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=r/+8OhgFIU3gLGWTCwQO/5HwWO22OAQG7y7TH74axdc=; b=nQ6NRZp9EpLsAnhcmjTstw+CfaP/4ZdIF2pO+auEU8zhklVjFTJIbNQbba6IyCgu+1jWCFOVZ+cvEjGBTjTMdz1CWpqhudz2RLRXqXLhQiKnzaYsNr+dMbYpI4HEsVPmAitieGHU2udUzDuLz78qQV3wLtdfYHa8LZEsKFOUK+Y= 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 1694525235443977.3699596606117; Tue, 12 Sep 2023 06:27:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3O9-0002nH-TA; Tue, 12 Sep 2023 09:25:09 -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 1qg3O1-0002gU-5l for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:01 -0400 Received: from mail-ot1-x32b.google.com ([2607:f8b0:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3Nx-0003Z5-90 for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:00 -0400 Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-6bf038b8f87so3389598a34.1 for ; Tue, 12 Sep 2023 06:24:55 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.24.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:24:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525095; x=1695129895; 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=r/+8OhgFIU3gLGWTCwQO/5HwWO22OAQG7y7TH74axdc=; b=IdFpndro+mqWbdAusb/HnBLNtTFLy/MqDMGtr0VW7sX9r9+YvtjhM7DCEUrJad/8A3 fo/1Ed6wv/uzS8HlxrzP3YPYBba8PETS5U8l+YfJBbAukUo1J4c3hb7nVdjygHI1ybRu 1fDQ1Zy0W3i82pd6fw7KukJ34q3kPujKVWxDT1wFLCtxxxJsbDqYZ9VRMh8TLvywcFWp IB0BbSSi8kv0uoWck19jwgioFEYVm08PxASJs4TYIsWmL5rlDaalKGCokHrMoxTO4IRn In+7cF9lHmDYkBYgtGYsmKEaJ0fsgU8VeCVFsvK94S4x4cG3VKs2CV2wTfhAKFKrjHAj iMzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525095; x=1695129895; 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=r/+8OhgFIU3gLGWTCwQO/5HwWO22OAQG7y7TH74axdc=; b=EMs2d+Q2lG4Dg18a9LajBOCx4XMtNvSKcab/S9d4NVLvxsjz2Z0hLqGgKC+T89XWSF Yz3MMb8LcdwyG75RdZuXvbD4E7b2jIKlE7C0BeQ7+nY2JkcEb50/nspYEwr+R5SHxZ+Q DM/Hj4KHobwp7Z6CSatXhDKQOj4fsme9OmsC0p8DSTJQTLGQq/J585GQiEdBTLsdPHEj PSEQFJaiUOBKmCuoMkvZV7pqetQnkNAEnBYdeyX+vf5/Bmvtv/9kv3y/zarLfyInLVJX NgVSvtcSCe9ZBtnPSXc670cUffkgnebA6oS4QHzhKUjlJXKcxJyR2nMm5yUIhISmw4Ry RZeA== X-Gm-Message-State: AOJu0Yz7PHngjZoJYW42p+pSYHMGRZKfwTXKjWd2Qi5yf7VlFXVuXs82 L3ZwGgzubK+JfWzpxKj1KASTUUIh+TzLT0OV5pA= X-Google-Smtp-Source: AGHT+IHmc92Cip9dZAs/7P14CKt1abxkyGGE1UVpSwwKmDS9FD8tHEh/1t9GsymTXrlMhWo9ptJFjg== X-Received: by 2002:a05:6830:1347:b0:6bc:cde2:3038 with SMTP id r7-20020a056830134700b006bccde23038mr1559259otq.11.1694525094826; Tue, 12 Sep 2023 06:24:54 -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 v10 07/20] target/riscv/cpu.c: add riscv_cpu_add_qdev_prop_array() Date: Tue, 12 Sep 2023 10:24:10 -0300 Message-ID: <20230912132423.268494-8-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::32b; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x32b.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=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 @ventanamicro.com) X-ZM-MESSAGEID: 1694525237026100001 The code inside riscv_cpu_add_user_properties() became quite repetitive after recent changes. Add a helper to hide the repetition away. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/riscv/cpu.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 9111a83a02..66c2183f20 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1932,6 +1932,15 @@ static Property riscv_cpu_options[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +static void riscv_cpu_add_qdev_prop_array(DeviceState *dev, Property *arra= y) +{ + g_assert(array); + + for (Property *prop =3D array; prop && prop->name; prop++) { + qdev_property_add_static(dev, prop); + } +} + #ifdef CONFIG_KVM static void cpu_set_cfg_unavailable(Object *obj, Visitor *v, const char *name, @@ -2005,7 +2014,6 @@ void kvm_riscv_cpu_add_kvm_properties(Object *obj) */ static void riscv_cpu_add_user_properties(Object *obj) { - Property *prop; DeviceState *dev =3D DEVICE(obj); =20 #ifndef CONFIG_USER_ONLY @@ -2019,21 +2027,10 @@ static void riscv_cpu_add_user_properties(Object *o= bj) =20 riscv_cpu_add_misa_properties(obj); =20 - for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { - qdev_property_add_static(dev, prop); - } - - for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { - qdev_property_add_static(dev, prop); - } - - for (prop =3D riscv_cpu_vendor_exts; prop && prop->name; prop++) { - qdev_property_add_static(dev, prop); - } - - for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { - qdev_property_add_static(dev, prop); - } + riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_extensions); + riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_options); + riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_vendor_exts); + riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_experimental_exts); } =20 static Property riscv_cpu_properties[] =3D { --=20 2.41.0 From nobody Thu May 9 12:31:27 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=1694525212; cv=none; d=zohomail.com; s=zohoarc; b=lUSsNJqRr9utQtY1iD0wMoBfxxgL0Q8raYpjHLUTarSNkDp9iJFR4K3IDGzvpTOx4uodrsuK32jipIHU3/Doye2b6V0oyopUbjE3o7q4voKG3SbrLqqW4k2jHwKPlJb37TObG3p5h2I3csrF5Iyuyst2oH2tSGd5qYNmAFf5BX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525212; 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=v+gk0kBBAHtrEuYiKX1fINvhZTVbZN3vla4ocCML9Go=; b=QWHh8+8RliGucOj1/6en2FdslLQ6xoqHw6CJdO9r1j4T2oxDMXKpwVjdm2o/LOVqXOZ5EoXJfcV/sdPwEaNubSkVITKfK6nzOp6nVTxs1h+kjUcIE6oaau+UNyHO0cp+pEPmhd2c6mRkrp8YEJIArl+FwnyF8UN6nrTFpJBinNM= 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 169452521268118.759428974882326; Tue, 12 Sep 2023 06:26:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3OD-0002rh-DZ; Tue, 12 Sep 2023 09:25:13 -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 1qg3O5-0002j0-32 for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:06 -0400 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3O0-0003bB-Ep for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:04 -0400 Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-3aa14d8641cso4191714b6e.3 for ; Tue, 12 Sep 2023 06:24:59 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.24.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:24:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525098; x=1695129898; 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=v+gk0kBBAHtrEuYiKX1fINvhZTVbZN3vla4ocCML9Go=; b=liWpQbPjj4TkzCN/miw95HYY0LHao5CGXmre1XGg4X7NNMlDDSG2yYy4nW5n9qqozh 8JcgEIKu88J77TV/iLsQ7JVD2UMfIJCGzwpOQ64dTfYxmiWcKQVfWZQrD1Vpu0AA5+Ew wkrPJqXAWEccjs+AWJH5fz5gXPpm5TqLErsMBOQUW14JpAXyv+rE92AB654JNlEZhUrz D1aAOB44/jHST7RswZCWESmB1/DJjDqD42e+x9BR3RwEcYe43sMw4hm/SkhHNtfDghA1 dw1Xrk5/R4uDoE8infOOlnyy2o95GlkR49YSt2ccCKjmsyERDG+TZ4zyQgaXS6E6XjS8 JD/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525098; x=1695129898; 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=v+gk0kBBAHtrEuYiKX1fINvhZTVbZN3vla4ocCML9Go=; b=FotrjbdSUrAaZICYEtt7FzzkQjXW2V+ShcL9GP/jBRfdiyJrF9pseUc9w59uUep4uS xUalX8GDBSd/iDTKXGAu8xGERZMlDwQ/TlCMqxo72H4kubPnHUGV+yndEok/RT38PaH3 9DOuylZpELjDWU7/D7qwHsqZFWkw1vZlQtbgzvqeOacHdbVFpAqhMTWF+Tx1cKqWha1D t7DkJOovIeiqS7OBHoUG+XkjAlmd5cEF6P+ZL7FYv8rnXYE3OtKTFjk1MpRm1Dxq7szA EIzrhuddVb/u8rqCRHxNjXlnZqJTFiPy5dD7J34g6pfGfNivRSBA/4ZKMDoU+3UY8yqL hFZA== X-Gm-Message-State: AOJu0YzRiMQC+V+37nM5jdZZYY06Ffn1E43SYkOWRLaYjHX3mCXslsHE axFgoi+SmHLoKaJxUeX0FLj9v0NcvrdoPMbMPsQ= X-Google-Smtp-Source: AGHT+IGYNYKDZE5lqeYcK30gPFbI2jPLbOMf0iP9XjnPbedTj8dp/4lLvpe7NXyd/YpsE9302SdCBw== X-Received: by 2002:aca:1c10:0:b0:3a7:46d2:5203 with SMTP id c16-20020aca1c10000000b003a746d25203mr14178307oic.51.1694525098721; Tue, 12 Sep 2023 06:24:58 -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 v10 08/20] target/riscv/cpu.c: add riscv_cpu_add_kvm_unavail_prop_array() Date: Tue, 12 Sep 2023 10:24:11 -0300 Message-ID: <20230912132423.268494-9-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-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::235; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x235.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: 1694525214423100007 Content-Type: text/plain; charset="utf-8" Use a helper in riscv_cpu_add_kvm_properties() to eliminate some of its code repetition. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 66c2183f20..15df29580c 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1976,6 +1976,16 @@ static void riscv_cpu_add_kvm_unavail_prop(Object *o= bj, const char *prop_name) NULL, (void *)prop_name); } =20 +static void riscv_cpu_add_kvm_unavail_prop_array(Object *obj, + Property *array) +{ + g_assert(array); + + for (Property *prop =3D array; prop && prop->name; prop++) { + riscv_cpu_add_kvm_unavail_prop(obj, prop->name); + } +} + void kvm_riscv_cpu_add_kvm_properties(Object *obj) { Property *prop; @@ -1984,17 +1994,9 @@ void kvm_riscv_cpu_add_kvm_properties(Object *obj) kvm_riscv_init_user_properties(obj); riscv_cpu_add_misa_properties(obj); =20 - for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { - riscv_cpu_add_kvm_unavail_prop(obj, prop->name); - } - - for (prop =3D riscv_cpu_vendor_exts; prop && prop->name; prop++) { - riscv_cpu_add_kvm_unavail_prop(obj, prop->name); - } - - for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { - riscv_cpu_add_kvm_unavail_prop(obj, prop->name); - } + riscv_cpu_add_kvm_unavail_prop_array(obj, riscv_cpu_extensions); + riscv_cpu_add_kvm_unavail_prop_array(obj, riscv_cpu_vendor_exts); + riscv_cpu_add_kvm_unavail_prop_array(obj, riscv_cpu_experimental_exts); =20 for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { /* Check if KVM created the property already */ --=20 2.41.0 From nobody Thu May 9 12:31:27 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=1694525290; cv=none; d=zohomail.com; s=zohoarc; b=fIbro8UxPtIKp12LExyzI9QK97vyU8IlqnE8prbjkRK8/NxPyC5rNYSbUWdwWtBiTVEiVMdt46st7tPfmWnI0SwRhiZoinfIZ9uv7h5gdVA+Rb1M2Zigc53PVdqV3FyDc8OY8naKXUBYA9/PMzYsoyqnowMK5z0RjH8dbYEFDkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525290; 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=iD4s02t8d5otzJTCsin7G8rQN10He0HED5VhIpHbSts=; b=Z7PB5+axUYXrnXtH7vLahih7NHtleAElZKZUGckdJ7KoRiHQEikm4+cyR0+IR0MKDhhWMvlaF5w3aNyC05TpaDt9zsACtLqBii75Pe2miFYMhpTLi3+zIdJziprL19waHpTYM/FZVQHQTGJrNQ+fsIYwzhHOrK53RTc6cOs+eHM= 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 169452529018169.83868890568885; Tue, 12 Sep 2023 06:28:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3OB-0002oW-34; Tue, 12 Sep 2023 09:25:11 -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 1qg3O8-0002jz-B0 for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:08 -0400 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3O5-0003cQ-Ug for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:08 -0400 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6bdacc5ed66so2973660a34.1 for ; Tue, 12 Sep 2023 06:25:05 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.24.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525102; x=1695129902; 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=iD4s02t8d5otzJTCsin7G8rQN10He0HED5VhIpHbSts=; b=ZmoQsCutuDOoqPeQKZuxGc7V8k3CVWNLWSR7I22wxRa0n/zHgQTshdjsQ3EOmuytGH ErEIJAmZGlI0ey7evLDOsg2LIioLqCG2Xs2lE8qwXZ3U8jLXMcSJ3aLFipPP3Da+l6AQ r9SiSqBTn2ikdksSXCL6m+f3XSBu0bfj4cugU24D/ppUjqMBHxkmrUBhht8MiZkJOwWw i2umg7WJwNy6moCjrzfHuqaWybVPwSdGShIYl32tpTPsRCM3rovW59oi1Xjn66Ojs/bN pk296NratWAs3AzfZh3yQah4gdB8nYUys9ylTZpLsKISJiZqxocbUQ0dkQBXZDG+nvWx LtEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525102; x=1695129902; 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=iD4s02t8d5otzJTCsin7G8rQN10He0HED5VhIpHbSts=; b=jf680pnIb34yMc9UpLtmZLveT63DYOCVnOG+p5trF0VU9kn1A3FhOfLPV58IUr2rP3 XGvOfLCyOj1k4YsO0jIBkWngTHQpBVzaUTAURFeRDcAVcRyxBL+bsfg1OKw4wC2rHwBG ENdCnoaEhEpcwUe47qz6TLD2tYxEmN77QOxeb6Z36DhPo/P8ZoaOLlB30UHE5Bv1Tzwt CiMmQuaUe5rvJQMAkP+/671wcjBwvWK4agxj5bH5pb0vNbcppcTvvGXFkRQjyZGGC3GE c7Z4GH9mYfpKOHBubklOt8b3XCMVbKUQM/ILeu767BGIXgUkOh7TZMtkW2ytgSAKU9ik w6NA== X-Gm-Message-State: AOJu0Yxb0q84I8+iG1qwN9mHIiaFR//2DuEIRSD6PRy28+kCl0ucL11j 9jyi4n8egBd4BxDuQs5KEeem19sO/2Zg4imdhn4= X-Google-Smtp-Source: AGHT+IEwFxaZEewhkzowvQQRdqmyyHD2wtzDhTntYHydXDiHG4q9NkNQfH1RpUO5/HDwKd2jcZOVfg== X-Received: by 2002:a05:6830:1347:b0:6bc:cde2:3038 with SMTP id r7-20020a056830134700b006bccde23038mr1559471otq.11.1694525102298; Tue, 12 Sep 2023 06:25:02 -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 v10 09/20] target/riscv/cpu.c: limit cfg->vext_spec log message Date: Tue, 12 Sep 2023 10:24:12 -0300 Message-ID: <20230912132423.268494-10-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-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::329; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x329.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=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 @ventanamicro.com) X-ZM-MESSAGEID: 1694525292193100003 Content-Type: text/plain; charset="utf-8" Inside riscv_cpu_validate_v() we're always throwing a log message if the user didn't set a vector version via 'vext_spec'. We're going to include one case with the 'max' CPU where env->vext_ver will be set in the cpu_init(). But that alone will not stop the "vector version is not specified" message from appearing. The usefulness of this log message is debatable for the generic CPUs, but for a 'max' CPU type, where we are supposed to deliver a CPU model with all features possible, it's strange to force users to set 'vext_spec' to get rid of this message. Change riscv_cpu_validate_v() to not throw this log message if env->vext_ver is already set. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Weiwei Li --- target/riscv/cpu.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 15df29580c..292928fcef 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -959,8 +959,6 @@ static void riscv_cpu_disas_set_info(CPUState *s, disas= semble_info *info) static void riscv_cpu_validate_v(CPURISCVState *env, RISCVCPUConfig *cfg, Error **errp) { - int vext_version =3D VEXT_VERSION_1_00_0; - if (!is_power_of_2(cfg->vlen)) { error_setg(errp, "Vector extension VLEN must be power of 2"); return; @@ -983,17 +981,18 @@ static void riscv_cpu_validate_v(CPURISCVState *env, = RISCVCPUConfig *cfg, } if (cfg->vext_spec) { if (!g_strcmp0(cfg->vext_spec, "v1.0")) { - vext_version =3D VEXT_VERSION_1_00_0; + env->vext_ver =3D VEXT_VERSION_1_00_0; } else { error_setg(errp, "Unsupported vector spec version '%s'", cfg->vext_spec); return; } - } else { + } else if (env->vext_ver =3D=3D 0) { qemu_log("vector version is not specified, " "use the default value v1.0\n"); + + env->vext_ver =3D VEXT_VERSION_1_00_0; } - env->vext_ver =3D vext_version; } =20 static void riscv_cpu_validate_priv_spec(RISCVCPU *cpu, Error **errp) --=20 2.41.0 From nobody Thu May 9 12:31:27 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=1694525443; cv=none; d=zohomail.com; s=zohoarc; b=d2H7q4JPeUI6v6pQXLrJ2uZxiIN7VdnV0rLVWx1jw82YnGLL2A1nT+J2PKF3RXIxn1AL9vf8juDRUi7spki6ezmBRSdmjHPBN0YLuO6tlGVHWWKNXwwNte9ayqRLXsgevwS60SGs44l5NFvKgURr5EBzFX7238HIyBWLgylHMZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525443; 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=lVXI/lCyhX66NjBUZXWygn19cXsgg+1YHDos6gcre8U=; b=d3IidwAZE5nzc2/L85Zn8e/iecM3h2ZP6hAfHDdhj/5S+nj2RYai9kcE/fXfkxCNLieBeUjh4+ww4S5AV0yAdmN72XmZ8ffyAOXf9wmCHIwjX6dcKPrnpZGw84wbFyYyX1lCAKmCAFQanH7iIUk/e/GkCaVa7nhkcUFELAphMk4= 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 16945254431971002.8547536455536; Tue, 12 Sep 2023 06:30:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3OF-0002sk-2r; Tue, 12 Sep 2023 09:25:15 -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 1qg3OC-0002q6-7r for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:12 -0400 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3O8-0003nT-Iy for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:10 -0400 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6c09d760cb9so3789421a34.2 for ; Tue, 12 Sep 2023 06:25:07 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525106; x=1695129906; 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=lVXI/lCyhX66NjBUZXWygn19cXsgg+1YHDos6gcre8U=; b=OG5IKSHoHxWKLeka6j3z1OTgS6+f796m5YYAkQe5XoavYmQfbB+4I10/BMOUPNXy29 4ClawzL1wdeUsDnaTGcDmrk4YCLkziyUXNEcZKiYErQCb7KRkYdAGSsHWU42v/QdehJ0 NQ11yXFmpVixVgbPFOTKV4b6oXXYe6ccvLpg/VJBTf5DENFMFJOxK/EH669vWTzifo+s MQxWuPpcgh/1aqnX/vkfauYRjEIICOG5NZQ1khxLCHrN34Wc+svET7/zzQvMeMnYYM8f a0B2wTeefOEBsNgcqbkRazvTQ49hZIlkpbnn9zqmndNowVYXxoDuWLn/plLPzs3npJJt ntyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525106; x=1695129906; 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=lVXI/lCyhX66NjBUZXWygn19cXsgg+1YHDos6gcre8U=; b=Tmy326vMty7c5LuSltAdxAZYsZi14byvMH05Y+jbJaNzsG27nNtRdrgvfh317FoH0q TbEIxvvEBLAtn6/npbG7bE70GAiJQL/GlFkHSqS5oNwce3ybDV0SdscqD9eM5o2DMgW1 rCdpy0qG3IWkIKkXil1/41wB+fEw30Bwdzkc/iBgMl/Y9ZXfOhj7lWl+jfdtT9tg19yf JqSHjEKq8eimB00Vf4T5ptFcqhHv0MyAXXtwpXK2N5VPLvZqcDMmMoKxNIq8NPN/gJ0C w9odJOvHfbYQTdFo268ISNKd4OuECacFieVfuVfkiERwWXJqLPMHk4AOHrIm+fAyrjsx gdZQ== X-Gm-Message-State: AOJu0YyIlC4vUKU2QqtS5rzN+D/1/VWoIlEkusNZEomhoSBjIuksiozN X/L0wiKLoqCYEhFzKpGfCrM0m18La0jnwNov2mU= X-Google-Smtp-Source: AGHT+IGWDQgPUOvpTx8jY7Q5BlLcvwhwH8EQaQvma/qcnk4Uj0EGcZ3mGopcO4wf3pjm2/PzNPf32w== X-Received: by 2002:a9d:6b15:0:b0:6b9:b904:99d3 with SMTP id g21-20020a9d6b15000000b006b9b90499d3mr11556722otp.28.1694525106252; Tue, 12 Sep 2023 06:25:06 -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 v10 10/20] target/riscv: add 'max' CPU type Date: Tue, 12 Sep 2023 10:24:13 -0300 Message-ID: <20230912132423.268494-11-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-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::32f; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x32f.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: 1694525444648100001 Content-Type: text/plain; charset="utf-8" The 'max' CPU type is used by tooling to determine what's the most capable CPU a current QEMU version implements. Other archs such as ARM implements this type. Let's add it to RISC-V. What we consider "most capable CPU" in this context are related to ratified, non-vendor extensions. This means that we want the 'max' CPU to enable all (possible) ratified extensions by default. The reasoning behind this design is (1) vendor extensions can conflict with each other and we won't play favorities deciding which one is default or not and (2) non-ratified extensions are always prone to changes, not being stable enough to be enabled by default. All this said, we're still not able to enable all ratified extensions due to conflicts between them. Zfinx and all its dependencies aren't enabled because of a conflict with RVF. zce, zcmp and zcmt are also disabled due to RVD conflicts. When running with 64 bits we're also disabling zcf. MISA bits RVG, RVJ and RVV are also being set manually since they're default disabled. This is the resulting 'riscv,isa' DT for this new CPU: rv64imafdcvh_zicbom_zicboz_zicsr_zifencei_zihintpause_zawrs_zfa_ zfh_zfhmin_zca_zcb_zcd_zba_zbb_zbc_zbkb_zbkc_zbkx_zbs_zk_zkn_zknd_ zkne_zknh_zkr_zks_zksed_zksh_zkt_zve32f_zve64f_zve64d_ smstateen_sscofpmf_sstc_svadu_svinval_svnapot_svpbmt Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu-qom.h | 1 + target/riscv/cpu.c | 56 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/target/riscv/cpu-qom.h b/target/riscv/cpu-qom.h index 04af50983e..f3fbe37a2c 100644 --- a/target/riscv/cpu-qom.h +++ b/target/riscv/cpu-qom.h @@ -30,6 +30,7 @@ #define CPU_RESOLVING_TYPE TYPE_RISCV_CPU =20 #define TYPE_RISCV_CPU_ANY RISCV_CPU_TYPE_NAME("any") +#define TYPE_RISCV_CPU_MAX RISCV_CPU_TYPE_NAME("max") #define TYPE_RISCV_CPU_BASE32 RISCV_CPU_TYPE_NAME("rv32") #define TYPE_RISCV_CPU_BASE64 RISCV_CPU_TYPE_NAME("rv64") #define TYPE_RISCV_CPU_BASE128 RISCV_CPU_TYPE_NAME("x-rv128") diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 292928fcef..dcc1b3ad8d 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -259,6 +259,7 @@ static const char * const riscv_intr_names[] =3D { }; =20 static void riscv_cpu_add_user_properties(Object *obj); +static void riscv_init_max_cpu_extensions(Object *obj); =20 const char *riscv_cpu_get_trap_name(target_ulong cause, bool async) { @@ -396,6 +397,25 @@ static void riscv_any_cpu_init(Object *obj) cpu->cfg.pmp =3D true; } =20 +static void riscv_max_cpu_init(Object *obj) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + CPURISCVState *env =3D &cpu->env; + RISCVMXL mlx =3D MXL_RV64; + +#ifdef TARGET_RISCV32 + mlx =3D MXL_RV32; +#endif + set_misa(env, mlx, 0); + riscv_cpu_add_user_properties(obj); + riscv_init_max_cpu_extensions(obj); + env->priv_ver =3D PRIV_VERSION_LATEST; +#ifndef CONFIG_USER_ONLY + set_satp_mode_max_supported(RISCV_CPU(obj), mlx =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) { @@ -2034,6 +2054,41 @@ static void riscv_cpu_add_user_properties(Object *ob= j) riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_experimental_exts); } =20 +/* + * The 'max' type CPU will have all possible ratified + * non-vendor extensions enabled. + */ +static void riscv_init_max_cpu_extensions(Object *obj) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + CPURISCVState *env =3D &cpu->env; + Property *prop; + + /* Enable RVG, RVJ and RVV that are disabled by default */ + set_misa(env, env->misa_mxl, env->misa_ext | RVG | RVJ | RVV); + + for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { + object_property_set_bool(obj, prop->name, true, NULL); + } + + /* set vector version */ + env->vext_ver =3D VEXT_VERSION_1_00_0; + + /* Zfinx is not compatible with F. Disable it */ + object_property_set_bool(obj, "zfinx", false, NULL); + object_property_set_bool(obj, "zdinx", false, NULL); + object_property_set_bool(obj, "zhinx", false, NULL); + object_property_set_bool(obj, "zhinxmin", false, NULL); + + object_property_set_bool(obj, "zce", false, NULL); + object_property_set_bool(obj, "zcmp", false, NULL); + object_property_set_bool(obj, "zcmt", false, NULL); + + if (env->misa_mxl !=3D MXL_RV32) { + object_property_set_bool(obj, "zcf", false, NULL); + } +} + static Property riscv_cpu_properties[] =3D { DEFINE_PROP_BOOL("debug", RISCVCPU, cfg.debug, true), =20 @@ -2372,6 +2427,7 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .abstract =3D true, }, DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_ANY, riscv_any_cpu_init), + DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_MAX, riscv_max_cpu_init), #if defined(CONFIG_KVM) DEFINE_CPU(TYPE_RISCV_CPU_HOST, riscv_host_cpu_init), #endif --=20 2.41.0 From nobody Thu May 9 12:31:27 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=1694525213; cv=none; d=zohomail.com; s=zohoarc; b=XLQxNQtgCJF4526bt8mwZYxatNzFCJCM07LMNhjW9Kq44myHGqyiuZUAfaZxt6MLHCaJd7rk30z00d+Ao3erHJWJwteu1/s683zySzntUivzJ5pzm0MPZNnrAo7AeSFyMIyU9HBq+UkpwuXl7l8p6raq4QFT4ZcUpBPt31+RrcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525213; h=Content-Type: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=B7qpf/JkqOOyGkufcoz/cV+noVL88MwgaLJx1Pp2JNY=; b=RrJ7gDmfEMrXD0+16MDxOtz64Ll3NBDHDh4e8OjnSTrROa9DH6U7X9UJg7jf3OfKLyLu7mLfPiIs6Hg8mgmJQdPu6uzh7yy8XnBDy78cIskarAzYRDNvRInkm/XBjghr4raH86XwI4OFWm/Ml8ET9UCOBPUb8IN7D61stE1cVIA= 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 1694525213311296.97816265144286; Tue, 12 Sep 2023 06:26:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3OG-0002tI-P8; Tue, 12 Sep 2023 09:25:16 -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 1qg3OE-0002sf-Kj for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:14 -0400 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3OB-0003p6-BE for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:14 -0400 Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-3ab2436b57dso3863283b6e.0 for ; Tue, 12 Sep 2023 06:25:10 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.25.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:25:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525110; x=1695129910; 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=B7qpf/JkqOOyGkufcoz/cV+noVL88MwgaLJx1Pp2JNY=; b=hoz/YelyVcZJEG9hTa7dyfU7boawWted+16ywn7DKTeAFTXiULWPquLvP6iTuMwKXV 9CfV/2w4e+OwRj+KzeAudWQYIv/nKSPX292b5qIzYqWWbHBgKseuay/qpEqBCK2LT+Ko wEtVTocWbfkdZVGKc0+YY3jYf8iiHlXWW/5Pyn+wNCkDdmUDbAPu0TAiGOsdwsKEWW1C AeEiIQE9ubn5Z8zOpAtIyfpuxCaRwZgXFi43j2M0dYUg5DrSqRKj7Awmz1MLFOR8OMwP XBktSueXL4QGsRptZJEemg85C5Teg/P2caa5UREV7DgZJY14KAtdgCuB1Zf503Y8afH0 wVTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525110; x=1695129910; 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=B7qpf/JkqOOyGkufcoz/cV+noVL88MwgaLJx1Pp2JNY=; b=Nj84O2BFkgTs0LkOEj7MWds4yQ8a299QierW9EVUGC0GqwsclQu+2FDN9WlwPWAhM+ rq2IjLEXGUczXwIk9pFN3xpPr+bjN5lekT7VZ71gTBgPBiARutlQUB7c99kw/CAJwqF2 47+Sg5hJjPhuZ7XkmmW+4vWCDzz9ttmnmLojHdO+mSx77NbC0+1l+hhnyCd6jnuKmCV0 AO85aeJi0vk3ElHOKjfyS8AajmAcm5h1dWnHPnT/8ALA58cwFXH3xMvXjXgPHyKWAt/Z 4BALgmarvOno8yom664HKdTTT3AakwpGIaa49EIZkhEkD92PpMmbAOjTeClmjDpxbi8f tA+Q== X-Gm-Message-State: AOJu0Yz+4wMciWctf3gpzRY9f6qxt8Yb5abLBjhjsqvDmll2NPda/AyH ar42uJdDjIRowRnWHd32A7DZ/EENsRxmGoJNRzA= X-Google-Smtp-Source: AGHT+IHOhMg9uJl2DWoPge+uHoGmT8PuQMSWAe3c5YuIMWp6xEhRm/8Q50V6UzYXBqIFFELwAY/Z7g== X-Received: by 2002:a9d:7501:0:b0:6bf:1f5f:ed18 with SMTP id r1-20020a9d7501000000b006bf1f5fed18mr13882966otk.1.1694525109943; Tue, 12 Sep 2023 06:25:09 -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 v10 11/20] avocado, risc-v: add tuxboot tests for 'max' CPU Date: Tue, 12 Sep 2023 10:24:14 -0300 Message-ID: <20230912132423.268494-12-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::229; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x229.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=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 @ventanamicro.com) X-ZM-MESSAGEID: 1694525214033100001 Add smoke tests to ensure that we'll not break the 'max' CPU type when adding new frozen/ratified RISC-V extensions. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- tests/avocado/tuxrun_baselines.py | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/avocado/tuxrun_baselines.py b/tests/avocado/tuxrun_basel= ines.py index e12250eabb..c99bea6c0b 100644 --- a/tests/avocado/tuxrun_baselines.py +++ b/tests/avocado/tuxrun_baselines.py @@ -501,6 +501,38 @@ def test_riscv64(self): =20 self.common_tuxrun(csums=3Dsums) =20 + def test_riscv32_maxcpu(self): + """ + :avocado: tags=3Darch:riscv32 + :avocado: tags=3Dmachine:virt + :avocado: tags=3Dcpu:max + :avocado: tags=3Dtuxboot:riscv32 + """ + sums =3D { "Image" : + "89599407d7334de629a40e7ad6503c73670359eb5f5ae9d686353a3d= 6deccbd5", + "fw_jump.elf" : + "f2ef28a0b77826f79d085d3e4aa686f1159b315eff9099a37046b189= 36676985", + "rootfs.ext4.zst" : + "7168d296d0283238ea73cd5a775b3dd608e55e04c7b92b76ecce31bb= 13108cba" } + + self.common_tuxrun(csums=3Dsums) + + def test_riscv64_maxcpu(self): + """ + :avocado: tags=3Darch:riscv64 + :avocado: tags=3Dmachine:virt + :avocado: tags=3Dcpu:max + :avocado: tags=3Dtuxboot:riscv64 + """ + sums =3D { "Image" : + "cd634badc65e52fb63465ec99e309c0de0369f0841b7d9486f9729e1= 19bac25e", + "fw_jump.elf" : + "6e3373abcab4305fe151b564a4c71110d833c21f2c0a1753b7935459= e36aedcf", + "rootfs.ext4.zst" : + "b18e3a3bdf27be03da0b285e84cb71bf09eca071c3a087b42884b698= 2ed679eb" } + + self.common_tuxrun(csums=3Dsums) + def test_s390(self): """ :avocado: tags=3Darch:s390x --=20 2.41.0 From nobody Thu May 9 12:31:27 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=1694527811; cv=none; d=zohomail.com; s=zohoarc; b=RoVJhEfMwRqBgABKxybFUz9jgIwb/X5SzmDV84IJaYbKrxn4cSO9fxfD0u2TZFLkNQyMtKEpFrBGXEQlrBDNdrv3byHhJCSOD6SmX0u8QEtU8JUWXruvzPlgLQglzTXy4kXBA/cEkGLFiYnRy1ZqBxJe3nB11xyWBB2c5oIO+XE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694527811; h=Content-Type: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=EY7q/ifwlBfCMI8HoRzhiL//2ixtNee6/k+VtF9bmb0=; b=nnBpIwOoIg2CCyFO6LU3U3PT7G4Fq3+suyr9zgcmUTyAmC5f2W7KGUaYf572qa3tOERRMXlYMHm6xIDYH1DOIf5GnwRj7H3YYDwhRk+6t06uzPA4m2JZis52FlH3dEu/SYae6IumMpp9Oy/MlEUmERuum2XmD7u5xBP4u83RLgY= 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 1694527811529360.62804800603385; Tue, 12 Sep 2023 07:10:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3OL-0002vE-8m; Tue, 12 Sep 2023 09:25:21 -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 1qg3OJ-0002uB-Im for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:19 -0400 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3OF-0003qG-HG for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:19 -0400 Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6c0b3cea424so3587243a34.2 for ; Tue, 12 Sep 2023 06:25:15 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525113; x=1695129913; 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=EY7q/ifwlBfCMI8HoRzhiL//2ixtNee6/k+VtF9bmb0=; b=ICnhYAwgcw6GOzZPabZxtyupPC+I35HaL3KOv9ShfT1+XNkq7Xq9oPgTNS4NaXCKEG myg4WKFSGlNa0WP7h53ZC+L8mJunECYCYfToSxFb1/0Q+nBr3M9O//Tvv2Ygt1fc3gCE aRFRE/EEjUHlrwufLT6GuRw8LWXNhUF1f4ksmu0lMS7S9ugMUdQLusJa5rk91qNgaLz/ zi31REMu6L1GDliNLq4pCpfJQ5f04Qo1jn/9vpR1HASyvE29qmn7oTmo66wXzpF3jQ27 l/7/SY9sBE7tgy48tlAauxsGVuPDw45QKC07OPGyFlhKA8AyEWMXZ8EBnG+RNwg+yQAf 3adA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525113; x=1695129913; 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=EY7q/ifwlBfCMI8HoRzhiL//2ixtNee6/k+VtF9bmb0=; b=j3ESQbVcLfT/B1t/gEZnbhBWWU55osCnFyNwSy/CuK0cyQp+UZoqQGjLJx7ddsCfNm sHW6QA55aEEkuVMB90/yu51V66d/qpkhLyUOQnNu2XhtngLH102cRIXAs0cSstgNyJOp UTGRoR2yLx+3nbG0Tek6pGeoMTuglQcBqrO0WV0kyPahQ7XaMTm4bl0ogCw7CSreq2I0 lKHAuMjKmH/MQDcl/FtWhPLNcGruD3ZFu8EPbAQDISApECIWuKT2ffSTlhrsie5BgxCm FAsr+xvyxyJ6HWPfSGFm99eASKHFlEObr7o/rZIJjSbMTl5TnguidJ22Sk9FYkBR4L74 PjbA== X-Gm-Message-State: AOJu0YxyNpjz8ZnDhiN4Lg56WQv9UG6OJlEh+7wo5AB7E1eMeoq+qLkT 1YBQdjhuQzcgTjb4vv4eWstWcdiaGAU5/M1LC+Q= X-Google-Smtp-Source: AGHT+IFz1YZnIxDtkCjoNQ4sqGHQKo3iHltUPF4D4uA+DPfAylA1uyZFROGzMyL1tSCzDSvhiFF7EA== X-Received: by 2002:a05:6830:460e:b0:6bd:152f:9913 with SMTP id ba14-20020a056830460e00b006bd152f9913mr12047331otb.29.1694525113547; Tue, 12 Sep 2023 06:25:13 -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 v10 12/20] target/riscv: deprecate the 'any' CPU type Date: Tue, 12 Sep 2023 10:24:15 -0300 Message-ID: <20230912132423.268494-13-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::333; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x333.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=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 @ventanamicro.com) X-ZM-MESSAGEID: 1694527813224100001 The 'any' CPU type was introduced in commit dc5bd18fa5725 ("RISC-V CPU Core Definition"), being around since the beginning. It's not an easy CPU to use: it's undocumented and its name doesn't tell users much about what the CPU is supposed to bring. 'git log' doesn't help us either in knowing what was the original design of this CPU type. The closest we have is a comment from Alistair [1] where he recalls from memory that the 'any' CPU is supposed to behave like the newly added 'max' CPU. He also suggested that the 'any' CPU should be removed. The default CPUs are rv32 and rv64, so removing the 'any' CPU will have impact only on users that might have a script that uses '-cpu any'. And those users are better off using the default CPUs or the new 'max' CPU. We would love to just remove the code and be done with it, but one does not simply remove a feature in QEMU. We'll put the CPU in quarantine first, letting users know that we have the intent of removing it in the future. [1] https://lists.gnu.org/archive/html/qemu-devel/2023-07/msg02891.html Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- docs/about/deprecated.rst | 12 ++++++++++++ target/riscv/cpu.c | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index dc4da95329..694b878f36 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -365,6 +365,18 @@ QEMU's ``vhost`` feature, which would eliminate the hi= gh latency costs under which the 9p ``proxy`` backend currently suffers. However as of to date no= body has indicated plans for such kind of reimplementation unfortunately. =20 +RISC-V 'any' CPU type ``-cpu any`` (since 8.2) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The 'any' CPU type was introduced back in 2018 and has been around since t= he +initial RISC-V QEMU port. Its usage has always been unclear: users don't k= now +what to expect from a CPU called 'any', and in fact the CPU does not do an= ything +special that isn't already done by the default CPUs rv32/rv64. + +After the introduction of the 'max' CPU type, RISC-V now has a good covera= ge +of generic CPUs: rv32 and rv64 as default CPUs and 'max' as a feature comp= lete +CPU for both 32 and 64 bit builds. Users are then discouraged to use the '= any' +CPU type starting in 8.2. =20 Block device options '''''''''''''''''''' diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index dcc1b3ad8d..447913636c 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1522,6 +1522,11 @@ static void riscv_cpu_realize(DeviceState *dev, Erro= r **errp) RISCVCPUClass *mcc =3D RISCV_CPU_GET_CLASS(dev); Error *local_err =3D NULL; =20 + if (object_dynamic_cast(OBJECT(dev), TYPE_RISCV_CPU_ANY) !=3D NULL) { + warn_report("The 'any' CPU is deprecated and will be " + "removed in the future."); + } + cpu_exec_realizefn(cs, &local_err); if (local_err !=3D NULL) { error_propagate(errp, local_err); --=20 2.41.0 From nobody Thu May 9 12:31:27 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=1694525443; cv=none; d=zohomail.com; s=zohoarc; b=RSiMD1gHU6S7YCvkdeGCKsGzJ7wyo3zFTF319EVlH8KnjTTyfGAGliSm1E5kClLT2E3ADUfwaURw60m7EGnWx6U6h/SEQvVIaZ7qyQnO2kk5exvKK5+hVi9QTMCoP3WrYFrJ/5NpA7HxEBIc7X9o/eW0u10ak5XU93WSG0/dOYo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525443; 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=qdz30WeRHHLw9r9EfvkoHnunIdK+QjVwadXG8AHnbfI=; b=JE21SLAF0GGq8cVgTBeDaR/gReyc0gwdRERcZQlHYHsdIvYp/WMhlqEZhu81tBlvHqBAMg2JcFCcLtahdxdbakNiPilVwKsqQyQY2nJS/yUN85tiZpP7uSnC76ad0qtKi9VAkMwye/Wow4N0ufEq/K6IXOvhVuWUQ4jlCwv+5hc= 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 1694525443789160.8039255822722; Tue, 12 Sep 2023 06:30:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3OM-0002ve-BY; Tue, 12 Sep 2023 09:25:22 -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 1qg3OL-0002vI-HB for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:21 -0400 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3OI-0003qr-7w for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:21 -0400 Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6c0a42a469dso3711888a34.2 for ; Tue, 12 Sep 2023 06:25:17 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.25.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:25:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525116; x=1695129916; 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=qdz30WeRHHLw9r9EfvkoHnunIdK+QjVwadXG8AHnbfI=; b=fawHyoke/98vjhMvZ2E9XwM8dD2fHqUTPtUAqKGblchhPNCv3E6wGsea5QUPFUUi96 ZHmU7rrPNuFmmf9StmH+tuZDIY9qBybacyb6MlUHU5qGrmTQOSMPEoGxHE/FKBIhEXf6 pL6yjsES2EdHc0m968wBCMn1RCysqUee6YpIWsmdxsjhLmb1dVkOuLsZuC1hI/ME1GxE DClQlVxfydx5kSS277IlLRc6GLVRVU8QdL+Go+wpxibtvybln72zCoou/g4vAf2UEh5Z DOhuhFbsYr3OM0V0cwf28H+3iLhSuClLqZV6bG2FwOJgWtPFghhxcWvbJaaQrhyYmC9B ZJ1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525116; x=1695129916; 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=qdz30WeRHHLw9r9EfvkoHnunIdK+QjVwadXG8AHnbfI=; b=VdwykM6wwbGvyoigyZuWpb6vtHgPMJPiTAmm4gQUkqSSr4aqw6NqKbwQwb+4sXHKSx 1Xho/w717y9pPa7EuB0u0HHquzPP0OSOWp4bro6v1V7ikcE7LMywORG6y/rLTgxa+laN +GEICIUPdmD2ox0gQwXeCFjmmMh4MgJ5Z+v753C37k7BmHScCITDFCYEfGWNmmzOCSBq FxW7QM3M7yn3StAsDpEhgNLizoq82eBYnD/2IE2wnHuBQvPFHl7DLIN7+J1zTF1NxgjH CXOexpZB/F4Y8T3oFeL9AgtTbwSJkPwLhJtZg64FYV1DPw5m3tljtlpGMc6xQ5eBI+g1 GJ5Q== X-Gm-Message-State: AOJu0Yxnwfi1NKoC9LudNK/yKhz8ElvOelOfOEKaHurV2Ku2WPwjSnpR ZYtL1TYvux4+p5HwUPuXrP8UudOkbr70R25xSxI= X-Google-Smtp-Source: AGHT+IEpZis1EDx0mR3ggGYQAt5vs2QNT4nZNHTc4sIugcuoxq8DkafV4prtwKNQ3ChDnu5cpWezmg== X-Received: by 2002:a05:6830:18f4:b0:6bd:d1fc:2f2f with SMTP id d20-20020a05683018f400b006bdd1fc2f2fmr14877005otf.21.1694525116776; Tue, 12 Sep 2023 06:25:16 -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 v10 13/20] target/riscv/cpu.c: use offset in isa_ext_is_enabled/update_enabled Date: Tue, 12 Sep 2023 10:24:16 -0300 Message-ID: <20230912132423.268494-14-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-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::335; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x335.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: 1694525445034100004 Content-Type: text/plain; charset="utf-8" We'll have future usage for a function where, given an offset of the struct RISCVCPUConfig, the flag is updated to a certain val. Change all existing callers to use edata->ext_enable_offset instead of 'edata'. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 447913636c..032fad8e03 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -162,18 +162,17 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(xventanacondops, PRIV_VERSION_1_12_0, ext_XVentanaC= ondOps), }; =20 -static bool isa_ext_is_enabled(RISCVCPU *cpu, - const struct isa_ext_data *edata) +static bool isa_ext_is_enabled(RISCVCPU *cpu, uint32_t ext_offset) { - bool *ext_enabled =3D (void *)&cpu->cfg + edata->ext_enable_offset; + bool *ext_enabled =3D (void *)&cpu->cfg + ext_offset; =20 return *ext_enabled; } =20 -static void isa_ext_update_enabled(RISCVCPU *cpu, - const struct isa_ext_data *edata, bool = en) +static void isa_ext_update_enabled(RISCVCPU *cpu, uint32_t ext_offset, + bool en) { - bool *ext_enabled =3D (void *)&cpu->cfg + edata->ext_enable_offset; + bool *ext_enabled =3D (void *)&cpu->cfg + ext_offset; =20 *ext_enabled =3D en; } @@ -1045,9 +1044,10 @@ static void riscv_cpu_disable_priv_spec_isa_exts(RIS= CVCPU *cpu) =20 /* Force disable extensions if priv spec version does not match */ for (i =3D 0; i < ARRAY_SIZE(isa_edata_arr); i++) { - if (isa_ext_is_enabled(cpu, &isa_edata_arr[i]) && + if (isa_ext_is_enabled(cpu, isa_edata_arr[i].ext_enable_offset) && (env->priv_ver < isa_edata_arr[i].min_version)) { - isa_ext_update_enabled(cpu, &isa_edata_arr[i], false); + isa_ext_update_enabled(cpu, isa_edata_arr[i].ext_enable_offset, + false); #ifndef CONFIG_USER_ONLY warn_report("disabling %s extension for hart 0x" TARGET_FMT_lx " because privilege spec version does not match", @@ -2344,7 +2344,7 @@ static void riscv_isa_string_ext(RISCVCPU *cpu, char = **isa_str, int i; =20 for (i =3D 0; i < ARRAY_SIZE(isa_edata_arr); i++) { - if (isa_ext_is_enabled(cpu, &isa_edata_arr[i])) { + if (isa_ext_is_enabled(cpu, isa_edata_arr[i].ext_enable_offset)) { new =3D g_strconcat(old, "_", isa_edata_arr[i].name, NULL); g_free(old); old =3D new; --=20 2.41.0 From nobody Thu May 9 12:31:27 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=1694525240; cv=none; d=zohomail.com; s=zohoarc; b=Y2FEzOfa/pBobK3mlwPP8HiNgtN+rXijMz9JNT95kLyvLV5rgDy8LVfmdBa7nDKrmXiaV2utn2bxAueDmxN3Ex1tYIrRS8l40LDAaRQr2eA6aaucIWhj8wcQuarFX6DYwBiOTwqey7WbEFrYa7CzGfbhkoz6Pf8coARD52qg/I4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525240; h=Content-Type: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=voPlcLnCfHA3Pf7+udd5Id15KbD/BVbOGmcjjKXZ6OY=; b=RJ8k0YVtp+GzZJ182Px1ia/ijpzuZ8pE9WpjV0IkD9XpTA3dQRveX/yteT7P1rytOxm8GA9cDGPdM1y+bkejI6bSGeukgwA5KF7ApjXyYbwLCgeUf9jbquJQFwWIPQj51FdCOX/1Uz3+c8u9pR8yTEEbh7ebvuSyaERpy+/QQ4M= 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 1694525240858912.1328051442782; Tue, 12 Sep 2023 06:27:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3OU-00031l-Aj; Tue, 12 Sep 2023 09:25:31 -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 1qg3ON-0002ze-S8 for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:23 -0400 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3OL-0003rV-Kp for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:23 -0400 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-6c0822f46a1so3805033a34.0 for ; Tue, 12 Sep 2023 06:25:21 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.25.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:25:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525120; x=1695129920; 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=voPlcLnCfHA3Pf7+udd5Id15KbD/BVbOGmcjjKXZ6OY=; b=CtnlhadzinQLY3/JfgMk8CtgLF4/FgJMvfOPi7aNMuJAFwPQLOdAyqyEmF/yc80Oid XefRXQ5SSQGagze3+XAZFxIKOFy7o5LdvEzLptfykCQUWZrk0qt+7/bICzhrvm8lgLQE fN07jNe7SKTG5o3crlVBaT9aa65MfQ1JcSJR4dvX9jrBbLZYKaeRgsq9dCZpK4Ea6kR8 auvO9wOD2zJW+2UgFcfmziwt+DOmn3khIRMuQGYS7CQVvWSYTKO5susb+pOBW4ohkF9K u4jPKDOB7mY0J8alnq3LkF8UDPxZ+NTPCADxNkUFtbxV8Fo/wFlZaO+el38W8xpWYcqB C1pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525120; x=1695129920; 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=voPlcLnCfHA3Pf7+udd5Id15KbD/BVbOGmcjjKXZ6OY=; b=Fkhu2d6HgYCwoNajCLnsnA0geS1mWiQaMiDlvRwJvlQubq8/tGqnD/4Q4vWcIwTg3/ PZFouXLzOiVnT05hIoVSgkp37gxnwiSO5CvTw2Txk047guxPisntRWKAvcCZKvVlh1En h5tRE3RqIGg37yutwcJ7JCI0yEDRrSVzQDYI14cguqHvQfoLVEsUlbIuMPJk3bxAfFjN Ct2W8JxqvANrOp+FpawPwVLrhydJi8iSGzi5ZGkhzVONcmInrXP3Mkg6hj5srgldLoak ExG+F7hY6Bqcv4uryqDalO5OhVVvUHuuCy0QrIcoWLDAoEfXjlcM2NkuYFt7xV9jkt83 okXg== X-Gm-Message-State: AOJu0Yy38sF9op7uLky7sbHqZdcIxxcPugsLaEBNzIFEAYM9+dhqlBqQ eCdIZ9JXITOmWmi/Sy7dyh97sHvMioA2WYBGd8Q= X-Google-Smtp-Source: AGHT+IEhqrdIM6CvJ6ORoGKoUpIIvmN5JBZm3RczkIarvfEP6iCFej6K8W7juFJmBUoUJ1d5q4pRQg== X-Received: by 2002:a9d:7b57:0:b0:6bd:b0c9:a89 with SMTP id f23-20020a9d7b57000000b006bdb0c90a89mr12116240oto.2.1694525119971; Tue, 12 Sep 2023 06:25:19 -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 v10 14/20] target/riscv: make CPUCFG() macro public Date: Tue, 12 Sep 2023 10:24:17 -0300 Message-ID: <20230912132423.268494-15-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::32a; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x32a.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: 1694525242159100001 The RISC-V KVM driver uses a CPUCFG() macro that calculates the offset of a certain field in the struct RISCVCPUConfig. We're going to use this macro in target/riscv/cpu.c as well in the next patches. Make it public. Rename it to CPU_CFG_OFFSET() for more clarity while we're at it. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/riscv/cpu.c | 2 +- target/riscv/cpu.h | 2 ++ target/riscv/kvm.c | 8 +++----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 032fad8e03..85630ac2c1 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -48,7 +48,7 @@ struct isa_ext_data { }; =20 #define ISA_EXT_DATA_ENTRY(_name, _min_ver, _prop) \ - {#_name, _min_ver, offsetof(struct RISCVCPUConfig, _prop)} + {#_name, _min_ver, CPU_CFG_OFFSET(_prop)} =20 /* * From vector_helper.c diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 6316cbcc23..7d6cfb07ea 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -62,6 +62,8 @@ const char *riscv_get_misa_ext_name(uint32_t bit); const char *riscv_get_misa_ext_description(uint32_t bit); =20 +#define CPU_CFG_OFFSET(_prop) offsetof(struct RISCVCPUConfig, _prop) + /* Privileged specification version */ enum { PRIV_VERSION_1_10_0 =3D 0, diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c index c01cfb03f4..14763ec0cd 100644 --- a/target/riscv/kvm.c +++ b/target/riscv/kvm.c @@ -205,10 +205,8 @@ static void kvm_riscv_update_cpu_misa_ext(RISCVCPU *cp= u, CPUState *cs) } } =20 -#define CPUCFG(_prop) offsetof(struct RISCVCPUConfig, _prop) - #define KVM_EXT_CFG(_name, _prop, _reg_id) \ - {.name =3D _name, .offset =3D CPUCFG(_prop), \ + {.name =3D _name, .offset =3D CPU_CFG_OFFSET(_prop), \ .kvm_reg_id =3D _reg_id} =20 static KVMCPUConfig kvm_multi_ext_cfgs[] =3D { @@ -285,13 +283,13 @@ static void kvm_cpu_set_multi_ext_cfg(Object *obj, Vi= sitor *v, =20 static KVMCPUConfig kvm_cbom_blocksize =3D { .name =3D "cbom_blocksize", - .offset =3D CPUCFG(cbom_blocksize), + .offset =3D CPU_CFG_OFFSET(cbom_blocksize), .kvm_reg_id =3D KVM_REG_RISCV_CONFIG_REG(zicbom_block_size) }; =20 static KVMCPUConfig kvm_cboz_blocksize =3D { .name =3D "cboz_blocksize", - .offset =3D CPUCFG(cboz_blocksize), + .offset =3D CPU_CFG_OFFSET(cboz_blocksize), .kvm_reg_id =3D KVM_REG_RISCV_CONFIG_REG(zicboz_block_size) }; =20 --=20 2.41.0 From nobody Thu May 9 12:31:27 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=1694525212; cv=none; d=zohomail.com; s=zohoarc; b=S097eYHzZFt5e4+PDlKSjFZsEvYxjr7BfufnP8UFVREVEthQL7yaNJPtwxW8t+aE5HIJBBT4Xn45nF3zJ81MfF5KLkOuG6vh9+T+RfQJ+yrkUDAKLCv0mgvG0mjH6Z++1f8x4f+hBRQvqEL9aSulYnhBCLgKu2AErruU+dK2uRA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525212; 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=U3vwhfzwzLZ+q36r+028e/WoJVWXeUlkHdzNaIijKAo=; b=QRmPniS134Kf1WCPwbK8KHLEIIoeE+Cyt1xDWItGkbfrw7IAconwh6RRldod0xydH4FG9hvEOLhfDHHb7JF2/jme2+RG0dUuq2mR6QKkqhnJ/JcQkjHb7OqeAxVhVt0Q0kTmiMEiDytoQwJR5BjpFv3qzaK8dc9Q+Kap7qg7LDA= 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 1694525212679573.4790487383747; Tue, 12 Sep 2023 06:26:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3Ob-00036u-M4; Tue, 12 Sep 2023 09:25:38 -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 1qg3OR-00031N-61 for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:28 -0400 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3OO-0003sB-S9 for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:26 -0400 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-6bee392fe9dso3714301a34.1 for ; Tue, 12 Sep 2023 06:25:24 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525123; x=1695129923; 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=U3vwhfzwzLZ+q36r+028e/WoJVWXeUlkHdzNaIijKAo=; b=bV3rxAgMBn02tBPWpl+xOZnsPkBTNgvwtWE7+3jO1nKhGBrVD5sfLivmzeZAOLQFZf pzZ82vgDsEUzkoeN2i8Zi/8uue6Yv2WjbJ8PeQLvEwSZ0/0pieMnv0cZtRDYuVJ2TiHd uFzZFsL09BiKVSWTMR7/n3RZ4jMDdSna0mWnd1XUkYsBclJSnTEv67hfauZdvEtcePEP zX+6wRAIFS0bgJfgvPiq4VNQGruqPqxwtufN/5H09z2jzcp96eKLQWgo4CrEB2KKDSGp WBa3C1mw/Y2mnbt5YrH/6zkKGiNtmuANAPdZgQbOoAMnnCYFcfsQA0tduQ0sXlIbz5WC qnRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525123; x=1695129923; 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=U3vwhfzwzLZ+q36r+028e/WoJVWXeUlkHdzNaIijKAo=; b=K7V5eRaBRNwxbd4u20zz2tmT2khUHSXn5YjPnPJv6RYtc8vQPHBwKLcfxig6AkEtKk YSAtYV5ubXFWeBxPAH//1rTiV5NRRLtxwmjacvKXxjW7+gmMrlKNRTk47GsnqS7o4Mly a5Fj/v1W48mYormRmOWajHiMPBLIJ55nlUuC77HdfVDxtqyx8fl64htaAfWbxzUCpRE8 1k4xwL4rdKbNSMOU8+2+ZmD0FWLzgn5sebs4Zud1uVOX8tA07V0e9OYvyFcXARM5j31X JoILts69sPR3WOPvcBUKnb9DnK+ZpYWiBTdtAUSsBY52jRhoTuUCQ7w37JN2Jmae23Vn ACIQ== X-Gm-Message-State: AOJu0YxeoHt//4RAH1RYUaRgJWJz1Ebc5Q76CYQy0MFUpgVh32C1Yq/M 9hc/JPWOzbv4HKNzDo8/OHWwAwsOvq1NMYy8xCo= X-Google-Smtp-Source: AGHT+IHEIiQk02nyy05I4a7m4/hd+waMtni6Y5bvvT54BjzmneeNAwtT8sagXkYMzYJWqissswm+4A== X-Received: by 2002:a05:6830:48:b0:6bd:b879:c313 with SMTP id d8-20020a056830004800b006bdb879c313mr14117417otp.10.1694525123512; Tue, 12 Sep 2023 06:25:23 -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 v10 15/20] target/riscv/cpu.c: introduce cpu_cfg_ext_auto_update() Date: Tue, 12 Sep 2023 10:24:18 -0300 Message-ID: <20230912132423.268494-16-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-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::32a; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x32a.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: 1694525214389100005 Content-Type: text/plain; charset="utf-8" During realize() time we're activating a lot of extensions based on some criteria, e.g.: if (cpu->cfg.ext_zk) { cpu->cfg.ext_zkn =3D true; cpu->cfg.ext_zkr =3D true; cpu->cfg.ext_zkt =3D true; } This practice resulted in at least one case where we ended up enabling something we shouldn't: RVC enabling zca/zcd/zcf when using a CPU that has priv_spec older than 1.12.0. We're also not considering user choice. There's no way of doing it now but this is about to change in the next few patches. cpu_cfg_ext_auto_update() will check for priv version mismatches before enabling extensions. If we have a mismatch between the current priv version and the extension we want to enable, do not enable it. In the near future, this same function will also consider user choice when deciding if we're going to enable/disable an extension or not. For now let's use it to handle zca/zcd/zcf enablement if RVC is enabled. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 85630ac2c1..4d490df285 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -177,6 +177,43 @@ static void isa_ext_update_enabled(RISCVCPU *cpu, uint= 32_t ext_offset, *ext_enabled =3D en; } =20 +static int cpu_cfg_ext_get_min_version(uint32_t ext_offset) +{ + int i; + + for (i =3D 0; i < ARRAY_SIZE(isa_edata_arr); i++) { + if (isa_edata_arr[i].ext_enable_offset !=3D ext_offset) { + continue; + } + + return isa_edata_arr[i].min_version; + } + + g_assert_not_reached(); +} + +static void cpu_cfg_ext_auto_update(RISCVCPU *cpu, uint32_t ext_offset, + bool value) +{ + CPURISCVState *env =3D &cpu->env; + bool prev_val =3D isa_ext_is_enabled(cpu, ext_offset); + int min_version; + + if (prev_val =3D=3D value) { + return; + } + + if (value && env->priv_ver !=3D PRIV_VERSION_LATEST) { + /* Do not enable it if priv_ver is older than min_version */ + min_version =3D cpu_cfg_ext_get_min_version(ext_offset); + if (env->priv_ver < min_version) { + return; + } + } + + isa_ext_update_enabled(cpu, ext_offset, value); +} + const char * const riscv_int_regnames[] =3D { "x0/zero", "x1/ra", "x2/sp", "x3/gp", "x4/tp", "x5/t0", "x6/t1", "x7/t2", "x8/s0", "x9/s1", "x10/a0", "x11/a1", "x12/a2", "x13/a3", @@ -1268,12 +1305,12 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cp= u, Error **errp) =20 /* zca, zcd and zcf has a PRIV 1.12.0 restriction */ if (riscv_has_ext(env, RVC) && env->priv_ver >=3D PRIV_VERSION_1_12_0)= { - cpu->cfg.ext_zca =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zca), true); if (riscv_has_ext(env, RVF) && env->misa_mxl_max =3D=3D MXL_RV32) { - cpu->cfg.ext_zcf =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcf), true); } if (riscv_has_ext(env, RVD)) { - cpu->cfg.ext_zcd =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcd), true); } } =20 --=20 2.41.0 From nobody Thu May 9 12:31:27 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=1694525420; cv=none; d=zohomail.com; s=zohoarc; b=Rgv85aRK0s9n5Wta+Elk3HYtV7gNx8psHeGqx5vFyxQfvdO2kKP28dwUgT7qewdozb+tVC4LHjy+cj+0xgnRJtA3ktG4ck4J3PErCfISogHHWSaoFFl0QsQLr2UgPqQoEVgYZkua/k4sulhVsmG6LURu9SxOTV0nSL1KfWnTFwY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525420; 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=WreuABpWhoVqoHYAg048x9E8h4HL8EbJ4OsZJ+bVBho=; b=naPlaZ30w0a0TXNFDryOJvsoiHHs6ZJR5qo55f7cZ557lb0iGiDeBjQppzH8m2viENCyC26x6cza1lmcMmgmLyza4a0ebkKPopta9AeskS5OPdCxQBf1PFlfInHMK6CFrzI0YyqdtSJBHcExCobmI6OaMLASj+3RjbQFMhe2GKs= 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 1694525420786621.4416928085897; Tue, 12 Sep 2023 06:30:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3Om-0003Fk-Gd; Tue, 12 Sep 2023 09:25:48 -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 1qg3OU-00032s-PA for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:33 -0400 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3OS-0003sy-BF for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:30 -0400 Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6b9e478e122so3800486a34.1 for ; Tue, 12 Sep 2023 06:25:27 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525127; x=1695129927; 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=WreuABpWhoVqoHYAg048x9E8h4HL8EbJ4OsZJ+bVBho=; b=VW5vcdTLkyc5HahuaDnzwNrxBm577g1iiLFsAmJtef/quWHLJS5USsFySqbzAYIQtI q77gTJia16O9CnXB/ZcF7pzhJmOBtTh07xeReEGJc5fiNEHBsAUWg4tiwXt3+/Y9PlK0 tJi1qs1jsR8N2AfL1+Ri/Rgwwr/PGuMiITQnr+Do7NfqZghSDELzgreNOd9nLOgSPZY6 0nc8GhJ5kwemMIlsZEP50BsCBlOrD0LSZpWq3Vl2v1pQFvGxd741JNdX+aWL3e8TjbZz FJZUrSEZ5xRA/NEuhqMFYMewWV2a9/hNzI6F+RZiaPlDK7nwxIoBQMXRVcmgIuup7t9R nQsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525127; x=1695129927; 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=WreuABpWhoVqoHYAg048x9E8h4HL8EbJ4OsZJ+bVBho=; b=hGCm0Pj9HxHLxKeXk7PLnh8WntPVQ5e1mIcstOVQmx5xTTcYk5g9OwHSXtdUXIZLWR SfOMAErZl0EAmJjzbrJQ/D8DsjhDiSJPDKH7jBRLI0VhzWlXNdmFAJ2XybXMZ9oKrOee PzrkbRSQsLAYQAuC71utxmvClFliEnQ8D6Mi5c1RRE8760XLd09Yp/8KBlgaVNIhdFp3 si9Vf6+uwPODLZSefBr3rUce5g9f1xl04w5OB0+eajPUNA6x1F3MXqPOaGWRDN14hObj /zqwBpCJISWRfO3K5qA0J9wFfXJdMG0r2J4HfUlBGKl3gQY9oRbRxY6E9Cgg6eBlD1Jm xTdg== X-Gm-Message-State: AOJu0YxgM9YEukjpvJcR4gsdg+QIWpQ+hLyngUaiZfe7BEcjnrPDtoQ5 PsbiogZ+8YIPUjUgjOVD5qqS+Xl1oSpYvT9zeLY= X-Google-Smtp-Source: AGHT+IGNgj4YHXy/Ypq2oXuQdU9nUiyDn2YL5OPUsuz+dOm7M3J5NmEvgB+YljUrjWUPAYzoBmHghw== X-Received: by 2002:a05:6830:4a2:b0:6b7:6e07:4951 with SMTP id l2-20020a05683004a200b006b76e074951mr13300548otd.25.1694525126996; Tue, 12 Sep 2023 06:25:26 -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 v10 16/20] target/riscv/cpu.c: use cpu_cfg_ext_auto_update() during realize() Date: Tue, 12 Sep 2023 10:24:19 -0300 Message-ID: <20230912132423.268494-17-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-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::333; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x333.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: 1694525425165100001 Content-Type: text/plain; charset="utf-8" Let's change the other instances in realize() where we're enabling an extension based on a certain criteria (e.g. it's a dependency of another extension). We're leaving icsr and ifencei being enabled during RVG for later - we'll want to error out in that case. Every other extension enablement during realize is now done via cpu_cfg_ext_auto_update(). The end goal is that only cpu init() functions will handle extension flags directly via "cpu->cfg.ext_N =3D true|false". Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 50 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 4d490df285..5a83b613b6 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1193,7 +1193,7 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu,= Error **errp) } =20 if (cpu->cfg.ext_zfh) { - cpu->cfg.ext_zfhmin =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zfhmin), true); } =20 if (cpu->cfg.ext_zfhmin && !riscv_has_ext(env, RVF)) { @@ -1219,17 +1219,17 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cp= u, Error **errp) } =20 /* The V vector extension depends on the Zve64d extension */ - cpu->cfg.ext_zve64d =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve64d), true); } =20 /* The Zve64d extension depends on the Zve64f extension */ if (cpu->cfg.ext_zve64d) { - cpu->cfg.ext_zve64f =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve64f), true); } =20 /* The Zve64f extension depends on the Zve32f extension */ if (cpu->cfg.ext_zve64f) { - cpu->cfg.ext_zve32f =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve32f), true); } =20 if (cpu->cfg.ext_zve64d && !riscv_has_ext(env, RVD)) { @@ -1243,7 +1243,7 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu,= Error **errp) } =20 if (cpu->cfg.ext_zvfh) { - cpu->cfg.ext_zvfhmin =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvfhmin), true); } =20 if (cpu->cfg.ext_zvfhmin && !cpu->cfg.ext_zve32f) { @@ -1273,7 +1273,7 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu,= Error **errp) =20 /* Set the ISA extensions, checks should have happened above */ if (cpu->cfg.ext_zhinx) { - cpu->cfg.ext_zhinxmin =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zca), true); } =20 if ((cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinxmin) && !cpu->cfg.ext_zfi= nx) { @@ -1294,12 +1294,12 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cp= u, Error **errp) } =20 if (cpu->cfg.ext_zce) { - cpu->cfg.ext_zca =3D true; - cpu->cfg.ext_zcb =3D true; - cpu->cfg.ext_zcmp =3D true; - cpu->cfg.ext_zcmt =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zca), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcb), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcmp), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcmt), true); if (riscv_has_ext(env, RVF) && env->misa_mxl_max =3D=3D MXL_RV32) { - cpu->cfg.ext_zcf =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcf), true); } } =20 @@ -1367,26 +1367,26 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cp= u, Error **errp) } =20 if (cpu->cfg.ext_zk) { - cpu->cfg.ext_zkn =3D true; - cpu->cfg.ext_zkr =3D true; - cpu->cfg.ext_zkt =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zkn), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zkr), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zkt), true); } =20 if (cpu->cfg.ext_zkn) { - cpu->cfg.ext_zbkb =3D true; - cpu->cfg.ext_zbkc =3D true; - cpu->cfg.ext_zbkx =3D true; - cpu->cfg.ext_zkne =3D true; - cpu->cfg.ext_zknd =3D true; - cpu->cfg.ext_zknh =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkb), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkc), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkx), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zkne), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zknd), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zknh), true); } =20 if (cpu->cfg.ext_zks) { - cpu->cfg.ext_zbkb =3D true; - cpu->cfg.ext_zbkc =3D true; - cpu->cfg.ext_zbkx =3D true; - cpu->cfg.ext_zksed =3D true; - cpu->cfg.ext_zksh =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkb), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkc), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkx), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zksed), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zksh), true); } =20 /* --=20 2.41.0 From nobody Thu May 9 12:31:28 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=1694525483; cv=none; d=zohomail.com; s=zohoarc; b=ZAT8ZS90N4wcj+1Pc0ouu5uBWZDHuMVP5J9s1z+Q6ahU0savft+hQaU9dOK04EIGQIlstqBUZl6m/2qAnyMDqllQdB6oI3BbHjc3ug5+qBEwJwfvQefosSOpEhWyThPwq8GnRl2fPOJvlVHv8K7VadgPCME2Dzls6+f71FG3S4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525483; 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=6O1tVZIDsDopjvhL3d5NzvfbyCVU/aRLjVJFU0x20W8=; b=WuZMhSDr76s53VfypbVY8R9YipTsUSkzgPW73v1gLt1rZRFUVt2W3y+ciu9/kYIX1Sp4ry076Mt4/7j53LqvrSgzgnPieku5sNhsSr+OJ3CH60/iLB3tMFULO86R0vkKwHKUqV5Nsz6Ybf0JlhPqFDwYzcIRBThpUDL/gRhyXRg= 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 1694525483274697.9779956032003; Tue, 12 Sep 2023 06:31:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3On-0003N7-SW; Tue, 12 Sep 2023 09:25:49 -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 1qg3OZ-00033c-K9 for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:36 -0400 Received: from mail-oo1-xc2c.google.com ([2607:f8b0:4864:20::c2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3OV-0003ti-Pg for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:34 -0400 Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-57354433a7dso3096216eaf.1 for ; Tue, 12 Sep 2023 06:25:31 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:25:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525130; x=1695129930; 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=6O1tVZIDsDopjvhL3d5NzvfbyCVU/aRLjVJFU0x20W8=; b=D21yUD1uGIlAC33nb5ggczmJceBjKUD28RELMTnBIOvlJfBj7fQdOfUdBtBtgqp/wB GYy0Am41moU/wR7BO9xRdqiz6f2gf3905GH7RLUg0OKlgJ2Oih06Aya3aJQwBNzRkHlR E5tWTdMYTR/10Fw/Vs/y06FCTPlKm6d3SHGtgzFBZvbDMC2hptTHq9gyRSBIssvD1R+Q Euvm7UhlgARY7bBg2FtK+V958bWlzD3oOJS3uqvUfRULt1hXq9B6qwdyxlEEJvLyIn2j Mo+IP9wL5jaPDazesS94eTgL2UBkhNFkWb1+IUZ4UUAogMLNQym3IkmyaoLVJR1yWENh 9OPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525130; x=1695129930; 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=6O1tVZIDsDopjvhL3d5NzvfbyCVU/aRLjVJFU0x20W8=; b=wACzKjGFAZT6qlGtuDIW++zd4LE+zhid3ch/G/TNhjdJ3tYlbrZoqulPGiCEXgo7RE c72kFX9CPSt0vCE85In/3TwuNieq5RbIR3ARqzc3DxSUH1WcVPyI3S3gb+KT1zo3kUHR uziodmGjRclSr53C5COqw/ovTQ0iLlC3Y1e6q/Ll0EQvzY6SPtRIBJhgBKk07Mv5D04i 8E/LRJ1stiXe2VEMlq6npbM6UCrOpy8P/RNtxV5nispiFj94v5hDiz313Fva5zEBezaL g9MmNF1kndm++mKmp/9qQISE2F/8Uj2Gvv2SzUfGu+fD7Pe06NZf/Vaxshx7N5OdicWX 2FeA== X-Gm-Message-State: AOJu0YyLd3LjRZu/EBlLuy3VkwD2ZPynKN5h67/wXt2aDI25giJnNieo aIlACWFrUfa7rKYOPksBRPoRZ/l/FVRA+3Tl6Zw= X-Google-Smtp-Source: AGHT+IGZTPqTBJ1hzpA/RXWw+Gk1+hEeFzkC5+UbCTy9C9o9vFkG9q1y9RABBivhB0IwcfungSYIAg== X-Received: by 2002:a4a:9217:0:b0:571:28d5:2c78 with SMTP id f23-20020a4a9217000000b0057128d52c78mr10802927ooh.4.1694525130233; Tue, 12 Sep 2023 06:25:30 -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 v10 17/20] target/riscv/cpu.c: introduce RISCVCPUMultiExtConfig Date: Tue, 12 Sep 2023 10:24:20 -0300 Message-ID: <20230912132423.268494-18-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-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::c2c; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc2c.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: 1694525484321100007 Content-Type: text/plain; charset="utf-8" If we want to make better decisions when auto-enabling extensions during realize() we need a way to tell if an user set an extension manually. The RISC-V KVM driver has its own solution via a KVMCPUConfig struct that has an 'user_set' flag that is set during the Property set() callback. The set() callback also does init() time validations based on the current KVM driver capabilities. For TCG we would want a 'user_set' mechanic too, but we would look ad-hoc via cpu_cfg_ext_auto_update() if a certain extension was user set or not. If we copy what was made in the KVM side we would look for 'user_set' for one into 60+ extension structs spreaded in 3 arrays (riscv_cpu_extensions, riscv_cpu_experimental_exts, riscv_cpu_vendor_exts). We'll still need an extension struct but we won't be using the 'user_set' flag: - 'RISCVCPUMultiExtConfig' will be our specialized structure, similar to wh= at we're already doing with the MISA extensions in 'RISCVCPUMisaExtConfig'. DEFINE_PROP_BOOL() for all 3 extensions arrays were replaced by MULTI_EXT_CFG_BOOL(), a macro that will init our specialized struct; - the 'multi_ext_user_opts' hash will be used to store the offset of each extension that the user set via the set() callback, cpu_set_multi_ext_cfg(). For now we're just initializing and populating it - next patch will use it to determine if a certain extension was user set; - cpu_add_multi_ext_prop() is a new helper that will replace the qdev_property_add_static() calls that our macros are doing to populate user properties. The macro was renamed to ADD_CPU_MULTIEXT_PROPS_ARRAY() for clarity. Note that the non-extension properties in riscv_cpu_options[] still need to be declared via qdev(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 258 ++++++++++++++++++++++++++++----------------- 1 file changed, 159 insertions(+), 99 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 5a83b613b6..e79fe13b26 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -162,6 +162,9 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(xventanacondops, PRIV_VERSION_1_12_0, ext_XVentanaC= ondOps), }; =20 +/* Hash that stores user set extensions */ +static GHashTable *multi_ext_user_opts; + static bool isa_ext_is_enabled(RISCVCPU *cpu, uint32_t ext_offset) { bool *ext_enabled =3D (void *)&cpu->cfg + ext_offset; @@ -1718,6 +1721,8 @@ static void riscv_cpu_init(Object *obj) qdev_init_gpio_in(DEVICE(cpu), riscv_cpu_set_irq, IRQ_LOCAL_MAX + IRQ_LOCAL_GUEST_MAX); #endif /* CONFIG_USER_ONLY */ + + multi_ext_user_opts =3D g_hash_table_new(NULL, g_direct_equal); } =20 typedef struct RISCVCPUMisaExtConfig { @@ -1869,108 +1874,118 @@ static void riscv_cpu_add_misa_properties(Object = *cpu_obj) } } =20 -static Property riscv_cpu_extensions[] =3D { +typedef struct RISCVCPUMultiExtConfig { + const char *name; + uint32_t offset; + bool enabled; +} RISCVCPUMultiExtConfig; + +#define MULTI_EXT_CFG_BOOL(_name, _prop, _defval) \ + {.name =3D _name, .offset =3D CPU_CFG_OFFSET(_prop), \ + .enabled =3D _defval} + +static RISCVCPUMultiExtConfig riscv_cpu_extensions[] =3D { /* Defaults for standard extensions */ - DEFINE_PROP_BOOL("sscofpmf", RISCVCPU, cfg.ext_sscofpmf, false), - DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true), - DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true), - DEFINE_PROP_BOOL("Zihintntl", RISCVCPU, cfg.ext_zihintntl, true), - DEFINE_PROP_BOOL("Zihintpause", RISCVCPU, cfg.ext_zihintpause, true), - DEFINE_PROP_BOOL("Zawrs", RISCVCPU, cfg.ext_zawrs, true), - DEFINE_PROP_BOOL("Zfa", RISCVCPU, cfg.ext_zfa, true), - DEFINE_PROP_BOOL("Zfh", RISCVCPU, cfg.ext_zfh, false), - DEFINE_PROP_BOOL("Zfhmin", RISCVCPU, cfg.ext_zfhmin, false), - DEFINE_PROP_BOOL("Zve32f", RISCVCPU, cfg.ext_zve32f, false), - DEFINE_PROP_BOOL("Zve64f", RISCVCPU, cfg.ext_zve64f, false), - DEFINE_PROP_BOOL("Zve64d", RISCVCPU, cfg.ext_zve64d, false), - DEFINE_PROP_BOOL("sstc", RISCVCPU, cfg.ext_sstc, true), - - DEFINE_PROP_BOOL("smstateen", RISCVCPU, cfg.ext_smstateen, false), - DEFINE_PROP_BOOL("svadu", RISCVCPU, cfg.ext_svadu, true), - DEFINE_PROP_BOOL("svinval", RISCVCPU, cfg.ext_svinval, false), - DEFINE_PROP_BOOL("svnapot", RISCVCPU, cfg.ext_svnapot, false), - DEFINE_PROP_BOOL("svpbmt", RISCVCPU, cfg.ext_svpbmt, false), - - DEFINE_PROP_BOOL("zba", RISCVCPU, cfg.ext_zba, true), - DEFINE_PROP_BOOL("zbb", RISCVCPU, cfg.ext_zbb, true), - DEFINE_PROP_BOOL("zbc", RISCVCPU, cfg.ext_zbc, true), - DEFINE_PROP_BOOL("zbkb", RISCVCPU, cfg.ext_zbkb, false), - DEFINE_PROP_BOOL("zbkc", RISCVCPU, cfg.ext_zbkc, false), - DEFINE_PROP_BOOL("zbkx", RISCVCPU, cfg.ext_zbkx, false), - DEFINE_PROP_BOOL("zbs", RISCVCPU, cfg.ext_zbs, true), - DEFINE_PROP_BOOL("zk", RISCVCPU, cfg.ext_zk, false), - DEFINE_PROP_BOOL("zkn", RISCVCPU, cfg.ext_zkn, false), - DEFINE_PROP_BOOL("zknd", RISCVCPU, cfg.ext_zknd, false), - DEFINE_PROP_BOOL("zkne", RISCVCPU, cfg.ext_zkne, false), - DEFINE_PROP_BOOL("zknh", RISCVCPU, cfg.ext_zknh, false), - DEFINE_PROP_BOOL("zkr", RISCVCPU, cfg.ext_zkr, false), - DEFINE_PROP_BOOL("zks", RISCVCPU, cfg.ext_zks, false), - DEFINE_PROP_BOOL("zksed", RISCVCPU, cfg.ext_zksed, false), - DEFINE_PROP_BOOL("zksh", RISCVCPU, cfg.ext_zksh, false), - DEFINE_PROP_BOOL("zkt", RISCVCPU, cfg.ext_zkt, false), - - DEFINE_PROP_BOOL("zdinx", RISCVCPU, cfg.ext_zdinx, false), - DEFINE_PROP_BOOL("zfinx", RISCVCPU, cfg.ext_zfinx, false), - DEFINE_PROP_BOOL("zhinx", RISCVCPU, cfg.ext_zhinx, false), - DEFINE_PROP_BOOL("zhinxmin", RISCVCPU, cfg.ext_zhinxmin, false), - - DEFINE_PROP_BOOL("zicbom", RISCVCPU, cfg.ext_icbom, true), - DEFINE_PROP_BOOL("zicboz", RISCVCPU, cfg.ext_icboz, true), - - DEFINE_PROP_BOOL("zmmul", RISCVCPU, cfg.ext_zmmul, false), - - DEFINE_PROP_BOOL("zca", RISCVCPU, cfg.ext_zca, false), - DEFINE_PROP_BOOL("zcb", RISCVCPU, cfg.ext_zcb, false), - DEFINE_PROP_BOOL("zcd", RISCVCPU, cfg.ext_zcd, false), - DEFINE_PROP_BOOL("zce", RISCVCPU, cfg.ext_zce, false), - DEFINE_PROP_BOOL("zcf", RISCVCPU, cfg.ext_zcf, false), - DEFINE_PROP_BOOL("zcmp", RISCVCPU, cfg.ext_zcmp, false), - DEFINE_PROP_BOOL("zcmt", RISCVCPU, cfg.ext_zcmt, false), - DEFINE_PROP_BOOL("zicond", RISCVCPU, cfg.ext_zicond, false), + MULTI_EXT_CFG_BOOL("sscofpmf", ext_sscofpmf, false), + MULTI_EXT_CFG_BOOL("Zifencei", ext_ifencei, true), + MULTI_EXT_CFG_BOOL("Zicsr", ext_icsr, true), + MULTI_EXT_CFG_BOOL("Zihintntl", ext_zihintntl, true), + MULTI_EXT_CFG_BOOL("Zihintpause", ext_zihintpause, true), + MULTI_EXT_CFG_BOOL("Zawrs", ext_zawrs, true), + MULTI_EXT_CFG_BOOL("Zfa", ext_zfa, true), + MULTI_EXT_CFG_BOOL("Zfh", ext_zfh, false), + MULTI_EXT_CFG_BOOL("Zfhmin", ext_zfhmin, false), + MULTI_EXT_CFG_BOOL("Zve32f", ext_zve32f, false), + MULTI_EXT_CFG_BOOL("Zve64f", ext_zve64f, false), + MULTI_EXT_CFG_BOOL("Zve64d", ext_zve64d, false), + MULTI_EXT_CFG_BOOL("sstc", ext_sstc, true), + + MULTI_EXT_CFG_BOOL("smstateen", ext_smstateen, false), + MULTI_EXT_CFG_BOOL("svadu", ext_svadu, true), + MULTI_EXT_CFG_BOOL("svinval", ext_svinval, false), + MULTI_EXT_CFG_BOOL("svnapot", ext_svnapot, false), + MULTI_EXT_CFG_BOOL("svpbmt", ext_svpbmt, false), + + MULTI_EXT_CFG_BOOL("zba", ext_zba, true), + MULTI_EXT_CFG_BOOL("zbb", ext_zbb, true), + MULTI_EXT_CFG_BOOL("zbc", ext_zbc, true), + MULTI_EXT_CFG_BOOL("zbkb", ext_zbkb, false), + MULTI_EXT_CFG_BOOL("zbkc", ext_zbkc, false), + MULTI_EXT_CFG_BOOL("zbkx", ext_zbkx, false), + MULTI_EXT_CFG_BOOL("zbs", ext_zbs, true), + MULTI_EXT_CFG_BOOL("zk", ext_zk, false), + MULTI_EXT_CFG_BOOL("zkn", ext_zkn, false), + MULTI_EXT_CFG_BOOL("zknd", ext_zknd, false), + MULTI_EXT_CFG_BOOL("zkne", ext_zkne, false), + MULTI_EXT_CFG_BOOL("zknh", ext_zknh, false), + MULTI_EXT_CFG_BOOL("zkr", ext_zkr, false), + MULTI_EXT_CFG_BOOL("zks", ext_zks, false), + MULTI_EXT_CFG_BOOL("zksed", ext_zksed, false), + MULTI_EXT_CFG_BOOL("zksh", ext_zksh, false), + MULTI_EXT_CFG_BOOL("zkt", ext_zkt, false), + + MULTI_EXT_CFG_BOOL("zdinx", ext_zdinx, false), + MULTI_EXT_CFG_BOOL("zfinx", ext_zfinx, false), + MULTI_EXT_CFG_BOOL("zhinx", ext_zhinx, false), + MULTI_EXT_CFG_BOOL("zhinxmin", ext_zhinxmin, false), + + MULTI_EXT_CFG_BOOL("zicbom", ext_icbom, true), + MULTI_EXT_CFG_BOOL("zicboz", ext_icboz, true), + + MULTI_EXT_CFG_BOOL("zmmul", ext_zmmul, false), + + MULTI_EXT_CFG_BOOL("zca", ext_zca, false), + MULTI_EXT_CFG_BOOL("zcb", ext_zcb, false), + MULTI_EXT_CFG_BOOL("zcd", ext_zcd, false), + MULTI_EXT_CFG_BOOL("zce", ext_zce, false), + MULTI_EXT_CFG_BOOL("zcf", ext_zcf, false), + MULTI_EXT_CFG_BOOL("zcmp", ext_zcmp, false), + MULTI_EXT_CFG_BOOL("zcmt", ext_zcmt, false), + MULTI_EXT_CFG_BOOL("zicond", ext_zicond, false), =20 DEFINE_PROP_END_OF_LIST(), }; =20 -static Property riscv_cpu_vendor_exts[] =3D { - DEFINE_PROP_BOOL("xtheadba", RISCVCPU, cfg.ext_xtheadba, false), - DEFINE_PROP_BOOL("xtheadbb", RISCVCPU, cfg.ext_xtheadbb, false), - DEFINE_PROP_BOOL("xtheadbs", RISCVCPU, cfg.ext_xtheadbs, false), - DEFINE_PROP_BOOL("xtheadcmo", RISCVCPU, cfg.ext_xtheadcmo, false), - DEFINE_PROP_BOOL("xtheadcondmov", RISCVCPU, cfg.ext_xtheadcondmov, fal= se), - DEFINE_PROP_BOOL("xtheadfmemidx", RISCVCPU, cfg.ext_xtheadfmemidx, fal= se), - DEFINE_PROP_BOOL("xtheadfmv", RISCVCPU, cfg.ext_xtheadfmv, false), - DEFINE_PROP_BOOL("xtheadmac", RISCVCPU, cfg.ext_xtheadmac, false), - DEFINE_PROP_BOOL("xtheadmemidx", RISCVCPU, cfg.ext_xtheadmemidx, false= ), - DEFINE_PROP_BOOL("xtheadmempair", RISCVCPU, cfg.ext_xtheadmempair, fal= se), - DEFINE_PROP_BOOL("xtheadsync", RISCVCPU, cfg.ext_xtheadsync, false), - DEFINE_PROP_BOOL("xventanacondops", RISCVCPU, cfg.ext_XVentanaCondOps,= false), +static RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[] =3D { + MULTI_EXT_CFG_BOOL("xtheadba", ext_xtheadba, false), + MULTI_EXT_CFG_BOOL("xtheadbb", ext_xtheadbb, false), + MULTI_EXT_CFG_BOOL("xtheadbs", ext_xtheadbs, false), + MULTI_EXT_CFG_BOOL("xtheadcmo", ext_xtheadcmo, false), + MULTI_EXT_CFG_BOOL("xtheadcondmov", ext_xtheadcondmov, false), + MULTI_EXT_CFG_BOOL("xtheadfmemidx", ext_xtheadfmemidx, false), + MULTI_EXT_CFG_BOOL("xtheadfmv", ext_xtheadfmv, false), + MULTI_EXT_CFG_BOOL("xtheadmac", ext_xtheadmac, false), + MULTI_EXT_CFG_BOOL("xtheadmemidx", ext_xtheadmemidx, false), + MULTI_EXT_CFG_BOOL("xtheadmempair", ext_xtheadmempair, false), + MULTI_EXT_CFG_BOOL("xtheadsync", ext_xtheadsync, false), + MULTI_EXT_CFG_BOOL("xventanacondops", ext_XVentanaCondOps, false), =20 DEFINE_PROP_END_OF_LIST(), }; =20 /* These are experimental so mark with 'x-' */ -static Property riscv_cpu_experimental_exts[] =3D { +static RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] =3D { /* ePMP 0.9.3 */ - DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false), - DEFINE_PROP_BOOL("x-smaia", RISCVCPU, cfg.ext_smaia, false), - DEFINE_PROP_BOOL("x-ssaia", RISCVCPU, cfg.ext_ssaia, false), + MULTI_EXT_CFG_BOOL("x-epmp", epmp, false), + MULTI_EXT_CFG_BOOL("x-smaia", ext_smaia, false), + MULTI_EXT_CFG_BOOL("x-ssaia", ext_ssaia, false), =20 - DEFINE_PROP_BOOL("x-zvfh", RISCVCPU, cfg.ext_zvfh, false), - DEFINE_PROP_BOOL("x-zvfhmin", RISCVCPU, cfg.ext_zvfhmin, false), + MULTI_EXT_CFG_BOOL("x-zvfh", ext_zvfh, false), + MULTI_EXT_CFG_BOOL("x-zvfhmin", ext_zvfhmin, false), =20 - DEFINE_PROP_BOOL("x-zfbfmin", RISCVCPU, cfg.ext_zfbfmin, false), - DEFINE_PROP_BOOL("x-zvfbfmin", RISCVCPU, cfg.ext_zvfbfmin, false), - DEFINE_PROP_BOOL("x-zvfbfwma", RISCVCPU, cfg.ext_zvfbfwma, false), + MULTI_EXT_CFG_BOOL("x-zfbfmin", ext_zfbfmin, false), + MULTI_EXT_CFG_BOOL("x-zvfbfmin", ext_zvfbfmin, false), + MULTI_EXT_CFG_BOOL("x-zvfbfwma", ext_zvfbfwma, false), =20 /* Vector cryptography extensions */ - DEFINE_PROP_BOOL("x-zvbb", RISCVCPU, cfg.ext_zvbb, false), - DEFINE_PROP_BOOL("x-zvbc", RISCVCPU, cfg.ext_zvbc, false), - DEFINE_PROP_BOOL("x-zvkg", RISCVCPU, cfg.ext_zvkg, false), - DEFINE_PROP_BOOL("x-zvkned", RISCVCPU, cfg.ext_zvkned, false), - DEFINE_PROP_BOOL("x-zvknha", RISCVCPU, cfg.ext_zvknha, false), - DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false), - DEFINE_PROP_BOOL("x-zvksed", RISCVCPU, cfg.ext_zvksed, false), - DEFINE_PROP_BOOL("x-zvksh", RISCVCPU, cfg.ext_zvksh, false), + MULTI_EXT_CFG_BOOL("x-zvbb", ext_zvbb, false), + MULTI_EXT_CFG_BOOL("x-zvbc", ext_zvbc, false), + MULTI_EXT_CFG_BOOL("x-zvkg", ext_zvkg, false), + MULTI_EXT_CFG_BOOL("x-zvkned", ext_zvkned, false), + MULTI_EXT_CFG_BOOL("x-zvknha", ext_zvknha, false), + MULTI_EXT_CFG_BOOL("x-zvknhb", ext_zvknhb, false), + MULTI_EXT_CFG_BOOL("x-zvksed", ext_zvksed, false), + MULTI_EXT_CFG_BOOL("x-zvksh", ext_zvksh, false), =20 DEFINE_PROP_END_OF_LIST(), }; @@ -1993,12 +2008,56 @@ static Property riscv_cpu_options[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 -static void riscv_cpu_add_qdev_prop_array(DeviceState *dev, Property *arra= y) +static void cpu_set_multi_ext_cfg(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + const RISCVCPUMultiExtConfig *multi_ext_cfg =3D opaque; + bool value; + + if (!visit_type_bool(v, name, &value, errp)) { + return; + } + + isa_ext_update_enabled(RISCV_CPU(obj), multi_ext_cfg->offset, value); + + g_hash_table_insert(multi_ext_user_opts, + GUINT_TO_POINTER(multi_ext_cfg->offset), + (gpointer)value); +} + +static void cpu_get_multi_ext_cfg(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + const RISCVCPUMultiExtConfig *multi_ext_cfg =3D opaque; + bool value =3D isa_ext_is_enabled(RISCV_CPU(obj), multi_ext_cfg->offse= t); + + visit_type_bool(v, name, &value, errp); +} + +static void cpu_add_multi_ext_prop(Object *cpu_obj, + RISCVCPUMultiExtConfig *multi_cfg) +{ + object_property_add(cpu_obj, multi_cfg->name, "bool", + cpu_get_multi_ext_cfg, + cpu_set_multi_ext_cfg, + NULL, (void *)multi_cfg); + + /* + * Set def val directly instead of using + * object_property_set_bool() to save the set() + * callback hash for user inputs. + */ + isa_ext_update_enabled(RISCV_CPU(cpu_obj), multi_cfg->offset, + multi_cfg->enabled); +} + +static void riscv_cpu_add_multiext_prop_array(Object *obj, + RISCVCPUMultiExtConfig *arra= y) { g_assert(array); =20 - for (Property *prop =3D array; prop && prop->name; prop++) { - qdev_property_add_static(dev, prop); + for (RISCVCPUMultiExtConfig *prop =3D array; prop && prop->name; prop+= +) { + cpu_add_multi_ext_prop(obj, prop); } } =20 @@ -2038,11 +2097,11 @@ static void riscv_cpu_add_kvm_unavail_prop(Object *= obj, const char *prop_name) } =20 static void riscv_cpu_add_kvm_unavail_prop_array(Object *obj, - Property *array) + RISCVCPUMultiExtConfig *a= rray) { g_assert(array); =20 - for (Property *prop =3D array; prop && prop->name; prop++) { + for (RISCVCPUMultiExtConfig *prop =3D array; prop && prop->name; prop+= +) { riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } } @@ -2077,8 +2136,6 @@ void kvm_riscv_cpu_add_kvm_properties(Object *obj) */ static void riscv_cpu_add_user_properties(Object *obj) { - DeviceState *dev =3D DEVICE(obj); - #ifndef CONFIG_USER_ONLY riscv_add_satp_mode_properties(obj); =20 @@ -2090,10 +2147,13 @@ static void riscv_cpu_add_user_properties(Object *o= bj) =20 riscv_cpu_add_misa_properties(obj); =20 - riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_extensions); - riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_options); - riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_vendor_exts); - riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_experimental_exts); + riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_extensions); + riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_vendor_exts); + riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_experimental_exts); + + for (Property *prop =3D riscv_cpu_options; prop && prop->name; prop++)= { + qdev_property_add_static(DEVICE(obj), prop); + } } =20 /* @@ -2104,7 +2164,7 @@ static void riscv_init_max_cpu_extensions(Object *obj) { RISCVCPU *cpu =3D RISCV_CPU(obj); CPURISCVState *env =3D &cpu->env; - Property *prop; + RISCVCPUMultiExtConfig *prop; =20 /* Enable RVG, RVJ and RVV that are disabled by default */ set_misa(env, env->misa_mxl, env->misa_ext | RVG | RVJ | RVV); --=20 2.41.0 From nobody Thu May 9 12:31:28 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=1694525376; cv=none; d=zohomail.com; s=zohoarc; b=BWIRInDV4Es8o0MzysUb0coTdrTBSXuxPc0b8CxeFQigzdq7ZdDJsp3jYQ6h/tKRlKjvoHtFWjCEAY0Nmj1/MQdb+0vwQBGY90TeEcKnuuGQZJuGM+Ln5Pomk97H6PXuJDyYIuVVTk6JVmMg2/IgOB2QfrFHCXgQp6xG89OWZi0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525376; 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=6fh7NT1S1YPs5nnVNPwU08i/h6gPC0ST6+6uExkwNm8=; b=dsxgs8pGMvPAlFb02aD7pNyTKfRVH45NeoMb3mJ/ktO5fml4xw8GF4ak6rSEregLxsYok3Of2LN83AEJQLcS8eQUkN30lEt5aCHorz8bUGbtF6ffTFakDOaz7qkPG7atfpICEPzyS02ghbNE4TEf9rwERpo8fp35UoB4Ivvt36E= 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 1694525376290319.9359310781142; Tue, 12 Sep 2023 06:29:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3Om-0003I4-R7; Tue, 12 Sep 2023 09:25:48 -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 1qg3Od-00038F-HI for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:43 -0400 Received: from mail-oo1-xc36.google.com ([2607:f8b0:4864:20::c36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3OZ-0003vB-Ci for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:38 -0400 Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-57361de8878so3432154eaf.0 for ; Tue, 12 Sep 2023 06:25:34 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:25:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525133; x=1695129933; 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=6fh7NT1S1YPs5nnVNPwU08i/h6gPC0ST6+6uExkwNm8=; b=Sj51NIpQhhDhOEUPeE6UJFxFUI2ECrfry1n5P6G08Eh7QXLvSPutmXumBAo8ljTfIu OOzXwyDBuUSW0Q4T9CaJ/maJ8Aweoay6oWauOhlkYjz2OSuV1iv6RZKkp9M33LHUXCQQ anBs5ml0rOX9a/zEJWsFWEqX6bjKogTA6yvKGznKrCdGt37rzlNWPj+7WPBcNb3k8qyc 4ou8D2Nl9jyk3nFlEO61AvnVeGRae6cqzsGeio0o2u/EiskdBcySf08sATpHjkapVsRD yrMOcTP5TjoBk6Hzxc3JQ26EGZw/UHyZO+yAdURvfdZEAqCZrG1HjAcuRfIbrX6GS9XA 23mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525133; x=1695129933; 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=6fh7NT1S1YPs5nnVNPwU08i/h6gPC0ST6+6uExkwNm8=; b=F5SJxzZU7xO46G86WIpw7z/J80gdPKf07ZBBREQcEtE+u4GM8gJ/wM4DRVNQjn1S/n jA7LfT//JNaAmdiu6h2iZiGaX+F+f0sRN4wzMLHFLL+T1/uHTEmq9eKuytxuc5Vw/agj bHYyweUqwZhXWCeYZ1yJGLsa8gtBGS2v/l/ipnOnEhVnGFk6kVsyVKz8Jg6QW5b+IAxk Ne8xsvArLlOmCvYMPZp/3kHhAbBkNOfHJE10GV+HgMImQsodSMHjIqqHL0R1Fq+lz2sr QVFUCPMGQRhWyGtcGgrlNcZA5E9FYcL+2nJnYinPswEW896y+Mv7d/V3IQ2/GFgB3vjR +QLA== X-Gm-Message-State: AOJu0YzOkDHgmJwknQkUpxdRrUf19v0ZgJI3rcBukRsaG6B2U4CnVg0H fJjQQovZgY1MRrbPCrOa0a3/JEiSkaNpkCZA6Eg= X-Google-Smtp-Source: AGHT+IGglHNko0Dsh9ZmDx8hoD7zHnnZUqJZJ3mDRG40vM8+fX5TskQNSQKYaP+y1LSqXpL4hmlhsQ== X-Received: by 2002:a4a:919c:0:b0:571:1a1d:f230 with SMTP id d28-20020a4a919c000000b005711a1df230mr11206630ooh.9.1694525133636; Tue, 12 Sep 2023 06:25:33 -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 v10 18/20] target/riscv: use isa_ext_update_enabled() in init_max_cpu_extensions() Date: Tue, 12 Sep 2023 10:24:21 -0300 Message-ID: <20230912132423.268494-19-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-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::c36; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc36.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: 1694525378799100003 Content-Type: text/plain; charset="utf-8" Before adding support to detect if an extension was user set we need to handle how we're enabling extensions in riscv_init_max_cpu_extensions(). object_property_set_bool() calls the set() callback for the property, and we're going to use this callback to set the 'multi_ext_user_opts' hash. This means that, as is today, all extensions we're setting for the 'max' CPU will be seen as user set in the future. Let's change set_bool() to isa_ext_update_enabled() that will just enable/disable the flag on a certain offset. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index e79fe13b26..b041d3c5db 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -2170,24 +2170,24 @@ static void riscv_init_max_cpu_extensions(Object *o= bj) set_misa(env, env->misa_mxl, env->misa_ext | RVG | RVJ | RVV); =20 for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { - object_property_set_bool(obj, prop->name, true, NULL); + isa_ext_update_enabled(cpu, prop->offset, true); } =20 /* set vector version */ env->vext_ver =3D VEXT_VERSION_1_00_0; =20 /* Zfinx is not compatible with F. Disable it */ - object_property_set_bool(obj, "zfinx", false, NULL); - object_property_set_bool(obj, "zdinx", false, NULL); - object_property_set_bool(obj, "zhinx", false, NULL); - object_property_set_bool(obj, "zhinxmin", false, NULL); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zfinx), false); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zdinx), false); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zhinx), false); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zhinxmin), false); =20 - object_property_set_bool(obj, "zce", false, NULL); - object_property_set_bool(obj, "zcmp", false, NULL); - object_property_set_bool(obj, "zcmt", false, NULL); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zce), false); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zcmp), false); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zcmt), false); =20 if (env->misa_mxl !=3D MXL_RV32) { - object_property_set_bool(obj, "zcf", false, NULL); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zcf), false); } } =20 --=20 2.41.0 From nobody Thu May 9 12:31:28 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=1694525501; cv=none; d=zohomail.com; s=zohoarc; b=PFudw1miMX22+ygG57ZFzbc9IgJ6UMul1/Dk0K0fZUrMCpjHlOWJixSPl8qzy2Wv3tB1e3KMruG7vixNT4PEbfdhmJQ36DMLLdw0q+Dpzhv7sGI/9cW3igD/KvNNtKH1J6h/kBzVg07xVCmpkdYLBWSfQXH+I8EB4c2W7xCdNDg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694525501; 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=EPB8Q5NlppSdfi0+ut0VqBbWb9jhPK5yJP3ZV8PISZA=; b=lHNwXAPr57wAOeuKBsKrBSjRUFGv4t+TFgwXNYUzuhYIv8WpodpBD+Sc20Kr5vOfuoYRsDKBRe4D8N48ydoww4R9emDYQvnyqbrP2EtJ0vP/9lOZh783QsguSS6+P4HkzD1WmCjIBUZEvcjk2Aj+YMiZ0d59xw6sgg/ROTBeyDE= 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 169452550122823.998796371858475; Tue, 12 Sep 2023 06:31:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3Ou-0003zl-3R; Tue, 12 Sep 2023 09:25:56 -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 1qg3Or-0003nw-T4 for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:53 -0400 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3Oc-0003wr-4Z for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:53 -0400 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6bf2427b947so3591864a34.3 for ; Tue, 12 Sep 2023 06:25:37 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.25.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525137; x=1695129937; 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=EPB8Q5NlppSdfi0+ut0VqBbWb9jhPK5yJP3ZV8PISZA=; b=VfPGlj7BlRMDptJXMKaVidxLQU1YigtRCqbbpeUe/3XIzWMPDb5X9wtXJXMCOhxWCn kLbjDtUa87zJiDfajkZZLCu6qyIVj85Ob8J3ki6mSIHVateU+QHwlaIQW6u2s9g/1QOn 1UKWGBZ7jlBvku2fyOOVYzxkdZ5WMyvFWV77T7Lfmr/BhzKcSFSZbjSKUO5XmBkGiVmJ ZKv5PC9nFUORVqEt3//MPbwXKnj75Ho7TDIInhJEjokcZ2PK6suttrVTLaD+7W+ThIO2 GGvWYcUIgjSMLBr1aC7Y2l3bvwMpPzZ4F6rqM6Ap/1tIdE5bi8NMVPC1oT8ILqxPykWm Avhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525137; x=1695129937; 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=EPB8Q5NlppSdfi0+ut0VqBbWb9jhPK5yJP3ZV8PISZA=; b=JrKcLtAVbXkztJqHtkl522EkxyH7rvfpobQHZSEi4IYYjwmb5PG5Qnq+ERAc/TdgOX xHQxCDjofBC50aody5NOzNkncE0Mn9vzxCEsu70r5yAtRqhSd1PPWa9iys27Av8ZIb09 rizbCMAqzyfO50HWgTdsmvMPrV9HLpf6EAcddjK4yiCpHTtZtjY5flMTTBL/9URFXxib +Yn3ZX/RmgHFWHmOuqkLWNNYPssP7Vex+i87XlhAT/iUFVsgHF/TTkJlkI8wX3XUY4eh xvljyHdPpW2S46upPPiK+Zz/sZA0FHSLbcn6aT7waR+nKgDXwYkz+dtU5CO37ryHcyRi ZwQQ== X-Gm-Message-State: AOJu0YxHqXP0BOlpBf0O9yyA/cAP3N4kSSChfeQz3ErsbIokBgqP3CNX aXzHPQzaHG1sc8zfivUnDczYrSUd7b6QKvMSZSw= X-Google-Smtp-Source: AGHT+IFdjUm0n8gxVj5bYVuzBQIS2+CuaAftPRD0m87+yhEvyXnbG4mGel3J7OYGQE6MJjNyzss9Yg== X-Received: by 2002:a9d:66c7:0:b0:6bd:a47:7bb6 with SMTP id t7-20020a9d66c7000000b006bd0a477bb6mr11599710otm.14.1694525136853; Tue, 12 Sep 2023 06:25:36 -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 v10 19/20] target/riscv/cpu.c: honor user choice in cpu_cfg_ext_auto_update() Date: Tue, 12 Sep 2023 10:24:22 -0300 Message-ID: <20230912132423.268494-20-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-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::329; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x329.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, 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: 1694525502389100001 Content-Type: text/plain; charset="utf-8" Add a new cpu_cfg_ext_is_user_set() helper to check if an extension was set by the user in the command line. Use it inside cpu_cfg_ext_auto_update() to verify if the user set a certain extension and, if that's the case, do not change its value. This will make us honor user choice instead of overwriting the values. Users will then be informed whether they're using an incompatible set of extensions instead of QEMU setting a magic value that works. The reason why we're not implementing user choice for MISA extensions right now is because, today, we do not silently change any MISA bit during realize() time (we do warn when enabling bits if RVG is enabled). We do that - a lot - with multi-letter extensions though, so we're handling the most immediate concern first. After this patch, we'll now error out if the user explicitly set 'zce' to t= rue and 'zca' to false: $ ./build/qemu-system-riscv64 -M virt -cpu rv64,zce=3Dtrue,zca=3Dfalse -nog= raphic qemu-system-riscv64: Zcf/Zcd/Zcb/Zcmp/Zcmt extensions require Zca extension This didn't happen before because we were enabling 'zca' if 'zce' was enabl= ed regardless if the user set 'zca' to false. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index b041d3c5db..fb8e4d6a8f 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -195,6 +195,12 @@ static int cpu_cfg_ext_get_min_version(uint32_t ext_of= fset) g_assert_not_reached(); } =20 +static bool cpu_cfg_ext_is_user_set(uint32_t ext_offset) +{ + return g_hash_table_contains(multi_ext_user_opts, + GUINT_TO_POINTER(ext_offset)); +} + static void cpu_cfg_ext_auto_update(RISCVCPU *cpu, uint32_t ext_offset, bool value) { @@ -206,6 +212,10 @@ static void cpu_cfg_ext_auto_update(RISCVCPU *cpu, uin= t32_t ext_offset, return; } =20 + if (cpu_cfg_ext_is_user_set(ext_offset)) { + return; + } + if (value && env->priv_ver !=3D PRIV_VERSION_LATEST) { /* Do not enable it if priv_ver is older than min_version */ min_version =3D cpu_cfg_ext_get_min_version(ext_offset); @@ -1847,6 +1857,12 @@ static RISCVCPUMisaExtConfig misa_ext_cfgs[] =3D { MISA_CFG(RVG, false), }; =20 +/* + * We do not support user choice tracking for MISA + * extensions yet because, so far, we do not silently + * change MISA bits during realize() (RVG enables MISA + * bits but the user is warned about it). + */ static void riscv_cpu_add_misa_properties(Object *cpu_obj) { int i; --=20 2.41.0 From nobody Thu May 9 12:31:28 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=1694529201; cv=none; d=zohomail.com; s=zohoarc; b=OW4rqa62GmBIKnn9s2VY/c/2RRvdMhPD9KR8KkyRnrmeU92o7nndfBVthivxEfuhczlGyZ9Ie8ZO8n4z55i6vg+AjuJwPiiAu/83QU5Cfbn24nFoDN/oVKKFb778kFKKhugL8yhr5uoDm13As+gsr9wjpVoAzUpXyD9QD7ej8M0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694529201; 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=b6iO2bfUgyZtWhxauloKtcvAGEb6vGPXh6RDEUPqof0=; b=euVvFpp2vQcwE9kb3yOC0YQXdw6QJxHzcxV422VaY5DNCSmuwCfTMXlAR0QN4NAwW7D+V7pwomvlBwKrdvS9th3FUKoDiOEYzSEaPG9mvFNPnQxsthqBG7h8SJnKQuvDhf7tWlDNqExfTAm+A7p9iBE44Fhx3c4fhI1IaI8vAJA= 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 1694529201756675.8933021267369; Tue, 12 Sep 2023 07:33:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3Ou-0003zi-2o; Tue, 12 Sep 2023 09:25:56 -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 1qg3Or-0003oh-Tv for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:53 -0400 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3Of-0003z5-BL for qemu-devel@nongnu.org; Tue, 12 Sep 2023 09:25:53 -0400 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-6bc9c01e154so3399293a34.0 for ; Tue, 12 Sep 2023 06:25:41 -0700 (PDT) Received: from grind.. ([177.9.182.82]) by smtp.gmail.com with ESMTPSA id p15-20020a0568301d4f00b006af9d8af435sm3991255oth.50.2023.09.12.06.25.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:25:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694525140; x=1695129940; 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=b6iO2bfUgyZtWhxauloKtcvAGEb6vGPXh6RDEUPqof0=; b=V9+GzsNCOeVb6MUL3zSVjreRfvfQqk+ce4eeLOlVA0l79yfM2jph+kRXws/uK+7EEf KiCRKQx3+rykI0FkLnEf9Dz+v44TXjmloSsgB8RAb/dOwOZo8EsHqEWayv905k5xQBRk KzznQp0eCP9DkEmHwvrxXTYXaF9yELHLUHKdZ9HneCUFBB2FVN1TNLVexUo/7A4MtoHu fG+JR+03mXO+nqmSNBmIb24u1+PIlrriMnQOEECQLScRUnjjn9L+dzbF9ZxEfav2lRO5 K0hXZZa+IlW45I5Kng0/UrNcd75ExUjNsCzItA/s5tqSIq9LpO2QrgUYsEKwL2FE9tZW w0KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525140; x=1695129940; 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=b6iO2bfUgyZtWhxauloKtcvAGEb6vGPXh6RDEUPqof0=; b=rPnbKqDrtB2IZbE5O5HiwJd/b3jozadtjjZYcrujnIB6LuXp6vHRIv7yoGSV5+S1lo I/w0BmRhSA5X5so/iifD0lp2DrHN0oEynjbVCxfFQ4xdg3zM27B8gBqh9sYNWfTGz5Rc bTBnDArqN7hK1uinvqrydA1DK3t2muPvP8+T/ilSHS4/j9JPvfAV/IneTFajBnAEkznh ko0o/026Y1HC9W1kFUEeQXuVvT4lO4Rf/PYVzowWv/ctjxBSYKmrwQwOdXbXK49Yi1Bi 3f5Fw8749ZLjXxVtfeeSGexsL3rWweMAw4S3y8WDa3rTTAtPK8/wZ51cZAjDhWSDJts2 bxeg== X-Gm-Message-State: AOJu0YxsyXEY6ytcStAmrhD5CHrhYsUWZUpCxeYkKWNldXod2hzhuKIU 1BQT2V90mOxppHZWjOC6Pv7JO11HC0vXoA84kOg= X-Google-Smtp-Source: AGHT+IF4JSmx+ozfKtiRFMjbJNbIbmpMGphRK01mXXOyJ4lnfl8TJPyHQ1boBgYzfu8nr1ejOcxdgA== X-Received: by 2002:a05:6830:4126:b0:6be:f8b8:5945 with SMTP id w38-20020a056830412600b006bef8b85945mr1471401ott.19.1694525140130; Tue, 12 Sep 2023 06:25:40 -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 v10 20/20] target/riscv/cpu.c: consider user option with RVG Date: Tue, 12 Sep 2023 10:24:23 -0300 Message-ID: <20230912132423.268494-21-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912132423.268494-1-dbarboza@ventanamicro.com> References: <20230912132423.268494-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::32a; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x32a.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, 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 @ventanamicro.com) X-ZM-MESSAGEID: 1694529203825100001 Content-Type: text/plain; charset="utf-8" Enabling RVG will enable a set of extensions that we're not checking if the user was okay enabling or not. And in this case we want to error out, instead of ignoring, otherwise we will be inconsistent enabling RVG without all its extensions. After this patch, disabling ifencei or icsr while enabling RVG will result in error: $ ./build/qemu-system-riscv64 -M virt -cpu rv64,g=3Dtrue,Zifencei=3Dfalse -= -nographic qemu-system-riscv64: RVG requires Zifencei but user set Zifencei to false Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index fb8e4d6a8f..2644638b11 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1153,9 +1153,23 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu= , Error **errp) riscv_has_ext(env, RVA) && riscv_has_ext(env, RVF) && riscv_has_ext(env, RVD) && cpu->cfg.ext_icsr && cpu->cfg.ext_ifencei)) { + + if (cpu_cfg_ext_is_user_set(CPU_CFG_OFFSET(ext_icsr)) && + !cpu->cfg.ext_icsr) { + error_setg(errp, "RVG requires Zicsr but user set Zicsr to fal= se"); + return; + } + + if (cpu_cfg_ext_is_user_set(CPU_CFG_OFFSET(ext_ifencei)) && + !cpu->cfg.ext_ifencei) { + error_setg(errp, "RVG requires Zifencei but user set " + "Zifencei to false"); + return; + } + warn_report("Setting G will also set IMAFD_Zicsr_Zifencei"); - cpu->cfg.ext_icsr =3D true; - cpu->cfg.ext_ifencei =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_icsr), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_ifencei), true); =20 env->misa_ext |=3D RVI | RVM | RVA | RVF | RVD; env->misa_ext_mask |=3D RVI | RVM | RVA | RVF | RVD; --=20 2.41.0