[PATCH 02/13] RISC-V: KVM: Don't treat SBI HFENCE calls as NOPs

Anup Patel posted 13 patches 6 months, 2 weeks ago
There is a newer version of this series
[PATCH 02/13] RISC-V: KVM: Don't treat SBI HFENCE calls as NOPs
Posted by Anup Patel 6 months, 2 weeks ago
The SBI specification clearly states that SBI HFENCE calls should
return SBI_ERR_NOT_SUPPORTED when one of the target hart doesn’t
support hypervisor extension (aka nested virtualization in-case
of KVM RISC-V).

Fixes: c7fa3c48de86 ("RISC-V: KVM: Treat SBI HFENCE calls as NOPs")
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 arch/riscv/kvm/vcpu_sbi_replace.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/kvm/vcpu_sbi_replace.c b/arch/riscv/kvm/vcpu_sbi_replace.c
index 9752d2ffff68..b17fad091bab 100644
--- a/arch/riscv/kvm/vcpu_sbi_replace.c
+++ b/arch/riscv/kvm/vcpu_sbi_replace.c
@@ -127,9 +127,9 @@ static int kvm_sbi_ext_rfence_handler(struct kvm_vcpu *vcpu, struct kvm_run *run
 	case SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID:
 		/*
 		 * Until nested virtualization is implemented, the
-		 * SBI HFENCE calls should be treated as NOPs
+		 * SBI HFENCE calls should return not supported
+		 * hence fallthrough.
 		 */
-		break;
 	default:
 		retdata->err_val = SBI_ERR_NOT_SUPPORTED;
 	}
-- 
2.43.0

Re: [PATCH 02/13] RISC-V: KVM: Don't treat SBI HFENCE calls as NOPs
Posted by Anup Patel 6 months, 1 week ago
On Thu, Jun 5, 2025 at 11:45 AM Anup Patel <apatel@ventanamicro.com> wrote:
>
> The SBI specification clearly states that SBI HFENCE calls should
> return SBI_ERR_NOT_SUPPORTED when one of the target hart doesn’t
> support hypervisor extension (aka nested virtualization in-case
> of KVM RISC-V).
>
> Fixes: c7fa3c48de86 ("RISC-V: KVM: Treat SBI HFENCE calls as NOPs")
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>

Queued as a fix for Linux-6.16

Regards,
Anup

> ---
>  arch/riscv/kvm/vcpu_sbi_replace.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/kvm/vcpu_sbi_replace.c b/arch/riscv/kvm/vcpu_sbi_replace.c
> index 9752d2ffff68..b17fad091bab 100644
> --- a/arch/riscv/kvm/vcpu_sbi_replace.c
> +++ b/arch/riscv/kvm/vcpu_sbi_replace.c
> @@ -127,9 +127,9 @@ static int kvm_sbi_ext_rfence_handler(struct kvm_vcpu *vcpu, struct kvm_run *run
>         case SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID:
>                 /*
>                  * Until nested virtualization is implemented, the
> -                * SBI HFENCE calls should be treated as NOPs
> +                * SBI HFENCE calls should return not supported
> +                * hence fallthrough.
>                  */
> -               break;
>         default:
>                 retdata->err_val = SBI_ERR_NOT_SUPPORTED;
>         }
> --
> 2.43.0
>
Re: [PATCH 02/13] RISC-V: KVM: Don't treat SBI HFENCE calls as NOPs
Posted by Atish Patra 6 months, 2 weeks ago
On 6/4/25 11:14 PM, Anup Patel wrote:
> The SBI specification clearly states that SBI HFENCE calls should
> return SBI_ERR_NOT_SUPPORTED when one of the target hart doesn’t
> support hypervisor extension (aka nested virtualization in-case
> of KVM RISC-V).
>
> Fixes: c7fa3c48de86 ("RISC-V: KVM: Treat SBI HFENCE calls as NOPs")
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> ---
>   arch/riscv/kvm/vcpu_sbi_replace.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/kvm/vcpu_sbi_replace.c b/arch/riscv/kvm/vcpu_sbi_replace.c
> index 9752d2ffff68..b17fad091bab 100644
> --- a/arch/riscv/kvm/vcpu_sbi_replace.c
> +++ b/arch/riscv/kvm/vcpu_sbi_replace.c
> @@ -127,9 +127,9 @@ static int kvm_sbi_ext_rfence_handler(struct kvm_vcpu *vcpu, struct kvm_run *run
>   	case SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID:
>   		/*
>   		 * Until nested virtualization is implemented, the
> -		 * SBI HFENCE calls should be treated as NOPs
> +		 * SBI HFENCE calls should return not supported
> +		 * hence fallthrough.
>   		 */
> -		break;
>   	default:
>   		retdata->err_val = SBI_ERR_NOT_SUPPORTED;
>   	}

Reviewed-by: Atish Patra <atishp@rivosinc.com>