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

Re: [PATCH for-4.17 v2 5/5] vpci: refuse BAR writes only if the BAR is mapped


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 26 Oct 2022 16:06:40 +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=QXq0m7jvoyekWseyL6Ho4aVMtVi5oA7iIXs0LHcyuUg=; b=GMJxaxiIxbBKnoqtuzU0902kjp4+PzMi14vB657I5HHBnUENq7HnuuVrSV3KMkNNbVTIFWrgEeq6H1b2qQAzr14tabxRtjm1TJSzIL5YFu1hbH1w68dXRAB5bSddd6gHF3b91JOswUcDTkI8D1/3iRVm8RE0TTt1ZvP+k9MCEo5xsQpqZu5envUmbT87IL4zCIaSQbO1pIZVA9Ylq+Fx1dAps56XSYUOU3y8XGQ0GxSj4lCCtqr+8isnLI0cQT7qids7d3nKmkUpBPrEc1eQ1aQNJgh3aQynG9N+nkk0pinoIgX1drXSM85KiJYlam+pEBuFZKsIlUTZ3mkqRWZUsQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PSyOJYNv6tUFK+RrNsrxi9mQYF9i8R6mNNLp6X4s+FCUsKopfv6ti7qNtOtQ7aTSR/AENmCFwtEIX0KXy2fDic40WKJyTlYyiJKWPL9QyJ9owzJP2Fmlf80JTJMOXIOSTpkTmcYSFDoEw0U+ydrILzVuoIVFgA7LHhIA506fLmqnK3qpGFqswkB75LHlxt+8sJy0g6pwbF34c3VyfzGILEzrkV9OCneEX2nT/9FUxmXFHa6+hXZq0yMNb4kq/MYjVF2Z/Hu5Bl+5fzCP2mUrEF/EN3j27pwlrEU8yBOEKKfnL55ckyE/g/+EssNEso4C7Mm8YjCx7seli14W7MRg/A==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Henry.Wang@xxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 26 Oct 2022 14:06:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 26.10.2022 15:58, Roger Pau Monné wrote:
> On Wed, Oct 26, 2022 at 02:47:43PM +0200, Jan Beulich wrote:
>> On 25.10.2022 16:44, Roger Pau Monne wrote:
>>> @@ -388,12 +391,12 @@ static void cf_check bar_write(
>>>      else
>>>          val &= PCI_BASE_ADDRESS_MEM_MASK;
>>>  
>>> -    if ( pci_conf_read16(pdev->sbdf, PCI_COMMAND) & PCI_COMMAND_MEMORY )
>>> +    if ( bar->enabled )
>>
>> In 3 of the 4 cases you use header->bars_mapped as replacement. Since it's
>> not clear to me why you don't here, could you explain this to me? (I'm
>> therefore undecided whether this is merely a cosmetic [consistency] issue.)
> 
> No, it's intended to use bar->enabled here rather than
> header->bars_mapped.
> 
> It's possible to have header->bars_mapped == true, but bar->enabled ==
> false if memory decoding is enabled, but this BAR specifically has
> failed to be mapped in the guest p2m, which means dom0 is safe to move
> it for what Xen cares (ie: it won't mess with p2m mappings because
> there are none for the BAR).
> 
> We could be more strict and use header->bars_mapped, but I don't think
> there's a need for it.
> 
> What about adding a comment with:
> 
> /*
>  * Xen only cares whether the BAR is mapped into the p2m, so allow BAR
>  * writes as long as the BAR is not mapped into the p2m.
>  */
> 
> Otherwise I can switch to using header->bars_mapped if you think
> that's clearer.

It's not so much a matter of being clearer, but a matter of consistency:
Why does the same consideration not apply in rom_write()? In fact both
uses there are (already before the change) combined with further
conditions (checking header->rom_enabled and new_enabled). If the
inconsistency is on purpose (and perhaps necessary), I'd like to first
understand why that is before deciding what to do about it. A comment
like you suggest it _may_ be the route to go.

Jan



 


Rackspace

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