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

Re: [PATCH v1 0/2] x86/pci: MMCFG improvements and always use it if available


  • To: Teddy Astie <teddy.astie@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Wed, 7 Jan 2026 18:07:56 +0000
  • 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=arcselector10001; 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=gUniAz9j09liMw8KdzdGqULjOflNM1Bt11OQ/cpWik0=; b=voCeBUYXk/D9wapRf1BdzD08vT6W4C4Y+oprf0CB9knRyA3fZPczKOrbsRvbytLXDY7MCea+fMus2lkQkv7Gjs/O1ZuIaTzctwBol49UbQLPlP02k5wl9koRZVPTBXC/+Gn/y3iPPhEJmM7xbV6td/tGIuGwXpSiDnL+v95qsUhBXWZPSzCrm0fpEquAvpf7skLnAeEEhF/5n/GmT1l4yXhtCUS5xq6V5rKtlc1Npp6Cc6wgo3BdUGIBLmH5yCp/IC0gSHI4ZLaRxBIQjNBVHU2Q16e2Lyddpk04t8WkwC3J6Kllee2mWWZ8+iHQ65s+iRP1DQD9OT19Rp3pnp8VZg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IxaZB/LiURLxp4fFfcMp/6C2db8ozNwC6f8BfuAH0/mS5VSOl+HJH9QM2fpX8Ftx71aP8A1iovIhzx9CBbFfZwC1TbaubX8cKz10HWdbKlrJWSBc+YJKDq8NmuethxJUANtSzwyj0mDJJYyR/lZ5ulprSH3Ns6PoVqdlspACB8wolYxts2tvFqJsIuTd+gy/yUMCB0w44/EjEJLr3ucvYafGzr+3cEm626xWkX1TUeU+aKWdG9g02lrIson95eksmhwweZLY9Tb2yFXVGc+Qi9Lf2QctKdPlkCyx2Ej3vNpOGcgUBzUITMI2ZAzKvqA9a2rqN/vH0DXGJJ2ZpLD0lQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Wed, 07 Jan 2026 18:08:13 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 07/01/2026 5:58 pm, Teddy Astie wrote:
> Le 07/01/2026 à 18:25, Roger Pau Monné a écrit :
>> On Wed, Jan 07, 2026 at 04:54:55PM +0000, Teddy Astie wrote:
>>> Currently, Xen uses legacy method to access the configuration space unless 
>>> the
>>> access cannot be made with it, where Xen fallbacks to MMCFG. This is not 
>>> really
>>> great, as MMCFG is more flexible and doesn't require a dedicated lock, so 
>>> it would
>>> be preferable to use it whenever possible.
>>>
>>> Teddy Astie (2):
>>>    x86/pci: Improve pci_mmcfg_{read,write} error handling
>>>    x86/pci: Prefer using mmcfg for accessing configuration space
>> AFAICT Linux is using the same approach as Xen to perform PCI
>> accesses.

I think you mean "Xen inherited it's PCI code from Linux". :)

>>   Registers below 256 on segment 0 are accessed using the
>> legacy method (IO ports), while the extended space is accessed using
>> MMCFG.  Do you know the reason for this?  I fear there might be
>> legacy devices/bridges (or root complexes?) where MMCFG is not
>> working as expected?
>>
> There is apparently a errata on some K8 chipset according to FreeBSD 
> code that uses MMCFG whenever possible.
>
> https://github.com/freebsd/freebsd-src/blob/main/sys/amd64/pci/pci_cfgreg.c#L261-L277

Using MMCFG is *far* more efficient than IO ports, not least because we
can avoid serialising accesses across the system.

If it really is only some K8's which were the problem then lets go the
FreeBSD way.  Both Linux and Xen both talk about AMD Fam10h issues,
which is the fact that early AMD CPUs only allow MMCFG accesses for
MOV-EAX instructions.

There's also loads of code improvements to be had.  The current APIs are
inefficient to use, and I did some cleanup for them for Trenchboot where
there is a 64k limit.  (But this can strictly come later).

~Andrew



 


Rackspace

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