Skip to content

log on adding C apps on rcore

Yuekai Jia edited this page Mar 18, 2019 · 26 revisions

plan

  • long term: porting glibc, rustc, add all kinds of apps(GUI, net, games,...) in rcore.
  • middle term: porting musl, rust std on x86-64/aarch64/rv32/64
  • short term: porting litc and some C apps on x86-64

2019.03.17

  • jyk: busybox ls passed on aarch64.

2019.03.09

  • wrj: Implement multithread: sys_clone, sys_futex.

2019.03.08

  • cjj: nginx is working.
  • wrj: fix fs.

2019.03.07

  • cjj: Use musl to build biscuit programs(except a few using biscuit-only syscalls). Add many missing things, and a large number of biscuit programs can run now, the rest usually mostly having problems in fs and memory.

2019.03.04

jyk:

  • Try to run rust std with musl on aarch64, panic at sys_mmap. Because the high 16 bits of user virtual address need to be 1, but sys_mmap doesn't consider.
  • I think it's better to put kernel in the top VA range and put user programs in the bottom VA range. Need to rewrite bootloader.

2019.03.02

  • cjj: Implement sys_getcwd, sys_munmap and sys_time.
  • wrj: Implement a lot file system syscalls

2019.02.27

wrj: How does Biscuit implement TLS

  • All TLS data is declared with __thread and put into tdata or tbss section in ELF.
  • User accesses TLS data through 'thread pointer' (x86_64: fs, aarch64: TPIDR_EL0, riscv: tp)
  • When a process starts, kernel put 2 copies of TLS section into its stack.
    • One for the first thread. Thread pointer (fsbase) is set to there.
    • One for the fresh copy for other threads. Kernel tells user its position by passing kinfo_t to entry.
  • When creating a new thread, user first copies the fresh TLS, then pass the new address in tfork_t to kernel in sys_fork. Kernel will set thread pointer (fsbase) to it for the new thread.

wrj: How does musl implement TLS

  • ELF header is contained in the first page of rodata section. It will be loaded into process memory.
  • Musl looks up the auxiliary vectors in the initial stack, to find the location of ELF header. The aux vectors should contain these entries: AT_PHDR, AT_PHNUM, AT_PHENT.
  • Then it parses the header to find TLS section.
  • For each thread, it allocates space and copies the fresh TLS data, then set fsbase through sys_arch_prctl.

See static_init_tls() in __init_tls.c for details.

wrj:

  • support TLS for musl. test coreutils: true, echo

jyk

  • fixed a bug: when the context switch occurs in InactivePageTable::edit() or InactivePageTable::with() which modify TTBR1_EL1 temporarily, TTBR1_EL1 can be restored to the unmodified value after context switch.

2019.02.25

  • jyk: support simple Biscuit programs on AArch64: echo, hello, cat

2019.02.24

  • wrj:
    • support set fs base (for TLS)
    • then met unknown bug on musl (access address 0). it's hard to debug without backtrace...
    • Biscuit litc has only one TLS variable: errno. Just remove __thread from litc.[c|h], then a lot of programs are runnable.

2019.02.22

  • wrj: update fs. refactor. implementing mmap.
  • jyk: read/repeat wrj's work

2019.02.21

  • wrj:
    • support simple Biscuit programs: echo, hello, cat
    • success to build std with customized musl using xargo

2019.02.20

2019.02.19

  • cy: analyze litc in biscuit. found litc is a customized libc for C/C++ apps(such as redis, nginx) on biscuit x86-64
  • wrj: found musl is statically linked to Rust std, hard to customize. begin port litc on rcore x86-64

2019.02.18

  • cy: try to run&analyze biscuit. install goland IDE, clion IDE
  • wrj: try to analyze musl libc

2019.02.17

  • cy: read biscuit osdi'18 paper
  • wrj: write a analysis doc for syscalls in biscuit

reference