[PATCH OLK-6.6 0/2] IPIV: fix bug in live migration
Patch#1: Change parameter from vcpu to kvm. IPIV is a per-VM feature. When checking whether IPIV is supported, it is more appropriate to use kvm as the input parameter. This change is also in preparation for the Patch#2 Patch#2: fix bug in live migration. 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. Jinqian Yang (2): KVM: arm64: ipiv: Change parameter from vcpu to kvm KVM: arm64: ipiv: fix bug in live migration arch/arm64/kvm/hisilicon/hisi_virt.c | 10 +++++----- arch/arm64/kvm/hisilicon/hisi_virt.h | 4 ++-- arch/arm64/kvm/hypercalls.c | 6 +++--- arch/arm64/kvm/vgic/vgic-its.c | 4 +++- 4 files changed, 13 insertions(+), 11 deletions(-) -- 2.33.0
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 <yangjinqian1@huawei.com> --- 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; -- 2.33.0
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 <yangjinqian1@huawei.com> --- 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 -- 2.33.0
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/19132 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/N5R... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/19132 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/N5R...
participants (2)
-
Jinqian Yang -
patchwork bot