VT-d Device-TLB flush issue
v8 cover VT-d Device-TLB flush issue
This patches fix current timeout concern and also allow limited ATS support:
1. Reduce spin timeout to 1ms, which can be boot-time changed with 'vtd_qi_timeout'. For example:
multiboot /boot/xen.gz ... vtd_qi_timeout=100 ...
2. Wrap a _sync version for all VT-d flush interfaces.
For consistency, we wrap a _sync version for all VT-d flush interfaces. It simplifies caller logic and makes code more readable as well.
3. Fix vt-d Device-TLB flush timeout issue.
If Device-TLB flush timed out, we would hide the target ATS device and crash the domain owning this ATS device. If impacted domain is hardware domain, just throw out a warning.
The hidden device should be disallowed to be further assigned to any domain.
**NOTE**
This patch set should base on 2 prereq patch sets:
a). Make the pcidevs_lock a recursive one. b). Check VT-d Device-TLB flush error.
----
Not covered in this series:
a) Eliminate the panic() in IOMMU_WAIT_OP, used only in VT-d register read/write. Further discussion is required on whether and how to improve it.
b) Handle IOTLB/Context/IEC flush timeout.
--Changes in v8:
*Rebase against a6f2cdb633bf519244a16674031b8034b581ba7f.
#patch 1
*Add __must_check annotation.
#patch 2
*It is a new patch that wraps a _sync version for all VT-d flush interfaces.
#patch 3
*Add a blank line between:
+ pcidevs_lock();
+ for_each_pdev(d, pdev)
Quan Xu (3):
VT-d: Reduce spin timeout to 1ms, which can be boot-time changed
VT-d: Wrap a _sync version for all VT-d flush interfaces
VT-d: Fix vt-d Device-TLB flush timeout issue
docs/misc/xen-command-line.markdown | 7 ++ xen/drivers/passthrough/pci.c | 6 +- xen/drivers/passthrough/vtd/extern.h | 3 + xen/drivers/passthrough/vtd/qinval.c | 202 ++++++++++++++++++++++++---------- xen/drivers/passthrough/vtd/x86/ats.c | 15 +-- xen/include/xen/pci.h | 1 + 6 files changed, 165 insertions(+), 69 deletions(-)
Signature · 6 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v8 1/3 VT-d: Reduce spin timeout to 1ms, which can be boot-time changed
--- docs/misc/xen-command-line.markdown | 7 +++++++ xen/drivers/passthrough/vtd/qinval.c | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-)
docs/misc/xen-command-line.markdown +7 -0
@@ -1532,6 +1532,13 @@ Note that if **watchdog** option is also specified vpmu will be turned off. As the virtualisation is not 100% safe, don't use the vpmu flag on production systems (see http://xenbits.xen.org/xsa/advisory-163.html)! +### vtd\_qi\_timeout (VT-d) +> `= <integer>` + +> Default: `1` + +Specify the timeout of the VT-d Queued Invalidation in milliseconds. + ### watchdog > `= force | <boolean>`
xen/drivers/passthrough/vtd/qinval.c +12 -5
@@ -28,6 +28,11 @@#include "vtd.h" #include "extern.h" +static unsigned int __read_mostly vtd_qi_timeout =1 ; +integer_param ("vtd_qi_timeout" , vtd_qi_timeout); + +#define IOMMU_QI_TIMEOUT (vtd_qi_timeout * MILLISECS(1)) +static void print_qi_regs (struct iommu *iommu) {u64 val;
@@ -130,10 +135,10 @@ static void queue_invalidate_iotlb(struct iommu *iommu,spin_unlock_irqrestore (&iommu->register_lock, flags); } -static int queue_invalidate_wait (struct iommu *iommu, +static int __must_check queue_invalidate_wait (struct iommu *iommu,u8 iflag,u8 sw,u8 fn) { -s_time_t start_time; +s_time_t timeout;volatile u32 poll_slot =QINVAL_STAT_INIT ;unsigned int index;unsigned long flags;
@@ -164,13 +169,15 @@ static int queue_invalidate_wait(struct iommu *iommu,if ( sw ) {/* In case all wait descriptor writes to same addr with same data */ - start_time =NOW (); + timeout =NOW () +IOMMU_QI_TIMEOUT ;while ( poll_slot !=QINVAL_STAT_DONE ) { -if (NOW () > (start_time +DMAR_OPERATION_TIMEOUT ) ) +if (NOW () > timeout ) {print_qi_regs (iommu); -panic ("queue invalidate wait descriptor was not executed" ); + printk(XENLOG_WARNING VTDPREFIX + "Queue invalidate wait descriptor timed out.\n"); +return -ETIMEDOUT ; }cpu_relax (); }
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v8 1/3] VT-d: Reduce spin timeout to 1ms, which can be boot-time changed
Quoted 9 lines · Quan Xu
docs/misc/xen-command-line.markdown +0
-0@@ -1532,6 +1532,13 @@ Note that if **watchdog** option is alsospecified vpmu will be turned off.
As the virtualisation is not 100% safe, don't use the vpmu flag on production systems (see http://xenbits.xen.org/xsa/advisory-163.html
)!
docs/misc/xen-command-line.markdown Note that if **watchdog** option is also specified vpmu will be turned off. · line 1541
Quoted 7 lines
docs/misc/xen-command-line.markdown +7
-0+### vtd\_qi\_timeout (VT-d) +> `= <integer>` + +> Default: `1` + +Specify the timeout of the VT-d Queued Invalidation in milliseconds. +
Perhaps we should put down a quick paragraph to explain what this parameter is about, and what happens if the timeout expires?
Giving hints on under what conditions one should change this value would be even more welcome (e.g. "if you see error XXX, try increasing the timeout to nnn").
Quoted 11 lines
xen/drivers/passthrough/vtd/qinval.c +0
-0xen/drivers/passthrough/vtd/qinval.c +0
-0@@ -130,10 +135,10 @@ static void queue_invalidate_iotlb(struct iommu *iommu, spin_unlock_irqrestore(&iommu->register_lock, flags); }xen/drivers/passthrough/vtd/qinval.c +1
-1-static int queue_invalidate_wait(struct iommu *iommu, +static int __must_check queue_invalidate_wait(struct iommu *iommu,
Quoted 3 lines
u8 iflag, u8 sw, u8 fn)
{
I'm not sure it is ok to add the __must_check annotation here in this patch, considering that the subject says "VT-d: Reduce spin timeout to 1ms, which can be boot-time changed", and there is no changelog.
Personally, I think it could be ok, but at least add a few words of changelog, mentioning that this is also being done.
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 1/3] VT-d: Reduce spin timeout to 1ms, which can be boot-time changed
Quoted 20 lines · On March 24, 2016 7:04pm, <[email protected]> wrote:
Quoted 9 lines · Quan Xu
docs/misc/xen-command-line.markdown +0
-0@@ -1532,6 +1532,13 @@ Note that if **watchdog** option is alsospecified vpmu will be turned off.
As the virtualisation is not 100% safe, don't use the vpmu flag on production systems (see http://xenbits.xen.org/xsa/advisory-163.html
)!docs/misc/xen-command-line.markdown Note that if **watchdog** option is also specified vpmu will be turned off. · line 1541
Quoted 7 lines
docs/misc/xen-command-line.markdown +7
-0+### vtd\_qi\_timeout (VT-d) +> `= <integer>` + +> Default: `1` + +Specify the timeout of the VT-d Queued Invalidation in milliseconds. +Perhaps we should put down a quick paragraph to explain what this parameter is about, and what happens if the timeout expires?
Quoted 4 lines
Giving hints on under what conditions one should change this value would be even more welcome (e.g. "if you see error XXX, try increasing the timeout to nnn").
Make sense. I would send out this paragraph before v9. I hope you could help me correct it. :)
Quoted 18 lines
Quoted 4 lines
xen/drivers/passthrough/vtd/qinval.c static void queue_invalidate_iotlb(struct iommu · line 143
Quoted 10 lines
xen/drivers/passthrough/vtd/qinval.c +1
-1@@ -130,10 +135,10 @@ static void queue_invalidate_iotlb(struct iommu *iommu, spin_unlock_irqrestore(&iommu->register_lock, flags); } -static int queue_invalidate_wait (struct iommu *iommu, +static int __must_check queue_invalidate_wait (struct iommu *iommu, u8 iflag, u8 sw, u8 fn) {I'm not sure it is ok to add the
__must_checkannotation here in this patch, considering that the subject says "VT-d: Reduce spin timeout to 1ms, which can be boot-time changed", and there is no changelog.
Quoted 3 lines
Personally, I think it could be ok, but at least add a few words of changelog, mentioning that this is also being done.
Thanks for your reminding. It's better to add a few words of changelog.
Quan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 1/3] VT-d: Reduce spin timeout to 1ms, which can be boot-time changed
In reply to Quan XuOn Thu, Mar 24, 2016 at 01:57:58PM +0800, Quan Xu wrote:
Hey!
Thanks for the patch!
I see that you have __must_check..
But if you check the callchain:
iommu_flush_iec_[index|global] ->
__iommu_flush_iec->invalidate_sync-> queue_invalidate_wait
you will see that the callers of iommu_flush_iec_[index|global] ignore the return value.
So ... perhaps you could explain in this commit description on how to address that? Is there an followup patch (if so just put in the name in here) to address that?
Or should the top callers: enable_intremap, ioapic_rte_to_remap_entry, free_remap_entry, msi_msg_to_remap_entry, and pi_update_irte do something?
I guess the 'free_remap_entry' reall can't. As you are suppose to always be able to free something.
msi_msg_to_remap_entry, _msg_to_remap_entry, and ioapic_rte_to_remap_entry could return an value... Or considering this is v8 - was there some epic conversation that went over this quite a lot? In which case I would recommend you say why it was not attempted this way so that folks six months from now when reading this patch won't ask again.
Quoted 80 lines
Signed-off-by Quan Xu <[email protected]>--- docs/misc/xen-command-line.markdown | 7 +++++++ xen/drivers/passthrough/vtd/qinval.c | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-)docs/misc/xen-command-line.markdown +7
-0@@ -1532,6 +1532,13 @@ Note that if **watchdog** option is also specified vpmu will be turned off. As the virtualisation is not 100% safe, don't use the vpmu flag on production systems (see http://xenbits.xen.org/xsa/advisory-163.html)! +### vtd\_qi\_timeout (VT-d) +> `= <integer>` + +> Default: `1` + +Specify the timeout of the VT-d Queued Invalidation in milliseconds. + ### watchdog > `= force | <boolean>`xen/drivers/passthrough/vtd/qinval.c +12
-5@@ -28,6 +28,11 @@#include "vtd.h" #include "extern.h" +static unsigned int __read_mostly vtd_qi_timeout =1 ; +integer_param ("vtd_qi_timeout" , vtd_qi_timeout); + +#define IOMMU_QI_TIMEOUT (vtd_qi_timeout * MILLISECS(1)) +static void print_qi_regs (struct iommu *iommu) {u64 val;@@ -130,10 +135,10 @@ static void queue_invalidate_iotlb(struct iommu *iommu,spin_unlock_irqrestore (&iommu->register_lock, flags); } -static int queue_invalidate_wait (struct iommu *iommu, +static int __must_check queue_invalidate_wait (struct iommu *iommu,u8 iflag,u8 sw,u8 fn) { -s_time_t start_time; +s_time_t timeout;volatile u32 poll_slot =QINVAL_STAT_INIT ;unsigned int index;unsigned long flags;@@ -164,13 +169,15 @@ static int queue_invalidate_wait(struct iommu *iommu,if ( sw ) {/* In case all wait descriptor writes to same addr with same data */ - start_time =NOW (); + timeout =NOW () +IOMMU_QI_TIMEOUT ;while ( poll_slot !=QINVAL_STAT_DONE ) { -if (NOW () > (start_time +DMAR_OPERATION_TIMEOUT ) ) +if (NOW () > timeout ) {print_qi_regs (iommu); -panic ("queue invalidate wait descriptor was not executed" ); + printk(XENLOG_WARNING VTDPREFIX + "Queue invalidate wait descriptor timed out.\n"); +return -ETIMEDOUT ; }cpu_relax (); }Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 1/3] VT-d: Reduce spin timeout to 1ms, which can be boot-time changed
Quoted 10 lines · Konrad Rzeszutek Wilk
On Thu, Mar 24, 2016 at 01:57:58PM +0800, Quan Xu wrote:
Hey!
Thanks for the patch!
I see that you have
__must_check..But if you check the callchain:
Quoted 8 lines
iommu_flush_iec_[index|global] ->
__iommu_flush_iec->invalidate_sync-> queue_invalidate_waityou will see that the callers of iommu_flush_iec_[index|global] ignore the return value.
So ... perhaps you could explain in this commit description on how to address that?
I mentioned it in 0000-cover-letter.patch -- "Not covered in this series:". IMO, it is not a good idea to explain in this commit description, as I don't touch it. Right?
Quoted 3 lines
Is there an followup patch (if so just put in the name in here) to address that?
Yes,
Quoted 4 lines
Or should the top callers:
enable_intremap,ioapic_rte_to_remap_entry,free_remap_entry,msi_msg_to_remap_entry, andpi_update_irtedo something?
I'd prefer to discuss about it in another thread. btw, I have spent a lot of time on
Interrupt research, including the logical topology of interrupt hardware/software, .e.g, lapci/vlapic/ioapic/vioapic/msi/PI. In last months, I wondered whether I could disable the interrupt remapping dynamically( by 'iommu_intremap = 0') or not. Now I think it would be insecure.
IMO, it is not a good time to discuss this new topic, otherwise it makes me exhausted.
Quan
Quoted 98 lines
I guess the '
free_remap_entry' reall can't. As you are suppose to always be able to free something.
msi_msg_to_remap_entry,_msg_to_remap_entry, andioapic_rte_to_remap_entrycould return an value... Or considering this is v8 - was there some epic conversation that went over this quite a lot? In which case I would recommend you say why it was not attempted this way so that folks six months from now when reading this patch won't ask again.docs/misc/xen-command-line.markdown Note that if **watchdog** option is also
Quoted 12 lines
Signed-off-by Quan Xu <[email protected]>--- docs/misc/xen-command-line.markdown | 7 +++++++ xen/drivers/passthrough/vtd/qinval.c | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-)docs/misc/xen-command-line.markdown +0
-0@@ -1532,6 +1532,13 @@ Note that if **watchdog** option is alsospecified vpmu will be turned off.
xen/drivers/passthrough/vtd/qinval.c static void queue_invalidate_iotlb(struct iommu
Quoted 30 lines
docs/misc/xen-command-line.markdown +0
-0As the virtualisation is not 100% safe, don't use the vpmu flag onproduction systems (see http://xenbits.xen.org/xsa/advisory-163.html)!
docs/misc/xen-command-line.markdown +7
-0+### vtd\_qi\_timeout (VT-d) +> `= <integer>` + +> Default: `1` + +Specify the timeout of the VT-d Queued Invalidation in milliseconds. + ### watchdog > `= force | <boolean>`xen/drivers/passthrough/vtd/qinval.c +5
-0@@ -28,6 +28,11 @@#include "vtd.h" #include "extern.h" +static unsigned int __read_mostly vtd_qi_timeout =1 ; +integer_param ("vtd_qi_timeout" , vtd_qi_timeout); + +#define IOMMU_QI_TIMEOUT (vtd_qi_timeout * MILLISECS(1)) +static void print_qi_regs (struct iommu *iommu) {u64 val;@@ -130,10 +135,10 @@ static void queue_invalidate_iotlb(struct iommu*iommu,
xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_wait(struct iommu
Quoted 12 lines
xen/drivers/passthrough/vtd/qinval.c +2
-2spin_unlock_irqrestore (&iommu->register_lock, flags); } -static int queue_invalidate_wait (struct iommu *iommu, +static int __must_check queue_invalidate_wait (struct iommu *iommu,u8 iflag,u8 sw,u8 fn) { -s_time_t start_time; +s_time_t timeout;volatile u32 poll_slot =QINVAL_STAT_INIT ;unsigned int index;unsigned long flags;@@ -164,13 +169,15 @@ static int queue_invalidate_wait(struct iommu*iommu,
xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_wait(struct iommu *iommu,
Quoted 3 lines
xen/drivers/passthrough/vtd/qinval.c +0
-0if ( sw ) {/* In case all wait descriptor writes to same addr with same data */
xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_wait(struct iommu *iommu,
Quoted 9 lines
xen/drivers/passthrough/vtd/qinval.c +2
-3- start_time =NOW (); + timeout =NOW () +IOMMU_QI_TIMEOUT ;while ( poll_slot !=QINVAL_STAT_DONE ) { -if (NOW () > (start_time +DMAR_OPERATION_TIMEOUT ) ) +if (NOW () > timeout ) {print_qi_regs (iommu); - panic("queue invalidate wait descriptor was notexecuted");
xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_wait(struct iommu · line 179
Quoted 2 lines
xen/drivers/passthrough/vtd/qinval.c +2
-0+ printk(XENLOG_WARNING VTDPREFIX + "Queue invalidate wait descriptor timedout.\n");
Quoted 8 lines
xen/drivers/passthrough/vtd/qinval.c +1
-1+return -ETIMEDOUT ; }cpu_relax (); } --1.9.1
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 1/3] VT-d: Reduce spin timeout to 1ms, which can be boot-time changed
Quoted 14 lines · Quan
Quoted 13 lines · Konrad Rzeszutek Wilk
On Thu, Mar 24, 2016 at 01:57:58PM +0800, Quan Xu wrote:
Hey!
Thanks for the patch!
I see that you have
__must_check..But if you check the callchain:
iommu_flush_iec_[index|global] ->
__iommu_flush_iec->invalidate_sync-> queue_invalidate_wait
Quoted 7 lines
Quoted 5 lines
you will see that the callers of iommu_flush_iec_[index|global] ignore the return value.
So ... perhaps you could explain in this commit description on how to address that?
I mentioned it in 0000-cover-letter.patch -- "Not covered in this series:".
But that goodness never gets documented in the code..
Quoted 2 lines
IMO, it is not a good idea to explain in this commit description, as I don't touch it. Right?
Why?
Put yourself in the shoes of a an engineer who wants to fix or add some code.
He or she will look at the code and say: Ok, they added __mustcheck so they MUST have thought it is important to check the return code. But then tracking through the different users and then it is ignored two or three levels up.
Huh? Why didn't the account for that?
If you include that information in the description it will save them further work from having to guess or email you.
Quoted 5 lines
Quoted 4 lines
Is there an followup patch (if so just put in the name in here) to address that?
Yes,
In which case I would just say that:
"The followup patch titled XYZ addresses the __mustcheck. That is the other callers of this routine (two or three levels up) ignore the return code. This patch does not address this but the other does."
And that
Quoted 11 lines
Quoted 5 lines
Or should the top callers:
enable_intremap,ioapic_rte_to_remap_entry,free_remap_entry,msi_msg_to_remap_entry, andpi_update_irtedo something?I'd prefer to discuss about it in another thread. btw, I have spent a lot of time on
Interrupt research, including the logical topology of interrupt hardware/software, .e.g, lapci/vlapic/ioapic/vioapic/msi/PI. In last months, I wondered whether I could disable the interrupt remappingdynamically( by 'iommu_intremap = 0')or not. Now I think it would be insecure.
IMO, it is not a good time to discuss this new topic, otherwise it makes me exhausted.
<grins>
I would recommend you send out an email to xen-devel with [BRAINSTORM] or such to explain the problem or ways to make it work. That way we can all benefit from your hard digging in the code and untangling it.
Or if you can - be at the Xen Hackathon in April to brainstorm this in person?
Quoted 105 lines
Quan
Quoted 102 lines
I guess the '
free_remap_entry' reall can't. As you are suppose to always be able to free something.
msi_msg_to_remap_entry,_msg_to_remap_entry, andioapic_rte_to_remap_entrycould return an value... Or considering this is v8 - was there some epic conversation that went over this quite a lot? In which case I would recommend you say why it was not attempted this way so that folks six months from now when reading this patch won't ask again.docs/misc/xen-command-line.markdown Note that if **watchdog** option is also
Quoted 12 lines
Signed-off-by Quan Xu <[email protected]>--- docs/misc/xen-command-line.markdown | 7 +++++++ xen/drivers/passthrough/vtd/qinval.c | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-)docs/misc/xen-command-line.markdown +0
-0@@ -1532,6 +1532,13 @@ Note that if **watchdog** option is alsospecified vpmu will be turned off.
xen/drivers/passthrough/vtd/qinval.c static void queue_invalidate_iotlb(struct iommu
Quoted 30 lines
docs/misc/xen-command-line.markdown +0
-0As the virtualisation is not 100% safe, don't use the vpmu flag onproduction systems (see http://xenbits.xen.org/xsa/advisory-163.html)!
docs/misc/xen-command-line.markdown +7
-0+### vtd\_qi\_timeout (VT-d) +> `= <integer>` + +> Default: `1` + +Specify the timeout of the VT-d Queued Invalidation in milliseconds. + ### watchdog > `= force | <boolean>`xen/drivers/passthrough/vtd/qinval.c +5
-0@@ -28,6 +28,11 @@#include "vtd.h" #include "extern.h" +static unsigned int __read_mostly vtd_qi_timeout =1 ; +integer_param ("vtd_qi_timeout" , vtd_qi_timeout); + +#define IOMMU_QI_TIMEOUT (vtd_qi_timeout * MILLISECS(1)) +static void print_qi_regs (struct iommu *iommu) {u64 val;@@ -130,10 +135,10 @@ static void queue_invalidate_iotlb(struct iommu*iommu,
xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_wait(struct iommu
Quoted 12 lines
xen/drivers/passthrough/vtd/qinval.c +2
-2spin_unlock_irqrestore (&iommu->register_lock, flags); } -static int queue_invalidate_wait (struct iommu *iommu, +static int __must_check queue_invalidate_wait (struct iommu *iommu,u8 iflag,u8 sw,u8 fn) { -s_time_t start_time; +s_time_t timeout;volatile u32 poll_slot =QINVAL_STAT_INIT ;unsigned int index;unsigned long flags;@@ -164,13 +169,15 @@ static int queue_invalidate_wait(struct iommu*iommu,
xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_wait(struct iommu *iommu,
Quoted 3 lines
xen/drivers/passthrough/vtd/qinval.c +0
-0if ( sw ) {/* In case all wait descriptor writes to same addr with same data */
xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_wait(struct iommu *iommu,
Quoted 9 lines
xen/drivers/passthrough/vtd/qinval.c +2
-3- start_time =NOW (); + timeout =NOW () +IOMMU_QI_TIMEOUT ;while ( poll_slot !=QINVAL_STAT_DONE ) { -if (NOW () > (start_time +DMAR_OPERATION_TIMEOUT ) ) +if (NOW () > timeout ) {print_qi_regs (iommu); - panic("queue invalidate wait descriptor was notexecuted");
xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_wait(struct iommu · line 179
Quoted 2 lines
xen/drivers/passthrough/vtd/qinval.c +2
-0+ printk(XENLOG_WARNING VTDPREFIX + "Queue invalidate wait descriptor timedout.\n");
Quoted 8 lines
xen/drivers/passthrough/vtd/qinval.c +1
-1+return -ETIMEDOUT ; }cpu_relax (); } --1.9.1
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 1/3] VT-d: Reduce spin timeout to 1ms, which can be boot-time changed
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 1 line · Quan
On March 26, 2016 4:07am, Konrad Rzeszutek Wilk <[email protected]>
Quoted 1 line · wrote:
Quoted 1 line · Quan Xu
<grins>
<grins> DX
Quoted 1 line
I would recommend you send out an email to xen-devel with [BRAINSTORM] or
Yes, I will do it.
Quoted 5 lines
such to explain the problem or ways to make it work.
That way we can all benefit from your hard digging in the code and untangling it.Or if you can - be at the Xen Hackathon in April to brainstorm this in person?
I would be very happy, if I can have a f2f discussion with you, Jan, Dario, Wei, Daniel, Stefano ... But sorry, I can't. I have the problems with my passport. I am in Shanghai China now.
Quan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v8 2/3 VT-d: Wrap a _sync version for all VT-d flush interfaces
In reply to Quan XuFor consistency, we wrap a _sync version for all VT-d flush interfaces. It simplifies caller logic and makes code more readable as well.
--- xen/drivers/passthrough/vtd/extern.h | 2 + xen/drivers/passthrough/vtd/qinval.c | 173 ++++++++++++++++++++-------------- xen/drivers/passthrough/vtd/x86/ats.c | 12 +-- 3 files changed, 106 insertions(+), 81 deletions(-)
xen/drivers/passthrough/vtd/extern.h +2 -0
@@ -61,6 +61,8 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did,int qinval_device_iotlb (struct iommu *iommu,u32 max_invs_pend,u16 sid,u16 size,u64 addr); +int qinval_device_iotlb_sync (struct iommu *iommu,u32 max_invs_pend, +u16 sid,u16 size,u64 addr);unsigned int get_cache_line_size (void );void cacheline_flush (char *);
xen/drivers/passthrough/vtd/qinval.c +100 -73
236 lines not on this page · raw message
xen/drivers/passthrough/vtd/x86/ats.c +4 -8
@@ -118,7 +118,6 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did, {u16 sid =PCI_BDF2 (pdev->bus, pdev->devfn);bool_t sbit; -int rc =0 ;/* Only invalidate devices that belong to this IOMMU */ if ( pdev->iommu != iommu )
@@ -134,8 +133,8 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did,/* invalidate all translations: sbit=1,bit_63=0,bit[62:12]=1 */ sbit =1 ; addr = (~0UL <<PAGE_SHIFT_4K ) &0x7FFFFFFFFFFFFFFF ; - rc =qinval_device_iotlb (iommu, pdev->ats_queue_depth, - sid, sbit, addr); + ret =qinval_device_iotlb_sync (iommu, pdev->ats_queue_depth, + sid, sbit, addr);break ;case DMA_TLB_PSI_FLUSH :if ( !device_in_domain (iommu, pdev, did) )
@@ -154,16 +153,13 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did, addr |= (((u64 )1 << (size_order -1 )) -1 ) <<PAGE_SHIFT_4K ; } - rc =qinval_device_iotlb (iommu, pdev->ats_queue_depth, - sid, sbit, addr); + ret =qinval_device_iotlb_sync (iommu, pdev->ats_queue_depth, + sid, sbit, addr);break ;default : dprintk(XENLOG_WARNING VTDPREFIX, "invalid vt-d flush type\n");return -EOPNOTSUPP ; } - -if ( !ret ) - ret = rc; }return ret;
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v8 2/3] VT-d: Wrap a _sync version for all VT-d flush interfaces
Quoted 3 lines · Quan Xu
For consistency, we wrap a
_syncversion for all VT-d flush interfaces.
I'm sorry, maybe it's me, but "for consistency" with what?
I see from where this comes, if I look at v7. But when this patch will be committed, what it is doing and why we decided to do it should be evident by just reading the changelog, without having to google for the review history.
So, please, try to describe the situation a little bit better (e.g., do we have inconsistencies, right now? Is this needed for avoiding introducing inconsistencies by means of this series? Etc.).
xen/drivers/passthrough/vtd/qinval.c static void qinval_update_qtail(struct iommu *iommu, unsigned int index) · line 77
Quoted 12 lines
xen/drivers/passthrough/vtd/qinval.c +0
-0@@ -72,6 +72,70 @@ static void qinval_update_qtail(struct iommu *iommu, unsigned int index)dmar_writeq(iommu->reg,
DMAR_IQT_REG, (val <<QINVAL_INDEX_SHIFT));
}xen/drivers/passthrough/vtd/qinval.c +3
-0+static int __must_check queue_invalidate_wait (struct iommu *iommu, + u8 iflag, u8 sw, u8 fn) +{
It looks like you are "just" moving this function, without making any change to the code, is this the case?
Assuming it is, mixing pure code movement and functional changes in the same patch makes reviewing the patch itself harder. And pure code motio is also bad for archaeologists (`git blame' would point at this commit for all of this function!).
So, I'd say either isolate the code movement in a pre-patch, or try using forward declarations. Given how moving messes up history, my personal preference would be for the latter.
xen/drivers/passthrough/vtd/qinval.c static void qinval_update_qtail(struct iommu *iommu, unsigned int index) · line 137
Quoted 9 lines
xen/drivers/passthrough/vtd/qinval.c +9
-0+static int invalidate_sync (struct iommu *iommu) +{ + struct qi_ctrl *qi_ctrl = iommu_qi_ctrl(iommu); + + if ( qi_ctrl->qinval_maddr ) + return queue_invalidate_wait(iommu, 0, 1, 1); + + return 0; +}
Same for this, even worse, in terms of how hard this makes to review this patch, as can be seen...
Quoted 9 lines
xen/drivers/passthrough/vtd/qinval.c +3
-2@@ -135,65 +208,12 @@ static void queue_invalidate_iotlb(struct iommu *iommu, -static int invalidate_sync(struct iommu *iommu) +static int queue_invalidate_iotlb_sync(struct iommu *iommu, + u8 granu, u8 dr, u8 dw, u16 did, u8 am, u8 ih, u64 addr) { - struct qi_ctrl *qi_ctrl = iommu_qi_ctrl(iommu); + queue_invalidate_iotlb(iommu, granu, dr, dw, did, am, ih, addr);
Quoted 7 lines
- if (qi_ctrl->qinval_maddr)
- returnqueue_invalidate_wait(iommu, 0, 1, 1); - return 0;
+ returninvalidate_sync(iommu);
}
...here!
The rest of this patch looks fine to me, with only one more doubt. Here:
Quoted 35 lines
xen/drivers/passthrough/vtd/x86/ats.c +0
-1@@ -118,7 +118,6 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did, { u16 sid = PCI_BDF2(pdev->bus, pdev->devfn); bool_t sbit; - int rc = 0;
/* Only invalidate devices that belong to this IOMMU */ if (pdev->iommu!= iommu )xen/drivers/passthrough/vtd/x86/ats.c +0
-0@@ -134,8 +133,8 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did, /* invalidate all translations:sbit=1,bit_63=0,bit[62:12]=1 */
sbit = 1;
addr = (~0UL <<PAGE_SHIFT_4K) &0x7FFFFFFFFFFFFFFF; - rc = qinval_device_iotlb(iommu,pdev->ats_queue_depth, - sid, sbit, addr); + ret = qinval_device_iotlb_sync(iommu, pdev-Quoted 1 line
ats_queue_depth,+ sid, sbit, addr); break;
caseDMA_TLB_PSI_FLUSH:
if ( !device_in_domain(iommu, pdev, did) )xen/drivers/passthrough/vtd/x86/ats.c +0
-0@@ -154,16 +153,13 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did,addr |= (((u64)1 << (
size_order- 1)) - 1) <<PAGE_SHIFT_4K;
}
- rc = qinval_device_iotlb(iommu,pdev->ats_queue_depth, - sid, sbit, addr); + ret = qinval_device_iotlb_sync(iommu, pdev-Quoted 1 line
ats_queue_depth,
Quoted 14 lines
+ sid, sbit, addr); break;
default:
dprintk(XENLOG_WARNING VTDPREFIX, "invalid vt-d flush type\n");
return-EOPNOTSUPP;
}
-
- if ( !ret )
- ret = rc;
}
return ret;
Am I misreading something or we are introducing synchronous handling, which was not there before?
If yes, is it ok to do this in this patch?
And if yes again, I think that it at least should be noted in the changelog, as it would mean that the patch is not only introducing some wrappers.
Regads,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 2/3] VT-d: Wrap a _sync version for all VT-d flush interfaces
Quoted 46 lines · Dario Faggioli
Quoted 28 lines · Quan Xu
(quoted diff) +0
-0@@ -134,8 +133,8 @@ int dev_invalidate_iotlb(struct iommu *iommu,u16
did,
/* invalidate all translations:
sbit=1,bit_63=0,bit[62:12]=1 */
sbit = 1;
addr = (~0UL <<PAGE_SHIFT_4K) &0x7FFFFFFFFFFFFFFF; - rc = qinval_device_iotlb(iommu,pdev->ats_queue_depth, - sid, sbit, addr); + ret = qinval_device_iotlb_sync(iommu, pdev-Quoted 2 lines
ats_queue_depth,+ sid, sbit, addr); break;
caseDMA_TLB_PSI_FLUSH:
if ( !device_in_domain(iommu, pdev, did) )(quoted diff) +0
-0@@ -154,16 +153,13 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did,addr |= (((u64)1 << (
size_order- 1)) - 1) <<PAGE_SHIFT_4K;
}
- rc = qinval_device_iotlb(iommu,pdev->ats_queue_depth, - sid, sbit, addr); + ret = qinval_device_iotlb_sync(iommu, pdev-Quoted 2 lines
ats_queue_depth,Quoted 14 lines
+ sid, sbit, addr); break;
default:
dprintk(XENLOG_WARNING VTDPREFIX, "invalid vt-d flush type\n");
return-EOPNOTSUPP;
}
-
- if ( !ret )
- ret = rc;
}
return ret;Am I misreading something or we are introducing synchronous handling, which was not there before?
Quoted 7 lines
If yes, is it ok to do this in this patch?
And if yes again, I think that it at least should be noted in the changelog, as it would mean that the patch is not only introducing some
wrappers.
Ok, I think I see what's happening here. Before this patch, invalidate_sync() was being called inside qinval_device_iotlb(), so we were synchronous already, and we need to continue to be like that, by calling the _sync() variants.
Yes, if this is what happens, this also looks ok to me.
Sorry for the noise.
Regards,
Dario
Quoted 6 lines
Regads,
Dario
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 2/3] VT-d: Wrap a _sync version for all VT-d flush interfaces
Quoted 52 lines · On March 24, 2016 11:06pm, <[email protected]> wrote:
Quoted 13 lines · Dario Faggioli
Quoted 12 lines · Quan Xu
(quoted diff) +0
-0@@ -134,8 +133,8 @@ int dev_invalidate_iotlb(struct iommu *iommu,u16
did,
/* invalidate all translations:
sbit=1,bit_63=0,bit[62:12]=1 */
sbit = 1;
addr = (~0UL <<PAGE_SHIFT_4K) &0x7FFFFFFFFFFFFFFF; - rc = qinval_device_iotlb(iommu,pdev->ats_queue_depth, - sid, sbit, addr); + ret = qinval_device_iotlb_sync(iommu, pdev-Quoted 1 line
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
ats_queue_depth,+ sid, sbit,
addr);
Quoted 9 lines
Quoted 9 lines
break;
caseDMA_TLB_PSI_FLUSH:
if ( !device_in_domain(iommu, pdev, did) ) @@ -154,16 +153,13 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did,
addr |= (((u64)1 << (size_order- 1)) - 1) <<PAGE_SHIFT_4K;
}Quoted 6 lines
Quoted 6 lines
- rc = qinval_device_iotlb(iommu,
pdev->ats_queue_depth, - sid, sbit, addr); + ret = qinval_device_iotlb_sync(iommu, pdev-Quoted 2 lines
ats_queue_depth,+ sid, sbit,
addr);
Quoted 3 lines
Quoted 3 lines
break;
default:
dprintk(XENLOG_WARNING VTDPREFIX, "invalid vt-dflush
Quoted 15 lines
Quoted 10 lines
type\n");
return-EOPNOTSUPP;
}
-
- if ( !ret )
- ret = rc;
}return ret;
Am I misreading something or we are introducing synchronous handling, which was not there before?
If yes, is it ok to do this in this patch?
Quoted 9 lines
Quoted 4 lines
And if yes again, I think that it at least should be noted in the changelog, as it would mean that the patch is not only introducing some wrappers.
Ok, I think I see what's happening here. Before this patch,
invalidate_sync()was being called inside qinval_device_iotlb(), so we were synchronous already, and we need to continue to be like that, by calling the_sync()variants.
yes, it not as well understood, but to me, it is difficult to describe it in changelog. Let me elaborate briefly on the evolution:
1. In original code, without my patch, it is:
...
if ( flush_dev_iotlb )
ret = dev_invalidate_iotlb(iommu, did, addr, size_order, type);
rc = invalidate_sync(iommu);
...In dev_invalidate_iotlb(), it scans ats_devices list the calls qinval_device_iotlb() to flush the Device-TLB via 'Device-TLB Invalidate Descriptor'. In invalidate_sync(), it synchronize with hardware for the invalidation request descriptors submitted before the wait descriptor via 'Invalidation Wait Descriptor'.
If we assign multiple ATS devices to a domain and invalidate_sync() times out, we couldn't find which one times out. Then,
2. in my previous patch, I put the invalidate_sync() variant (-as we need to pass down the device's SBDF to hide the ATS device) within dev_invalidate_iotlb() to flush the ATS device one by one. if it timed out, I could find the bogus device and hide it.
3. as Kevin mentioned, I put invalidation sync within dev_invalidate_iotlb, while for all other IOMMU invalidations the sync is put after. That is the consistency issue. That's also why I provide _sync version in v8. (could you help me enhance the description? :) )
Quoted 3 lines
Yes, if this is what happens, this also looks ok to me. Sorry for the noise.
Dario, feel free to express yourself. As you know, I'd appreciate your (and the other's) comments.:)
Quan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v8 3/3 VT-d: Fix vt-d Device-TLB flush timeout issue
In reply to Quan XuIf Device-TLB flush timed out, we would hide the target ATS device and crash the domain owning this ATS device. If impacted domain is hardware domain, just throw out a warning.
The hidden device should be disallowed to be further assigned to any domain.
--- xen/drivers/passthrough/pci.c | 6 ++-- xen/drivers/passthrough/vtd/extern.h | 3 +- xen/drivers/passthrough/vtd/qinval.c | 58 +++++++++++++++++++++++++++++++++-- xen/drivers/passthrough/vtd/x86/ats.c | 11 ++++--- xen/include/xen/pci.h | 1 + 5 files changed, 68 insertions(+), 11 deletions(-)
xen/drivers/passthrough/pci.c +3 -3
@@ -420,7 +420,7 @@ static void free_pdev(struct pci_seg *pseg, struct pci_dev *pdev)xfree (pdev); } -static void _pci_hide_device (struct pci_dev *pdev) +void pci_hide_existing_device (struct pci_dev *pdev) {if ( pdev->domain )return ;
@@ -437,7 +437,7 @@ int __init pci_hide_device(int bus, int devfn) pdev =alloc_pdev (get_pseg (0 ), bus, devfn);if ( pdev ) { -_pci_hide_device (pdev); +pci_hide_existing_device (pdev); rc =0 ; }pcidevs_unlock ();
@@ -467,7 +467,7 @@ int __init pci_ro_device(int seg, int bus, int devfn) }__set_bit (PCI_BDF2 (bus, devfn), pseg->ro_map); -_pci_hide_device (pdev); +pci_hide_existing_device (pdev);return 0 ; }
xen/drivers/passthrough/vtd/extern.h +2 -1
@@ -62,7 +62,8 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did,int qinval_device_iotlb (struct iommu *iommu,u32 max_invs_pend,u16 sid,u16 size,u64 addr);int qinval_device_iotlb_sync (struct iommu *iommu,u32 max_invs_pend, -u16 sid,u16 size,u64 addr); +u16 did,u16 seg,u8 bus,u8 devfn, +u16 size,u64 addr);unsigned int get_cache_line_size (void );void cacheline_flush (char *);
xen/drivers/passthrough/vtd/qinval.c +56 -2
73 lines not on this page · raw message
xen/drivers/passthrough/vtd/x86/ats.c +6 -5
@@ -116,7 +116,6 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did,list_for_each_entry ( pdev, &ats_devices, list ) { -u16 sid =PCI_BDF2 (pdev->bus, pdev->devfn);bool_t sbit;/* Only invalidate devices that belong to this IOMMU */
@@ -133,8 +132,9 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did,/* invalidate all translations: sbit=1,bit_63=0,bit[62:12]=1 */ sbit =1 ; addr = (~0UL <<PAGE_SHIFT_4K ) &0x7FFFFFFFFFFFFFFF ; - ret =qinval_device_iotlb_sync (iommu, pdev->ats_queue_depth, - sid, sbit, addr); + ret =qinval_device_iotlb_sync (iommu, pdev->ats_queue_depth, did, + pdev->seg, pdev->bus, pdev->devfn, + sbit, addr);break ;case DMA_TLB_PSI_FLUSH :if ( !device_in_domain (iommu, pdev, did) )
@@ -153,8 +153,9 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did, addr |= (((u64 )1 << (size_order -1 )) -1 ) <<PAGE_SHIFT_4K ; } - ret =qinval_device_iotlb_sync (iommu, pdev->ats_queue_depth, - sid, sbit, addr); + ret =qinval_device_iotlb_sync (iommu, pdev->ats_queue_depth, did, + pdev->seg, pdev->bus, pdev->devfn, + sbit, addr);break ;default : dprintk(XENLOG_WARNING VTDPREFIX, "invalid vt-d flush type\n");
xen/include/xen/pci.h +1 -0
@@ -116,6 +116,7 @@ const unsigned long *pci_get_ro_map(u16 seg);int pci_add_device (u16 seg,u8 bus,u8 devfn,const struct pci_dev_info *,nodeid_t node);int pci_remove_device (u16 seg,u8 bus,u8 devfn); +void pci_hide_existing_device (struct pci_dev *pdev);int pci_ro_device (int seg,int bus,int devfn);int pci_hide_device (int bus,int devfn);struct pci_dev *pci_get_pdev (int seg,int bus,int devfn);
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v8 3/3] VT-d: Fix vt-d Device-TLB flush timeout issue
Quoted 7 lines · Quan Xu
If Device-TLB flush timed out, we would hide the target ATS device and crash the domain owning this ATS device. If impacted domain is hardware domain, just throw out a warning.
The hidden device should be disallowed to be further assigned to any domain.
What is "should be disallowed" supposed to mean here? Isn't the situation that, by hiding the device, which this patch is doing, we actually disallow any further assignment?
If yes, this should rather be (something like):
"By hiding the device, we make sure it can't be assigned to any domain any longer."
Other than this, the patch looks good to me, but I'll re-review it when the new version comes out (with the other patches from the preliminary series folded in), before saying Reviewed-by.
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 3/3] VT-d: Fix vt-d Device-TLB flush timeout issue
Quoted 8 lines · On March 24, 2016 11:38pm, <[email protected]> wrote:
Quoted 7 lines · Quan Xu
If Device-TLB flush timed out, we would hide the target ATS device and crash the domain owning this ATS device. If impacted domain is hardware domain, just throw out a warning.
The hidden device should be disallowed to be further assigned to any domain.
Quoted 9 lines
What is "should be disallowed" supposed to mean here? Isn't the situation that, by hiding the device, which this patch is doing, we actually disallow any further assignment?
If yes, this should rather be (something like):
"By hiding the device, we make sure it can't be assigned to any domain any longer."
Let me introduce what happen first.
If the ATS device flush timed out, it would be assigned to dom_xen (dummy domain).
Then, .e.g, the ATS device is 0000:81:00.0 in my platform. If the ATS device 0000:81:00.0 is hidden and we assign the ATS device 0000:81:00.0 to another domain with xl tool, It would fail and print out:
""" libxl: error: libxl_pci.c:1216:libxl__device_pci_add: PCI device 0000:81:00.0 already assigned to a different guest? """
To be honest, I'd prefer your description. do you think?
Quan
Quoted 3 lines
Other than this, the patch looks good to me, but I'll re-review it when the new version comes out (with the other patches from the preliminary series folded in), before saying Reviewed-by.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 3/3] VT-d: Fix vt-d Device-TLB flush timeout issue
In reply to Dario FaggioliQuoted 11 lines · Dario Faggioli
Quoted 7 lines · Quan Xu
If Device-TLB flush timed out, we would hide the target ATS device and crash the domain owning this ATS device. If impacted domain is hardware domain, just throw out a warning.
The hidden device should be disallowed to be further assigned to any domain.
What is "should be disallowed" supposed to mean here? Isn't the situation that, by hiding the device, which this patch is doing, we actually disallow any further assignment?
Yes.
Take a look at device_assigned. This patch reassigns the device to dom_xen so device_assigned will return -EBUSY.
Actually that information could be part of the commit to get an idea of the effects of this patch.
Quoted 6 lines
If yes, this should rather be (something like):
"By hiding the device, we make sure it can't be assigned to any domain any longer."
Quoted 19 lines
Other than this, the patch looks good to me, but I'll re-review it when the new version comes out (with the other patches from the preliminary series folded in), before saying Reviewed-by.
Regards,
DarioSignature · 12 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 3/3] VT-d: Fix vt-d Device-TLB flush timeout issue
Quoted 13 lines · Konrad Rzeszutek Wilk
Quoted 11 lines · Dario Faggioli
Quoted 7 lines · Quan Xu
If Device-TLB flush timed out, we would hide the target ATS device and crash the domain owning this ATS device. If impacted domain is hardware domain, just throw out a warning.
The hidden device should be disallowed to be further assigned to any domain.
What is "should be disallowed" supposed to mean here? Isn't the situation that, by hiding the device, which this patch is doing, we actually disallow any further assignment?
Quoted 8 lines
Yes.
Take a look at
device_assigned. This patch reassigns the device todom_xensodevice_assignedwill return-EBUSY.Actually that information could be part of the commit to get an idea of the effects of this patch.
Quoted 1 line
Konrad, Welcome.
Yes, I would try to add it in changelog.
Quan
Quoted 26 lines
Quoted 20 lines
If yes, this should rather be (something like):
"By hiding the device, we make sure it can't be assigned to any domain any longer."
Other than this, the patch looks good to me, but I'll re-review it when the new version comes out (with the other patches from the preliminary series folded in), before saying Reviewed-by.
Regards,
Dario
--
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 3/3] VT-d: Fix vt-d Device-TLB flush timeout issue
In reply to Dario Faggioli+cc Konrad Rzeszutek Wilk <[email protected]>, who is also reviewing this patch.
Quoted 12 lines · Dario Faggioli
Quoted 7 lines · Quan Xu
If Device-TLB flush timed out, we would hide the target ATS device and crash the domain owning this ATS device. If impacted domain is hardware domain, just throw out a warning.
The hidden device should be disallowed to be further assigned to any domain.
What is "should be disallowed" supposed to mean here? Isn't the situation that, by hiding the device, which this patch is doing, we actually disallow any further assignment?
Quoted 8 lines
If yes, this should rather be (something like):
"By hiding the device, we make sure it can't be assigned to any domain any longer."
Other than this, the patch looks good to me, but I'll re-review it when the new version comes out (with the other patches from the preliminary series folded in), before saying Reviewed-by.
Dario,
What about this one:
"""
VT-d: Fix vt-d Device-TLB flush timeout issue
If Device-TLB flush timed out, we would hide the target ATS device and crash the domain owning this ATS device. If impacted domain is hardware domain, the error handling is just ignored.
By hiding the device, we make sure it can't be assigned to any domain any longer.
"""
Quan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 3/3] VT-d: Fix vt-d Device-TLB flush timeout issue
In reply to Quan XuQuoted 80 lines · Quan Xu
If Device-TLB flush timed out, we would hide the target ATS device and crash the domain owning this ATS device. If impacted domain is hardware domain, just throw out a warning.
The hidden device should be disallowed to be further assigned to any domain.
Signed-off-by Quan Xu <[email protected]>--- xen/drivers/passthrough/pci.c | 6 ++-- xen/drivers/passthrough/vtd/extern.h | 3 +- xen/drivers/passthrough/vtd/qinval.c | 58 +++++++++++++++++++++++++++++++++-- xen/drivers/passthrough/vtd/x86/ats.c | 11 ++++--- xen/include/xen/pci.h | 1 + 5 files changed, 68 insertions(+), 11 deletions(-)xen/drivers/passthrough/pci.c +3
-3@@ -420,7 +420,7 @@ static void free_pdev(struct pci_seg *pseg, struct pci_dev *pdev)xfree (pdev); } -static void _pci_hide_device (struct pci_dev *pdev) +void pci_hide_existing_device (struct pci_dev *pdev) {if ( pdev->domain )return ;@@ -437,7 +437,7 @@ int __init pci_hide_device(int bus, int devfn) pdev =alloc_pdev (get_pseg (0 ), bus, devfn);if ( pdev ) { -_pci_hide_device (pdev); +pci_hide_existing_device (pdev); rc =0 ; }pcidevs_unlock ();@@ -467,7 +467,7 @@ int __init pci_ro_device(int seg, int bus, int devfn) }__set_bit (PCI_BDF2 (bus, devfn), pseg->ro_map); -_pci_hide_device (pdev); +pci_hide_existing_device (pdev);return 0 ; }xen/drivers/passthrough/vtd/extern.h +2
-1@@ -62,7 +62,8 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did,int qinval_device_iotlb (struct iommu *iommu,u32 max_invs_pend,u16 sid,u16 size,u64 addr);int qinval_device_iotlb_sync (struct iommu *iommu,u32 max_invs_pend, -u16 sid,u16 size,u64 addr); +u16 did,u16 seg,u8 bus,u8 devfn, +u16 size,u64 addr);unsigned int get_cache_line_size (void );void cacheline_flush (char *);xen/drivers/passthrough/vtd/qinval.c +11
-0@@ -216,6 +216,58 @@ static int queue_invalidate_iotlb_sync(struct iommu *iommu,return invalidate_sync (iommu); } +static void dev_invalidate_iotlb_timeout (struct iommu *iommu,u16 did, +u16 seg,u8 bus,u8 devfn) +{ +struct domain *d =NULL ; +struct pci_dev *pdev; + +if (test_bit (did, iommu->domid_bitmap) ) + d =rcu_lock_domain_by_id (iommu->domid_map[did]); + +if ( d ==NULL ) +return ;
xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_iotlb_sync(struct iommu *iommu, · line 239
Quoted 10 lines
xen/drivers/passthrough/vtd/qinval.c +10
-0+ +pcidevs_lock (); + +for_each_pdev (d, pdev) + { +if ( ( pdev->seg == seg ) && + ( pdev->bus == bus ) && + ( pdev->devfn == devfn ) ) + { +ASSERT ( pdev->domain );
Oddly enough (and I don't see this in the StyleGuide), the ASSERTS do not require the spaces. So it can be:
ASSERT(pdev->domain);
xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_iotlb_sync(struct iommu *iommu, · line 250
Quoted 11 lines
xen/drivers/passthrough/vtd/qinval.c +11
-0+list_del (&pdev->domain_list); + pdev->domain =NULL ; +pci_hide_existing_device (pdev); +break ; + } + } + +pcidevs_unlock (); + +if ( !is_hardware_domain (d) ) +domain_crash (d);
The description said something about 'just throw out a warning' (if the domain owning it is a hardware domain). That seems to be missing?
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 3/3] VT-d: Fix vt-d Device-TLB flush timeout issue
Quoted 100 lines · Konrad Rzeszutek Wilk
xen/drivers/passthrough/pci.c static void free_pdev(struct pci_seg *pseg, struct
Quoted 22 lines · Quan Xu
If Device-TLB flush timed out, we would hide the target ATS device and crash the domain owning this ATS device. If impacted domain is hardware domain, just throw out a warning.
The hidden device should be disallowed to be further assigned to any domain.
Signed-off-by Quan Xu <[email protected]>--- xen/drivers/passthrough/pci.c | 6 ++-- xen/drivers/passthrough/vtd/extern.h | 3 +- xen/drivers/passthrough/vtd/qinval.c | 58 +++++++++++++++++++++++++++++++++-- xen/drivers/passthrough/vtd/x86/ats.c | 11 ++++--- xen/include/xen/pci.h | 1 + 5 files changed, 68 insertions(+), 11 deletions(-)(quoted diff) +0
-0
b/xen/drivers/passthrough/pci.cindex 9f1716a..9a214c6 100644xen/drivers/passthrough/pci.c +0
-0@@ -420,7 +420,7 @@ static void free_pdev(struct pci_seg *pseg, struct
pci_dev*pdev)Quoted 34 lines
xen/drivers/passthrough/pci.c +3
-3xfree (pdev); } -static void _pci_hide_device (struct pci_dev *pdev) +void pci_hide_existing_device (struct pci_dev *pdev) {if ( pdev->domain )return ;@@ -437,7 +437,7 @@ int __init pci_hide_device(int bus, int devfn) pdev =alloc_pdev (get_pseg (0 ), bus, devfn);if ( pdev ) { -_pci_hide_device (pdev); +pci_hide_existing_device (pdev); rc =0 ; }pcidevs_unlock ();@@ -467,7 +467,7 @@ int __init pci_ro_device(int seg, int bus, int devfn) }__set_bit (PCI_BDF2 (bus, devfn), pseg->ro_map); -_pci_hide_device (pdev); +pci_hide_existing_device (pdev);return 0 ; }xen/drivers/passthrough/vtd/extern.h +0
-0@@ -62,7 +62,8 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did, int qinval_device_iotlb(struct iommu *iommu, u32 max_invs_pend, u16 sid, u16 size, u64Quoted 1 line
addr); int qinval_device_iotlb_sync(struct iommu *iommu, u32
max_invs_pend,xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_iotlb_sync(struct iommu
Quoted 11 lines
xen/drivers/passthrough/vtd/extern.h +2
-1- u16 sid, u16 size, u64 addr); + u16 did, u16 seg, u8 bus, u8 devfn, + u16 size, u64 addr); unsigned int get_cache_line_size(void); void cacheline_flush(char*); diff --git
a/xen/drivers/passthrough/vtd/qinval.cb/xen/drivers/passthrough/vtd/qinval.c
index ad9e265..10c5684 100644xen/drivers/passthrough/vtd/qinval.c +0
-0@@ -216,6 +216,58 @@ static int queue_invalidate_iotlb_sync(struct iommu*iommu,
xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_iotlb_sync(struct iommu *iommu, · line 220
Quoted 5 lines
xen/drivers/passthrough/vtd/qinval.c +2
-0return invalidate_sync (iommu); } +static void dev_invalidate_iotlb_timeout (struct iommu *iommu,u16 did, +u16 seg,u8 bus,u8 devfn){
Quoted 8 lines
xen/drivers/passthrough/vtd/qinval.c +8
-0+struct domain *d =NULL ; +struct pci_dev *pdev; + +if (test_bit (did, iommu->domid_bitmap) ) + d =rcu_lock_domain_by_id (iommu->domid_map[did]); + +if ( d ==NULL ) +return ;xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_iotlb_sync(struct iommu *iommu, · line 239
Quoted 10 lines
xen/drivers/passthrough/vtd/qinval.c +10
-0+ +pcidevs_lock (); + +for_each_pdev (d, pdev) + { +if ( ( pdev->seg == seg ) && + ( pdev->bus == bus ) && + ( pdev->devfn == devfn ) ) + { +ASSERT ( pdev->domain );Oddly enough (and I don't see this in the StyleGuide), the ASSERTS do not require the spaces. So it can be:
Quoted 1 line
ASSERT(pdev->domain);
Got it, I will fix it in next v9.
Quoted 6 lines
Quoted 6 lines
xen/drivers/passthrough/vtd/qinval.c +6
-0+list_del (&pdev->domain_list); + pdev->domain =NULL ; +pci_hide_existing_device (pdev); +break ; + } + }
Quoted 10 lines
xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_iotlb_sync(struct iommu *iommu, · line 250
Quoted 5 lines
xen/drivers/passthrough/vtd/qinval.c +5
-0+ +pcidevs_unlock (); + +if ( !is_hardware_domain (d) ) +domain_crash (d);The description said something about 'just throw out a warning' (if the domain owning it is a hardware domain). That seems to be missing?
The warning is in the call path, in queue_invalidate_wait():
"""Queue invalidate wait descriptor timed out."""
Then, does it make sense?
Quan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 3/3] VT-d: Fix vt-d Device-TLB flush timeout issue
Quoted 18 lines
Quoted 17 lines
xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_iotlb_sync(struct iommu *iommu, · line 250
Quoted 12 lines
xen/drivers/passthrough/vtd/qinval.c +11
-0+list_del (&pdev->domain_list); + pdev->domain =NULL ; +pci_hide_existing_device (pdev); +break ; + } + } + +pcidevs_unlock (); + +if ( !is_hardware_domain (d) ) +domain_crash (d);The description said something about 'just throw out a warning' (if the domain owning it is a hardware domain). That seems to be missing?
Quoted 2 lines
The warning is in the call path, in
queue_invalidate_wait():
"""Queue invalidate wait descriptor timed out."""
Aah, right.
Quoted 2 lines
Then, does it make sense?
Yes. I would recommend you modify the commit description so that clueless folks like me can see it. You could modify the commit description to say:
"just throw out a warning (done in queue_invalidate_wait)."
Quoted 2 lines
Quan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 3/3] VT-d: Fix vt-d Device-TLB flush timeout issue
Quoted 21 lines · Konrad Rzeszutek Wilk
Quoted 18 lines
Quoted 17 lines
xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_iotlb_sync(struct iommu *iommu, · line 250
Quoted 12 lines
xen/drivers/passthrough/vtd/qinval.c +11
-0+list_del (&pdev->domain_list); + pdev->domain =NULL ; +pci_hide_existing_device (pdev); +break ; + } + } + +pcidevs_unlock (); + +if ( !is_hardware_domain (d) ) +domain_crash (d);The description said something about 'just throw out a warning' (if the domain owning it is a hardware domain). That seems to be missing?
Quoted 2 lines
The warning is in the call path, in
queue_invalidate_wait():
"""Queue invalidate wait descriptor timed out."""
Quoted 10 lines
Aah, right.
Quoted 2 lines
Then, does it make sense?
Yes. I would recommend you modify the commit description so that clueless folks like me can see it. You could modify the commit description to say:
"just throw out a warning (done in
queue_invalidate_wait)."
Then, based on Dario/your suggestion, the changelog could be:
"""
VT-d: Fix vt-d Device-TLB flush timeout issue
If Device-TLB flush timed out, we would hide the target ATS device and crash the domain owning this ATS device. If impacted domain is hardware domain, just throw out a warning (done in queue_invalidate_wait).
By hiding the device, we make sure it can't be assigned to any domain any longer. """
Quan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 3/3] VT-d: Fix vt-d Device-TLB flush timeout issue
Quoted 37 lines · Quan
Quoted 21 lines · Konrad Rzeszutek Wilk
Quoted 18 lines
Quoted 17 lines
xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_iotlb_sync(struct iommu *iommu, · line 250
Quoted 12 lines
xen/drivers/passthrough/vtd/qinval.c +11
-0+list_del (&pdev->domain_list); + pdev->domain =NULL ; +pci_hide_existing_device (pdev); +break ; + } + } + +pcidevs_unlock (); + +if ( !is_hardware_domain (d) ) +domain_crash (d);The description said something about 'just throw out a warning' (if the domain owning it is a hardware domain). That seems to be missing?
Quoted 2 lines
The warning is in the call path, in
queue_invalidate_wait():
"""Queue invalidate wait descriptor timed out."""Quoted 10 lines
Aah, right.
Quoted 2 lines
Then, does it make sense?
Yes. I would recommend you modify the commit description so that clueless folks like me can see it. You could modify the commit description to say:
"just throw out a warning (done in
queue_invalidate_wait)."Then, based on Dario/your suggestion, the changelog could be:
"""
VT-d: Fix vt-d Device-TLB flush timeout issue
Quoted 5 lines
If Device-TLB flush timed out, we would hide the target ATS device and crash the domain owning this ATS device. If impacted domain is hardware domain, just throw out a warning (done in
queue_invalidate_wait).By hiding the device, we make sure it can't be assigned to any domain any longer. """
s/to any domain any longer./to any domain any longer (see device_assigned)./
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 3/3] VT-d: Fix vt-d Device-TLB flush timeout issue
Quoted 43 lines · Konrad Rzeszutek Wilk
Quoted 1 line · Quan
On March 28, 2016 10:11pm, Konrad Rzeszutek Wilk
Quoted 15 lines · <[email protected]> wrote:
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
xen/drivers/passthrough/vtd/qinval.c static int queue_invalidate_iotlb_sync(struct iommu *iommu, · line 250
Quoted 12 lines
xen/drivers/passthrough/vtd/qinval.c +11
-0+list_del (&pdev->domain_list); + pdev->domain =NULL ; +pci_hide_existing_device (pdev); +break ; + } + } + +pcidevs_unlock (); + +if ( !is_hardware_domain (d) ) +domain_crash (d);The description said something about 'just throw out a warning' (if the domain owning it is a hardware domain). That seems to be
missing?
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
The warning is in the call path, in
queue_invalidate_wait():
"""Queue invalidate wait descriptor timed out."""Quoted 6 lines
Quoted 6 lines
Aah, right.
Quoted 2 lines
Then, does it make sense?
Yes. I would recommend you modify the commit description so that clueless folks like me can see it. You could modify the commit description to
say:
Quoted 10 lines
Quoted 4 lines
"just throw out a warning (done in
queue_invalidate_wait)."Then, based on Dario/your suggestion, the changelog could be:
"""
VT-d: Fix vt-d Device-TLB flush timeout issueIf Device-TLB flush timed out, we would hide the target ATS device and crash
the domain owning this ATS device.
Quoted 9 lines
Quoted 1 line
If impacted domain is hardware domain, just throw out a warning (done in
queue_invalidate_wait).Quoted 2 lines
By hiding the device, we make sure it can't be assigned to any domain any
longer.
Quoted 1 line
"""
s/to any domain any longer./to any domain any longer (see device_assigned)./
Got it, thanks.
Quan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 24.03.16 at 06:57, <[email protected]> wrote:
**NOTE**
This patch set should base on 2 prereq patch sets:
a). Make thepcidevs_locka recursive one.
This one already went in, so is pointless to mention here.
Quoted 1 line
b). Check VT-d Device-TLB flush error.
And this one is WIP, so it's continuing to be cumbersome to review this series without the other one even known to be almost ready to go in. I think loose dependencies are okay, but in the case here everything would better be presented together in one series.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 6 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 24.03.16 at 06:57, <[email protected]> wrote:
**NOTE**
This patch set should base on 2 prereq patch sets:
a). Make thepcidevs_locka recursive one.This one already went in, so is pointless to mention here.
Agreed,
Quoted 4 lines
Quoted 2 lines
b). Check VT-d Device-TLB flush error.
And this one is WIP,
Yes,
Quoted 1 line
so it's continuing to be cumbersome to review this series
Sorry, I don't think so.
Quoted 4 lines
without the other one even known to be almost ready to go in. I think loose dependencies are okay, but in the case here everything would better be presented together in one series.
ok. I would send them together in next series.
Quan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 9 lines · On March 24, 2016 7:11pm, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line · On 24.03.16 at 06:57, <[email protected]> wrote:
without the other one even known to be almost ready to go in. I think loose dependencies are okay, but in the case here everything would better be presented together in one series.
ok. I would send them together in next series.
Think twice, I'd better fix them and send out asap. When the interval is too long, I am afraid I may overlook some Of the details, even I can read all of reply.
Quan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel