diff mbox

[v4,08/10] vt-d/ept: propagate IOMMU Device-TLB flush error up to EPT update.

Message ID 1462524880-67205-9-git-send-email-quan.xu@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Quan Xu May 6, 2016, 8:54 a.m. UTC
Propagate the IOMMU Device-TLB flush error up to the ept_set_entry(),
when VT-d shares EPT page table.

Signed-off-by: Quan Xu <quan.xu@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>

CC: Jun Nakajima <jun.nakajima@intel.com>
CC: Kevin Tian <kevin.tian@intel.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Feng Wu <feng.wu@intel.com>
---
 xen/arch/x86/mm/p2m-ept.c           | 3 ++-
 xen/drivers/passthrough/vtd/iommu.c | 4 ++--
 xen/include/asm-x86/iommu.h         | 3 ++-
 3 files changed, 6 insertions(+), 4 deletions(-)

Comments

Jan Beulich May 10, 2016, 9:09 a.m. UTC | #1
>>> On 06.05.16 at 10:54, <quan.xu@intel.com> wrote:
> --- a/xen/arch/x86/mm/p2m-ept.c
> +++ b/xen/arch/x86/mm/p2m-ept.c
> @@ -832,7 +832,8 @@ out:
>           need_modify_vtd_table )
>      {
>          if ( iommu_hap_pt_share )
> -            iommu_pte_flush(d, gfn, &ept_entry->epte, order, vtd_pte_present);
> +            ret = iommu_pte_flush(d, gfn, &ept_entry->epte,
> +                                  order, vtd_pte_present);
>          else
>          {
>              if ( iommu_flags )

Looking at this in conjunction with patch 3, I can't see where "ret"
would get consumed.

Jan
George Dunlap May 10, 2016, 2:58 p.m. UTC | #2
On Tue, May 10, 2016 at 10:09 AM, Jan Beulich <JBeulich@suse.com> wrote:
>>>> On 06.05.16 at 10:54, <quan.xu@intel.com> wrote:
>> --- a/xen/arch/x86/mm/p2m-ept.c
>> +++ b/xen/arch/x86/mm/p2m-ept.c
>> @@ -832,7 +832,8 @@ out:
>>           need_modify_vtd_table )
>>      {
>>          if ( iommu_hap_pt_share )
>> -            iommu_pte_flush(d, gfn, &ept_entry->epte, order, vtd_pte_present);
>> +            ret = iommu_pte_flush(d, gfn, &ept_entry->epte,
>> +                                  order, vtd_pte_present);
>>          else
>>          {
>>              if ( iommu_flags )
>
> Looking at this in conjunction with patch 3, I can't see where "ret"
> would get consumed.

Hmm, and here I see where "rc == 0" might be a better option than
"entry_written".

If we know rc is zero, we can just use rc here instead of 'ret', and I
think everything falls out.

If rc is not zero, then we have to do this "if ( !rc ) rc = ret;"
business, which seems a bit silly to do when we know it's zero and
don't expect that to change.

On the other hand, using rc *without* actually checking that it's zero
seems like asking for trouble.

So perhaps it would be better if we take your advice for patch 3, and
then use 'rc' here?

Everything else looks good.

 -George
Jan Beulich May 10, 2016, 3:04 p.m. UTC | #3
>>> On 10.05.16 at 16:58, <George.Dunlap@eu.citrix.com> wrote:
> On Tue, May 10, 2016 at 10:09 AM, Jan Beulich <JBeulich@suse.com> wrote:
>>>>> On 06.05.16 at 10:54, <quan.xu@intel.com> wrote:
>>> --- a/xen/arch/x86/mm/p2m-ept.c
>>> +++ b/xen/arch/x86/mm/p2m-ept.c
>>> @@ -832,7 +832,8 @@ out:
>>>           need_modify_vtd_table )
>>>      {
>>>          if ( iommu_hap_pt_share )
>>> -            iommu_pte_flush(d, gfn, &ept_entry->epte, order, 
> vtd_pte_present);
>>> +            ret = iommu_pte_flush(d, gfn, &ept_entry->epte,
>>> +                                  order, vtd_pte_present);
>>>          else
>>>          {
>>>              if ( iommu_flags )
>>
>> Looking at this in conjunction with patch 3, I can't see where "ret"
>> would get consumed.
> 
> Hmm, and here I see where "rc == 0" might be a better option than
> "entry_written".
> 
> If we know rc is zero, we can just use rc here instead of 'ret', and I
> think everything falls out.
> 
> If rc is not zero, then we have to do this "if ( !rc ) rc = ret;"
> business, which seems a bit silly to do when we know it's zero and
> don't expect that to change.
> 
> On the other hand, using rc *without* actually checking that it's zero
> seems like asking for trouble.
> 
> So perhaps it would be better if we take your advice for patch 3, and
> then use 'rc' here?

Ah, yes, that's a good 2nd reason.

Jan
Quan Xu May 11, 2016, 7:25 a.m. UTC | #4
On Tuesday, May 10, 2016 5:10 PM, Jan Beulich <JBeulich@suse.com> wrote:
> >>> On 06.05.16 at 10:54, <quan.xu@intel.com> wrote:
> > --- a/xen/arch/x86/mm/p2m-ept.c
> > +++ b/xen/arch/x86/mm/p2m-ept.c
> > @@ -832,7 +832,8 @@ out:
> >           need_modify_vtd_table )
> >      {
> >          if ( iommu_hap_pt_share )
> > -            iommu_pte_flush(d, gfn, &ept_entry->epte, order, vtd_pte_present);
> > +            ret = iommu_pte_flush(d, gfn, &ept_entry->epte,
> > +                                  order, vtd_pte_present);
> >          else
> >          {
> >              if ( iommu_flags )
> 
> Looking at this in conjunction with patch 3, I can't see where "ret"
> would get consumed.
> 

Sorry, this 'ret' should be 'rc' here, as I removed  the pending

"
+    if ( !rc )
+        rc = ret;
+
"

from v4.


Quan
diff mbox

Patch

diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index 814cb72..34b96f8 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -832,7 +832,8 @@  out:
          need_modify_vtd_table )
     {
         if ( iommu_hap_pt_share )
-            iommu_pte_flush(d, gfn, &ept_entry->epte, order, vtd_pte_present);
+            ret = iommu_pte_flush(d, gfn, &ept_entry->epte,
+                                  order, vtd_pte_present);
         else
         {
             if ( iommu_flags )
diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index a749c67..bf77417 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1773,8 +1773,8 @@  static int intel_iommu_unmap_page(struct domain *d, unsigned long gfn)
     return dma_pte_clear_one(d, (paddr_t)gfn << PAGE_SHIFT_4K);
 }
 
-int iommu_pte_flush(struct domain *d, u64 gfn, u64 *pte,
-                    int order, bool_t present)
+int __must_check iommu_pte_flush(struct domain *d, u64 gfn, u64 *pte,
+                                 int order, bool_t present)
 {
     struct acpi_drhd_unit *drhd;
     struct iommu *iommu = NULL;
diff --git a/xen/include/asm-x86/iommu.h b/xen/include/asm-x86/iommu.h
index 43f1620..3d2c354 100644
--- a/xen/include/asm-x86/iommu.h
+++ b/xen/include/asm-x86/iommu.h
@@ -27,7 +27,8 @@  int iommu_setup_hpet_msi(struct msi_desc *);
 
 /* While VT-d specific, this must get declared in a generic header. */
 int adjust_vtd_irq_affinities(void);
-int iommu_pte_flush(struct domain *d, u64 gfn, u64 *pte, int order, bool_t present);
+int __must_check iommu_pte_flush(struct domain *d, u64 gfn, u64 *pte,
+                                 int order, bool_t present);
 bool_t iommu_supports_eim(void);
 int iommu_enable_x2apic_IR(void);
 void iommu_disable_x2apic_IR(void);