summaryrefslogtreecommitdiff
path: root/src/VBox/Devices/Security/DevTpm.cpp
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2021-08-26 09:49:06 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2021-08-26 09:49:06 +0000
commitfb4e4e9ec34f00dd179aafea46cadf5f855287cb (patch)
tree0cae1d2eefd2bda775fea82b45cfd134442276b9 /src/VBox/Devices/Security/DevTpm.cpp
parent1c313987ff6700072e0836793001e875aaf5b6a5 (diff)
downloadVirtualBox-svn-fb4e4e9ec34f00dd179aafea46cadf5f855287cb.tar.gz
Devices/Security/DevTpm: Allow unaligned reads, Windows loves to access the FIFO status register unaligned, bugref:10075
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@90904 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/Devices/Security/DevTpm.cpp')
-rw-r--r--src/VBox/Devices/Security/DevTpm.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/VBox/Devices/Security/DevTpm.cpp b/src/VBox/Devices/Security/DevTpm.cpp
index e52cde9a9e3..160b8dfa9c6 100644
--- a/src/VBox/Devices/Security/DevTpm.cpp
+++ b/src/VBox/Devices/Security/DevTpm.cpp
@@ -1128,11 +1128,12 @@ static DECLCALLBACK(VBOXSTRICTRC) tpmMmioRead(PPDMDEVINS pDevIns, void *pvUser,
PDEVTPM pThis = PDMDEVINS_2_DATA(pDevIns, PDEVTPM);
RT_NOREF(pvUser);
- Assert(!(off & (cb - 1)));
+ RTGCPHYS offAligned = off & ~UINT64_C(0x3);
+ uint8_t cBitsShift = (off & 0x3) * 8;
VBOXSTRICTRC rc = VINF_SUCCESS;
- uint32_t uReg = tpmGetRegisterFromOffset(off);
- uint8_t bLoc = tpmGetLocalityFromOffset(off);
+ uint32_t uReg = tpmGetRegisterFromOffset(offAligned);
+ uint8_t bLoc = tpmGetLocalityFromOffset(offAligned);
PDEVTPMLOCALITY pLoc = &pThis->aLoc[bLoc];
uint64_t u64;
@@ -1147,9 +1148,9 @@ static DECLCALLBACK(VBOXSTRICTRC) tpmMmioRead(PPDMDEVINS pDevIns, void *pvUser,
{
switch (cb)
{
- case 1: *(uint8_t *)pv = (uint8_t)u64; break;
- case 2: *(uint16_t *)pv = (uint16_t)u64; break;
- case 4: *(uint32_t *)pv = (uint32_t)u64; break;
+ case 1: *(uint8_t *)pv = (uint8_t)(u64 >> cBitsShift); break;
+ case 2: *(uint16_t *)pv = (uint16_t)(u64 >> cBitsShift); break;
+ case 4: *(uint32_t *)pv = (uint32_t)(u64 >> cBitsShift); break;
case 8: *(uint64_t *)pv = u64; break;
default: AssertFailedBreakStmt(rc = VERR_INTERNAL_ERROR);
}