Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1pSmEk-0002yc-AG for mharc-qemu-riscv@gnu.org; Thu, 16 Feb 2023 16:56:18 -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 1pSmEh-0002wo-UL for qemu-riscv@nongnu.org; Thu, 16 Feb 2023 16:56:16 -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 1pSmEg-0001wU-5m for qemu-riscv@nongnu.org; Thu, 16 Feb 2023 16:56:15 -0500 Received: by mail-oi1-x232.google.com with SMTP id bh15so3110652oib.4 for ; Thu, 16 Feb 2023 13:56:13 -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=DqOEK63Mc9QLDqVHs79rHT9rPK8OGxBFD1pNt63dIkw=; b=k3wUIYrHuZVA0gNRK3rK0rO91vj1Ka6/1+UxGdZ9FHCpTpxFJvO82Xezh5rYHPUY+4 t1rtEwk9xF5xlNuexpmSV+Va49AZMpfaWG8eSAxEklhhWxV/SneSY3AYZePX2k8ytHyI fXVKs5OiPupLq+UmXDL+6tyvTyoL5YGKe6DdJGDzjSMTdXcEu9DohRtlYZyNX28hzudi 1emNvA9AJrNSabniZgynYro7TZLgA7eEUxhUdqVRFS0DToSfWdpIfvkJc193OZmUdzeY DvI1tAYeQKE5/U3FYHfJkdNr/WoEOlJ/jTQWzn5Q3PYTy3iH1sx1+/iBIaAQA152nyOx WOZg== 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=DqOEK63Mc9QLDqVHs79rHT9rPK8OGxBFD1pNt63dIkw=; b=hsKbJiDZ1eQcVI5HrJuYJ9aJfQ0jy63afVR8PPFgK0PZI6s1Q5AGGE7Na9QHWFiBd1 iVQUZUTmmWi5xpvQZZNAf/nCQ+30pQHtiy99htz5QFtgrdb0RRipx2l6i8ryMEg4vNDQ EqigTaQEldLuZ3GN0BJXmEYsoTWIqXDNkRJfDcyAyrUPolp1IQs6l5yCrUngE9MoCDue Wm+Qcj1bhfQry+Smv26FlLu+b/LARCKmitorVuJfgIJ4jxqNf/E/9gMOAOkXTTat+CKV QbTQYWX7zre4HjzhLjHDBiir1fz/HOcBb4CA8ZoZRSQTcdhyvJHn2I/riCX1/rm2cw5t bidA== X-Gm-Message-State: AO0yUKXa7mrSVDaqACVpNLPofnlE4Wsj+w8TNwpYrujuGc7OAF1mJYaM IIY6PDhKKO8I0apxgPM1x2DZkg== X-Google-Smtp-Source: AK7set8RpjlKAog2iItuKehqfNNJGesBp3TX8ASI5E03XW3TG4NMCIoiJM63e/hnW9p29JLlW4U77A== X-Received: by 2002:a05:6808:911:b0:37a:c2d2:675b with SMTP id w17-20020a056808091100b0037ac2d2675bmr2993409oih.53.1676584572303; Thu, 16 Feb 2023 13:56:12 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id i132-20020acaea8a000000b0037d7f4d0890sm1047570oih.26.2023.02.16.13.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 13:56:11 -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, richard.henderson@linaro.org, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v6 5/9] target/riscv: remove RISCV_FEATURE_EPMP Date: Thu, 16 Feb 2023 18:55:46 -0300 Message-Id: <20230216215550.1011637-6-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216215550.1011637-1-dbarboza@ventanamicro.com> References: <20230216215550.1011637-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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-riscv@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Feb 2023 21:56:16 -0000 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 2afb705930..6d659d74fa 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 58af2c0e66..cdc68d3676 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..aa4d1996e9 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 -- 2.39.1