From nobody Thu Sep 4 02:45:34 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cHP3f55HVz66cxG; Thu, 04 Sep 2025 02:45:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cHP3f3Xbgz3MBB; Thu, 04 Sep 2025 02:45:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756953934; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kYS9oCfxmAbiEZnsAXK4wd3hQEbXxbtZk9YsBLqtCl8=; b=u8X+lFtJtUor+NOyOFcH9XzI91RZVOadbuL04tndjjhU0+ffBdpDwwdZ3PNP18YH8UOXUa Co7ADZaiejpgAtUUUwaoGVDcKMaicN9+gMe6j4Lf4lPy77DMqQyzgp5Q1s1JLZIex8nzgK EUqj7i4rHfO6ylxjssB+3rgTNUz6cb7FOlFHjoLFxi1UoEVXSQguEvjCX/e6z0zolgTw0R XvNxk7AXrH2KHiPjhwgOZikcifr9xOEYqMYZK/TJ92ceaurgCPq873DU7ijE8clInAlWyF sRW4na7vC5dIHALsTVuFgSDMCL3C2DKBgp56laLJfSYCuYGoGqaGjQ819zsS4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756953934; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kYS9oCfxmAbiEZnsAXK4wd3hQEbXxbtZk9YsBLqtCl8=; b=knE7g49VW7p7L9IjKnMY4mFCZT1Bv+5N81mwXqSgb1UPsHa5Ut7XPiIzFkV47AvYZa7STZ 8R1KohhxVwv9S9ZdI+YObjV1JCnzwD/Am0r1MVqw2dEEIjnfw9mMq8zdOM5yiloSBIHel0 Qirec2H9/e4ZEpB+IWuSIZUvz/V65gXrlLDgs6qEacO6UYRhToISNJmIKJFB9bN+G6tD2p sKkwpVAQd3WsUF2yRSVLc/1qVgpqrWou0P6lpcAbgn5jxIEd7N2eY3YURMw6AuLOvjN7yJ K4WAiRaN0OnZpGTo4ssrXBlgrHxL3oqWXZrLB2I3chsMjPL+e87lmaSoSlfOhw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1756953934; a=rsa-sha256; cv=none; b=Rn/AsuZ6YbhqWha3U8ogvg1zDvnXxcfdcWu9qeHfEopp7TQSruluHOaQlhDoJ/KybzZuMu xt/sIGQJQzaYzGCx/b5sy+O4tOEkzSYSb/2cBrihgCmakxWThiiOXt1+UacHn+eceFWYc7 wnRgap1GhSW0HTx5VsQ+xDMMsXNJxny7YGLmpe/DbyM3vwInApZdv3zs6gnndsodGSRs3+ 391ti+nWQuZsWUu9Ryv1bjB3Nq4SimRrKJxRbZDAckyQedFVPS0/sPymjW1/csKYN6Bpyz iFwFjNEwexOYwW5UEVJuQDUPcnfPq5bHevDIVkPrrKJZt4pFrFF6ZOMNRotlfw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cHP3f2ybkzkSC; Thu, 04 Sep 2025 02:45:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 5842jYiE085550; Thu, 4 Sep 2025 02:45:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5842jY1Q085547; Thu, 4 Sep 2025 02:45:34 GMT (envelope-from git) Date: Thu, 4 Sep 2025 02:45:34 GMT Message-Id: <202509040245.5842jY1Q085547@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jake Freeland Subject: git: 4f6f4aacaf97 - main - pci_user: Add compatibility padding List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jfree X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4f6f4aacaf97f301e5c5646649a1217ca8099349 Auto-Submitted: auto-generated The branch main has been updated by jfree: URL: https://cgit.FreeBSD.org/src/commit/?id=4f6f4aacaf97f301e5c5646649a1217ca8099349 commit 4f6f4aacaf97f301e5c5646649a1217ca8099349 Author: Jake Freeland AuthorDate: 2025-09-04 02:42:48 +0000 Commit: Jake Freeland CommitDate: 2025-09-04 02:42:48 +0000 pci_user: Add compatibility padding Avoid future compatibility churn when adding new members to struct pci_conf by introducing some padding. An additional member, pc_reported_len, has also been added to report the length of the valid portion of an encompassing pci_conf. This allows users to verify that their definition of pci_conf matches the kernel's, preventing the use of invalid data. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D52313 --- share/man/man4/pci.4 | 11 ++++++++++- sys/dev/pci/pci_user.c | 10 +++++++++- sys/sys/pciio.h | 2 ++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/share/man/man4/pci.4 b/share/man/man4/pci.4 index 5237b6bc7adc..b99747969035 100644 --- a/share/man/man4/pci.4 +++ b/share/man/man4/pci.4 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 20, 2025 +.Dd August 31, 2025 .Dt PCI 4 .Os .Sh NAME @@ -237,6 +237,15 @@ Driver name. Driver unit number. .It pd_numa_domain Driver NUMA domain. +.It pc_reported_len +Length of the valid portion of the encompassing +.Vt pci_conf +structure. +This should always be equivalent to the offset of the +.Va pc_spare +member. +.It pc_spare +Reserved for future use. .El .It offset The offset is passed in by the user to tell the kernel where it should diff --git a/sys/dev/pci/pci_user.c b/sys/dev/pci/pci_user.c index 5090ecb3dd7c..9768030995e7 100644 --- a/sys/dev/pci/pci_user.c +++ b/sys/dev/pci/pci_user.c @@ -80,6 +80,8 @@ struct pci_conf32 { char pd_name[PCI_MAXNAMELEN + 1]; /* device name */ u_int32_t pd_unit; /* device unit number */ int pd_numa_domain; /* device NUMA domain */ + u_int32_t pc_reported_len;/* length of PCI data reported */ + char pc_spare[64]; /* space for future fields */ }; struct pci_match_conf32 { @@ -885,8 +887,11 @@ pci_conf_for_copyout(const struct pci_conf *pcp, union pci_conf_union *pcup, strlcpy(pcup->pc32.pd_name, pcp->pd_name, sizeof(pcup->pc32.pd_name)); pcup->pc32.pd_unit = (uint32_t)pcp->pd_unit; - if (cmd == PCIOCGETCONF32) + if (cmd == PCIOCGETCONF32) { pcup->pc32.pd_numa_domain = pcp->pd_numa_domain; + pcup->pc32.pc_reported_len = + (uint32_t)offsetof(struct pci_conf32, pc_spare); + } return; #endif /* COMPAT_FREEBSD32 */ @@ -1326,6 +1331,9 @@ pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *t break; } + dinfo->conf.pc_reported_len = + offsetof(struct pci_conf, pc_spare); + pci_conf_for_copyout(&dinfo->conf, &pcu, cmd); error = copyout(&pcu, (caddr_t)cio->matches + diff --git a/sys/sys/pciio.h b/sys/sys/pciio.h index 351397ab9d9b..64c0b32cb8e2 100644 --- a/sys/sys/pciio.h +++ b/sys/sys/pciio.h @@ -78,6 +78,8 @@ struct pci_conf { char pd_name[PCI_MAXNAMELEN + 1]; /* device name */ u_long pd_unit; /* device unit number */ int pd_numa_domain; /* device NUMA domain */ + size_t pc_reported_len;/* length of PCI data reported */ + char pc_spare[64]; /* space for future fields */ }; struct pci_match_conf {