intel_iommu: fixing source id during IOTLB hash key calculation
PATCH 1/1 intel_iommu: fixing source id during IOTLB hash key calculation
Using uint8_t for source id will lose bus num and get the wrong/invalid IOTLB entry. Fixing by using uint16_t instead and enlarge level shift.
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Signed-off-by Jason Wang <[email protected]>
--- hw/i386/intel_iommu.c | 2 +- hw/i386/intel_iommu_internal.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/i386/intel_iommu.c +1 -1
@@ -215,7 +215,7 @@ static void vtd_reset_iotlb(IntelIOMMUState *s)g_hash_table_remove_all (s->iotlb); } -static uint64_t vtd_get_iotlb_key (uint64_t gfn,uint8_t source_id, +static uint64_t vtd_get_iotlb_key (uint64_t gfn,uint16_t source_id,uint32_t level) { return gfn | ((uint64_t)(source_id) << VTD_IOTLB_SID_SHIFT) |
hw/i386/intel_iommu_internal.h +1 -1
@@ -115,7 +115,7 @@/* The shift of source_id in the key of IOTLB hash table */ #define VTD_IOTLB_SID_SHIFT 36 -#define VTD_IOTLB_LVL_SHIFT 44 +#define VTD_IOTLB_LVL_SHIFT 52#define VTD_IOTLB_MAX_SIZE 1024/* Max size of the hash table */ /* IOTLB_REG */
Signature · 1 line
2.7.4
Quoted 9 lines · Jason Wang
Using
uint8_tfor source id will lose bus num and get the wrong/invalid IOTLB entry. Fixing by usinguint16_tinstead and enlarge level shift.Cc Paolo Bonzini <[email protected]>Cc Richard Henderson <[email protected]>Cc Eduardo Habkost <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Jason Wang <[email protected]>
Reviewed-by Peter Xu <[email protected]>