Skip to content

Commit 1ca9d2e

Browse files
aljimenezbMichael Tokarev
authored andcommitted
amd_iommu: Fix Device ID decoding for INVALIDATE_IOTLB_PAGES command
The DeviceID bits are extracted using an incorrect offset in the call to amdvi_iotlb_remove_page(). This field is read (correctly) earlier, so use the value already retrieved for devid. Cc: [email protected] Fixes: d29a09c ("hw/i386: Introduce AMD IOMMU") Signed-off-by: Alejandro Jimenez <[email protected]> Reviewed-by: Vasant Hegde <[email protected]> Message-Id: <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> (cherry picked from commit c63b8d1425ba8b3b08ee4f7346457fd8a7f12a24) Signed-off-by: Michael Tokarev <[email protected]>
1 parent 10a9eed commit 1ca9d2e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

hw/i386/amd_iommu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ static void amdvi_inval_inttable(AMDVIState *s, uint64_t *cmd)
508508
static void iommu_inval_iotlb(AMDVIState *s, uint64_t *cmd)
509509
{
510510

511-
uint16_t devid = extract64(cmd[0], 0, 16);
511+
uint16_t devid = cpu_to_le16(extract64(cmd[0], 0, 16));
512512
if (extract64(cmd[1], 1, 1) || extract64(cmd[1], 3, 1) ||
513513
extract64(cmd[1], 6, 6)) {
514514
amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4),
@@ -521,7 +521,7 @@ static void iommu_inval_iotlb(AMDVIState *s, uint64_t *cmd)
521521
&devid);
522522
} else {
523523
amdvi_iotlb_remove_page(s, cpu_to_le64(extract64(cmd[1], 12, 52)) << 12,
524-
cpu_to_le16(extract64(cmd[1], 0, 16)));
524+
devid);
525525
}
526526
trace_amdvi_iotlb_inval();
527527
}

0 commit comments

Comments
 (0)