AMD/IOMMU: avoid UB in guest CR3 retrieval

Found by looking for patterns similar to the one Julien did spot in
pci_vtd_quirks(). (Not that it matters much here, considering the code
is dead right now.)

Fixes: 3a7947b690 ("amd-iommu: use a bitfield for DTE")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
This commit is contained in:
Jan Beulich committed 2020-11-20 08:28:58 +01:00
1 parent dee7d981b9
commit 846d22d54f
1 file changed
+2 -1
+2 -1
View File
@@ -70,7 +70,8 @@ static void guest_iommu_disable(struct guest_iommu *iommu)
static uint64_t get_guest_cr3_from_dte(struct amd_iommu_dte *dte)
{
return ((dte->gcr3_trp_51_31 << 31) | (dte->gcr3_trp_30_15 << 15) |
return (((uint64_t)dte->gcr3_trp_51_31 << 31) |
(dte->gcr3_trp_30_15 << 15) |
(dte->gcr3_trp_14_12 << 12)) >> PAGE_SHIFT;
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.