From nobody Tue May 7 15:50:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513837990659186.90848420152201; Wed, 20 Dec 2017 22:33:10 -0800 (PST) Received: from localhost ([::1]:34743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRuPX-0001zU-OS for importer@patchew.org; Thu, 21 Dec 2017 01:32:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRuOX-0001Vp-Ko for qemu-devel@nongnu.org; Thu, 21 Dec 2017 01:31:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eRuOU-0001mN-Hc for qemu-devel@nongnu.org; Thu, 21 Dec 2017 01:31:53 -0500 Received: from mga11.intel.com ([192.55.52.93]:32422) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eRuOU-0001lx-85 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 01:31:50 -0500 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Dec 2017 22:31:49 -0800 Received: from sky-dev.bj.intel.com ([10.238.144.127]) by fmsmga005.fm.intel.com with ESMTP; 20 Dec 2017 22:31:47 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,434,1508828400"; d="scan'208";a="188631061" From: "Liu, Yi L" To: qemu-devel@nongnu.org, peterx@redhat.com, jasowang@redhat.com Date: Thu, 21 Dec 2017 14:15:19 +0800 Message-Id: <1513836919-13458-1-git-send-email-yi.l.liu@linux.intel.com> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Subject: [Qemu-devel] [PATCH] intel_iommu: a fix to vtd_dev_get_trans_type() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Liu, Yi L" , yi.l.liu@intel.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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; } =20 - return vtd_ce_get_type(&ce); + *tt =3D vtd_ce_get_type(&ce); + return 0; } =20 static bool vtd_dev_pt_enabled(VTDAddressSpace *as) { int ret; + uint32_t tt; =20 assert(as); =20 - ret =3D vtd_dev_get_trans_type(as); + ret =3D 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; } =20 - return ret =3D=3D VTD_CONTEXT_TT_PASS_THROUGH; + return tt =3D=3D VTD_CONTEXT_TT_PASS_THROUGH; } =20 /* Return whether the device is using IOMMU translation. */ --=20 1.9.1