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

Re: [PATCH v3] xen/pci: detect when BARs are not suitably positioned


  • To: Julien Grall <julien@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 2 Feb 2022 11:05:46 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ratNYSfrRorbiM7zyzZLpSz4meXwcrFeqbTdcFve2ao=; b=DBGX/uU1P+QtgkPjD/zKjVVaRol/c5ehRDdsgJLUevfhVAzEwW/jLsp5ctz7pEpO7Ox/brNLPKEgRucbV9HY0ZB0VKn3VBK/Gut2g30K3k4yxaodDG0SLMxPZwCWXWxE8I/78bJjy5F+Npg/bfao3iLi0GwnsOdiTd/6JeEifEyjUAuuGp2g4KQGkwHvbqumWIQMd/Bikl7OI8F9fouGtAzrfPYLbkWYh7Rt/TKzzTTexPsUM3/IyMyVE1Ge56+Xqm7X472BzmiJaPq66tyCztE8keJmepbcGJ3tRC750QMmv67k9FTBccoEvBXXZoT2EDu/Nud8oXx6z+gBSBQrxA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TdojwcLHDrxxH0sXLUnVo3Gs0YKZbi/UKdsVBN3dQCQX2Tynm/k5OiRtUbtaFfK8h/mW0pzc7z3uz/i6kiTi+CE90KMDnxB8YjOyYg8XfSGjpbjvOIu6iZINRh2Yi0adpVYLOFWtJJSgsBjA8AVWOnprKHXPIMckpTVSn0zJDq/2uW0+dxj5k5i7LavUDuliDhyI2jD6+fZ8YR3z8BiTFe/s07Ed/RKj6EI4HjMdI8TGOWVgob2ALG+5S3Lno7EXhwmP24debBcEbP5JuDxjRxHrjb0t1GDJOuaXABLUyw78XfqFZvKuoQGJKcxo/58zH+8XBNJMARRLfxD5YZ278w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Delivery-date: Wed, 02 Feb 2022 10:05:54 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 02.02.2022 10:57, Julien Grall wrote:
> On 02/02/2022 09:42, Jan Beulich wrote:
>> On 01.02.2022 13:45, Roger Pau Monne wrote:
>>> --- a/xen/arch/x86/mm.c
>>> +++ b/xen/arch/x86/mm.c
>>> @@ -783,6 +783,23 @@ bool is_iomem_page(mfn_t mfn)
>>>       return (page_get_owner(page) == dom_io);
>>>   }
>>>   
>>> +bool is_memory_hole(unsigned long start, unsigned long end)
>>> +{
>>> +    unsigned int i;
>>> +
>>> +    for ( i = 0; i < e820.nr_map; i++ )
>>> +    {
>>> +        const struct e820entry *entry = &e820.map[i];
>>> +
>>> +        /* Do not allow overlaps with any memory range. */
>>> +        if ( start < PFN_DOWN(entry->addr + entry->size) &&
>>> +             PFN_DOWN(entry->addr) <= end )
>>> +            return false;
>>> +    }
>>> +
>>> +    return true;
>>> +}
>>
>> Doesn't the left side of the && need to use PFN_UP()?
>>
>> I also think it would help if a brief comment ahead of the
>> function said that the range is inclusive. Otherwise the use
>> of < and >= gives the impression of something being wrong.
>> Then again it may be better to switch to <= anyway, as I
>> think you want to avoid possible zero-size regions (at which
>> point subtracting 1 for using <= is going to be valid).
>>
>> Finally I wonder whether the function parameters wouldn't
>> better be named e.g. spfn and epfn, but maybe their units can
>> be inferred from their types being unsigned long (which,
>> however, would build on the assumption that we use appropriate
>> types everywhere).
> 
> I think this a case where mfn_t would be useful to use.

Actually I did consider to suggest it when asking to convert
to frame numbers, and specifically didn't because its use will
clutter the code here quite a bit. Which isn't to mean I'd
object if the adjustment was made ...

Jan




 


Rackspace

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