Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Jun 2018 22:21:20 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Hans Petter Selasky <hps@selasky.org>
Cc:        Bruce Evans <brde@optusnet.com.au>, Matthew Macy <mmacy@freebsd.org>,  Ryan Libby <rlibby@freebsd.org>,  src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org,  svn-src-head@freebsd.org, bde@freebsd.org
Subject:   Re: svn commit: r335094 - head/sys/ofed/drivers/infiniband/core
Message-ID:  <20180614213127.E2164@besplex.bde.org>
In-Reply-To: <4aa93c89-686e-e344-8e04-c34069e8516d@selasky.org>
References:  <201806132330.w5DNUsrE043573@repo.freebsd.org> <CAHgpiFwQza_CEeu687s-HwnHPT%2BfcPk80nHkbU3Kn-aUM2AjHQ@mail.gmail.com> <CAPrugNq-dGjOhJ7PW5zniggowENW74P5ttCWH01U=AmXcj4gzA@mail.gmail.com> <c14b6b39-22b3-cdb5-d387-829bad3509f3@selasky.org> <20180614182603.U1417@besplex.bde.org> <4aa93c89-686e-e344-8e04-c34069e8516d@selasky.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 14 Jun 2018, Hans Petter Selasky wrote:

> On 06/14/18 10:46, Bruce Evans wrote:
>> Are these macros for conversion of host (FreeBSD) dev_t's or target (Lin=
ux)
>> ones?=C2=A0 If for the host, then I don't see any reason not to use the =
host=20
>> APIs.
>> If for the target, then they shouldn't be used with the host dev_t.=C2=
=A0 If=20
>> for
>> a mixture, then the translations are very confusing, especially when the=
y
>> are the identity, and many more macros are needed to reduce the confusio=
n.
>
> These values are only used inside the LinuxKPI for creating character=20
> devices. They have no exposure to user-space.
>
> Basically:
>
> Z =3D MKDEV(X,Y)
> MAJOR(Z) must be equal to X
> MINOR(Z) must be equal to Y

So they are only for the host.

You should try harder to allocate the device number properly (not using
hard-coded numbers which are not even #defined in a central place).
compat/linux already has similar hard-coding for pts and more, but that
is more central and historically established.

Unique device numbers now seems to be allocated by devfs_alloc_cdp_inode().
Or call make_dev*() to create a full device with a device number allocated
by this.

I now see bugs in this too.  Major numbers for devices are supposed
to be 0.  But devfs_alloc_cdp_inode() constructs a minor number which
is assigned to cdp->cdp_inode.  cdp_inode is treated as a device number,
not as a minor number.  It is assigned directly to a device number in
dev2udev() and for assignment to va_rdev.  So after 256 allocations,
the minor bits leak into the major bits.  Eventually the leak breaks
uniqueness of hard-coded Linux major numbers.

I saw this earlier to today but thought the problem was a kernel without
the encoding fixes combined with an old userland using old major(), etc.,
to decode new dev_t encoding.  Actually, the encodings were consistently
old except in devfs_alloc_cdp_inode().  I created 514 ptys in /dev/pts/
and noticed that the numbers change from (major =3D N, minor =3D 255) to
(major =3D N, minor =3D 0).  With the previous kernel encoding, the minor
numbers would have increased sequentially, but old userland would not
have noticed the difference since it users old major(), etc., to decode.s

If you create a device by name, then its name needs to be unique instead
of its numbers, but this is easier to arrange.

Bruce
From owner-svn-src-head@freebsd.org  Thu Jun 14 12:35:58 2018
Return-Path: <owner-svn-src-head@freebsd.org>
Delivered-To: svn-src-head@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0349910016D3;
 Thu, 14 Jun 2018 12:35:58 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org
 [IPv6:2610:1c1:1:606c::19:3])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client CN "mxrelay.nyi.freebsd.org",
 Issuer "Let's Encrypt Authority X3" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 9FD81683EF;
 Thu, 14 Jun 2018 12:35:57 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from repo.freebsd.org (repo.freebsd.org
 [IPv6:2610:1c1:1:6068::e6a:0])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7CBA57D5;
 Thu, 14 Jun 2018 12:35:57 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5ECZvE1047960;
 Thu, 14 Jun 2018 12:35:57 GMT (envelope-from kib@FreeBSD.org)
Received: (from kib@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5ECZvTk047959;
 Thu, 14 Jun 2018 12:35:57 GMT (envelope-from kib@FreeBSD.org)
Message-Id: <201806141235.w5ECZvTk047959@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org
 using -f
From: Konstantin Belousov <kib@FreeBSD.org>
Date: Thu, 14 Jun 2018 12:35:57 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r335135 - head/sys/amd64/linux
X-SVN-Group: head
X-SVN-Commit-Author: kib
X-SVN-Commit-Paths: head/sys/amd64/linux
X-SVN-Commit-Revision: 335135
X-SVN-Commit-Repository: base
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.26
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
 <svn-src-head.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-head/>;
List-Post: <mailto:svn-src-head@freebsd.org>
List-Help: <mailto:svn-src-head-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Thu, 14 Jun 2018 12:35:58 -0000

Author: kib
Date: Thu Jun 14 12:35:57 2018
New Revision: 335135
URL: https://svnweb.freebsd.org/changeset/base/335135

Log:
  linuxolator/amd64: Don't mangle %r10 on return from syscall for EJUSTRETURN.
  
  This fixes the %r10 content for rt_sigreturn.
  
  Submitted by:	Yanko Yankulov <yanko.yankulov@gmail.com>
  MFC after:	1 week

Modified:
  head/sys/amd64/linux/linux_sysvec.c

Modified: head/sys/amd64/linux/linux_sysvec.c
==============================================================================
--- head/sys/amd64/linux/linux_sysvec.c	Thu Jun 14 12:14:51 2018	(r335134)
+++ head/sys/amd64/linux/linux_sysvec.c	Thu Jun 14 12:35:57 2018	(r335135)
@@ -228,7 +228,8 @@ linux_set_syscall_retval(struct thread *td, int error)
 	 * the syscall.  So, do not clobber %rdx and %r10.
 	 */
 	td->td_retval[1] = frame->tf_rdx;
-	frame->tf_r10 = frame->tf_rcx;
+	if (error != EJUSTRETURN)
+		frame->tf_r10 = frame->tf_rcx;
 
 	cpu_set_syscall_retval(td, error);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180614213127.E2164>