From nobody Fri May 17 04:49:53 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+113765+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+113765+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1705086967; cv=none; d=zohomail.com; s=zohoarc; b=G7rIXoO7J/jpw00SmD7TiLlppiBt9xeAXuGtNAGbW2dC8plp8/bk8+9WEk4UdXL3KyuoZFbAoyt5QtSVlEIrStqcZiTXpYl9peMlG1TDBcTRyQMxbGCcPaYSBTlBq5d8H2SKl1/FA5VNf5TPahUm0f5JjNyAwfqqd+sCOCepUco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705086967; 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=EmwdRb7gM6v6a6FErBarjJxK8dVBGq9muT63DG10nKw=; b=WMrejfc90jaHtMHu/2w134ZhdHl0z8ZPNcfjYKPibDP6fHFfYuqaJYSwKx+b+mCrwWyFvNJtKEb3HMXJKMzSCHVJU6rz6APZnJRgaHQWB/LqpxDT/zk7Ebl6ejeFs8a66/bY6YH4EX76V0voLZ+bewpkWABIkP3EPmzzhJVvdFY= 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+113765+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 1705086967107467.1564486737401; Fri, 12 Jan 2024 11:16:07 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=QVH+0mIsEfBtUJEdaGjcZMYspsJcwRTRZ5D1RGKBHBQ=; 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=bvCFvF/7BwTEiJXLpC0CkmFUplW+hAVe8djkiiEGVT/HFD81Qfpepn7EhrnGSdFKkvXBFFjd SV5MTPN+D9aR7OgqpySpAwfc5UdXe5vQOQJiBR/LvzEGcReKcx0ovI0zc/7j2QDAtuUFdbJgQsZ oR2dZJ2YHsDERcXJn6QnVyI8= X-Received: by 127.0.0.2 with SMTP id Rw46YY1788612xjHsDBBwZTQ; Fri, 12 Jan 2024 11:16:06 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by mx.groups.io with SMTP id smtpd.web10.1463.1705038041141047884 for ; Thu, 11 Jan 2024 21:40:41 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10950"; a="12445915" X-IronPort-AV: E=Sophos;i="6.04,188,1695711600"; d="scan'208";a="12445915" X-Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jan 2024 21:40:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10950"; a="782919245" X-IronPort-AV: E=Sophos;i="6.04,188,1695711600"; d="scan'208";a="782919245" X-Received: from zhiquan-linux-dev.bj.intel.com ([10.238.156.102]) by orsmga002.jf.intel.com with ESMTP; 11 Jan 2024 21:40:18 -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 14:02:20 +0800 Message-Id: <20240112060220.824280-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: 73LNHWlLeSzu5PA4ik5G1GFRx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1705086968142100035 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 Reviewed-by: Michael D Kinney --- 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 (#113765): https://edk2.groups.io/g/devel/message/113765 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-