Reviewed-by: Jay Chang<[email protected]>
Thanks

On Tue, Aug 25, 2026 at 10:49 PM Konstantin Semichastnov <
[email protected]> wrote:

> N-Trace format requires idle bytes to be filled with 0xff, instead of
> zeroes, like E-Trace format
>
> Signed-off-by: Konstantin Semichastnov <[email protected]>
> ---
>  hw/riscv/trace-encoder.c | 24 +++++++++++++++++++-----
>  1 file changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/hw/riscv/trace-encoder.c b/hw/riscv/trace-encoder.c
> index 10e52e207e..703454c9b7 100644
> --- a/hw/riscv/trace-encoder.c
> +++ b/hw/riscv/trace-encoder.c
> @@ -398,21 +398,35 @@ static void trencoder_send_message_smem(TraceEncoder
> *trencoder,
>      hwaddr dest = trencoder_read_ramsink_writep(trencoder);
>      bool wrapped = false;
>
> +    if (trencoder->ntrace) {
> +        /*
> +         * RISC-V N-Trace 3.1. MSEO Sequences:
> +         * idle bytes in N-Trace format are filled with 0xff, instead of
> zeroes
> +         */
> +        memset(msg + msg_size, 0xff, 4 - msg_size % 4);
> +    }
>      msg_size = QEMU_ALIGN_UP(msg_size, 4);
>
>      /* clear trRamWrap before writing to SMEM */
>      dest = FIELD_DP64(dest, TR_RAM_WP_LOW, WRAP, 0);
>
>      /*
> -     * Fill with null bytes if we can't fit the packet in
> +     * Fill with idle bytes if we can't fit the packet in
>       * ramlimit, set wrap and write the packet in ramstart.
>       */
>      if (dest + msg_size > trencoder->ramsink_ramlimit) {
> -        g_autofree uint8_t *null_packet = NULL;
> -        uint8_t null_size = trencoder->ramsink_ramlimit - dest;
> +        g_autofree uint8_t *idle_packet = NULL;
> +        uint8_t idle_size = trencoder->ramsink_ramlimit - dest;
>
> -        null_packet = g_malloc0(null_size);
> -        cpu_physical_memory_write(dest, null_packet, null_size);
> +        idle_packet = g_malloc0(idle_size);
> +        if (trencoder->ntrace) {
> +            /*
> +             * RISC-V N-Trace 3.1. MSEO Sequences:
> +             * idle bytes in N-Trace format are filled with 0xff, instead
> of zeroes
> +             */
> +            memset(idle_packet, 0xff, idle_size);
> +        }
> +        cpu_physical_memory_write(dest, idle_packet, idle_size);
>
>          dest = trencoder->ramsink_ramstart;
>          wrapped = true;
>
> --
> 2.43.0
>
>
>

Reply via email to