linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Haibo Xu <xiaobo55x@gmail.com>
To: Andrew Jones <ajones@ventanamicro.com>
Cc: Haibo Xu <haibo1.xu@intel.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	 Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	 Paolo Bonzini <pbonzini@redhat.com>,
	Shuah Khan <shuah@kernel.org>, Anup Patel <anup@brainfault.org>,
	 Atish Patra <atishp@atishpatra.org>,
	Sean Christopherson <seanjc@google.com>,
	 Colton Lewis <coltonlewis@google.com>,
	Andrew Jones <andrew.jones@linux.dev>,
	 Vipin Sharma <vipinsh@google.com>, Marc Zyngier <maz@kernel.org>,
	 Vishal Annapurve <vannapurve@google.com>,
	linux-kernel@vger.kernel.org,  linux-riscv@lists.infradead.org,
	kvm@vger.kernel.org,  linux-kselftest@vger.kernel.org,
	kvm-riscv@lists.infradead.org
Subject: Re: [PATCH 3/4] KVM: riscv: selftests: Add guest helper to get vcpu id
Date: Wed, 2 Aug 2023 10:02:07 +0800	[thread overview]
Message-ID: <CAJve8omPWM7JR+Bqtemw0XjP8Q-C5zNbAzWxB_HMFcWKoSFuog@mail.gmail.com> (raw)
In-Reply-To: <20230728-42019a78766a59dc5abdd412@orel>

On Fri, Jul 28, 2023 at 5:49 PM Andrew Jones <ajones@ventanamicro.com> wrote:
>
> On Thu, Jul 27, 2023 at 03:20:07PM +0800, Haibo Xu wrote:
> > Add guest_get_vcpuid() helper to simplify accessing to per-cpu
> > private data. The sscratch CSR was used to store the vcpu id.
> >
> > Signed-off-by: Haibo Xu <haibo1.xu@intel.com>
> > ---
> >  tools/testing/selftests/kvm/include/riscv/processor.h | 2 ++
> >  tools/testing/selftests/kvm/lib/riscv/processor.c     | 8 ++++++++
> >  2 files changed, 10 insertions(+)
> >
> > diff --git a/tools/testing/selftests/kvm/include/riscv/processor.h b/tools/testing/selftests/kvm/include/riscv/processor.h
> > index 9ea6e7bedc61..ca53570ce6de 100644
> > --- a/tools/testing/selftests/kvm/include/riscv/processor.h
> > +++ b/tools/testing/selftests/kvm/include/riscv/processor.h
> > @@ -165,4 +165,6 @@ struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
> >                       unsigned long arg3, unsigned long arg4,
> >                       unsigned long arg5);
> >
> > +uint32_t guest_get_vcpuid(void);
>
> I'd also put this prototype somewhere common.
>
> > +
> >  #endif /* SELFTEST_KVM_PROCESSOR_H */
> > diff --git a/tools/testing/selftests/kvm/lib/riscv/processor.c b/tools/testing/selftests/kvm/lib/riscv/processor.c
> > index f1b0be58a5dc..b8ad3e69a697 100644
> > --- a/tools/testing/selftests/kvm/lib/riscv/processor.c
> > +++ b/tools/testing/selftests/kvm/lib/riscv/processor.c
> > @@ -316,6 +316,9 @@ struct kvm_vcpu *vm_arch_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id,
> >       vcpu_set_reg(vcpu, RISCV_CORE_REG(regs.sp), stack_vaddr + stack_size);
> >       vcpu_set_reg(vcpu, RISCV_CORE_REG(regs.pc), (unsigned long)guest_code);
> >
> > +     /* Setup scratch regiter of guest */
>
> typo: register
>
> The comment above is pretty useless since it just states what the code
> states, but with even less information, since it doesn't state how the
> sscratch register is getting set up. I'd either drop it or write it
> as
>
>  /* Setup sscratch for guest_get_vcpuid() */
>
> > +     vcpu_set_reg(vcpu, RISCV_CSR_REG(sscratch), vcpu_id);
> > +
> >       /* Setup default exception vector of guest */
> >       vcpu_set_reg(vcpu, RISCV_CSR_REG(stvec), (unsigned long)guest_unexp_trap);
> >
> > @@ -424,3 +427,8 @@ void vm_install_interrupt_handler(struct kvm_vm *vm, void (*handler)(struct ex_r
> >
> >       handlers->exception_handlers[1][0] = handler;
> >  }
> > +
> > +uint32_t guest_get_vcpuid(void)
> > +{
> > +     return csr_read(CSR_SSCRATCH);
> > +}
> > --
> > 2.34.1
> >
>

Sure! will fix them in v2.

Thanks,
Haibo

> Thanks,
> drew

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2023-08-02  2:02 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-27  7:20 [PATCH 0/4] RISCV: Add kvm Sstc timer selftest Haibo Xu
2023-07-27  7:20 ` [PATCH 1/4] tools: riscv: Add header file csr.h Haibo Xu
2023-07-28  9:43   ` Andrew Jones
2023-08-02  2:05     ` Haibo Xu
2023-08-03  3:13       ` Guo Ren
2023-08-03  7:44         ` Andrew Jones
2023-08-05  1:31           ` Guo Ren
2023-07-27  7:20 ` [PATCH 2/4] KVM: riscv: selftests: Add exception handling support Haibo Xu
2023-07-28  9:37   ` Andrew Jones
2023-07-28 15:53     ` Sean Christopherson
2023-08-02  1:49       ` Haibo Xu
2023-08-02  1:46     ` Haibo Xu
2023-07-27  7:20 ` [PATCH 3/4] KVM: riscv: selftests: Add guest helper to get vcpu id Haibo Xu
2023-07-28  9:49   ` Andrew Jones
2023-08-02  2:02     ` Haibo Xu [this message]
2023-07-27  7:20 ` [PATCH 4/4] KVM: riscv: selftests: Add sstc_timer test Haibo Xu
2023-07-27 15:14 ` [PATCH 0/4] RISCV: Add kvm Sstc timer selftest Sean Christopherson
2023-07-28  1:37   ` Haibo Xu
2023-07-28  9:57     ` Andrew Jones
2023-08-02  2:01       ` Haibo Xu
2023-08-02 22:16 ` Sean Christopherson
2023-08-03  0:26   ` Haibo Xu
2023-08-27  8:59   ` Haibo Xu
2023-08-28 14:08     ` Sean Christopherson
2023-08-29  5:04       ` Haibo Xu

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=CAJve8omPWM7JR+Bqtemw0XjP8Q-C5zNbAzWxB_HMFcWKoSFuog@mail.gmail.com \
    --to=xiaobo55x@gmail.com \
    --cc=ajones@ventanamicro.com \
    --cc=andrew.jones@linux.dev \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atishp@atishpatra.org \
    --cc=coltonlewis@google.com \
    --cc=haibo1.xu@intel.com \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=maz@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=shuah@kernel.org \
    --cc=vannapurve@google.com \
    --cc=vipinsh@google.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).