Git Product home page Git Product logo

lk's People

Contributors

aaron-odell avatar arichardson avatar arve-android avatar bingzhux avatar cdotstout avatar cleverca22 avatar cpu-chromium avatar eberman-quic avatar eieio avatar erikcorrygoogle avatar girtsf avatar gkalsi avatar heatd avatar hollanderic avatar ianloic avatar james-zzz avatar konkers avatar luka177 avatar m1cha avatar macpaul avatar mob5566 avatar nvll avatar pcc avatar playground-will avatar riandrews avatar schultetwin1 avatar srodrig1 avatar swetland avatar travisg avatar zeusk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lk's Issues

Any way to boot lk in x86 uefi?

I have managed booting lk on x86 in legacy mode, now am trying to boot it in uefi, but failed.
Steps:

  1. copy lk.bin into /boot directory of ubuntu 16.04
  2. add an entry in grub.cfg submenu
    menuentry "lk" {
    multiboot /boot/lk.bin
    boot
    }
    It works in legacy mode, do you have any idea to boot it in uefi mode?

arch for build-qemu-m4-test

Hi, Sorry for bothering, however does build-qemu-m4-test refer to cortex-m4 arm arch please?

I tried to use qemu-system-arm execute it, however it does not work through. Qemu shows up with error message as "no cortex-m4" exists.

Incorrect call to thread_resched in thread_unblock_from_wait_queue

In thread_unblock_from_wait_queue,

If reschedule is true, current thread is not inserted on a run list before calling thread_resched which essentially blocks (without updating the status field) the current thread.

Possible solution:
change thread_resched to thread_yield (newly woken thread will still run if it's priority is higher than or equal to the priority of current thread).

Why is "WITH_LIB_CONSOLE" not defined anywhere?

Hi,

I have done a full scan of the code trying to understand WITH_LIB_CONSOLE. I have have seen many cases where it is being tested for conditional compilation of blocks of code. But it doesn't seem to be defined anywhere. Not in any header file; nor in any make file; not even in app/shell which seems to me the primary user of lib/console. What gives ?

Thanks,

VMM alloc fails

I'm not sure if this is a platform bug or not.

I run 'vmm alloc 4096 2'.
ltracef logs:
arch_mmu_map:299: vaddr 0x40000000 paddr 0x894aa000 count 1 flags 0x0
arch_mmu_map:332: tt_entry 0x40000406
panic (caller 0xc0010061): arch_mmu_map unimplemented

I added some prints, and it fails the unimplemented code in MMU_MEMORY_L1_DESCRIPTOR_SECTION.

PMM arenas:

arena 0xc001ccb0: name 'sdram' base 0x88f00000 size 0x20000000 priority 0 flags 0x1
        page_array 0xc0029170, free_count 129622
        free ranges:
                0x894aa000 - 0xa8f00000

VMM aspaces:

aspace 0xc0029130: name 'kernel' range 0x40000000 - 0xffffffff size 0xc0000000 flags 0x0
regions:
        region 0x890aa00c: name 'memory' range 0x80000000 - 0xbfffffff size 0x40000000 flags 0x1 mmu_flags 0x2
        region 0x890aa058: name 'memory' range 0xc0000000 - 0xffffffff size 0x40000000 flags 0x1 mmu_flags 0x2

the function _vsnprintf_output returns bad count.

in function _vsnprintf_output from:lib/libc/printf.c

static int _vsnprintf_output(const char *str, size_t len, void *state)
{
struct _output_args *args = state;

size_t count = 0;
while (count < len) {
    if (args->pos < args->len) {
        args->outstr[args->pos++] = *str;
    }

    str++;
    count++;
}

return count;

}

the return value count couldn't represent the actual length of string const char *str.

[linker][x86_64] page fault crash happens when calling lk_init_level() in lk_main()

Travis,
I found a new issue was introduced from this patch recently:
114a350

I encountered a serious crash issue (x86_64) during startup (lk_main()), when calling lk_primary_cpu_init_level (). Here is the crash log from lk_init_level()

lk_init_level:61: looking at 0x226e10 (version) level 0x3ffff, flags 0x1, seen_last 0
lk_init_level:61: looking at 0x226e28 (S粈p") level 0x0, flags 0x0, seen_last 0
lk_init_level:61: looking at 0x226e40
---- page fault happens here ----

The above log printed from the below "for-loop" in lk_init_level() function, you can see that every iteration, the ptr++ will increase address by 0x18.
for (const struct lk_init_struct *ptr = __lk_init; ptr != __lk_init_end; ptr++)

However, my investigation shows that the structure "lk_init_struct" is aligned with 0x10-byte. see the output file lk.elf.sym.sorted. so the above iteration, the address should increase by 0x20.
0000000000226e10 g .lk_init 0000000000000000 __lk_init
0000000000226e10 g O .lk_init 0000000000000018 _init_struct_version
0000000000226e30 g O .lk_init 0000000000000018 _init_struct_vm
0000000000226e50 g O .lk_init 0000000000000018 _init_struct_vm_preheap
0000000000226e68 g .lk_init 0000000000000000 __lk_init_end

You can see that the size of the structure "init_struct*" is 0x18, this is correct, but, their address is aligned with 0x10 (incremental is 0x20 for each structure), as below:
0000000000226e10
0000000000226e30
0000000000226e50

Notes:

  1. x64 32bit is OK, but I think it is just a coincidence. Not sure if ARM has the similar issue.
  2. this issue also happens in other sections like ".apps", or ".drivers"
    0000000000226ca0 g .apps 0000000000000000 __apps_start
    0000000000226ca0 g O .apps 0000000000000028 _app_shell
    0000000000226ce0 g O .apps 0000000000000028 _app_stringtests
    0000000000226d20 g O .apps 0000000000000028 _app_tests
    0000000000226d48 g .apps 0000000000000000 __apps_end

arp list crashes LK

Commit 63fa995, Ubuntu 16.04 host.

[5.1.1]antone@lnxantone1:~/git/lk> scripts/do-qemuarm
DO_BLOCK = 0
DO_NET = 0
make[1]: Entering directory '/home/antone/git/lk'
make[2]: Entering directory '/home/antone/git/lk'
PROJECT = qemu-virt-a15-test
PLATFORM = qemu-virt
TARGET = qemu-virt

TOOLCHAIN_PREFIX = arm-none-eabi-
LIBGCC = /usr/lib/gcc/arm-none-eabi/4.9.3/armv7-ar/thumb/softfp/libgcc.a
GLOBAL_COMPILEFLAGS = -g -finline -include ./build-qemu-virt-a15-test/config.h -W -Wall -Wno-multichar -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Werror=return-type -fno-common -mthumb-interwork  -mcpu=cortex-a15 -mfpu=vfpv3 -mfloat-abi=softfp -mthumb -D__thumb__
including app app/inetsrv app/shell app/stringtests app/tests dev dev/interrupt/arm_gic dev/timer/arm_generic dev/virtio/block dev/virtio/gpu dev/virtio/net kernel lib/aes lib/aes/test lib/cbuf lib/cksum lib/debugcommands lib/fdt lib/fs lib/fs/ext2 lib/fs/fat32 lib/fs/memfs lib/fs/spifs lib/fs/spifs/test lib/libm lib/minip lib/version platform target
including dev/virtio kernel/vm lib/bcache lib/bio lib/console lib/debug lib/fixed_point lib/gfx lib/heap lib/iovec lib/libc lib/pool lib/tftp
including lib/heap/dlmalloc lib/io
LIBGCC = /usr/lib/gcc/arm-none-eabi/4.9.3/armv7-ar/thumb/softfp/libgcc.a
GLOBAL_COMPILEFLAGS = -g -finline -include ./build-qemu-virt-a15-test/config.h -W -Wall -Wno-multichar -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Werror=return-type -fno-common -mthumb-interwork
GLOBAL_OPTFLAGS = -O2
generating build-qemu-virt-a15-test/platform/qemu-virt/module_config.h
generating build-qemu-virt-a15-test/config.h
generating build-qemu-virt-a15-test/top/module_config.h
generating build-qemu-virt-a15-test/arch/arm/module_config.h
generating build-qemu-virt-a15-test/app/inetsrv/module_config.h
generating build-qemu-virt-a15-test/app/module_config.h
generating build-qemu-virt-a15-test/app/shell/module_config.h
generating build-qemu-virt-a15-test/app/stringtests/module_config.h
generating build-qemu-virt-a15-test/app/tests/module_config.h
generating build-qemu-virt-a15-test/dev/module_config.h
generating build-qemu-virt-a15-test/dev/interrupt/arm_gic/module_config.h
generating build-qemu-virt-a15-test/dev/timer/arm_generic/module_config.h
generating build-qemu-virt-a15-test/dev/virtio/block/module_config.h
generating build-qemu-virt-a15-test/dev/virtio/gpu/module_config.h
generating build-qemu-virt-a15-test/dev/virtio/net/module_config.h
generating build-qemu-virt-a15-test/kernel/module_config.h
generating build-qemu-virt-a15-test/external/lib/aes/module_config.h
generating build-qemu-virt-a15-test/external/lib/aes/test/module_config.h
generating build-qemu-virt-a15-test/lib/cbuf/module_config.h
generating build-qemu-virt-a15-test/external/lib/cksum/module_config.h
generating build-qemu-virt-a15-test/lib/debugcommands/module_config.h
generating build-qemu-virt-a15-test/external/lib/fdt/module_config.h
generating build-qemu-virt-a15-test/lib/fs/module_config.h
generating build-qemu-virt-a15-test/lib/fs/ext2/module_config.h
generating build-qemu-virt-a15-test/lib/fs/fat32/module_config.h
generating build-qemu-virt-a15-test/lib/fs/memfs/module_config.h
generating build-qemu-virt-a15-test/lib/fs/spifs/module_config.h
generating build-qemu-virt-a15-test/lib/fs/spifs/test/module_config.h
generating build-qemu-virt-a15-test/external/lib/libm/module_config.h
generating build-qemu-virt-a15-test/lib/minip/module_config.h
generating build-qemu-virt-a15-test/buildid.h
build-qemu-virt-a15-test/buildid.h.tmp build-qemu-virt-a15-test/buildid.h differ: byte 115, line 3
generating build-qemu-virt-a15-test/lib/version/module_config.h
generating build-qemu-virt-a15-test/platform/module_config.h
generating build-qemu-virt-a15-test/target/module_config.h
generating build-qemu-virt-a15-test/dev/virtio/module_config.h
generating build-qemu-virt-a15-test/kernel/vm/module_config.h
generating build-qemu-virt-a15-test/lib/bcache/module_config.h
generating build-qemu-virt-a15-test/lib/bio/module_config.h
generating build-qemu-virt-a15-test/lib/console/module_config.h
generating build-qemu-virt-a15-test/lib/debug/module_config.h
generating build-qemu-virt-a15-test/lib/fixed_point/module_config.h
generating build-qemu-virt-a15-test/lib/gfx/module_config.h
generating build-qemu-virt-a15-test/lib/heap/module_config.h
generating build-qemu-virt-a15-test/lib/iovec/module_config.h
generating build-qemu-virt-a15-test/lib/libc/module_config.h
generating build-qemu-virt-a15-test/lib/pool/module_config.h
generating build-qemu-virt-a15-test/lib/tftp/module_config.h
generating build-qemu-virt-a15-test/external/lib/heap/dlmalloc/module_config.h
generating build-qemu-virt-a15-test/lib/io/module_config.h
generating build-qemu-virt-a15-test/system-onesegment.ld
compiling lib/version/version.c
linking build-qemu-virt-a15-test/lib/version.mod.o
linking build-qemu-virt-a15-test/lk.elf
   text	   data	    bss	    dec	    hex	filename
    177	      0	      0	    177	     b1	./build-qemu-virt-a15-test/app.mod.o
   2028	      0	      0	   2028	    7ec	./build-qemu-virt-a15-test/app/inetsrv.mod.o
     34	      0	      0	     34	     22	./build-qemu-virt-a15-test/app/shell.mod.o
   2673	     12	     16	   2701	    a8d	./build-qemu-virt-a15-test/app/stringtests.mod.o
  23412	    140	    188	  23740	   5cbc	./build-qemu-virt-a15-test/app/tests.mod.o
  11405	     20	  49280	  60705	   ed21	./build-qemu-virt-a15-test/arch/arm.mod.o
   1515	      0	      0	   1515	    5eb	./build-qemu-virt-a15-test/dev.mod.o
   1077	      0	   1796	   2873	    b39	./build-qemu-virt-a15-test/dev/interrupt/arm_gic.mod.o
   2412	      0	     44	   2456	    998	./build-qemu-virt-a15-test/dev/timer/arm_generic.mod.o
   1967	      0	      4	   1971	    7b3	./build-qemu-virt-a15-test/dev/virtio.mod.o
   1310	      0	      1	   1311	    51f	./build-qemu-virt-a15-test/dev/virtio/block.mod.o
   2730	      0	      4	   2734	    aae	./build-qemu-virt-a15-test/dev/virtio/gpu.mod.o
   2879	      0	      4	   2883	    b43	./build-qemu-virt-a15-test/dev/virtio/net.mod.o
  14108	      0	      0	  14108	   371c	./build-qemu-virt-a15-test/external/lib/aes.mod.o
    885	     12	      0	    897	    381	./build-qemu-virt-a15-test/external/lib/aes/test.mod.o
   3392	     12	      0	   3404	    d4c	./build-qemu-virt-a15-test/external/lib/cksum.mod.o
  11134	      0	      0	  11134	   2b7e	./build-qemu-virt-a15-test/external/lib/fdt.mod.o
  15630	     28	    524	  16182	   3f36	./build-qemu-virt-a15-test/external/lib/heap/dlmalloc.mod.o
  19672	     32	      8	  19712	   4d00	./build-qemu-virt-a15-test/external/lib/libm.mod.o
  18302	     12	   2772	  21086	   525e	./build-qemu-virt-a15-test/kernel.mod.o
  10779	    124	     88	  10991	   2aef	./build-qemu-virt-a15-test/kernel/vm.mod.o
   1575	      0	      0	   1575	    627	./build-qemu-virt-a15-test/lib/bcache.mod.o
   9121	     48	      0	   9169	   23d1	./build-qemu-virt-a15-test/lib/bio.mod.o
   1974	      0	      0	   1974	    7b6	./build-qemu-virt-a15-test/lib/cbuf.mod.o
   3975	     13	     28	   4016	    fb0	./build-qemu-virt-a15-test/lib/console.mod.o
    814	     12	      0	    826	    33a	./build-qemu-virt-a15-test/lib/debug.mod.o
   2509	     12	      8	   2529	    9e1	./build-qemu-virt-a15-test/lib/debugcommands.mod.o
      0	      0	      0	      0	      0	./build-qemu-virt-a15-test/lib/fixed_point.mod.o
   5501	     60	      4	   5565	   15bd	./build-qemu-virt-a15-test/lib/fs.mod.o
   2416	      0	      0	   2416	    970	./build-qemu-virt-a15-test/lib/fs/ext2.mod.o
   2902	      0	      0	   2902	    b56	./build-qemu-virt-a15-test/lib/fs/fat32.mod.o
   1414	      0	      0	   1414	    586	./build-qemu-virt-a15-test/lib/fs/memfs.mod.o
   4900	      0	      0	   4900	   1324	./build-qemu-virt-a15-test/lib/fs/spifs.mod.o
   5350	     12	      0	   5362	   14f2	./build-qemu-virt-a15-test/lib/fs/spifs/test.mod.o
   5029	     12	      0	   5041	   13b1	./build-qemu-virt-a15-test/lib/gfx.mod.o
   3570	     32	      5	   3607	    e17	./build-qemu-virt-a15-test/lib/heap.mod.o
    697	     16	    308	   1021	    3fd	./build-qemu-virt-a15-test/lib/io.mod.o
    180	      0	      0	    180	     b4	./build-qemu-virt-a15-test/lib/iovec.mod.o
   9901	     16	     12	   9929	   26c9	./build-qemu-virt-a15-test/lib/libc.mod.o
  16397	    172	    117	  16686	   412e	./build-qemu-virt-a15-test/lib/minip.mod.o
    574	      0	      0	    574	    23e	./build-qemu-virt-a15-test/lib/pool.mod.o
    935	     12	      0	    947	    3b3	./build-qemu-virt-a15-test/lib/tftp.mod.o
    350	     12	      0	    362	    16a	./build-qemu-virt-a15-test/lib/version.mod.o
    262	     12	      0	    274	    112	./build-qemu-virt-a15-test/platform.mod.o
   1230	    104	     48	   1382	    566	./build-qemu-virt-a15-test/platform/qemu-virt.mod.o
     16	      0	      0	     16	     10	./build-qemu-virt-a15-test/target.mod.o
   1576	      0	     32	   1608	    648	./build-qemu-virt-a15-test/top.mod.o
 230689	    937	  55291	 286917	  460c5	(TOTALS)
generating image: build-qemu-virt-a15-test/lk.bin
generating listing: build-qemu-virt-a15-test/lk.elf.lst
generating listing: build-qemu-virt-a15-test/lk.elf.debug.lst
generating symbols: build-qemu-virt-a15-test/lk.elf.sym
   text	   data	    bss	    dec	    hex	filename
 229936	    940	  55340	 286216	  45e08	build-qemu-virt-a15-test/lk.elf
generating sorted symbols: build-qemu-virt-a15-test/lk.elf.sym.sorted
generating size map: build-qemu-virt-a15-test/lk.elf.size
generating objdump: build-qemu-virt-a15-test/lk.elf.dump
generating build-qemu-virt-a15-test/srcfiles.txt
generating build-qemu-virt-a15-test/include_paths.txt
generating stack usage build-qemu-virt-a15-test/lk.elf.stack
make[2]: Leaving directory '/home/antone/git/lk'
make[1]: Leaving directory '/home/antone/git/lk'
qemu-system-arm -machine virt -cpu cortex-a15 -m 512 -smp 1 -kernel build-qemu-virt-a15-test/lk.elf -nographic

welcome to lk/MP

boot args 0x0 0x0 0x0 0x0
INIT: cpu 0, calling hook 0x8002eba1 (version) at level 0x3ffff, flags 0x1
version:
	arch:     ARM
	platform: QEMU_VIRT
	target:   QEMU_VIRT
	project:  QEMU_VIRT_A15_TEST
	buildid:  G8A90_LOCAL
INIT: cpu 0, calling hook 0x8002fed5 (vm_preheap) at level 0x3ffff, flags 0x1
initializing heap
calling constructors
INIT: cpu 0, calling hook 0x8002ff19 (vm) at level 0x50000, flags 0x1
initializing mp
initializing threads
initializing timers
initializing ports
creating bootstrap completion thread
top of bootstrap2()
INIT: cpu 0, calling hook 0x8002ca6d (pktbuf) at level 0x70000, flags 0x1
pktbuf: creating 256 pktbuf entries of size 1536 (total 393216)
INIT: cpu 0, calling hook 0x8002ec95 (virtio) at level 0x70000, flags 0x1
releasing 0 secondary cpus
initializing platform
initializing target
calling apps_init()
starting app inetsrv
starting internet servers
starting app shell
entering main console loop
] arp list


cpu 0 data abort, translation fault on read
DFAR 0x8 (fault address)
DFSR 0x5 (fault status register)
halting
current_thread 0x801df4b8, name shell
r0  0x00000000 r1  0x800453c0 r2  0x00000000 r3  0x00000000
r4  0x00000000 r5  0x801e07e0 r6  0x800594bc r7  0x800593e8
r8  0x801e0760 r9  0x801e0758 r10 0x00000008 r11 0x801e0928
r12 0x7a0b5ed8 usp 0x00000000 ulr 0x00000000 pc  0x8002b7be
spsr 0x40000173
 usr r13 0x00000000 r14 0x00000000
 fiq r13 0x00000000 r14 0x00000000
 irq r13 0x00000000 r14 0x800122d0
asvc r13 0x801e05c8 r14 0x80010a8b
*svc r13 0x801e0698 r14 0x8002c0c7
 und r13 0x00000000 r14 0x00000000
 sys r13 0x00000000 r14 0x00000000
bottom of stack at 0x801e0698:
0x801e0698: 00000000 80048450 00000061 00000008 |....P...a.......|
0x801e06a8: 800594bc 801dc640 00000000 801e07fc |....@...........|
0x801e06b8: 00000001 00000000 801e07e0 800594bc |................|
0x801e06c8: 00000000 8002c0c7 8002c051 00000000 |........Q.......|
0x801e06d8: 800594bc 80033a55 00009801 80039533 |....U:......3...|
0x801e06e8: 99999999 801e07e0 80033c07 00000001 |.........<......|
0x801e06f8: 80033375 00000000 00000000 800594bc |u3..............|
0x801e0708: 00000000 801e0758 00000000 800594bc |....X...........|
CRASH: starting debug shell... (reason = 9)
entering panic shell loop
! QEMU: Terminated

display_present implementations needed

Since this is called now by sod.

dev/virtio/gpu/virtio-gpu.c
platform/armemu/display.c
target/qemu-m4/m4display.c
target/stm32746g-eval2/lcd.c
target/stm32f746g-disco/lcd.c

False negative in thread join test?

At [1], the join_tester_server test 3 is checking if the thread struct's magic is zero but the thread structure is freed by then at thread_exit [2] and thread->magic now holds the value of &delayed_free_list from heap_delayed_free.
In other test cases(1,2 and 4) also thread->magic is checked after it is freed but the test didn't fail since HEAP_FREE doesn't seem to change its contents.

[1] https://github.com/littlekernel/lk/blob/master/app/tests/thread_tests.c#L548 - join_tester_server test 3
[2] https://github.com/littlekernel/lk/blob/master/kernel/thread.c#L431

compile error

external/lib/heap/dlmalloc/dlmalloc.c: In function ‘mmap_resize’:
external/lib/heap/dlmalloc/dlmalloc.c:1752:44: error: implicit declaration of function ‘mremap’ [-Werror=implicit-function-declaration]
#define MREMAP_DEFAULT(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv))

ARCH_arm_TOOLCHAIN_PREFIX=arm-linux-gnueabihf- ./scripts/do-qemuarm

time comparison flawed

The conversion of unsigned to signed type for TIME_LT() and friends in sys/types.h depends on C compiler implementation-defined behavior.

[x86_64][MMU] should not check canonical form addresses for physical address

According to this site below, canonical address is meaningful only for VIRTUAL address.
https://en.wikipedia.org/wiki/X86-64#Canonical_form_addresses

However, in this function: lk/arch/x86-64/mmu.c:x86_mmu_add_mapping(), as below.

if((!x86_mmu_check_map_addr(vaddr)) || (!x86_mmu_check_map_addr(paddr)) )
return ERR_INVALID_ARGS;

It is not only checking virtual address but also checking physical address.

Besides, there are many other places to check both virtual and physical by calling x86_mmu_check_map_addr().

In my opinion, for virtual address , it is ok to check canonical form, but for physical address , just check it should be less than max supported address reported by CPUID capability.

a problem(?) in scheduler

in function get_top_thread (kernel/thread.c)

uint next_queue = HIGHEST_PRIORITY - __builtin_clz(local_run_queue_bitmap) - (sizeof(run_queue_bitmap) * 8 - NUM_PRIORITIES);

if NUM_PRIORITIES is less than 32, the result will be wrong?

Regards,
Allen Y.

Bus faults on threading tests on STM32F4-discovery

Discovery board is bus faulting on almost all the threading tests, which is only interesting since it's a stm32f407, which seems to already have some support.

This is half FYI, let me know if I should just move this issue to my fork.

E.g.

] thread_tests
preinitialized mutex:
0x20000048: 6d757478 00000000 00000000 77616974 |xtum........tiaw|
0x20000058: 20000058 20000058 00000000 00000001 |X...X...........|
mutex tester thread 0x20000888 starting up, will go for busfault: exception frame at 0x20000be8
        r0  0x000000c3 r1  0x0000c350 r2  0x0000000a r3 0x00000000 r4 0x0000c350
        r5  0x00000000 r6  0x00c35000 r7  0x08004727 r8 0x20000c77 r9 0x00000000
        r10 0x20000c78 r11 0x0000001e r12 0x0000001f
        lr  0x08004f47 pc  0x080065cc psr 0x01000000
HALT: spinning forever...

E.g. 2

] threads
thread list:
dump_thread: t 0x2000156c (shell)
        state run, priority hardfault: exception frame at 0x20001868
        r0  0x00000073 r1  0x08000235 r2  0x00000010 r3 0x20000110 r4 0x4807129f
        r5  0xe1e00e60 r6  0x00001000 r7  0x00000000 r8 0x200018f7 r9 0x00000000
        r10 0x200018f8 r11 0x0000001e r12 0x0000001f
        lr  0x08004f17 pc  0x080065dc psr 0x01000000
HFSR 0x40000000
HALT: spinning forever...

Is it possible to run lk on STM32F401CCU6 ?

Hi,

Sorry if this question has been already been addressed before. I would like to tinker with lk and I'm wondering if I can run it on a board with STM32F401CCU6 (256K Flash/64K RAM).

Thanks,

Zinahe A.

thread_join on a thread from multiple threads

Is the behaviour undefined for when a thread is joined by multiple concurrent threads ?

From the man-page of pthread, I realize they do it that way.

And from kernel/thread.c it seems, we do the same. In fact we will invariably crash, since we call wait_queue_wake_all from thread_detach / thread_exit. Hence multiple threads will be trying to free the resources of the thread.

Is that a valid observation ?

Custom bootloader for Nexus 5(hammerhead)

Hello,

I want to flash the bootloader of a nexus 5(rooted) to a custom bootloader. The custom bootloader is needed to perform some custom booting cryptographic verification like secure boot/authenticated boot So I have a couple of questions.

  1. fastboot flash bootloader <bootloader.img> this command will flash the bootloader or something else?
  2. Can I build the little kernel, create an img file and flash the stock bootloader with the custome bootloader?
  3. Suggestions on any other board other than nexus 5 hammerhead board where performing this process is safer (for example hikey960 board) is very much welcome.

Thanks,
Dim

arch_chain_load keeps MMU enabled

I have the problem that binaries loaded by arch_chain_load crash as soon as they try to enable the MMU because LK keeps it enabled.

I added a "arm_write_sctlr(arm_read_sctlr() & ~(1<<0));" immediately before loader() but that just makes the system hang.

In case that helps you - if I load LK with LK I get a translation fault at this line: https://github.com/travisg/lk/blob/master/arch/arm/arm/start.S#L204

chainload from 0x80200000 size 124928
arch_chain_load:131: entry 0x80200800, args 0x0 0x0 0x0 0x0
arch_chain_load:154: entry pa 0x80200800
arch_chain_load:168: loader address 0xc0000b44, phys 0x88f00b44, surrounding large page 0x88f00000
arch_chain_load:173: disabling instruction/data cache
arch_chain_load:176: branching to physical address of loader


prefetch abort, translation fault
IFAR 0x88f0012c (fault address)
IFSR 0x5 (fault status register)
halting
r0  0x00000000 r1  0x00000000 r2  0x00000000 r3  0x00000000
r4  0x88f20048 r5  0x88f1d590 r6  0x00000000 r7  0x00000000
r8  0x00000000 r9  0x00000000 r10 0x00000000 r11 0xa8e00406
r12 0x00c54879 usp 0xc0025010 ulr 0x00000000 pc  0x88f0012c
spsr 0x60000193
 fiq r13 0x00000000 r14 0x00000000
 irq r13 0xc0025010 r14 0xc000ee2e
*svc r13 0x80007168 r14 0x88f00098
 und r13 0xc0025010 r14 0x00000000
 sys r13 0xc0025010 r14 0x00000000
bottom of stack at 0x80007168:
0x80007168:

data abort, translation fault on read
DFAR 0x80007168 (fault address)
DFSR 0x5 (fault status register)
halting
r0  0x0000000c r1  0x00000020 r2  0xa0000000 r3  0x80007164
r4  0x00000000 r5  0x00000004 r6  0x00000010 r7  0xc0024f20
r8  0x00000000 r9  0x80007168 r10 0x80007164 r11 0x4001ddb8
r12 0x00000000 usp 0xc0025010 ulr 0x00000000 pc  0xc0010d60
spsr 0x400001b7
 fiq r13 0x00000000 r14 0x00000000
 irq r13 0xc0025010 r14 0xc000ee2e
 svc r13 0x80007168 r14 0x88f00098
 und r13 0xc0025010 r14 0x00000000
 sys r13 0xc0025010 r14 0x00000000
HALT: shutdown device.

test run for "make lm3s6965evb-test"

Hi, I was trying to give it a test run for cortex-m3, however got error trace as following, any idea of why this happens please?

vagrant@vagrant-ubuntu-trusty-32:~/lk/build-lm3s6965evb-test$ qemu-system-arm -machine versatileab -cpu cortex-m3 ./lk.elf
pulseaudio: pa_context_connect() failed
pulseaudio: Reason: Connection refused
pulseaudio: Failed to initialize PA contextaudio: Could not init `pa' audio driver
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
audio: Failed to create voice `lm4549.out'
Could not initialize SDL(No available video device) - exiting

LK build

can someone explain how to build this for msm8612?

x86-64 fpu context save seems broken

The x86-64 fpu context saving seems broken. float_tests, which runs a bunch of separate threads doing calculations that should result in similar answers gets different results every time:

] float_tests
floating point test:
creating 8 floating point threads
float thread 0 returns 1, val 821434452.497358
float thread 1 returns 1, val 81419905.943663
float thread 2 returns 1, val 29789586.236013
float thread 3 returns 1, val 30216835.564976
float thread 4 returns 1, val 227027182.938372
float thread 5 returns 1, val 886723275.849505
float thread 6 returns 1, val 303244330.207326
float thread 7 returns 1, val 222952286.814904
] float_tests
floating point test:
creating 8 floating point threads
float thread 0 returns 1, val 240072320.917543
float thread 1 returns 1, val 1092221311.715492
float thread 2 returns 1, val 660033076.162435
float thread 3 returns 1, val 1102409849.573568
float thread 4 returns 1, val 1008718492.368174
float thread 5 returns 1, val 299878691.231605
float thread 6 returns 1, val 15341624.298121
float thread 7 returns 1, val 601862821.592540

on x86-32 and arm the results are very close and consistent:
] float_tests
floating point test:
creating 8 floating point threads
float thread 0 returns 1, val 2811768340480.000000
float thread 1 returns 1, val 2811768340480.000000
float thread 2 returns 1, val 2811768602624.000000
float thread 3 returns 1, val 2811768602624.000000
float thread 4 returns 1, val 2811768602624.000000
float thread 5 returns 1, val 2811768602624.000000
float thread 6 returns 1, val 2811768602624.000000
float thread 7 returns 1, val 2811768602624.000000

This seems to have nothing to do with the recent x86-64 integer context switch changes, it was broken before those changes went through.

Snapdragon 820 MSM8996

Can I flash lk bootloader for Snapdragon 820 MSM8996 on ZTE Axon 7? This Smartphone using verificate bootloader(Проверяет загрузчик по x509 ключу)

lib/bio needs C guards (__BEGIN_CDECL)

From a cpp file:
#include <lib/bio.h>

Generates errors of the form:
foo_runner.cpp:33: undefined reference to bio_open(char const*)' foo_runner.cpp:39: undefined reference tobio_ioctl(bdev_, int, void_)'

which go away if you do

extern "C" {

include <lib/bio.h>

}

[Q] Display driver

I'm new here. How can i change display driver to get display works? Thanks

snprintf behaviour different from the standard

Precision modifier when used with %s, should not pad the result with spaces. However, it does in the little kernel library.

char *temp  = “hello”;
char result[20];
snprintf (result, sizeof(result), “%.10s”, temp); // Notice the dot after the % sign
printf(“%s\n”, result);
Expected output

hello

Observed output

     hello

In essense, snprintf is padding spaces when it should not be with a precision modifier used with strings.
At least, it doesn’t on my Ubuntu 12.04 x86_64 system, and also shouldn’t according to the man page.

lk can't run on AMD Dell Ryzen7

hi
I managed flashing LK kernel and creating a bootable USB device driver, it can boot on any Intel computer, but failed on AMD Dell Ryzen7.

Here is experiment procedures:
1. run ./script/do-qemux86 -6
this will generate lk.elf
2. create an ISO image
a) create a directory tree looks like bellow. note '^' stands for space key
isofile
|---boot
|^^^|---grub
|^^^|^^^|---
b) copy your lk.elf(find it in your lk build directory) into isofile/boot directory, and create a grub.cfg file under grub diretory.
c) fill grub.cfg with the following lines
set timeout=0
set default=0
menuentry "little kernel" {
multiboot /boot/lk.elf
boot
}
d) then your isofile directory tree looks like:
isofile
|---boot
|^^^|---grub
|^^^|^^^|---grub.cfg
|^^^|---lk.elf
run grub-mkrescue -o lk.iso isofile, then lk.iso will be created.
3. create a bootable USB device driver
run sudo dd if=isofile.iso of=/dev/sdb. Assume your USB device appears as "/dev/sdb" under "/dev" directory.
4. boot computer
Inert the bootable USB device into computer's USB slot, and boot the computer in legacy mode(configured in BIOS) from USB device.

On any recently Intel processor Computer, it works fine, but failed to boot up on AMD processor Computer.

I added the following debug info in "arch/x86/64/start.S" to print "OK" and then halt the processor
movl $0x2f4b2f4f, 0xb8000
hlt

It should print "OK" on screen if I insert the snippet at the point before enabling Paging, but won't print after paging is enabled.

It's reasonable that after paging is enabled, CPU should fed with virtual address, so I add kernel offset 0XFFFFFFFF80000000 to 0xb8000 in order to print message on screen.
mov $0XFFFFFFFF8000b8000, %rax
movl $0x2f4b2f4f, (%rax)
hlt

It looks perfect and should work now, however it still can't print the massage.

So am not sure what's going on with LK or AMD processor, I have no idea about that!!!

arm_gic: GICv3 support?

Hello, I have a question about ARM GIC:

Do lk need GICv3 support in dev/interrupt/arm_gic ?

Or we have to init GICv3 in ATF before load lk loaded as S-EL1 OS and not to init GICv3 in lk?

Is there official released version of LK?

Hello everyone,

Now I am learning little Kernel and I want to get the official released version of LK.

On BlackDuck Code Center, I have checked that LK has a relesed version on October 21, 2014, and the home page is here. But it seems that here on 'master' branch, the 'releases' is '0'. Thus I want to know whether the 'master' branch is the official released branch, or is there any released version of LK?

Thank you in advance.

[cdcserial] Needs non-blocking API.

I'd like to be able to implement console over cdcserial. Since printf is safe to call from interrupt context, there needs to be a way to queue transactions asynchronously.

QEMU timer not firing

For build-qemu-virt-a15 which is executed in qemu-system-arm -machine virt -cpu cortex-a15 might not fire in some versions. For example for QEMU 2.4.50 the following patch fixes it:

index d7cb9f4..52d0b9d 100644
--- a/platform/qemu-virt/include/platform/qemu-virt.h
+++ b/platform/qemu-virt/include/platform/qemu-virt.h
@@ -88,12 +88,8 @@ static const int a15irqmap[] = {

/* interrupts /
#define ARM_GENERIC_TIMER_VIRTUAL_INT 27
-#if ARCH_ARM
-/
for cortex-a15, the irq seems to be coming in via the secure vector /
-#define ARM_GENERIC_TIMER_PHYSICAL_INT 29
-#else
+/
Note that in some QEMUS the physical timer is wired to INT 29 */
#define ARM_GENERIC_TIMER_PHYSICAL_INT 30
-#endif
#define UART0_INT (32 + 1)
#define VIRTIO0_INT (32 + 16)

The current QEMU behavior, which is the timer mapped to 30 seems to start end of may, or possibly related to the default mode of virt which used to be trustzone, which is recent:

qemu/qemu@2d71000

dlmalloc.c:1752:44: error: implicit declaration of function ‘mremap’

ubutu64@ubutu64:~/lk$ make pc-x86-64-test
make[1]: Entering directory '/home/ubutu64/lk'
make[2]: Entering directory '/home/ubutu64/lk'
PROJECT = pc-x86-64-test
PLATFORM = pc
TARGET = pc-x86
arch/x86/rules.mk:73: ARCH_x86_TOOLCHAIN_PREFIX =
arch/x86/rules.mk:74: ARCH_x86_64_TOOLCHAIN_PREFIX =
arch/x86/rules.mk:75: TOOLCHAIN_PREFIX =
including app app/shell app/stringtests app/tests dev kernel lib/aes lib/aes/test lib/cbuf lib/cksum lib/debugcommands lib/libm lib/version platform target
including kernel/vm lib/console lib/debug lib/heap lib/libc
including lib/heap/dlmalloc lib/io
LIBGCC = /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a
GLOBAL_COMPILEFLAGS = -g -finline -include ./build-pc-x86-64-test/config.h -W -Wall -Wno-multichar -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Werror=return-type -fasynchronous-unwind-tables -gdwarf-2 -fno-pic -fno-stack-protector -mcmodel=kernel -mno-red-zone
GLOBAL_OPTFLAGS = -O2
generating build-pc-x86-64-test/target/pc-x86/module_config.h
generating build-pc-x86-64-test/config.h
generating build-pc-x86-64-test/platform/pc/module_config.h
generating build-pc-x86-64-test/arch/x86/module_config.h
generating build-pc-x86-64-test/top/module_config.h
generating build-pc-x86-64-test/app/module_config.h
generating build-pc-x86-64-test/app/shell/module_config.h
generating build-pc-x86-64-test/app/stringtests/module_config.h
generating build-pc-x86-64-test/app/tests/module_config.h
generating build-pc-x86-64-test/dev/module_config.h
generating build-pc-x86-64-test/kernel/module_config.h
generating build-pc-x86-64-test/external/lib/aes/module_config.h
generating build-pc-x86-64-test/external/lib/aes/test/module_config.h
generating build-pc-x86-64-test/lib/cbuf/module_config.h
generating build-pc-x86-64-test/external/lib/cksum/module_config.h
generating build-pc-x86-64-test/lib/debugcommands/module_config.h
generating build-pc-x86-64-test/external/lib/libm/module_config.h
generating build-pc-x86-64-test/srcfiles.txt
generating build-pc-x86-64-test/include_paths.txt
generating build-pc-x86-64-test/buildid.h
build-pc-x86-64-test/buildid.h.tmp build-pc-x86-64-test/buildid.h 不同:第 108 字节,第 3 行
generating build-pc-x86-64-test/lib/version/module_config.h
compiling lib/version/version.c
linking build-pc-x86-64-test/lib/version.mod.o
generating build-pc-x86-64-test/platform/module_config.h
generating build-pc-x86-64-test/target/module_config.h
generating build-pc-x86-64-test/kernel/vm/module_config.h
generating build-pc-x86-64-test/lib/console/module_config.h
generating build-pc-x86-64-test/lib/debug/module_config.h
generating build-pc-x86-64-test/lib/heap/module_config.h
generating build-pc-x86-64-test/lib/libc/module_config.h
generating build-pc-x86-64-test/external/lib/heap/dlmalloc/module_config.h
compiling external/lib/heap/dlmalloc/dlmalloc.c
external/lib/heap/dlmalloc/dlmalloc.c: In function ‘mmap_resize’:
external/lib/heap/dlmalloc/dlmalloc.c:1752:44: error: implicit declaration of function ‘mremap’ [-Werror=implicit-function-declaration]
#define MREMAP_DEFAULT(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv))
^
external/lib/heap/dlmalloc/dlmalloc.c:1808:49: note: in expansion of macro ‘MREMAP_DEFAULT’
#define CALL_MREMAP(addr, osz, nsz, mv) MREMAP_DEFAULT((addr), (osz), (
^
external/lib/heap/dlmalloc/dlmalloc.c:3924:23: note: in expansion of macro ‘CALL_MREMAP’
char* cp = (char_)CALL_MREMAP((char_)oldp - offset,
^
external/lib/heap/dlmalloc/dlmalloc.c:3924:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
char* cp = (char_)CALL_MREMAP((char_)oldp - offset,
^
external/lib/heap/dlmalloc/dlmalloc.c: In function ‘sys_trim’:
external/lib/heap/dlmalloc/dlmalloc.c:4369:62: warning: comparison between pointer and integer
if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) ||
^
cc1: some warnings being treated as errors
make/compile.mk:41: recipe for target 'build-pc-x86-64-test/external/lib/heap/dlmalloc/dlmalloc.o' failed
make[2]: *** [build-pc-x86-64-test/external/lib/heap/dlmalloc/dlmalloc.o] Error 1
make[2]: Leaving directory '/home/ubutu64/lk'
engine.mk:28: recipe for target 'make-make' failed
make[1]: *** [make-make] Error 2
make[1]: Leaving directory '/home/ubutu64/lk'
makefile:34: recipe for target 'pc-x86-64-test' failed
make: *** [pc-x86-64-test] Error 2

error!

command:
./scripts/do-qemuarm -M

result:

arm-linux-androideabi-ld: error: top/init.ld:8:8: syntax error, unexpected STRING
arm-linux-androideabi-ld: fatal error: unable to parse script file top/init.ld
make[2]: *** [build-qemu-virt-a15-test/lk.elf] Error 1
make[2]: Leaving directory /home/poi/lk/lk' make[1]: *** [make-make] Error 2 make[1]: Leaving directory /home/poi/lk/lk'
make: *** [_top] Error 2

what the problem?

top/init.ld:8:8

SECTIONS {
.lk_init : {
__lk_init = .;
KEEP (*(.lk_init))
__lk_init_end = .;
}
}
INSERT AFTER .rodata;

AFTE?!?! i don't understand plz help me

new ioctl like BIO_IOCTL_GET_MEM_MAP with no side effects

Issuing ioctl with BIO_IOCTL_GET_MEM_MAP for qspi causes it to enter into linear mode, it would be nice to have an ioctl which gives me the address it would be mapped to but without causing it to enter linear mode, so I can get the address it would map.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.