Skip to contentSkip to conversation

riscv: KVM: Remove unnecessary vcpu kick

PATCH Applied BillXiang 5 participants 5 messages Feb 21, 2025 – Mar 27, 2025

Subsystems (3)
lore
Share & tools
lore

BillXiang

author
#0 lore raw

PATCH v2 1/1 riscv: KVM: Remove unnecessary vcpu kick

Remove the unnecessary kick to the vCPU after writing to the vs_file of IMSIC in kvm_riscv_vcpu_aia_imsic_inject.

For vCPUs that are running, writing to the vs_file directly forwards the interrupt as an MSI to them and does not need an extra kick.

For vCPUs that are descheduled after emulating WFI, KVM will enable the guest external interrupt for that vCPU in kvm_riscv_aia_wakeon_hgei. This means that writing to the vs_file will cause a guest external interrupt, which will cause KVM to wake up the vCPU in hgei_interrupt to handle the interrupt properly.

---
v2: Revise the commit message to ensure it meets the required
standards for acceptance

 arch/riscv/kvm/aia_imsic.c | 1 -
 1 file changed, 1 deletion(-)
arch/riscv/kvm/aia_imsic.c +0 -1
index a8085cd8215e..29ef9c2133a9 100644
@@ -974,7 +974,6 @@ int kvm_riscv_vcpu_aia_imsic_inject(struct kvm_vcpu *vcpu,
 
 	if (imsic->vsfile_cpu >= 0) {
 		writel(iid, imsic->vsfile_va + IMSIC_MMIO_SETIPNUM_LE);
-		kvm_vcpu_kick(vcpu);
 	} else {
 		eix = &imsic->swfile->eix[iid / BITS_PER_TYPE(u64)];
 		set_bit(iid & (BITS_PER_TYPE(u64) - 1), eix->eip);
Signature · 1 line
2.46.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 34 lines · BillXiang

Remove the unnecessary kick to the vCPU after writing to the vs_file of IMSIC in kvm_riscv_vcpu_aia_imsic_inject.

For vCPUs that are running, writing to the vs_file directly forwards the interrupt as an MSI to them and does not need an extra kick.

For vCPUs that are descheduled after emulating WFI, KVM will enable the guest external interrupt for that vCPU in kvm_riscv_aia_wakeon_hgei. This means that writing to the vs_file will cause a guest external interrupt, which will cause KVM to wake up the vCPU in hgei_interrupt to handle the interrupt properly.

---
v2: Revise the commit message to ensure it meets the required
standards for acceptance

 arch/riscv/kvm/aia_imsic.c | 1 -
 1 file changed, 1 deletion(-)
arch/riscv/kvm/aia_imsic.c +0 -1
index a8085cd8215e..29ef9c2133a9 100644
@@ -974,7 +974,6 @@ int kvm_riscv_vcpu_aia_imsic_inject(struct kvm_vcpu *vcpu,
 
 	if (imsic->vsfile_cpu >= 0) {
 		writel(iid, imsic->vsfile_va + IMSIC_MMIO_SETIPNUM_LE);
-		kvm_vcpu_kick(vcpu);
 	} else {
 		eix = &imsic->swfile->eix[iid / BITS_PER_TYPE(u64)];
 		set_bit(iid & (BITS_PER_TYPE(u64) - 1), eix->eip);
Signature · 1 line
2.46.2
Reviewed-by on v2 1/1
#2 lore raw
In reply to BillXiang
2025-02-21T18:45:38+08:00, BillXiang <[email protected]>:
Quoted 12 lines

Remove the unnecessary kick to the vCPU after writing to the vs_file of IMSIC in kvm_riscv_vcpu_aia_imsic_inject.

For vCPUs that are running, writing to the vs_file directly forwards the interrupt as an MSI to them and does not need an extra kick.

For vCPUs that are descheduled after emulating WFI, KVM will enable the guest external interrupt for that vCPU in kvm_riscv_aia_wakeon_hgei. This means that writing to the vs_file will cause a guest external interrupt, which will cause KVM to wake up the vCPU in hgei_interrupt to handle the interrupt properly.

Quoted 4 lines

---
v2: Revise the commit message to ensure it meets the required
standards for acceptance

Nice, thanks.

maintainer
#3 lore raw
In reply to BillXiang
Quoted 7 lines · BillXiang

Remove the unnecessary kick to the vCPU after writing to the vs_file of IMSIC in kvm_riscv_vcpu_aia_imsic_inject.

For vCPUs that are running, writing to the vs_file directly forwards the interrupt as an MSI to them and does not need an extra kick.

Quoted 7 lines

For vCPUs that are descheduled after emulating WFI, KVM will enable the guest external interrupt for that vCPU in kvm_riscv_aia_wakeon_hgei. This means that writing to the vs_file will cause a guest external interrupt, which will cause KVM to wake up the vCPU in hgei_interrupt to handle the interrupt properly.

Queued this patch as a fix for Linux-6.14-rcX.

Thanks,
Anup

Quoted 21 lines

---
v2: Revise the commit message to ensure it meets the required
standards for acceptance

 arch/riscv/kvm/aia_imsic.c | 1 -
 1 file changed, 1 deletion(-)
arch/riscv/kvm/aia_imsic.c +0 -2
index a8085cd8215e..29ef9c2133a9 100644
@@ -974,7 +974,6 @@ int kvm_riscv_vcpu_aia_imsic_inject(struct kvm_vcpu *vcpu,
 
        if (imsic->vsfile_cpu >= 0) {
                writel(iid, imsic->vsfile_va + IMSIC_MMIO_SETIPNUM_LE);
-               kvm_vcpu_kick(vcpu);
        } else {
                eix = &imsic->swfile->eix[iid / BITS_PER_TYPE(u64)];
                set_bit(iid & (BITS_PER_TYPE(u64) - 1), eix->eip);
--

2.46.2

#4 lore raw
In reply to BillXiang
This patch was applied to riscv/linux.git (for-next) by Anup Patel <[email protected]>:

Hello:

This patch was applied to riscv/linux.git (for-next) by Anup Patel <[email protected]>:

Quoted 6 lines · On Fri, 21 Feb 2025 18:45:38 +0800 you wrote:

Remove the unnecessary kick to the vCPU after writing to the vs_file of IMSIC in kvm_riscv_vcpu_aia_imsic_inject.

For vCPUs that are running, writing to the vs_file directly forwards the interrupt as an MSI to them and does not need an extra kick.

Quoted 7 lines

For vCPUs that are descheduled after emulating WFI, KVM will enable the guest external interrupt for that vCPU in kvm_riscv_aia_wakeon_hgei. This means that writing to the vs_file will cause a guest external interrupt, which will cause KVM to wake up the vCPU in hgei_interrupt to handle the interrupt properly.

[...]

Here is the summary with links:
- [v2] riscv: KVM: Remove unnecessary vcpu kick

    https://git.kernel.org/riscv/c/d252435aca44

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html