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

Re: [PATCH] xen/arm: pci: fix check in pci_check_bar()


  • To: Julien Grall <julien@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Tue, 11 Jul 2023 14:39:50 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=xen.org 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
  • 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=sx8DOHT2p5MU8kS/X9RGeA2+Wmz1iLb+nZoRNiHb5d8=; b=RiW9kwOZXf64M73QMvn1NFiL8jaFYhfSt7alTh+7hmEhZ1ByeWyCpODdQVeItPeELuqt2FGmSDadIylLGJq2DYw1bcijFPhpnlERzBnHCfA5eUOb3ksftL8+JfBPmxS38SuxtqeLQSTflyYWvtna7mHhOe6NwAnlfiet/lJXfx2W9zWJazoquLVngUqaMmnpUqqHa/qyJ8BTVCrSq3OOn5UzPduC7wXPekAJGSQJD1nTvo7Mz/j+6ZdE2Rr0vziegAkPF2lak566DeyxtsX1gXC0FSjUYcq2OK+d+i4IStenrqOWaGbPy/xmk38rK+DxaY2H1BwCV6qSwsqtbLQAAA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c+G17aqSaUlumij63/FZ+tbsK1ve9YfIxEP+00AN4GNqkdgYWw9deyaqwanOiLiFZaRjs3oGMvYd7ah7owxwtYbNR4HHhcDd09h0verKzcV0c4Pa6T1HhNDhBPY/hQV/WYMsys8IvJT8WVbPxpbIiSljQMDYCby3ut42ZG05EI5LbgLrTlNoELf6ix4k1KZj6gJ1ErRn5/eZISE9D8Wet5HvqQpbPl08EHLIKo+ugnDY0nlN6jTVI0JeCUoIbQCfTnHUzcKB/IPDEFey//K56MMrtPgyTLLTJZH3Opka0G6CZjdwDzdr/feb1x5NQkjz6uqaafjx9LDECOX0maq8xA==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>
  • Delivery-date: Tue, 11 Jul 2023 18:40:19 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 7/11/23 12:10, Julien Grall wrote:
> Hi,
> 
> On 11/07/2023 16:46, Stewart Hildebrand wrote:
>> When mapping BARs for vPCI, it's valid for a BAR start address to equal the 
>> BAR
>> end address (i.e. s == e). However, pci_check_bar() currently returns false 
>> in
>> this case, which results in Xen not mapping the BAR. In this example boot 
>> log,
>> Linux has mapped the BARs, but since Xen did not map them, Linux encounters a
>> data abort and panics:
>>
>> [    2.593300] pci 0000:00:00.0: BAR 0: assigned [mem 0x50008000-0x50008fff]
>> [    2.593682] pci 0000:00:00.0: BAR 2: assigned [mem 0x50009000-0x50009fff]
>> [    2.594066] pci 0000:00:00.0: BAR 4: assigned [mem 0x5000a000-0x5000afff]
>> ...
>> [    2.810502] virtio-pci 0000:00:00.0: enabling device (0000 -> 0002)
>> (XEN) 0000:00:00.0: not mapping BAR [50008, 50008] invalid position
>> (XEN) 0000:00:00.0: not mapping BAR [50009, 50009] invalid position
>> (XEN) 0000:00:00.0: not mapping BAR [5000a, 5000a] invalid position
>> [    2.817502] virtio-pci 0000:00:00.0: virtio_pci: leaving for legacy driver
>> [    2.817853] virtio-pci 0000:00:00.0: enabling bus mastering
>> (XEN) arch/arm/traps.c:1992:d0v0 HSR=0x00000093010045 pc=0xffff8000089507d4 
>> gva=0xffff80000c46d012 gpa=0x00000050008012
>> [    2.818397] Unable to handle kernel ttbr address size fault at virtual 
>> address ffff80000c46d012
>> ...
>>
>> Fix this by changing the condition in pci_check_bar().
>>
>> Fixes: cc80e2bab0d0 ("xen/pci: replace call to is_memory_hole to 
>> pci_check_bar")
>> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
>> ---
>>   xen/arch/arm/pci/pci-host-common.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/xen/arch/arm/pci/pci-host-common.c 
>> b/xen/arch/arm/pci/pci-host-common.c
>> index 7cdfc89e5211..e0ec526f9776 100644
>> --- a/xen/arch/arm/pci/pci-host-common.c
>> +++ b/xen/arch/arm/pci/pci-host-common.c
>> @@ -406,7 +406,7 @@ bool pci_check_bar(const struct pci_dev *pdev, mfn_t 
>> start, mfn_t end)
>>           .is_valid = false
>>       };
>>
>> -    if ( s >= e )
>> +    if ( s > e )
>>           return false;
> 
> This is yet another example why using start/end in parameters are a bad
> idea :). I am OK if you want to keep the same interface, but can we at
> least document on top of the function whether we are expecting 'end' to
> be excluded or included?

Yes, will do. I will send a v2 that also addresses Roger's comments. For 
clarity's sake, e is inclusive.



 


Rackspace

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