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>, Marc Zyngier <maz@kernel.org>,
Oliver Upton <oliver.upton@linux.dev>,
James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Anup Patel <anup@brainfault.org>,
Atish Patra <atishp@atishpatra.org>, Guo Ren <guoren@kernel.org>,
Conor Dooley <conor.dooley@microchip.com>,
Mayuresh Chitale <mchitale@ventanamicro.com>,
Greentime Hu <greentime.hu@sifive.com>,
wchen <waylingii@gmail.com>, Jisheng Zhang <jszhang@kernel.org>,
Minda Chen <minda.chen@starfivetech.com>,
Samuel Holland <samuel@sholland.org>,
Sean Christopherson <seanjc@google.com>,
Like Xu <likexu@tencent.com>, Peter Xu <peterx@redhat.com>,
Vipin Sharma <vipinsh@google.com>,
Aaron Lewis <aaronlewis@google.com>,
Thomas Huth <thuth@redhat.com>,
Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>,
linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
kvm-riscv@lists.infradead.org
Subject: Re: [PATCH v4 08/11] KVM: riscv: selftests: Add guest helper to get vcpu id
Date: Tue, 19 Dec 2023 10:28:31 +0800 [thread overview]
Message-ID: <CAJve8okOO=e66Kko3LyDfsD+tRZvDGf_Zgmog-u5TUzk1JZ1RA@mail.gmail.com> (raw)
In-Reply-To: <20231213-b02db86aaf7957be22b200f1@orel>
On Wed, Dec 13, 2023 at 10:08 PM Andrew Jones <ajones@ventanamicro.com> wrote:
>
> On Tue, Dec 12, 2023 at 05:31:17PM +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>
> > Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
> > ---
> > tools/testing/selftests/kvm/include/aarch64/processor.h | 4 ----
> > tools/testing/selftests/kvm/include/kvm_util_base.h | 9 +++++++++
> > tools/testing/selftests/kvm/lib/riscv/processor.c | 8 ++++++++
> > 3 files changed, 17 insertions(+), 4 deletions(-)
> >
> > diff --git a/tools/testing/selftests/kvm/include/aarch64/processor.h b/tools/testing/selftests/kvm/include/aarch64/processor.h
> > index c42d683102c7..16ae0ac01879 100644
> > --- a/tools/testing/selftests/kvm/include/aarch64/processor.h
> > +++ b/tools/testing/selftests/kvm/include/aarch64/processor.h
> > @@ -226,8 +226,4 @@ void smccc_smc(uint32_t function_id, uint64_t arg0, uint64_t arg1,
> > uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5,
> > uint64_t arg6, struct arm_smccc_res *res);
> >
> > -
> > -
> > -uint32_t guest_get_vcpuid(void);
> > -
> > #endif /* SELFTEST_KVM_PROCESSOR_H */
> > diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h
> > index a18db6a7b3cf..666438113d22 100644
> > --- a/tools/testing/selftests/kvm/include/kvm_util_base.h
> > +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h
> > @@ -932,4 +932,13 @@ void kvm_selftest_arch_init(void);
> >
> > void kvm_arch_vm_post_create(struct kvm_vm *vm);
> >
> > +void vm_init_vector_tables(struct kvm_vm *vm);
> > +void vcpu_init_vector_tables(struct kvm_vcpu *vcpu);
> > +
> > +struct ex_regs;
> > +typedef void(*exception_handler_fn)(struct ex_regs *);
> > +void vm_install_exception_handler(struct kvm_vm *vm, int vector, exception_handler_fn handler);
>
> I think something happend on rebase since the above should be in a
> different patch (and were for v3). I suggest checking your previous
> and current version branches with git-range-diff after rebasing in
> order to catch stuff like this.
>
> Thanks,
> drew
>
Thanks for pointing it out. Will fix it in v5.
> > +
> > +uint32_t guest_get_vcpuid(void);
> > +
> > #endif /* SELFTEST_KVM_UTIL_BASE_H */
> > diff --git a/tools/testing/selftests/kvm/lib/riscv/processor.c b/tools/testing/selftests/kvm/lib/riscv/processor.c
> > index efd9ac4b0198..39a1e9902dec 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 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);
> >
> > @@ -436,3 +439,8 @@ void vm_install_interrupt_handler(struct kvm_vm *vm, exception_handler_fn handle
> >
> > handlers->exception_handlers[1][0] = handler;
> > }
> > +
> > +uint32_t guest_get_vcpuid(void)
> > +{
> > + return csr_read(CSR_SSCRATCH);
> > +}
> > --
> > 2.34.1
> >
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2023-12-19 2:28 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 9:31 [PATCH v4 00/11] RISCV: Add kvm Sstc timer selftests Haibo Xu
2023-12-12 9:31 ` [PATCH v4 01/11] selftests/kvm: Fix issues with $(SPLIT_TESTS) Haibo Xu
2023-12-12 9:31 ` [PATCH v4 02/11] KVM: arm64: selftests: Split arch_timer test code Haibo Xu
2023-12-14 6:41 ` Anup Patel
2023-12-12 9:31 ` [PATCH v4 03/11] KVM: selftests: Add CONFIG_64BIT definition for the build Haibo Xu
2023-12-13 13:52 ` Andrew Jones
2023-12-12 9:31 ` [PATCH v4 04/11] tools: riscv: Add header file csr.h Haibo Xu
2023-12-12 9:31 ` [PATCH v4 05/11] tools: riscv: Add header file vdso/processor.h Haibo Xu
2023-12-13 14:02 ` Andrew Jones
2023-12-12 9:31 ` [PATCH v4 06/11] KVM: riscv: selftests: Switch to use macro from csr.h Haibo Xu
2023-12-12 9:31 ` [PATCH v4 07/11] KVM: riscv: selftests: Add exception handling support Haibo Xu
2023-12-12 9:31 ` [PATCH v4 08/11] KVM: riscv: selftests: Add guest helper to get vcpu id Haibo Xu
2023-12-13 14:08 ` Andrew Jones
2023-12-19 2:28 ` Haibo Xu [this message]
2023-12-12 9:31 ` [PATCH v4 09/11] KVM: riscv: selftests: Change vcpu_has_ext to a common function Haibo Xu
2023-12-12 9:31 ` [PATCH v4 10/11] KVM: riscv: selftests: Add sstc timer test Haibo Xu
2023-12-13 14:18 ` Andrew Jones
2023-12-12 9:31 ` [PATCH v4 11/11] KVM: selftests: Enable tunning of err_margin_us in arch " Haibo Xu
2023-12-13 14:27 ` Andrew Jones
2023-12-14 6:44 ` Anup Patel
2023-12-19 18:22 ` Marc Zyngier
2023-12-20 6:50 ` Haibo Xu
2023-12-20 9:00 ` Marc Zyngier
2023-12-20 13:51 ` Haibo Xu
2023-12-20 13:58 ` Marc Zyngier
2023-12-21 2:58 ` Haibo Xu
2023-12-21 9:25 ` Marc Zyngier
2024-01-04 11:09 ` Andrew Jones
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='CAJve8okOO=e66Kko3LyDfsD+tRZvDGf_Zgmog-u5TUzk1JZ1RA@mail.gmail.com' \
--to=xiaobo55x@gmail.com \
--cc=aaronlewis@google.com \
--cc=ajones@ventanamicro.com \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=atishp@atishpatra.org \
--cc=conor.dooley@microchip.com \
--cc=greentime.hu@sifive.com \
--cc=guoren@kernel.org \
--cc=haibo1.xu@intel.com \
--cc=james.morse@arm.com \
--cc=jszhang@kernel.org \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=likexu@tencent.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=maciej.wieczor-retman@intel.com \
--cc=maz@kernel.org \
--cc=mchitale@ventanamicro.com \
--cc=minda.chen@starfivetech.com \
--cc=oliver.upton@linux.dev \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=samuel@sholland.org \
--cc=seanjc@google.com \
--cc=shuah@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=thuth@redhat.com \
--cc=vipinsh@google.com \
--cc=waylingii@gmail.com \
--cc=yuzenghui@huawei.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).