From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: xianglai li <lixianglai@loongson.cn>,
qemu-devel@nongnu.org, kvm@vger.kernel.org
Cc: "Tianrui Zhao" <zhaotianrui@loongson.cn>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Bibo Mao" <maobibo@loongson.cn>,
"Song Gao" <gaosong@loongson.cn>,
"Xiaojuan Yang" <yangxiaojuan@loongson.cn>
Subject: Re: [PATCH RFC v4 4/9] target/loongarch: Implement kvm get/set registers
Date: Wed, 11 Oct 2023 04:56:16 +0200 [thread overview]
Message-ID: <1f552f71-3b47-a2be-67c5-fdca86bf59f7@linaro.org> (raw)
In-Reply-To: <f4399db694265f34dbe9aafd024c56470e8a0f54.1696841645.git.lixianglai@loongson.cn>
Hi Li and Zhao,
On 9/10/23 11:01, xianglai li wrote:
> From: Tianrui Zhao <zhaotianrui@loongson.cn>
>
> Implement kvm_arch_get/set_registers interfaces, many regs
> can be get/set in the function, such as core regs, csr regs,
> fpu regs, mp state, etc.
>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Bibo Mao <maobibo@loongson.cn>
> Cc: Song Gao <gaosong@loongson.cn>
> Cc: Xiaojuan Yang <yangxiaojuan@loongson.cn>
> Cc: Tianrui Zhao <zhaotianrui@loongson.cn>
>
> Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn>
> Signed-off-by: xianglai li <lixianglai@loongson.cn>
> ---
> meson.build | 1 +
> target/loongarch/cpu.c | 3 +
> target/loongarch/cpu.h | 2 +
> target/loongarch/kvm.c | 406 +++++++++++++++++++++++++++++++++-
> target/loongarch/trace-events | 13 ++
> target/loongarch/trace.h | 1 +
> 6 files changed, 424 insertions(+), 2 deletions(-)
> create mode 100644 target/loongarch/trace-events
> create mode 100644 target/loongarch/trace.h
> +static int kvm_larch_getq(CPUState *cs, uint64_t reg_id,
> + uint64_t *addr)
> +{
> + struct kvm_one_reg csrreg = {
> + .id = reg_id,
> + .addr = (uintptr_t)addr
> + };
> +
> + return kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &csrreg);
> +}
This is kvm_get_one_reg().
> +static int kvm_larch_putq(CPUState *cs, uint64_t reg_id,
> + uint64_t *addr)
> +{
> + struct kvm_one_reg csrreg = {
> + .id = reg_id,
> + .addr = (uintptr_t)addr
> + };
> +
> + return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &csrreg);
> +}
This is kvm_set_one_reg().
> +
> +#define KVM_GET_ONE_UREG64(cs, ret, regidx, addr) \
> + ({ \
> + err = kvm_larch_getq(cs, KVM_IOC_CSRID(regidx), addr); \
> + if (err < 0) { \
> + ret = err; \
> + trace_kvm_failed_get_csr(regidx, strerror(errno)); \
> + } \
> + })
> +
> +#define KVM_PUT_ONE_UREG64(cs, ret, regidx, addr) \
> + ({ \
> + err = kvm_larch_putq(cs, KVM_IOC_CSRID(regidx), addr); \
> + if (err < 0) { \
> + ret = err; \
> + trace_kvm_failed_put_csr(regidx, strerror(errno)); \
> + } \
> + })
next prev parent reply other threads:[~2023-10-11 2:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-09 9:01 [PATCH RFC v4 0/9] Add loongarch kvm accel support xianglai li
2023-10-09 9:01 ` [PATCH RFC v4 1/9] linux-headers: Add KVM headers for loongarch xianglai li
2023-10-09 9:01 ` [PATCH RFC v4 2/9] target/loongarch: Define some kvm_arch interfaces xianglai li
2023-10-09 9:01 ` [PATCH RFC v4 3/9] target/loongarch: Supplement vcpu env initial when vcpu reset xianglai li
2023-10-09 9:01 ` [PATCH RFC v4 4/9] target/loongarch: Implement kvm get/set registers xianglai li
2023-10-11 2:56 ` Philippe Mathieu-Daudé [this message]
2023-10-11 9:23 ` lixianglai
2023-10-09 9:01 ` [PATCH RFC v4 5/9] target/loongarch: Implement kvm_arch_init function xianglai li
2023-10-09 9:01 ` [PATCH RFC v4 6/9] target/loongarch: Implement kvm_arch_init_vcpu xianglai li
2023-10-09 9:01 ` [PATCH RFC v4 7/9] target/loongarch: Implement kvm_arch_handle_exit xianglai li
2023-10-09 9:01 ` [PATCH RFC v4 8/9] target/loongarch: Implement set vcpu intr for kvm xianglai li
2023-10-09 9:01 ` [PATCH RFC v4 9/9] target/loongarch: Add loongarch kvm into meson build xianglai li
2023-10-11 12:31 ` [PATCH RFC v4 0/9] Add loongarch kvm accel support Philippe Mathieu-Daudé
2023-10-12 3:38 ` lixianglai
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=1f552f71-3b47-a2be-67c5-fdca86bf59f7@linaro.org \
--to=philmd@linaro.org \
--cc=berrange@redhat.com \
--cc=cohuck@redhat.com \
--cc=gaosong@loongson.cn \
--cc=kvm@vger.kernel.org \
--cc=lixianglai@loongson.cn \
--cc=maobibo@loongson.cn \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
--cc=yangxiaojuan@loongson.cn \
--cc=zhaotianrui@loongson.cn \
/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).