From nobody Wed Nov 06 00:23:48 2024 X-Original-To: dev-commits-src-all@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 4XjmCS6RZzz5bqLv; Wed, 06 Nov 2024 00:23:48 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XjmCS5ljzz4qj0; Wed, 6 Nov 2024 00:23:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730852628; 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=KL+nuAv1/CoBiyqvJPhCcs5V7tnzjSPrtSVcPyUfFu4=; b=Vvwc/p1DR7CLNsYtRKilp305bKeqlWH3bW4UEqPtzzx0naiMRG9w/50Bi/1WHYhFXk7WLy tesD+1R9kXivlxBQSQYlWkEMdcSZBRMH2ZWSgaANhBaZNUCoBcgE1vkDxDEi+wOgkJpRlb Uz+cO/lCdkWJi/m89kXnw6LGHp0/4xScKhdF94sjVy0MuJqt+oX6ZQ61P+vGe7lJkY6NR+ cyzU6D/poh4QNtSc9IShAhxg9gzk7JroWQu47qILZKgwqcc3teDcitmzVgNEZSiwkLjnCB jxyfgv8nbDhd0PKDmaXojIFAjiwCz/aqoxsGhGEWiPNRejajM5kf7y1riPy91g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730852628; 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=KL+nuAv1/CoBiyqvJPhCcs5V7tnzjSPrtSVcPyUfFu4=; b=buS8FBoDOR8coHpLE/1w99lJrRsEzq+mTxv+FDEW+TNDLYew8qYTf4iQW/W7GHTT0X+BwQ kQ309JqpaV1sI7JacbI0BJuaCVho5tBJq0uN2Mtu8sXgHPi3xaidPEC/kukcniJm5Esg6E gP9PLqQOYJP/O8+TPRnGBArfwjefacvbZg6rDB4LKZjP13ickDJtLKvBxcC+y4FJU+K8eC DAgtMLQ3gvDtg4t2lW8NOdFG//dbX7uxACpLX87SzUGX2mgdCRDmbuqErv+GNyfTXG807N 27PfiGZ9ST0EJPVbfY6c75+0Wc+OztChYwdud5D32eB6jQqTIGpFcismAOdacA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730852628; a=rsa-sha256; cv=none; b=xq9kGP1Sxr2NIgQR6PGeT0VtN0JqpJkUNaVxm//O7M0qpL7WYrWn5dPMEJasrggZVPtmcL vcquI3hg68Z9oYzZO0q/ombDWYrf6IW3Rz2rnq/YxmnMBNjIvRlNk2PdtkXzZ2L+m9y2bP fJrvo8Qsv9DRvCuVdMRScMut9TWX65m5A/gSGAJWspgSenrzPx+r4yb2j8jWuPIMoBU/9n CYbrw+9LVs7gHeNOBVaSkDZVsNCDIbUCVDyto2agCFtktr2t9l/zaRZ21HhAafQogRLSnK pUpqvf3gOEFZZimDIIdTI0dHZ3uIvbuHmOm5UGEI5aowCbfa/dxNcHlIX51hCA== 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 4XjmCS5LNgzfjb; Wed, 6 Nov 2024 00:23:48 +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 4A60Nmx2091017; Wed, 6 Nov 2024 00:23:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A60Nmpq091014; Wed, 6 Nov 2024 00:23:48 GMT (envelope-from git) Date: Wed, 6 Nov 2024 00:23:48 GMT Message-Id: <202411060023.4A60Nmpq091014@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 580340dbdaaf - main - vm_object: do not assume that un_pager.devp.dev is cdev List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 580340dbdaaf372867e9ed3dd257430982753e5e Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=580340dbdaaf372867e9ed3dd257430982753e5e commit 580340dbdaaf372867e9ed3dd257430982753e5e Author: Konstantin Belousov AuthorDate: 2024-11-04 21:54:30 +0000 Commit: Konstantin Belousov CommitDate: 2024-11-06 00:11:00 +0000 vm_object: do not assume that un_pager.devp.dev is cdev It is subtype-specific handle. Mark OBJT_DEVICE that do fill cdev into the handle, with a new object flag OBJ_CDEVH. PR: 282533 Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D47443 --- sys/kern/kern_proc.c | 5 +++-- sys/vm/vm_mmap.c | 3 +++ sys/vm/vm_object.c | 3 ++- sys/vm/vm_object.h | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 0d5b9a93d704..4cd13234a10b 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -2717,8 +2717,9 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, ssize_t maxlen, int flags) kve->kve_ref_count = obj->ref_count; kve->kve_shadow_count = obj->shadow_count; - if (obj->type == OBJT_DEVICE || - obj->type == OBJT_MGTDEVICE) { + if ((obj->type == OBJT_DEVICE || + obj->type == OBJT_MGTDEVICE) && + (obj->flags & OBJ_CDEVH) != 0) { cdev = obj->un_pager.devp.handle; if (cdev != NULL) { csw = dev_refthread(cdev, &ref); diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 4f709b1b74e1..028175b88b4f 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -1407,6 +1407,9 @@ vm_mmap_cdev(struct thread *td, vm_size_t objsize, vm_prot_t prot, td->td_ucred); if (obj == NULL) return (EINVAL); + VM_OBJECT_WLOCK(obj); + vm_object_set_flag(obj, OBJ_CDEVH); + VM_OBJECT_WUNLOCK(obj); *objp = obj; *flagsp = flags; return (0); diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 6d29ddf71f19..e6324647e29e 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -2515,7 +2515,8 @@ vm_object_list_handler(struct sysctl_req *req, bool swap_only) sp = swap_pager_swapped_pages(obj); kvo->kvo_swapped = sp > UINT32_MAX ? UINT32_MAX : sp; } - if (obj->type == OBJT_DEVICE || obj->type == OBJT_MGTDEVICE) { + if ((obj->type == OBJT_DEVICE || obj->type == OBJT_MGTDEVICE) && + (obj->flags & OBJ_CDEVH) != 0) { cdev = obj->un_pager.devp.handle; if (cdev != NULL) { csw = dev_refthread(cdev, &ref); diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index 596f67b46e6f..fc39041d02d6 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -204,6 +204,7 @@ struct vm_object { #define OBJ_PAGERPRIV2 0x00008000 /* Pager private */ #define OBJ_SYSVSHM 0x00010000 /* SysV SHM */ #define OBJ_POSIXSHM 0x00020000 /* Posix SHM */ +#define OBJ_CDEVH 0x00040000 /* OBJT_DEVICE handle is cdev */ /* * Helpers to perform conversion between vm_object page indexes and offsets.