From owner-freebsd-hackers@freebsd.org Tue Mar 3 00:35:40 2020 Return-Path: Delivered-To: freebsd-hackers@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 D86762602D7 for ; Tue, 3 Mar 2020 00:35:40 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-ot1-f67.google.com (mail-ot1-f67.google.com [209.85.210.67]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48WdMv1gC7z3FZ8 for ; Tue, 3 Mar 2020 00:35:38 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-ot1-f67.google.com with SMTP id j5so1262630otn.10 for ; Mon, 02 Mar 2020 16:35:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=VVIzGndlgdEh3gZyvaoQ/53wbUzlLhqnmE6LnA2ZSY0=; b=HiL5eOdjZINzFExK9xbxtAEbJj3G6XHoxp4Rx6uhUH7J5g2w4WJYBvMXwKvvaShQRA jtVNZXpnxnwHHOHBXo9jmkzZZl5I0JcsYK2wBxsUHZpHA+5aU3l+q58qFIuuMs1xzABf d1bDs59V5dOdU1bFjxBUvxFhYo5HA/berIgE8+ABvAVNcZX1P9hbysB3A8OfvBnsOjtD hRm0UaMjuLLSxw/qO6w3x1b5nJPGJpt+0dP3nfeq6YR5E33OuSo62lmySe64g5IW9hzP lfDQw1uxbu3KepVZRZe1tc4ho8c7TctMtoyEkj3SkdBT7Yj1W96CCdEV87vsEXT4157E gTBQ== X-Gm-Message-State: ANhLgQ0sh1AM87Xn4kbIDS9B2mzXfV5NckcEjl9dr3wdday7IszlhlFT 1Y3AFD08ZNP3bY4o+fGQU4Jx6gtv X-Google-Smtp-Source: ADFU+vu/RXHNRZacafWocOBhij7yvOcOLXRPVdhJ7safcjmSFrU1Hy+4KESy4Nw7N8qJjiW48qxWGw== X-Received: by 2002:a9d:2028:: with SMTP id n37mr1486790ota.127.1583195737254; Mon, 02 Mar 2020 16:35:37 -0800 (PST) Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com. [209.85.167.174]) by smtp.gmail.com with ESMTPSA id o15sm4824530ote.2.2020.03.02.16.35.36 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Mar 2020 16:35:37 -0800 (PST) Received: by mail-oi1-f174.google.com with SMTP id i1so1214219oie.8 for ; Mon, 02 Mar 2020 16:35:36 -0800 (PST) X-Received: by 2002:a05:6808:289:: with SMTP id z9mr745220oic.48.1583195736660; Mon, 02 Mar 2020 16:35:36 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Reply-To: cem@freebsd.org From: Conrad Meyer Date: Mon, 2 Mar 2020 16:35:25 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: What is the exact function of the offset parameter in preadv?? To: Willem Jan Withagen Cc: FreeBSD Hackers Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 48WdMv1gC7z3FZ8 X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of csecem@gmail.com designates 209.85.210.67 as permitted sender) smtp.mailfrom=csecem@gmail.com X-Spamd-Result: default: False [-1.99 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[cem@freebsd.org]; RWL_MAILSPIKE_GOOD(0.00)[67.210.85.209.rep.mailspike.net : 127.0.0.18]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; REPLYTO_ADDR_EQ_FROM(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; TO_DN_ALL(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; FORGED_SENDER(0.30)[cem@freebsd.org,csecem@gmail.com]; SUBJECT_ENDS_QUESTION(1.00)[]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; FROM_NEQ_ENVFROM(0.00)[cem@freebsd.org,csecem@gmail.com]; TAGGED_FROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[67.210.85.209.list.dnswl.org : 127.0.5.0]; IP_SCORE(-1.00)[ip: (-0.28), ipnet: 209.85.128.0/17(-2.99), asn: 15169(-1.66), country: US(-0.05)]; RCVD_TLS_ALL(0.00)[] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Mar 2020 00:35:41 -0000 Hi Willem, The offset parameter to the p{read,write}{,v} family of functions indeed indicates a file offset. For ordinary files, negative offsets are invalid (EINVAL). Bhyve is probably accessing a special kernel device file, kmem(4), and those negative "offsets" instead represent addresses in kernel virtual memory. Best, Conrad On Sun, Mar 1, 2020 at 4:47 PM Willem Jan Withagen wrote: > > Hi, > > Tried looking in the manual page, but it does not really describes what > off_t offset does with a preadv... > > I suspect that is the offset in the file to start reading from? > > Next question is: What if the value is negative? > Are we then reading from the end of the file/device if it is > seekable? > > Manual page says: > The pread() and preadv() system calls may also return the following > errors: > [EINVAL] The offset value was negative. > > But then I have this behyve code that gets calls like: > block_proc_read: buf=0x0, cnt=1, len=512, off=-1024(0xfffffc00). > block_proc_read: buf=0x0, cnt=1, len=512, off=-512(0xfffffe00). > block_proc_read: buf=0x0, cnt=1, len=512, off=-1024(0xfffffc00). > block_proc_read: buf=0x0, cnt=1, len=512, off=-512(0xfffffe00). > block_proc_read: buf=0x0, cnt=1, len=512, off=-512(0xfffffe00). > block_proc_read: buf=0x0, cnt=1, len=2048, off=-32256(0xffff8200). > block_proc_read: buf=0x0, cnt=1, len=512, off=512(0x200). > block_proc_read: buf=0x0, cnt=1, len=512, off=0(0x0). > block_proc_read: buf=0x0, cnt=1, len=512, off=512(0x200). > block_proc_read: buf=0x0, cnt=1, len=512, off=0(0x0). > block_proc_read: buf=0x0, cnt=1, len=512, off=512(0x200). > block_proc_read: buf=0x0, cnt=1, len=16384, off=1024(0x400). > block_proc_read: buf=0x0, cnt=1, len=512, off=-512(0xfffffe00). > block_proc_read: buf=0x0, cnt=1, len=16384, off=-16896(0xffffbe00). > block_proc_read: buf=0x0, cnt=1, len=512, off=-512(0xfffffe00). > > Where these are the very first calls that a bhyve loaded image executes. > which I guess is for probing the bootdisk to see where/what it needs to > mount a root disk. > > Below bhyve boot output of a not working boot, and a working boot. > The read trace above is from the working bhyve boot. > > So what are the negative offsets? > > --WjW > > > Compare > Using block_rbd_read for reading from a Rados device > > ============= > vtblk0: on virtio_pci1 > vtblk0: 134217727MB (34359738366 4096 byte sectors) > ahci0: mem 0xc0004000-0xc00043ff irq > 18 at device 4.0 on pci0 > ahci0: AHCI v1.30 with 6 6Gbps ports, Port Multiplier not supported > atkbdc0: port 0x60,0x64 irq 1 on acpi0 > atkbd0: irq 1 on atkbdc0 > kbd0 at atkbd0 > atkbd0: [GIANT-LOCKED] > driver bug: Unable to set devclass (class: atkbdc devname: (unknown)) > psm0: irq 12 on atkbdc0 > psm0: [GIANT-LOCKED] > psm0: model Generic PS/2 mouse, device ID 0 > uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0 > uart0: console (9600,n,8,1) > uart1: <16550 or compatible> port 0x2f8-0x2ff irq 3 on acpi0 > vga0: at port 0x3b0-0x3bb iomem 0xb0000-0xb7fff pnpid > PNP0900 on isa0 > Timecounters tick every 10.000 msec > usb_needs_explore_all: no devclass > Trying to mount root from ufs:/dev/ada0p2 [rw]... > mountroot: waiting for device /dev/ada0p2... > Mounting from ufs:/dev/ada0p2 failed with error 19. > > Loader variables: > vfs.root.mountfrom=ufs:/dev/ada0p2 > vfs.root.mountfrom.options=rw > > Manual root filesystem specification: > : [options] > Mount using filesystem > and with the specified (optional) option list. > > eg. ufs:/dev/da0s1a > zfs:zroot/ROOT/default > cd9660:/dev/cd0 ro > (which is equivalent to: mount -t cd9660 -o ro /dev/cd0 /) > > ? List valid disk boot devices > . Yield 1 second (for background tasks) > Abort manual input > > ============= > > With booting from a normal file device: > atkbdc0: port 0x60,0x64 irq 1 on acpi0 > atkbd0: irq 1 on atkbdc0 > kbd0 at atkbd0 > atkbd0: [GIANT-LOCKED] > driver bug: Unable to set devclass (class: atkbdc devname: (unknown)) > psm0: irq 12 on atkbdc0 > psm0: [GIANT-LOCKED] > psm0: model Generic PS/2 mouse, device ID 0 > uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0 > uart0: console (9600,n,8,1) > uart1: <16550 or compatible> port 0x2f8-0x2ff irq 3 on acpi0 > vga0: at port 0x3b0-0x3bb iomem 0xb0000-0xb7fff pnpid > PNP0900 on isa0 > Timecounters tick every 10.000 msec > usb_needs_explore_all: no devclass > Trying to mount root from ufs:/dev/ada0p2 [rw]... > Root mount waiting for: CAM > ada0 at ahcich0 bus 0 scbus0 target 0 lun 0 > ada0: ACS-2 ATA SATA 3.x device > ada0: Serial Number BHYVE-8C7D-D922-AD47 > ada0: 600.000MB/s transfers (SATA 3.x, UDMA6, PIO 8192bytes) > ada0: Command Queueing enabled > ada0: 20480MB (41943040 512 byte sectors) > ada1 at ahcich6 bus 0 scbus1 target 0 lun 0 > ada1: ACS-2 ATA SATA 3.x device > ada1: Serial Number BHYVE-4318-7904-5D51 > ada1: 600.000MB/s transfers (SATA 3.x, UDMA6, PIO 8192bytes) > ada1: Command Queueing enabled > ada1: 20480MB (41943040 512 byte sectors) > mountroot: waiting for device /dev/ada0p2... > WARNING: / was not properly dismounted > WARNING: /: mount pending error: blocks 168 files 1 > ========== > > > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"