Message ID | 20211129075451.418122-1-anup.patel@wdc.com |
---|---|
Headers | show |
Series | KVM RISC-V 64-bit selftests support | expand |
Hi Paolo, On Mon, Nov 29, 2021 at 1:40 PM Anup Patel <anup.patel@wdc.com> wrote: > > This series adds initial support for testing KVM RISC-V 64-bit using > kernel selftests framework. The PATCH1 & PATCH2 of this series does > some ground work in KVM RISC-V to implement RISC-V support in the KVM > selftests whereas remaining patches does required changes in the KVM > selftests. > > These patches can be found in riscv_kvm_selftests_v2 branch at: > https://github.com/avpatel/linux.git > > Changes since v1: > - Renamed kvm_sbi_ext_expevend_handler() to kvm_sbi_ext_forward_handler() > in PATCH1 > - Renamed KVM_CAP_RISCV_VM_GPA_SIZE to KVM_CAP_VM_GPA_BITS in PATCH2 > and PATCH4 > > Anup Patel (4): > RISC-V: KVM: Forward SBI experimental and vendor extensions > RISC-V: KVM: Add VM capability to allow userspace get GPA bits > KVM: selftests: Add EXTRA_CFLAGS in top-level Makefile > KVM: selftests: Add initial support for RISC-V 64-bit Any further comments on this series ? Regards, Anup > > arch/riscv/include/asm/kvm_host.h | 1 + > arch/riscv/kvm/mmu.c | 5 + > arch/riscv/kvm/vcpu_sbi.c | 4 + > arch/riscv/kvm/vcpu_sbi_base.c | 27 ++ > arch/riscv/kvm/vm.c | 3 + > include/uapi/linux/kvm.h | 1 + > tools/testing/selftests/kvm/Makefile | 14 +- > .../testing/selftests/kvm/include/kvm_util.h | 10 + > .../selftests/kvm/include/riscv/processor.h | 135 +++++++ > tools/testing/selftests/kvm/lib/guest_modes.c | 10 + > .../selftests/kvm/lib/riscv/processor.c | 362 ++++++++++++++++++ > tools/testing/selftests/kvm/lib/riscv/ucall.c | 87 +++++ > 12 files changed, 658 insertions(+), 1 deletion(-) > create mode 100644 tools/testing/selftests/kvm/include/riscv/processor.h > create mode 100644 tools/testing/selftests/kvm/lib/riscv/processor.c > create mode 100644 tools/testing/selftests/kvm/lib/riscv/ucall.c > > -- > 2.25.1 >
On Mon, Nov 29, 2021 at 12:10 AM Anup Patel <anup.patel@wdc.com> wrote: > > The SBI experimental extension space is for temporary (or experimental) > stuff whereas SBI vendor extension space is for hardware vendor specific > stuff. Both these SBI extension spaces won't be standardized by the SBI > specification so let's blindly forward such SBI calls to the userspace. > > Signed-off-by: Anup Patel <anup.patel@wdc.com> > --- > arch/riscv/kvm/vcpu_sbi.c | 4 ++++ > arch/riscv/kvm/vcpu_sbi_base.c | 27 +++++++++++++++++++++++++++ > 2 files changed, 31 insertions(+) > > diff --git a/arch/riscv/kvm/vcpu_sbi.c b/arch/riscv/kvm/vcpu_sbi.c > index f62d25bc9733..78aa3db76225 100644 > --- a/arch/riscv/kvm/vcpu_sbi.c > +++ b/arch/riscv/kvm/vcpu_sbi.c > @@ -46,6 +46,8 @@ extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_time; > extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_ipi; > extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_rfence; > extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_hsm; > +extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_experimental; > +extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_vendor; > > static const struct kvm_vcpu_sbi_extension *sbi_ext[] = { > &vcpu_sbi_ext_v01, > @@ -54,6 +56,8 @@ static const struct kvm_vcpu_sbi_extension *sbi_ext[] = { > &vcpu_sbi_ext_ipi, > &vcpu_sbi_ext_rfence, > &vcpu_sbi_ext_hsm, > + &vcpu_sbi_ext_experimental, > + &vcpu_sbi_ext_vendor, > }; > > void kvm_riscv_vcpu_sbi_forward(struct kvm_vcpu *vcpu, struct kvm_run *run) > diff --git a/arch/riscv/kvm/vcpu_sbi_base.c b/arch/riscv/kvm/vcpu_sbi_base.c > index 641015549d12..ac0537d479d8 100644 > --- a/arch/riscv/kvm/vcpu_sbi_base.c > +++ b/arch/riscv/kvm/vcpu_sbi_base.c > @@ -68,3 +68,30 @@ const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_base = { > .extid_end = SBI_EXT_BASE, > .handler = kvm_sbi_ext_base_handler, > }; > + > +static int kvm_sbi_ext_forward_handler(struct kvm_vcpu *vcpu, > + struct kvm_run *run, > + unsigned long *out_val, > + struct kvm_cpu_trap *utrap, > + bool *exit) > +{ > + /* > + * Both SBI experimental and vendor extensions are > + * unconditionally forwarded to userspace. > + */ > + kvm_riscv_vcpu_sbi_forward(vcpu, run); > + *exit = true; > + return 0; > +} > + > +const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_experimental = { > + .extid_start = SBI_EXT_EXPERIMENTAL_START, > + .extid_end = SBI_EXT_EXPERIMENTAL_END, > + .handler = kvm_sbi_ext_forward_handler, > +}; > + > +const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_vendor = { > + .extid_start = SBI_EXT_VENDOR_START, > + .extid_end = SBI_EXT_VENDOR_END, > + .handler = kvm_sbi_ext_forward_handler, > +}; > -- > 2.25.1 > Reviewed-by: Atish Patra <atishp@rivosinc.com> -- Regards, Atish
On Mon, Nov 29, 2021 at 12:10 AM Anup Patel <anup.patel@wdc.com> wrote: > > We add EXTRA_CFLAGS to the common CFLAGS of top-level Makefile > which will allow users to pass additional compile-time flags such > as "-static". > > Signed-off-by: Anup Patel <anup.patel@wdc.com> > --- > tools/testing/selftests/kvm/Makefile | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile > index c4e34717826a..ee6740e9ecdb 100644 > --- a/tools/testing/selftests/kvm/Makefile > +++ b/tools/testing/selftests/kvm/Makefile > @@ -131,7 +131,7 @@ endif > CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \ > -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \ > -I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \ > - -I$(<D) -Iinclude/$(UNAME_M) -I.. > + -I$(<D) -Iinclude/$(UNAME_M) -I.. $(EXTRA_CFLAGS) > > no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ > $(CC) -Werror -no-pie -x c - -o "$$TMP", -no-pie) > -- > 2.25.1 > Reviewed-by: Atish Patra <atishp@rivosinc.com> -- Regards, Atish
On Mon, Nov 29, 2021, Anup Patel wrote: > We add EXTRA_CFLAGS to the common CFLAGS of top-level Makefile Nit, wrap closer to 75 chars. > which will allow users to pass additional compile-time flags such > as "-static". In case there's any hesitation in applying this (Paolo asked if this was just for debugging in v1), being able to pass "-static" is helpful for our environment as our test systems have a funky and minimal configuration (no gcc, and the interpreter is in a weird location). Running selftests either requires building them with -static or creating a symbolic link for /lib64/ld-linux-x86-64.so.2. It's generally easier to just tell people to compile with -static. > Signed-off-by: Anup Patel <anup.patel@wdc.com> > --- Reviewed-and-tested-by: Sean Christopherson <seanjc@google.com>
On Tue, Dec 21, 2021 at 1:15 AM Sean Christopherson <seanjc@google.com> wrote: > > On Mon, Nov 29, 2021, Anup Patel wrote: > > We add EXTRA_CFLAGS to the common CFLAGS of top-level Makefile > > Nit, wrap closer to 75 chars. Okay, I will update. > > > which will allow users to pass additional compile-time flags such > > as "-static". > > In case there's any hesitation in applying this (Paolo asked if this was just for > debugging in v1), being able to pass "-static" is helpful for our environment as > our test systems have a funky and minimal configuration (no gcc, and the interpreter > is in a weird location). Running selftests either requires building them with > -static or creating a symbolic link for /lib64/ld-linux-x86-64.so.2. It's generally > easier to just tell people to compile with -static. > > > Signed-off-by: Anup Patel <anup.patel@wdc.com> > > --- > > Reviewed-and-tested-by: Sean Christopherson <seanjc@google.com> Thanks, I am planning to queue this for 5.17. Currently, I am waiting for some reviews on the PATCH4 (last patch). Regards, Anup
On Mon, Nov 29, 2021 at 12:10 AM Anup Patel <anup.patel@wdc.com> wrote: > > This series adds initial support for testing KVM RISC-V 64-bit using > kernel selftests framework. The PATCH1 & PATCH2 of this series does > some ground work in KVM RISC-V to implement RISC-V support in the KVM > selftests whereas remaining patches does required changes in the KVM > selftests. > > These patches can be found in riscv_kvm_selftests_v2 branch at: > https://github.com/avpatel/linux.git > > Changes since v1: > - Renamed kvm_sbi_ext_expevend_handler() to kvm_sbi_ext_forward_handler() > in PATCH1 > - Renamed KVM_CAP_RISCV_VM_GPA_SIZE to KVM_CAP_VM_GPA_BITS in PATCH2 > and PATCH4 > > Anup Patel (4): > RISC-V: KVM: Forward SBI experimental and vendor extensions > RISC-V: KVM: Add VM capability to allow userspace get GPA bits > KVM: selftests: Add EXTRA_CFLAGS in top-level Makefile > KVM: selftests: Add initial support for RISC-V 64-bit > > arch/riscv/include/asm/kvm_host.h | 1 + > arch/riscv/kvm/mmu.c | 5 + > arch/riscv/kvm/vcpu_sbi.c | 4 + > arch/riscv/kvm/vcpu_sbi_base.c | 27 ++ > arch/riscv/kvm/vm.c | 3 + > include/uapi/linux/kvm.h | 1 + > tools/testing/selftests/kvm/Makefile | 14 +- > .../testing/selftests/kvm/include/kvm_util.h | 10 + > .../selftests/kvm/include/riscv/processor.h | 135 +++++++ > tools/testing/selftests/kvm/lib/guest_modes.c | 10 + > .../selftests/kvm/lib/riscv/processor.c | 362 ++++++++++++++++++ > tools/testing/selftests/kvm/lib/riscv/ucall.c | 87 +++++ > 12 files changed, 658 insertions(+), 1 deletion(-) > create mode 100644 tools/testing/selftests/kvm/include/riscv/processor.h > create mode 100644 tools/testing/selftests/kvm/lib/riscv/processor.c > create mode 100644 tools/testing/selftests/kvm/lib/riscv/ucall.c > > -- > 2.25.1 > For the entire series, Tested-by: Atish Patra <atishp@rivosinc.com>