Nmi branch test#1
Open
dg1197 wants to merge 155 commits intorex-rs:rex-linuxfrom
Open
Conversation
When we compile the rust programs with PIE, the compiler creates the Global Offset Table (GOT) to put the address of the extern variables. The GOT is supposed to be fixed at program load time by the dynamic loader. However, we do not have a dynamic loader and therefore, the GOT entries are un-patched and contain absolute addresses. This causes problem when the program is triggered in the kernel -- the use of absolute address will cause the code going to non-existing pages. Add a new GOT fix step when the base program is loaded. Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Add a new trace_printk function only used by inner-unikernel programs. This function always pads a null character at the end. Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Add a new iu_dispatcher_func to dispatch inner-unikernel programs so
that rust panics can be handled. The dispatch have a prototype of:
extern asmlinkage unsigned int iu_dispatcher_func(
const void *ctx,
const struct bpf_insn *insnsi,
unsigned int (*bpf_func)(const void *,
const struct bpf_insn *));
which shares the same signature as bpf_dispatcher_nop_func but differs
in linkage, as it is implemented directly in assembly.
The function will save the stack pointer and frame pointer to designated
per-cpu variables before calling into the program.
If the execution is successful (i.e. no exceptions), the function will
just return normally.
+-----------------------+
| iu_dispatcher_func: |
| movq %rsp %gs:iu_sp |
| movq %rbp %gs:iu_fp | +-----------+
| call *%rdx |--------------->| iu_prog1: |
| | | ... |
| iu_exit: |<---------------| ret |
| ret | +-----------+
| ... |
+-----------------------+
Under exceptional cases (where a rust panic is fired), rust_begin_unwind
(i.e. panic handler) will transfer the control flow to the iu_landingpad
function, which, after dumping some information to the kernel ring
buffer, will issue a direct jump to iu_panic_trampoline, a global label
in the middle of iu_dispatcher_func. The trampoline code restores the
old stack pointer and frame pointer value, effectively unwinding the
stack. It then sets a return value of -EINVAL and jumps to iu_exit to
return from iu_dispatcher_func.
+-----------------------+
| iu_dispatcher_func: |
| movq %rsp, %gs:iu_sp |
| movq %rbp, %gs:iu_fp | +-----------+
| call *%rdx |--------------->| iu_prog1: |
| | +------| ... |
+---->| iu_exit: | | | ret |
| | ret | | +-----------+
| | | |
| | iu_panic_trampoline: |<-----+ | panic!()
| | movq %gs:iu_sp, %rsp | | |
| | movq %gs:iu_fp, %rbp | | | +-------------------------+
| | movq $(-EINVAL), %rax | | +----->| iu_landingpad: |
+-----| jmp iu_exit | | | ... |
+-----------------------+ +---------| jmp iu_panic_trampoline |
+-------------------------+
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
This right now only works for program invocations where bpf_dispatcher_nop_func is used originally. It does cover all tracing programs (i.e. these invoked via trace_call_bpf). Other program types (e.g. XDP) are not supported. Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
The C function currently is "naked" anyway, it makes more sense to move it to the asm source file. Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
According to kernel documentation, WARN() should only be used for "significant kernel issues that need prompt attention if they should ever appear at runtime." Use a rate-limited pr_err() instead. Note that we do not directly use pr_err_ratelimited(), but the plain __rate_limited() to also rate-limit the stack dump. Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
- Remove debug prints - Remove commented out code Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Apparently lld does things differently from bfd and mold -- it puts a 0 at the relative relocation address instead of the addend. Let's just directly compute the final value with *ABS*+addend to make it more robust. Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Ruowen Qin <ruowenq2@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Ruowen Qin <ruowenq2@illinois.edu>
The previous __vmalloc() invocation already has __GFP_ZERO flag set so there is no need to zero the memory again. Plus, the address calculation is incorrect, which causes accidental zeroing of real data. Fixes: 23903f1 ("Rewritten to resolve conflicts") Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
We previously counted the total memory and page counts needed for the program incrementally. This causes problems when the linker (e.g. mold) generates a gap page between LOAD segments, as that gap page will not be counted. Instead, directly calculate the total memory and page counts by aligning the largest memeory address found in the LOAD segments to page boundary. Fixes: 88b2c24 ("Fixed memory conflict for distributed apps") Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
This fixes the following warning from modpost: WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kprobes/kprobe_target.o Fixes: c16cb95 ("samples/kprobe: add kprobe target module") Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: dmo <dganesh3@illiois.edu>
Signed-off-by: dmo <dganesh3@illiois.edu>
Signed-off-by: dmo <dganesh3@illiois.edu>
Signed-off-by: dmo <dganesh3@illiois.edu>
Signed-off-by: Dhanush Ganesh <dganesh3@illinois.edu>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.