Message ID | 535d1050-e5e0-6e1f-5299-f41b84350ca0@suse.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | VT-d: address fallout from XSA-400 | expand |
On Wed, Apr 06, 2022 at 02:25:13PM +0200, Jan Beulich wrote: > Despite the comment there infinite recursion was still possible, by > flip-flopping between two domains. This is because prev_dom is derived > from the DID found in the context entry, which was already updated by > the time error recovery is invoked. Simply introduce yet another mode > flag to detect the situation and cancel further recursion attempts. > > Fixes: 8f41e481b485 ("VT-d: re-assign devices directly") > Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com> Thanks, Roger.
--- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1608,11 +1608,13 @@ int domain_context_mapping_one( */ (prev_dom == dom_io && !pdev) ) ret = domain_context_unmap_one(domain, iommu, bus, devfn); - else if ( prev_dom != domain ) /* Avoid infinite recursion. */ + /* Avoid infinite recursion. */ + else if ( prev_dom != domain && !(mode & MAP_ERROR_RECOVERY) ) ret = domain_context_mapping_one(prev_dom, iommu, bus, devfn, pdev, DEVICE_DOMID(prev_dom, pdev), DEVICE_PGTABLE(prev_dom, pdev), - mode & MAP_WITH_RMRR) < 0; + (mode & MAP_WITH_RMRR) | + MAP_ERROR_RECOVERY) < 0; else ret = 1; --- a/xen/drivers/passthrough/vtd/vtd.h +++ b/xen/drivers/passthrough/vtd/vtd.h @@ -29,7 +29,8 @@ #define MAP_WITH_RMRR (1u << 0) #define MAP_OWNER_DYING (1u << 1) #define MAP_SINGLE_DEVICE (1u << 2) -#define UNMAP_ME_PHANTOM_FUNC (1u << 3) +#define MAP_ERROR_RECOVERY (1u << 3) +#define UNMAP_ME_PHANTOM_FUNC (1u << 4) /* Allow for both IOAPIC and IOSAPIC. */ #define IO_xAPIC_route_entry IO_APIC_route_entry
Despite the comment there infinite recursion was still possible, by flip-flopping between two domains. This is because prev_dom is derived from the DID found in the context entry, which was already updated by the time error recovery is invoked. Simply introduce yet another mode flag to detect the situation and cancel further recursion attempts. Fixes: 8f41e481b485 ("VT-d: re-assign devices directly") Signed-off-by: Jan Beulich <jbeulich@suse.com>