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

Re: [PATCH] xen/vpci: allow BAR write if value is the same


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 24 Oct 2023 09:39:19 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=JxhTkv2FkQ0zeJkTVbbuMTBoosOE4Y/qbQFqek0JtUg=; b=mDzcZXDixiQ4Xui3hG+m7hGbhyyVHF0F3VlpluXyj+Rxyd+cEHE/vvMN1tSE4FDmRnzrl7HxnNmfrKNFoNTnN2Wh5xbV7Zrhcvm77EtGBBx4+MDyIeqy8YDGsQTJH8i8rS9SMjXb9yeM3j92nCfvrQ+gPkEGOpndNgf09uHmWJTMRIYbcEGRy79UREBdjItGPi8dQyJOry14wMVeMsV+8pMz9t8v7fGnA5HcYOkM322z8Td3C7+D1EnrrFMboipLfZu3RvkKGPWZoj+n177qf/zGVIffvfFt8BS/k1ceoEgI4IH2ml8xiiuXX+qB0jfix1ovR0zeTStuC7WPlN0LPw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JW3Em4yeT2mLaCY0O1yxMVBiNQPZIzEVbnu5yGNwywGUMStdRtKXSWJBzzRKloo6srVifG6fPoJQPlbKJNVIRjxkGKx858wRYWxYmAnYr/JOPMCFq1uPlEqAk+LYFIiqsCNcvt0de7eW2qHudWy4KytOUH9ZJtEHcxaqv7HGZ9Yn/+xtsGc5OxqAk2+5nUVJGF9AZuaFGMlABqG/OmEIObQJdx/DbArZ+isf5ILxUZZ6zdGVmJgsYXFxBn7bo42Sb9eTVvgbm3i/6OXRvzhP8873x11Ae+6CFzV+EdL3TY6efcZuqDXmsmdMu7ojzY1LL4kJQdoTgw9dqEjQW6oeVQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 24 Oct 2023 07:39:47 +0000
  • Ironport-data: A9a23:9dhzIqLo39otjKMcFE+R55QlxSXFcZb7ZxGr2PjKsXjdYENS0zUAn 2BMXWqCPa2DZmCjf4wiYN/i9kwFuZLWytVjG1RlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAhk/nOHvylULKs1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpKrfrYwP9TlK6q4mhB5gZiPakjUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5zWGMW+ McTJgk3awCmrfOswZyjVKpz05FLwMnDZOvzu1lG5BSAVbMDfsqGRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/dqpTGLlGSd05C0WDbRUsaNSshP2F6Ru 0rN/njjAwFcP9uaodaA2iv227GezXOhCOr+EpWJyMZouAa2/1ADKxIUfkujnaW+t0WxDoc3x 0s8v3BGQbIJ3E6hQ8T5Xha4iGWZpRNaUN1Ve8Uh9AySw7DIpQaYAmQJRCRIbtAOvco6Azct0 zehj97vQDBirrCRYXac7auP6yO/PzAPKm0PbjNCShEKi+QPu6k2hxPLC9N8Sqi8i4StHSmqm mjS6i8jm78UkMgHkb2h+kzKiC6toZ6PSRMp4gLQXSSu6QYRiJOZWrFEIGPztZ5oRLt1hHHY1 JTYs6ByNNwzMKw=
  • Ironport-hdrordr: A9a23:/0R4K67DzD+AI2ImhQPXwAzXdLJyesId70hD6qkQc3Fom62j5q WTdZEgvyMc5wx/ZJhNo7690cq7MBHhHPxOgbX5VI3KNGXbUQOTR72KhrGSoAEIdReeygZcv5 0QCZSXCrfLfCVHZRCR2njFLz4iquP3j5xBnY3lvhNQpZkBUdAZ0+9+YDzrdXFedU19KrcSMo GT3cZDryrIQwVtUizqbkN1OdQqvrfw5evbXSI=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Oct 24, 2023 at 09:09:45AM +0200, Jan Beulich wrote:
> On 23.10.2023 18:36, Stewart Hildebrand wrote:
> > During xl pci-assignable-add, pciback may reset the device while memory 
> > decoding
> > (PCI_COMMAND_MEMORY) is enabled. After device reset, memory decoding may be
> > disabled in hardware, and the BARs may be zeroed/reset in hardware. 
> > However, Xen
> > vPCI still thinks memory decoding is enabled, and BARs will remain mapped in
> > p2m. In other words, memory decoding may become disabled and BARs reset in
> > hardware, bypassing the respective vPCI command and BAR register handlers.
> > Subsequently, when pciback attempts to restore state to the device, 
> > including
> > BARs, it happens to write the BARs before writing the command register.
> > Restoring/writing the BARs silently fails because Xen vPCI mistakenly thinks
> > memory decoding is enabled.
> > 
> > Fix the BAR write by allowing it to succeed if the value written is the 
> > same as
> > the Xen vPCI stored value. pciback will subsequently restore the command
> > register and the state of the BARs and memory decoding bit will then be in 
> > sync
> > between hardware and vPCI again.
> > 
> > While here, remove a nearby stray newline.
> > 
> > Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
> > ---
> > Do we need similar handling in rom_write()?
> 
> I think so, if we are to go this route. However, ...
> 
> > We may consider additionally checking during bar_write() if the memory 
> > decoding
> > state has become out of sync between hardware and vPCI. During bar_write(), 
> > we
> > would check the device's memory decoding bit, compare it to our vPCI state, 
> > and
> > invoke modify_bars() if needed. Please let me know your thoughts.
> 
> ... iirc we discussed earlier on that doing resets in Dom0 wants
> communicating to Xen. Any way of resetting by a DomU would likely need
> intercepting. This way the described situation can be avoided altogether.
> We may go further and uniformly intercept resets, carrying them out on
> behalf of Dom0 as well. The main issue is, as with any config-space-
> based interaction with a device, that there may be device specific ways
> of resetting.

I agree with Jan, the plan as I recall was to introduce a new
hypercall to signal Xen of when a device has been reset, I can't
however find that conversation right now.  It would be nice to trap
device reset attempts, but there are some device specific reset
methods that would be too much special casing to accommodate sadly.

The fix here is just papering over the issue, as if the device has
been reset and Xen is not aware of it all the vPCI cached state is out
of date, so it's not only BARs addresses that are stale, but also
possibly MSI and MSI-X.

Thanks, Roger.



 


Rackspace

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