From cbd165f529bd32b586342c0a2d11c3ca50b9fdd3 Mon Sep 17 00:00:00 2001 From: Jinqian Yang Date: Thu, 20 Nov 2025 16:45:16 +0800 Subject: [PATCH 1/2] KVM: arm64: ipiv: Change parameter from vcpu to kvm virt inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID7MBH ------------------------------------------------------------------------ IPIV is a per-VM feature. When checking whether IPIV is supported, it is more appropriate to use kvm as the input parameter. Fixes: cd77c03a1ee1 ("KVM: arm64: Implement PV_SGI related calls") Signed-off-by: Jinqian Yang --- arch/arm64/kvm/hisilicon/hisi_virt.c | 10 +++++----- arch/arm64/kvm/hisilicon/hisi_virt.h | 4 ++-- arch/arm64/kvm/hypercalls.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kvm/hisilicon/hisi_virt.c b/arch/arm64/kvm/hisilicon/hisi_virt.c index cf22f247f00f..5731d337b228 100644 --- a/arch/arm64/kvm/hisilicon/hisi_virt.c +++ b/arch/arm64/kvm/hisilicon/hisi_virt.c @@ -201,27 +201,27 @@ bool hisi_ipiv_supported(void) extern struct static_key_false ipiv_enable; -bool hisi_ipiv_supported_per_vm(struct kvm_vcpu *vcpu) +bool hisi_ipiv_supported_per_vm(struct kvm *kvm) { /* IPIV is supported by the hardware */ if (!static_branch_unlikely(&ipiv_enable)) return false; /* vSGI passthrough is configured */ - if (!vcpu->kvm->arch.vgic.nassgireq) + if (!kvm->arch.vgic.nassgireq) return false; /* IPIV is enabled by the user */ - if (!vcpu->kvm->arch.vgic.its_vm.enable_ipiv_from_vmm) + if (!kvm->arch.vgic.its_vm.enable_ipiv_from_vmm) return false; return true; } -void hisi_ipiv_enable_per_vm(struct kvm_vcpu *vcpu) +void hisi_ipiv_enable_per_vm(struct kvm *kvm) { /* Enable IPIV feature */ - vcpu->kvm->arch.vgic.its_vm.enable_ipiv_from_guest = true; + kvm->arch.vgic.its_vm.enable_ipiv_from_guest = true; } void ipiv_gicd_init(void) diff --git a/arch/arm64/kvm/hisilicon/hisi_virt.h b/arch/arm64/kvm/hisilicon/hisi_virt.h index 74f469a1c2f6..fcf65cec942e 100644 --- a/arch/arm64/kvm/hisilicon/hisi_virt.h +++ b/arch/arm64/kvm/hisilicon/hisi_virt.h @@ -96,8 +96,8 @@ bool hisi_ncsnp_supported(void); bool hisi_dvmbm_supported(void); #ifdef CONFIG_ARM64_HISI_IPIV bool hisi_ipiv_supported(void); -bool hisi_ipiv_supported_per_vm(struct kvm_vcpu *vcpu); -void hisi_ipiv_enable_per_vm(struct kvm_vcpu *vcpu); +bool hisi_ipiv_supported_per_vm(struct kvm *kvm); +void hisi_ipiv_enable_per_vm(struct kvm *kvm); void ipiv_gicd_init(void); #endif /* CONFIG_ARM64_HISI_IPIV */ void kvm_get_pg_cfg(void); diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c index 3e17e4620895..e71fed7f7135 100644 --- a/arch/arm64/kvm/hypercalls.c +++ b/arch/arm64/kvm/hypercalls.c @@ -377,14 +377,14 @@ int kvm_smccc_call_handler(struct kvm_vcpu *vcpu) #endif /* CONFIG_PARAVIRT_SCHED */ #ifdef CONFIG_ARM64_HISI_IPIV case ARM_SMCCC_VENDOR_PV_SGI_FEATURES: - if (hisi_ipiv_supported_per_vm(vcpu)) + if (hisi_ipiv_supported_per_vm(vcpu->kvm)) val[0] = SMCCC_RET_SUCCESS; else val[0] = SMCCC_RET_NOT_SUPPORTED; break; case ARM_SMCCC_VENDOR_PV_SGI_ENABLE: - if (hisi_ipiv_supported_per_vm(vcpu)) { - hisi_ipiv_enable_per_vm(vcpu); + if (hisi_ipiv_supported_per_vm(vcpu->kvm)) { + hisi_ipiv_enable_per_vm(vcpu->kvm); val[0] = SMCCC_RET_SUCCESS; } else { val[0] = SMCCC_RET_NOT_SUPPORTED; -- Gitee From 22f1e3b38ca09cbc655a606e6404b996710841a1 Mon Sep 17 00:00:00 2001 From: Jinqian Yang Date: Thu, 20 Nov 2025 16:45:17 +0800 Subject: [PATCH 2/2] KVM: arm64: ipiv: fix bug in live migration virt inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID7MBH ------------------------------------------------------------------------ If an environment has IPIV enabled and a VM also has IPIV enabled, when this VM is migrated to a host environment where IPIV is not enabled, the host will continuously print "vSGI trap! IPIV disabled!" This is because the destination host enabled the VM's IPIV without checking for IPIV support. Fixes: b599aaac9ec7 ("KVM: arm64: fix live migration bug of IPIv") Signed-off-by: Jinqian Yang --- arch/arm64/kvm/vgic/vgic-its.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c index f888b099cefc..fdeb22083196 100644 --- a/arch/arm64/kvm/vgic/vgic-its.c +++ b/arch/arm64/kvm/vgic/vgic-its.c @@ -22,6 +22,7 @@ #include "vgic.h" #include "vgic-mmio.h" +#include "hisilicon/hisi_virt.h" static int vgic_its_save_tables_v0(struct vgic_its *its); static int vgic_its_restore_tables_v0(struct vgic_its *its); @@ -563,7 +564,8 @@ static int vgic_mmio_uaccess_write_its_iidr(struct kvm *kvm, return -EINVAL; #ifdef CONFIG_ARM64_HISI_IPIV - if (val & (1UL << HISI_GUEST_ENABLE_IPIV_SHIFT)) + if (hisi_ipiv_supported_per_vm(kvm) && + val & (1UL << HISI_GUEST_ENABLE_IPIV_SHIFT)) kvm->arch.vgic.its_vm.enable_ipiv_from_guest = true; #endif -- Gitee