[RFC PATCH 17/34] hw/core: [CPUTLB] Move target specifics to end of TCGCPUOps

Anton Johansson via posted 34 patches 10 months, 1 week ago
[RFC PATCH 17/34] hw/core: [CPUTLB] Move target specifics to end of TCGCPUOps
Posted by Anton Johansson via 10 months, 1 week ago
TCGCPUOps contains an extra function pointer when included with
NEED_CPU_H, these are moved from the middle to the end of the struct. As
such offsets to target independent function pointers don't vary in
target specific and independent code.

[Move target specfic fields to separate struct?]

Signed-off-by: Anton Johansson <anjo@rev.ng>
---
 include/hw/core/tcg-cpu-ops.h | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h
index 479713a36e..feb849051f 100644
--- a/include/hw/core/tcg-cpu-ops.h
+++ b/include/hw/core/tcg-cpu-ops.h
@@ -49,21 +49,6 @@ struct TCGCPUOps {
     /** @debug_excp_handler: Callback for handling debug exceptions */
     void (*debug_excp_handler)(CPUState *cpu);
 
-#ifdef NEED_CPU_H
-#if defined(CONFIG_USER_ONLY) && defined(TARGET_I386)
-    /**
-     * @fake_user_interrupt: Callback for 'fake exception' handling.
-     *
-     * Simulate 'fake exception' which will be handled outside the
-     * cpu execution loop (hack for x86 user mode).
-     */
-    void (*fake_user_interrupt)(CPUState *cpu);
-#else
-    /**
-     * @do_interrupt: Callback for interrupt handling.
-     */
-    void (*do_interrupt)(CPUState *cpu);
-#endif /* !CONFIG_USER_ONLY || !TARGET_I386 */
 #ifdef CONFIG_USER_ONLY
     /**
      * record_sigsegv:
@@ -171,8 +156,25 @@ struct TCGCPUOps {
     bool (*io_recompile_replay_branch)(CPUState *cpu,
                                        const TranslationBlock *tb);
 #endif /* !CONFIG_USER_ONLY */
+
+#ifdef NEED_CPU_H
+#if defined(CONFIG_USER_ONLY) && defined(TARGET_I386)
+    /**
+     * @fake_user_interrupt: Callback for 'fake exception' handling.
+     *
+     * Simulate 'fake exception' which will be handled outside the
+     * cpu execution loop (hack for x86 user mode).
+     */
+    void (*fake_user_interrupt)(CPUState *cpu);
+#else
+    /**
+     * @do_interrupt: Callback for interrupt handling.
+     */
+    void (*do_interrupt)(CPUState *cpu);
+#endif /* !CONFIG_USER_ONLY || !TARGET_I386 */
 #endif /* NEED_CPU_H */
 
+
 };
 
 #if defined(CONFIG_USER_ONLY)
-- 
2.43.0
Re: [RFC PATCH 17/34] hw/core: [CPUTLB] Move target specifics to end of TCGCPUOps
Posted by Richard Henderson 10 months, 1 week ago
On 1/20/24 00:40, Anton Johansson wrote:
> TCGCPUOps contains an extra function pointer when included with
> NEED_CPU_H, these are moved from the middle to the end of the struct. As
> such offsets to target independent function pointers don't vary in
> target specific and independent code.
> 
> [Move target specfic fields to separate struct?]
> 
> Signed-off-by: Anton Johansson <anjo@rev.ng>

Or make these unconditional.  Move fake_user_interrupt into the CONFIG_USER_ONLY block and 
do_interrupt into the system block.


r~
Re: [RFC PATCH 17/34] hw/core: [CPUTLB] Move target specifics to end of TCGCPUOps
Posted by Richard Henderson 10 months ago
On 1/24/24 10:43, Richard Henderson wrote:
> On 1/20/24 00:40, Anton Johansson wrote:
>> TCGCPUOps contains an extra function pointer when included with
>> NEED_CPU_H, these are moved from the middle to the end of the struct. As
>> such offsets to target independent function pointers don't vary in
>> target specific and independent code.
>>
>> [Move target specfic fields to separate struct?]
>>
>> Signed-off-by: Anton Johansson <anjo@rev.ng>
> 
> Or make these unconditional.  Move fake_user_interrupt into the CONFIG_USER_ONLY block and 
> do_interrupt into the system block.

I have split the patch in two, made fake_user_interrupt unconditional, and queued.


r~