qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
To: Jim Shu <jim.shu@sifive.com>,
	qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
	Alistair Francis <alistair.francis@wdc.com>,
	Bin Meng <bin.meng@windriver.com>,
	Weiwei Li <liweiwei@iscas.ac.cn>,
	Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Subject: Re: [PATCH 2/2] target/riscv: Make the "virt" register writable by GDB
Date: Mon, 6 Mar 2023 19:26:21 +0800	[thread overview]
Message-ID: <0b2407ee-a7dd-d651-763a-a73b3802dc8f@linux.alibaba.com> (raw)
In-Reply-To: <20230305094231.1616-2-jim.shu@sifive.com>


On 2023/3/5 17:42, Jim Shu wrote:
> This patch also enables debugger to set current privilege mode to
> VU/VS-mode.
>
> Extend previous commit 81d2929c41d32af138f3562f5a7b309f6eac7ca7 to
> support H-extension.
>
> Signed-off-by: Jim Shu <jim.shu@sifive.com>
> Reviewed-by: Frank Chang <frank.chang@sifive.com>
> ---
>   target/riscv/gdbstub.c | 18 ++++++++++++++++--
>   1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c
> index 1755fd9d51..a7f234beaf 100644
> --- a/target/riscv/gdbstub.c
> +++ b/target/riscv/gdbstub.c
> @@ -203,15 +203,29 @@ static int riscv_gdb_get_virtual(CPURISCVState *cs, GByteArray *buf, int n)
>   
>   static int riscv_gdb_set_virtual(CPURISCVState *cs, uint8_t *mem_buf, int n)
>   {
> +#ifdef CONFIG_USER_ONLY
> +    if (n >= 0 && n <= 1) {
> +        return sizeof(target_ulong);
> +    }
> +#else
> +    bool virt;
> +
>       if (n == 0) {
> -#ifndef CONFIG_USER_ONLY
>           cs->priv = ldtul_p(mem_buf) & 0x3;
>           if (cs->priv == PRV_H) {
>               cs->priv = PRV_S;
>           }
> -#endif
> +        return sizeof(target_ulong);
We should return according to the misa_mxl_max. And this is a bug before 
your commit.
> +    } else if (n == 1) {
> +        virt = ldtul_p(mem_buf) & 0x1;
> +        if ((cs->priv == PRV_M) && (virt == true)) {
> +            /* M-mode only supports V=0. */
> +            virt = false;
> +        }
> +        riscv_cpu_set_virt_enabled(cs, virt);
>           return sizeof(target_ulong);
Same error here. Otherwise,

Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>

Zhiwei

>       }
> +#endif
>       return 0;
>   }
>   


  reply	other threads:[~2023-03-06 11:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-05  9:42 [PATCH 1/2] target/riscv: Expose "virt" register for GDB for reads Jim Shu
2023-03-05  9:42 ` [PATCH 2/2] target/riscv: Make the "virt" register writable by GDB Jim Shu
2023-03-06 11:26   ` LIU Zhiwei [this message]
2023-03-08 11:14     ` Jim Shu
2023-03-09  3:05     ` Jim Shu
2023-03-09  3:21       ` LIU Zhiwei
2023-03-10  3:58   ` Alistair Francis
2023-03-06 11:22 ` [PATCH 1/2] target/riscv: Expose "virt" register for GDB for reads LIU Zhiwei
2023-03-10  0:05 ` Alistair Francis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0b2407ee-a7dd-d651-763a-a73b3802dc8f@linux.alibaba.com \
    --to=zhiwei_liu@linux.alibaba.com \
    --cc=alistair.francis@wdc.com \
    --cc=bin.meng@windriver.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=jim.shu@sifive.com \
    --cc=liweiwei@iscas.ac.cn \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).