diff --git a/MdePkg/Library/BaseIoLibIntrinsic/IoLibTdx.c b/MdePkg/Library/BaseIoLibIntrinsic/IoLibTdx.c index a96075caa8b0..eec490ac3816 100644 --- a/MdePkg/Library/BaseIoLibIntrinsic/IoLibTdx.c +++ b/MdePkg/Library/BaseIoLibIntrinsic/IoLibTdx.c @@ -211,6 +211,8 @@ TdMmioRead8 ( UINT64 Value; UINT64 Status; + Address |= TdSharedPageMask (); + MemoryFence (); Status = TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_1, TDVMCALL_ACCESS_READ, Address, 0, &Value); if (Status != 0) { @@ -242,6 +244,8 @@ TdMmioWrite8 ( UINT64 Value; UINT64 Status; + Address |= TdSharedPageMask (); + MemoryFence (); Value = Val; Status = TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_1, TDVMCALL_ACCESS_WRITE, Address, Value, 0); @@ -272,6 +276,8 @@ TdMmioRead16 ( UINT64 Value; UINT64 Status; + Address |= TdSharedPageMask (); + MemoryFence (); Status = TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_2, TDVMCALL_ACCESS_READ, Address, 0, &Value); if (Status != 0) { @@ -305,6 +311,8 @@ TdMmioWrite16 ( ASSERT ((Address & 1) == 0); + Address |= TdSharedPageMask (); + MemoryFence (); Value = Val; Status = TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_2, TDVMCALL_ACCESS_WRITE, Address, Value, 0); @@ -335,6 +343,8 @@ TdMmioRead32 ( UINT64 Value; UINT64 Status; + Address |= TdSharedPageMask (); + MemoryFence (); Status = TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_4, TDVMCALL_ACCESS_READ, Address, 0, &Value); if (Status != 0) { @@ -368,6 +378,8 @@ TdMmioWrite32 ( ASSERT ((Address & 3) == 0); + Address |= TdSharedPageMask (); + MemoryFence (); Value = Val; Status = TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_4, TDVMCALL_ACCESS_WRITE, Address, Value, 0); @@ -398,6 +410,8 @@ TdMmioRead64 ( UINT64 Value; UINT64 Status; + Address |= TdSharedPageMask (); + MemoryFence (); Status = TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_8, TDVMCALL_ACCESS_READ, Address, 0, &Value); if (Status != 0) { @@ -428,6 +442,8 @@ TdMmioWrite64 ( ASSERT ((Address & 7) == 0); + Address |= TdSharedPageMask (); + MemoryFence (); Status = TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_8, TDVMCALL_ACCESS_WRITE, Address, Value, 0); if (Status != 0) {