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

Re: [PATCH 2/2] x86/vpci: refuse to map BARs at position 0


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Tue, 3 Jun 2025 16:47:55 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=citrix.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=auvcygLBSRlC2nO2N4ZqD++PYsSu95L6zPf6TAUUoJE=; b=DaYKGW3Vc4syTLlA49P0iG/2BD5/TB7k/gZB3j1RjFW1Sc0BIYMxiSZxAyPTiRBHsKdFdGYvhPgQRTOtX/OWMx/FDvk/SzgRU0yPt8xwzxCdajQ9HeMMt9ZIG8AkEfCAFhm8tNJH4wR5sb7za2eKNS1BHRtZjRvHqwOmhq+h3KotyD3//t4f+AcQfBMFd54AZoF77rSAppYDgeUazgj2IoUO79DieREYs4+ae9qWLfZZ8O8BLL/amvgxFlHdYTO3CrNbDhAJpkN+FI3GhJwcUAIAZzDBM03k86JCq2Ywv/sGv5FZWsRp/F9ogl1mF0Db6QGCnBYqAbILpx4bECBRmQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kqTjlKgLNsk8zRZTddCHhOpDpQ3zu6DTaFIsl3DcgdT+SLHvIE0M5nBplS8xMhEQGVfrfhGRcOg4Z5EW6311XYRHjZ1OdJ2ei1kBsG7fEFArOZPJSfYi5CSBUCrOALk6LOIO9Ks2D77jERHRQik5rx1PhBNlDnMleH73y9orMzGO90sGeQlmVt9mb7lS25CMMqFKTM10uBoLvbOJC5GWmoK2EmV99RyTE7gi3+dQxq45k02LPg9cYcrfUyF0/Q1PDFgXCfisQ5vKSDGGECQ4U9dxWE4myyC5jQeHP76kd0YNOtxNbSipQPiYSyY0D2iKO67A2dXY6kbaw7MWHKcLnw==
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 03 Jun 2025 20:48:19 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 5/22/25 12:24, Roger Pau Monné wrote:
> On Thu, May 22, 2025 at 11:44:24AM -0400, Stewart Hildebrand wrote:
>> On 5/22/25 10:59, Jan Beulich wrote:
>>> On 22.05.2025 16:03, Roger Pau Monne wrote:
>>>> diff --git a/xen/arch/x86/pci.c b/xen/arch/x86/pci.c
>>>> index 26bb7f6a3c3a..39fd5a16a4aa 100644
>>>> --- a/xen/arch/x86/pci.c
>>>> +++ b/xen/arch/x86/pci.c
>>>> @@ -101,6 +101,15 @@ int pci_conf_write_intercept(unsigned int seg, 
>>>> unsigned int bdf,
>>>>  
>>>>  bool pci_check_bar(const struct pci_dev *pdev, mfn_t start, mfn_t end)
>>>>  {
>>>> +    /*
>>>> +     * Refuse to map BARs at position 0, those are not initialized.  This 
>>>> might
>>>> +     * be required by Linux, that can reposition BARs with memory decoding
>>>> +     * enabled.  By returning false here bar->enabled will be set to 
>>>> false, and
>>>> +     * bar_write() will work as expected.
>>>> +     */
>>>> +    if ( mfn_eq(start, _mfn(0)) )
>>>> +        return false;
>>>
>>> Is this really x86-specific?
>>
>> No, I think Arm would benefit from this check too. I'm in favor of
>> moving the check to common.
> 
> I think on ARM pci_check_bar() is more strict, and doesn't really need
> this check since it explicitly checks whether the BAR falls inside of
> a bridge window.
> 
> So unless you have a bridge window at mfn 0 this won't make a
> difference.  And if you have a bridge window at mfn 0 you really want
> to be able to position BARs at address 0.
> 
> Thanks, Roger.

True, but I was thinking more generally: if a BAR is not initialized,
don't map it. On Arm, it seems to be hit or miss whether BARs have been
initialized or not. I guess the difficulty lies in whether comparing to
zero is a reliable test to determine if the BAR is uninitialized.



 


Rackspace

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