* [PATCH] KVM: unmap SMM memslots in vt-d table
@ 2017-03-25 11:14 ` herongguang
0 siblings, 0 replies; 13+ messages in thread
From: herongguang @ 2017-03-25 11:14 UTC (permalink / raw)
To: pbonzini, rkrcmar, kvm; +Cc: qemu-devel, wangxinxin.wang, herongguang.he
or pages are not unmaped and freed
Signed-off-by: herongguang <herongguang.he@huawei.com>
---
arch/x86/kvm/iommu.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Well, do we should change pci-assign to not map SMM slots instead? Like vfio.
diff --git a/arch/x86/kvm/iommu.c b/arch/x86/kvm/iommu.c
index b181426..5b931bb 100644
--- a/arch/x86/kvm/iommu.c
+++ b/arch/x86/kvm/iommu.c
@@ -320,15 +320,17 @@ void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
static int kvm_iommu_unmap_memslots(struct kvm *kvm)
{
int idx;
- struct kvm_memslots *slots;
+ struct kvm_memslots *slots, *smm_slots;
struct kvm_memory_slot *memslot;
idx = srcu_read_lock(&kvm->srcu);
slots = kvm_memslots(kvm);
-
kvm_for_each_memslot(memslot, slots)
kvm_iommu_unmap_pages(kvm, memslot);
+ smm_slots = __kvm_memslots(kvm, 1);
+ kvm_for_each_memslot(memslot, smm_slots)
+ kvm_iommu_unmap_pages(kvm, memslot);
srcu_read_unlock(&kvm->srcu, idx);
if (kvm->arch.iommu_noncoherent)
--
1.7.12.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH] KVM: unmap SMM memslots in vt-d table
@ 2017-03-25 11:14 ` herongguang
0 siblings, 0 replies; 13+ messages in thread
From: herongguang @ 2017-03-25 11:14 UTC (permalink / raw)
To: pbonzini, rkrcmar, kvm; +Cc: qemu-devel, wangxinxin.wang, herongguang.he
or pages are not unmaped and freed
Signed-off-by: herongguang <herongguang.he@huawei.com>
---
arch/x86/kvm/iommu.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Well, do we should change pci-assign to not map SMM slots instead? Like vfio.
diff --git a/arch/x86/kvm/iommu.c b/arch/x86/kvm/iommu.c
index b181426..5b931bb 100644
--- a/arch/x86/kvm/iommu.c
+++ b/arch/x86/kvm/iommu.c
@@ -320,15 +320,17 @@ void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
static int kvm_iommu_unmap_memslots(struct kvm *kvm)
{
int idx;
- struct kvm_memslots *slots;
+ struct kvm_memslots *slots, *smm_slots;
struct kvm_memory_slot *memslot;
idx = srcu_read_lock(&kvm->srcu);
slots = kvm_memslots(kvm);
-
kvm_for_each_memslot(memslot, slots)
kvm_iommu_unmap_pages(kvm, memslot);
+ smm_slots = __kvm_memslots(kvm, 1);
+ kvm_for_each_memslot(memslot, smm_slots)
+ kvm_iommu_unmap_pages(kvm, memslot);
srcu_read_unlock(&kvm->srcu, idx);
if (kvm->arch.iommu_noncoherent)
--
1.7.12.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2] KVM: pci-assign: do not map smm memory slot pages
2017-03-25 11:14 ` [Qemu-devel] " herongguang
@ 2017-03-27 7:21 ` Herongguang (Stephen)
-1 siblings, 0 replies; 13+ messages in thread
From: Herongguang (Stephen) @ 2017-03-27 7:21 UTC (permalink / raw)
To: pbonzini, rkrcmar, kvm; +Cc: qemu-devel, wangxinxin.wang
From f6f0ee6831488bef7af841cb86f3d85a04848fe5 Mon Sep 17 00:00:00 2001
From: herongguang <herongguang.he@huawei.com>
Date: Mon, 27 Mar 2017 15:08:59 +0800
Subject: [PATCH] KVM: pci-assign: do not map smm memory slot pages
in vt-d page table
or VM memory are not put thus leaked in kvm_iommu_unmap_memslots() when
destroy VM.
This is consistent with current vfio implementation.
---
virt/kvm/kvm_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 482612b..9018d06 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1052,7 +1052,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
* changes) is disallowed above, so any other attribute changes getting
* here can be skipped.
*/
- if ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE)) {
+ if ((as_id == 0) && ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE))) {
r = kvm_iommu_map_pages(kvm, &new);
return r;
}
--
1.7.12.4
On 2017/3/25 19:14, herongguang wrote:
> or pages are not unmaped and freed
>
> Signed-off-by: herongguang <herongguang.he@huawei.com>
> ---
> arch/x86/kvm/iommu.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> Well, do we should change pci-assign to not map SMM slots instead? Like vfio.
>
> diff --git a/arch/x86/kvm/iommu.c b/arch/x86/kvm/iommu.c
> index b181426..5b931bb 100644
> --- a/arch/x86/kvm/iommu.c
> +++ b/arch/x86/kvm/iommu.c
> @@ -320,15 +320,17 @@ void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
> static int kvm_iommu_unmap_memslots(struct kvm *kvm)
> {
> int idx;
> - struct kvm_memslots *slots;
> + struct kvm_memslots *slots, *smm_slots;
> struct kvm_memory_slot *memslot;
>
> idx = srcu_read_lock(&kvm->srcu);
> slots = kvm_memslots(kvm);
> -
> kvm_for_each_memslot(memslot, slots)
> kvm_iommu_unmap_pages(kvm, memslot);
>
> + smm_slots = __kvm_memslots(kvm, 1);
> + kvm_for_each_memslot(memslot, smm_slots)
> + kvm_iommu_unmap_pages(kvm, memslot);
> srcu_read_unlock(&kvm->srcu, idx);
>
> if (kvm->arch.iommu_noncoherent)
>
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v2] KVM: pci-assign: do not map smm memory slot pages
@ 2017-03-27 7:21 ` Herongguang (Stephen)
0 siblings, 0 replies; 13+ messages in thread
From: Herongguang (Stephen) @ 2017-03-27 7:21 UTC (permalink / raw)
To: pbonzini, rkrcmar, kvm; +Cc: qemu-devel, wangxinxin.wang
From f6f0ee6831488bef7af841cb86f3d85a04848fe5 Mon Sep 17 00:00:00 2001
From: herongguang <herongguang.he@huawei.com>
Date: Mon, 27 Mar 2017 15:08:59 +0800
Subject: [PATCH] KVM: pci-assign: do not map smm memory slot pages
in vt-d page table
or VM memory are not put thus leaked in kvm_iommu_unmap_memslots() when
destroy VM.
This is consistent with current vfio implementation.
---
virt/kvm/kvm_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 482612b..9018d06 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1052,7 +1052,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
* changes) is disallowed above, so any other attribute changes getting
* here can be skipped.
*/
- if ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE)) {
+ if ((as_id == 0) && ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE))) {
r = kvm_iommu_map_pages(kvm, &new);
return r;
}
--
1.7.12.4
On 2017/3/25 19:14, herongguang wrote:
> or pages are not unmaped and freed
>
> Signed-off-by: herongguang <herongguang.he@huawei.com>
> ---
> arch/x86/kvm/iommu.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> Well, do we should change pci-assign to not map SMM slots instead? Like vfio.
>
> diff --git a/arch/x86/kvm/iommu.c b/arch/x86/kvm/iommu.c
> index b181426..5b931bb 100644
> --- a/arch/x86/kvm/iommu.c
> +++ b/arch/x86/kvm/iommu.c
> @@ -320,15 +320,17 @@ void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
> static int kvm_iommu_unmap_memslots(struct kvm *kvm)
> {
> int idx;
> - struct kvm_memslots *slots;
> + struct kvm_memslots *slots, *smm_slots;
> struct kvm_memory_slot *memslot;
>
> idx = srcu_read_lock(&kvm->srcu);
> slots = kvm_memslots(kvm);
> -
> kvm_for_each_memslot(memslot, slots)
> kvm_iommu_unmap_pages(kvm, memslot);
>
> + smm_slots = __kvm_memslots(kvm, 1);
> + kvm_for_each_memslot(memslot, smm_slots)
> + kvm_iommu_unmap_pages(kvm, memslot);
> srcu_read_unlock(&kvm->srcu, idx);
>
> if (kvm->arch.iommu_noncoherent)
>
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2] KVM: pci-assign: do not map smm memory slot pages
2017-03-27 7:21 ` [Qemu-devel] " Herongguang (Stephen)
@ 2017-03-27 11:53 ` Paolo Bonzini
-1 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2017-03-27 11:53 UTC (permalink / raw)
To: Herongguang (Stephen), rkrcmar, kvm; +Cc: qemu-devel, wangxinxin.wang
On 27/03/2017 09:21, Herongguang (Stephen) wrote:
> From f6f0ee6831488bef7af841cb86f3d85a04848fe5 Mon Sep 17 00:00:00 2001
> From: herongguang <herongguang.he@huawei.com>
> Date: Mon, 27 Mar 2017 15:08:59 +0800
> Subject: [PATCH] KVM: pci-assign: do not map smm memory slot pages
> in vt-d page table
>
> or VM memory are not put thus leaked in kvm_iommu_unmap_memslots() when
> destroy VM.
>
> This is consistent with current vfio implementation.
> ---
> virt/kvm/kvm_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 482612b..9018d06 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1052,7 +1052,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
> * changes) is disallowed above, so any other attribute changes
> getting
> * here can be skipped.
> */
> - if ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE)) {
> + if ((as_id == 0) && ((change == KVM_MR_CREATE) || (change ==
> KVM_MR_MOVE))) {
> r = kvm_iommu_map_pages(kvm, &new);
> return r;
> }
This makes more sense. :)
Applied to kvm/master, thanks.
Paolo
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v2] KVM: pci-assign: do not map smm memory slot pages
@ 2017-03-27 11:53 ` Paolo Bonzini
0 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2017-03-27 11:53 UTC (permalink / raw)
To: Herongguang (Stephen), rkrcmar, kvm; +Cc: qemu-devel, wangxinxin.wang
On 27/03/2017 09:21, Herongguang (Stephen) wrote:
> From f6f0ee6831488bef7af841cb86f3d85a04848fe5 Mon Sep 17 00:00:00 2001
> From: herongguang <herongguang.he@huawei.com>
> Date: Mon, 27 Mar 2017 15:08:59 +0800
> Subject: [PATCH] KVM: pci-assign: do not map smm memory slot pages
> in vt-d page table
>
> or VM memory are not put thus leaked in kvm_iommu_unmap_memslots() when
> destroy VM.
>
> This is consistent with current vfio implementation.
> ---
> virt/kvm/kvm_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 482612b..9018d06 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1052,7 +1052,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
> * changes) is disallowed above, so any other attribute changes
> getting
> * here can be skipped.
> */
> - if ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE)) {
> + if ((as_id == 0) && ((change == KVM_MR_CREATE) || (change ==
> KVM_MR_MOVE))) {
> r = kvm_iommu_map_pages(kvm, &new);
> return r;
> }
This makes more sense. :)
Applied to kvm/master, thanks.
Paolo
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] KVM: pci-assign: do not map smm memory slot pages
2017-03-27 7:21 ` [Qemu-devel] " Herongguang (Stephen)
@ 2017-03-27 12:22 ` Paolo Bonzini
-1 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2017-03-27 12:22 UTC (permalink / raw)
To: Herongguang (Stephen), rkrcmar, kvm; +Cc: qemu-devel, wangxinxin.wang
On 27/03/2017 09:21, Herongguang (Stephen) wrote:
> From f6f0ee6831488bef7af841cb86f3d85a04848fe5 Mon Sep 17 00:00:00 2001
> From: herongguang <herongguang.he@huawei.com>
> Date: Mon, 27 Mar 2017 15:08:59 +0800
> Subject: [PATCH] KVM: pci-assign: do not map smm memory slot pages
> in vt-d page table
>
> or VM memory are not put thus leaked in kvm_iommu_unmap_memslots() when
> destroy VM.
>
> This is consistent with current vfio implementation.
Oops, you forgot a Signed-off-by.
Paolo
> ---
> virt/kvm/kvm_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 482612b..9018d06 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1052,7 +1052,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
> * changes) is disallowed above, so any other attribute changes
> getting
> * here can be skipped.
> */
> - if ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE)) {
> + if ((as_id == 0) && ((change == KVM_MR_CREATE) || (change ==
> KVM_MR_MOVE))) {
> r = kvm_iommu_map_pages(kvm, &new);
> return r;
> }
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v2] KVM: pci-assign: do not map smm memory slot pages
@ 2017-03-27 12:22 ` Paolo Bonzini
0 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2017-03-27 12:22 UTC (permalink / raw)
To: Herongguang (Stephen), rkrcmar, kvm; +Cc: qemu-devel, wangxinxin.wang
On 27/03/2017 09:21, Herongguang (Stephen) wrote:
> From f6f0ee6831488bef7af841cb86f3d85a04848fe5 Mon Sep 17 00:00:00 2001
> From: herongguang <herongguang.he@huawei.com>
> Date: Mon, 27 Mar 2017 15:08:59 +0800
> Subject: [PATCH] KVM: pci-assign: do not map smm memory slot pages
> in vt-d page table
>
> or VM memory are not put thus leaked in kvm_iommu_unmap_memslots() when
> destroy VM.
>
> This is consistent with current vfio implementation.
Oops, you forgot a Signed-off-by.
Paolo
> ---
> virt/kvm/kvm_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 482612b..9018d06 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1052,7 +1052,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
> * changes) is disallowed above, so any other attribute changes
> getting
> * here can be skipped.
> */
> - if ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE)) {
> + if ((as_id == 0) && ((change == KVM_MR_CREATE) || (change ==
> KVM_MR_MOVE))) {
> r = kvm_iommu_map_pages(kvm, &new);
> return r;
> }
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v2] KVM: pci-assign: do not map smm memory slot pages
2017-03-27 12:22 ` [Qemu-devel] " Paolo Bonzini
(?)
@ 2017-03-27 12:58 ` hrg
-1 siblings, 0 replies; 13+ messages in thread
From: hrg @ 2017-03-27 12:58 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Herongguang (Stephen), rkrcmar, kvm, wangxinxin.wang, qemu-devel
On Mon, Mar 27, 2017 at 8:22 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>
> On 27/03/2017 09:21, Herongguang (Stephen) wrote:
>> From f6f0ee6831488bef7af841cb86f3d85a04848fe5 Mon Sep 17 00:00:00 2001
>> From: herongguang <herongguang.he@huawei.com>
>> Date: Mon, 27 Mar 2017 15:08:59 +0800
>> Subject: [PATCH] KVM: pci-assign: do not map smm memory slot pages
>> in vt-d page table
>>
>> or VM memory are not put thus leaked in kvm_iommu_unmap_memslots() when
>> destroy VM.
>>
>> This is consistent with current vfio implementation.
>
> Oops, you forgot a Signed-off-by.
Sorry, I forget this, I'll resend it tomorrow since I am home now.
PS, what's your opinion about this
(http://www.spinics.net/lists/kvm/msg146914.html)?
>
> Paolo
>
>> ---
>> virt/kvm/kvm_main.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
>> index 482612b..9018d06 100644
>> --- a/virt/kvm/kvm_main.c
>> +++ b/virt/kvm/kvm_main.c
>> @@ -1052,7 +1052,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
>> * changes) is disallowed above, so any other attribute changes
>> getting
>> * here can be skipped.
>> */
>> - if ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE)) {
>> + if ((as_id == 0) && ((change == KVM_MR_CREATE) || (change ==
>> KVM_MR_MOVE))) {
>> r = kvm_iommu_map_pages(kvm, &new);
>> return r;
>> }
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] KVM: pci-assign: do not map smm memory slot pages
2017-03-27 12:22 ` [Qemu-devel] " Paolo Bonzini
@ 2017-03-28 1:08 ` Herongguang (Stephen)
-1 siblings, 0 replies; 13+ messages in thread
From: Herongguang (Stephen) @ 2017-03-28 1:08 UTC (permalink / raw)
To: Paolo Bonzini, rkrcmar, kvm; +Cc: qemu-devel, wangxinxin.wang
From 8f5b9d2c2944ea7cd8149e9d3b4088f487217d20 Mon Sep 17 00:00:00 2001
From: herongguang <herongguang.he@huawei.com>
Date: Mon, 27 Mar 2017 15:08:59 +0800
Subject: [PATCH] KVM: pci-assign: do not map smm memory slot pages in vt-d
page table
or VM memory are not put thus leaked in kvm_iommu_unmap_memslots() when
destroy VM.
This is consistent with current vfio implementation.
Signed-off-by: herongguang <herongguang.he@huawei.com>
---
virt/kvm/kvm_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 482612b..9018d06 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1052,7 +1052,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
* changes) is disallowed above, so any other attribute changes getting
* here can be skipped.
*/
- if ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE)) {
+ if ((as_id == 0) && ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE))) {
r = kvm_iommu_map_pages(kvm, &new);
return r;
}
--
1.7.12.4
On 2017/3/27 20:22, Paolo Bonzini wrote:
>
>
> On 27/03/2017 09:21, Herongguang (Stephen) wrote:
>> From f6f0ee6831488bef7af841cb86f3d85a04848fe5 Mon Sep 17 00:00:00 2001
>> From: herongguang <herongguang.he@huawei.com>
>> Date: Mon, 27 Mar 2017 15:08:59 +0800
>> Subject: [PATCH] KVM: pci-assign: do not map smm memory slot pages
>> in vt-d page table
>>
>> or VM memory are not put thus leaked in kvm_iommu_unmap_memslots() when
>> destroy VM.
>>
>> This is consistent with current vfio implementation.
>
> Oops, you forgot a Signed-off-by.
>
> Paolo
>
>> ---
>> virt/kvm/kvm_main.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
>> index 482612b..9018d06 100644
>> --- a/virt/kvm/kvm_main.c
>> +++ b/virt/kvm/kvm_main.c
>> @@ -1052,7 +1052,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
>> * changes) is disallowed above, so any other attribute changes
>> getting
>> * here can be skipped.
>> */
>> - if ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE)) {
>> + if ((as_id == 0) && ((change == KVM_MR_CREATE) || (change ==
>> KVM_MR_MOVE))) {
>> r = kvm_iommu_map_pages(kvm, &new);
>> return r;
>> }
>
> .
>
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v2] KVM: pci-assign: do not map smm memory slot pages
@ 2017-03-28 1:08 ` Herongguang (Stephen)
0 siblings, 0 replies; 13+ messages in thread
From: Herongguang (Stephen) @ 2017-03-28 1:08 UTC (permalink / raw)
To: Paolo Bonzini, rkrcmar, kvm; +Cc: qemu-devel, wangxinxin.wang
From 8f5b9d2c2944ea7cd8149e9d3b4088f487217d20 Mon Sep 17 00:00:00 2001
From: herongguang <herongguang.he@huawei.com>
Date: Mon, 27 Mar 2017 15:08:59 +0800
Subject: [PATCH] KVM: pci-assign: do not map smm memory slot pages in vt-d
page table
or VM memory are not put thus leaked in kvm_iommu_unmap_memslots() when
destroy VM.
This is consistent with current vfio implementation.
Signed-off-by: herongguang <herongguang.he@huawei.com>
---
virt/kvm/kvm_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 482612b..9018d06 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1052,7 +1052,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
* changes) is disallowed above, so any other attribute changes getting
* here can be skipped.
*/
- if ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE)) {
+ if ((as_id == 0) && ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE))) {
r = kvm_iommu_map_pages(kvm, &new);
return r;
}
--
1.7.12.4
On 2017/3/27 20:22, Paolo Bonzini wrote:
>
>
> On 27/03/2017 09:21, Herongguang (Stephen) wrote:
>> From f6f0ee6831488bef7af841cb86f3d85a04848fe5 Mon Sep 17 00:00:00 2001
>> From: herongguang <herongguang.he@huawei.com>
>> Date: Mon, 27 Mar 2017 15:08:59 +0800
>> Subject: [PATCH] KVM: pci-assign: do not map smm memory slot pages
>> in vt-d page table
>>
>> or VM memory are not put thus leaked in kvm_iommu_unmap_memslots() when
>> destroy VM.
>>
>> This is consistent with current vfio implementation.
>
> Oops, you forgot a Signed-off-by.
>
> Paolo
>
>> ---
>> virt/kvm/kvm_main.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
>> index 482612b..9018d06 100644
>> --- a/virt/kvm/kvm_main.c
>> +++ b/virt/kvm/kvm_main.c
>> @@ -1052,7 +1052,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
>> * changes) is disallowed above, so any other attribute changes
>> getting
>> * here can be skipped.
>> */
>> - if ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE)) {
>> + if ((as_id == 0) && ((change == KVM_MR_CREATE) || (change ==
>> KVM_MR_MOVE))) {
>> r = kvm_iommu_map_pages(kvm, &new);
>> return r;
>> }
>
> .
>
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2] KVM: pci-assign: do not map smm memory slot pages
2017-03-28 1:08 ` [Qemu-devel] " Herongguang (Stephen)
@ 2017-03-28 8:09 ` Paolo Bonzini
-1 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2017-03-28 8:09 UTC (permalink / raw)
To: Herongguang (Stephen), rkrcmar, kvm; +Cc: qemu-devel, wangxinxin.wang
On 28/03/2017 03:08, Herongguang (Stephen) wrote:
> From 8f5b9d2c2944ea7cd8149e9d3b4088f487217d20 Mon Sep 17 00:00:00 2001
> From: herongguang <herongguang.he@huawei.com>
> Date: Mon, 27 Mar 2017 15:08:59 +0800
> Subject: [PATCH] KVM: pci-assign: do not map smm memory slot pages in vt-d
> page table
>
> or VM memory are not put thus leaked in kvm_iommu_unmap_memslots() when
> destroy VM.
>
> This is consistent with current vfio implementation.
>
> Signed-off-by: herongguang <herongguang.he@huawei.com>
> ---
> virt/kvm/kvm_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 482612b..9018d06 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1052,7 +1052,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
> * changes) is disallowed above, so any other attribute changes
> getting
> * here can be skipped.
> */
> - if ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE)) {
> + if ((as_id == 0) && ((change == KVM_MR_CREATE) || (change ==
> KVM_MR_MOVE))) {
> r = kvm_iommu_map_pages(kvm, &new);
> return r;
> }
Thanks!
Paolo
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v2] KVM: pci-assign: do not map smm memory slot pages
@ 2017-03-28 8:09 ` Paolo Bonzini
0 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2017-03-28 8:09 UTC (permalink / raw)
To: Herongguang (Stephen), rkrcmar, kvm; +Cc: qemu-devel, wangxinxin.wang
On 28/03/2017 03:08, Herongguang (Stephen) wrote:
> From 8f5b9d2c2944ea7cd8149e9d3b4088f487217d20 Mon Sep 17 00:00:00 2001
> From: herongguang <herongguang.he@huawei.com>
> Date: Mon, 27 Mar 2017 15:08:59 +0800
> Subject: [PATCH] KVM: pci-assign: do not map smm memory slot pages in vt-d
> page table
>
> or VM memory are not put thus leaked in kvm_iommu_unmap_memslots() when
> destroy VM.
>
> This is consistent with current vfio implementation.
>
> Signed-off-by: herongguang <herongguang.he@huawei.com>
> ---
> virt/kvm/kvm_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 482612b..9018d06 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1052,7 +1052,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
> * changes) is disallowed above, so any other attribute changes
> getting
> * here can be skipped.
> */
> - if ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE)) {
> + if ((as_id == 0) && ((change == KVM_MR_CREATE) || (change ==
> KVM_MR_MOVE))) {
> r = kvm_iommu_map_pages(kvm, &new);
> return r;
> }
Thanks!
Paolo
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2017-03-28 8:09 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-25 11:14 [PATCH] KVM: unmap SMM memslots in vt-d table herongguang
2017-03-25 11:14 ` [Qemu-devel] " herongguang
2017-03-27 7:21 ` [PATCH v2] KVM: pci-assign: do not map smm memory slot pages Herongguang (Stephen)
2017-03-27 7:21 ` [Qemu-devel] " Herongguang (Stephen)
2017-03-27 11:53 ` Paolo Bonzini
2017-03-27 11:53 ` [Qemu-devel] " Paolo Bonzini
2017-03-27 12:22 ` Paolo Bonzini
2017-03-27 12:22 ` [Qemu-devel] " Paolo Bonzini
2017-03-27 12:58 ` hrg
2017-03-28 1:08 ` Herongguang (Stephen)
2017-03-28 1:08 ` [Qemu-devel] " Herongguang (Stephen)
2017-03-28 8:09 ` Paolo Bonzini
2017-03-28 8:09 ` [Qemu-devel] " Paolo Bonzini
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.