NetBSD Problem Report #55467

From www@netbsd.org  Tue Jul  7 01:16:29 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 999351A9213
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  7 Jul 2020 01:16:29 +0000 (UTC)
Message-Id: <20200707011628.6A8D01A921A@mollari.NetBSD.org>
Date: Tue,  7 Jul 2020 01:16:28 +0000 (UTC)
From: rokuyama.rk@gmail.com
Reply-To: rokuyama.rk@gmail.com
To: gnats-bugs@NetBSD.org
Subject: tmpfs calls pmap_kenter_pa(9) with virtual address with page offset
X-Send-Pr-Version: www-1.0

>Number:         55467
>Category:       kern
>Synopsis:       tmpfs calls pmap_kenter_pa(9) with virtual address with page offset
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 07 01:20:00 +0000 2020
>Last-Modified:  Thu Jul 09 09:25:01 +0000 2020
>Originator:     Rin Okuyama
>Release:        9.99.69
>Organization:
Department of Physics, Meiji University
>Environment:
NetBSD rb800 9.99.69 NetBSD 9.99.69 (RB800-$Revision: 1.37 $) #13: Tue Jul  7 10:00:31 JST 2020  rin@latipes:/usr/src/sys/arch/evbppc/compile/RB800 evbppc
>Description:
By recent changes, tmpfs became to call pmap_kenter_pa(9) with ``va''
argument with page offset via ubc_uiomove(9).

For many ports, page offset of ``va'' is silently truncated, but this
causes KASSERT failure for powerpc/booke:

----
/etc/rc.conf is not configured.  Multiuser boot aborted.
Enter pathname of shell or RETURN for /bin/sh:
We recommend that you create a non-root account and use su(1) for root access.
rb800# mount /tmp
rb800# dd if=/dev/zero of=/tmp/zero bs=1k count=1024
panic: kernel diagnostic assertion "trunc_page(tlb.tlb_va) == tlb.tlb_va" failed: file "../../../../arch/powerpc/booke/e500_tlb.c", line 233
cpu0: Begin traceback...
0x00bfbb60: at vpanic+0x12c
0x00bfbb90: at kern_assert+0x60
0x00bfbbd0: at tlb_to_hwtlb+0x174
0x00bfbc10: at e500_tlb_update_addr+0x50
0x00bfbc60: at pmap_tlb_update_addr+0x8c
0x00bfbc90: at pmap_kenter_pa+0xf0
0x00bfbcc0: at ubc_alloc.constprop.1+0x30c
0x00bfbd40: at ubc_uiomove+0x118
0x00bfbdb0: at tmpfs_write+0x210
0x00bfbdf0: at VOP_WRITE+0x3c
0x00bfbe20: at vn_write+0x14c
0x00bfbe50: at dofilewrite+0x8c
0x00bfbeb0: at syscall+0x2cc
0x00bfbf20: user SC trap #4 by 0xefc50d48: srr1=0x2d230
            r1=0xffff7950 cr=0x24224882 xer=0 ctr=0xefc50d40
cpu0: End traceback...
Stopped in pid 112.112 (dd) at  netbsd:cpu_Debugger+0xc:        tw      0, r1, r
1
----
>How-To-Repeat:
Described above.
>Fix:
Not known.

I will bisect which commit caused this if required.

According to my record, kernel as of mid April worked fine.

>Audit-Trail:
From: "Rin Okuyama" <rin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55467 CVS commit: src/sys/uvm
Date: Thu, 9 Jul 2020 09:24:33 +0000

 Module Name:	src
 Committed By:	rin
 Date:		Thu Jul  9 09:24:33 UTC 2020

 Modified Files:
 	src/sys/uvm: uvm_bio.c

 Log Message:
 PR kern/55467
 tmpfs calls pmap_kenter_pa(9) with virtual address with page offset

 Bisectioning revealed that the failure starts with this commit:

 sys/fs/tmpfs/tmpfs_vnops.c rev 1.142:
 http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/fs/tmpfs/tmpfs_vnops.c#rev1.142

 by which tmpfs became to use UBC_FAULTBUSY flag for ubc_uiomove(9).
 If this flag is specified, pmap_kenter_pa(9) is called with virtual
 address with page offset via ubc_alloc(9):

 https://nxr.netbsd.org/xref/src/sys/uvm/uvm_bio.c#616

 Most ports seem to neglect silently page offset of va argument for
 pmap_kenter_pa(9). However, it causes KASSERT failure correctly for
 powerpc/booke. So, truncate page offset there.

 Now, tmpfs works just fine on evbppc-booke, and I've confirmed that
 no new failures are detected by ATF.

 Discussed with chs@. Thanks!


 To generate a diff of this commit:
 cvs rdiff -u -r1.120 -r1.121 src/sys/uvm/uvm_bio.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.