From nobody Fri May 17 02:03:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+113763+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113763+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1705086966; cv=none; d=zohomail.com; s=zohoarc; b=W4JXbBpuzCxFy1d+y2huTix2gnYuXeNZPrAng1KC8aXU+q0nU0tOo1UE3h0vBxC9wBmTP3vgxBQKA163IuSdPwJdiiAa/QAbsnq2A0HmkNe7x20RYKXHidzh+hUXQrdjgulbVE5TPnMXxFtYXTOp6OVBN4Tdxk+ga+M/Lcqdmzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705086966; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=B1JurjsEwjWhc+dRh9Ak6aP7nBADJzBlVGhNkYO7hpg=; b=MjSAJlwoAXB4z4TQsrxJm0T0sgvT5MAgaFNgMVHFYn2wIjKFWqSPbiyrHRiXt65ETv//5bIcFHjBS2YM0pI27iMU+UJ5NNetf/odktdKEECEw/HM7mQrKgQgWz0G8zXUePPVY4gS7GU1xoTJqxX4LT6zs/ZpDnmU/kwzVlm2Dm0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113763+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1705086966385122.61992431115641; Fri, 12 Jan 2024 11:16:06 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=vwRlwlkRl19VEa4wpQXkuN1Kk71cp4Fb5pjxHQyCX10=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1705086966; v=1; b=gcOT1yUs5dWPhGWAYFc25HVjm2wQZzneb61KrWSaTMAgNnOfiBBV4f59BVH76NqNu2FbwRYB UpBzo6KOtZdzJSNAm4qCjWXnfa+c4qZn56PEbec/cHZVp6HVtvPXDJoR+gDvpyt3+R900NIkjhp ZtwoX+QcEqDyBK/2DmvIMWq0= X-Received: by 127.0.0.2 with SMTP id zWaVYY1788612xtvEmBUEThC; Fri, 12 Jan 2024 11:16:06 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web11.9977.1705024435917917572 for ; Thu, 11 Jan 2024 17:53:56 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10950"; a="485234236" X-IronPort-AV: E=Sophos;i="6.04,188,1695711600"; d="scan'208";a="485234236" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jan 2024 17:53:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10950"; a="786197970" X-IronPort-AV: E=Sophos;i="6.04,188,1695711600"; d="scan'208";a="786197970" X-Received: from zhiquan-linux-dev.bj.intel.com ([10.238.156.102]) by fmsmga007.fm.intel.com with ESMTP; 11 Jan 2024 17:53:49 -0800 From: "Zhiquan Li" To: devel@edk2.groups.io Cc: zhiquan1.li@intel.com Subject: [edk2-devel] [PATCH] MdePkg: fix the types of casting for TD MMIO read Date: Fri, 12 Jan 2024 10:15:57 +0800 Message-Id: <20240112021557.813290-1-zhiquan1.li@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zhiquan1.li@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: j7ygFiTrhUhkhkUM2r7HbDXOx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1705086968130100033 Content-Type: text/plain; charset="utf-8" Currently the types of casting mismatch with TD MMIO read 1, 2 and 4 bytes, that might introduce potential issues. So fix the types as conventional MmioRead[8|16|32] does. Signed-off-by: Zhiquan Li --- MdePkg/Library/BaseIoLibIntrinsic/IoLibInternalTdx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MdePkg/Library/BaseIoLibIntrinsic/IoLibInternalTdx.c b/MdePkg/= Library/BaseIoLibIntrinsic/IoLibInternalTdx.c index ec837f5eb03e..1acc3b3d9638 100644 --- a/MdePkg/Library/BaseIoLibIntrinsic/IoLibInternalTdx.c +++ b/MdePkg/Library/BaseIoLibIntrinsic/IoLibInternalTdx.c @@ -237,7 +237,7 @@ TdMmioRead8 ( =20 Status =3D TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_1, TDVMCALL_ACC= ESS_READ, Address | TdSharedPageMask (), 0, &Value); if (Status !=3D 0) { - Value =3D *(volatile UINT64 *)Address; + Value =3D *(volatile UINT8 *)Address; } =20 return (UINT8)Value; @@ -294,7 +294,7 @@ TdMmioRead16 ( =20 Status =3D TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_2, TDVMCALL_ACC= ESS_READ, Address | TdSharedPageMask (), 0, &Value); if (Status !=3D 0) { - Value =3D *(volatile UINT64 *)Address; + Value =3D *(volatile UINT16 *)Address; } =20 return (UINT16)Value; @@ -353,7 +353,7 @@ TdMmioRead32 ( =20 Status =3D TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_4, TDVMCALL_ACC= ESS_READ, Address | TdSharedPageMask (), 0, &Value); if (Status !=3D 0) { - Value =3D *(volatile UINT64 *)Address; + Value =3D *(volatile UINT32 *)Address; } =20 return (UINT32)Value; --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113763): https://edk2.groups.io/g/devel/message/113763 Mute This Topic: https://groups.io/mt/103689726/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-