From patchwork Wed Feb 15 18:57:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13142076 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A9A96C636CC for ; Wed, 15 Feb 2023 18:59:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMyT-0007tN-RX; Wed, 15 Feb 2023 13:57:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyH-0007bS-RT for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:37 -0500 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyG-0007vU-E6 for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:37 -0500 Received: by mail-oi1-x22a.google.com with SMTP id w11so1979542oiv.5 for ; Wed, 15 Feb 2023 10:57:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=x3Rpse8tpnuic4jsmgudmXGGcOHYXYnwKwheV2Dzwek=; b=FcoLlVlO2EyTVFlPSJqjZ4uF/aqJZRiq7eIFQ6gK7iKD5x1HT7jRGYguk77LDnNsJ+ QN94ingGm1iDIa9pSC9tCw2unv+oPKUBWkIAx4weF9Q3UU8rIs9uiiR31B/+CllrBotS m+ab4WYTbb9joq7ABM44HNourW2pcASUGv7U9Hl6vUzxpJ1OwA0MOWF7U2t4hg8Pd1t7 dJX8mnqjUgzduAfIx/Hd4kfHq3dzHSb7FvnV7wh1cMcAyZVl6dK4F1eiAOdtfIJh/Rdv ezCGk/z6MgXHJwCTnZUIDeii+h9Mu0ZHUhvILTyi7aUIWoKTwhoLQDgRjFz3gDjQ5u7e +8kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=x3Rpse8tpnuic4jsmgudmXGGcOHYXYnwKwheV2Dzwek=; b=XjrrpJyhbnyumA+N07dOJ57AooP2A3l+8Jm8rk2B0luj2H5GptDZZAcdesV4Q+Gwqp 3hgjqSwCuZuMPO4JNt8WygEga/noKugujBTv+wYor/fQLTrz8NUhN44+IkEq/MSg1MX+ 6hwWcP+THMTMiSkVJ2p+iymHdmYyGLnxEq3w5hmm4tW5iIYkqdc8lT+qdxVFpaXw/CSY Fuadq/qLHKE+okye2rPKmfADNcZZxVznrOzoUFizNnB13hNPnXvlCbmyrF3C8g2Ekmr9 u77L1JRl1hJ84/Vp+nq0BdkuWaH7ol6qImmWY2s4KO1T55Cdq8k3T1fEbK4nk6mWL6hv m8Fg== X-Gm-Message-State: AO0yUKW+/RdSLHLetODqBBqi+DR1ETsNBZhoO2fkKa1dHlRKytj2Cix4 7cbhB3ngFxU14LxNI+STGh8ozwgahx+9/kA1 X-Google-Smtp-Source: AK7set/DvhK0t/FJCTsjEpczCv54R/ierhNHtg9X91RNyi9WPCrnabmpaUfLgHbdbCkMhWsUfNMyvA== X-Received: by 2002:a05:6808:147:b0:36f:883:6f76 with SMTP id h7-20020a056808014700b0036f08836f76mr1248238oie.7.1676487455043; Wed, 15 Feb 2023 10:57:35 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:34 -0800 (PST) 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, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 01/10] target/riscv: do not mask unsupported QEMU extensions in write_misa() Date: Wed, 15 Feb 2023 15:57:17 -0300 Message-Id: <20230215185726.691759-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22a; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x22a.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The masking done using env->misa_ext_mask already filters any extension that QEMU doesn't support. If the hart supports the extension then QEMU supports it as well. If the masking done by env->misa_ext_mask is somehow letting unsupported QEMU extensions pass by, misa_ext_mask itself needs to be fixed instead. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/csr.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 1b0a0c1693..e149b453da 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1356,9 +1356,6 @@ static RISCVException write_misa(CPURISCVState *env, int csrno, /* Mask extensions that are not supported by this hart */ val &= env->misa_ext_mask; - /* Mask extensions that are not supported by QEMU */ - val &= (RVI | RVE | RVM | RVA | RVF | RVD | RVC | RVS | RVU | RVV); - /* 'D' depends on 'F', so clear 'D' if 'F' is not present */ if ((val & RVD) && !(val & RVF)) { val &= ~RVD; From patchwork Wed Feb 15 18:57:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13142067 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F37FCC636D4 for ; Wed, 15 Feb 2023 18:58:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMya-00081r-PI; Wed, 15 Feb 2023 13:57:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyN-0007i5-JA for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:43 -0500 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyI-0007vG-SW for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:41 -0500 Received: by mail-oi1-x236.google.com with SMTP id bd6so16640945oib.6 for ; Wed, 15 Feb 2023 10:57:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=8Ogl+RmsTuQKGbHwWL7YbtcFc2a1h5NOUKob+9lW4sA=; b=jQ07UfJNwJQi5B+O+HiP6ewYT/fSCOu79nfT3G8yaztn3ZQWBBo72psVIMPZQISBW0 TLewFyR5NiXFi4ACeXfqxGNqRZgj0yQ3ErzqGjNxXezBY2Q6UTku/pSVE6ThqeuSqF4J +zRAHjf85fUQeBijEINdOlD1XqUJrOVQmbfHOHHgMif+TgTHagSlmMRPY3LOXjcLkMzr s6MLWDEb9WKs3EVW8kOmkF6ZWdR7JVrKTYRE6XxtOLK74Za9q3o9rrO7XmhVMDnT8j2L wXA6Bkgl5FvhAiTtEBdon8HdNeKskg5/KWQtLyOMWXb/eMW2yBR5k7AzB2bAAGaApEWf GgOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=8Ogl+RmsTuQKGbHwWL7YbtcFc2a1h5NOUKob+9lW4sA=; b=fEdPJbvdC79Bius5Rmc6V+1pzrR8+lPIndqZOR+CjvaMFze0uGc2jyXZMDAuxPC18e nPD+cHCmNAAaF5byrSAJCYaaONceXBCS0PCdqXGfHcZAb2bhCCU6sEgdik4iWhedZeya tnXuNWp3HUlT9k6CfT2oSfPXzWZnawEbpUc3IYI4WKy4qF7M+iBwVBe00QtEyxcUWn5w An/Q1ojdYWKPxPjygt8IxNYRWN4UwKsqu/RfRyI9figbcWAJ8ttI1USizu/NrQ+Rt7ii Q9yZlm1EZ1y7FEWCAYCJiHPmRcLC76QMC44zClLGOWK1BMTWP9h0cHgpEBmdlRQallW4 NDkw== X-Gm-Message-State: AO0yUKWSTC+oYrlFmE/NzjX8TuCtAnSPsmxPKilQErM1yCSoLYutTfTY ymr00IV2urqaeUyJ8Hz+5n12rvahb83r4HPf X-Google-Smtp-Source: AK7set+tLP3B9PXez80z08GAQtqgo6BLcJHzVLBiJh7tHb+2otHPNI2wQuuZH6ufYEDAAsAkDsFMMA== X-Received: by 2002:a05:6808:1185:b0:37a:2bf0:502a with SMTP id j5-20020a056808118500b0037a2bf0502amr2615611oil.24.1676487457908; Wed, 15 Feb 2023 10:57:37 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:37 -0800 (PST) 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, Daniel Henrique Barboza Subject: [PATCH v3 02/10] target/riscv: always allow write_misa() to write MISA Date: Wed, 15 Feb 2023 15:57:18 -0300 Message-Id: <20230215185726.691759-3-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::236; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x236.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org At this moment, and apparently since ever, we have no way of enabling RISCV_FEATURE_MISA. This means that all the code from write_misa(), all the nuts and bolts that handles how to properly write this CSR, has always been a no-op as well because write_misa() will always exit earlier. This seems to be benign in the majority of cases. Booting an Ubuntu 'virt' guest and logging all the calls to 'write_misa' shows that no writes to MISA CSR was attempted. Writing MISA, i.e. enabling/disabling RISC-V extensions after the machine is powered on, seems to be a niche use. Regardless, the spec says that MISA is a WARL read-write CSR, and gating the writes in the register doesn't make sense. OS and applications should be wary of the consequences when writing it, but the write itself must always be allowed. Remove the RISCV_FEATURE_MISA verification at the start of write_misa(), removing RISCV_FEATURE_MISA altogether since there will be no more callers of this enum. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Bin Meng --- target/riscv/cpu.h | 1 - target/riscv/csr.c | 5 ----- 2 files changed, 6 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 7128438d8e..01803a020d 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -89,7 +89,6 @@ enum { RISCV_FEATURE_MMU, RISCV_FEATURE_PMP, RISCV_FEATURE_EPMP, - RISCV_FEATURE_MISA, RISCV_FEATURE_DEBUG }; diff --git a/target/riscv/csr.c b/target/riscv/csr.c index e149b453da..5bd4cdbef5 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1329,11 +1329,6 @@ static RISCVException read_misa(CPURISCVState *env, int csrno, static RISCVException write_misa(CPURISCVState *env, int csrno, target_ulong val) { - if (!riscv_feature(env, RISCV_FEATURE_MISA)) { - /* drop write to misa */ - return RISCV_EXCP_NONE; - } - /* 'I' or 'E' must be present */ if (!(val & (RVI | RVE))) { /* It is not, drop write to misa */ From patchwork Wed Feb 15 18:57:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13142072 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A030C636D7 for ; Wed, 15 Feb 2023 18:58:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMyV-0007vG-HQ; Wed, 15 Feb 2023 13:57:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyP-0007qE-MI for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:46 -0500 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyN-0007vQ-Cn for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:45 -0500 Received: by mail-oi1-x22a.google.com with SMTP id cz14so16639408oib.12 for ; Wed, 15 Feb 2023 10:57:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=/ze670EFc4knKxHYmBNv1C1tJqYk4J5P+dEI+i7TEM8=; b=a8ZrW13ClEJW9k3sGdoDd/f+UNGHaZrkEemRiReeQDDQnD+qn3rTtfBR8+KQItUhcy 6OMhONJdDJE+CRjYKHGcm2mwKVqXEu+Ex0IkbZlulc0ZBHj+RPZ+cNVaQk1K3rI+l/1J SvQWJk5WoPQvWeJSWmRNFyFN0p6sikJio/z4co/dxlDU0xXG9XDJ6fVXxyHo4+qTrYTN JiKCb28ynJeC4dJqLsVmzhI92GEUww1Umbe2Bn3t6r83RqV3ggQF0pZtw4hDEKUzT5kH Po624CfWPD+B239xrSAY5j+f3ua+PvVn2gXa3qIY2Ncvo7nJ3CXlEFDGdusQizFgPArm 1N5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=/ze670EFc4knKxHYmBNv1C1tJqYk4J5P+dEI+i7TEM8=; b=fimMn10m2BUQLwBH4zDSqZjTx5PJiyfiXCXnGx+T+CoJVX6egX37DXG059OqEuWQhm +9YgT/Q/WdSMZu23Bj2iqLbU7/bqAoYbvb6fXkcRs+SAUn7nWc7jADtaChaPWmfwDjyI KaFs9BAtSkPACGSELcZV64W+WhExbAjYLlNGjZ+pBuPPKbkoLr8s9z1pzMyiTafUWohr S/78kxaiSxmVWcHaUHoacS0Bq6D0eVTuXXvOKHjV5yLHRYE8J5ZITNdFCvvCuzlVRK62 sWth09ijEX2Y132U775SuIvbDd1BbNAS7pPGoMswaqkIzNZc8ualpNZZfBwfjXW9YZ33 CCNg== X-Gm-Message-State: AO0yUKWW249jLBP8Gl3HoHJ421GsIQ8n2lJXWzlxpNtITK7RgUJe/OuZ rxJbCzcAMKqRkQa5nOF6ZkwE7n6V1O7PNn6U X-Google-Smtp-Source: AK7set9uUatECYM/r7dub4NSKg4e1kFYuWBBnWLAba6RQt5b7r7VozhT9T0eA3wEUMkwWkRwpaYsyA== X-Received: by 2002:a05:6808:9ad:b0:37a:d54f:8c7a with SMTP id e13-20020a05680809ad00b0037ad54f8c7amr1191017oig.59.1676487461024; Wed, 15 Feb 2023 10:57:41 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:40 -0800 (PST) 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, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 03/10] target/riscv: introduce riscv_cpu_cfg() Date: Wed, 15 Feb 2023 15:57:19 -0300 Message-Id: <20230215185726.691759-4-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22a; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x22a.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org We're going to do changes that requires accessing the RISCVCPUConfig struct from the RISCVCPU, having access only to a CPURISCVState 'env' pointer. Add a helper to make the code easier to read. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 01803a020d..368a522b5b 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -653,6 +653,11 @@ static inline RISCVMXL riscv_cpu_mxl(CPURISCVState *env) #endif #define riscv_cpu_mxl_bits(env) (1UL << (4 + riscv_cpu_mxl(env))) +static inline RISCVCPUConfig riscv_cpu_cfg(CPURISCVState *env) +{ + return env_archcpu(env)->cfg; +} + #if defined(TARGET_RISCV32) #define cpu_recompute_xl(env) ((void)(env), MXL_RV32) #else From patchwork Wed Feb 15 18:57:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13142074 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E237C636CC for ; Wed, 15 Feb 2023 18:59:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMyj-0008S8-Hd; Wed, 15 Feb 2023 13:58:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyR-0007sm-F0 for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:49 -0500 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyP-0007wk-BF for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:46 -0500 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-16a7f5b6882so24090790fac.10 for ; Wed, 15 Feb 2023 10:57:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=ztd1b1aEAN7YodigTUG6Ro/lcZCclFr+SzJZ6tToCaI=; b=Pu55rwRByNtTYPjjpdQkaIgwolVW2n2+TwhxLZwIi30skV0hSLHPaWhBhd/fWCRCnp 6stZ4sv2rLzNLFFjqVDZriFbas+ABj0JiBM383JxAs1GDYc5/72L+KNmSOSw/QiEyJWT 34/UWEGnXY+OuIMhzHbxP0Bc4waNqn889QmeqE79Xsf05EQkHsJ+PgO7XNa0aLtQnz0k 2i9J5TLfoN6qBRVd8noUlTJu32QmHulNHIQ6cDcatICYuRRZ4+TVD4v5mpdMV/EYl/+I dvLia8sOjI/mvTB96/9OjvEXxlnoqDBpMD8ZQznTQ6uEDpH/Z3LTGupRRv5AhN0L7SY4 GRGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ztd1b1aEAN7YodigTUG6Ro/lcZCclFr+SzJZ6tToCaI=; b=LxJRnMB08xJ4ktMWg1/senSXaJQ15ZnWo7fjLssM3XXv6WUB0iKFI5Lp3yz1QGyCec qP5N18M38sDNE+RFc6UU2QvqnvazFiPEPiWWghrtTEOyErfoS4TxDJ3A9Xm1f7zTKkPC zCJNxQlkJVr7CwiIBs8ooyUyQ18dGA1BBisIIkGIEBlZcZVdWKMvj/wiz/eWC1P7mfoc +nGE3RSTQDEem8JgewvBXFkbFk5w4eEI4P6kPMbiGC8ilNVkA0N6bXIi3TB0oy8JD72U J3gsoQ+tCk2nRb7IxNQ+ZarM6/JtNdn1AcGxEJZopJf4f7TGeYrH7RG27Ixllwj2ScO3 2hZA== X-Gm-Message-State: AO0yUKU6SiZW1s3RlU794/TSIa7czOlZgafzJn4HBrv8zq76YLB3NHBc W113r40cWx60ahZeXNiBC6wZwdwYP0yINC68 X-Google-Smtp-Source: AK7set8zVcpyQ9jSKXFsng+Jx/9trVpoLF0GOK2Fc3P6Xd0zhwde4ZgR38SZu1dSs/VtCm0e3+QAWA== X-Received: by 2002:a05:6870:fb8b:b0:16e:c7d:c657 with SMTP id kv11-20020a056870fb8b00b0016e0c7dc657mr1859450oab.49.1676487463817; Wed, 15 Feb 2023 10:57:43 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:43 -0800 (PST) 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, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 04/10] target/riscv: remove RISCV_FEATURE_DEBUG Date: Wed, 15 Feb 2023 15:57:20 -0300 Message-Id: <20230215185726.691759-5-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::31; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x31.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org RISCV_FEATURE_DEBUG will always follow the value defined by cpu->cfg.debug flag. Read the flag instead. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 6 +----- target/riscv/cpu.h | 1 - target/riscv/cpu_helper.c | 2 +- target/riscv/csr.c | 2 +- target/riscv/machine.c | 3 +-- 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 93b52b826c..e34a5e3f11 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -637,7 +637,7 @@ static void riscv_cpu_reset_hold(Object *obj) set_default_nan_mode(1, &env->fp_status); #ifndef CONFIG_USER_ONLY - if (riscv_feature(env, RISCV_FEATURE_DEBUG)) { + if (cpu->cfg.debug) { riscv_trigger_init(env); } @@ -935,10 +935,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) } } - if (cpu->cfg.debug) { - riscv_set_feature(env, RISCV_FEATURE_DEBUG); - } - #ifndef CONFIG_USER_ONLY if (cpu->cfg.ext_sstc) { diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 368a522b5b..7326aaed27 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -89,7 +89,6 @@ enum { RISCV_FEATURE_MMU, RISCV_FEATURE_PMP, RISCV_FEATURE_EPMP, - RISCV_FEATURE_DEBUG }; /* Privileged specification version */ diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index ad8d82662c..4cdd247c6c 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -105,7 +105,7 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc, flags = FIELD_DP32(flags, TB_FLAGS, MSTATUS_HS_VS, get_field(env->mstatus_hs, MSTATUS_VS)); } - if (riscv_feature(env, RISCV_FEATURE_DEBUG) && !icount_enabled()) { + if (cpu->cfg.debug && !icount_enabled()) { flags = FIELD_DP32(flags, TB_FLAGS, ITRIGGER, env->itrigger_enabled); } #endif diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 5bd4cdbef5..287792d6d6 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -437,7 +437,7 @@ static RISCVException epmp(CPURISCVState *env, int csrno) static RISCVException debug(CPURISCVState *env, int csrno) { - if (riscv_feature(env, RISCV_FEATURE_DEBUG)) { + if (riscv_cpu_cfg(env).debug) { return RISCV_EXCP_NONE; } diff --git a/target/riscv/machine.c b/target/riscv/machine.c index c6ce318cce..4634968898 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -226,9 +226,8 @@ static const VMStateDescription vmstate_kvmtimer = { static bool debug_needed(void *opaque) { RISCVCPU *cpu = opaque; - CPURISCVState *env = &cpu->env; - return riscv_feature(env, RISCV_FEATURE_DEBUG); + return cpu->cfg.debug; } static int debug_post_load(void *opaque, int version_id) From patchwork Wed Feb 15 18:57:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13142077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9FE5CC636CC for ; Wed, 15 Feb 2023 18:59:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMyi-0008NL-Ke; Wed, 15 Feb 2023 13:58:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyT-0007vA-VY for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:51 -0500 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyS-0007xM-7b for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:49 -0500 Received: by mail-oi1-x22b.google.com with SMTP id n132so16650239oih.7 for ; Wed, 15 Feb 2023 10:57:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=bzgUQCLPgU6X7MZ2uleR0+KefuKd7NhosDsVObTIs/M=; b=LOO3Aw+4O/x4DDMndxOcWWbRp+PaoLPv9slPF7t6+iQ3HYFjC9ad0ipGLJzz9o7DzI NYIq7tBkjRVqRkTD/lZxULrVSot58/sRPIJQaup876poUjwc4K24bI9YYH4ZCCRNVWhE 9iZEw/gBuQTtYlPLvvjVUmQ4VSJjEIp/2c4azh2Cb/SkwP1qTplfYw7Li6BBbZv2AH6H VZ7q0o6MnwY8+xwUO/0J2PeAbAs6B3UbZQQRRUHln2YLQ0QYGVlJqZrS+RLyy4nKFNoh ge03NXCcA2fLqsraQK3Fy960fTrI9bZVB9ObCYp9vLRhD4M6WBMR7mC0SgcWGmWgiMry BsFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=bzgUQCLPgU6X7MZ2uleR0+KefuKd7NhosDsVObTIs/M=; b=KCiFEntwWQjDyKeLvIxw3rTq9HIh7v4zd4ythbMLjSwEZ/FzgcIIgknzmPzNVajcx9 JQ/mnpuQ1Bh90BpQqaKINYZdhN8HWs3wXnRRRk4lqQxgITwIpI1psHxT/C1msdT1S/Tx wFwuuKPx3bTGrwZcNj6a6GD9PS1NPN6Dn6iJJKxMrXaB8Kprk94UtJpljecaUV3QarRn l9AAuvMeIHxjl9wyPxXjAgtBuNzGmv2T0umD6E920FlSqi7ZllH/KbWnLqCh6ba/MhIi Sz2U9HLK25x2zfvgDOSj5FVEMc96ZiKmsBydK/Jgf1aQGt55YDZPmuISRmmue9CH7U0+ ME3w== X-Gm-Message-State: AO0yUKXTjlGNBx68SNc1Ydv87Q4IbSAdrLiwETG0itKTYfWqBbEjcYmR EvsTAFUmcfQ5r8BCpA4xnWZR0OtxHRTP7wxs X-Google-Smtp-Source: AK7set8HGPd+7pnj0afCL9oguEdGct0htrfsgxK4oQR4JM1/M/hRjhjBkBcsMGjOsJiqnEo7GZM8gA== X-Received: by 2002:a05:6808:ab1:b0:364:5d1d:5528 with SMTP id r17-20020a0568080ab100b003645d1d5528mr1299692oij.1.1676487466739; Wed, 15 Feb 2023 10:57:46 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:46 -0800 (PST) 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, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 05/10] target/riscv/cpu.c: error out if EPMP is enabled without PMP Date: Wed, 15 Feb 2023 15:57:21 -0300 Message-Id: <20230215185726.691759-6-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22b; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x22b.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Instead of silently ignoring the EPMP setting if there is no PMP available, error out informing the user that EPMP depends on PMP support: $ ./qemu-system-riscv64 -cpu rv64,pmp=false,x-epmp=true qemu-system-riscv64: Invalid configuration: EPMP requires PMP support This will force users to pick saner options in the QEMU command line. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index e34a5e3f11..4585ca74dc 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -925,13 +925,18 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) if (cpu->cfg.pmp) { riscv_set_feature(env, RISCV_FEATURE_PMP); + } + + if (cpu->cfg.epmp) { + riscv_set_feature(env, RISCV_FEATURE_EPMP); /* * Enhanced PMP should only be available * on harts with PMP support */ - if (cpu->cfg.epmp) { - riscv_set_feature(env, RISCV_FEATURE_EPMP); + if (!cpu->cfg.pmp) { + error_setg(errp, "Invalid configuration: EPMP requires PMP support"); + return; } } From patchwork Wed Feb 15 18:57:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13142070 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DCDF9C636D4 for ; Wed, 15 Feb 2023 18:58:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMyh-0008H5-Ui; Wed, 15 Feb 2023 13:58:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyX-0007xm-CV for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:53 -0500 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyV-0007vQ-DM for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:52 -0500 Received: by mail-oi1-x22a.google.com with SMTP id cz14so16639831oib.12 for ; Wed, 15 Feb 2023 10:57:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=wGItmEUvt/2Qmm35pUKwvQ8V0KNI6gfDmMeF+0diUQs=; b=KlZo/jwDeRjULS37T2HMqRjKvfdrlQl4pGFV1xCExfil0Bu28HwWUVLpIIUHusZIbm RM4Ehh+Fbqtqv86E6m/nV8aLJeLrfTpX+F05/aw1AyAAEpxKHuuNxylDjuI2W34aRYq+ z1pimwET5ggfMRaFuyBONMWmodBU5ZL1oKvp6pU64y/HsKPuL8sc05lcMdOflt/MH6fi vBTTV7SbwhDDlZ7TAm1tEpWEkW+axCrwccT1kQkslARmxKWjTwpyZUI1etZ6Vjtucyq8 87C1TPa6sA4EWKwLRMKoF0pg4vL63smGT6BLOz7aKP4lnyo8p6xE6ryPcNZ0Y7T95MBt yXXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=wGItmEUvt/2Qmm35pUKwvQ8V0KNI6gfDmMeF+0diUQs=; b=ClGjj7mr2uc/ImFV8JyuLMB2kL4yWocTmhd9YU3ZMWXUCVDZHv2v5UAQ6Y8yAbKCcK SZTvSSZrmuhynfM2+kCfz8zhSZU6cIq0YQlV7g7reSBTE1rbtE3jy5S+e7/kCZ+fCou+ CP92UZq52DdBJmuOm3e6f+HUPLttbFIvTTzxcwFqO46Ug+CdL9NuE/a9KXccMsjd1kYW F4GW+pvJRpPzCaztM3/3ryBXTpXiKzbjz7ghqbOm95CFC0pD4VjLXrND3jY4Yi4qKKEF cnzjuzLnn/uo5vWF6IETmOxErv8u1gMbzEzHayNfSwHtDCGOxjj4PELTQn6sBiLqsuvT WAzQ== X-Gm-Message-State: AO0yUKUzdTVxcxDQIQrbE7gg+m254Z36aWja6wfe93iH6Q1ZA33QDKDB BKjihKIje9Bl7jL2KlP71rOBohV6S2GBf6Ln X-Google-Smtp-Source: AK7set9keYh0vKL+sILODfYwjJ4xVkgqPiRqq1L3hKJAZBQYqUmPT4GDzwmelBEoP37hGBqm+qeqAg== X-Received: by 2002:aca:120f:0:b0:378:89a7:2f4f with SMTP id 15-20020aca120f000000b0037889a72f4fmr1258059ois.3.1676487469638; Wed, 15 Feb 2023 10:57:49 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:49 -0800 (PST) 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, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 06/10] target/riscv: remove RISCV_FEATURE_EPMP Date: Wed, 15 Feb 2023 15:57:22 -0300 Message-Id: <20230215185726.691759-7-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22a; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x22a.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org RISCV_FEATURE_EPMP is always set to the same value as the cpu->cfg.epmp flag. Use the flag directly. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 10 +++------- target/riscv/cpu.h | 1 - target/riscv/csr.c | 2 +- target/riscv/pmp.c | 4 ++-- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 4585ca74dc..71b2042d73 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -927,17 +927,13 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) riscv_set_feature(env, RISCV_FEATURE_PMP); } - if (cpu->cfg.epmp) { - riscv_set_feature(env, RISCV_FEATURE_EPMP); - + if (cpu->cfg.epmp && !cpu->cfg.pmp) { /* * Enhanced PMP should only be available * on harts with PMP support */ - if (!cpu->cfg.pmp) { - error_setg(errp, "Invalid configuration: EPMP requires PMP support"); - return; - } + error_setg(errp, "Invalid configuration: EPMP requires PMP support"); + return; } diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 7326aaed27..c87e50e804 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -88,7 +88,6 @@ enum { RISCV_FEATURE_MMU, RISCV_FEATURE_PMP, - RISCV_FEATURE_EPMP, }; /* Privileged specification version */ diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 287792d6d6..6fa6b7e7ed 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -428,7 +428,7 @@ static RISCVException pmp(CPURISCVState *env, int csrno) static RISCVException epmp(CPURISCVState *env, int csrno) { - if (env->priv == PRV_M && riscv_feature(env, RISCV_FEATURE_EPMP)) { + if (env->priv == PRV_M && riscv_cpu_cfg(env).epmp) { return RISCV_EXCP_NONE; } diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index 4bc4113531..bb54899635 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -88,7 +88,7 @@ static void pmp_write_cfg(CPURISCVState *env, uint32_t pmp_index, uint8_t val) if (pmp_index < MAX_RISCV_PMPS) { bool locked = true; - if (riscv_feature(env, RISCV_FEATURE_EPMP)) { + if (riscv_cpu_cfg(env).epmp) { /* mseccfg.RLB is set */ if (MSECCFG_RLB_ISSET(env)) { locked = false; @@ -239,7 +239,7 @@ static bool pmp_hart_has_privs_default(CPURISCVState *env, target_ulong addr, { bool ret; - if (riscv_feature(env, RISCV_FEATURE_EPMP)) { + if (riscv_cpu_cfg(env).epmp) { if (MSECCFG_MMWP_ISSET(env)) { /* * The Machine Mode Whitelist Policy (mseccfg.MMWP) is set From patchwork Wed Feb 15 18:57:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13142075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 02C71C636D4 for ; Wed, 15 Feb 2023 18:59:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMyl-0000Dm-1y; Wed, 15 Feb 2023 13:58:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyZ-0007zw-0v for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:55 -0500 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 1pSMyX-0007vI-DY for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:54 -0500 Received: by mail-oi1-x22f.google.com with SMTP id t5so16652635oiw.1 for ; Wed, 15 Feb 2023 10:57:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=J7fLV3zLmjzcQ9pqfO11dTsPpOFgbHe4zd0GhL8+Yyw=; b=NXAe8mEi/KRTfdNhWnU5LsUFmO128wORqoqiFFwPfwwqMJDeQQxN0UWvjpmtlHRiHD 5uJmuY7Sb2HzfLlw3YjA9Y+zkINu3CIwtUzEMuvFHNMEl+ow217W1JTr0sb/OZegUa83 jLxOsGfH6y/LzGVPfJfgsY47v8WDN/nGzKLiRhJlXrWVXCLXkAZk0TIeYYyZpNMc78LT wqoUM8eKODDM+2ZnCg73hkZzauvawL59TpnbNaqIb1OLOPzGAsgEVVDmu1pdOKQqevsa enhVo2WJ1rJ0RHMetHdKjpKT+JfAklH8s3XPHoEJcDddG5hCocAi9QeisVUuobxxnwKw H61w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=J7fLV3zLmjzcQ9pqfO11dTsPpOFgbHe4zd0GhL8+Yyw=; b=x+qk5UzjZgyiI9pYe86BJcSYYUO2Ybv7wQGMRXPvr9rKz3qIAepRKHXVZwErJn6VPC cG1ijn+0FLsPDVO9j8hiL7WTklNnwXjvuW6rSws260MqDDaudjh/q1KsXhcfusBwhJyt dNHQ/WenwRyWCtpFiFU+GYlE1Lue1ImMtTXld5kQYIwkMRzjmPR/CyDCLu++EzkZ/AmP JgNMJckfoGlLNU7s9wWePRIjqjz0L84GEHwPxa7RxdNaygFHxc1zBiWuUFha1NPn/Her 4pFQQ1bey1oNo6bSlKucOWBxg7buEX7IM0ZAjq6s/uK3Mz3fonfKXpfxzOIuTmoom8Hz i5Ew== X-Gm-Message-State: AO0yUKX2PL2bLyZ41u1PDOkm/U0A+cmh47CMVX///NvoORjhXr/D+0a4 CQVkFbb6Xc4S3HQzeKEZ6LZ6IQHPGxxIaQFA X-Google-Smtp-Source: AK7set88RCHBqm14gR590S9sNi3h/KBh5+UtHsKi5jm+VAP4z0JX94TF0Kk2v6tGdWYvbPU3RajlIA== X-Received: by 2002:a05:6808:7c3:b0:378:9c80:7da0 with SMTP id f3-20020a05680807c300b003789c807da0mr1258892oij.19.1676487472434; Wed, 15 Feb 2023 10:57:52 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:52 -0800 (PST) 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, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 07/10] target/riscv: remove RISCV_FEATURE_PMP Date: Wed, 15 Feb 2023 15:57:23 -0300 Message-Id: <20230215185726.691759-8-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org RISCV_FEATURE_PMP is being set via riscv_set_feature() by mirroring the cpu->cfg.pmp flag. Use the flag instead. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 4 ---- target/riscv/cpu.h | 1 - target/riscv/cpu_helper.c | 2 +- target/riscv/csr.c | 2 +- target/riscv/machine.c | 3 +-- target/riscv/op_helper.c | 2 +- target/riscv/pmp.c | 2 +- 7 files changed, 5 insertions(+), 11 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 71b2042d73..7b1360d6ba 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -923,10 +923,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) riscv_set_feature(env, RISCV_FEATURE_MMU); } - if (cpu->cfg.pmp) { - riscv_set_feature(env, RISCV_FEATURE_PMP); - } - if (cpu->cfg.epmp && !cpu->cfg.pmp) { /* * Enhanced PMP should only be available diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index c87e50e804..bd7ab5fceb 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -87,7 +87,6 @@ so a cpu features bitfield is required, likewise for optional PMP support */ enum { RISCV_FEATURE_MMU, - RISCV_FEATURE_PMP, }; /* Privileged specification version */ diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 4cdd247c6c..15d9542691 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -706,7 +706,7 @@ static int get_physical_address_pmp(CPURISCVState *env, int *prot, pmp_priv_t pmp_priv; int pmp_index = -1; - if (!riscv_feature(env, RISCV_FEATURE_PMP)) { + if (!riscv_cpu_cfg(env).pmp) { *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; return TRANSLATE_SUCCESS; } diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 6fa6b7e7ed..4011b0d6f8 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -419,7 +419,7 @@ static int aia_hmode32(CPURISCVState *env, int csrno) static RISCVException pmp(CPURISCVState *env, int csrno) { - if (riscv_feature(env, RISCV_FEATURE_PMP)) { + if (riscv_cpu_cfg(env).pmp) { return RISCV_EXCP_NONE; } diff --git a/target/riscv/machine.c b/target/riscv/machine.c index 4634968898..67e9e56853 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -27,9 +27,8 @@ static bool pmp_needed(void *opaque) { RISCVCPU *cpu = opaque; - CPURISCVState *env = &cpu->env; - return riscv_feature(env, RISCV_FEATURE_PMP); + return cpu->cfg.pmp; } static int pmp_post_load(void *opaque, int version_id) diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index 48f918b71b..f34701b443 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -195,7 +195,7 @@ target_ulong helper_mret(CPURISCVState *env) uint64_t mstatus = env->mstatus; target_ulong prev_priv = get_field(mstatus, MSTATUS_MPP); - if (riscv_feature(env, RISCV_FEATURE_PMP) && + if (riscv_cpu_cfg(env).pmp && !pmp_get_num_rules(env) && (prev_priv != PRV_M)) { riscv_raise_exception(env, RISCV_EXCP_INST_ACCESS_FAULT, GETPC()); } diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index bb54899635..1e7903dffa 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -265,7 +265,7 @@ static bool pmp_hart_has_privs_default(CPURISCVState *env, target_ulong addr, } } - if ((!riscv_feature(env, RISCV_FEATURE_PMP)) || (mode == PRV_M)) { + if (!riscv_cpu_cfg(env).pmp || (mode == PRV_M)) { /* * Privileged spec v1.10 states if HW doesn't implement any PMP entry * or no PMP entry matches an M-Mode access, the access succeeds. From patchwork Wed Feb 15 18:57:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13142078 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CE38AC636CC for ; Wed, 15 Feb 2023 18:59:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMym-0000RG-GA; Wed, 15 Feb 2023 13:58:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyc-00086f-39 for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:58 -0500 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMya-000805-LA for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:57 -0500 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-16ab8581837so24014961fac.4 for ; Wed, 15 Feb 2023 10:57:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=Rhjy4ZuFr2J/YQsYfjypiNp1FTwn/nVolIeKKoKX5g0=; b=cQRoPKkkeY6SG7kjMP2mcLCrvmFRchM/Ek8r4BVoUl+XreMhbEz3/aJE9u30OC1oFB Hr+Wilsp0sR/R3+FasRaIg3bFIwwBdyqvCuRUTh4RhlA31BqaS3/nDjGarR0nLRxOuFd YIepH7WC2vcAzS6+T4faaD4DJd2S1hfnfTDCkzJ/akGhXQ5U2FM/QyqWFmppnkWDyIHG XqXZt54h/X0XBH29hHkOwxSPpUXIaAvVJUxxFX6etgC5z7H+ydF/5OV8yPbjO5+9vcIY vCWBkMnNkvB7/ZDZXzZ+iB8G1GCwM2jvlfSWDhYcNuRJ3l++mDxuohQF/4FPDhOgxb77 6S/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Rhjy4ZuFr2J/YQsYfjypiNp1FTwn/nVolIeKKoKX5g0=; b=ZN8AMzoQ8mQh0Lbpz47Kwwk3h+y8EmFIdm2fD6DmhUht4VsgqfXbbJoBsHVZNSld4B yTtbB2ZlLc/h4hiIHKUjxRoKsKHLTuM9Oou3qBcf47tl1yMlYlA3ZxlwVljsQVpQ+h03 oNkMCQKY14gCebQMnugapkwsYwxZIVk2OzSuwjz0M4QAQ+3D9nk2o7Ft94yZ5dvPhY6L xU3bWfKmuaPoZ9h3eHnRt4nfLvmDksiYxLUzY3zaAuB89A0uQanoLUdd2maLPJfFeWWJ 43s4jvZJXaEGrk4AbZAOkB6YzPB2+ghPKYTfDci+/uRh+1koWSOIto+nPNYCs8GFDrOI hagw== X-Gm-Message-State: AO0yUKUDdXh1xfL/iZoLYmdRkeCf14dlKyR6MhDePOUBsWQ44RjFbCGg Ev1DPqmWA8Ah1VtlSfTYi0smmbSdZPStdJYy X-Google-Smtp-Source: AK7set99WNSWOw5IYu4hKdqjrkA617YNnvhKygjmCUQzmX+RrlC0M6nLJ0LQWAqdh0x9uyYvyddtBQ== X-Received: by 2002:a05:6870:560c:b0:16a:c90e:def9 with SMTP id m12-20020a056870560c00b0016ac90edef9mr1547552oao.9.1676487475205; Wed, 15 Feb 2023 10:57:55 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:54 -0800 (PST) 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, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 08/10] hw/riscv/virt.c: do not use RISCV_FEATURE_MMU in create_fdt_socket_cpus() Date: Wed, 15 Feb 2023 15:57:24 -0300 Message-Id: <20230215185726.691759-9-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::2d; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x2d.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Read cpu_ptr->cfg.mmu directly. As a bonus, use cpu_ptr in riscv_isa_string(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- hw/riscv/virt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 86c4adc0c9..49f2c157f7 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -232,20 +232,21 @@ static void create_fdt_socket_cpus(RISCVVirtState *s, int socket, bool is_32_bit = riscv_is_32bit(&s->soc[0]); for (cpu = s->soc[socket].num_harts - 1; cpu >= 0; cpu--) { + RISCVCPU *cpu_ptr = &s->soc[socket].harts[cpu]; + cpu_phandle = (*phandle)++; cpu_name = g_strdup_printf("/cpus/cpu@%d", s->soc[socket].hartid_base + cpu); qemu_fdt_add_subnode(ms->fdt, cpu_name); - if (riscv_feature(&s->soc[socket].harts[cpu].env, - RISCV_FEATURE_MMU)) { + if (cpu_ptr->cfg.mmu) { qemu_fdt_setprop_string(ms->fdt, cpu_name, "mmu-type", (is_32_bit) ? "riscv,sv32" : "riscv,sv48"); } else { qemu_fdt_setprop_string(ms->fdt, cpu_name, "mmu-type", "riscv,none"); } - name = riscv_isa_string(&s->soc[socket].harts[cpu]); + name = riscv_isa_string(cpu_ptr); qemu_fdt_setprop_string(ms->fdt, cpu_name, "riscv,isa", name); g_free(name); qemu_fdt_setprop_string(ms->fdt, cpu_name, "compatible", "riscv"); From patchwork Wed Feb 15 18:57:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13142068 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BB6C8C636D7 for ; Wed, 15 Feb 2023 18:58:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMyn-0000Z7-G4; Wed, 15 Feb 2023 13:58:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyf-000892-0Z for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:58:03 -0500 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyd-0007wH-7m for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:58:00 -0500 Received: by mail-oi1-x232.google.com with SMTP id bj22so16653155oib.11 for ; Wed, 15 Feb 2023 10:57:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=KqvKnxVMWo5xUwBFYmmbLK4P5nYy97w+H/Se5TENS3M=; b=mH0tRWzfKrQPXRRnwFeRGaoVw1QWZCcr6oGcW4kuIKZdPBbSg+txJtyEYANuhF17Nx pLRY96VnbZRHXH8Q1G/9yrTcQymKnBIQEjfYBqpozMhD+aJ9jrxwmIywQbcPOevGUJEo NTURaSBy+QbltJDDyWdOB5TACSJw6pNomvi8Tad48gKX7junHnfjhJovIZiBNCbqHMw6 N2+pxFKT+uRaEspONZ+46wdABzvicDqO4aYNK1yjkdYYqfEifC/EWDh/xpGLgM2XE2TZ h16+/fD3oynuMxIK9/6LbA0Z7I1KUwqrZxWRwZ9OKu2F/Rboafra9bqgGdXTvtTsU+id i1fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=KqvKnxVMWo5xUwBFYmmbLK4P5nYy97w+H/Se5TENS3M=; b=FqkjSdSPhJK+Kq2CWWyfsaPKeaSm186rxvW0g84XlnSPkJ1CGhToxnh4dQ02upQ/7e Y6I/7AADsVIFo2IHv3VomcgOGJamWYGrF1GHxfPfWaHmh8M2Zr8QaLtaLnhupIkGBN55 8a40QmogzHxHey7zzp3HxnjP7Y9ziFcL5butx1HNoTL0BGHM7voiEdRwTVL/2PeLDmip zOolZcw3eaCAxZXAzIuSePScVxc5rT7/2IuQ+3Pa3V1yqv3pu7goosxP//pN4QKrTGeN j22cg0qHgSwE502H237TzWNpoYlRxMvdjgZFsMZMQjVT8UVxFvgqPfpSV1jq/5wNm45Z Ibxg== X-Gm-Message-State: AO0yUKUV9cwslS52VSTKvg9+EhsLjdVYUUxUOYH5XyjNXBDt2kCod9Cg rwlegZ8RJrXFWBQ2N9WK9/HgLYzlEsQCZOov X-Google-Smtp-Source: AK7set/w7mev+PWMye3T2b17WKghZXE8R/u1VvPij9TpLusC9l4m+gwm4/MHC02JbMXW01EoCVnwig== X-Received: by 2002:a54:4484:0:b0:378:24b1:65a2 with SMTP id v4-20020a544484000000b0037824b165a2mr1236039oiv.6.1676487478183; Wed, 15 Feb 2023 10:57:58 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:57 -0800 (PST) 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, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 09/10] target/riscv: remove RISCV_FEATURE_MMU Date: Wed, 15 Feb 2023 15:57:25 -0300 Message-Id: <20230215185726.691759-10-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::232; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x232.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org RISCV_FEATURE_MMU is set whether cpu->cfg.mmu is set, so let's just use the flag directly instead. With this change the enum is also removed. It is worth noticing that this enum, and all the RISCV_FEATURES_* that were contained in it, predates the existence of the cpu->cfg object. Today, using cpu->cfg is an easier way to retrieve all the features and extensions enabled in the hart. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 4 ---- target/riscv/cpu.h | 7 ------- target/riscv/cpu_helper.c | 2 +- target/riscv/csr.c | 4 ++-- target/riscv/monitor.c | 2 +- target/riscv/pmp.c | 2 +- 6 files changed, 5 insertions(+), 16 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 7b1360d6ba..075033006c 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -919,10 +919,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) } } - if (cpu->cfg.mmu) { - riscv_set_feature(env, RISCV_FEATURE_MMU); - } - if (cpu->cfg.epmp && !cpu->cfg.pmp) { /* * Enhanced PMP should only be available diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index bd7ab5fceb..7ff4d90261 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -81,13 +81,6 @@ #define RVH RV('H') #define RVJ RV('J') -/* S extension denotes that Supervisor mode exists, however it is possible - to have a core that support S mode but does not have an MMU and there - is currently no bit in misa to indicate whether an MMU exists or not - so a cpu features bitfield is required, likewise for optional PMP support */ -enum { - RISCV_FEATURE_MMU, -}; /* Privileged specification version */ enum { diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 15d9542691..e76b206191 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -796,7 +796,7 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, mode = PRV_U; } - if (mode == PRV_M || !riscv_feature(env, RISCV_FEATURE_MMU)) { + if (mode == PRV_M || !riscv_cpu_cfg(env).mmu) { *physical = addr; *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; return TRANSLATE_SUCCESS; diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 4011b0d6f8..ec2c4c7c4a 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -2616,7 +2616,7 @@ static RISCVException rmw_siph(CPURISCVState *env, int csrno, static RISCVException read_satp(CPURISCVState *env, int csrno, target_ulong *val) { - if (!riscv_feature(env, RISCV_FEATURE_MMU)) { + if (!riscv_cpu_cfg(env).mmu) { *val = 0; return RISCV_EXCP_NONE; } @@ -2635,7 +2635,7 @@ static RISCVException write_satp(CPURISCVState *env, int csrno, { target_ulong vm, mask; - if (!riscv_feature(env, RISCV_FEATURE_MMU)) { + if (!riscv_cpu_cfg(env).mmu) { return RISCV_EXCP_NONE; } diff --git a/target/riscv/monitor.c b/target/riscv/monitor.c index 236f93b9f5..b7b8d0614f 100644 --- a/target/riscv/monitor.c +++ b/target/riscv/monitor.c @@ -218,7 +218,7 @@ void hmp_info_mem(Monitor *mon, const QDict *qdict) return; } - if (!riscv_feature(env, RISCV_FEATURE_MMU)) { + if (!riscv_cpu_cfg(env).mmu) { monitor_printf(mon, "S-mode MMU unavailable\n"); return; } diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index 1e7903dffa..c67de36942 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -315,7 +315,7 @@ int pmp_hart_has_privs(CPURISCVState *env, target_ulong addr, } if (size == 0) { - if (riscv_feature(env, RISCV_FEATURE_MMU)) { + if (riscv_cpu_cfg(env).mmu) { /* * If size is unknown (0), assume that all bytes * from addr to the end of the page will be accessed. From patchwork Wed Feb 15 18:57:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13142073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4A6CAC64ED6 for ; Wed, 15 Feb 2023 18:59:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMyo-0000il-IR; Wed, 15 Feb 2023 13:58:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyj-0008RC-Ad for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:58:05 -0500 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyh-00080p-ID for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:58:05 -0500 Received: by mail-oi1-x22e.google.com with SMTP id dt8so16700886oib.0 for ; Wed, 15 Feb 2023 10:58:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=GvaH81B5hBrpGPqem9kaUkSdCiGN0le0jCxW0/4CJJg=; b=jkIr/+wjpIgWgAjVzvrmpKtmvPFIPna3dhunaWVZGCDKCask1VqCI6jcmt/33lCh04 f74+ZGaCh2tkCVIQIDXWclV1wkolbdlK5WNE2E1m9SmYSKiJ6ntcP6VcjC9IgRzz4UCd GhNXMkAICI3/3AzERPUKUSAV7Ez8XlcvUZvj82iUzQSwM6XHCEGP377BbUGZbIKXLS+3 ZnmfifVg1TOZ01mS/bHBfI8MgGXJq/RENnxQjEpzpBPXZqTEsE13joy1vxg6zNle6+1e WTZxOfM7OZBe0XI7RZFnfSbc64foD5Sm5kt3I5P+0XTT3PtijawEiyVz6Cm2N2XOIT/g IvPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=GvaH81B5hBrpGPqem9kaUkSdCiGN0le0jCxW0/4CJJg=; b=bu24kGdc2t+GdVczSincCOc9i0rTehK2pQ4SzdTjscDrTKOs6D0O4Tm4EpPik5ubuN WzRO6Z1zbIwPIkT10gXPAd90jk/Qh513c3m60IsV50iEJsdwUze4zdruNc41JBbtvycp VHWRCZlA/bVwnaTXRt6LDQSjpMm3nLuxmMzVq1y8tcwV9vVC0po5++r/vREJ1/z8qBpZ K3IskRyem9m3Ju81YneyPRgnFccFWrs7B9rJogKMJ/1bUzHCBujpvOdTwQkSfkMUDNh3 L6DnYm7T3j5MjH7XuKXq4FMpaliCDCOlIYJP5Q2rzsUnmJuzrq2NecXlZ9yN1Vxr9x7B Ryfg== X-Gm-Message-State: AO0yUKVg2ptzs4Yzyvs56WZIOckT8LajGykbzQw+1JS5bm4Sz5fPWQji HNooI4QZsR2QhHRY4C7ycMBi2GJdfur+Zz8F X-Google-Smtp-Source: AK7set9+BX1XPIa2drpEYnGU2E2HncOZOL2DVGS5NOZCl0U7L5WuK8o0ABeHUUX0cFnFnuMsSpSQPA== X-Received: by 2002:a05:6808:3a9:b0:37d:c268:d3d9 with SMTP id n9-20020a05680803a900b0037dc268d3d9mr1504057oie.11.1676487481131; Wed, 15 Feb 2023 10:58:01 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:58:00 -0800 (PST) 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, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 10/10] target/riscv/cpu: remove CPUArchState::features and friends Date: Wed, 15 Feb 2023 15:57:26 -0300 Message-Id: <20230215185726.691759-11-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22e; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x22e.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The attribute is no longer used since we can retrieve all the enabled features in the hart by using cpu->cfg instead. Remove env->feature, riscv_feature() and riscv_set_feature(). We also need to bump vmstate_riscv_cpu version_id and minimal_version_id since 'features' is no longer being migrated. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.h | 12 ------------ target/riscv/machine.c | 5 ++--- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 7ff4d90261..671734420b 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -173,8 +173,6 @@ struct CPUArchState { /* 128-bit helpers upper part return value */ target_ulong retxh; - uint32_t features; - #ifdef CONFIG_USER_ONLY uint32_t elf_flags; #endif @@ -524,16 +522,6 @@ static inline int riscv_has_ext(CPURISCVState *env, target_ulong ext) return (env->misa_ext & ext) != 0; } -static inline bool riscv_feature(CPURISCVState *env, int feature) -{ - return env->features & (1ULL << feature); -} - -static inline void riscv_set_feature(CPURISCVState *env, int feature) -{ - env->features |= (1ULL << feature); -} - #include "cpu_user.h" extern const char * const riscv_int_regnames[]; diff --git a/target/riscv/machine.c b/target/riscv/machine.c index 67e9e56853..9c455931d8 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -331,8 +331,8 @@ static const VMStateDescription vmstate_pmu_ctr_state = { const VMStateDescription vmstate_riscv_cpu = { .name = "cpu", - .version_id = 6, - .minimum_version_id = 6, + .version_id = 7, + .minimum_version_id = 7, .post_load = riscv_cpu_post_load, .fields = (VMStateField[]) { VMSTATE_UINTTL_ARRAY(env.gpr, RISCVCPU, 32), @@ -351,7 +351,6 @@ const VMStateDescription vmstate_riscv_cpu = { VMSTATE_UINT32(env.misa_ext, RISCVCPU), VMSTATE_UINT32(env.misa_mxl_max, RISCVCPU), VMSTATE_UINT32(env.misa_ext_mask, RISCVCPU), - VMSTATE_UINT32(env.features, RISCVCPU), VMSTATE_UINTTL(env.priv, RISCVCPU), VMSTATE_UINTTL(env.virt, RISCVCPU), VMSTATE_UINT64(env.resetvec, RISCVCPU),