Svinval support for KVM RISC-V
Subsystems (3)
cover Svinval support for KVM RISC-V
This series adds Svinval extension support for both Host hypervisor and Guest.
These patches can also be found in riscv_kvm_svinval_v1 branch at:
https://github.com/avpatel/linux.git
The corresponding KVMTOOL patches are available in riscv_svinval_v1 branch at: https://github.com/avpatel/kvmtool.git
Anup Patel (2):
RISC-V: KVM: Use Svinval for local TLB maintenance when available
RISC-V: KVM: Allow Guest use Svinval extension
Mayuresh Chitale (1):
RISC-V: Probe Svinval extension form ISA string
arch/riscv/include/asm/hwcap.h | 4 +++ arch/riscv/include/asm/insn-def.h | 20 +++++++++++ arch/riscv/include/uapi/asm/kvm.h | 1 + arch/riscv/kernel/cpu.c | 1 + arch/riscv/kernel/cpufeature.c | 1 + arch/riscv/kvm/tlb.c | 60 ++++++++++++++++++++++++------- arch/riscv/kvm/vcpu.c | 2 ++ 7 files changed, 77 insertions(+), 12 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/3 RISC-V: Probe Svinval extension form ISA string
From: Mayuresh Chitale <[email protected]>
Just like other ISA extensions, we allow callers/users to detect the presence of Svinval extension from ISA string.
--- arch/riscv/include/asm/hwcap.h | 4 ++++ arch/riscv/kernel/cpu.c | 1 + arch/riscv/kernel/cpufeature.c | 1 + 3 files changed, 6 insertions(+)
arch/riscv/include/asm/hwcap.h +4 -0
@@ -58,6 +58,7 @@ enum riscv_isa_ext_id {RISCV_ISA_EXT_ZICBOM ,RISCV_ISA_EXT_ZIHINTPAUSE ,RISCV_ISA_EXT_SSTC , +RISCV_ISA_EXT_SVINVAL , RISCV_ISA_EXT_ID_MAX = RISCV_ISA_EXT_MAX, };
@@ -69,6 +70,7 @@ enum riscv_isa_ext_id {enum riscv_isa_ext_key {RISCV_ISA_EXT_KEY_FPU ,/* For 'F' and 'D' */ RISCV_ISA_EXT_KEY_ZIHINTPAUSE , +RISCV_ISA_EXT_KEY_SVINVAL ,RISCV_ISA_EXT_KEY_MAX , };
@@ -90,6 +92,8 @@ static __always_inline int riscv_isa_ext2key(int num)return RISCV_ISA_EXT_KEY_FPU ;case RISCV_ISA_EXT_ZIHINTPAUSE :return RISCV_ISA_EXT_KEY_ZIHINTPAUSE ; +case RISCV_ISA_EXT_SVINVAL : +return RISCV_ISA_EXT_KEY_SVINVAL ;default :return -EINVAL ; }
arch/riscv/kernel/cpu.c +1 -0
@@ -96,6 +96,7 @@ static struct riscv_isa_ext_data isa_ext_arr[] = {__RISCV_ISA_EXT_DATA (zicbom,RISCV_ISA_EXT_ZICBOM ),__RISCV_ISA_EXT_DATA (zihintpause,RISCV_ISA_EXT_ZIHINTPAUSE ),__RISCV_ISA_EXT_DATA (sstc,RISCV_ISA_EXT_SSTC ), +__RISCV_ISA_EXT_DATA (svinval,RISCV_ISA_EXT_SVINVAL ), __RISCV_ISA_EXT_DATA("", RISCV_ISA_EXT_MAX), };
arch/riscv/kernel/cpufeature.c +1 -0
@@ -204,6 +204,7 @@ void __init riscv_fill_hwcap(void)SET_ISA_EXT_MAP ("zicbom" ,RISCV_ISA_EXT_ZICBOM );SET_ISA_EXT_MAP ("zihintpause" ,RISCV_ISA_EXT_ZIHINTPAUSE );SET_ISA_EXT_MAP ("sstc" ,RISCV_ISA_EXT_SSTC ); +SET_ISA_EXT_MAP ("svinval" ,RISCV_ISA_EXT_SVINVAL ); }#undef SET_ISA_EXT_MAP }
Signature · 1 line
2.34.1
PATCH 2/3 RISC-V: KVM: Use Svinval for local TLB maintenance when available
In reply to Anup PatelWe should prefer HINVAL.GVMA and HINVAL.VVMA instruction for local TLB maintenance when underlying host supports Svinval extension.
--- arch/riscv/include/asm/insn-def.h | 20 +++++++++++ arch/riscv/kvm/tlb.c | 60 ++++++++++++++++++++++++------- 2 files changed, 68 insertions(+), 12 deletions(-)
arch/riscv/include/asm/insn-def.h +20 -0
@@ -110,4 +110,24 @@ __ASM_STR(.error "hlv.d requires 64-bit support")#endif +#define SINVAL_VMA (vaddr, asid) \ + INSN_R(OPCODE_SYSTEM, FUNC3(0), FUNC7(11), \ + __RD(0), RS1(vaddr), RS2(asid)) + +#define SFENCE_W_INVAL () \ + INSN_R(OPCODE_SYSTEM, FUNC3(0), FUNC7(12), \ + __RD(0), __RS1(0), __RS2(0)) + +#define SFENCE_INVAL_IR () \ + INSN_R(OPCODE_SYSTEM, FUNC3(0), FUNC7(12), \ + __RD(0), __RS1(0), __RS2(1)) + +#define HINVAL_VVMA (vaddr, asid) \ + INSN_R(OPCODE_SYSTEM, FUNC3(0), FUNC7(19), \ + __RD(0), RS1(vaddr), RS2(asid)) + +#define HINVAL_GVMA (gaddr, vmid) \ + INSN_R(OPCODE_SYSTEM, FUNC3(0), FUNC7(51), \ + __RD(0), RS1(gaddr), RS2(vmid)) +#endif /* __ASM_INSN_DEF_H */
arch/riscv/kvm/tlb.c +48 -12
92 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 3/3 RISC-V: KVM: Allow Guest use Svinval extension
In reply to Anup PatelWe should advertise Svinval ISA extension to KVM user-space whenever host supports it. This will allow KVM user-space (i.e. QEMU or KVMTOOL) to pass on this information to Guest via ISA string.
--- arch/riscv/include/uapi/asm/kvm.h | 1 + arch/riscv/kvm/vcpu.c | 2 ++ 2 files changed, 3 insertions(+)
arch/riscv/include/uapi/asm/kvm.h +1 -0
@@ -98,6 +98,7 @@ enum KVM_RISCV_ISA_EXT_ID {KVM_RISCV_ISA_EXT_M ,KVM_RISCV_ISA_EXT_SVPBMT ,KVM_RISCV_ISA_EXT_SSTC , +KVM_RISCV_ISA_EXT_SVINVAL , KVM_RISCV_ISA_EXT_MAX, };
arch/riscv/kvm/vcpu.c +2 -0
@@ -53,6 +53,7 @@ static const unsigned long kvm_isa_ext_arr[] = { RISCV_ISA_EXT_m,RISCV_ISA_EXT_SVPBMT ,RISCV_ISA_EXT_SSTC , + RISCV_ISA_EXT_SVINVAL, };static unsigned long kvm_riscv_vcpu_base2isa_ext (unsigned long base_ext)
@@ -87,6 +88,7 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned long ext)case KVM_RISCV_ISA_EXT_I :case KVM_RISCV_ISA_EXT_M :case KVM_RISCV_ISA_EXT_SSTC : +case KVM_RISCV_ISA_EXT_SVINVAL :return false;default :break ;
Signature · 1 line
2.34.1
Quoted 16 lines · Anup Patel
This series adds Svinval extension support for both Host hypervisor and Guest.
These patches can also be found in
riscv_kvm_svinval_v1branch at:
https://github.com/avpatel/linux.gitThe corresponding KVMTOOL patches are available in
riscv_svinval_v1branch at: https://github.com/avpatel/kvmtool.gitAnup Patel (2):
RISC-V: KVM: Use Svinval for local TLB maintenance when available
RISC-V: KVM: Allow Guest use Svinval extensionMayuresh Chitale (1):
RISC-V: Probe Svinval extension form ISA string
Quoted 11 lines
arch/riscv/include/asm/hwcap.h | 4 +++ arch/riscv/include/asm/insn-def.h | 20 +++++++++++ arch/riscv/include/uapi/asm/kvm.h | 1 + arch/riscv/kernel/cpu.c | 1 + arch/riscv/kernel/cpufeature.c | 1 + arch/riscv/kvm/tlb.c | 60 ++++++++++++++++++++++++------- arch/riscv/kvm/vcpu.c | 2 ++ 7 files changed, 77 insertions(+), 12 deletions(-)Signature · 1 line
2.34.1
For the series,
Anup Patel
maintainerQuoted 10 lines · Anup Patel
This series adds Svinval extension support for both Host hypervisor and Guest.
These patches can also be found in
riscv_kvm_svinval_v1branch at:
https://github.com/avpatel/linux.gitThe corresponding KVMTOOL patches are available in
riscv_svinval_v1branch at: https://github.com/avpatel/kvmtool.git
Quoted 6 lines
Anup Patel (2):
RISC-V: KVM: Use Svinval for local TLB maintenance when available
RISC-V: KVM: Allow Guest use Svinval extensionMayuresh Chitale (1):
RISC-V: Probe Svinval extension form ISA string
I have queued this series for 6.1
Thanks,
Anup
Quoted 13 lines
arch/riscv/include/asm/hwcap.h | 4 +++ arch/riscv/include/asm/insn-def.h | 20 +++++++++++ arch/riscv/include/uapi/asm/kvm.h | 1 + arch/riscv/kernel/cpu.c | 1 + arch/riscv/kernel/cpufeature.c | 1 + arch/riscv/kvm/tlb.c | 60 ++++++++++++++++++++++++------- arch/riscv/kvm/vcpu.c | 2 ++ 7 files changed, 77 insertions(+), 12 deletions(-)--
2.34.1