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

Re: [PATCH v3 2/2] xen/pci: replace call to is_memory_hole to pci_check_bar


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 6 Sep 2022 10:53:52 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PFe3S9fToKmfWXmXNYX7xeWC318ja0UwmItRMLycIc4=; b=mvTonxikV52o+rmA+vgh2sVj0oeRPQTnR7VG53CirGwcrn8fm4e4Zmp5DUhlNy2lql5B2PPU8EHvLXIlmlrHdoT/8LqsfhYECXoSOmNg2HKoTKMQUCQ9qB/irYyEsC97tSNrbFq6Tlr/C4FXHCDEtnl+0pa0tr/utZI0C/Rj75LpWJt0lf/UjP4Oy1qzLG9Kj58N5gf7pdrA5XfTqXjkflBXCF4+nUEGoP1VGJdlbKOYLDS72mGaIZTXcTygDOCapBJD3Y4g1W8+73y7HLMFqCH5XtIPnAOjRniQxPBUvCsxRtnuEsAYnPVyk/wf6vh6XeWjgx+Tlib7F0WD4b8QjA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZvErLYQQOBZ1sX5nKBS3NXhTFftCGnxNIf+yrLjlvz4rCni6mQRQ9P6VMqdb/rn7ZPN0i2gxYO3BP0qsTVkHfzWMiI7YgrdAS/xJccvlkOJJAvNWMysHrl011EP+DnGXUF2twwm4LVxnwmmgOIbZdV9DrAYhTZBHsLm6yRkKRZoVpTuk2/KjNLtTRq5bWLywdUMp5btxh5MO71zqn2lqCUJ+ckfP56cFMkj39yPmF4vOlAJR/WyJpjEhboaiUxTjebhwVfCJWZs77vud1GwHvzEGBR+XwG7Lm4xjcmaUPRdpY/ZMC3HMl2923lJUdp3GJj27Z+AroZ+CulSfP4UFoA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, bertrand.marquis@xxxxxxx, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Paul Durrant <paul@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>
  • Delivery-date: Tue, 06 Sep 2022 21:39:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 03.09.2022 02:24, Stefano Stabellini wrote:
> On Thu, 1 Sep 2022, Rahul Singh wrote:
>> @@ -363,6 +373,39 @@ int __init pci_host_bridge_mappings(struct domain *d)
>>      return 0;
>>  }
>>  
>> +static int is_bar_valid(const struct dt_device_node *dev,
>> +                        uint64_t addr, uint64_t len, void *data)
>> +{
>> +    struct pdev_bar *bar_data = data;
>> +    unsigned long s = mfn_x(bar_data->start);
>> +    unsigned long e = mfn_x(bar_data->end);
>> +
>> +    if ( (s <= e) && (s >= PFN_DOWN(addr)) && (e <= PFN_UP(addr + len - 1)) 
>> )
>> +        bar_data->is_valid =  true;
> 
> 
> This patch looks good and you addressed all Jan's comment well. Before I
> ack it, one question.
> 
> I know that you made this change to address Jan's comment but using
> PFN_DOWN for the (s >= PFN_DOWN(addr)) check and PFN_UP for the (e <=
> PFN_UP(addr + len - 1)) check means that we are relaxing the
> requirements, aren't we?
> 
> I know that this discussion is a bit pointless because addr and len should
> always be page aligned, and if they weren't it would be a mistake. But
> assuming that they are not page aligned, wouldn't we want this check to
> be a strict as possible?
> 
> Wouldn't we want to ensure that the [s,e] range is a strict subset of
> [addr,addr+len-1] ? If so we would need to do the following instead:
> 
>     if ( (s <= e) && (s >= PFN_UP(addr)) && (e <= PFN_DOWN(addr + len - 1)) )
>         bar_data->is_valid =  true;

But that might mean (in theory at least) a partial overlap, which has
to be avoided. The only alternative that I see to Rahul's original
code is to omit use of PFN_DOWN() and PFN_UP() in this construct
altogether. Assuming that's correct for the passed in (addr,len)
tuple.

Jan



 


Rackspace

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