public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zhiquan Li" <zhiquan1.li@intel.com>
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	[thread overview]
Message-ID: <20240112021557.813290-1-zhiquan1.li@intel.com> (raw)

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 <zhiquan1.li@intel.com>
---
 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 (
 
   Status = TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_1, TDVMCALL_ACCESS_READ, Address | TdSharedPageMask (), 0, &Value);
   if (Status != 0) {
-    Value = *(volatile UINT64 *)Address;
+    Value = *(volatile UINT8 *)Address;
   }
 
   return (UINT8)Value;
@@ -294,7 +294,7 @@ TdMmioRead16 (
 
   Status = TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_2, TDVMCALL_ACCESS_READ, Address | TdSharedPageMask (), 0, &Value);
   if (Status != 0) {
-    Value = *(volatile UINT64 *)Address;
+    Value = *(volatile UINT16 *)Address;
   }
 
   return (UINT16)Value;
@@ -353,7 +353,7 @@ TdMmioRead32 (
 
   Status = TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_4, TDVMCALL_ACCESS_READ, Address | TdSharedPageMask (), 0, &Value);
   if (Status != 0) {
-    Value = *(volatile UINT64 *)Address;
+    Value = *(volatile UINT32 *)Address;
   }
 
   return (UINT32)Value;
-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
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/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



             reply	other threads:[~2024-01-12 19:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-12  2:15 Zhiquan Li [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-01-12  6:02 [edk2-devel] [PATCH] MdePkg: fix the types of casting for TD MMIO read Zhiquan Li
2024-01-20  2:49 ` Michael D Kinney
2024-01-20  4:39   ` Michael D Kinney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240112021557.813290-1-zhiquan1.li@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox