Skip to contentSkip to conversation

arm/p2m: call iommu iotlb flush if iommu exists and enabled

RFC Superseded Andrii Anisov 3 participants 6 messages Jan 23, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC 1/1 arm/p2m: call iommu iotlb flush if iommu exists and enabled

From: Andrii Anisov <[email protected]>

Taking decission by need_iommu_pt_sync() make us never kicking iommu_iotlb_flush() for IOMMUs which do share TLB with CPU. So check has_iommu_pt() instead.

---

Julien,

Could you please look at this, IMO there is a mistake here.
x86 uses need_iommu_pt_sync() to make decission if iommu's map/unmap should be additionally called. But ARM has no non-shared pt support in the mainline, so using need_iommu_pt_sync() seems to be odd.

 xen/arch/arm/p2m.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/p2m.c +1 -1
index 2394f97..059a391 100644
@@ -1019,7 +1019,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m,
          !mfn_eq(lpae_get_mfn(*entry), lpae_get_mfn(orig_pte)) )
         p2m_free_entry(p2m, orig_pte, level);
 
-    if ( need_iommu_pt_sync(p2m->domain) &&
+    if ( has_iommu_pt(p2m->domain) &&
          (lpae_is_valid(orig_pte) || lpae_is_valid(*entry)) )
     {
         unsigned int flush_flags = 0;
Signature · 7 lines
2.7.4


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

(+ Paul)

Hello,

Quoted 3 lines · Andrii Anisov

From: Andrii Anisov <[email protected]>

Taking decission by need_iommu_pt_sync() make us never kicking

s/decission/decision/

Quoted 1 line

iommu_iotlb_flush() for IOMMUs which do share TLB with CPU.

I am not aware of platform where we share the TLB with the CPU. Do you mean sharing the P2M?

Quoted 20 lines

So check has_iommu_pt() instead.

---

Julien,

Could you please look at this, IMO there is a mistake here.
x86 uses need_iommu_pt_sync() to make decission if iommu's map/unmap should be additionally called. But ARM has no non-shared pt support in the mainline, so using need_iommu_pt_sync() seems to be odd.

  xen/arch/arm/p2m.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/p2m.c +0 -0
index 2394f97..059a391 100644

xen/arch/arm/p2m.c static int __p2m_set_entry(struct p2m_domain *p2m, · line 1022

Quoted 5 lines
xen/arch/arm/p2m.c +1 -1
@@ -1019,7 +1019,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m,
           !mfn_eq(lpae_get_mfn(*entry), lpae_get_mfn(orig_pte)) )
          p2m_free_entry(p2m, orig_pte, level);
 
-    if ( need_iommu_pt_sync(p2m->domain) &&
+    if ( has_iommu_pt(p2m->domain) &&

I think this makes sense because we want to flush the TLB when the P2M is shared. Although, I would like to hear Paul's opinion here.

xen/arch/arm/p2m.c static int __p2m_set_entry(struct p2m_domain *p2m,

Quoted 3 lines
xen/arch/arm/p2m.c +0 -0
           (lpae_is_valid(orig_pte) || lpae_is_valid(*entry)) )
      {
          unsigned int flush_flags = 0; >

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw
Quoted 52 lines

-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 23 January 2019 11:34
To: Andrii Anisov <[email protected]>; xen- [email protected]
Cc: Stefano Stabellini <[email protected]>; Andrii Anisov <[email protected]>; Paul Durrant <[email protected]>
Subject: Re: [RFC] arm/p2m: call iommu iotlb flush if iommu exists and enabled

(+ Paul)

Hello,

Quoted 3 lines · Andrii Anisov

From: Andrii Anisov <[email protected]>

Taking decission by need_iommu_pt_sync() make us never kicking

s/decission/decision/

Quoted 1 line

iommu_iotlb_flush() for IOMMUs which do share TLB with CPU.

I am not aware of platform where we share the TLB with the CPU. Do you mean
sharing the P2M?

Quoted 10 lines

So check has_iommu_pt() instead.

---

Julien,

Could you please look at this, IMO there is a mistake here. x86 uses need_iommu_pt_sync() to make decission if iommu's map/unmap

should be additionally called.

Quoted 1 line

But ARM has no non-shared pt support in the mainline, so using

need_iommu_pt_sync() seems to be odd.

Quoted 12 lines
  xen/arch/arm/p2m.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/p2m.c +0 -0
index 2394f97..059a391 100644
@@ -1019,7 +1019,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m,
           !mfn_eq(lpae_get_mfn(*entry), lpae_get_mfn(orig_pte)) )
          p2m_free_entry(p2m, orig_pte, level);
 
Quoted 5 lines

xen/arch/arm/p2m.c static int __p2m_set_entry(struct p2m_domain *p2m, · line 1022

Quoted 2 lines
xen/arch/arm/p2m.c +1 -1
-    if ( need_iommu_pt_sync(p2m->domain) &&
+    if ( has_iommu_pt(p2m->domain) &&

I think this makes sense because we want to flush the TLB when the P2M is shared. Although, I would like to hear Paul's opinion here.

Yes, this was a mistake when moving from the old macros and need_iommu. Andrii is correct that need_iommu_pt_sync() is supposed to gate whether an explicit map/unmap is needed. The need for flush should only depend on has_iommu_pt(). There is also iommu_use_hap_pt() which is actually defined as has_iommu_pt(), but I wonder whether that should just go away for ARM since the page tables are always shared.

Paul

Quoted 9 lines

xen/arch/arm/p2m.c static int __p2m_set_entry(struct p2m_domain *p2m,

Quoted 4 lines
xen/arch/arm/p2m.c +0 -0
           (lpae_is_valid(orig_pte) || lpae_is_valid(*entry)) )
      {
          unsigned int flush_flags = 0; >

Cheers,

--
Julien Grall

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

#3 lore raw

Hello Paul,

Quoted 1 line · Paul Durrant

Yes, this was a mistake when moving from the old macros and need_iommu. Andrii is correct that need_iommu_pt_sync() is supposed to gate whether an explicit map/unmap is needed. The need for flush should only depend on has_iommu_pt().

So I fix the commit message and send V2 for XEN 4.12.

Quoted 1 line

There is also iommu_use_hap_pt() which is actually defined as has_iommu_pt(), but I wonder whether that should just go away for ARM since the page tables are always shared.

Actually, the mainline currently supports only SMMU, which does share the page table.
But it is not always true, we are using HW, where PT is not shared. And going to upstream that support one day.

Signature · 7 lines
Sincerely,
Andrii Anisov.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#4 lore raw
Quoted 10 lines

-----Original Message-----
From: Andrii Anisov [mailto:[email protected]]
Sent: 23 January 2019 12:40
To: Paul Durrant <[email protected]>; 'Julien Grall' <[email protected]>; [email protected]
Cc: Stefano Stabellini <[email protected]>; Andrii Anisov <[email protected]>
Subject: Re: [RFC] arm/p2m: call iommu iotlb flush if iommu exists and enabled

Quoted 8 lines

Hello Paul,

Quoted 1 line · Paul Durrant

Yes, this was a mistake when moving from the old macros and need_iommu.

Andrii is correct that need_iommu_pt_sync() is supposed to gate whether an explicit map/unmap is needed. The need for flush should only depend on has_iommu_pt().
So I fix the commit message and send V2 for XEN 4.12.

Cool.

Quoted 8 lines
Quoted 2 lines

There is also iommu_use_hap_pt() which is actually defined as

has_iommu_pt(), but I wonder whether that should just go away for ARM since the page tables are always shared.
Actually, the mainline currently supports only SMMU, which does share the page table.
But it is not always true, we are using HW, where PT is not shared. And going to upstream that support one day.

Oh, ok. Leave it in then :-)

Paul

Quoted 4 lines

--
Sincerely,
Andrii Anisov.

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

#5 lore raw
In reply to Julien Grall
Quoted 1 line · Julien Grall

Do you mean sharing the P2M?

For sure!

Signature · 7 lines
Sincerely,
Andrii Anisov.

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