Skip to contentSkip to conversation

VT-d: correct a comment and remove useless if() statement

PATCH Superseded Chao Gao 3 participants 8 messages Apr 12, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chao Gao

author
#0 lore raw

PATCH 1/1 VT-d: correct a comment and remove useless if() statement

fix two flaws in the patch (93358e8e VT-d: introduce update_irte to update irte safely).

---
 xen/drivers/passthrough/vtd/intremap.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
xen/drivers/passthrough/vtd/intremap.c +4 -4
index 699239b..8649666 100644
@@ -200,8 +200,9 @@ static void update_irte(struct iommu *iommu, struct iremap_entry *entry,
     else
     {
         /*
-         * If the caller requests an atomic update but we can't meet it, 
-         * a bug will be raised.
+         * VT-d hardware doesn't update IRTEs behind us, nor the software.
+         * If a caller want an atomic update from the views of VT-d
+         * hardware, but we can't meet it, a bug will be raised.
          */
         if ( entry->lo == new_ire->lo )
             write_atomic(&entry->hi, new_ire->hi);
@@ -690,8 +691,7 @@ static int msi_msg_to_remap_entry(
     remap_rte->data = index - i;
 
     update_irte(iommu, iremap_entry, &new_ire, msi_desc->irte_initialized);
-    if ( !msi_desc->irte_initialized )
-        msi_desc->irte_initialized = true;
+    msi_desc->irte_initialized = true;
 
     iommu_flush_cache_entry(iremap_entry, sizeof(*iremap_entry));
     iommu_flush_iec_index(iommu, 0, index);
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

xen/drivers/passthrough/vtd/intremap.c static void update_irte(struct iommu *iommu, struct iremap_entry *entry, · line 203

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 12.04.17 at 02:04, <[email protected]> wrote:
xen/drivers/passthrough/vtd/intremap.c +1 -2
@@ -200,8 +200,9 @@ static void update_irte(struct iommu *iommu, struct iremap_entry *entry,
     else
     {
         /*
-         * If the caller requests an atomic update but we can't meet it, 
-         * a bug will be raised.
+         * VT-d hardware doesn't update IRTEs behind us, nor the software.

Hmm, so far I was under the impression that in posted mode the IRTE could be updated by hardware. Is that not the case? As to software not updating, with there not being any synchronization clearly visible around here, I'm afraid this also needs expanding on (in the commit message at least, not necessarily in the comment).

xen/drivers/passthrough/vtd/intremap.c static void update_irte(struct iommu *iommu, struct iremap_entry *entry, · line 204

Quoted 1 line
xen/drivers/passthrough/vtd/intremap.c +1 -0
+         * If a caller want an atomic update from the views of VT-d

wants

Also what do you mean by "from the views of VT-d"?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#2 lore raw
Quoted 13 lines · Jan Beulich

xen/drivers/passthrough/vtd/intremap.c static void update_irte(struct iommu *iommu, struct iremap_entry *entry, · line 203

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 12.04.17 at 02:04, <[email protected]> wrote:
xen/drivers/passthrough/vtd/intremap.c +1 -2
@@ -200,8 +200,9 @@ static void update_irte(struct iommu *iommu, struct iremap_entry *entry,
     else
     {
         /*
-         * If the caller requests an atomic update but we can't meet it, 
-         * a bug will be raised.
+         * VT-d hardware doesn't update IRTEs behind us, nor the software.

Hmm, so far I was under the impression that in posted mode the IRTE could be updated by hardware. Is that not the case? As to

No. I have confirmed this with VT-d architect that VT-d hardware doesn't update IRTEs. For posted format, VT-d hardware will atomically update Posted Interrupt Descriptor, an address recorded in posted format IRTE.

Quoted 4 lines

software not updating, with there not being any synchronization clearly visible around here, I'm afraid this also needs expanding on (in the commit message at least, not necessarily in the comment).

Will do.

Quoted 6 lines

xen/drivers/passthrough/vtd/intremap.c static void update_irte(struct iommu *iommu, struct iremap_entry *entry, · line 204

Quoted 2 lines
xen/drivers/passthrough/vtd/intremap.c +1 -0
+         * If a caller want an atomic update from the views of VT-d

wants

Also what do you mean by "from the views of VT-d"?

OK. will fix this too. Do you mean it is (and should be) atomic from software's view , so these words are redundant.

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 12.04.17 at 04:41, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 12.04.17 at 02:04, <[email protected]> wrote:

+ * If a caller want an atomic update from the views of VT-d

Quoted 7 lines
Quoted 3 lines

wants

Also what do you mean by "from the views of VT-d"?

OK. will fix this too. Do you mean it is (and should be) atomic from software's view
, so these words are redundant.

I don't mean anything here until I understand what you mean.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#4 lore raw
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 12.04.17 at 04:41, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 12.04.17 at 02:04, <[email protected]> wrote:

+ * If a caller want an atomic update from the views of VT-d

wants

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Also what do you mean by "from the views of VT-d"?

OK. will fix this too. Do you mean it is (and should be) atomic from software's view
, so these words are redundant.

I don't mean anything here until I understand what you mean.

I think making this update presented to VT-d hardware as an atomic update is this function's goal. Is that right? That's why I said "from the views fo VT-d".

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 12.04.17 at 05:56, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 12.04.17 at 04:41, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 12.04.17 at 02:04, <[email protected]> wrote:

+ * If a caller want an atomic update from the views of VT-d

wants

Also what do you mean by "from the views of VT-d"?

OK. will fix this too. Do you mean it is (and should be) atomic from software's view
, so these words are redundant.

Quoted 6 lines
Quoted 2 lines

I don't mean anything here until I understand what you mean.

I think making this update presented to VT-d hardware as an atomic update is this function's goal. Is that right? That's why I said "from the views fo VT-d".

"If the caller wants VT-d hardware to always see a consistent entry ..." perhaps?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#6 lore raw
In reply to Jan Beulich
Quoted 12 lines · Jan Beulich

xen/drivers/passthrough/vtd/intremap.c static void update_irte(struct iommu *iommu, struct iremap_entry *entry, · line 203

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 12.04.17 at 02:04, <[email protected]> wrote:
xen/drivers/passthrough/vtd/intremap.c +1 -2
@@ -200,8 +200,9 @@ static void update_irte(struct iommu *iommu, struct iremap_entry *entry,
     else
     {
         /*
-         * If the caller requests an atomic update but we can't meet it, 
-         * a bug will be raised.
+         * VT-d hardware doesn't update IRTEs behind us, nor the software.

Hmm, so far I was under the impression that in posted mode the IRTE could be updated by hardware. Is that not the case?

No. The IRTE is just a translation structure, so conceptually similar to a pagetable.

With posted interrupts, it is the PI block in memory (referenced by the IRTE) which gets written to by hardware.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#7 lore raw
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 12.04.17 at 12:58, <[email protected]> wrote:
Quoted 12 lines · Jan Beulich

xen/drivers/passthrough/vtd/intremap.c static void update_irte(struct iommu *iommu, struct iremap_entry *entry, · line 203

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 12.04.17 at 02:04, <[email protected]> wrote:
xen/drivers/passthrough/vtd/intremap.c +1 -2
@@ -200,8 +200,9 @@ static void update_irte(struct iommu *iommu, struct iremap_entry *entry,
     else
     {
         /*
-         * If the caller requests an atomic update but we can't meet it, 
-         * a bug will be raised.
+         * VT-d hardware doesn't update IRTEs behind us, nor the software.

Hmm, so far I was under the impression that in posted mode the IRTE could be updated by hardware. Is that not the case?

Quoted 2 lines

No. The IRTE is just a translation structure, so conceptually similar to a pagetable.

Not the best analogy, as page tables do get written by the CPU.

Quoted 2 lines

With posted interrupts, it is the PI block in memory (referenced by the IRTE) which gets written to by hardware.

Okay, then I apparently misremember Feng saying otherwise in the early stages of the original series.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel