Don't track all memory when enabling log dirty to track vram
PATCH 1/1 Don't track all memory when enabling log dirty to track vram
From: Yang Zhang <[email protected]>
When enabling log dirty mode, it sets all guest's memory to readonly. And in HAP enabled domain, it modifies all EPT entries to clear write bit to make sure it is readonly. This will cause problem if VT-d shares page table with EPT: the device may issue a DMA write request, then VT-d engine tells it the target memory is readonly and result in VT-d fault.
Currnetly, there are two places will enable log dirty mode: migration and vram tracking. Migration with device assigned is not allowed, so it is ok. For vram, it doesn't need to set all memory to readonly. Only track the vram range is enough.
--- xen/arch/x86/mm/hap/hap.c | 20 ++++++++++++++------ xen/arch/x86/mm/paging.c | 9 +++++---- xen/arch/x86/mm/shadow/common.c | 2 +- xen/include/asm-x86/domain.h | 2 +- xen/include/asm-x86/paging.h | 5 +++-- xen/include/asm-x86/shadow.h | 2 +- 6 files changed, 25 insertions(+), 15 deletions(-)
xen/arch/x86/mm/hap/hap.c +14 -6
@@ -82,7 +82,7 @@ int hap_track_dirty_vram(struct domain *d,if ( !paging_mode_log_dirty (d) ) {hap_logdirty_init (d); - rc =paging_log_dirty_enable (d); + rc =paging_log_dirty_enable (d,0 );if ( rc ) goto out; }
@@ -167,17 +167,25 @@ out:/* HAP LOG DIRTY SUPPORT */ /************************************************/ -/* hap code to call when log_dirty is enable. return 0 if no problem found. */ -static int hap_enable_log_dirty (struct domain *d) +/* +* hap code to call when log_dirty is enable. return 0 if no problem found. +* +* NB: Domain that having device assigned should not set log_global. Because +* there is no way to track the memory updating from device. +*/ +static int hap_enable_log_dirty (struct domain *d,bool_t log_global) {/* turn on PG_log_dirty bit in paging mode */ paging_lock (d); d->arch.paging.mode |= PG_log_dirty;paging_unlock (d); -/* set l1e entries of P2M table to be read-only. */ -p2m_change_entry_type_global (d, p2m_ram_rw, p2m_ram_logdirty); -flush_tlb_mask (d->domain_dirty_cpumask); +if ( log_global ) + { +/* set l1e entries of P2M table to be read-only. */ +p2m_change_entry_type_global (d, p2m_ram_rw, p2m_ram_logdirty); +flush_tlb_mask (d->domain_dirty_cpumask); + }return 0 ; }
xen/arch/x86/mm/paging.c +5 -4
@@ -164,7 +164,7 @@ void paging_free_log_dirty_bitmap(struct domain *d)paging_unlock (d); } -int paging_log_dirty_enable (struct domain *d) +int paging_log_dirty_enable (struct domain *d,bool_t log_global) {int ret;
@@ -172,7 +172,7 @@ int paging_log_dirty_enable(struct domain *d)return -EINVAL ;domain_pause (d); - ret = d->arch.paging.log_dirty.enable_log_dirty (d); + ret = d->arch.paging.log_dirty.enable_log_dirty (d, log_global);domain_unpause (d);return ret;
@@ -489,7 +489,8 @@ void paging_log_dirty_range(struct domain *d,* These function pointers must not be followed with the log-dirty lock held. */ void paging_log_dirty_init (struct domain *d, -int (*enable_log_dirty)(struct domain *d), +int (*enable_log_dirty)(struct domain *d, +bool_t log_global),int (*disable_log_dirty)(struct domain *d),void (*clean_dirty_bitmap)(struct domain *d)) {
@@ -590,7 +591,7 @@ int paging_domctl(struct domain *d, xen_domctl_shadow_op_t *sc,case XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY :if (hap_enabled (d) )hap_logdirty_init (d); -return paging_log_dirty_enable (d); +return paging_log_dirty_enable (d,1 );case XEN_DOMCTL_SHADOW_OP_OFF :if (paging_mode_log_dirty (d) )
xen/arch/x86/mm/shadow/common.c +1 -1
@@ -3418,7 +3418,7 @@ shadow_write_p2m_entry(struct vcpu *v, unsigned long gfn,/* Shadow specific code which is called in paging_log_dirty_enable(). * Return 0 if no problem found. */ -int shadow_enable_log_dirty (struct domain *d) +int shadow_enable_log_dirty (struct domain *d,bool_t log_global) {int ret;
xen/include/asm-x86/domain.h +1 -1
@@ -169,7 +169,7 @@ struct log_dirty_domain {unsigned int dirty_count;/* functions which are paging mode specific */ -int (*enable_log_dirty )(struct domain *d); +int (*enable_log_dirty )(struct domain *d,bool_t log_global);int (*disable_log_dirty )(struct domain *d);void (*clean_dirty_bitmap )(struct domain *d); };
xen/include/asm-x86/paging.h +3 -2
@@ -143,14 +143,15 @@ void paging_log_dirty_range(struct domain *d, uint8_t *dirty_bitmap);/* enable log dirty */ -int paging_log_dirty_enable (struct domain *d); +int paging_log_dirty_enable (struct domain *d,bool_t log_global);/* disable log dirty */ int paging_log_dirty_disable (struct domain *d);/* log dirty initialization */ void paging_log_dirty_init (struct domain *d, -int (*enable_log_dirty)(struct domain *d), +int (*enable_log_dirty)(struct domain *d, +bool_t log_global),int (*disable_log_dirty)(struct domain *d),void (*clean_dirty_bitmap)(struct domain *d));
xen/include/asm-x86/shadow.h +1 -1
@@ -82,7 +82,7 @@ void shadow_teardown(struct domain *d);void shadow_final_teardown (struct domain *d);/* shadow code to call when log dirty is enabled */ -int shadow_enable_log_dirty (struct domain *d); +int shadow_enable_log_dirty (struct domain *d,bool_t log_global);/* shadow code to call when log dirty is disabled */ int shadow_disable_log_dirty (struct domain *d);
Signature · 1 line
1.7.1
Quoted 7 lines · Yang Zhang
From: Yang Zhang <[email protected]>
When enabling log dirty mode, it sets all guest's memory to readonly. And in HAP enabled domain, it modifies all EPT entries to clear write bit to make sure it is readonly. This will cause problem if VT-d shares page table with EPT: the device may issue a DMA write request, then VT-d engine tells it the target memory is readonly and result in VT-d fault.
So that's a problem even if only the VGA framebuffer is being tracked -- DMA from a passthrough device will either cause a spurious error or fail to update the dirt bitmap.
I think it would be better not to allow VT-d and EPT to share pagetables in cases where devices are passed through (i.e. all cases where VT-d is in use).
Tim.
Tim Deegan wrote on 2014-02-10:
Quoted 9 lines
Quoted 8 lines · Yang Zhang
From: Yang Zhang <[email protected]>
When enabling log dirty mode, it sets all guest's memory to readonly. And in HAP enabled domain, it modifies all EPT entries to clear write bit to make sure it is readonly. This will cause problem if VT-d shares page table with EPT: the device may issue a DMA write request, then VT-d engine tells it the target memory is readonly and result in VT-d
Quoted 5 lines
fault.
So that's a problem even if only the VGA framebuffer is being tracked -- DMA from a passthrough device will either cause a spurious error or fail to update the dirt bitmap.
Do you mean the VGA frambuffer will be used as DMA buffer in guest? If yes, I think it's guest's responsibility to ensure it never happens.
Quoted 3 lines
I think it would be better not to allow VT-d and EPT to share
pagetables in cases where devices are passed through (i.e. all cases where VT-d is in use).
Without VT-d and EPT share page, we still cannot track the memory updating from DMA. I think the point is that we cannot track the memory updating via DMA. So the user should use the log dirty mode carefully. Also, I am not sure whether the memory updating from dom0 and QEMU is tracked currently.
Quoted 2 lines
Tim.
Best regards,
Yang
Quoted 10 lines · Yang Z
Tim Deegan wrote on 2014-02-10:
Quoted 9 lines
Quoted 8 lines · Yang Zhang
From: Yang Zhang <[email protected]>
When enabling log dirty mode, it sets all guest's memory to readonly. And in HAP enabled domain, it modifies all EPT entries to clear write bit to make sure it is readonly. This will cause problem if VT-d shares page table with EPT: the device may issue a DMA write request, then VT-d engine tells it the target memory is readonly and result in VT-d
Quoted 8 lines
Quoted 5 lines
fault.
So that's a problem even if only the VGA framebuffer is being tracked -- DMA from a passthrough device will either cause a spurious error or fail to update the dirt bitmap.
Do you mean the VGA frambuffer will be used as DMA buffer in guest? If yes, I think it's guest's responsibility to ensure it never happens.
I don't think that works. We can't expect arbitrary OSes to (a) know they're running on Xen and (b) know that that means they can't DMA to or from their framebuffers.
Quoted 2 lines
Without VT-d and EPT share page, we still cannot track the memory updating from DMA.
Yeah, but at least we don't risk crashing the _host_ by throwing DMA failures around.
Quoted 4 lines
I think the point is that we cannot track the
memory updating via DMA. So the user should use the log dirty mode carefully. Also, I am not sure whether the memory updating from dom0 and QEMU is tracked currently.
Yes, dom0 and qemu updates are tracked in the log-dirty bitmaps.
Tim.
Quoted 24 lines · Tim Deegan
Quoted 10 lines · Yang Z
Tim Deegan wrote on 2014-02-10:
Quoted 9 lines
Quoted 8 lines · Yang Zhang
From: Yang Zhang <[email protected]>
When enabling log dirty mode, it sets all guest's memory to readonly. And in HAP enabled domain, it modifies all EPT entries to clear write bit to make sure it is readonly. This will cause problem if VT-d shares page table with EPT: the device may issue a DMA write request, then VT-d engine tells it the target memory is readonly and result in VT-d
Quoted 8 lines
Quoted 5 lines
fault.
So that's a problem even if only the VGA framebuffer is being tracked -- DMA from a passthrough device will either cause a spurious error or fail to update the dirt bitmap.
Do you mean the VGA frambuffer will be used as DMA buffer in guest? If yes, I think it's guest's responsibility to ensure it never happens.
I don't think that works. We can't expect arbitrary OSes to (a) know they're running on Xen and (b) know that that means they can't DMA to or from their framebuffers.
Quoted 5 lines
Quoted 2 lines
Without VT-d and EPT share page, we still cannot track the memory updating from DMA.
Yeah, but at least we don't risk crashing the _host_ by throwing DMA failures around.
What I'm missing here is what you think a proper solution is. It seems we have:
A. Share EPT/IOMMU tables, only do log-dirty tracking on the buffer being tracked, and hope the guest doesn't DMA into video ram; DMA causes IOMMU fault. (This really shouldn't crash the host under normal circumstances; if it does it's a hardware bug.)
B. Never share EPT/IOMMU tables, and hope the guest doesn't DMA into video ram. DMA causes missed update to dirty bitmap, which will hopefully just cause screen corruption.
C. Do buffer scanning rather than dirty vram tracking (SLOW) D. Don't allow both a virtual video card and pass-through
Given that most operating systems will probably *not* DMA into video ram, and that an IOMMU fault isn't *supposed* to be able to crash the host, 'A' seems like the most reasonable option to me.
-George
Quoted 25 lines · George Dunlap
Quoted 24 lines · Tim Deegan
Quoted 10 lines · Yang Z
Tim Deegan wrote on 2014-02-10:
Quoted 9 lines
Quoted 8 lines · Yang Zhang
From: Yang Zhang <[email protected]>
When enabling log dirty mode, it sets all guest's memory to readonly. And in HAP enabled domain, it modifies all EPT entries to clear write bit to make sure it is readonly. This will cause problem if VT-d shares page table with EPT: the device may issue a DMA write request, then VT-d engine tells it the target memory is readonly and result in VT-d
Quoted 8 lines
Quoted 5 lines
fault.
So that's a problem even if only the VGA framebuffer is being tracked -- DMA from a passthrough device will either cause a spurious error or fail to update the dirt bitmap.
Do you mean the VGA frambuffer will be used as DMA buffer in guest? If yes, I think it's guest's responsibility to ensure it never happens.
I don't think that works. We can't expect arbitrary OSes to (a) know they're running on Xen and (b) know that that means they can't DMA to or from their framebuffers.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Without VT-d and EPT share page, we still cannot track the memory updating from DMA.
Yeah, but at least we don't risk crashing the _host_ by throwing DMA failures around.
What I'm missing here is what you think a proper solution is.
A _proper_ solution would be for the IOMMU h/w to allow restartable faults, so that we can do all the usual fault-driven virtual memory operations with DMA. :) In the meantime...
Quoted 6 lines
It seems we have:
A. Share EPT/IOMMU tables, only do log-dirty tracking on the buffer being tracked, and hope the guest doesn't DMA into video ram; DMA causes IOMMU fault. (This really shouldn't crash the host under normal circumstances; if it does it's a hardware bug.)
Note "hope" and "shouldn't" there. :)
Quoted 3 lines
B. Never share EPT/IOMMU tables, and hope the guest doesn't DMA into video ram. DMA causes missed update to dirty bitmap, which will hopefully just cause screen corruption.
Yep. At a cost of about 0.2% in space and some extra bookkeeping (for VMs that actually have devices passed through to them). The extra bookkeeping could be expensive in some cases, but basically all of those cases are already incompatible with IOMMU.
Quoted 2 lines
C. Do buffer scanning rather than dirty vram tracking (SLOW) D. Don't allow both a virtual video card and pass-through
E. Share EPT and IOMMU tables until someone turns on log-dirty mode and then split them out. That one
Quoted 3 lines
Given that most operating systems will probably *not* DMA into video ram, and that an IOMMU fault isn't *supposed* to be able to crash the host, 'A' seems like the most reasonable option to me.
Meh, OK. I prefer 'B' but 'A' is better than nothing, I guess, and seems to have most support from other people. On that basis this patch can have my Ack.
Is it intended for 4.4 as a bugfix (i.e. should I be checking it in?)
Tim.
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
Quoted 1 line · George Dunlap
What I'm missing here is what you think a proper solution is.
A _proper_ solution would be for the IOMMU h/w to allow restartable faults, so that we can do all the usual fault-driven virtual memory operations with DMA. :) In the meantime...
Or maintaining the A/D bits for IOMMU side accesses too.
Quoted 18 lines
Quoted 6 lines
It seems we have:
A. Share EPT/IOMMU tables, only do log-dirty tracking on the buffer being tracked, and hope the guest doesn't DMA into video ram; DMA causes IOMMU fault. (This really shouldn't crash the host under normal circumstances; if it does it's a hardware bug.)
Note "hope" and "shouldn't" there. :)
Quoted 3 lines
B. Never share EPT/IOMMU tables, and hope the guest doesn't DMA into video ram. DMA causes missed update to dirty bitmap, which will hopefully just cause screen corruption.
Yep. At a cost of about 0.2% in space and some extra bookkeeping (for VMs that actually have devices passed through to them). The extra bookkeeping could be expensive in some cases, but basically all of those cases are already incompatible with IOMMU.
Quoted 5 lines
Quoted 2 lines
C. Do buffer scanning rather than dirty vram tracking (SLOW) D. Don't allow both a virtual video card and pass-through
E. Share EPT and IOMMU tables until someone turns on log-dirty mode and then split them out. That one
Wouldn't that be problematic in terms of memory being available, namely when using ballooning in Dom0?
Quoted 7 lines
Quoted 3 lines
Given that most operating systems will probably *not* DMA into video ram, and that an IOMMU fault isn't *supposed* to be able to crash the host, 'A' seems like the most reasonable option to me.
Meh, OK. I prefer 'B' but 'A' is better than nothing, I guess, and seems to have most support from other people. On that basis this patch can have my Ack.
I too would consider B better than A.
Jan
Quoted 41 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
Quoted 1 line · George Dunlap
What I'm missing here is what you think a proper solution is.
A _proper_ solution would be for the IOMMU h/w to allow restartable faults, so that we can do all the usual fault-driven virtual memory operations with DMA. :) In the meantime...
Or maintaining the A/D bits for IOMMU side accesses too.
Quoted 18 lines
Quoted 6 lines
It seems we have:
A. Share EPT/IOMMU tables, only do log-dirty tracking on the buffer being tracked, and hope the guest doesn't DMA into video ram; DMA causes IOMMU fault. (This really shouldn't crash the host under normal circumstances; if it does it's a hardware bug.)
Note "hope" and "shouldn't" there. :)
Quoted 3 lines
B. Never share EPT/IOMMU tables, and hope the guest doesn't DMA into video ram. DMA causes missed update to dirty bitmap, which will hopefully just cause screen corruption.
Yep. At a cost of about 0.2% in space and some extra bookkeeping (for VMs that actually have devices passed through to them). The extra bookkeeping could be expensive in some cases, but basically all of those cases are already incompatible with IOMMU.
Quoted 5 lines
Quoted 2 lines
C. Do buffer scanning rather than dirty vram tracking (SLOW) D. Don't allow both a virtual video card and pass-through
E. Share EPT and IOMMU tables until someone turns on log-dirty mode and then split them out. That one
Wouldn't that be problematic in terms of memory being available, namely when using ballooning in Dom0?
Quoted 4 lines
Quoted 3 lines
Given that most operating systems will probably *not* DMA into video ram, and that an IOMMU fault isn't *supposed* to be able to crash the host, 'A' seems like the most reasonable option to me.
Quoted 5 lines
Quoted 3 lines
Meh, OK. I prefer 'B' but 'A' is better than nothing, I guess, and seems to have most support from other people. On that basis this patch can have my Ack.
I too would consider B better than A.
I think I got a bit distracted with the "A isn't really so bad" thing. Actually, if the overhead of not sharing tables isn't very high, then B isn't such a bad option. In fact, B is what I expected Yang to submit when he originally described the problem.
I was going to say, from a release perspective, B is probably the safest option for now. But on the other hand, if we've been testing sharing all this time, maybe switching back over to non-sharing whole-hog has the higher risk?
Anyway, both are at least probably equal risk-wise. How easy is it to implement?
-George
George Dunlap wrote on 2014-02-11:
Quoted 45 lines · Jan Beulich
Quoted 44 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
Quoted 1 line · George Dunlap
What I'm missing here is what you think a proper solution is.
A _proper_ solution would be for the IOMMU h/w to allow restartable faults, so that we can do all the usual fault-driven virtual memory operations with DMA. :) In the meantime...
Or maintaining the A/D bits for IOMMU side accesses too.
Quoted 17 lines
Quoted 5 lines
It seems we have:
A. Share EPT/IOMMU tables, only do log-dirty tracking on the buffer being tracked, and hope the guest doesn't DMA into video ram; DMA causes IOMMU fault. (This really shouldn't crash the host under normal circumstances; if it does it's a hardware bug.)Note "hope" and "shouldn't" there. :)
Quoted 3 lines
B. Never share EPT/IOMMU tables, and hope the guest doesn't DMA into video ram. DMA causes missed update to dirty bitmap, which will hopefully just cause screen corruption.
Yep. At a cost of about 0.2% in space and some extra bookkeeping (for VMs that actually have devices passed through to them). The extra bookkeeping could be expensive in some cases, but basically all of those cases are already incompatible with IOMMU.
Quoted 5 lines
Quoted 2 lines
C. Do buffer scanning rather than dirty vram tracking (SLOW) D. Don't allow both a virtual video card and pass-through
E. Share EPT and IOMMU tables until someone turns on log-dirty mode and then split them out. That one
Wouldn't that be problematic in terms of memory being available, namely when using ballooning in Dom0?
Quoted 7 lines
Quoted 3 lines
Given that most operating systems will probably *not* DMA into video ram, and that an IOMMU fault isn't *supposed* to be able to crash the host, 'A' seems like the most reasonable option to me.
Meh, OK. I prefer 'B' but 'A' is better than nothing, I guess, and seems to have most support from other people. On that basis this patch can have my Ack.
Quoted 6 lines
Quoted 1 line
I too would consider B better than A.
I think I got a bit distracted with the "A isn't really so bad" thing. Actually, if the overhead of not sharing tables isn't very high, then B isn't such a bad option. In fact, B is what I expected Yang to submit when he originally described the problem.
Actually, the first solution came to my mind is B. Then I realized that even chose B, we still cannot track the memory updating from DMA(even with A/D bit, it still a problem). Also, considering the current usage case of log dirty in Xen(only vram tracking has problem), I though A is better.: Hypervisor only need to track the vram change. If a malicious guest try to DMA to vram range, it only crashed himself (This should be reasonable).
Quoted 4 lines
I was going to say, from a release perspective, B is probably the
safest option for now. But on the other hand, if we've been testing
sharing all this time, maybe switching back over to non-sharing whole-hog has the higher risk?
Another problem with B is that current VT-d large paging supporting relies on the sharing EPT and VT-d page table. This means if we choose B, then we need to re-enable VT-d large page. This would be a huge performance impaction for Xen 4.4 on using VT-d solution.
Quoted 5 lines
Anyway, both are at least probably equal risk-wise. How easy is it to implement?
-George
Best regards,
Yang
Quoted 43 lines · Yang Z
George Dunlap wrote on 2014-02-11:
Quoted 34 lines · Jan Beulich
Quoted 33 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
Quoted 1 line · George Dunlap
What I'm missing here is what you think a proper solution is.
A _proper_ solution would be for the IOMMU h/w to allow restartable faults, so that we can do all the usual fault-driven virtual memory operations with DMA. :) In the meantime...
Or maintaining the A/D bits for IOMMU side accesses too.
Quoted 15 lines
Quoted 5 lines
It seems we have:
A. Share EPT/IOMMU tables, only do log-dirty tracking on the buffer being tracked, and hope the guest doesn't DMA into video ram; DMA causes IOMMU fault. (This really shouldn't crash the host under normal circumstances; if it does it's a hardware bug.)Note "hope" and "shouldn't" there. :)
Quoted 3 lines
B. Never share EPT/IOMMU tables, and hope the guest doesn't DMA into video ram. DMA causes missed update to dirty bitmap, which will hopefully just cause screen corruption.
Yep. At a cost of about 0.2% in space and some extra bookkeeping (for VMs that actually have devices passed through to them). The extra bookkeeping could be expensive in some cases, but basically all of those cases are already incompatible with IOMMU.
Quoted 4 lines
Quoted 2 lines
C. Do buffer scanning rather than dirty vram tracking (SLOW) D. Don't allow both a virtual video card and pass-through
E. Share EPT and IOMMU tables until someone turns on log-dirty mode and then split them out. That one
Wouldn't that be problematic in terms of memory being available, namely when using ballooning in Dom0?
Quoted 3 lines
Quoted 3 lines
Given that most operating systems will probably *not* DMA into video ram, and that an IOMMU fault isn't *supposed* to be able to crash the host, 'A' seems like the most reasonable option to me.
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Meh, OK. I prefer 'B' but 'A' is better than nothing, I guess, and seems to have most support from other people. On that basis this patch can have my Ack.
I too would consider B better than A.
I think I got a bit distracted with the "A isn't really so bad" thing. Actually, if the overhead of not sharing tables isn't very high, then B isn't such a bad option. In fact, B is what I expected Yang to submit when he originally described the problem.
Quoted 6 lines
Actually, the first solution came to my mind is B. Then I realized that even chose B, we still cannot track the memory updating from
DMA(even with A/D bit, it still a problem). Also, considering the current usage case of log dirty in Xen(only vram tracking has problem), I though A is better.: Hypervisor only need to track the vram change. If a malicious guest try to DMA to vram range, it only crashed himself (This should be reasonable).Quoted 3 lines
I was going to say, from a release perspective, B is probably the
safest option for now. But on the other hand, if we've been testing
sharing all this time, maybe switching back over to non-sharing whole-hog has the higher risk?Another problem with B is that current VT-d large paging supporting relies on the sharing EPT and VT-d page table. This means if we choose B, then we need to re-enable VT-d large page. This would be a huge performance impaction for Xen 4.4 on using VT-d solution.
OK -- if that's the case, then it definitely tips the balance back to A. Unless Tim or Jan disagrees, can one of you two check it in?
Don't rush your judgement; but it would be nice to have this in before RC4, which would mean checking it in today preferrably, or early tomorrow at the latest.
-George
Quoted 23 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 6 lines · Yang Z
George Dunlap wrote on 2014-02-11:
Quoted 4 lines
I think I got a bit distracted with the "A isn't really so bad" thing. Actually, if the overhead of not sharing tables isn't very high, then B isn't such a bad option. In fact, B is what I expected Yang to submit when he originally described the problem.
Actually, the first solution came to my mind is B. Then I realized that even
chose B, we still cannot track the memory updating from
DMA(even with A/D bit, it still a problem). Also, considering the current usage case of log dirty in Xen(only vram tracking has problem), I though A is better.:
Hypervisor only need to track the vram change. If a malicious guest try to DMA to vram range, it only crashed himself (This should be reasonable).Quoted 4 lines
Quoted 4 lines
I was going to say, from a release perspective, B is probably the safest option for now. But on the other hand, if we've been testing sharing all this time, maybe switching back over to non-sharing whole-hog has
the higher risk?
Quoted 1 line
Another problem with B is that current VT-d large paging supporting relies on
the sharing EPT and VT-d page table. This means if we choose B, then we need to re-enable VT-d large page. This would be a huge performance impaction for Xen 4.4 on using VT-d solution.
Quoted 6 lines
OK -- if that's the case, then it definitely tips the balance back to A. Unless Tim or Jan disagrees, can one of you two check it in?
Don't rush your judgement; but it would be nice to have this in before RC4, which would mean checking it in today preferrably, or early tomorrow at the latest.
That would be Tim then, as he would have to approve of it anyway. I should also say that while I certainly understand the argumentation above, I would still want to go this route only with the promise that B is going to be worked on reasonably soon after the release, ideally with the goal of backporting the changes for 4.4.1.
Jan
Quoted 23 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 6 lines · Yang Z
George Dunlap wrote on 2014-02-11:
Quoted 4 lines
I think I got a bit distracted with the "A isn't really so bad" thing. Actually, if the overhead of not sharing tables isn't very high, then B isn't such a bad option. In fact, B is what I expected Yang to submit when he originally described the problem.
Actually, the first solution came to my mind is B. Then I realized that even
chose B, we still cannot track the memory updating from
DMA(even with A/D bit, it still a problem). Also, considering the current usage case of log dirty in Xen(only vram tracking has problem), I though A is better.:
Hypervisor only need to track the vram change. If a malicious guest try to DMA to vram range, it only crashed himself (This should be reasonable).Quoted 4 lines
Quoted 4 lines
I was going to say, from a release perspective, B is probably the safest option for now. But on the other hand, if we've been testing sharing all this time, maybe switching back over to non-sharing whole-hog has
the higher risk?
Quoted 1 line
Another problem with B is that current VT-d large paging supporting relies on
the sharing EPT and VT-d page table. This means if we choose B, then we need to re-enable VT-d large page. This would be a huge performance impaction for Xen 4.4 on using VT-d solution.
Quoted 8 lines
Quoted 6 lines
OK -- if that's the case, then it definitely tips the balance back to A. Unless Tim or Jan disagrees, can one of you two check it in?
Don't rush your judgement; but it would be nice to have this in before RC4, which would mean checking it in today preferrably, or early tomorrow at the latest.
That would be Tim then, as he would have to approve of it anyway.
Done.
Quoted 4 lines
I should also say that while I certainly understand the argumentation above, I would still want to go this route only with the promise that B is going to be worked on reasonably soon after the release, ideally with the goal of backporting the changes for 4.4.1.
Agreed.
Tim.
title 38 Implement VT-d large pages so we can avoid sharing between EPT and IOMMU owner it Yang Z Zhang <[email protected]>
thanks
Quoted 29 lines · Tim Deegan
Quoted 28 lines · Jan Beulich
Quoted 28 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 6 lines · Yang Z
George Dunlap wrote on 2014-02-11:
Quoted 4 lines
I think I got a bit distracted with the "A isn't really so bad" thing. Actually, if the overhead of not sharing tables isn't very high, then B isn't such a bad option. In fact, B is what I expected Yang to submit when he originally described the problem.
Actually, the first solution came to my mind is B. Then I realized that even
chose B, we still cannot track the memory updating from
DMA(even with A/D bit, it still a problem). Also, considering the current usage case of log dirty in Xen(only vram tracking has problem), I though A is better.:
Hypervisor only need to track the vram change. If a malicious guest try to DMA to vram range, it only crashed himself (This should be reasonable).Quoted 3 lines
Quoted 3 lines
I was going to say, from a release perspective, B is probably the safest option for now. But on the other hand, if we've been testing sharing all this time, maybe switching back over to non-sharing whole-hog has
the higher risk?
Quoted 1 line
Another problem with B is that current VT-d large paging supporting relies on
the sharing EPT and VT-d page table. This means if we choose B, then we need to re-enable VT-d large page. This would be a huge performance impaction for Xen 4.4 on using VT-d solution.
OK -- if that's the case, then it definitely tips the balance back to A. Unless Tim or Jan disagrees, can one of you two check it in?
Don't rush your judgement; but it would be nice to have this in before RC4, which would mean checking it in today preferrably, or early tomorrow at the latest.
Quoted 8 lines
Quoted 1 line
That would be Tim then, as he would have to approve of it anyway.
Done.
Quoted 4 lines
I should also say that while I certainly understand the argumentation above, I would still want to go this route only with the promise that B is going to be worked on reasonably soon after the release, ideally with the goal of backporting the changes for 4.4.1.
Agreed.
OK -- I've retitled the bug and am going to leave it open.
-George
Processed: Re: [PATCH] Don't track all memory when enabling log dirty to track vram
Processing commands for [email protected]:
Quoted 1 line
title 38 Implement VT-d large pages so we can avoid sharing between EPT
Set title for #38 to `Implement VT-d large pages so we can avoid sharing between EPT'
Quoted 1 line
and IOMMU
Command failed: Unknown command `and'. at /srv/xen-devel-bugs/lib/emesinae/control.pl line 455, <GEN1> line 2. Stop processing here.
Modified/created Bugs:
- 38: http://bugs.xenproject.org/xen/bug/38
---
Xen Hypervisor Bug Tracker
See http://wiki.xen.org/wiki/Reporting_Bugs_against_Xen for information on reporting bugs Contact [email protected] with any infrastructure issues
Quoted 32 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 6 lines · Yang Z
George Dunlap wrote on 2014-02-11:
Quoted 4 lines
I think I got a bit distracted with the "A isn't really so bad" thing. Actually, if the overhead of not sharing tables isn't very high, then B isn't such a bad option. In fact, B is what I expected Yang to submit when he originally described the problem.
Actually, the first solution came to my mind is B. Then I realized that
even
Quoted 6 lines
Quoted 6 lines
chose B, we still cannot track the memory updating from
DMA(even with A/D bit, it still a problem). Also, considering the current usage case of log dirty in Xen(only vram tracking has problem), I though A is better.:
Hypervisor only need to track the vram change. If a malicious guest try to DMA to vram range, it only crashed himself (This should be reasonable).Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
I was going to say, from a release perspective, B is probably the safest option for now. But on the other hand, if we've been testing sharing all this time, maybe switching back over to non-sharing whole-hog has
the higher risk?
Quoted 1 line
Another problem with B is that current VT-d large paging supporting relies
on
Quoted 8 lines
Quoted 8 lines
the sharing EPT and VT-d page table. This means if we choose B, then we need
to re-enable VT-d large page. This would be a huge performance impaction for Xen 4.4 on using VT-d solution.
OK -- if that's the case, then it definitely tips the balance back to A. Unless Tim or Jan disagrees, can one of you two check it in?
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Don't rush your judgement; but it would be nice to have this in before RC4, which would mean checking it in today preferrably, or early tomorrow at the latest.
That would be Tim then, as he would have to approve of it anyway.
Done.
Actually I'm afraid there are two problems with this patch:
For one, is enabling "global" log dirty mode still going to work after VRAM-only mode already got enabled? I ask because the paging_mode_log_dirty() check which paging_log_dirty_enable() does first thing suggests otherwise to me (i.e. the now conditional setting of all p2m entries to p2m_ram_logdirty would seem to never get executed). IOW I would think that we're now lacking a control operation allowing the transition from dirty VRAM tracking mode to full log dirty mode.
And second, I have been fighting with finding both conditions and (eventually) the root cause of a severe performance regression (compared to 4.3.x) I'm observing on an EPT+IOMMU system. This became _much_ worse after adding in the patch here (while in fact I had hoped it might help with the originally observed degradation): X startup fails due to timing out, and booting the guest now takes about 20 minutes). I didn't find the root cause of this yet, but meanwhile I know that
- the same isn't observable on SVM
- there's no problem when forcing the domain to use shadow mode
- there's no need for any device to actually be assigned to the guest
- the regression is very likely purely graphics related (based on the observation that when running something that regularly but not heavily updates the screen with X up, the guest consumes a full CPU's worth of processing power, yet when that updating doesn't happen, CPU consumption goes down, and it goes further down when shutting down X altogether - at least as log as the patch here doesn't get involved).
This I'm observing on a Westmere box (and I didn't notice it earlier because that's one of those where due to a chipset erratum the IOMMU gets turned off by default), so it's possible that this can't be seen on more modern hardware. I'll hopefully find time today to check this on the one newer (Sandy Bridge) box I have.
Jan
Quoted 36 lines · Jan Beulich
Quoted 26 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 6 lines · Yang Z
George Dunlap wrote on 2014-02-11:
Quoted 4 lines
I think I got a bit distracted with the "A isn't really so bad" thing. Actually, if the overhead of not sharing tables isn't very high, then B isn't such a bad option. In fact, B is what I expected Yang to submit when he originally described the problem.
Actually, the first solution came to my mind is B. Then I realized that
even
Quoted 10 lines
Quoted 10 lines
chose B, we still cannot track the memory updating from
DMA(even with A/D bit, it still a problem). Also, considering the current usage case of log dirty in Xen(only vram tracking has problem), I though A is better.:
Hypervisor only need to track the vram change. If a malicious guest try to DMA to vram range, it only crashed himself (This should be reasonable).Quoted 3 lines
Quoted 3 lines
I was going to say, from a release perspective, B is probably the safest option for now. But on the other hand, if we've been testing sharing all this time, maybe switching back over to non-sharing whole-hog has
the higher risk?
Quoted 1 line
Another problem with B is that current VT-d large paging supporting relies
on
Quoted 4 lines
Quoted 4 lines
the sharing EPT and VT-d page table. This means if we choose B, then we need to re-enable VT-d large page. This would be a huge performance impaction for Xen 4.4 on using VT-d solution.
Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
OK -- if that's the case, then it definitely tips the balance back to A. Unless Tim or Jan disagrees, can one of you two check it in?
Don't rush your judgement; but it would be nice to have this in before RC4, which would mean checking it in today preferrably, or early tomorrow at the latest.
That would be Tim then, as he would have to approve of it anyway.
Done.
Actually I'm afraid there are two problems with this patch:
Quoted 8 lines
For one, is enabling "global" log dirty mode still going to work after VRAM-only mode already got enabled? I ask because the
paging_mode_log_dirty()check whichpaging_log_dirty_enable()does first thing suggests otherwise to me (i.e. the now conditional setting of all p2m entries top2m_ram_logdirtywould seem to never get executed). IOW I would think that we're now lacking a control operation allowing the transition from dirty VRAM tracking mode to full log dirty mode.
Hmm, yes, doing a code inspection, that would appear to be the case. This probably wouldn't be caught by osstest, because (as I understand it) we never attach to the display, so dirty vram tracking is probably never enabled.
Quoted 17 lines
And second, I have been fighting with finding both conditions and (eventually) the root cause of a severe performance regression (compared to 4.3.x) I'm observing on an EPT+IOMMU system. This became _much_ worse after adding in the patch here (while in fact I had hoped it might help with the originally observed degradation): X startup fails due to timing out, and booting the guest now takes about 20 minutes). I didn't find the root cause of this yet, but meanwhile I know that
- the same isn't observable on SVM
- there's no problem when forcing the domain to use shadow mode
- there's no need for any device to actually be assigned to the guest
- the regression is very likely purely graphics related (based on the observation that when running something that regularly but not heavily updates the screen with X up, the guest consumes a full CPU's worth of processing power, yet when that updating
Quoted 8 lines
doesn't happen, CPU consumption goes down, and it goes further down when shutting down X altogether - at least as log as the patch here doesn't get involved).
This I'm observing on a Westmere box (and I didn't notice it earlier because that's one of those where due to a chipset erratum the IOMMU gets turned off by default), so it's possible that this can't be seen on more modern hardware. I'll hopefully find time today to check this on the one newer (Sandy Bridge) box I have.
So you're saying that the slowdown happens if you have EPT+IOMMU, but *not* if you have EPT alone (IOMMU disabled), or shadow + IOMMU?
I have an issue I haven't had time to look into where windows installs are sometimes terribly slow on my Nehalem box; but it seems to be only with qemu-xen, not qemu-traditional. I haven't tried with shadow.
-George
Quoted 28 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 17 lines · Jan Beulich
And second, I have been fighting with finding both conditions and (eventually) the root cause of a severe performance regression (compared to 4.3.x) I'm observing on an EPT+IOMMU system. This became _much_ worse after adding in the patch here (while in fact I had hoped it might help with the originally observed degradation): X startup fails due to timing out, and booting the guest now takes about 20 minutes). I didn't find the root cause of this yet, but meanwhile I know that
- the same isn't observable on SVM
- there's no problem when forcing the domain to use shadow mode
- there's no need for any device to actually be assigned to the guest
- the regression is very likely purely graphics related (based on the observation that when running something that regularly but not heavily updates the screen with X up, the guest consumes a full CPU's worth of processing power, yet when that updatingQuoted 8 lines
doesn't happen, CPU consumption goes down, and it goes further down when shutting down X altogether - at least as log as the patch here doesn't get involved).
This I'm observing on a Westmere box (and I didn't notice it earlier because that's one of those where due to a chipset erratum the IOMMU gets turned off by default), so it's possible that this can't be seen on more modern hardware. I'll hopefully find time today to check this on the one newer (Sandy Bridge) box I have.
Quoted 6 lines
So you're saying that the slowdown happens if you have EPT+IOMMU, but *not* if you have EPT alone (IOMMU disabled), or shadow + IOMMU?
I have an issue I haven't had time to look into where windows installs are sometimes terribly slow on my Nehalem box; but it seems to be only with qemu-xen, not qemu-traditional. I haven't tried with shadow.
Sorry I forgot to mention this - I too suspected the qemu version update to be one possible reason, but I'm seeing the same behavior with qemu-trad.
Jan
Quoted 36 lines · Jan Beulich
Quoted 26 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 6 lines · Yang Z
George Dunlap wrote on 2014-02-11:
Quoted 4 lines
I think I got a bit distracted with the "A isn't really so bad" thing. Actually, if the overhead of not sharing tables isn't very high, then B isn't such a bad option. In fact, B is what I expected Yang to submit when he originally described the problem.
Actually, the first solution came to my mind is B. Then I realized that
even
Quoted 10 lines
Quoted 10 lines
chose B, we still cannot track the memory updating from
DMA(even with A/D bit, it still a problem). Also, considering the current usage case of log dirty in Xen(only vram tracking has problem), I though A is better.:
Hypervisor only need to track the vram change. If a malicious guest try to DMA to vram range, it only crashed himself (This should be reasonable).Quoted 3 lines
Quoted 3 lines
I was going to say, from a release perspective, B is probably the safest option for now. But on the other hand, if we've been testing sharing all this time, maybe switching back over to non-sharing whole-hog has
the higher risk?
Quoted 1 line
Another problem with B is that current VT-d large paging supporting relies
on
Quoted 4 lines
Quoted 4 lines
the sharing EPT and VT-d page table. This means if we choose B, then we need to re-enable VT-d large page. This would be a huge performance impaction for Xen 4.4 on using VT-d solution.
Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
OK -- if that's the case, then it definitely tips the balance back to A. Unless Tim or Jan disagrees, can one of you two check it in?
Don't rush your judgement; but it would be nice to have this in before RC4, which would mean checking it in today preferrably, or early tomorrow at the latest.
That would be Tim then, as he would have to approve of it anyway.
Done.
Actually I'm afraid there are two problems with this patch:
Quoted 8 lines
For one, is enabling "global" log dirty mode still going to work after VRAM-only mode already got enabled? I ask because the
paging_mode_log_dirty()check whichpaging_log_dirty_enable()does first thing suggests otherwise to me (i.e. the now conditional setting of all p2m entries top2m_ram_logdirtywould seem to never get executed). IOW I would think that we're now lacking a control operation allowing the transition from dirty VRAM tracking mode to full log dirty mode.
Hrm, will so far playing with this I've been unable to get a localhost migrate to fail with the vncviewer attached. Which seems a bit strange...
-George
Quoted 13 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 10 lines · Jan Beulich
Actually I'm afraid there are two problems with this patch:
For one, is enabling "global" log dirty mode still going to work after VRAM-only mode already got enabled? I ask because the
paging_mode_log_dirty()check whichpaging_log_dirty_enable()does first thing suggests otherwise to me (i.e. the now conditional setting of all p2m entries top2m_ram_logdirtywould seem to never get executed). IOW I would think that we're now lacking a control operation allowing the transition from dirty VRAM tracking mode to full log dirty mode.
Quoted 2 lines
Hrm, will so far playing with this I've been unable to get a localhost migrate to fail with the vncviewer attached. Which seems a bit strange...
Not necessarily - it may depend on how the tools actually do this:
They might temporarily disable log dirty mode altogether, just to re-enable full mode again right away. But this specific usage of the hypervisor interface wouldn't (to me) mean that other tool stacks might not be doing this differently.
Jan
Jan Beulich wrote on 2014-02-17:
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 17.02.14 at 15:51, George Dunlap <[email protected]>
Quoted 12 lines · wrote:
Quoted 10 lines · Jan Beulich
Actually I'm afraid there are two problems with this patch:
For one, is enabling "global" log dirty mode still going to work after VRAM-only mode already got enabled? I ask because the
paging_mode_log_dirty()check whichpaging_log_dirty_enable()does first thing suggests otherwise to me (i.e. the now conditional setting of all p2m entries top2m_ram_logdirtywould seem to never get executed). IOW I would think that we're now lacking a control operation allowing the transition from dirty VRAM tracking mode to full log dirty mode.
Quoted 8 lines
Quoted 2 lines
Hrm, will so far playing with this I've been unable to get a
localhost migrate to fail with the vncviewer attached. Which seems a bit strange...Not necessarily - it may depend on how the tools actually do this:
They might temporarily disable log dirty mode altogether, just to re-enable full mode again right away. But this specific usage of the hypervisor interface wouldn't (to me) mean that other tool stacks might not be doing this differently.
You are right. Before migration, libxc will disable log dirty mode if it already enabled before and re-enable it. So when I am developing this patch, I think it is ok for migration.
If there really have other tool stacks also will use this interface (Is it true?), perhaps my original patch is better which will check paging_mode_log_dirty(d) && log_global:
xen/arch/x86/mm/paging.c +1 -1
@@ -168,7 +168,7 @@ int paging_log_dirty_enable(struct domain *d, bool_t log_global) {int ret; -if (paging_mode_log_dirty (d) ) +if (paging_mode_log_dirty (d) && !log_global )return -EINVAL ;domain_pause (d);
Quoted 2 lines
Jan
Best regards,
Yang
Quoted 16 lines · Yang Z
Jan Beulich wrote on 2014-02-17:
Quoted 15 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 17.02.14 at 15:51, George Dunlap <[email protected]>
Quoted 13 lines · wrote:
Quoted 10 lines · Jan Beulich
Actually I'm afraid there are two problems with this patch:
For one, is enabling "global" log dirty mode still going to work after VRAM-only mode already got enabled? I ask because the
paging_mode_log_dirty()check whichpaging_log_dirty_enable()does first thing suggests otherwise to me (i.e. the now conditional setting of all p2m entries top2m_ram_logdirtywould seem to never get executed). IOW I would think that we're now lacking a control operation allowing the transition from dirty VRAM tracking mode to full log dirty mode.Hrm, will so far playing with this I've been unable to get a
localhost migrate to fail with the vncviewer attached. Which seems a bit strange...
Quoted 8 lines
Quoted 5 lines
Not necessarily - it may depend on how the tools actually do this:
They might temporarily disable log dirty mode altogether, just to re-enable full mode again right away. But this specific usage of the hypervisor interface wouldn't (to me) mean that other tool stacks might not be doing this differently.You are right. Before migration, libxc will disable log dirty mode if it already enabled before and re-enable it. So when I am developing this patch, I think it is ok for migration.
If there really have other tool stacks also will use this interface (Is it true?), perhaps my original patch is better which will check
paging_mode_log_dirty(d)&&log_global:
It turns out that the reason I couldn't get a crash was because libxc was actually paying attention to the -EINVAL return value, and disabling and then re-enabling logdirty. That's what would happen before your dirty vram patch, and that's what happens after. And arguably, that's the correct behavior for any toolstack, given that the interface returns an error.
This patch would actually change the interface; if we check this in, then if you enable logdirty when dirty vram tracking is enabled, you *won't* get an error, and thus *won't* disable and re-enable logdirty mode. So actually, this patch would be more disruptive.
Thanks for the patch, though. :-)
-George
Quoted 22 lines
xen/arch/x86/mm/paging.c +1
-1@@ -168,7 +168,7 @@ int paging_log_dirty_enable(struct domain *d, bool_t log_global) {int ret; -if (paging_mode_log_dirty (d) ) +if (paging_mode_log_dirty (d) && !log_global )return -EINVAL ;domain_pause (d);Quoted 3 lines
Jan
Best regards,
Yang
George Dunlap wrote on 2014-02-18:
Quoted 32 lines · Yang Z
Quoted 18 lines
Jan Beulich wrote on 2014-02-17:
Quoted 17 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
On 17.02.14 at 15:51, George Dunlap
<[email protected]>Quoted 14 lines · wrote:
Quoted 10 lines · Jan Beulich
Actually I'm afraid there are two problems with this patch:
For one, is enabling "global" log dirty mode still going to work after VRAM-only mode already got enabled? I ask because the
paging_mode_log_dirty()check whichpaging_log_dirty_enable()does first thing suggests otherwise to me (i.e. the now conditional setting of all p2m entries top2m_ram_logdirtywould seem to never get executed). IOW I would think that we're now lacking a control operation allowing the transition from dirty VRAM tracking mode to full log dirty mode.Hrm, will so far playing with this I've been unable to get a localhost migrate to fail with the vncviewer attached. Which seems a bit
strange...
Quoted 7 lines
Quoted 5 lines
Not necessarily - it may depend on how the tools actually do this:
They might temporarily disable log dirty mode altogether, just to re-enable full mode again right away. But this specific usage of the hypervisor interface wouldn't (to me) mean that other tool stacks might not be doing this differently.You are right. Before migration, libxc will disable log dirty mode if it already
enabled before and re-enable it. So when I am developing this patch, I think it is ok for migration.
Quoted 3 lines
If there really have other tool stacks also will use this interface (Is it true?),
Quoted 8 lines
perhaps my original patch is better which will check
paging_mode_log_dirty(d)&&log_global:It turns out that the reason I couldn't get a crash was because libxc
was actually paying attention to the-EINVALreturn value, and
disabling and then re-enabling logdirty. That's what would happen
before your dirty vram patch, and that's what happens after. And
arguably, that's the correct behavior for any toolstack, given that the interface returns an error.
Agree.
Quoted 6 lines
This patch would actually change the interface; if we check this in, then if you enable logdirty when dirty vram tracking is enabled, you *won't* get an error, and thus *won't* disable and re-enable logdirty mode. So actually, this patch would be more disruptive.
Jan, do you have any comment?
Quoted 4 lines
Thanks for the patch, though. :-)
-George
Quoted 1 line
Quoted 20 lines
xen/arch/x86/mm/paging.c int paging_log_dirty_enable(struct domain *d,
Quoted 6 lines
xen/arch/x86/mm/paging.c +0
-0index
ab5eacb..368c975 100644xen/arch/x86/mm/paging.c +0
-0@@ -168,7 +168,7 @@ int paging_log_dirty_enable(struct domain *d,
bool_tlog_global)Quoted 13 lines
xen/arch/x86/mm/paging.c +1
-1{int ret; -if (paging_mode_log_dirty (d) ) +if (paging_mode_log_dirty (d) && !log_global )return -EINVAL ;domain_pause (d);Quoted 1 line
Jan
Best regards,
Yang
Best regards,
Yang
Quoted 16 lines
Quoted 1 line
Quoted 1 line · Yang Z
George Dunlap wrote on 2014-02-18:
Quoted 9 lines · Yang Z
perhaps my original patch is better which will check
paging_mode_log_dirty(d)&&log_global:It turns out that the reason I couldn't get a crash was because libxc was actually paying attention to the
-EINVALreturn value, and disabling and then re-enabling logdirty. That's what would happen before your dirty vram patch, and that's what happens after. And arguably, that's the correct behavior for any toolstack, given that theinterface returns an error.
Agree.
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
This patch would actually change the interface; if we check this in, then if you enable logdirty when dirty vram tracking is enabled, you *won't* get an error, and thus *won't* disable and re-enable logdirty mode. So actually, this patch would be more disruptive.
Jan, do you have any comment?
This simplistic variant is just calling for problems. As was already said elsewhere on this thread, we should simply do the mode change
properly: Track that a partial log-dirty mode is in use, and allow switching to global log-dirty mode (converting all entries to R/O).
Jan
Quoted 20 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · Yang Z
George Dunlap wrote on 2014-02-18:
Quoted 9 lines · Yang Z
perhaps my original patch is better which will check
paging_mode_log_dirty(d)&&log_global:It turns out that the reason I couldn't get a crash was because libxc was actually paying attention to the
-EINVALreturn value, and disabling and then re-enabling logdirty. That's what would happen before your dirty vram patch, and that's what happens after. And arguably, that's the correct behavior for any toolstack, given that theinterface returns an error.
Agree.
Quoted 5 lines
This patch would actually change the interface; if we check this in, then if you enable logdirty when dirty vram tracking is enabled, you *won't* get an error, and thus *won't* disable and re-enable logdirty mode. So actually, this patch would be more disruptive.
Quoted 5 lines
Quoted 1 line
Jan, do you have any comment?
This simplistic variant is just calling for problems. As was already said elsewhere on this thread, we should simply do the mode change
properly: Track that a partial log-dirty mode is in use, and allow switching to global log-dirty mode (converting all entries to R/O).
I think Yang was asking you for your opinion on my suggestion that nothing actually needed to be done. Enabling full logdirty mode for migration when dirty vram tracking was enabled has *always* returned an error (or at least for a long time now), and *always* resulted in the toolstack disabling and re-enabling logdirty mode; Yang's patch doesn't change that at all.
If you think that's an interface we need to improve in the future, we can put it on the list of improvements. But at this point it seems to me more like a nice-to-have.
-George
Quoted 35 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 20 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · Yang Z
George Dunlap wrote on 2014-02-18:
Quoted 9 lines · Yang Z
perhaps my original patch is better which will check
paging_mode_log_dirty(d)&&log_global:It turns out that the reason I couldn't get a crash was because libxc was actually paying attention to the
-EINVALreturn value, and disabling and then re-enabling logdirty. That's what would happen before your dirty vram patch, and that's what happens after. And arguably, that's the correct behavior for any toolstack, given that theinterface returns an error.
Agree.
Quoted 5 lines
This patch would actually change the interface; if we check this in, then if you enable logdirty when dirty vram tracking is enabled, you *won't* get an error, and thus *won't* disable and re-enable logdirty mode. So actually, this patch would be more disruptive.
Quoted 5 lines
Quoted 1 line
Jan, do you have any comment?
This simplistic variant is just calling for problems. As was already said elsewhere on this thread, we should simply do the mode change
properly: Track that a partial log-dirty mode is in use, and allow switching to global log-dirty mode (converting all entries to R/O).I think Yang was asking you for your opinion on my suggestion that nothing actually needed to be done. Enabling full logdirty mode for migration when dirty vram tracking was enabled has *always* returned an error (or at least for a long time now), and *always* resulted in the toolstack disabling and re-enabling logdirty mode; Yang's patch doesn't change that at all.
Quoted 3 lines
If you think that's an interface we need to improve in the future, we can put it on the list of improvements. But at this point it seems to me more like a nice-to-have.
I agree - for 4.4.0 we shouldn't need any further adjustments. And I hoped to imply that I don't see a need for this incremental change to go in by having said "This simplistic variant is just calling for problems".
Jan
Quoted 34 lines · Jan Beulich
Quoted 34 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 20 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · Yang Z
George Dunlap wrote on 2014-02-18:
Quoted 9 lines · Yang Z
perhaps my original patch is better which will check
paging_mode_log_dirty(d)&&log_global:It turns out that the reason I couldn't get a crash was because libxc was actually paying attention to the
-EINVALreturn value, and disabling and then re-enabling logdirty. That's what would happen before your dirty vram patch, and that's what happens after. And arguably, that's the correct behavior for any toolstack, given that theinterface returns an error.
Agree.
Quoted 5 lines
This patch would actually change the interface; if we check this in, then if you enable logdirty when dirty vram tracking is enabled, you *won't* get an error, and thus *won't* disable and re-enable logdirty mode. So actually, this patch would be more disruptive.
Quoted 5 lines
Quoted 1 line
Jan, do you have any comment?
This simplistic variant is just calling for problems. As was already said elsewhere on this thread, we should simply do the mode change
properly: Track that a partial log-dirty mode is in use, and allow switching to global log-dirty mode (converting all entries to R/O).I think Yang was asking you for your opinion on my suggestion that nothing actually needed to be done. Enabling full logdirty mode for migration when dirty vram tracking was enabled has *always* returned an error (or at least for a long time now), and *always* resulted in the toolstack disabling and re-enabling logdirty mode; Yang's patch doesn't change that at all.
Quoted 7 lines
Quoted 3 lines
If you think that's an interface we need to improve in the future, we can put it on the list of improvements. But at this point it seems to me more like a nice-to-have.
I agree - for 4.4.0 we shouldn't need any further adjustments. And I hoped to imply that I don't see a need for this incremental change to go in by having said "This simplistic variant is just calling for problems".
No, but "we should simply do the mode change properly" could be interpreted as saying, "this needs to be done as a follow-up to the dirty vram tracking patch"; someone might even interpret it as, "you need to do this as a follow-up". That's what I was trying to clarify / express an opinion on. :-)
-George
Quoted 18 lines
Quoted 1 line
Quoted 1 line · Jan Beulich
And second, I have been fighting with finding both conditions and (eventually) the root cause of a severe performance regression (compared to 4.3.x) I'm observing on an EPT+IOMMU system. This became _much_ worse after adding in the patch here (while in fact I had hoped it might help with the originally observed degradation): X startup fails due to timing out, and booting the guest now takes about 20 minutes). I didn't find the root cause of this yet, but meanwhile I know that
- the same isn't observable on SVM
- there's no problem when forcing the domain to use shadow mode
- there's no need for any device to actually be assigned to the guest
- the regression is very likely purely graphics related (based on the observation that when running something that regularly but not heavily updates the screen with X up, the guest consumes a full CPU's worth of processing power, yet when that updating
Quoted 8 lines
doesn't happen, CPU consumption goes down, and it goes further down when shutting down X altogether - at least as log as the patch here doesn't get involved).
This I'm observing on a Westmere box (and I didn't notice it earlier because that's one of those where due to a chipset erratum the IOMMU gets turned off by default), so it's possible that this can't be seen on more modern hardware. I'll hopefully find time today to check this on the one newer (Sandy Bridge) box I have.
Just got done with trying this: By default, things work fine there. As soon as I use "iommu=no-snoop", things go bad (even worse than one the older box - the guest is consuming about 2.5 CPUs worth of processing power _without_ the patch here in use, so I don't even want to think about trying it there); I guessed that to be another of the potential sources of the problem since on that older box the respective hardware feature is unavailable.
While I'll try to look into this further, I guess I have to defer to our VT-d specialists at Intel at this point...
Jan
Jan Beulich wrote on 2014-02-17:
Quoted 31 lines
Quoted 15 lines
Quoted 1 line
Quoted 1 line · Jan Beulich
And second, I have been fighting with finding both conditions and (eventually) the root cause of a severe performance regression (compared to 4.3.x) I'm observing on an EPT+IOMMU system. This became _much_ worse after adding in the patch here (while in fact I had hoped it might help with the originally observed degradation): X startup fails due to timing out, and booting the guest now takes about 20 minutes). I didn't find the root cause of this yet, but meanwhile I know that
- the same isn't observable on SVM
- there's no problem when forcing the domain to use shadow mode - there's no need for any device to actually be assigned to the guest - the regression is very likely purely graphics related (based on the observation that when running something that regularly but not heavily updates the screen with X up, the guest consumes a full CPU'sQuoted 8 lines
worth of processing power, yet when that updating doesn't happen, CPU consumption goes down, and it goes further down when shutting down X altogether - at least as log as the patch here doesn't get involved).
This I'm observing on a Westmere box (and I didn't notice it earlier because that's one of those where due to a chipset erratum the IOMMU gets turned off by default), so it's possible that this can't be seen on more modern hardware. I'll hopefully find time today to check this on the one newer (Sandy Bridge) box I have.Just got done with trying this: By default, things work fine there.
As soon as I use "iommu=no-snoop", things go bad (even worse than one
the older box - the guest is consuming about 2.5 CPUs worth of
processing power _without_ the patch here in use, so I don't even want
to think about trying it there); I guessed that to be another of the
potential sources of the problem since on that older box the respective hardware feature is unavailable.
Quoted 3 lines
While I'll try to look into this further, I guess I have to defer to our VT-d specialists at Intel at this point...
Hi, Jan,
I tried to reproduce it. But unfortunately, I cannot reproduce it in my box (sandy bridge EP)with latest Xen(include my patch). I guess my configuration or steps may wrong, here is mine:
1. add iommu=1,no-snoop in by xen cmd line:
(XEN) Intel VT-d Snoop Control not enabled. (XEN) Intel VT-d Dom0 DMA Passthrough not enabled. (XEN) Intel VT-d Queued Invalidation enabled. (XEN) Intel VT-d Interrupt Remapping enabled. (XEN) Intel VT-d Shared EPT tables enabled.
2. boot a rhel6u4 guest.
3. after guest boot up, run startx inside guest.
4. a few second, the X windows shows and didn't see any error. Also the CPU utilization is about 1.7%.
Any thing wrong?
Quoted 1 line
Jan
Best regards,
Yang
Quoted 12 lines
Quoted 1 line
Quoted 1 line · Yang Z
I tried to reproduce it. But unfortunately, I cannot reproduce it in my box (sandy bridge EP)with latest Xen(include my patch). I guess my configuration or steps may wrong, here is mine:
1. add iommu=1,no-snoop in by xen cmd line:
(XEN) Intel VT-d Snoop Control not enabled. (XEN) Intel VT-d Dom0 DMA Passthrough not enabled. (XEN) Intel VT-d Queued Invalidation enabled. (XEN) Intel VT-d Interrupt Remapping enabled. (XEN) Intel VT-d Shared EPT tables enabled.
Quoted 8 lines
2. boot a rhel6u4 guest.
3. after guest boot up, run startx inside guest.
4. a few second, the X windows shows and didn't see any error. Also the CPU utilization is about 1.7%.
Any thing wrong?
Nothing I can see. The main difference might be that I'm using a SLES11 SP3 guest instead of a RHEL one.
Jan
Quoted 51 lines
Quoted 1 line
Quoted 1 line · Yang Z
Jan Beulich wrote on 2014-02-17:
Quoted 24 lines
Quoted 15 lines
Quoted 1 line
Quoted 1 line · Jan Beulich
And second, I have been fighting with finding both conditions and (eventually) the root cause of a severe performance regression (compared to 4.3.x) I'm observing on an EPT+IOMMU system. This became _much_ worse after adding in the patch here (while in fact I had hoped it might help with the originally observed degradation): X startup fails due to timing out, and booting the guest now takes about 20 minutes). I didn't find the root cause of this yet, but meanwhile I know that
- the same isn't observable on SVM
- there's no problem when forcing the domain to use shadow mode - there's no need for any device to actually be assigned to the guest - the regression is very likely purely graphics related (based on the observation that when running something that regularly but not heavily updates the screen with X up, the guest consumes a full CPU'sQuoted 8 lines
worth of processing power, yet when that updating doesn't happen, CPU consumption goes down, and it goes further down when shutting down X altogether - at least as log as the patch here doesn't get involved).
This I'm observing on a Westmere box (and I didn't notice it earlier because that's one of those where due to a chipset erratum the IOMMU gets turned off by default), so it's possible that this can't be seen on more modern hardware. I'll hopefully find time today to check this on the one newer (Sandy Bridge) box I have.Quoted 6 lines
Just got done with trying this: By default, things work fine there. As soon as I use "iommu=no-snoop", things go bad (even worse than one the older box - the guest is consuming about 2.5 CPUs worth of processing power _without_ the patch here in use, so I don't even want to think about trying it there); I guessed that to be another of the potential sources of the problem since on that older box the respective
hardware feature is unavailable.
Quoted 4 lines
While I'll try to look into this further, I guess I have to defer to our VT-d specialists at Intel at this point...
Hi, Jan,
I tried to reproduce it. But unfortunately, I cannot reproduce it in my box (sandy bridge EP)with latest Xen(include my patch). I guess my configuration or steps may wrong, here is mine:
1. add iommu=1,no-snoop in by xen cmd line:
(XEN) Intel VT-d Snoop Control not enabled. (XEN) Intel VT-d Dom0 DMA Passthrough not enabled. (XEN) Intel VT-d Queued Invalidation enabled. (XEN) Intel VT-d Interrupt Remapping enabled. (XEN) Intel VT-d Shared EPT tables enabled.
Quoted 8 lines
2. boot a rhel6u4 guest.
3. after guest boot up, run startx inside guest.
4. a few second, the X windows shows and didn't see any error. Also the CPU utilization is about 1.7%.
Any thing wrong?
Nothing at all, as it turns out. The regression is due to Dongxiao's
http://lists.xenproject.org/archives/html/xen-devel/2013-12/msg00367.html
which I have in my tree as part of various things pending for 4.5. And which at the first, second, and third glance looks pretty innocent (IOW I still have to find out _why_ it is wrong).
In any case - I'm very sorry for the false alarm.
Jan
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Jan Beulich
Nothing at all, as it turns out. The regression is due to Dongxiao's
http://lists.xenproject.org/archives/html/xen-devel/2013-12/msg00367.html
which I have in my tree as part of various things pending for 4.5. And which at the first, second, and third glance looks pretty innocent (IOW I still have to find out _why_ it is wrong).
And here's a fixed version of the patch - we simply can't drop the bogus HVM_PARAM_IDENT_PT check entirely yet.
In the course of fixing this I also found two other shortcomings:
- EPT EMT field should be updated upon guest MTRR writes (the lack thereof is the reason for needing to retain the bogus check)
- epte_get_entry_emt() either needs "order" passed, or its callers must call it more than once for big/huge pages
Jan
x86/hvm: refine the judgment on IDENT_PT for EMT
When trying to get the EPT EMT type, the judgment on HVM_PARAM_IDENT_PT is not correct which always returns WB type if the parameter is not set. Remove the related code.
We can't fully drop the dependency yet, but we should certainly avoid overriding cases already properly handled. The reason for this is that the guest setting up its MTRRs happens _after_ the EPT tables got already constructed, and no code is in place to propagate this to the EPT code. Without this check we're forcing the guest to run with all of its memory uncachable until something happens to re-write every single EPT entry. But of course this has to be just a temporary solution.
In the same spirit we should defer the "very early" (when the guest is still being constructed and has no vCPU yet) override to the last possible point.
xen/arch/x86/hvm/mtrr.c +4 -8
@@ -689,13 +689,8 @@ uint8_t epte_get_entry_emt(struct domain *ipat =0 ; -if ( (current->domain != d) && - ((d->vcpu ==NULL ) || ((v = d->vcpu[0 ]) ==NULL )) ) -return MTRR_TYPE_WRBACK ; - -if ( !is_pvh_vcpu (v) && - !v->domain->arch.hvm_domain.params[HVM_PARAM_IDENT_PT ] ) -return MTRR_TYPE_WRBACK ; +if ( v->domain != d ) + v = d->vcpu ? d->vcpu[0 ] :NULL ;if ( !mfn_valid (mfn_x (mfn)) )return MTRR_TYPE_UNCACHABLE ;
@@ -718,7 +713,8 @@ uint8_t epte_get_entry_emt(struct domainreturn MTRR_TYPE_WRBACK ; } - gmtrr_mtype =is_hvm_vcpu (v) ? + gmtrr_mtype =is_hvm_domain (d) && v && + d->arch.hvm_domain.params[HVM_PARAM_IDENT_PT ] ?get_mtrr_type (&v->arch.hvm_vcpu.mtrr, (gfn <<PAGE_SHIFT )) :MTRR_TYPE_WRBACK ;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 18 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Tuesday, February 18, 2014 11:29 PM
To: Xu, Dongxiao; Zhang, Xiantao; Zhang, Yang Z
Cc: [email protected]; George Dunlap; Dugger, Donald D; [email protected]; Tim Deegan
Subject: Re: [Xen-devel] [PATCH] Don't track all memory when enabling log dirty to track vramQuoted 8 lines
Quoted 1 line
Quoted 1 line · Jan Beulich
Nothing at all, as it turns out. The regression is due to Dongxiao's
http://lists.xenproject.org/archives/html/xen-devel/2013-12/msg00367.html
which I have in my tree as part of various things pending for 4.5. And which at the first, second, and third glance looks pretty innocent (IOW I still have to find out _why_ it is wrong).
Quoted 9 lines
And here's a fixed version of the patch - we simply can't drop the bogus
HVM_PARAM_IDENT_PTcheck entirely yet.In the course of fixing this I also found two other shortcomings:
- EPT EMT field should be updated upon guest MTRR writes (the lack thereof is the reason for needing to retain the bogus check)
-epte_get_entry_emt()either needs "order" passed, or its callers must call it more than once for big/huge pages
The below patch looks okay to me. Thanks!
Thanks,
Dongxiao
Quoted 56 lines
Jan
x86/hvm: refine the judgment on
IDENT_PTfor EMTWhen trying to get the EPT EMT type, the judgment on
HVM_PARAM_IDENT_PTis not correct which always returns WB type if the parameter is not set. Remove the related code.Signed-off-by Dongxiao Xu <[email protected]>We can't fully drop the dependency yet, but we should certainly avoid overriding cases already properly handled. The reason for this is that the guest setting up its MTRRs happens _after_ the EPT tables got already constructed, and no code is in place to propagate this to the EPT code. Without this check we're forcing the guest to run with all of its memory uncachable until something happens to re-write every single EPT entry. But of course this has to be just a temporary solution.
In the same spirit we should defer the "very early" (when the guest is still being constructed and has no vCPU yet) override to the last possible point.
Signed-off-by Jan Beulich <[email protected]>xen/arch/x86/hvm/mtrr.c +4
-8@@ -689,13 +689,8 @@ uint8_t epte_get_entry_emt(struct domain *ipat =0 ; -if ( (current->domain != d) && - ((d->vcpu ==NULL ) || ((v = d->vcpu[0 ]) ==NULL )) ) -return MTRR_TYPE_WRBACK ; - -if ( !is_pvh_vcpu (v) && - !v->domain->arch.hvm_domain.params[HVM_PARAM_IDENT_PT ] ) -return MTRR_TYPE_WRBACK ; +if ( v->domain != d ) + v = d->vcpu ? d->vcpu[0 ] :NULL ;if ( !mfn_valid (mfn_x (mfn)) )return MTRR_TYPE_UNCACHABLE ;@@ -718,7 +713,8 @@ uint8_t epte_get_entry_emt(struct domainreturn MTRR_TYPE_WRBACK ; } - gmtrr_mtype = is_hvm_vcpu(v) ? + gmtrr_mtype =is_hvm_domain (d) && v && + d->arch.hvm_domain.params[HVM_PARAM_IDENT_PT] ? get_mtrr_type(&v->arch.hvm_vcpu.mtrr, (gfn <<
PAGE_SHIFT)) :MTRR_TYPE_WRBACK;
Jan Beulich wrote on 2014-02-18:
Quoted 66 lines
Quoted 19 lines
Quoted 1 line
Quoted 1 line · Yang Z
Jan Beulich wrote on 2014-02-17:
Quoted 17 lines
Quoted 17 lines
Quoted 1 line
Quoted 1 line · Jan Beulich
And second, I have been fighting with finding both conditions and (eventually) the root cause of a severe performance regression (compared to 4.3.x) I'm observing on an EPT+IOMMU system. This became _much_ worse after adding in the patch here (while in fact I had hoped it might help with the originally observed degradation): X startup fails due to timing out, and booting the guest now takes about 20 minutes). I didn't find the root cause of this yet, but meanwhile I know that
- the same isn't observable on SVM
- there's no problem when forcing the domain to use shadow mode - there's no need for any device to actually be assigned to the guest - the regression is very likely purely graphics related (based on the observation that when running something that regularly but not heavily updates the screen with X up, the guest consumes a full CPU's worth of processing power, yet when that updating doesn't
happen,CPU
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
consumption goes down, and it goes further down when shutting
downX
Quoted 32 lines
Quoted 15 lines
Quoted 6 lines
altogether - at least as log as the patch here doesn't get involved).
This I'm observing on a Westmere box (and I didn't notice it earlier because that's one of those where due to a chipset erratum the IOMMU gets turned off by default), so it's possible that this can't be seen on more modern hardware. I'll hopefully find time today to check this on the one newer (Sandy Bridge) box I have.Just got done with trying this: By default, things work fine there. As soon as I use "iommu=no-snoop", things go bad (even worse than one the older box - the guest is consuming about 2.5 CPUs worth of processing power _without_ the patch here in use, so I don't even want to think about trying it there); I guessed that to be another of the potential sources of the problem since on that older box the respective hardware feature is unavailable.
Quoted 3 lines
While I'll try to look into this further, I guess I have to defer to our VT-d specialists at Intel at this point...
Hi, Jan,
I tried to reproduce it. But unfortunately, I cannot reproduce it in my box (sandy bridge EP)with latest Xen(include my patch). I guess my configuration or steps may wrong, here is mine:
1. add iommu=1,no-snoop in by xen cmd line:
(XEN) Intel VT-d Snoop Control not enabled. (XEN) Intel VT-d Dom0 DMA Passthrough not enabled. (XEN) Intel VT-d Queued Invalidation enabled. (XEN) Intel VT-d Interrupt Remapping enabled. (XEN) Intel VT-d Shared EPT tables enabled.Quoted 8 lines
2. boot a rhel6u4 guest.
3. after guest boot up, run startx inside guest.
4. a few second, the X windows shows and didn't see any error. Also the CPU utilization is about 1.7%.
Any thing wrong?
Nothing at all, as it turns out. The regression is due to Dongxiao's
Quoted 9 lines
http://lists.xenproject.org/archives/html/xen-devel/2013-12/msg00367.h
tmlwhich I have in my tree as part of various things pending for 4.5. And which at the first, second, and third glance looks pretty innocent (IOW I still have to find out _why_ it is wrong).
In any case - I'm very sorry for the false alarm.
It doesn't matter. Conversely, we need to thank you for helping us to fix this issue. :)
BTW, I still cannot reproduce it in my box, even I uses SLES 11 SP3 as guest.
Quoted 1 line
Jan
Best regards,
Yang
Quoted 75 lines
Quoted 1 line
Quoted 1 line · Yang Z
Jan Beulich wrote on 2014-02-18:
Quoted 73 lines
Quoted 19 lines
Quoted 1 line
Quoted 1 line · Yang Z
Jan Beulich wrote on 2014-02-17:
Quoted 17 lines
Quoted 17 lines
Quoted 1 line
Quoted 1 line · Jan Beulich
And second, I have been fighting with finding both conditions and (eventually) the root cause of a severe performance regression (compared to 4.3.x) I'm observing on an EPT+IOMMU system. This became _much_ worse after adding in the patch here (while in fact I had hoped it might help with the originally observed degradation): X startup fails due to timing out, and booting the guest now takes about 20 minutes). I didn't find the root cause of this yet, but meanwhile I know that
- the same isn't observable on SVM
- there's no problem when forcing the domain to use shadow mode - there's no need for any device to actually be assigned to the guest - the regression is very likely purely graphics related (based on the observation that when running something that regularly but not heavily updates the screen with X up, the guest consumes a full CPU's worth of processing power, yet when that updating doesn't
happen,CPU
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
consumption goes down, and it goes further down when shutting
downX
Quoted 32 lines
Quoted 15 lines
Quoted 6 lines
altogether - at least as log as the patch here doesn't get involved).
This I'm observing on a Westmere box (and I didn't notice it earlier because that's one of those where due to a chipset erratum the IOMMU gets turned off by default), so it's possible that this can't be seen on more modern hardware. I'll hopefully find time today to check this on the one newer (Sandy Bridge) box I have.Just got done with trying this: By default, things work fine there. As soon as I use "iommu=no-snoop", things go bad (even worse than one the older box - the guest is consuming about 2.5 CPUs worth of processing power _without_ the patch here in use, so I don't even want to think about trying it there); I guessed that to be another of the potential sources of the problem since on that older box the respective hardware feature is unavailable.
Quoted 3 lines
While I'll try to look into this further, I guess I have to defer to our VT-d specialists at Intel at this point...
Hi, Jan,
I tried to reproduce it. But unfortunately, I cannot reproduce it in my box (sandy bridge EP)with latest Xen(include my patch). I guess my configuration or steps may wrong, here is mine:
1. add iommu=1,no-snoop in by xen cmd line:
(XEN) Intel VT-d Snoop Control not enabled. (XEN) Intel VT-d Dom0 DMA Passthrough not enabled. (XEN) Intel VT-d Queued Invalidation enabled. (XEN) Intel VT-d Interrupt Remapping enabled. (XEN) Intel VT-d Shared EPT tables enabled.Quoted 8 lines
2. boot a rhel6u4 guest.
3. after guest boot up, run startx inside guest.
4. a few second, the X windows shows and didn't see any error. Also the CPU utilization is about 1.7%.
Any thing wrong?
Nothing at all, as it turns out. The regression is due to Dongxiao's
http://lists.xenproject.org/archives/html/xen-devel/2013-12/msg00367.h
tmlwhich I have in my tree as part of various things pending for 4.5. And which at the first, second, and third glance looks pretty innocent (IOW I still have to find out _why_ it is wrong).
Quoted 8 lines
Quoted 2 lines
In any case - I'm very sorry for the false alarm.
It doesn't matter. Conversely, we need to thank you for helping us to fix this issue. :)
BTW, I still cannot reproduce it in my box, even I uses SLES 11 SP3 as guest.
I assume you didn't pull in the broken patch - I'm sure you would see the problem if you did.
Jan
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines · Jan Beulich
Quoted 1 line · Jan Beulich
This I'm observing on a Westmere box (and I didn't notice it earlier because that's one of those where due to a chipset erratum the IOMMU gets turned off by default), so it's possible that this can't be seen on more modern hardware. I'll hopefully find time today to check this on the one newer (Sandy Bridge) box I have.
Quoted 7 lines
Just got done with trying this: By default, things work fine there. As soon as I use "iommu=no-snoop", things go bad (even worse than one the older box - the guest is consuming about 2.5 CPUs worth of processing power _without_ the patch here in use, so I don't even want to think about trying it there); I guessed that to be another of the potential sources of the problem since on that older box the respective hardware feature is unavailable.
That wasn't a fair comparison: The guest here had an SR-IOV NIC assigned. Once removing that, badness goes back to about the level I observe on the Westmere box. I'm then relatively certain that this "extra" badness can be attributed to the excessive use of wbinvd. Which of course puts under question what good assigning a device does on a system without snoop control, if overall performance gets worse rather than better.
Jan
Tim Deegan wrote on 2014-02-14:
Quoted 41 lines
Quoted 2 lines · Jan Beulich
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
On 13.02.14 at 16:46, George Dunlap
<[email protected]>Quoted 6 lines · wrote:
Quoted 6 lines · Yang Z
Quoted 5 lines
George Dunlap wrote on 2014-02-11:
Quoted 4 lines
I think I got a bit distracted with the "A isn't really so bad" thing. Actually, if the overhead of not sharing tables isn't very high, then B isn't such a bad option. In fact, B is what I expected Yang to submit when he originally described the problem.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Actually, the first solution came to my mind is B. Then I realized that even
chose B, we still cannot track the memory updating from
DMA(even with A/D bit, it still a problem). Also, considering the current usage case of log dirty in Xen(only vram tracking has problem), I though A is better.: Hypervisor only need to track the vram change. If a malicious guest try to DMA to vram range, it only crashed himself (This should bereasonable).
Quoted 12 lines
Quoted 12 lines
Quoted 5 lines
Quoted 5 lines
I was going to say, from a release perspective, B is probably the safest option for now. But on the other hand, if we've been testing sharing all this time, maybe switching back over to non-sharing whole-hog has
the higher risk?
Quoted 2 lines
Another problem with B is that current VT-d large paging supporting relies on
the sharing EPT and VT-d page table. This means if we choose B, then we need to re-enable VT-d large page. This would be a huge performance impaction for Xen 4.4 on using VT-d solution.
Quoted 8 lines
Quoted 6 lines
OK -- if that's the case, then it definitely tips the balance back to A. Unless Tim or Jan disagrees, can one of you two check it in?
Don't rush your judgement; but it would be nice to have this in before RC4, which would mean checking it in today preferrably, or early tomorrow at the latest.
That would be Tim then, as he would have to approve of it anyway.
Done.
Quoted 8 lines
Quoted 4 lines
I should also say that while I certainly understand the argumentation above, I would still want to go this route only with the promise that B is going to be worked on reasonably soon after the release, ideally with the goal of backporting the changes for 4.4.1.
Agreed.
Tim.
Hi all
Sorry to turn out this old thread.
Because I just noticed that someone is asking when Intel will implement the VT-d page table separately. Actually, I am totally unaware it. The original issue that this patch tries to fix is the VRAM tracking which using the global log dirty mode. And I thought the best solution to fix it is in VRAM side not VT-d side. Because even use separate VT-d page table, we still cannot track the memory update from DMA. Even worse, I think two page tables introduce redundant code and maintain effort. So I wonder is it really necessary to implement the separate VT-d large page?
Best regards,
Yang
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 19.05.14 at 09:48, <[email protected]> wrote:
Because I just noticed that someone is asking when Intel will implement the VT-d page table separately. Actually, I am totally unaware it.
This was a request sent directly to you, so it shouldn't be a surprise.
Quoted 5 lines
The original
issue that this patch tries to fix is the VRAM tracking which using the global log dirty mode. And I thought the best solution to fix it is in VRAM side not VT-d side. Because even use separate VT-d page table, we still cannot track the memory update from DMA.
Correct. But at least we can avoid IOMMU faults by not marking read- only the VRAM region. Unless the guest stores data in the VRAM region that's not directly displayed information, but needs to be preserved across migration, the only downside of this would be temporary screen corruption in the guest immediately following migration. Clearly far better than eventually turning off passed through devices due to excessive IOMMU faults.
Quoted 3 lines
Even worse, I think two page tables
introduce redundant code and maintain effort. So I wonder is it really necessary to implement the separate VT-d large page?
Tim and I certainly think so. Andrew had a valid point in stating that guests without the need for VRAM dirty tracking, but with assigned PCI device(s) could still benefit from sharing page tables, so working towards a model where this could be retained would clearly be the optimal solution.
I wonder whether you actually too the time to go through the old thread before writing your mail, since all you did is repeat your old arguments, without addressing any of the reasons given why we consider separate page tables better than shared ones.
Jan
Jan Beulich wrote on 2014-05-19:
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 19.05.14 at 09:48, <[email protected]> wrote:
Because I just noticed that someone is asking when Intel will implement the VT-d page table separately. Actually, I am totally unaware it.
This was a request sent directly to you, so it shouldn't be a surprise.
Yes, but I am not buying in it since I think it not the right direction to fix this issue:
This is my original point:
Actually, the first solution came to my mind is B. Then I realized that even chose B, we still cannot track the memory updating from DMA(even with A/D bit, it still a problem). Also, considering the current usage case of log dirty in Xen(only vram tracking has problem), I though A is better.: Hypervisor only need to track the vram change. If a malicious guest try to DMA to vram range, it only crashed himself (This should be reasonable).
Quoted 9 lines
Quoted 6 lines
The original
issue that this patch tries to fix is the VRAM tracking which using the global log dirty mode. And I thought the best solution to fix it is in VRAM side not VT-d side. Because even use separate VT-d page table, we still cannot track the memory update from DMA.Correct. But at least we can avoid IOMMU faults by not marking read- only the VRAM region. Unless the guest stores data in the VRAM region
It is easy to trigger an IOMMU faults by guest, like set an invalid DMA address. We cannot prevent it.
Quoted 5 lines
that's not directly displayed information, but needs to be preserved across migration, the only downside of this would be temporary screen corruption in the guest immediately following migration. Clearly far better than eventually turning off passed through devices due to excessive IOMMU faults.
Quoted 8 lines
Quoted 3 lines
Even worse, I think two page tables
introduce redundant code and maintain effort. So I wonder is it really necessary to implement the separate VT-d large page?Tim and I certainly think so. Andrew had a valid point in stating that guests without the need for VRAM dirty tracking, but with assigned PCI device(s) could still benefit from sharing page tables, so working towards a model where this could be retained would clearly be the optimal solution.
I still cannot understand what we want to achieve or fix by separate the page table.
Quoted 5 lines
I wonder whether you actually too the time to go through the old thread before writing your mail, since all you did is repeat your old arguments, without addressing any of the reasons given why we consider separate page tables better than shared ones.
I have gone through it many times. But I cannot find a strong reason to persuade me to do it. I think it is a 'nice to have' feature, not required. Unless if anyone can show me that current sharing mechanism do have problem and it only can be fixed by separate page table, then I think we must to do it.
Quoted 2 lines
Jan
Best regards,
Yang
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 05:09, <[email protected]> wrote:
Jan Beulich wrote on 2014-05-19:
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 19.05.14 at 09:48, <[email protected]> wrote:
Because I just noticed that someone is asking when Intel will implement the VT-d page table separately. Actually, I am totally unaware it.
This was a request sent directly to you, so it shouldn't be a surprise.
Yes, but I am not buying in it since I think it not the right direction to fix this issue:
Quoted 7 lines
This is my original point:
Actually, the first solution came to my mind is B. Then I realized that even chose B, we still cannot track the memory updating fromDMA(even with A/D bit, it still a problem). Also, considering the current usage case of log dirty in Xen(only vram tracking has problem), I though A is better.:
Hypervisor only need to track the vram change. If a malicious guest try to DMA to vram range, it only crashed himself (This should be reasonable).
Except that the guest in no way needs to be malicious. I think you forget that the ultimate goal of virtualization ought to be to make guests behave the same (in terms of correctness, not generally in terms of performance) as if run on real hardware, not matter what they do. And DMA to VRAM wouldn't crash on real hardware (and I can see legitimate uses of such).
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
The original
issue that this patch tries to fix is the VRAM tracking which using the global log dirty mode. And I thought the best solution to fix it is in VRAM side not VT-d side. Because even use separate VT-d page table, we still cannot track the memory update from DMA.Correct. But at least we can avoid IOMMU faults by not marking read- only the VRAM region. Unless the guest stores data in the VRAM region
It is easy to trigger an IOMMU faults by guest, like set an invalid DMA address. We cannot prevent it.
Correct (and this btw also contradicts above spelled out goal: On real hardware this would in the majority of cases also just cause certain operations to become ineffectual rather than bring down the system - we just have to be more rigid here to deal with potential malicious guests).
Jan
Quoted 47 lines · Yang Z
Tim Deegan wrote on 2014-02-14:
Quoted 46 lines
Quoted 2 lines · Jan Beulich
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
On 13.02.14 at 16:46, George Dunlap
<[email protected]>Quoted 6 lines · wrote:
Quoted 6 lines · Yang Z
Quoted 5 lines
George Dunlap wrote on 2014-02-11:
Quoted 4 lines
I think I got a bit distracted with the "A isn't really so bad" thing. Actually, if the overhead of not sharing tables isn't very high, then B isn't such a bad option. In fact, B is what I expected Yang to submit when he originally described the problem.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Actually, the first solution came to my mind is B. Then I realized that even
chose B, we still cannot track the memory updating from
DMA(even with A/D bit, it still a problem). Also, considering the current usage case of log dirty in Xen(only vram tracking has problem), I though A is better.: Hypervisor only need to track the vram change. If a malicious guest try to DMA to vram range, it only crashed himself (This should bereasonable).
Quoted 12 lines
Quoted 12 lines
Quoted 5 lines
Quoted 5 lines
I was going to say, from a release perspective, B is probably the safest option for now. But on the other hand, if we've been testing sharing all this time, maybe switching back over to non-sharing whole-hog has
the higher risk?
Quoted 2 lines
Another problem with B is that current VT-d large paging supporting relies on
the sharing EPT and VT-d page table. This means if we choose B, then we need to re-enable VT-d large page. This would be a huge performance impaction for Xen 4.4 on using VT-d solution.
Quoted 8 lines
Quoted 6 lines
OK -- if that's the case, then it definitely tips the balance back to A. Unless Tim or Jan disagrees, can one of you two check it in?
Don't rush your judgement; but it would be nice to have this in before RC4, which would mean checking it in today preferrably, or early tomorrow at the latest.
That would be Tim then, as he would have to approve of it anyway.
Done.
Quoted 4 lines
I should also say that while I certainly understand the argumentation above, I would still want to go this route only with the promise that B is going to be worked on reasonably soon after the release, ideally with the goal of backporting the changes for 4.4.1.
Quoted 8 lines
Quoted 3 lines
Agreed.
Tim.
Hi all
Sorry to turn out this old thread.
Because I just noticed that someone is asking when Intel will implement the VT-d page table separately. Actually, I am totally unaware it. The original issue that this patch tries to fix is the VRAM tracking which using the global log dirty mode. And I thought the best solution to fix it is in VRAM side not VT-d side. Because even use separate VT-d page table, we still cannot track the memory update from DMA. Even worse, I think two page tables introduce redundant code and maintain effort. So I wonder is it really necessary to implement the separate VT-d large page?
Yes, it does introduce redundant code. But unfortunately, IOMMU faults at the moment have to be considered rather risky; having on happens risks (in order of decreasing probability / increasing damage):
* Device stops working for that VM until an FLR (losing a lot of its state)
* The VM has to be killed
* The device stops working until a host reboot
* The host crashes
Avoiding these by "hoping" that the guest OS doesn't DMA into a video buffer isn't really robust enough. I think that was Tim and Jan's primary reason for wanting the ability to have separate tables for HAP and IOMMU.
Is that about right, Jan / Tim?
-George
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 19.05.14 at 15:27, <[email protected]> wrote:
Quoted 1 line · Yang Z
Because I just noticed that someone is asking when Intel will implement the
VT-d page table separately. Actually, I am totally unaware it. The original issue that this patch tries to fix is the VRAM tracking which using the global log dirty mode. And I thought the best solution to fix it is in VRAM side not VT-d side. Because even use separate VT-d page table, we still cannot track the memory update from DMA. Even worse, I think two page tables introduce redundant code and maintain effort. So I wonder is it really necessary to implement the separate VT-d large page?
Yes, it does introduce redundant code. But unfortunately, IOMMU faults at the moment have to be considered rather risky; having on happens risks (in order of decreasing probability / increasing damage):
* Device stops working for that VM until an FLR (losing a lot of its state)
* The VM has to be killed
* The device stops working until a host reboot
* The host crashes
Quoted 6 lines
Avoiding these by "hoping" that the guest OS doesn't DMA into a video buffer isn't really robust enough. I think that was Tim and Jan's primary reason for wanting the ability to have separate tables for HAP and IOMMU.
Is that about right, Jan / Tim?
Yes, and not just "about" (perhaps with the exception that I think/ hope we don't have any lurking host crashes here).
Jan
Quoted 20 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 19.05.14 at 15:27, <[email protected]> wrote:
Quoted 1 line · Yang Z
Because I just noticed that someone is asking when Intel will implement the
VT-d page table separately. Actually, I am totally unaware it. The original issue that this patch tries to fix is the VRAM tracking which using the global log dirty mode. And I thought the best solution to fix it is in VRAM side not VT-d side. Because even use separate VT-d page table, we still cannot track the memory update from DMA. Even worse, I think two page tables introduce redundant code and maintain effort. So I wonder is it really necessary to implement the separate VT-d large page?
Yes, it does introduce redundant code. But unfortunately, IOMMU faults at the moment have to be considered rather risky; having on happens risks (in order of decreasing probability / increasing damage):
* Device stops working for that VM until an FLR (losing a lot of its state)
* The VM has to be killed
* The device stops working until a host reboot
* The host crashes
Quoted 8 lines
Quoted 6 lines
Avoiding these by "hoping" that the guest OS doesn't DMA into a video buffer isn't really robust enough. I think that was Tim and Jan's primary reason for wanting the ability to have separate tables for HAP and IOMMU.
Is that about right, Jan / Tim?
Yes, and not just "about" (perhaps with the exception that I think/ hope we don't have any lurking host crashes here).
I think the fear was that buggy hardware might cause a host crash / hang.
-George
Quoted 27 lines
Quoted 1 line
Quoted 1 line · On 19.05.14 at 15:59, <[email protected]> wrote:
Quoted 25 lines · Jan Beulich
Quoted 25 lines
Quoted 1 line
Quoted 1 line · On 19.05.14 at 15:27, <[email protected]> wrote:
Quoted 1 line · Yang Z
Because I just noticed that someone is asking when Intel will implement the
VT-d page table separately. Actually, I am totally unaware it. The original issue that this patch tries to fix is the VRAM tracking which using the global log dirty mode. And I thought the best solution to fix it is in VRAM side not VT-d side. Because even use separate VT-d page table, we still cannot track the memory update from DMA. Even worse, I think two page tables introduce redundant code and maintain effort. So I wonder is it really necessary to implement the separate VT-d large page?
Yes, it does introduce redundant code. But unfortunately, IOMMU faults at the moment have to be considered rather risky; having on happens risks (in order of decreasing probability / increasing damage):
* Device stops working for that VM until an FLR (losing a lot of its state)
* The VM has to be killed
* The device stops working until a host reboot
* The host crashesAvoiding these by "hoping" that the guest OS doesn't DMA into a video buffer isn't really robust enough. I think that was Tim and Jan's primary reason for wanting the ability to have separate tables for HAP and IOMMU.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Is that about right, Jan / Tim?
Yes, and not just "about" (perhaps with the exception that I think/ hope we don't have any lurking host crashes here).
I think the fear was that buggy hardware might cause a host crash / hang.
That's a valid concern indeed.
Jan
George Dunlap wrote on 2014-05-19:
Quoted 14 lines
Quoted 6 lines
Hi all
Sorry to turn out this old thread.
Because I just noticed that someone is asking when Intel will implement theVT-d page table separately. Actually, I am totally unaware it. The
original issue that this patch tries to fix is the VRAM tracking which
using the global log dirty mode. And I thought the best solution to fix it is in VRAM side not VT-d side. Because even use separate VT-d page table, we still cannot track the
memory update from DMA. Even worse, I think two page tables introduce
redundant code and maintain effort. So I wonder is it really necessary
to implement the separate VT-d large page?
Quoted 2 lines
Yes, it does introduce redundant code. But unfortunately, IOMMU faults at the moment have to be considered rather risky; having on happens
You cannot prevent guest to trigger the IOMMU faults. It is easy to trigger an IOMMU fault by setting a invalid DMA address.
Quoted 7 lines
risks (in order of decreasing probability / increasing damage): * Device stops working for that VM until an FLR (losing a lot of its state) * The VM has to be killed * The device stops working until a host reboot * The host crashes
Avoiding these by "hoping" that the guest OS doesn't DMA into a video buffer isn't really robust enough. I think that was Tim and Jan's
Video buffer is only one case. How we can prevent the DMA to other reserved region?
Quoted 5 lines
primary reason for wanting the ability to have separate tables for HAP and IOMMU.
Is that about right, Jan / Tim?
-George
Best regards,
Yang
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 05:13, <[email protected]> wrote:
George Dunlap wrote on 2014-05-19:
Quoted 2 lines
Avoiding these by "hoping" that the guest OS doesn't DMA into a video buffer isn't really robust enough. I think that was Tim and Jan's
Video buffer is only one case. How we can prevent the DMA to other reserved region?
You continue to neglect the difference: Accessing VRAM this way is legitimate (and potentially useful). And - as just said in the other reply - ideally we'd also simply ignore accesses to reserved regions (and in fact we try to, by not immediately bringing down a guest device doing such).
Jan
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 05:13, <[email protected]> wrote:
George Dunlap wrote on 2014-05-19:
Quoted 2 lines
Avoiding these by "hoping" that the guest OS doesn't DMA into a video buffer isn't really robust enough. I think that was Tim and Jan's
Quoted 8 lines
Quoted 2 lines
Video buffer is only one case. How we can prevent the DMA to other reserved region?
You continue to neglect the difference: Accessing VRAM this way is legitimate (and potentially useful). And - as just said in the other reply - ideally we'd also simply ignore accesses to reserved regions (and in fact we try to, by not immediately bringing down a guest device doing such).
On the other hand, just to play devil's advocate here: Implementing separate IOMMU tables (including superpages) isn't free; it has a non-negligible cost, both in initial developer time, continuing maintenance (code complexity, fixing bugs), extra memory at run-time, &c.
Of all the things we could invest that developer time doing, why should we make it possible to DMA into VRAM, rather than doing something else?
-George
Quoted 22 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 12:12, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 05:13, <[email protected]> wrote:
George Dunlap wrote on 2014-05-19:
Quoted 2 lines
Avoiding these by "hoping" that the guest OS doesn't DMA into a video buffer isn't really robust enough. I think that was Tim and Jan's
Quoted 8 lines
Quoted 2 lines
Video buffer is only one case. How we can prevent the DMA to other reserved region?
You continue to neglect the difference: Accessing VRAM this way is legitimate (and potentially useful). And - as just said in the other reply - ideally we'd also simply ignore accesses to reserved regions (and in fact we try to, by not immediately bringing down a guest device doing such).
On the other hand, just to play devil's advocate here: Implementing separate IOMMU tables (including superpages) isn't free; it has a non-negligible cost, both in initial developer time, continuing maintenance (code complexity, fixing bugs), extra memory at run-time, &c.
Quoted 3 lines
Of all the things we could invest that developer time doing, why should we make it possible to DMA into VRAM, rather than doing something else?
While I agree that the question is valid, my position really is that it was a mistake to implement the IOMMU code without superpage support, i.e. I view this as a shortcoming independent of the VRAM issue, and I would want to see this fixed rather sooner than later. Had it been done properly from the beginning (like one would expect for non-experimental code), a lot of this discussion could have been avoided, and we wouldn't have had to take the respective workaround close to the 4.4 release.
Jan
Jan Beulich wrote on 2014-05-20:
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 12:12, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 05:13, <[email protected]> wrote:
George Dunlap wrote on 2014-05-19:
Quoted 3 lines
Avoiding these by "hoping" that the guest OS doesn't DMA into a video buffer isn't really robust enough. I think that was Tim and Jan's
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Video buffer is only one case. How we can prevent the DMA to other reserved region?
You continue to neglect the difference: Accessing VRAM this way is legitimate (and potentially useful). And - as just said in the other reply - ideally we'd also simply ignore accesses to reserved
Can you give an example of what legitmate case you are mentioned twice(You mentioned it also in other reply)? I cannot understand why we need to restrict the CPU access to VRAM region but allow accessing from device. As I known, for gfx passthrough, both device and CPU are able to access them. And for emulated gfx, only software will access it which same as current we see in Xen.
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
regions (and in fact we try to, by not immediately bringing down a guest device doing such).
On the other hand, just to play devil's advocate here: Implementing separate IOMMU tables (including superpages) isn't free; it has a non-negligible cost, both in initial developer time, continuing maintenance (code complexity, fixing bugs), extra memory at run-time, &c.
Quoted 6 lines
Quoted 3 lines
Of all the things we could invest that developer time doing, why should we make it possible to DMA into VRAM, rather than doing something else?
While I agree that the question is valid, my position really is that it was a mistake to implement the IOMMU code without superpage
We support the superpage via sharing EPT and VT-d pagetable.
Quoted 6 lines
support, i.e. I view this as a shortcoming independent of the VRAM issue, and I would want to see this fixed rather sooner than later. Had it been done properly from the beginning (like one would expect for non-experimental code), a lot of this discussion could have been avoided, and we wouldn't have had to take the respective workaround close to the 4.4 release.
I still think the best solution is fixing the VRAM global log dirty mechanism which my previous patch already did. Because I cannot see any benefit with separating the page table.
Quoted 2 lines
Jan
Best regards,
Yang
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 21.05.14 at 03:02, <[email protected]> wrote:
Jan Beulich wrote on 2014-05-20:
Quoted 11 lines
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 12:12, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 05:13, <[email protected]> wrote:
George Dunlap wrote on 2014-05-19:
Quoted 3 lines
Avoiding these by "hoping" that the guest OS doesn't DMA into a video buffer isn't really robust enough. I think that was Tim and Jan's
Video buffer is only one case. How we can prevent the DMA to other reserved region?
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
You continue to neglect the difference: Accessing VRAM this way is legitimate (and potentially useful). And - as just said in the other reply - ideally we'd also simply ignore accesses to reserved
Can you give an example of what legitmate case you are mentioned twice(You mentioned it also in other reply)?
What's wrong with loading some graphics data right from an I/O device (disk, network) into the frame buffer?
Quoted 2 lines
I cannot understand why we need to
restrict the CPU access to VRAM region but allow accessing from device.
We'd love to also do this for device accesses, but to date IOMMU fault are unrecoverable, and hence this is not an option.
Quoted 4 lines
As I
known, for gfx passthrough, both device and CPU are able to access them. And for emulated gfx, only software will access it which same as current we see in Xen.
Why's that? I.e. why should a guest with emulated graphics not be able to program a passed through device to access the VRAM directly?
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
regions (and in fact we try to, by not immediately bringing down a guest device doing such).
On the other hand, just to play devil's advocate here: Implementing separate IOMMU tables (including superpages) isn't free; it has a non-negligible cost, both in initial developer time, continuing maintenance (code complexity, fixing bugs), extra memory at run-time, &c.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Of all the things we could invest that developer time doing, why should we make it possible to DMA into VRAM, rather than doing something else?
While I agree that the question is valid, my position really is that it was a mistake to implement the IOMMU code without superpage
We support the superpage via sharing EPT and VT-d pagetable.
I.e. without EPT no superpages. Afaict there's no such limitation on the AMD side.
Quoted 10 lines
Quoted 6 lines
support, i.e. I view this as a shortcoming independent of the VRAM issue, and I would want to see this fixed rather sooner than later. Had it been done properly from the beginning (like one would expect for non-experimental code), a lot of this discussion could have been avoided, and we wouldn't have had to take the respective workaround close to the 4.4 release.
I still think the best solution is fixing the VRAM global log dirty mechanism which my previous patch already did. Because I cannot see any benefit with separating the page table.
You didn't in any way negate the condition of superpage support to be added post-4.4 in order for your other change to go in: Neither
http://lists.xenproject.org/archives/html/xen-devel/2014-02/msg01230.html
nor
http://lists.xenproject.org/archives/html/xen-devel/2014-02/msg01236.html
have been responded to by you. By not doing so, to me at least you implicitly accepted the condition. And by now refusing to meet it, you basically tell us that we shouldn't be doing compromises like this with you in the future.
Jan
Jan Beulich wrote on 2014-05-21:
Quoted 18 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 21.05.14 at 03:02, <[email protected]> wrote:
Jan Beulich wrote on 2014-05-20:
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 12:12, <[email protected]> wrote:
On Tue, May 20, 2014 at 8:20 AM, Jan Beulich <[email protected]>
Quoted 13 lines · wrote:
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 05:13, <[email protected]> wrote:
George Dunlap wrote on 2014-05-19:
Quoted 3 lines
Avoiding these by "hoping" that the guest OS doesn't DMA into a video buffer isn't really robust enough. I think that was Tim and Jan's
Video buffer is only one case. How we can prevent the DMA to other reserved region?
You continue to neglect the difference: Accessing VRAM this way is legitimate (and potentially useful). And - as just said in the other reply - ideally we'd also simply ignore accesses to reserved
Quoted 5 lines
Quoted 2 lines
Can you give an example of what legitmate case you are mentioned twice(You mentioned it also in other reply)?
What's wrong with loading some graphics data right from an I/O device (disk, network) into the frame buffer?
Yes, it is ok. But we are talking about the DMA access to a 'readonly' buffer. It is totally a wrong usage model to me.
Quoted 7 lines
Quoted 3 lines
I cannot understand why we need to
restrict the CPU access to VRAM region but allow accessing from device.We'd love to also do this for device accesses, but to date IOMMU fault are unrecoverable, and hence this is not an option.
Quoted 6 lines
Quoted 3 lines
As I known, for gfx passthrough, both device and CPU are able to access them. And for emulated gfx, only software will access it which same as current we see in Xen.
Why's that? I.e. why should a guest with emulated graphics not be able to program a passed through device to access the VRAM directly?
I think you confused the background of the issue: the essence of the issue is that we marked all pages as read-only and meanwhile we allow DMA to access those page. So the right solution is only mark the required page (in this case means VRAM region) as readonly and if guest still DMA to that region, then any unpredictable behavior to that guest is reasonable. What you said before totally ignore the 'read-only' thing. If there is no read-only operation, there will be no problem and no discussion around it.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 3 lines
regions (and in fact we try to, by not immediately bringing down a guest device doing such).
On the other hand, just to play devil's advocate here: Implementing separate IOMMU tables (including superpages) isn't free; it has a non-negligible cost, both in initial developer time, continuing maintenance (code complexity, fixing bugs), extra memory at run-time, &c.
Of all the things we could invest that developer time doing, why should we make it possible to DMA into VRAM, rather than doing something else?
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
While I agree that the question is valid, my position really is that it was a mistake to implement the IOMMU code without superpage
We support the superpage via sharing EPT and VT-d pagetable.
I.e. without EPT no superpages. Afaict there's no such limitation on the AMD side.
I don't think this is a 'limitation'. The original motivation to sharing page table is to use memory efficiently and easy for code maintain. And when we tried to add superpage support, we follow this way (we only need to change one copy of page table). But you think it is a limitation. I cannot understand.
Quoted 12 lines
Quoted 11 lines
Quoted 7 lines
support, i.e. I view this as a shortcoming independent of the VRAM issue, and I would want to see this fixed rather sooner than later. Had it been done properly from the beginning (like one would expect for non-experimental code), a lot of this discussion could have been avoided, and we wouldn't have had to take the respective workaround close to the 4.4 release.
I still think the best solution is fixing the VRAM global log dirty mechanism which my previous patch already did. Because I cannot see any benefit with separating the page table.
Quoted 9 lines
You didn't in any way negate the condition of superpage support to be added post-4.4 in order for your other change to go in: Neither
http://lists.xenproject.org/archives/html/xen-devel/2014-02/msg01230.html
nor
http://lists.xenproject.org/archives/html/xen-devel/2014-02/msg01236.html
have been responded to by you. By not doing so, to me at least you
implicitly accepted the condition. And by now refusing to meet it, you basically tell us that we shouldn't be doing compromises like this with you in the future.
I have said before I am totally unware of it. And I know it only two days ago after someone told me. So please do not confuse this with the thing what we are discussing now. If you think I gave a promise implicitly at that time, I am sorry to let you think so.
As I said in previous thread, if we can prove that add hugepage for the separate VT-d page table is the only choice to solve problem, then now I am promising that I will do it ASAP. But till now, I didn't see any point that we must to have it. To me, it is still a nice to have feature.
Quoted 2 lines
Jan
Best regards,
Yang
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 21.05.14 at 10:37, <[email protected]> wrote:
Jan Beulich wrote on 2014-05-21:
Quoted 18 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 21.05.14 at 03:02, <[email protected]> wrote:
Jan Beulich wrote on 2014-05-20:
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 12:12, <[email protected]> wrote:
On Tue, May 20, 2014 at 8:20 AM, Jan Beulich <[email protected]>
Quoted 13 lines · wrote:
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 05:13, <[email protected]> wrote:
George Dunlap wrote on 2014-05-19:
Quoted 3 lines
Avoiding these by "hoping" that the guest OS doesn't DMA into a video buffer isn't really robust enough. I think that was Tim and Jan's
Video buffer is only one case. How we can prevent the DMA to other reserved region?
You continue to neglect the difference: Accessing VRAM this way is legitimate (and potentially useful). And - as just said in the other reply - ideally we'd also simply ignore accesses to reserved
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Can you give an example of what legitmate case you are mentioned twice(You mentioned it also in other reply)?
What's wrong with loading some graphics data right from an I/O device (disk, network) into the frame buffer?
Yes, it is ok. But we are talking about the DMA access to a 'readonly' buffer. It is totally a wrong usage model to me.
What read-only buffer are you referring to? From guest perspective, nothing that gets marked read-only due to log-dirty handling really is read-only. The fact that migration doesn't work due to this with an assigned device can be excused by the handling of such an assigned device not being implemented anyway. But the fact that behind the scenes VRAM gets marked read-only should be (but isn't) entirely transparent to the guest.
I'm not going to reply to the rest of your mail, both because I'm getting the impression that we're moving in circles, and because I might become impolite otherwise.
Jan
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 21.05.14 at 10:37, <[email protected]> wrote:
Jan Beulich wrote on 2014-05-21:
Quoted 9 lines
You didn't in any way negate the condition of superpage support to be added post-4.4 in order for your other change to go in: Neither
http://lists.xenproject.org/archives/html/xen-devel/2014-02/msg01230.html
nor
http://lists.xenproject.org/archives/html/xen-devel/2014-02/msg01236.html
have been responded to by you. By not doing so, to me at least you
implicitly accepted the condition. And by now refusing to meet it, you basically tell us that we shouldn't be doing compromises like this with you in the future.I have said before I am totally unware of it. And I know it only two days ago after someone told me. So please do not confuse this with the thing what we are discussing now. If you think I gave a promise implicitly at that time, I am sorry to let you think so.
Quoted 4 lines
As I said in previous thread, if we can prove that add hugepage for the separate VT-d page table is the only choice to solve problem, then now I am promising that I will do it ASAP. But till now, I didn't see any point that we must to have it. To me, it is still a nice to have feature.
Btw., I think I just spotted a second thing not working without split page tables: mem-access (which doesn't and imo shouldn't depend on !need_iommu(), other than mem-sharing and mem-paging) likewise has the potential of creating entries resulting in IOMMU faults.
Jan
Jan Beulich wrote on 2014-05-23:
Quoted 23 lines
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 21.05.14 at 10:37, <[email protected]> wrote:
Jan Beulich wrote on 2014-05-21:
Quoted 10 lines
You didn't in any way negate the condition of superpage support to be added post-4.4 in order for your other change to go in: Neither
http://lists.xenproject.org/archives/html/xen-devel/2014-02/msg01230.
html
nor
http://lists.xenproject.org/archives/html/xen-devel/2014-02/msg01236.
html have been responded to by you. By not doing so, to me at least you implicitly accepted the condition. And by now refusing to meet it, you basically tell us that we shouldn't be doing compromises like this with you in the future.I have said before I am totally unware of it. And I know it only two days ago after someone told me. So please do not confuse this with the thing what we are discussing now. If you think I gave a promise implicitly at that time, I am sorry to let you think so.
Quoted 4 lines
As I said in previous thread, if we can prove that add hugepage for
the separate VT-d page table is the only choice to solve problem,
then now I am promising that I will do it ASAP. But till now, I
didn't see any point that we must to have it. To me, it is still a nice to have feature.
Quoted 5 lines
Btw., I think I just spotted a second thing not working without split page tables:
mem-access (which doesn't and imo shouldn't depend on !need_iommu(), other than mem-sharing and mem-paging) likewise has the potential of creating entries resulting in IOMMU faults.
I don't know what mem-access is? Do you mean Xenaccess? If not, can you elaborate it or provide a link to help me to understand how it works?
Quoted 1 line
Jan
Best regards,
Yang
Quoted 27 lines
Quoted 1 line
Quoted 1 line · On 26.05.14 at 10:16, <[email protected]> wrote:
Jan Beulich wrote on 2014-05-23:
Quoted 18 lines
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 21.05.14 at 10:37, <[email protected]> wrote:
Jan Beulich wrote on 2014-05-21:
Quoted 10 lines
You didn't in any way negate the condition of superpage support to be added post-4.4 in order for your other change to go in: Neither
http://lists.xenproject.org/archives/html/xen-devel/2014-02/msg01230.
html
nor
http://lists.xenproject.org/archives/html/xen-devel/2014-02/msg01236.
html have been responded to by you. By not doing so, to me at least you implicitly accepted the condition. And by now refusing to meet it, you basically tell us that we shouldn't be doing compromises like this with you in the future.I have said before I am totally unware of it. And I know it only two days ago after someone told me. So please do not confuse this with the thing what we are discussing now. If you think I gave a promise implicitly at that time, I am sorry to let you think so.
Quoted 4 lines
Quoted 4 lines
As I said in previous thread, if we can prove that add hugepage for the separate VT-d page table is the only choice to solve problem, then now I am promising that I will do it ASAP. But till now, I didn't see any point that we must to have it. To me, it is still a nice to
have feature.
Quoted 2 lines
Btw., I think I just spotted a second thing not working without split page
Quoted 8 lines
tables:
Quoted 4 lines
mem-access (which doesn't and imo shouldn't depend on !need_iommu(), other than mem-sharing and mem-paging) likewise has the potential of creating entries resulting in IOMMU faults.
I don't know what mem-access is? Do you mean Xenaccess? If not, can you elaborate it or provide a link to help me to understand how it works?
The (example) tool indeed is named xen-access. See XENMEM_access_op (used to be HVMOP_{get,set}_mem_access).
Jan
Quoted 33 lines · Jan Beulich
Quoted 33 lines
Quoted 1 line
Quoted 1 line · On 26.05.14 at 10:16, <[email protected]> wrote:
Jan Beulich wrote on 2014-05-23:
Quoted 18 lines
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 21.05.14 at 10:37, <[email protected]> wrote:
Jan Beulich wrote on 2014-05-21:
Quoted 10 lines
You didn't in any way negate the condition of superpage support to be added post-4.4 in order for your other change to go in: Neither
http://lists.xenproject.org/archives/html/xen-devel/2014-02/msg01230.
html
nor
http://lists.xenproject.org/archives/html/xen-devel/2014-02/msg01236.
html have been responded to by you. By not doing so, to me at least you implicitly accepted the condition. And by now refusing to meet it, you basically tell us that we shouldn't be doing compromises like this with you in the future.I have said before I am totally unware of it. And I know it only two days ago after someone told me. So please do not confuse this with the thing what we are discussing now. If you think I gave a promise implicitly at that time, I am sorry to let you think so.
Quoted 4 lines
Quoted 4 lines
As I said in previous thread, if we can prove that add hugepage for the separate VT-d page table is the only choice to solve problem, then now I am promising that I will do it ASAP. But till now, I didn't see any point that we must to have it. To me, it is still a nice to
have feature.
Quoted 2 lines
Btw., I think I just spotted a second thing not working without split page
tables:
Quoted 4 lines
mem-access (which doesn't and imo shouldn't depend on !need_iommu(), other than mem-sharing and mem-paging) likewise has the potential of creating entries resulting in IOMMU faults.
Quoted 6 lines
Quoted 2 lines
I don't know what mem-access is? Do you mean Xenaccess? If not, can you elaborate it or provide a link to help me to understand how it works?
The (example) tool indeed is named xen-access. See
XENMEM_access_op(used to be HVMOP_{get,set}_mem_access).
The tool xen-access is located in tools/tests, and I think that this is used mostly by developers who know what they are doing. If we had separate VT-d page tables, they might observe confusing results; even if they write-protect pages, somebody (i.e. I/O devices) modifies those pages.
To me, observing IOMMU faults seems consistent with the consequence of changes to guest memory permission.
Signature · 2 lines
Jun Intel Open Source Technology Center
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 31.05.14 at 03:26, <[email protected]> wrote:
Quoted 12 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 26.05.14 at 10:16, <[email protected]> wrote:
Jan Beulich wrote on 2014-05-23:
Quoted 1 line
Btw., I think I just spotted a second thing not working without split page
tables:
Quoted 4 lines
mem-access (which doesn't and imo shouldn't depend on !need_iommu(), other than mem-sharing and mem-paging) likewise has the potential of creating entries resulting in IOMMU faults.
I don't know what mem-access is? Do you mean Xenaccess? If not, can you elaborate it or provide a link to help me to understand how it works?
Quoted 6 lines
Quoted 3 lines
The (example) tool indeed is named xen-access. See
XENMEM_access_op(used to be HVMOP_{get,set}_mem_access).The tool xen-access is located in
tools/tests, and I think that this is used mostly by developers who know what they are doing.
The tool is, indeed. But the underlying feature clearly isn't limited to or solely intended for developers.
Quoted 5 lines
If we had separate VT-d page tables, they might observe confusing results; even if they write-protect pages, somebody (i.e. I/O devices) modifies those pages.
To me, observing IOMMU faults seems consistent with the consequence of changes to guest memory permission.
And I would agree if these faults were restartable. You're certainly aware that a not too large amount of faults within a reasonably short period of time will lead to the device being turned off, with quite likely fatal consequences to the guest.
Jan
Quoted 30 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 31.05.14 at 03:26, <[email protected]> wrote:
Quoted 12 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 26.05.14 at 10:16, <[email protected]> wrote:
Jan Beulich wrote on 2014-05-23:
Quoted 1 line
Btw., I think I just spotted a second thing not working without split page
tables:
Quoted 4 lines
mem-access (which doesn't and imo shouldn't depend on !need_iommu(), other than mem-sharing and mem-paging) likewise has the potential of creating entries resulting in IOMMU faults.
I don't know what mem-access is? Do you mean Xenaccess? If not, can you elaborate it or provide a link to help me to understand how it works?
Quoted 6 lines
Quoted 3 lines
The (example) tool indeed is named xen-access. See
XENMEM_access_op(used to be HVMOP_{get,set}_mem_access).The tool xen-access is located in
tools/tests, and I think that this is used mostly by developers who know what they are doing.The tool is, indeed. But the underlying feature clearly isn't limited to or solely intended for developers.
Quoted 5 lines
If we had separate VT-d page tables, they might observe confusing results; even if they write-protect pages, somebody (i.e. I/O devices) modifies those pages.
To me, observing IOMMU faults seems consistent with the consequence of changes to guest memory permission.
Quoted 4 lines
And I would agree if these faults were restartable. You're certainly aware that a not too large amount of faults within a reasonably short period of time will lead to the device being turned off, with quite likely fatal consequences to the guest.
Sure -- but there are a number of features (PoD, paging, page sharing, even migration) which are incompatible with pass-through, and the user is simply not allowed to use them together. Why not just add this one to the list?
-George
Quoted 37 lines
Quoted 1 line
Quoted 1 line · On 02.06.14 at 16:06, <[email protected]> wrote:
Quoted 30 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 31.05.14 at 03:26, <[email protected]> wrote:
Quoted 12 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 26.05.14 at 10:16, <[email protected]> wrote:
Jan Beulich wrote on 2014-05-23:
Quoted 1 line
Btw., I think I just spotted a second thing not working without split page
tables:
Quoted 4 lines
mem-access (which doesn't and imo shouldn't depend on !need_iommu(), other than mem-sharing and mem-paging) likewise has the potential of creating entries resulting in IOMMU faults.
I don't know what mem-access is? Do you mean Xenaccess? If not, can you elaborate it or provide a link to help me to understand how it works?
Quoted 6 lines
Quoted 3 lines
The (example) tool indeed is named xen-access. See
XENMEM_access_op(used to be HVMOP_{get,set}_mem_access).The tool xen-access is located in
tools/tests, and I think that this is used mostly by developers who know what they are doing.The tool is, indeed. But the underlying feature clearly isn't limited to or solely intended for developers.
Quoted 5 lines
If we had separate VT-d page tables, they might observe confusing results; even if they write-protect pages, somebody (i.e. I/O devices) modifies those pages.
To me, observing IOMMU faults seems consistent with the consequence of changes to guest memory permission.Quoted 4 lines
And I would agree if these faults were restartable. You're certainly aware that a not too large amount of faults within a reasonably short period of time will lead to the device being turned off, with quite likely fatal consequences to the guest.
Quoted 4 lines
Sure -- but there are a number of features (PoD, paging, page sharing, even migration) which are incompatible with pass-through, and the user is simply not allowed to use them together. Why not just add this one to the list?
Considering that mem-access came at about the same time or even later than mem-paging and mem-sharing, I was silently assuming that it wasn't enforcing the same restrictions as the other two for a reason. Maybe it was just forgotten...
Jan
Quoted 31 lines · Jan Beulich
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 02.06.14 at 16:06, <[email protected]> wrote:
Quoted 29 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 31.05.14 at 03:26, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 26.05.14 at 10:16, <[email protected]> wrote:
Jan Beulich wrote on 2014-05-23:
Quoted 1 line
Btw., I think I just spotted a second thing not working without split page
tables:
Quoted 4 lines
mem-access (which doesn't and imo shouldn't depend on !need_iommu(), other than mem-sharing and mem-paging) likewise has the potential of creating entries resulting in IOMMU faults.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I don't know what mem-access is? Do you mean Xenaccess? If not, can you elaborate it or provide a link to help me to understand how it works?
The (example) tool indeed is named xen-access. See
XENMEM_access_op(used to be HVMOP_{get,set}_mem_access).The tool xen-access is located in
tools/tests, and I think that this is used mostly by developers who know what they are doing.The tool is, indeed. But the underlying feature clearly isn't limited to or solely intended for developers.
Quoted 5 lines
If we had separate VT-d page tables, they might observe confusing results; even if they write-protect pages, somebody (i.e. I/O devices) modifies those pages.
To me, observing IOMMU faults seems consistent with the consequence of changes to guest memory permission.And I would agree if these faults were restartable. You're certainly aware that a not too large amount of faults within a reasonably short period of time will lead to the device being turned off, with quite likely fatal consequences to the guest.
Quoted 8 lines
Quoted 4 lines
Sure -- but there are a number of features (PoD, paging, page sharing, even migration) which are incompatible with pass-through, and the user is simply not allowed to use them together. Why not just add this one to the list?
Considering that mem-access came at about the same time or even later than mem-paging and mem-sharing, I was silently assuming that it wasn't enforcing the same restrictions as the other two for a reason. Maybe it was just forgotten...
Well one can certainly imagine someone wanting to run it in that mode, and "knowing" that it would be safe because they were going to be careful not going to use memaccess on pages on which a DMA was going to happen. I think in that situation, a developer would probably want to know that their assumption was wrong immediately (by having the IOMMU fault perhaps crash the domain), than have to figure out that their assumption was wrong by having unexplainable results.
If memaccess + passthru is enabled by default at the moment, there may be an argument for disabling it by default, perhaps with an override for those who want the ability to shoot themselves in the foot. But I don't think that silent violations of the memaccess "promise" is better than just having the IOMMU faults; so I don't think that's an argument for implementing non-shared IOMMU superpages.
-George
Quoted 12 lines · Tim Deegan
Quoted 7 lines · Yang Zhang
From: Yang Zhang <[email protected]>
When enabling log dirty mode, it sets all guest's memory to readonly. And in HAP enabled domain, it modifies all EPT entries to clear write bit to make sure it is readonly. This will cause problem if VT-d shares page table with EPT: the device may issue a DMA write request, then VT-d engine tells it the target memory is readonly and result in VT-d fault.
So that's a problem even if only the VGA framebuffer is being tracked -- DMA from a passthrough device will either cause a spurious error or fail to update the dirt bitmap.
Quoted 5 lines
I think it would be better not to allow VT-d and EPT to share pagetables in cases where devices are passed through (i.e. all cases where VT-d is in use).
Tim.
Sadly, this would make shared VT-d/EPT completely pointless as a feature, causing extra memory overhead in Xen by having to maintain EPT and IOMMU tables separately.
Any usecase which doesn't involve dirty vram tracking (e.g. headless VM with SRIOV, PVH dom0) would be adversely affected.
~Andrew
create ^
title it HAP dirty vram tracking breaks pass-through thanks
Quoted 176 lines · Yang Zhang
From: Yang Zhang <[email protected]>
When enabling log dirty mode, it sets all guest's memory to readonly. And in HAP enabled domain, it modifies all EPT entries to clear write bit to make sure it is readonly. This will cause problem if VT-d shares page table with EPT: the device may issue a DMA write request, then VT-d engine tells it the target memory is readonly and result in VT-d fault.
Currnetly, there are two places will enable log dirty mode: migration and vram tracking. Migration with device assigned is not allowed, so it is ok. For vram, it doesn't need to set all memory to readonly. Only track the vram range is enough.
Signed-off-by Yang Zhang <[email protected]>--- xen/arch/x86/mm/hap/hap.c | 20 ++++++++++++++------ xen/arch/x86/mm/paging.c | 9 +++++---- xen/arch/x86/mm/shadow/common.c | 2 +- xen/include/asm-x86/domain.h | 2 +- xen/include/asm-x86/paging.h | 5 +++-- xen/include/asm-x86/shadow.h | 2 +- 6 files changed, 25 insertions(+), 15 deletions(-)xen/arch/x86/mm/hap/hap.c +14
-6@@ -82,7 +82,7 @@ int hap_track_dirty_vram(struct domain *d,if ( !paging_mode_log_dirty (d) ) {hap_logdirty_init (d); - rc =paging_log_dirty_enable (d); + rc =paging_log_dirty_enable (d,0 );if ( rc ) goto out; }@@ -167,17 +167,25 @@ out:/* HAP LOG DIRTY SUPPORT */ /************************************************/ -/* hap code to call when log_dirty is enable. return 0 if no problem found. */ -static int hap_enable_log_dirty (struct domain *d) +/* +* hap code to call when log_dirty is enable. return 0 if no problem found. +* +* NB: Domain that having device assigned should not set log_global. Because +* there is no way to track the memory updating from device. +*/ +static int hap_enable_log_dirty (struct domain *d,bool_t log_global) {/* turn on PG_log_dirty bit in paging mode */ paging_lock (d); d->arch.paging.mode |= PG_log_dirty;paging_unlock (d); -/* set l1e entries of P2M table to be read-only. */ -p2m_change_entry_type_global (d, p2m_ram_rw, p2m_ram_logdirty); -flush_tlb_mask (d->domain_dirty_cpumask); +if ( log_global ) + { +/* set l1e entries of P2M table to be read-only. */ +p2m_change_entry_type_global (d, p2m_ram_rw, p2m_ram_logdirty); +flush_tlb_mask (d->domain_dirty_cpumask); + }return 0 ; }xen/arch/x86/mm/paging.c +5
-4@@ -164,7 +164,7 @@ void paging_free_log_dirty_bitmap(struct domain *d)paging_unlock (d); } -int paging_log_dirty_enable (struct domain *d) +int paging_log_dirty_enable (struct domain *d,bool_t log_global) {int ret;@@ -172,7 +172,7 @@ int paging_log_dirty_enable(struct domain *d)return -EINVAL ;domain_pause (d); - ret = d->arch.paging.log_dirty.enable_log_dirty (d); + ret = d->arch.paging.log_dirty.enable_log_dirty (d, log_global);domain_unpause (d);return ret;@@ -489,7 +489,8 @@ void paging_log_dirty_range(struct domain *d,* These function pointers must not be followed with the log-dirty lock held. */ void paging_log_dirty_init (struct domain *d, -int (*enable_log_dirty)(struct domain *d), +int (*enable_log_dirty)(struct domain *d, +bool_t log_global),int (*disable_log_dirty)(struct domain *d),void (*clean_dirty_bitmap)(struct domain *d)) {@@ -590,7 +591,7 @@ int paging_domctl(struct domain *d, xen_domctl_shadow_op_t *sc,case XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY :if (hap_enabled (d) )hap_logdirty_init (d); -return paging_log_dirty_enable (d); +return paging_log_dirty_enable (d,1 );case XEN_DOMCTL_SHADOW_OP_OFF :if (paging_mode_log_dirty (d) )xen/arch/x86/mm/shadow/common.c +1
-1@@ -3418,7 +3418,7 @@ shadow_write_p2m_entry(struct vcpu *v, unsigned long gfn,/* Shadow specific code which is called in paging_log_dirty_enable(). * Return 0 if no problem found. */ -int shadow_enable_log_dirty (struct domain *d) +int shadow_enable_log_dirty (struct domain *d,bool_t log_global) {int ret;xen/include/asm-x86/domain.h +1
-1@@ -169,7 +169,7 @@ struct log_dirty_domain {unsigned int dirty_count;/* functions which are paging mode specific */ -int (*enable_log_dirty )(struct domain *d); +int (*enable_log_dirty )(struct domain *d,bool_t log_global);int (*disable_log_dirty )(struct domain *d);void (*clean_dirty_bitmap )(struct domain *d); };xen/include/asm-x86/paging.h +3
-2@@ -143,14 +143,15 @@ void paging_log_dirty_range(struct domain *d, uint8_t *dirty_bitmap);/* enable log dirty */ -int paging_log_dirty_enable (struct domain *d); +int paging_log_dirty_enable (struct domain *d,bool_t log_global);/* disable log dirty */ int paging_log_dirty_disable (struct domain *d);/* log dirty initialization */ void paging_log_dirty_init (struct domain *d, -int (*enable_log_dirty)(struct domain *d), +int (*enable_log_dirty)(struct domain *d, +bool_t log_global),int (*disable_log_dirty)(struct domain *d),void (*clean_dirty_bitmap)(struct domain *d));xen/include/asm-x86/shadow.h +1
-2@@ -82,7 +82,7 @@ void shadow_teardown(struct domain *d);void shadow_final_teardown (struct domain *d);/* shadow code to call when log dirty is enabled */ -int shadow_enable_log_dirty (struct domain *d); +int shadow_enable_log_dirty (struct domain *d,bool_t log_global);/* shadow code to call when log dirty is disabled */ int shadow_disable_log_dirty (struct domain *d); --1.7.1
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Processed: Re: [PATCH] Don't track all memory when enabling log dirty to track vram
Processing commands for [email protected]:
Quoted 1 line
create ^
Created new bug #38 rooted at `<[email protected]>'
Title: `Re: [Xen-devel] [PATCH] Don't track all memory when enabling log dirty to track vram'
Quoted 1 line
title it HAP dirty vram tracking breaks pass-through
Set title for #38 to `HAP dirty vram tracking breaks pass-through'
Quoted 1 line
thanks
Finished processing.
Modified/created Bugs:
- 38: http://bugs.xenproject.org/xen/bug/38 (new)
---
Xen Hypervisor Bug Tracker
See http://wiki.xen.org/wiki/Reporting_Bugs_against_Xen for information on reporting bugs Contact [email protected] with any infrastructure issues