-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run semu inside web browser via WebAssembly translation #38
Comments
Command bridging from web frontend shell(Xterm.js) to real shell has been solved. Now, xv6 can be booted and use it normally. Before entering any command, please wait and see this kernel message:
Otherwise, kernel might panic. Porting source: link |
semu uses + char buf[4096];
+ int offset = 0;
+ int ret;
+ while((ret = read(fd, buf, 4096)) > 0) {
+ memcpy(*ram_loc + offset, buf, ret);
+ offset += ret;
+ }
- *ram_loc = mmap(*ram_loc, st.st_size, PROT_READ | PROT_WRITE,
- MAP_FIXED | MAP_PRIVATE, fd, 0);
- if (*ram_loc == MAP_FAILED) {
- perror("mmap");
- printf("errno: %d\n", errno);
- printf("EINVAL: %d\n", EINVAL);
- printf("size: %lld\n", st.st_size);
- printf("name: %s\n", name);
- close(fd);
- exit(2);
- }
... After applying this patch, Linux can be boot and show dmesg messages.
But, it will stuck at some point. The difficult part to determine the stuck point is that it does not generate error although
void __init console_on_rootfs(void)
{
+ pr_debug("before filp_open /dev/console");
struct file *file = filp_open("/dev/console", O_RDWR, 0);
...
}
void __init console_on_rootfs(void)
{
+ pr_debug("before getname_kernel\n");
struct filename *name = getname_kernel(filename);
...
} To reproduce it, follow the steps in linux-wasm branch. You will see something like below:
According to the stuck point, I believe the bug is highly relevent to console/tty/UART. Any ideas or experiences on this? |
You have the option to disable the standard UART path and retain earlycon solely for debugging purposes. |
After tracing the kernel call stack more deeply, the real stuck point is calling Note: disable Kernel call stack:
Although the kernel boots, but one more problem(very weird) comes out. The kernel hangs when single line of output printed out during running the "/etc/ini.d/rcS" script (before login shell), see demo, press Enter when |
Can you confirm if the above appears for latest linux-6.1.y ? |
I found an interesting WebAssembly-based RISC-V system emulator capable of running Linux kernel with MMU. See RISC-V Emulator with workable WASM! |
I have tried v5.17, v5.19, v6.1, v6.7 and the stuck point still the same. For simplicity, comment out The tracing should be done on host machine. The first tool I can think about is |
Could the terminal emulation efforts be shared and reused in the RVVM project? WebAssembly is already working there: https://lekkit.github.io/test/index.html I am working on a VT emulator locally but I don't think i am able to write a VT100 renderer in JS |
Hi @LekKit, Thank you for your recent messages regarding RISC-V system emulation. I wanted to share some background on my work in this area and discuss potential collaboration opportunities. My motivation for initiating the The initial public release of Recently, my team and I have made further progress in this field:
I want to acknowledge that RVVM is an excellent open-source project. In fact, I have had my students study its codebase to deepen their understanding of RISC-V instruction set simulation and system emulation. Moving forward, instead of reworking the somewhat hacky |
Wow thank you for such a kind and thoughtful response! I really appreciate it Yes, I don't want to sound too selfish, but I believe that if we want something competitive with QEMU and unique the efforts should be directed and not fragmened. But I really think that your project is very cool too. Additionally, RVVM is also sorta oriented at being "small", but mostly in terms of native code footprint. Trying to write readable / well-documented / portable / error-handling code tends to be long anyways, but we can disable a lot of features like JIT, RV64 CPU and different devices/networking via useflags. I am also wondering if anything on my side can be further reinforced and improved. Sorry if some of my contributors are bothering you lately, I hope they figure their stuff out :D (I don't have time to look at virtio stuff yet and wanna focus on CPU side, network stack and image format) |
WebAssembly is capable to port rv32emu to browser. Then, I would like to test the WebAssembly translation of the semu codebase to see if kernels (like Linux or xv6) can be booted in a browser in order to facilitate the further integration of semu to rv32emu.
I would like to start with the smaller codebase and boot xv6 first. A few technical points are as follows:
ls
command to confirm the kernel is booted successfully. The demo below shows Emscripten's capability to boot a kernel.sh
shell's dollar sign ($) of xv6 does not flush after exec, possibly some source kernel code needs to be changed.Demo: xv6
You shall see output of
ls
command like below:Next, command bridging from web frontend shell(Xterm.js) to real shell will be solved, and then boot the Linux kernel.
The text was updated successfully, but these errors were encountered: