Skip to content

Commit 787a817

Browse files
EthsanMichael Tokarev
authored andcommitted
amd_iommu: Fix truncation of oldval in amdvi_writeq
The variable `oldval` was incorrectly declared as a 32-bit `uint32_t`. This could lead to truncation and incorrect behavior where the upper read-only 32 bits are significant. Fix the type of `oldval` to match the return type of `ldq_le_p()`. Cc: [email protected] Fixes: d29a09c ("hw/i386: Introduce AMD IOMMU") Signed-off-by: Ethan Milon <[email protected]> Message-Id: <[email protected]> Reviewed-by: Vasant Hegde <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> (cherry picked from commit 5788929e05e18ed5f76dc8ade4210f022c9ba5a1) Signed-off-by: Michael Tokarev <[email protected]>
1 parent fc1ad51 commit 787a817

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

hw/i386/amd_iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static void amdvi_writeq(AMDVIState *s, hwaddr addr, uint64_t val)
140140
{
141141
uint64_t romask = ldq_le_p(&s->romask[addr]);
142142
uint64_t w1cmask = ldq_le_p(&s->w1cmask[addr]);
143-
uint32_t oldval = ldq_le_p(&s->mmior[addr]);
143+
uint64_t oldval = ldq_le_p(&s->mmior[addr]);
144144
stq_le_p(&s->mmior[addr],
145145
((oldval & romask) | (val & ~romask)) & ~(val & w1cmask));
146146
}

0 commit comments

Comments
 (0)