[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v7 1/8] AMD/IOMMU: check / convert IVMD ranges for being / to be reserved


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Thu, 26 Aug 2021 13:10:14 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S7Uc5TIHZISEM7DFkRn6MOnP9gHt5BLon77i8zu0xQ0=; b=lHD4tYcZtKaDutZIV8twZZTo6mkuYaUGv85D/e/YhkU/AWg2vEOsZ32bo+cuBvFld8Oo9DexJoDBzywfw+DaWqu+3Wuvq/c0KkFvyRsSJUTAyOes6K2rubfDjGKFybcbyS0qxLHnDPRHxVEXKjoI74YjxgQvIJdaVxVfE6q+HymLWy7XrLxKciS5yBLL4A60pkO+zzRX2uGP9s0INzp6dOlIt3fp7O7YaAOtSDmDYq9tyu6YNeZFdSlhfJI0wCnpA01wPBfKRs7LxMCOzVyP+C9W0iAxnIpRfbk5j8l3YqbbCTdD1ldZxitmby1D0C3gCyL+CWbMVORntHsSfgOqLw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cJuPnJOzNi/AOz4iYvbycooZBP0KwZTbtpnIBAwAdvaPO95N5MTig8/6tv899Aw3MTfPT87Jxo3v7Q5McFVvCudwJ1KhM/zc0E0Hc6U6SjvMi/lNu6CuC15U6guP00c9CjI73ixlKkzIp0eIjTPeCfUL0Lb+bYALW53wOfn00HkG3OlaFuLOUFPz+G8t3FgrFtsnVpFN9jZMwQ/ZIXyWEZYzIyTylLQDdgZdimen3vLRFYX4XFcGFm0qp6zUhoL+slwTilHjsGMIfNd0lx2WxfSWuwHAIsG6uKMqKeZGAtyxRE7JQ269u3eGCjxzyqe867R7g0ZPoYMF/0yExykeKA==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Thu, 26 Aug 2021 12:10:29 +0000
  • Ironport-hdrordr: A9a23:RkGczKGex76HYA4kpLqEEseALOsnbusQ8zAXPiBKJCC9vPb5qy nOpoV+6faQslwssR4b9uxoVJPvfZq+z+8R3WByB8bAYOCOggLBQL2KhbGI/9SKIVydygcy78 Zdm6gVMqyMMbB55/yKnDVRxbwbsaa6GKPDv5ah8590JzsaDJ2Jd21Ce32m+ksdfnghObMJUK Cyy+BgvDSadXEefq2AdwM4t7iqnayzqHr+CyR2fyIa1A==
  • Ironport-sdr: 1Nu4iBAF/LHP3f+8rPQFnvcMEZgU6sxdTdp/+obg3VaXUbIdqv+CR0TAk3iOvn7COi/rc+k+Di YjyQT7N2e6T1qKUPrxOmhyZYn5Wrgy9xdKtDib+kghf+WuHBTgQ+WSEMfvp6OIZ8YBR/BHiCnR tI0QxQt2Xt89rShccaD2ySQ1PHcU9Bx/0NEFGDX695OrdWICx382K7WfWlriDVsXBE0E9Yo2fR SpqivQezDotDVYecyM4Wrm5OBTzBG7sb6Ocw+2zUIqb8kGuYeE0VuXI4ltqcJ8IStbxbgxnMeK qoEkFbQ0toonor3Sa1hs3FkV
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 26/08/2021 08:23, Jan Beulich wrote:
> While the specification doesn't say so, just like for VT-d's RMRRs no
> good can come from these ranges being e.g. conventional RAM or entirely
> unmarked and hence usable for placing e.g. PCI device BARs. Check
> whether they are, and put in some limited effort to convert to reserved.
> (More advanced logic can be added if actual problems are found with this
> simplistic variant.)
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> Reviewed-by: Paul Durrant <paul@xxxxxxx>
> ---
> v7: Re-base.
> v5: New.
>
> --- a/xen/drivers/passthrough/amd/iommu_acpi.c
> +++ b/xen/drivers/passthrough/amd/iommu_acpi.c
> @@ -384,6 +384,38 @@ static int __init parse_ivmd_block(const
>      AMD_IOMMU_DEBUG("IVMD Block: type %#x phys %#lx len %#lx\n",
>                      ivmd_block->header.type, start_addr, mem_length);
>  
> +    if ( !e820_all_mapped(base, limit + PAGE_SIZE, E820_RESERVED) )
> +    {
> +        paddr_t addr;
> +
> +        AMD_IOMMU_DEBUG("IVMD: [%lx,%lx) is not (entirely) in reserved 
> memory\n",
> +                        base, limit + PAGE_SIZE);
> +
> +        for ( addr = base; addr <= limit; addr += PAGE_SIZE )
> +        {
> +            unsigned int type = page_get_ram_type(maddr_to_mfn(addr));
> +
> +            if ( type == RAM_TYPE_UNKNOWN )
> +            {
> +                if ( e820_add_range(&e820, addr, addr + PAGE_SIZE,
> +                                    E820_RESERVED) )
> +                    continue;
> +                AMD_IOMMU_DEBUG("IVMD Error: Page at %lx couldn't be 
> reserved\n",
> +                                addr);
> +                return -EIO;
> +            }
> +
> +            /* Types which won't be handed out are considered good enough. */
> +            if ( !(type & (RAM_TYPE_RESERVED | RAM_TYPE_ACPI |
> +                           RAM_TYPE_UNUSABLE)) )
> +                continue;
> +
> +            AMD_IOMMU_DEBUG("IVMD Error: Page at %lx can't be converted\n",
> +                            addr);

I think these print messages need to more than just debug.  The first
one is a warning, whereas the final two are hard errors liable to impact
the correct running of the system.

Especially as you're putting them in to try and spot problem cases, they
should be visible by default for when we inevitably get bug reports to
xen-devel saying "something changed with passthrough in Xen 4.16".

~Andrew


> +            return -EIO;
> +        }
> +    }
> +
>      if ( ivmd_block->header.flags & ACPI_IVMD_EXCLUSION_RANGE )
>          exclusion = true;
>      else if ( ivmd_block->header.flags & ACPI_IVMD_UNITY )
>




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.