okuoku / wasmlinux-project

Build environment WasmLinux kernel and userland
https://wasmlinux-demo.pages.dev/
30 stars 4 forks source link

`sysfs: cannot create duplicate filename '/devices/virtual/tty/(efault)p0'` execution error occurerd. #7

Open yomaytk opened 1 week ago

yomaytk commented 1 week ago

Description

I succeeded in building the executable binary using the given scripts, but the following error occurred when I tried executing it as the native binary, not wasm.

...
[    0.090363] sysfs: cannot create duplicate filename '/devices/virtual/tty/(efault)p0'
[    0.090409] CPU: 0 PID: 1 Comm: swapper Not tainted 6.1.0+ #
[    0.090439]  Call Trace:
[    0.090460]  #00 [<0x00000000001dbbd0>] 0x1dbbd0
[    0.090523]  #01 [<0x0000000073250000>] 0x73250000
[    0.090584] kobject_add_internal failed for (efault)p0 with -EEXIST, don't try to register things with the same name in the same directory.
[    0.090623] Kernel panic - not syncing: Couldn't register pty slave driver
[    0.090657] ---[ end Kernel panic - not syncing: Couldn't register pty slave driver ]---

In addition, the same error occurred when executing wasm binary using xterm-pty on the browser. @okuoku If you know any solutions, I would appreciate it if you could tell me.

detail of the log ```bash [ 0.000000] Linux version 6.1.0+ (ubuntu@ip-172-31-4-105) (Ubuntu clang version 18.1.8 (++20240731024944+3b5b5c1ec4a3-1~exp1~20240731145000.144), Ubuntu LLD 18.1.8) # [ 0.000000] memblock address range: 0x200000 - 0x4200000 [ 0.000000] Zone ranges: [ 0.000000] Normal [mem 0x0000000000200000-0x00000000041fffff] [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000000200000-0x00000000041fffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000000200000-0x00000000041fffff] [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 16256 [ 0.000000] Kernel command line: mem=64M [ 0.000000] Unknown kernel command line parameters "mem=64M", will be passed to user space. [ 0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes, linear) [ 0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes, linear) [ 0.000000] mem auto-init: stack:all(zero), heap alloc:off, heap free:off [ 0.000000] Memory: 64904K/65536K available (0K kernel code, 0K rwdata, 0K rodata, 0K init, 0K bss, 632K reserved, 0K cma-reserved) [ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 [ 0.000000] NR_IRQS: 1024 [ 0.000000] lkl: irqs initialized [ 0.000000] clocksource: lkl: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns [ 0.000000] lkl: time and timers initialized (irq1) [ 0.000052] pid_max: default: 4096 minimum: 301 [ 0.000467] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.000588] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.015862] printk: console [lkl_console0] enabled [ 0.016112] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns [ 0.019529] NET: Registered PF_NETLINK/PF_ROUTE protocol family [ 0.020840] lkl_pci: probe of lkl_pci failed with error -1 [ 0.022932] raid6: skipped pq benchmark and selected int32x8 [ 0.022966] raid6: using intx1 recovery algorithm [ 0.025076] vgaarb: loaded [ 0.025190] clocksource: Switched to clocksource lkl [ 0.027822] NET: Registered PF_INET protocol family [ 0.028808] IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear) [ 0.030215] tcp_listen_portaddr_hash hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.030261] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear) [ 0.030292] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.030332] TCP bind hash table entries: 1024 (order: 1, 8192 bytes, linear) [ 0.030380] TCP: Hash tables configured (established 1024 bind 1024) [ 0.031395] UDP hash table entries: 256 (order: 0, 4096 bytes, linear) [ 0.031440] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear) [ 0.031677] PCI: CLS 0 bytes, default 32 [ 0.033257] workingset: timestamp_bits=30 max_order=14 bucket_order=0 [ 0.045300] SGI XFS with ACLs, security attributes, no debug enabled [ 0.048084] xor: automatically using best checksumming function 8regs [ 0.048401] io scheduler mq-deadline registered [ 0.048429] io scheduler kyber registered [ 0.090363] sysfs: cannot create duplicate filename '/devices/virtual/tty/(efault)p0' [ 0.090409] CPU: 0 PID: 1 Comm: swapper Not tainted 6.1.0+ # [ 0.090439] Call Trace: [ 0.090460] #00 [<0x00000000001dbbd0>] 0x1dbbd0 [ 0.090523] #01 [<0x0000000073250000>] 0x73250000 [ 0.090584] kobject_add_internal failed for (efault)p0 with -EEXIST, don't try to register things with the same name in the same directory. [ 0.090623] Kernel panic - not syncing: Couldn't register pty slave driver [ 0.090657] ---[ end Kernel panic - not syncing: Couldn't register pty slave driver ]--- panic. ```

Environment

~$ uname -v -i
#18~22.04.1-Ubuntu SMP Thu Oct  3 19:57:42 UTC 2024 x86_64

Thanks.

okuoku commented 1 week ago

It seems you have used Ubuntu-bundled Clang

(Ubuntu clang version 18.1.8 (++20240731024944+3b5b5c1ec4a3-1~exp1~20240731145000.144), Ubuntu LLD 18.1.8)

This is more recent version than mine; does the issue still reproduce with LLVM version ( https://github.com/llvm/llvm-project/tree/6367677c9d901f412934b4935c4341dc6d421d36 ) which is bundled on this repository?

Anyway, this is unexpected and I'll chase difference...

okuoku commented 1 week ago

I couldn't reproduce your issue with your toolchain (it seems it was from official LLVM .dev package) so I suspect build process has some issue to recreate intended configuration (= .config file).

My working .config attached.

my_config.txt

But thanks to your report, pushed 2 QOL update:

yomaytk commented 5 days ago

@okuoku I succeeded in correctly executing lkl-wasm on the browser using my_config.txt. Thank you!🙏

However, when I tried executing lkl-wasm on the native environment, the following unexpected log messages was output. (It seems that the process up to the log Run /init as init process was correct)

[    0.076126] Run /init as init process
Exiting thread.
TLS[1]: 1 -> 0
Thread: 1 Call = 59 Ret = 0
Ret: 0, 0, 1
TLS[1]: 1 -> 3bbc00
Thread: 1 Call = 59 Ret = 0
(user) syscall = 94
TLS[60]: 1 -> 880000
Rearm: 9643783
[    0.077871] Exiting userthread.
Exiting thread(main thread).
???: TLS destructor 0 did not found.
TLS[1]: 1 -> 3bbc00
TLS[63]: 1 -> 880c00
...
[    0.154921] Exiting userthread.
Exiting thread(main thread).
???: TLS destructor 0 did not found.
MINIIO[0]: 5
MINIIO[1]: 2
MINIIO[2]: 110519660813664
MINIIO[3]: 0
MINIIO[4]: 0

Rearm: 9801441
detail of the log ```bash memmgr region = ptr: 0x7adb56e00000 pages: 36 - 2084 malloc: 0x7adb57040000 (offs: 0x240000) 67108864 [ 0.000000] Linux version 6.1.0+ (ubuntu@ip-172-31-4-105) (clang version 18.0.0 (https://github.com/llvm/llvm-project 6367677c9d901f412934b4935c4341dc6d421d36), LLD 18.0.0) # [ 0.000000] memblock address range: 0x240000 - 0x4240000 [ 0.000000] Zone ranges: [ 0.000000] Normal [mem 0x0000000000240000-0x000000000423ffff] [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000000240000-0x000000000423ffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000000240000-0x000000000423ffff] [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 16256 [ 0.000000] Kernel command line: mem=64M [ 0.000000] Unknown kernel command line parameters "mem=64M", will be passed to user space. [ 0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes, linear) [ 0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes, linear) [ 0.000000] mem auto-init: stack:all(zero), heap alloc:off, heap free:off [ 0.000000] Memory: 64904K/65536K available (0K kernel code, 0K rwdata, 0K rodata, 0K init, 0K bss, 632K reserved, 0K cma-reserved) [ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 [ 0.000000] NR_IRQS: 1024 [ 0.000000] lkl: irqs initialized [ 0.000000] clocksource: lkl: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns [ 0.000000] lkl: time and timers initialized (irq1) [ 0.000050] pid_max: default: 4096 minimum: 301 [ 0.000463] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.000584] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.016252] printk: console [lkl_console0] enabled [ 0.016522] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns [ 0.016564] futex hash table entries: 16 (order: -5, 192 bytes, linear) [ 0.019991] NET: Registered PF_NETLINK/PF_ROUTE protocol family [ 0.021281] lkl_pci: probe of lkl_pci failed with error -1 [ 0.023402] raid6: skipped pq benchmark and selected int32x8 [ 0.023446] raid6: using intx1 recovery algorithm [ 0.024233] SCSI subsystem initialized [ 0.025157] usbcore: registered new interface driver usbfs [ 0.025345] usbcore: registered new interface driver hub [ 0.025539] usbcore: registered new device driver usb [ 0.027408] vgaarb: loaded [ 0.027541] clocksource: Switched to clocksource lkl [ 0.030168] NET: Registered PF_INET protocol family Rearm: 7040163 [ 0.031156] IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear) [ 0.032574] tcp_listen_portaddr_hash hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.032627] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear) [ 0.032659] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.032699] TCP bind hash table entries: 1024 (order: 1, 8192 bytes, linear) [ 0.032745] TCP: Hash tables configured (established 1024 bind 1024) [ 0.033733] UDP hash table entries: 256 (order: 0, 4096 bytes, linear) [ 0.033778] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear) [ 0.034011] NET: Registered PF_UNIX/PF_LOCAL protocol family [ 0.034079] PCI: CLS 0 bytes, default 32 [ 0.035677] workingset: timestamp_bits=30 max_order=14 bucket_order=0 [ 0.048297] ntfs: driver 2.1.32 [Flags: R/W]. [ 0.048515] ntfs3: Max link count 4000 [ 0.048541] ntfs3: Enabled Linux POSIX ACLs support [ 0.048563] ntfs3: Read-only LZX/Xpress compression included [ 0.048745] fuse: init (API version 7.37) [ 0.049832] SGI XFS with ACLs, security attributes, no debug enabled [ 0.053288] xor: automatically using best checksumming function 8regs [ 0.053650] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254) [ 0.053686] io scheduler mq-deadline registered [ 0.053711] io scheduler kyber registered [ 0.057587] tun: Universal TUN/TAP device driver, 1.6 [ 0.058123] usbcore: registered new interface driver asix [ 0.058296] usbcore: registered new interface driver ax88179_178a [ 0.058485] usbcore: registered new interface driver cdc_ether [ 0.058660] usbcore: registered new interface driver net1080 [ 0.058830] usbcore: registered new interface driver cdc_subset [ 0.059014] usbcore: registered new interface driver zaurus [ 0.059269] usbcore: registered new interface driver cdc_ncm [ 0.059451] usbcore: registered new interface driver aqc111 [ 0.059626] usbcore: registered new interface driver r8153_ecm [ 0.060147] usbcore: registered new interface driver uas [ 0.060346] usbcore: registered new interface driver usb-storage [ 0.060940] usbcore: registered new interface driver usbserial_generic [ 0.061102] usbserial: USB Serial support registered for generic [ 0.061274] usbcore: registered new interface driver cp210x [ 0.061441] usbserial: USB Serial support registered for cp210x [ 0.061617] usbcore: registered new interface driver cypress_m8 [ 0.061778] usbserial: USB Serial support registered for DeLorme Earthmate USB [ 0.061940] usbserial: USB Serial support registered for HID->COM RS232 Adapter [ 0.062099] usbserial: USB Serial support registered for Nokia CA-42 V2 Adapter [ 0.062273] usbcore: registered new interface driver ftdi_sio [ 0.062440] usbserial: USB Serial support registered for FTDI USB Serial Device [ 0.062625] usbcore: registered new interface driver pl2303 [ 0.062782] usbserial: USB Serial support registered for pl2303 [ 0.062953] usbcore: registered new interface driver usb_serial_simple [ 0.063111] usbserial: USB Serial support registered for carelink [ 0.063268] usbserial: USB Serial support registered for zio [ 0.063435] usbserial: USB Serial support registered for funsoft [ 0.063599] usbserial: USB Serial support registered for flashloader [ 0.063760] usbserial: USB Serial support registered for google [ 0.063922] usbserial: USB Serial support registered for libtransistor [ 0.064079] usbserial: USB Serial support registered for vivopay [ 0.064236] usbserial: USB Serial support registered for moto_modem [ 0.064409] usbserial: USB Serial support registered for motorola_tetra [ 0.064692] usbserial: USB Serial support registered for nokia [ 0.064850] usbserial: USB Serial support registered for novatel_gps [ 0.065006] usbserial: USB Serial support registered for hp4x [ 0.065166] usbserial: USB Serial support registered for suunto [ 0.065324] usbserial: USB Serial support registered for siemens_mpi [ 0.066494] usbcore: registered new interface driver usbhid [ 0.066526] usbhid: USB HID core driver [ 0.068068] NET: Registered PF_INET6 protocol family [ 0.070914] Segment Routing with IPv6 [ 0.071157] In-situ OAM (IOAM) with IPv6 [ 0.071320] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver [ 0.072968] Key type dns_resolver registered [ 0.075138] Btrfs loaded, crc32c=crc32c-generic, zoned=no, fsverity=no [ 0.076059] Warning: unable to open an initial console. [ 0.076100] This architecture does not have kernel memory protection. [ 0.076126] Run /init as init process Exiting thread. TLS[1]: 1 -> 0 Thread: 1 Call = 59 Ret = 0 Ret: 0, 0, 1 TLS[1]: 1 -> 3bbc00 Thread: 1 Call = 59 Ret = 0 Ret: 0, 2, 3 TLS[1]: 1 -> 3bbc00 Thread: 1 Call = 172 Ret = 1 (init) pid = 1 TLS[1]: 1 -> 3bbc00 TLS[56]: 1 -> 0 Rearm: 80213796 Rearm: 207876 TLS[58]: 1 -> 0 Rearm: 1000 TLS[60]: 1 -> 880000 ... # omitted because the logs was too long. [ 0.156207] Exiting userthread. Exiting thread(main thread). ???: TLS destructor 0 did not found. MINIIO[0]: 5 MINIIO[1]: 2 MINIIO[2]: 101615908826080 MINIIO[3]: 0 MINIIO[4]: 0 Rearm: 9790959 Rearm: 9703054 Rearm: 9703710 Rearm: 9693913 Rearm: 9699438 # continue to output Rearm: xxx ```

The generated native binary runner depends on libuv.so.1, so I tried some versions of libuv (1.43.0, 1.49.0), but the result was the same... In any case, I was able to execute LKL as Wasm, so it was a great help. Thank you!

okuoku commented 5 days ago

These are debug print; you can disable it with replacing PCK0 and PCK functions and/or active_debug_print variable

https://github.com/okuoku/wasmlinux-runner/blob/67b75f18d11de4eaacf4cd14e85700d22d06ddbb/hostrunner/runner.cpp#L51