On Thu, Aug 29, 2024 at 10:56:41PM -0700, Deepak Gupta wrote:
On Fri, Aug 30, 2024 at 03:20:04PM +1000, Richard Henderson wrote:
On 8/30/24 09:34, Deepak Gupta wrote:
+bool cpu_get_bcfien(CPURISCVState *env)

It occurs to me that a better name would be "cpu_get_sspen".
The backward cfi is merely a consequence of the shadow stack.

On a second thought, I would like to keep to keep `cpu_get_bcfien`
We use this helper in `cpu_get_tb_cpu_state`, `get_physical_address`
and `cfi_ss`. In 2 out of 3 functions, intent is to check whether backcfi
is enabled or not and based on set TB state or perform appropriate page
table walk. Only in case of whether access to ssp is allowed or not
(i.e. `cfi_ss`), intent is sspen or not.

Let me know if you feel strongly against it.


Want me to change cpu_get_fcfien as well to cpu_get_lpen ?


+{
+    /* no cfi extension, return false */
+    if (!env_archcpu(env)->cfg.ext_zicfiss) {
+        return false;
+    }
+
+    switch (env->priv) {
+    case PRV_U:
+        if (riscv_has_ext(env, RVS)) {
+            return env->senvcfg & SENVCFG_SSE;
+        }
+        return env->menvcfg & MENVCFG_SSE;
+#ifndef CONFIG_USER_ONLY
+    case PRV_S:
+        if (env->virt_enabled) {
+            return env->henvcfg & HENVCFG_SSE;
+        }
+        return env->menvcfg & MENVCFG_SSE;
+    case PRV_M: /* M-mode shadow stack is always on if hart implements */
+        return true;

Reply via email to