[PATCH v2 35/37] target/sparc: Implement MWAIT

Richard Henderson posted 37 patches 6 months ago
Maintainers: Aurelien Jarno <aurelien@aurel32.net>, Peter Maydell <peter.maydell@linaro.org>, "Alex Bennée" <alex.bennee@linaro.org>, Laurent Vivier <laurent@vivier.eu>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>
[PATCH v2 35/37] target/sparc: Implement MWAIT
Posted by Richard Henderson 6 months ago
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/sparc/insns.decode |  1 +
 target/sparc/translate.c  | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode
index a7720560f8..fbcb4f7aef 100644
--- a/target/sparc/insns.decode
+++ b/target/sparc/insns.decode
@@ -124,6 +124,7 @@ CALL    01 i:s30
     WRTICK_CMPR     10 10111 110000 ..... . .............  @n_r_ri
     WRSTICK         10 11000 110000 ..... . .............  @n_r_ri
     WRSTICK_CMPR    10 11001 110000 ..... . .............  @n_r_ri
+    WRMWAIT         10 11100 110000 ..... . .............  @n_r_ri
   ]
   # Before v8, rs1==0 was WRY, and the rest executed as nop.
   [
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index e3e92bcf83..dba0eaa30c 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -3344,6 +3344,17 @@ static void do_wrpowerdown(DisasContext *dc, TCGv src)
 
 TRANS(WRPOWERDOWN, POWERDOWN, do_wr_special, a, supervisor(dc), do_wrpowerdown)
 
+static void do_wrmwait(DisasContext *dc, TCGv src)
+{
+    /*
+     * TODO: This is a stub version of mwait, which merely recognizes
+     * interrupts immediately and does not wait.
+     */
+    dc->base.is_jmp = DISAS_EXIT;
+}
+
+TRANS(WRMWAIT, VIS4, do_wr_special, a, true, do_wrmwait)
+
 static void do_wrpsr(DisasContext *dc, TCGv src)
 {
     gen_helper_wrpsr(tcg_env, src);
-- 
2.34.1
Re: [PATCH v2 35/37] target/sparc: Implement MWAIT
Posted by Philippe Mathieu-Daudé 5 months, 3 weeks ago
On 26/5/24 21:42, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/sparc/insns.decode |  1 +
>   target/sparc/translate.c  | 11 +++++++++++
>   2 files changed, 12 insertions(+)


> +static void do_wrmwait(DisasContext *dc, TCGv src)
> +{
> +    /*
> +     * TODO: This is a stub version of mwait, which merely recognizes
> +     * interrupts immediately and does not wait.

If icount is used, do we need to consume some instructions from the budget?

> +     */
> +    dc->base.is_jmp = DISAS_EXIT;
> +}

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


Re: [PATCH v2 35/37] target/sparc: Implement MWAIT
Posted by Richard Henderson 5 months, 3 weeks ago
On 6/5/24 02:27, Philippe Mathieu-Daudé wrote:
> On 26/5/24 21:42, Richard Henderson wrote:
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>   target/sparc/insns.decode |  1 +
>>   target/sparc/translate.c  | 11 +++++++++++
>>   2 files changed, 12 insertions(+)
> 
> 
>> +static void do_wrmwait(DisasContext *dc, TCGv src)
>> +{
>> +    /*
>> +     * TODO: This is a stub version of mwait, which merely recognizes
>> +     * interrupts immediately and does not wait.
> 
> If icount is used, do we need to consume some instructions from the budget?

Pardon?  There's nothing special about this.
One insn will be consumed from the budget.


r~