-
Notifications
You must be signed in to change notification settings - Fork 140
lkl: Implement lkl_printf and lkl_bug internally #588
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
Conversation
Currently, lkl.o needs the lkl_printf and lkl_bug symbols to work but does not implement the corresponding functions. These helper functions are implemented as part of liblkl in tools/lkl/lib/util.c. This works, but it requires users of lkl.o to implement lkl_printf manually. However, this does not make much sense, because lkl_printf, by definition, is just a wrapper to host_ops->print. In fact, lkl_printf can be implemented correctly using the utilities from linux/stdarg.h and linux/sprintf.h, as well as the host operations host_ops->mem_alloc and host_ops->print. See changes in this commit for more details. Implementing it internally in arch/lkl makes lkl.o more self-contained and easier to use in environments without libc support (since in such environments tool/lkl/lib/util.c may fail to compile due to missing headers like stdio.h and stdarg.h). Signed-off-by: Ruihan Li <[email protected]>
thanks for the patch. I was wondering if kernel code (i.e., code under arch/lkl) can use |
Thanks for your review. I guess sometimes we need to use
Or we may be in some state that appears to be corrupted and we don't know if we're in the Linux context: Lines 117 to 119 in b5fa7a2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I'm a little confused by the zpoline test failure, which should(?) have been fixed via b788994
This commit does not appear to fix the bug, as the issue is still open: #577 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the patch @lrh2000 !
And you are correct, the purpose of these functions is for cases where we can't use panic or printk because we don't run in Linux context.
Just curios, if you can, could you share more details about the environment? Does it make sense to add support for it in |
Thanks for your interest. For the first question, we are trying to play lkl.o with another kernel we're developing (if you're interested, see asterinas/asterinas). However, the integration with lkl.o is still at a very early stage, and the way LKL interacts with our kernel is still being studied. I have found unexpected undefined symbols in the process, so I am submitting patches to fix the undefined symbols, which will definitely make the integration easier. Since the way LKL interacts with our kernel is still being determined, I'm afraid I don't have an answer to your second question at this time. |
thanks for the info; I wasn't aware of that intention, which is helpful for me. and thanks for the background information for those PRs. I looked through the asterinas project and also skimmed the paper (apsys) of framekernel. Yes, offering Linux ABI via LKL would be the best if various requirements of yours satisfy. I have personally ported host_ops for rump hypercall (https://github.com/ukontainer/lkl-linux/blob/rump-hypcall-next/tools/lkl/lib/rump-host.c), which doesn't have libc-like utilities either, as your environment. @tavip and his team had also a port for Windows kernel host_ops, which has similar situation as nolibc environment (I guess). Having less dependency to lkl.o, as you did, is definitely helpful. If you wish to have more interaction to LKL kernel from your environment, creating a host_ops for your case would be also helpful to cleanly integrate with. |
@thehajime Thank you for your kind reply and the references you provided.
Yes, that's exactly what I'm trying to do. It seems very promising indeed. |
(Follow up #587 to remove undefined symbols in lkl.o)
Currently, lkl.o needs the lkl_printf and lkl_bug symbols to work but does not implement the corresponding functions. These helper functions are implemented as part of liblkl in tools/lkl/lib/util.c.
This works, but it requires users of lkl.o to implement lkl_printf manually. However, this does not make much sense, because lkl_printf, by definition, is just a wrapper to host_ops->print.
In fact, lkl_printf can be implemented correctly using the utilities from linux/stdarg.h and linux/sprintf.h, as well as the host operations host_ops->mem_alloc and host_ops->print. See changes in this commit for more details.
Implementing it internally in arch/lkl makes lkl.o more self-contained and easier to use in environments without libc support (since in such environments tool/lkl/lib/util.c may fail to compile due to missing headers like stdio.h and stdarg.h).