AMD/IOMMU: fix off-by-one in amd_iommu_get_paging_mode() callers
authorJan Beulich <jbeulich@suse.com>
Mon, 16 Mar 2020 10:24:29 +0000 (11:24 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 16 Mar 2020 10:24:29 +0000 (11:24 +0100)
commitb75b3c62fe4afe381c6f74a07f614c0b39fe2f5d
tree676a39735ec15a4e825de67c9c876dd51dab24ac
parentd094e95fb7c61c5f46d8e446b4bdc028438dea1c
AMD/IOMMU: fix off-by-one in amd_iommu_get_paging_mode() callers

amd_iommu_get_paging_mode() expects a count, not a "maximum possible"
value. Prior to b4f042236ae0 dropping the reference, the use of our mis-
named "max_page" in amd_iommu_domain_init() may have lead to such a
misunderstanding. In an attempt to avoid such confusion in the future,
rename the function's parameter and - while at it - convert it to an
inline function.

Also replace a literal 4 by an expression tying it to a wider use
constant, just like amd_iommu_quarantine_init() does.

Fixes: ea38867831da ("x86 / iommu: set up a scratch page in the quarantine domain")
Fixes: b4f042236ae0 ("AMD/IOMMU: Cease using a dynamic height for the IOMMU pagetables")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/drivers/passthrough/amd/iommu.h
xen/drivers/passthrough/amd/iommu_map.c
xen/drivers/passthrough/amd/pci_amd_iommu.c