Skip to contentSkip to conversation

amd/iommu: fix present bit checking when clearing PTE

PATCH In review Roger Pau Monne 4 participants 4 messages Jan 23, 2019 – Jan 24, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 amd/iommu: fix present bit checking when clearing PTE

The current check for the present bit is wrong, since the present bit is located in the low part of the entry.

Fixes e8afe1124cc1 ("iommu: elide flushing for higher order map/unmap operations")

---
Cc: Suravee Suthikulpanit <[email protected]>
Cc: Brian Woods <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Paul Durrant <[email protected]>

---
 xen/drivers/passthrough/amd/iommu_map.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
xen/drivers/passthrough/amd/iommu_map.c +1 -3
index 99ac0a6862..67329b0c95 100644
@@ -39,15 +39,13 @@ static unsigned int clear_iommu_pte_present(unsigned long l1_mfn,
                                             unsigned long dfn)
 {
     uint64_t *table, *pte;
-    uint32_t entry;
     unsigned int flush_flags;
 
     table = map_domain_page(_mfn(l1_mfn));
 
     pte = (table + pfn_to_pde_idx(dfn, 1));
-    entry = *pte >> 32;
 
-    flush_flags = get_field_from_reg_u32(entry, IOMMU_PTE_PRESENT_MASK,
+    flush_flags = get_field_from_reg_u32(*pte, IOMMU_PTE_PRESENT_MASK,
                                          IOMMU_PTE_PRESENT_SHIFT) ?
                                          IOMMU_FLUSHF_modified : 0;
 
Signature · 7 lines
2.20.1


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

-----Original Message-----
From: Roger Pau Monne [mailto:[email protected]]
Sent: 23 January 2019 09:48
To: [email protected]
Cc: Roger Pau Monne <[email protected]>; Suravee Suthikulpanit <[email protected]>; Brian Woods <[email protected]>; Juergen Gross <[email protected]>; Paul Durrant <[email protected]>
Subject: [PATCH for-4.12] amd/iommu: fix present bit checking when clearing PTE

Quoted 6 lines

The current check for the present bit is wrong, since the present bit is located in the low part of the entry.

Fixes e8afe1124cc1 ("iommu: elide flushing for higher order map/unmap

operations")

No idea how I managed to get that wrong. I had a bad feeling at the time about not accessing the pte as a uint32_t[2] array.

Quoted 33 lines

---
Cc: Suravee Suthikulpanit <[email protected]>
Cc: Brian Woods <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Paul Durrant <[email protected]>

---
 xen/drivers/passthrough/amd/iommu_map.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
xen/drivers/passthrough/amd/iommu_map.c +1 -4
index 99ac0a6862..67329b0c95 100644
@@ -39,15 +39,13 @@ static unsigned int clear_iommu_pte_present(unsigned
 long l1_mfn,
                                             unsigned long dfn)
 {
     uint64_t *table, *pte;
-    uint32_t entry;
     unsigned int flush_flags;
 
     table = map_domain_page(_mfn(l1_mfn));
 
     pte = (table + pfn_to_pde_idx(dfn, 1));
-    entry = *pte >> 32;
 
-    flush_flags = get_field_from_reg_u32(entry, IOMMU_PTE_PRESENT_MASK,
+    flush_flags = get_field_from_reg_u32(*pte, IOMMU_PTE_PRESENT_MASK,
                                          IOMMU_PTE_PRESENT_SHIFT) ?
                                          IOMMU_FLUSHF_modified : 0;
 
--
Quoted 1 line

2.20.1

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

#2 lore raw
In reply to Roger Pau Monne
Quoted 5 lines · Roger Pau Monne

The current check for the present bit is wrong, since the present bit is located in the low part of the entry.

Fixes e8afe1124cc1 ("iommu: elide flushing for higher order map/unmap operations")

Juergen

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

Reviewed-by on v1 1/1
#3 lore raw
In reply to Roger Pau Monne
Quoted 5 lines · Roger Pau Monne

The current check for the present bit is wrong, since the present bit is located in the low part of the entry.

Fixes e8afe1124cc1 ("iommu: elide flushing for higher order map/unmap operations")
Quoted 21 lines

---
Cc: Suravee Suthikulpanit <[email protected]>
Cc: Brian Woods <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Paul Durrant <[email protected]>

---
  xen/drivers/passthrough/amd/iommu_map.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
xen/drivers/passthrough/amd/iommu_map.c +0 -1
index 99ac0a6862..67329b0c95 100644
@@ -39,15 +39,13 @@ static unsigned int clear_iommu_pte_present(unsigned long l1_mfn,
                                              unsigned long dfn)
  {
      uint64_t *table, *pte;
-    uint32_t entry;
      unsigned int flush_flags;
 

xen/drivers/passthrough/amd/iommu_map.c static unsigned int clear_iommu_pte_present(unsigned long l1_mfn, · line 51

Quoted 10 lines
xen/drivers/passthrough/amd/iommu_map.c +1 -2
      table = map_domain_page(_mfn(l1_mfn));
 
      pte = (table + pfn_to_pde_idx(dfn, 1));
-    entry = *pte >> 32;
 
-    flush_flags = get_field_from_reg_u32(entry, IOMMU_PTE_PRESENT_MASK,
+    flush_flags = get_field_from_reg_u32(*pte, IOMMU_PTE_PRESENT_MASK,
                                           IOMMU_PTE_PRESENT_SHIFT) ?
                                           IOMMU_FLUSHF_modified : 0;
 

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