From nobody Tue Nov 12 23:19: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 4Xp2SN4w8gz5cn4M; Tue, 12 Nov 2024 23:19: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 4Xp2SN4Lk5z4ZWn; Tue, 12 Nov 2024 23:19:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731453588; 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=HbaKbgWyfiBFjREumFNZyOGt0s01blNUZ/zJO/0dC6A=; b=Msoo3AyBCsYm3B8Tx7e9wXtCs2Z4lADXpUj6l/gWIiJqce/HEVyibSLRdNHm3KK1vY/Xlh oJ60BpglIQIM3skPxw6fB0oP3T8z2fDoURHKNBt/Un94eoNwueq6c6WCVC/slwvXFXGVOv wJRZ5Ok27fuvigoY+H63t5y7RSuFys3cZgYDpD9AERBKlBs7qaNuBiG30Xjl6xEtobndfd JqPgCabLnr2heoHBqwpczg3DogQYvUCKH7kKwDPM3dTAlsD+yoivupZLPzHUYD0xPIzcSB NnrdoWHv5AJvd7S/lxPozA5Rzb4VrzORzCht6A5zW+nAPB2iQc6udeFn+MS+4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731453588; 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=HbaKbgWyfiBFjREumFNZyOGt0s01blNUZ/zJO/0dC6A=; b=ca/b7cObCGl36z7Bd1jbNCePT57ae/p2wjrvq5Ls3N9wNPVtmJmIrfBBRY8sGflI+l3rwq pdzyg9DDQiwdSKieQxQj2ODeocx0NFcI1olUSZRoFWWl2llO1E/6BBl3K4NyUmbusmG7We 9o5WeKCo/vQVE5X5yy+uQyfhOzfo9dP4Dt9ukE/1Dleb9Hu2utD4zYESaKU/k7abTo7pAF ipUwKt6/EtxlceDxSIn3S/N1AOlNmV94bgJIwY0fd5ua8Bz24YPDlshIw+l4VbPZsOvksf 5NaizbQAvJ1PkWFVwRfu42/mzRgh+maRZ+TjAxIhHivfJcwbjZp8AwoFS5BrZQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731453588; a=rsa-sha256; cv=none; b=C7tRLs7a7aYJl05CTXAQrFJg9h5whTTu+Ui8C8+q2yxWIcvuUsvVUP9lons1tXcAy313lc x+WsbDg4zfNQ4qF8LV7xPY+W5Tz59qSY46F3lhzzuArA//lxKGQcPVRUvCynhemn1O4gMg PycV4hB1SOdSXHaTXyl1NMzFYZfVqcjNq6/TSY1LITT9OcIqInpx1SOW3ZIwB8jKVeGczt m5P6pdGIhVcqLSFUs+Xj4B/ZSh480F9hrvCfBoNFj1fXs8h3pxEupCc3FrLcCgrN8Rk7Mq FkYOybuLdE558UWLmOHhcfn0hMCs2zYynNI4cqeGPwhHqD91TnUnQ5EZRiECTQ== 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 4Xp2SN3dtdzVwm; Tue, 12 Nov 2024 23:19: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 4ACNJmjm084893; Tue, 12 Nov 2024 23:19:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4ACNJmmd084890; Tue, 12 Nov 2024 23:19:48 GMT (envelope-from git) Date: Tue, 12 Nov 2024 23:19:48 GMT Message-Id: <202411122319.4ACNJmmd084890@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 92a9501b6be3 - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 92a9501b6be3d37a4eefcfbdda799b656ae146e8 Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=92a9501b6be3d37a4eefcfbdda799b656ae146e8 commit 92a9501b6be3d37a4eefcfbdda799b656ae146e8 Author: Konstantin Belousov AuthorDate: 2024-11-04 21:54:30 +0000 Commit: Konstantin Belousov CommitDate: 2024-11-12 23:19:18 +0000 vm_object: do not assume that un_pager.devp.dev is cdev PR: 282533 (cherry picked from commit 580340dbdaaf372867e9ed3dd257430982753e5e) --- 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 18302bb8abae..b7fa7bfb60e9 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -2718,8 +2718,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 6b0a70d523d5..21ec52b8124f 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -1435,6 +1435,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 5933b2c1d4bd..84e56b910809 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -2610,7 +2610,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 16ee3544b658..bd71820bed3c 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -206,6 +206,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.