From owner-freebsd-current@freebsd.org Sun Jul 21 14:44:11 2019 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B8A50B527C for ; Sun, 21 Jul 2019 14:44:11 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 51332830CE for ; Sun, 21 Jul 2019 14:44:11 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id x6LEi4Sn008837 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 21 Jul 2019 17:44:07 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x6LEi4Sn008837 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x6LEi48e008836; Sun, 21 Jul 2019 17:44:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 21 Jul 2019 17:44:04 +0300 From: Konstantin Belousov To: Laurie Jennings Cc: "freebsd-current@freebsd.org" Subject: Re: mmap port from 9 not working Message-ID: <20190721144404.GJ47193@kib.kiev.ua> References: <446145008.4396329.1563680883838.ref@mail.yahoo.com> <446145008.4396329.1563680883838@mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <446145008.4396329.1563680883838@mail.yahoo.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jul 2019 14:44:11 -0000 On Sun, Jul 21, 2019 at 03:48:03AM +0000, Laurie Jennings wrote: > I have some custom stuff I'm porting from Freebsd 9.x using mmap. I get a pointer from the kernel via an ioctl and I map it into a shared buffer. > char *kptr;   // mem ptr from kernel > fd=open("/dev/kmem",O_RDWR);memp=mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,fd,(off_t) ptr); > > This worked perfectly in 9; memp I had a shared block of memory between the kernel and user space. > In 11.3 this returns an errno 22, which is pretty murky. I did notice that off_t doesnt yield an actual offset; I've tried putting in the correct value manuallybut it just fails and fails.I've tried read only also.  > Please Help! Start with providing (and looking yourself) at the output of kdump/ktrace around the failing mmap. The checks for correctness of the mmap(2) arguments were greatly improved during years after FreeBSD 9.