Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Dec 2022 23:13:19 +0400
From:      Hikmat Jafarli <jafarlihi@gmail.com>
To:        freebsd-fs@freebsd.org
Subject:   Trying to implement BFS, page fault at vfs_domount_first, how to debug?
Message-ID:  <CAPWrP-Y3usfDukwhQroJY0NUbZK_C=cuctm%2BXYSjBqDQYejBWw@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
--000000000000e67b7e05f1106808
Content-Type: text/plain; charset="UTF-8"

I'm trying to implement the BeOS filesystem (BFS) for FreeBSD.
The repository is here: https://github.com/jafarlihi/freebsd-bfs
(Please don't mind bad styling and all the copy-paste work,
I'll polish it later, I'm just trying to get to some PoC where it works)

Now when I try to mount a valid BFS partition (reported as BFS by `fstyp`)
it executes all the way to printf that logs "Either not a BFS volume or
corrupted" and then crashes with "page fault while in kernel mode" in
vfs_domount_first+0x271. Here's the log:
```
Either not a BFS volume or corrupted

Fatal trap 12: page fault while in kernel mode
cpuid = 0; apic id = 00
fault virtual address = 0x18
fault code = supervisor read data, page not present
instruction pointer = 0x20:0xffffffff82b2427b
stack pointer        = 0x28:0xfffffe00df399ac0
frame pointer        = 0x28:0xfffffe00df399ac0
code segment = base 0x0, limit 0xfffff, type 0x1b
= DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags = interrupt enabled, resume, IOPL = 0
current process = 1208 (mount)
trap number = 12
panic: page fault
cpuid = 0
time = 1672414952
KDB: stack backtrace:
#0 0xffffffff80c694a5 at kdb_backtrace+0x65
#1 0xffffffff80c1bb5f at vpanic+0x17f
#2 0xffffffff80c1b9d3 at panic+0x43
#3 0xffffffff810afdf5 at trap_fatal+0x385
#4 0xffffffff810afe4f at trap_pfault+0x4f
#5 0xffffffff810875b8 at calltrap+0x8
#6 0xffffffff80cf0651 at vfs_domount_first+0x271
#7 0xffffffff80cece9d at vfs_domount+0x2ad
#8 0xffffffff80cec2d8 at vfs_donmount+0x8f8
#9 0xffffffff80ceb9a9 at sys_nmount+0x69
#10 0xffffffff810b06ec at amd64_syscall+0x10c
#11 0xffffffff81087ecb at fast_syscall_common+0xf8
```

Now I'm trying to understand what exactly goes wrong here
and how to map 0x271 to the exact source line.

I'd appreciate it if someone could tell me how to debug this.

(Sorry for noob question, I already tried IRC and was directed here)

--000000000000e67b7e05f1106808
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I&#39;m trying to implement the BeOS filesystem (BFS) for =
FreeBSD.<br>The repository is here:=C2=A0<a href=3D"https://github.com/jafa=
rlihi/freebsd-bfs" target=3D"_blank">https://github.com/jafarlihi/freebsd-b=
fs</a><br>(Please don&#39;t mind bad styling and all the copy-paste work,<b=
r>I&#39;ll polish it later, I&#39;m just trying to get to some PoC where it=
 works)<br><br>Now when I try to mount a valid BFS partition (reported as B=
FS by `fstyp`)<br>it executes all the way to printf that logs &quot;Either =
not a BFS volume or<br>corrupted&quot; and then crashes with &quot;page fau=
lt while in kernel mode&quot; in<br>vfs_domount_first+0x271. Here&#39;s the=
 log:<br>```<br>Either not a BFS volume or corrupted<br><br>Fatal trap 12: =
page fault while in kernel mode<br>cpuid =3D 0; apic id =3D 00<br>fault vir=
tual address =3D 0x18<br>fault code =3D supervisor read data, page not pres=
ent<br>instruction pointer =3D 0x20:0xffffffff82b2427b<br>stack pointer =C2=
=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x28:0xfffffe00df399ac0<br>frame pointer =C2=A0=
 =C2=A0 =C2=A0 =C2=A0=3D 0x28:0xfffffe00df399ac0<br>code segment =3D base 0=
x0, limit 0xfffff, type 0x1b<br>=3D DPL 0, pres 1, long 1, def32 0, gran 1<=
br>processor eflags =3D interrupt enabled, resume, IOPL =3D 0<br>current pr=
ocess =3D 1208 (mount)<br>trap number =3D 12<br>panic: page fault<br>cpuid =
=3D 0<br>time =3D 1672414952<br>KDB: stack backtrace:<br>#0 0xffffffff80c69=
4a5 at kdb_backtrace+0x65<br>#1 0xffffffff80c1bb5f at vpanic+0x17f<br>#2 0x=
ffffffff80c1b9d3 at panic+0x43<br>#3 0xffffffff810afdf5 at trap_fatal+0x385=
<br>#4 0xffffffff810afe4f at trap_pfault+0x4f<br>#5 0xffffffff810875b8 at c=
alltrap+0x8<br>#6 0xffffffff80cf0651 at vfs_domount_first+0x271<br>#7 0xfff=
fffff80cece9d at vfs_domount+0x2ad<br>#8 0xffffffff80cec2d8 at vfs_donmount=
+0x8f8<br>#9 0xffffffff80ceb9a9 at sys_nmount+0x69<br>#10 0xffffffff810b06e=
c at amd64_syscall+0x10c<br>#11 0xffffffff81087ecb at fast_syscall_common+0=
xf8<br>```<br><br>Now I&#39;m trying to understand what exactly goes wrong =
here<br>and how to map 0x271 to the exact source line.<br><br>I&#39;d appre=
ciate it if someone could tell me how to debug this.<br><br>(Sorry for noob=
 question, I already tried IRC and was directed here)<br></div>

--000000000000e67b7e05f1106808--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPWrP-Y3usfDukwhQroJY0NUbZK_C=cuctm%2BXYSjBqDQYejBWw>