Re: [Qemu-devel] [RFC/PATCH 2] kvm: x86: handle KVM_SET_VCPU_EVENTS/KVM_VCPUEVENT_VALID_SMM properly

2016-09-22 Thread Herongguang (Stephen)



On 2016/9/22 17:29, Paolo Bonzini wrote:



On 22/09/2016 09:51, Herongguang (Stephen) wrote:

After making memory consistent between source and destination
(https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg03069.html),
there can
still reproduce instruction emulation failure in destination side if
migration when VM’s in grub stage:


Hi!  Did you follow up on that patch, by the way?

Yes, I have some concern, see that post.




So I think there is some lacking in kvm-kmod’s
kvm_vcpu_ioctl_x86_set_vcpu_events that handles KVM_VCPUEVENT_VALID_SMM.
I tried following patch,
it seems works fine.

Do you think this patch is appropriate or not enough? Thanks.


Yes.  I would just call kvm_mmu_reset_context unconditionally at the end
of kvm_vcpu_iocyl_x86_set_x86_vcpu_events.  Please send this patch as
non-RFC.

Patch 3 is also okay, please send it separately.

Ok, I will test and post it tomorrow, thanks!



Thanks,

Paolo


diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 19f9f9e..f39e839 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3013,8 +3013,10 @@ static int
kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
 vcpu->arch.apic->sipi_vector = events->sipi_vector;

 if (events->flags & KVM_VCPUEVENT_VALID_SMM) {
-   if (events->smi.smm)
+   if (events->smi.smm) {
 vcpu->arch.hflags |= HF_SMM_MASK;
+   kvm_mmu_reset_context(vcpu);
+   }
 else
 vcpu->arch.hflags &= ~HF_SMM_MASK;
 vcpu->arch.smi_pending = events->smi.pending;




.






Re: [Qemu-devel] [RFC/PATCH 2] kvm: x86: handle KVM_SET_VCPU_EVENTS/KVM_VCPUEVENT_VALID_SMM properly

2016-09-22 Thread Paolo Bonzini


On 22/09/2016 09:51, Herongguang (Stephen) wrote:
> After making memory consistent between source and destination
> (https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg03069.html),
> there can
> still reproduce instruction emulation failure in destination side if
> migration when VM’s in grub stage:

Hi!  Did you follow up on that patch, by the way?

> So I think there is some lacking in kvm-kmod’s
> kvm_vcpu_ioctl_x86_set_vcpu_events that handles KVM_VCPUEVENT_VALID_SMM.
> I tried following patch,
> it seems works fine.
> 
> Do you think this patch is appropriate or not enough? Thanks.

Yes.  I would just call kvm_mmu_reset_context unconditionally at the end
of kvm_vcpu_iocyl_x86_set_x86_vcpu_events.  Please send this patch as
non-RFC.

Patch 3 is also okay, please send it separately.

Thanks,

Paolo

> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 19f9f9e..f39e839 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3013,8 +3013,10 @@ static int
> kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
> vcpu->arch.apic->sipi_vector = events->sipi_vector;
> 
> if (events->flags & KVM_VCPUEVENT_VALID_SMM) {
> -   if (events->smi.smm)
> +   if (events->smi.smm) {
> vcpu->arch.hflags |= HF_SMM_MASK;
> +   kvm_mmu_reset_context(vcpu);
> +   }
> else
> vcpu->arch.hflags &= ~HF_SMM_MASK;
> vcpu->arch.smi_pending = events->smi.pending;
> 
>