From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH] KVM: x86: handle KVM_SET_VCPU_EVENTS/KVM_VCPUEVENT_VALID_SMM properly Date: Mon, 10 Oct 2016 14:48:44 +0200 Message-ID: <20161010124844.GA27786@potion> References: <1474606751-17100-1-git-send-email-herongguang.he@huawei.com> <57F868AF.7030806@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: pbonzini@redhat.com, kvm@vger.kernel.org, quintela@redhat.com, amit.shah@redhat.com, qemu-devel@nongnu.org, arei.gonglei@huawei.com, weidong.huang@huawei.com To: "Herongguang (Stephen)" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:60730 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751783AbcJJMss (ORCPT ); Mon, 10 Oct 2016 08:48:48 -0400 Content-Disposition: inline In-Reply-To: <57F868AF.7030806@huawei.com> Sender: kvm-owner@vger.kernel.org List-ID: 2016-10-08 11:31+0800, Herongguang (Stephen): > On 2016/9/23 12:59, herongguang wrote: >> From: He Rongguang >> >> handle KVM_VCPUEVENT_VALID_SMM properly, or kvm-kmod/kernel will crash >> in migration destination in gfn_to_rmap() since kvm_memslots_for_spte_role >> is false, whilst (vcpu->arch.hflags & HF_SMM_MASK) is true >> >> Signed-off-by: herongguang >> --- >> arch/x86/kvm/x86.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >> index 699f872..7ebcb59 100644 >> --- a/arch/x86/kvm/x86.c >> +++ b/arch/x86/kvm/x86.c >> @@ -3028,6 +3028,7 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu, >> else >> clear_bit(KVM_APIC_INIT, &vcpu->arch.apic->pending_events); >> } >> + kvm_mmu_reset_context(vcpu); >> } >> >> kvm_make_request(KVM_REQ_EVENT, vcpu); >> > > Hi, do you think this is OK for linux 4.9? Thanks for the notification. I think it would be better to use kvm_smm_changed(). Calling kvm_mmu_reset_context() only when SMM mode changed also seems beneficial, which is already done in kvm_set_hflags(). It is a fix and can go into later 4.9 release candidates, in case we miss the first one. From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bta0k-0005xK-Qm for qemu-devel@nongnu.org; Mon, 10 Oct 2016 08:48:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bta0f-0004tp-SX for qemu-devel@nongnu.org; Mon, 10 Oct 2016 08:48:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36876) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bta0f-0004tQ-MP for qemu-devel@nongnu.org; Mon, 10 Oct 2016 08:48:49 -0400 Date: Mon, 10 Oct 2016 14:48:44 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Message-ID: <20161010124844.GA27786@potion> References: <1474606751-17100-1-git-send-email-herongguang.he@huawei.com> <57F868AF.7030806@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <57F868AF.7030806@huawei.com> Subject: Re: [Qemu-devel] [PATCH] KVM: x86: handle KVM_SET_VCPU_EVENTS/KVM_VCPUEVENT_VALID_SMM properly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Herongguang (Stephen)" Cc: pbonzini@redhat.com, kvm@vger.kernel.org, quintela@redhat.com, amit.shah@redhat.com, qemu-devel@nongnu.org, arei.gonglei@huawei.com, weidong.huang@huawei.com 2016-10-08 11:31+0800, Herongguang (Stephen): > On 2016/9/23 12:59, herongguang wrote: >> From: He Rongguang >> >> handle KVM_VCPUEVENT_VALID_SMM properly, or kvm-kmod/kernel will crash >> in migration destination in gfn_to_rmap() since kvm_memslots_for_spte_role >> is false, whilst (vcpu->arch.hflags & HF_SMM_MASK) is true >> >> Signed-off-by: herongguang >> --- >> arch/x86/kvm/x86.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >> index 699f872..7ebcb59 100644 >> --- a/arch/x86/kvm/x86.c >> +++ b/arch/x86/kvm/x86.c >> @@ -3028,6 +3028,7 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu, >> else >> clear_bit(KVM_APIC_INIT, &vcpu->arch.apic->pending_events); >> } >> + kvm_mmu_reset_context(vcpu); >> } >> >> kvm_make_request(KVM_REQ_EVENT, vcpu); >> > > Hi, do you think this is OK for linux 4.9? Thanks for the notification. I think it would be better to use kvm_smm_changed(). Calling kvm_mmu_reset_context() only when SMM mode changed also seems beneficial, which is already done in kvm_set_hflags(). It is a fix and can go into later 4.9 release candidates, in case we miss the first one.