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

Re: [PATCH RFC] xen/pci: detect when BARs overlap RAM


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 26 Jan 2022 16:49:09 +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=H4YAwF/w+unTE322F2AFQijYArLKdz6GymS+pMDTgWs=; b=l2AqrdC3Cj7NRYFA43pejdXsHCd5hnEzD8k0wDXhz/d+tGMJND2Mc+qExEvzajV+HTJUREkuu0EAE04hCwrWz4z4N+HngZukOo+Wueg7APuukcef1qts1D+ryghIZ9beM/IGMd0OYE6aQsNGzdPNiMpKz5B05g7B2YtloQ6rb/g3mtnCxEAeIvYUhjPImkcr+ABrkqhXQH4BLn05EG5nqOauBkivjLK5cee4xJxuaS+qFnBCpBJTOe2W66Ew8NhK0Baalj53zQBkPWVrUSA3ukISJGZgQcJVwU679LbHVpHWUrMfg6BpBC5DIUfR3FfW/UehwHy6vBnhlyqOupW5Xw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dXJe6VtIn4fgB3gx5qFYbPIPmZwsQqTMEds8gOiOajkzQhMcATdAtGHGYH/PFMXQdL2HXWsKyyqCj1KRCogb5sbgVWGKjiBXMGbmjU446NM6pXF/dMzLr5lksAXXFEhjbp8WYPiqbqqyC/Sjo991sE9ufME4wyUqCon5GKKUn+C4OgSyvjlVDhBg3pM87LfMqVg4t9JYiA9b14r3yknMCQzqtIt+NaNNEnIriF+r9AfDeCkdaGNIOURCncYA18yXH2ndzLKTiH0sX8+cHq+jFeo+z9OHrQKCUxtSLKs27Kf2frPnH4f7olj/FuYC0V9mlvbE+1rTtFjRH0V38GU69Q==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Andrew Cooper <amc96@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Paul Durrant <paul@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 26 Jan 2022 15:49:30 +0000
  • Ironport-data: A9a23:xGwJZa4Si53ue/hi9cn5lAxRtGLBchMFZxGqfqrLsTDasY5as4F+v mJJWGiFO/mKYDb1fNgjOti/oUxVvpCBzdUwTQo4/ilhHi5G8cbLO4+Ufxz6V8+wwmwvb67FA +E2MISowBUcFyeEzvuV3zyIQUBUjclkfJKlYAL/En03FV8MpBsJ00o5wbZg2NAw27BVPivW0 T/Mi5yHULOa82Yc3lI8s8pvfzs24ZweEBtB1rAPTagjUG32zhH5P7pGTU2FFFPqQ5E8IwKPb 72rIIdVXI/u10xF5tuNyt4Xe6CRK1LYFVDmZnF+A8BOjvXez8CbP2lS2Pc0MC9qZzu1c99Zy 9pssaCUaCYTDIrznrleWR16FwpyIvgTkFPHCSDXXc27ykTHdz3nwul0DVFwNoodkgp1KTgQr 7pCcmlLN03dwbLtqF64YrAEasALNs7kMZlZonh95TrYEewnUdbIRKCiCdpwgmth1pgeTaq2i 8wxZDxrYDrRQiJ0AEo6JIolodmYm2fhbGgNwL6SjfVuuDWCpOBr65DyNPLFd9rMQt9a9m6Sq 3ja5W3/DlcfPcaG1Due2nu2g6nEmiaTcJIfEvi0++Bnh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3O2+ZVykbYKidhEHHM2axWhIgUuQAMx1gHfgzblt3Aj/4x/RtQ7TVoEVgFkkQZi7p+a jpxKkl4BaSS5DM51sFMUlelFxxFGBDEqFf6zEEElTGBQkSlPoAXwLbR5QpZEJglzl9h
  • Ironport-hdrordr: A9a23:xggAQqCFeBN6zYnlHemQ55DYdb4zR+YMi2TDsHoBLSC9E/bo8v xG885rtiMc5AxxZJhCo7690cu7MBThHPdOiOF6UItKNDOW3ldAR7sSj7cKrQeBJ8TWzJ8l6U 8+GJIUNDSLNzdHZGzBkXGF+q0brOW6zA==
  • Ironport-sdr: h6GgggW/CznHHslxgFlUbMnx2/H0qHDFGvj/fxo/Tf+8bv+6kqtGqL3jk5x5CYofFuOHrqmcpY jpLMrr7QyxHkWyu26TuwAdctI3hjNJvbSVvKTDFSfOapYGlfyaKUj2OxVya4scwiaJbeADCtAp Cg0yM8RuqfHgMbjBhaNM8zmIh/IUKhMwrD4XrlqxNgkP2N76nJDdzQb9Rp8jzJjseLcT2S1+bn FLk3bUmbYbF0r1uNDCbXof0hn4CZqLgLGdMmENYFgB42nR/EMoiMtWogNsAgBJpVbLgo7cDpSa EwiRTKgldi9UneUylRyPcQFD
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Jan 26, 2022 at 04:27:04PM +0100, Jan Beulich wrote:
> On 26.01.2022 15:45, Andrew Cooper wrote:
> > On 26/01/2022 12:26, Roger Pau Monne wrote:
> >> One of the boxes where I was attempting to boot Xen in PVH dom0 mode
> >> has quirky firmware, as it will handover with a device with memory
> >> decoding enabled and a BAR of size 4K at address 0. Such BAR overlaps
> >> with a RAM range on the e820.
> >>
> >> This interacts badly with the dom0 PVH build, as BARs will be setup on
> >> the p2m before RAM, so if there's a BAR positioned over a RAM region
> >> it will trigger a domain crash when the dom0 builder attempts to
> >> populate that region with a regular RAM page.
> >>
> >> It's in general a very bad idea to have a BAR overlapping with a RAM
> >> region, so add some sanity checks for devices that are added with
> >> memory decoding enabled in order to assure that BARs are not placed on
> >> top of memory regions. If overlaps are detected just disable the
> >> memory decoding bit for the device and expect the hardware domain to
> >> properly position the BAR.
> >>
> >> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> > 
> > I'm not sure this is a sensible approach.
> > 
> > A bar at 0 is utterly unusable, because it is outside of the host bridge
> > window.
> > 
> > The absence of any coherent GPA map for guests (needs fixing for oh so
> > many reasons) is a primary contributor to the problem, because Xen
> > *should* know where the guest's low and high MMIO windows are before
> > attempting to map BARs into the guest.
> 
> But this is all about Dom0, ...
> 
> > The proper fix is to teach Xen about GPA maps, and reject BAR insertion
> > outside of the respective bridge windows.
> 
> ... and hence this isn't about "insertion", but about what we find
> upon booting.
> 
> > An fix in the short term would be to disable the problematic BAR when
> > scanning the PCI bus to being with.
> 
> You can't disable an individual BAR (except for the ROM one), you need
> to disable all memory ones collectively (by disabling memory decode).
> Which is what Roger does.

I've thought about just disabling the ROM BAR if that's the only
conflicting one, but it was easier given the context to just disable
memory decoding globally like it's done for plain BARs. Didn't seem
worth the extra code to special case the ROM BAR disabling.

Thanks, Roger.



 


Rackspace

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