From: Alistair Francis <alistair23@gmail.com>
To: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
alistair.francis@wdc.com, bmeng@tinylab.org,
liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com,
palmer@rivosinc.com, ajones@ventanamicro.com
Subject: Re: [PATCH for-9.0 4/4] target/riscv/kvm: add RVV and Vector CSR regs
Date: Wed, 6 Dec 2023 10:29:15 +1000 [thread overview]
Message-ID: <CAKmqyKMJMmoJj4fTqJMducewvfqdukbueyaenXLaTWcT1_ou4A@mail.gmail.com> (raw)
In-Reply-To: <20231130182748.1894790-5-dbarboza@ventanamicro.com>
On Fri, Dec 1, 2023 at 5:40 AM Daniel Henrique Barboza
<dbarboza@ventanamicro.com> wrote:
>
> Add support for RVV and Vector CSR KVM regs vstart, vl and vtype.
>
> Support for vregs[] requires KVM side changes and an extra reg (vlenb)
> and will be added later.
>
> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> target/riscv/kvm/kvm-cpu.c | 74 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 74 insertions(+)
>
> diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c
> index 273c71baea..5408ead81c 100644
> --- a/target/riscv/kvm/kvm-cpu.c
> +++ b/target/riscv/kvm/kvm-cpu.c
> @@ -89,6 +89,10 @@ static uint64_t kvm_riscv_reg_id(CPURISCVState *env, uint64_t type,
>
> #define RISCV_FP_D_REG(env, idx) kvm_riscv_reg_id(env, KVM_REG_RISCV_FP_D, idx)
>
> +#define RISCV_VECTOR_CSR_REG(env, name) \
> + kvm_riscv_reg_id(env, KVM_REG_RISCV_VECTOR, \
> + KVM_REG_RISCV_VECTOR_CSR_REG(name))
> +
> #define KVM_RISCV_GET_CSR(cs, env, csr, reg) \
> do { \
> int _ret = kvm_get_one_reg(cs, RISCV_CSR_REG(env, csr), ®); \
> @@ -142,6 +146,7 @@ static KVMCPUConfig kvm_misa_ext_cfgs[] = {
> KVM_MISA_CFG(RVH, KVM_RISCV_ISA_EXT_H),
> KVM_MISA_CFG(RVI, KVM_RISCV_ISA_EXT_I),
> KVM_MISA_CFG(RVM, KVM_RISCV_ISA_EXT_M),
> + KVM_MISA_CFG(RVV, KVM_RISCV_ISA_EXT_V),
> };
>
> static void kvm_cpu_get_misa_ext_cfg(Object *obj, Visitor *v,
> @@ -688,6 +693,65 @@ static void kvm_riscv_put_regs_timer(CPUState *cs)
> env->kvm_timer_dirty = false;
> }
>
> +static int kvm_riscv_get_regs_vector(CPUState *cs)
> +{
> + CPURISCVState *env = &RISCV_CPU(cs)->env;
> + target_ulong reg;
> + int ret = 0;
> +
> + if (!riscv_has_ext(env, RVV)) {
> + return 0;
> + }
> +
> + ret = kvm_get_one_reg(cs, RISCV_VECTOR_CSR_REG(env, vstart), ®);
> + if (ret) {
> + return ret;
> + }
> + env->vstart = reg;
> +
> + ret = kvm_get_one_reg(cs, RISCV_VECTOR_CSR_REG(env, vl), ®);
> + if (ret) {
> + return ret;
> + }
> + env->vl = reg;
> +
> + ret = kvm_get_one_reg(cs, RISCV_VECTOR_CSR_REG(env, vtype), ®);
> + if (ret) {
> + return ret;
> + }
> + env->vtype = reg;
> +
> + return 0;
> +}
> +
> +static int kvm_riscv_put_regs_vector(CPUState *cs)
> +{
> + CPURISCVState *env = &RISCV_CPU(cs)->env;
> + target_ulong reg;
> + int ret = 0;
> +
> + if (!riscv_has_ext(env, RVV)) {
> + return 0;
> + }
> +
> + reg = env->vstart;
> + ret = kvm_set_one_reg(cs, RISCV_VECTOR_CSR_REG(env, vstart), ®);
> + if (ret) {
> + return ret;
> + }
> +
> + reg = env->vl;
> + ret = kvm_set_one_reg(cs, RISCV_VECTOR_CSR_REG(env, vl), ®);
> + if (ret) {
> + return ret;
> + }
> +
> + reg = env->vtype;
> + ret = kvm_set_one_reg(cs, RISCV_VECTOR_CSR_REG(env, vtype), ®);
> +
> + return ret;
> +}
> +
> typedef struct KVMScratchCPU {
> int kvmfd;
> int vmfd;
> @@ -989,6 +1053,11 @@ int kvm_arch_get_registers(CPUState *cs)
> return ret;
> }
>
> + ret = kvm_riscv_get_regs_vector(cs);
> + if (ret) {
> + return ret;
> + }
> +
> return ret;
> }
>
> @@ -1029,6 +1098,11 @@ int kvm_arch_put_registers(CPUState *cs, int level)
> return ret;
> }
>
> + ret = kvm_riscv_put_regs_vector(cs);
> + if (ret) {
> + return ret;
> + }
> +
> if (KVM_PUT_RESET_STATE == level) {
> RISCVCPU *cpu = RISCV_CPU(cs);
> if (cs->cpu_index == 0) {
> --
> 2.41.0
>
>
next prev parent reply other threads:[~2023-12-06 0:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-30 18:27 [PATCH for-9.0 0/4] target/riscv: add RVV CSRs Daniel Henrique Barboza
2023-11-30 18:27 ` [PATCH for-9.0 1/4] linux-headers: Update to Linux v6.7-rc3 Daniel Henrique Barboza
2023-12-06 0:23 ` Alistair Francis
2023-11-30 18:27 ` [PATCH for-9.0 2/4] linux-headers: riscv: add ptrace.h Daniel Henrique Barboza
2023-12-06 0:24 ` Alistair Francis
2023-11-30 18:27 ` [PATCH for-9.0 3/4] target/riscv/kvm: do PR_RISCV_V_SET_CONTROL during realize() Daniel Henrique Barboza
2023-12-06 0:25 ` Alistair Francis
2023-11-30 18:27 ` [PATCH for-9.0 4/4] target/riscv/kvm: add RVV and Vector CSR regs Daniel Henrique Barboza
2023-12-06 0:29 ` Alistair Francis [this message]
2023-12-18 3:18 ` [PATCH for-9.0 0/4] target/riscv: add RVV CSRs 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=CAKmqyKMJMmoJj4fTqJMducewvfqdukbueyaenXLaTWcT1_ou4A@mail.gmail.com \
--to=alistair23@gmail.com \
--cc=ajones@ventanamicro.com \
--cc=alistair.francis@wdc.com \
--cc=bmeng@tinylab.org \
--cc=dbarboza@ventanamicro.com \
--cc=liwei1518@gmail.com \
--cc=palmer@rivosinc.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.com \
/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).