[RFC PATCH v1 34/43] target/hexagon: Add get_tb_mmu_index()

Anton Johansson via posted 43 patches 2 days, 13 hours ago
[RFC PATCH v1 34/43] target/hexagon: Add get_tb_mmu_index()
Posted by Anton Johansson via 2 days, 13 hours ago
Adds a functions to return the current mmu index given tb_flags of the
current translation block.  Required by helper-to-tcg in order to
retrieve the mmu index for memory operations without changing the
signature of helper functions.

Signed-off-by: Anton Johansson <anjo@rev.ng>
---
 target/hexagon/cpu.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h
index 764f3c38cc..7be4b5769e 100644
--- a/target/hexagon/cpu.h
+++ b/target/hexagon/cpu.h
@@ -153,6 +153,18 @@ static inline void cpu_get_tb_cpu_state(CPUHexagonState *env, vaddr *pc,
     }
 }
 
+// Returns the current mmu index given tb_flags of the current translation
+// block.  Required by helper-to-tcg in order to retrieve the mmu index for
+// memory operations without changing the signature of helper functions.
+static inline int get_tb_mmu_index(uint32_t flags)
+{
+#ifdef CONFIG_USER_ONLY
+    return MMU_USER_IDX;
+#else
+#error System mode not supported on Hexagon yet
+#endif
+}
+
 typedef HexagonCPU ArchCPU;
 
 void hexagon_translate_init(void);
-- 
2.45.2
Re: [RFC PATCH v1 34/43] target/hexagon: Add get_tb_mmu_index()
Posted by Richard Henderson 21 hours ago
On 11/20/24 19:49, Anton Johansson wrote:
> Adds a functions to return the current mmu index given tb_flags of the
> current translation block.  Required by helper-to-tcg in order to
> retrieve the mmu index for memory operations without changing the
> signature of helper functions.
> 
> Signed-off-by: Anton Johansson <anjo@rev.ng>
> ---
>   target/hexagon/cpu.h | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h
> index 764f3c38cc..7be4b5769e 100644
> --- a/target/hexagon/cpu.h
> +++ b/target/hexagon/cpu.h
> @@ -153,6 +153,18 @@ static inline void cpu_get_tb_cpu_state(CPUHexagonState *env, vaddr *pc,
>       }
>   }
>   
> +// Returns the current mmu index given tb_flags of the current translation
> +// block.  Required by helper-to-tcg in order to retrieve the mmu index for
> +// memory operations without changing the signature of helper functions.
> +static inline int get_tb_mmu_index(uint32_t flags)
> +{
> +#ifdef CONFIG_USER_ONLY
> +    return MMU_USER_IDX;
> +#else
> +#error System mode not supported on Hexagon yet
> +#endif
> +}
> +
>   typedef HexagonCPU ArchCPU;
>   
>   void hexagon_translate_init(void);

I suggest placing this somewhere other than cpu.h, as it's private to the translator and 
its generated code.


r~