All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: handle KVM_SET_VCPU_EVENTS/KVM_VCPUEVENT_VALID_SMM properly
@ 2016-09-23  4:59 ` herongguang
  0 siblings, 0 replies; 6+ messages in thread
From: herongguang @ 2016-09-23  4:59 UTC (permalink / raw)
  To: herongguang.he, pbonzini, quintela, amit.shah, rkrcmar, kvm
  Cc: qemu-devel, arei.gonglei, weidong.huang

From: He Rongguang <herongguang.he@huawei.com>

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 <herongguang.he@huawei.com>
---
 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);
-- 
1.8.3.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH] KVM: x86: handle KVM_SET_VCPU_EVENTS/KVM_VCPUEVENT_VALID_SMM properly
@ 2016-09-23  4:59 ` herongguang
  0 siblings, 0 replies; 6+ messages in thread
From: herongguang @ 2016-09-23  4:59 UTC (permalink / raw)
  To: herongguang.he, pbonzini, quintela, amit.shah, rkrcmar, kvm
  Cc: qemu-devel, arei.gonglei, weidong.huang

From: He Rongguang <herongguang.he@huawei.com>

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 <herongguang.he@huawei.com>
---
 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);
-- 
1.8.3.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: x86: handle KVM_SET_VCPU_EVENTS/KVM_VCPUEVENT_VALID_SMM properly
  2016-09-23  4:59 ` [Qemu-devel] " herongguang
@ 2016-10-08  3:31   ` Herongguang (Stephen)
  -1 siblings, 0 replies; 6+ messages in thread
From: Herongguang (Stephen) @ 2016-10-08  3:31 UTC (permalink / raw)
  To: pbonzini, rkrcmar, kvm
  Cc: quintela, amit.shah, qemu-devel, arei.gonglei, weidong.huang



On 2016/9/23 12:59, herongguang wrote:
> From: He Rongguang <herongguang.he@huawei.com>
>
> 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 <herongguang.he@huawei.com>
> ---
>   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?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] KVM: x86: handle KVM_SET_VCPU_EVENTS/KVM_VCPUEVENT_VALID_SMM properly
@ 2016-10-08  3:31   ` Herongguang (Stephen)
  0 siblings, 0 replies; 6+ messages in thread
From: Herongguang (Stephen) @ 2016-10-08  3:31 UTC (permalink / raw)
  To: pbonzini, rkrcmar, kvm
  Cc: quintela, amit.shah, qemu-devel, arei.gonglei, weidong.huang



On 2016/9/23 12:59, herongguang wrote:
> From: He Rongguang <herongguang.he@huawei.com>
>
> 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 <herongguang.he@huawei.com>
> ---
>   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?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: x86: handle KVM_SET_VCPU_EVENTS/KVM_VCPUEVENT_VALID_SMM properly
  2016-10-08  3:31   ` [Qemu-devel] " Herongguang (Stephen)
@ 2016-10-10 12:48     ` Radim Krčmář
  -1 siblings, 0 replies; 6+ messages in thread
From: Radim Krčmář @ 2016-10-10 12:48 UTC (permalink / raw)
  To: Herongguang (Stephen)
  Cc: pbonzini, kvm, quintela, amit.shah, qemu-devel, arei.gonglei,
	weidong.huang

2016-10-08 11:31+0800, Herongguang (Stephen):
> On 2016/9/23 12:59, herongguang wrote:
>> From: He Rongguang <herongguang.he@huawei.com>
>> 
>> 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 <herongguang.he@huawei.com>
>> ---
>>   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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] KVM: x86: handle KVM_SET_VCPU_EVENTS/KVM_VCPUEVENT_VALID_SMM properly
@ 2016-10-10 12:48     ` Radim Krčmář
  0 siblings, 0 replies; 6+ messages in thread
From: Radim Krčmář @ 2016-10-10 12:48 UTC (permalink / raw)
  To: Herongguang (Stephen)
  Cc: pbonzini, kvm, quintela, amit.shah, qemu-devel, arei.gonglei,
	weidong.huang

2016-10-08 11:31+0800, Herongguang (Stephen):
> On 2016/9/23 12:59, herongguang wrote:
>> From: He Rongguang <herongguang.he@huawei.com>
>> 
>> 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 <herongguang.he@huawei.com>
>> ---
>>   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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-10-10 12:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-23  4:59 [PATCH] KVM: x86: handle KVM_SET_VCPU_EVENTS/KVM_VCPUEVENT_VALID_SMM properly herongguang
2016-09-23  4:59 ` [Qemu-devel] " herongguang
2016-10-08  3:31 ` Herongguang (Stephen)
2016-10-08  3:31   ` [Qemu-devel] " Herongguang (Stephen)
2016-10-10 12:48   ` Radim Krčmář
2016-10-10 12:48     ` [Qemu-devel] " Radim Krčmář

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.