qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] intel_iommu: a fix to vtd_dev_get_trans_type()
@ 2017-12-21  6:15 Liu, Yi L
  2017-12-21  6:39 ` no-reply
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Liu, Yi L @ 2017-12-21  6:15 UTC (permalink / raw)
  To: qemu-devel, peterx, jasowang; +Cc: yi.l.liu, Liu, Yi L

vtd_ce_get_type() returns uin32_t and vtd_dev_get_trans_type() returns
the value from vtd_ce_get_type(). However, vtd_dev_get_trans_type()
returns int. This patch switchs to return the translation type by
parameter. It avoids unsigned to int transfer and also avoid potential
reading confusion.

Signed-off-by: Liu, Yi L <yi.l.liu@linux.intel.com>
---
 hw/i386/intel_iommu.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 3a5bb0b..609f087 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -916,7 +916,7 @@ static int vtd_dev_to_context_entry(IntelIOMMUState *s, uint8_t bus_num,
  * happens, otherwise return the shifted type to check against
  * VTD_CONTEXT_TT_*.
  */
-static int vtd_dev_get_trans_type(VTDAddressSpace *as)
+static int vtd_dev_get_trans_type(VTDAddressSpace *as, uint32_t *tt)
 {
     IntelIOMMUState *s;
     VTDContextEntry ce;
@@ -930,16 +930,18 @@ static int vtd_dev_get_trans_type(VTDAddressSpace *as)
         return ret;
     }
 
-    return vtd_ce_get_type(&ce);
+    *tt = vtd_ce_get_type(&ce);
+    return 0;
 }
 
 static bool vtd_dev_pt_enabled(VTDAddressSpace *as)
 {
     int ret;
+    uint32_t tt;
 
     assert(as);
 
-    ret = vtd_dev_get_trans_type(as);
+    ret = vtd_dev_get_trans_type(as, &tt);
     if (ret < 0) {
         /*
          * Possibly failed to parse the context entry for some reason
@@ -950,7 +952,7 @@ static bool vtd_dev_pt_enabled(VTDAddressSpace *as)
         return false;
     }
 
-    return ret == VTD_CONTEXT_TT_PASS_THROUGH;
+    return tt == VTD_CONTEXT_TT_PASS_THROUGH;
 }
 
 /* Return whether the device is using IOMMU translation. */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-12-25  6:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-21  6:15 [Qemu-devel] [PATCH] intel_iommu: a fix to vtd_dev_get_trans_type() Liu, Yi L
2017-12-21  6:39 ` no-reply
2017-12-21  6:53 ` no-reply
2017-12-25  5:45 ` Peter Xu
2017-12-25  6:19   ` Liu, Yi L
2017-12-25  6:57     ` Peter Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).