[PATCH] target/hexagon: use vaddr for wait PC

Yonggang Luo posted 1 patch 1 month, 3 weeks ago
Failed in applying to current master (apply log)
target/hexagon/gen_tcg_sys.h | 2 +-
target/hexagon/helper.h      | 2 +-
target/hexagon/op_helper.c   | 8 ++++----
3 files changed, 6 insertions(+), 6 deletions(-)
[PATCH] target/hexagon: use vaddr for wait PC
Posted by Yonggang Luo 1 month, 3 weeks ago
Pass the wait-instruction resume PC as vaddr through the helper
interface and implementation.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 target/hexagon/gen_tcg_sys.h | 2 +-
 target/hexagon/helper.h      | 2 +-
 target/hexagon/op_helper.c   | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/target/hexagon/gen_tcg_sys.h b/target/hexagon/gen_tcg_sys.h
index af5032214c..de66b85b49 100644
--- a/target/hexagon/gen_tcg_sys.h
+++ b/target/hexagon/gen_tcg_sys.h
@@ -80,7 +80,7 @@
 #define fGEN_TCG_Y2_wait(SHORTCODE) \
     do { \
         RsV = RsV; \
-        gen_helper_wait(tcg_env, tcg_constant_tl(ctx->pkt.pc)); \
+        gen_helper_wait(tcg_env, tcg_constant_vaddr(ctx->pkt.pc)); \
     } while (0)
 
 #define fGEN_TCG_Y2_resume(SHORTCODE) \
diff --git a/target/hexagon/helper.h b/target/hexagon/helper.h
index 71c8da4c46..18cff7f4d2 100644
--- a/target/hexagon/helper.h
+++ b/target/hexagon/helper.h
@@ -136,7 +136,7 @@ DEF_HELPER_3(sreg_write_masked, void, env, i32, i32)
 DEF_HELPER_3(setprio, void, env, i32, i32)
 DEF_HELPER_2(start, void, env, i32)
 DEF_HELPER_1(stop, void, env)
-DEF_HELPER_2(wait, void, env, i32)
+DEF_HELPER_2(wait, void, env, vaddr)
 DEF_HELPER_2(resume, void, env, i32)
 DEF_HELPER_1(resched, void, env)
 DEF_HELPER_3(modify_ssr, void, env, i32, i32)
diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c
index 4f00ca773f..0785f1a127 100644
--- a/target/hexagon/op_helper.c
+++ b/target/hexagon/op_helper.c
@@ -1741,7 +1741,7 @@ static void set_wait_mode(CPUHexagonState *env)
     SET_SYSTEM_FIELD(env, HEX_SREG_MODECTL, MODECTL_W, thread_wait_mask);
 }
 
-static void hexagon_wait_thread(CPUHexagonState *env, uint32_t PC)
+static void hexagon_wait_thread(CPUHexagonState *env, vaddr pc)
 {
     CPUState *cs;
 
@@ -1768,7 +1768,7 @@ static void hexagon_wait_thread(CPUHexagonState *env, uint32_t PC)
         return;
     }
     set_wait_mode(env);
-    env->wait_next_pc = PC + 4;
+    env->wait_next_pc = pc + 4;
 
     cpu_interrupt(cs, CPU_INTERRUPT_HALT);
 }
@@ -1836,12 +1836,12 @@ void HELPER(resched)(CPUHexagonState *env)
     resched(env);
 }
 
-void HELPER(wait)(CPUHexagonState *env, uint32_t PC)
+void HELPER(wait)(CPUHexagonState *env, vaddr pc)
 {
     BQL_LOCK_GUARD();
 
     if (!fIN_DEBUG_MODE(env->threadId)) {
-        hexagon_wait_thread(env, PC);
+        hexagon_wait_thread(env, pc);
     }
 }
 
-- 
2.55.0.windows.3
Re: [PATCH] target/hexagon: use vaddr for wait PC
Posted by Philippe Mathieu-Daudé 1 month, 3 weeks ago
On 30/9/26 09:20, Yonggang Luo wrote:
> Pass the wait-instruction resume PC as vaddr through the helper
> interface and implementation.
> 
> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> ---
>   target/hexagon/gen_tcg_sys.h | 2 +-
>   target/hexagon/helper.h      | 2 +-
>   target/hexagon/op_helper.c   | 8 ++++----
>   3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/target/hexagon/gen_tcg_sys.h b/target/hexagon/gen_tcg_sys.h
> index af5032214c..de66b85b49 100644
> --- a/target/hexagon/gen_tcg_sys.h
> +++ b/target/hexagon/gen_tcg_sys.h
> @@ -80,7 +80,7 @@
>   #define fGEN_TCG_Y2_wait(SHORTCODE) \
>       do { \
>           RsV = RsV; \
> -        gen_helper_wait(tcg_env, tcg_constant_tl(ctx->pkt.pc)); \
> +        gen_helper_wait(tcg_env, tcg_constant_vaddr(ctx->pkt.pc)); \

Just curious, why tcg_constant_vaddr over tcg_constant_i32?

>       } while (0)
>   
>   #define fGEN_TCG_Y2_resume(SHORTCODE) \
> diff --git a/target/hexagon/helper.h b/target/hexagon/helper.h
> index 71c8da4c46..18cff7f4d2 100644
> --- a/target/hexagon/helper.h
> +++ b/target/hexagon/helper.h
> @@ -136,7 +136,7 @@ DEF_HELPER_3(sreg_write_masked, void, env, i32, i32)
>   DEF_HELPER_3(setprio, void, env, i32, i32)
>   DEF_HELPER_2(start, void, env, i32)
>   DEF_HELPER_1(stop, void, env)
> -DEF_HELPER_2(wait, void, env, i32)
> +DEF_HELPER_2(wait, void, env, vaddr)
>   DEF_HELPER_2(resume, void, env, i32)
>   DEF_HELPER_1(resched, void, env)
>   DEF_HELPER_3(modify_ssr, void, env, i32, i32)
> diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c
> index 4f00ca773f..0785f1a127 100644
> --- a/target/hexagon/op_helper.c
> +++ b/target/hexagon/op_helper.c
> @@ -1741,7 +1741,7 @@ static void set_wait_mode(CPUHexagonState *env)
>       SET_SYSTEM_FIELD(env, HEX_SREG_MODECTL, MODECTL_W, thread_wait_mask);
>   }
>   
> -static void hexagon_wait_thread(CPUHexagonState *env, uint32_t PC)
> +static void hexagon_wait_thread(CPUHexagonState *env, vaddr pc)
>   {
>       CPUState *cs;
>   
> @@ -1768,7 +1768,7 @@ static void hexagon_wait_thread(CPUHexagonState *env, uint32_t PC)
>           return;
>       }
>       set_wait_mode(env);
> -    env->wait_next_pc = PC + 4;
> +    env->wait_next_pc = pc + 4;
>   
>       cpu_interrupt(cs, CPU_INTERRUPT_HALT);
>   }
> @@ -1836,12 +1836,12 @@ void HELPER(resched)(CPUHexagonState *env)
>       resched(env);
>   }
>   
> -void HELPER(wait)(CPUHexagonState *env, uint32_t PC)
> +void HELPER(wait)(CPUHexagonState *env, vaddr pc)
>   {
>       BQL_LOCK_GUARD();
>   
>       if (!fIN_DEBUG_MODE(env->threadId)) {
> -        hexagon_wait_thread(env, PC);
> +        hexagon_wait_thread(env, pc);
>       }
>   }
>
Re: [PATCH] target/hexagon: use vaddr for wait PC
Posted by Yonggang Luo 1 month, 3 weeks ago
On Wed, Sep 30, 2026 at 5:10 PM Philippe Mathieu-Daudé
<philmd@oss.qualcomm.com> wrote:
>
> On 30/9/26 09:20, Yonggang Luo wrote:
> > Pass the wait-instruction resume PC as vaddr through the helper
> > interface and implementation.
> >
> > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> > ---
> >   target/hexagon/gen_tcg_sys.h | 2 +-
> >   target/hexagon/helper.h      | 2 +-
> >   target/hexagon/op_helper.c   | 8 ++++----
> >   3 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/target/hexagon/gen_tcg_sys.h b/target/hexagon/gen_tcg_sys.h
> > index af5032214c..de66b85b49 100644
> > --- a/target/hexagon/gen_tcg_sys.h
> > +++ b/target/hexagon/gen_tcg_sys.h
> > @@ -80,7 +80,7 @@
> >   #define fGEN_TCG_Y2_wait(SHORTCODE) \
> >       do { \
> >           RsV = RsV; \
> > -        gen_helper_wait(tcg_env, tcg_constant_tl(ctx->pkt.pc)); \
> > +        gen_helper_wait(tcg_env, tcg_constant_vaddr(ctx->pkt.pc)); \
>
> Just curious, why tcg_constant_vaddr over tcg_constant_i32?

because "pc" is more like an addr than i32, if the hexagon is i32 only
then i32 is fine. but addr is still easier to understand(pc is an address).

>
> >       } while (0)
> >
> >   #define fGEN_TCG_Y2_resume(SHORTCODE) \
> > diff --git a/target/hexagon/helper.h b/target/hexagon/helper.h
> > index 71c8da4c46..18cff7f4d2 100644
> > --- a/target/hexagon/helper.h
> > +++ b/target/hexagon/helper.h
> > @@ -136,7 +136,7 @@ DEF_HELPER_3(sreg_write_masked, void, env, i32, i32)
> >   DEF_HELPER_3(setprio, void, env, i32, i32)
> >   DEF_HELPER_2(start, void, env, i32)
> >   DEF_HELPER_1(stop, void, env)
> > -DEF_HELPER_2(wait, void, env, i32)
> > +DEF_HELPER_2(wait, void, env, vaddr)
> >   DEF_HELPER_2(resume, void, env, i32)
> >   DEF_HELPER_1(resched, void, env)
> >   DEF_HELPER_3(modify_ssr, void, env, i32, i32)
> > diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c
> > index 4f00ca773f..0785f1a127 100644
> > --- a/target/hexagon/op_helper.c
> > +++ b/target/hexagon/op_helper.c
> > @@ -1741,7 +1741,7 @@ static void set_wait_mode(CPUHexagonState *env)
> >       SET_SYSTEM_FIELD(env, HEX_SREG_MODECTL, MODECTL_W, thread_wait_mask);
> >   }
> >
> > -static void hexagon_wait_thread(CPUHexagonState *env, uint32_t PC)
> > +static void hexagon_wait_thread(CPUHexagonState *env, vaddr pc)
> >   {
> >       CPUState *cs;
> >
> > @@ -1768,7 +1768,7 @@ static void hexagon_wait_thread(CPUHexagonState *env, uint32_t PC)
> >           return;
> >       }
> >       set_wait_mode(env);
> > -    env->wait_next_pc = PC + 4;
> > +    env->wait_next_pc = pc + 4;
> >
> >       cpu_interrupt(cs, CPU_INTERRUPT_HALT);
> >   }
> > @@ -1836,12 +1836,12 @@ void HELPER(resched)(CPUHexagonState *env)
> >       resched(env);
> >   }
> >
> > -void HELPER(wait)(CPUHexagonState *env, uint32_t PC)
> > +void HELPER(wait)(CPUHexagonState *env, vaddr pc)
> >   {
> >       BQL_LOCK_GUARD();
> >
> >       if (!fIN_DEBUG_MODE(env->threadId)) {
> > -        hexagon_wait_thread(env, PC);
> > +        hexagon_wait_thread(env, pc);
> >       }
> >   }
> >
>


-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo