git: 0e2ae559a147 - releng/13.1 - linuxkpi: add padding to struct pci_driver
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 06 Apr 2022 17:46:02 UTC
The branch releng/13.1 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=0e2ae559a147fd3fe830d343c1cc40bb9a6650ec commit 0e2ae559a147fd3fe830d343c1cc40bb9a6650ec Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2022-04-05 04:54:49 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2022-04-06 17:45:10 +0000 linuxkpi: add padding to struct pci_driver Add 32 or 64 bytes of padding to struct pci_driver at the end in the _spare field like we should have done when we branched stable/13, but neglected to do so since we didn't properly anticipate the need. We cannot safely use these spare fields until after 13.0 EOL since drivers compiled on 13.0 won't have that space reserved and we'll step on something else using them. This isn't 100% KBI compatible through the 13.x release branch, but is compatible enough so that drm packages built on the oldest supported release will work on the latest stable/13 and any newer releases. It's not ideal, but makes the best of a bad situation and is a pragmatic approach that belatedly builds in some future proofing. Direct commit to stable/13 because this is not relevant to main in this exact form. Approved by: re@ (gjb) Sponsored by: Netflix Reviewed by: bz Differential Revision: https://reviews.freebsd.org/D34754 (cherry picked from commit 86d5c66106610f083deda03ce0c661a51b2dd723) --- sys/compat/linuxkpi/common/include/linux/pci.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 7afe426d6b52..c4d30a6e293a 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -235,8 +235,27 @@ struct pci_driver { void (*bsd_iov_uninit)(device_t dev); int (*bsd_iov_add_vf)(device_t dev, uint16_t vfnum, const nvlist_t *vf_config); + uintptr_t _spare[8]; }; +/* + * Pseudo-stable KPI. In 13.0 we neglected to include any spare fields to allow + * for growth in struct pci_driver. Those were added in 13.1, but can't be used + * until 13.1 is the oldest supported release so that packages built in 13.0 + * will continue to work on stable/13 and 13.1 release. The 13.0 driver was 92 + * or 182 bytes on 32 or 64 bit systems (respectively). We added 64 or 32 bytes + * of padding, hence the math below (which shouldn't be changed as spare fields + * are used up). + */ +#ifdef __LP64__ +#define __PCI_DRIVER_SIZE (184 + 64) +#else +#define __PCI_DRIVER_SIZE (92 + 32) +#endif +_Static_assert(sizeof(struct pci_driver) == __PCI_DRIVER_SIZE, + "linuxkpi struct pci_driver: Bad size"); +#undef __PCI_DRIVER_SIZE + struct pci_bus { struct pci_dev *self; int domain;