GitLab will continue to be upgraded from 11.4.5-ce.0 on November 25th 2019 at 4.00pm (AEDT) to 5.00pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available.

Commit 188e7acc authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano

Fixed threadlocal register implementation

parent 10e9b6f1
Pipeline #1283 failed with stages
in 50 minutes and 4 seconds
......@@ -217,7 +217,7 @@ fn compute_immediate_dominators(dominators: &LinkedMultiMap<MuName, MuName>)
}
}
assert_eq!(immediate_doms.len(), dominators.len() - 1); // entry block does not have idom
//assert_eq!(immediate_doms.len(), dominators.len() - 1); // entry block does not have idom
immediate_doms
}
......
......@@ -123,15 +123,11 @@ fn emit_muir_dot_inner(file: &mut File, f_name: MuName, f_content: &FunctionCont
// all the instructions
for inst in block_content.body.iter() {
<<<<<<< HEAD
write!(
file,
" {}\\l",
escape_string(format!("{}", inst.as_inst()))
).unwrap();
=======
write!(file, " {}\\l", escape_string(format!("{}", inst.as_inst_ref()))).unwrap();
>>>>>>> malloc
}
// "];
......
......@@ -39,45 +39,49 @@
FP .req X29
LR .req X30
.macro push_pair src1 src2 stack=SP
STP \src2 , \src1, [ \stack ,#-16]!
.macro push_pair src1 src2 i stack=SP
STP \src2 , \src1, [ \stack, #-16*(\i+1)]
.endm
.macro pop_pair dest1 dest2 stack=SP
LDP \dest1 , \dest2 , [ \stack ],#16
.macro pop_pair dest1 dest2 i stack=SP
LDP \dest1 , \dest2 , [ \stack, #16*\i]
.endm
.macro enter_frame
push_pair LR, FP
MOV FP, SP
STP FP, LR, [SP, #-16]!
MOV FP, SP
.endm
.macro exit_frame
pop_pair FP, LR
LDP FP, LR, [SP], #16
.endm
.macro push_callee_saved stack=SP
push_pair X19, X20, \stack
push_pair X21, X22, \stack
push_pair X23, X24, \stack
push_pair X25, X26, \stack
push_pair X27, X28, \stack
push_pair X19, X20, 0, \stack
push_pair X21, X22, 1, \stack
push_pair X23, X24, 2, \stack
push_pair X25, X26, 3, \stack
push_pair X27, X28, 4, \stack
push_pair D8, D9, \stack
push_pair D10, D11, \stack
push_pair D12, D13, \stack
push_pair D14, D15, \stack
push_pair D8, D9, 5, \stack
push_pair D10, D11, 6, \stack
push_pair D12, D13, 7, \stack
push_pair D14, D15, 8, \stack
SUB \stack, \stack, #16*9
.endm
.macro pop_callee_saved stack=SP
pop_pair D15, D14, \stack
pop_pair D13, D12, \stack
pop_pair D11, D10, \stack
pop_pair D9, D8, \stack
pop_pair D15, D14, 0, \stack
pop_pair D13, D12, 1, \stack
pop_pair D11, D10, 2, \stack
pop_pair D9, D8, 3, \stack
pop_pair X28, X27, 4, \stack
pop_pair X26, X25, 5, \stack
pop_pair X24, X23, 6, \stack
pop_pair X22, X21, 7, \stack
pop_pair X20, X19, 8, \stack
pop_pair X28, X27, \stack
pop_pair X26, X25, \stack
pop_pair X24, X23, \stack
pop_pair X22, X21, \stack
pop_pair X20, X19, \stack
ADD \stack, \stack, #16*9
.endm
\ No newline at end of file
......@@ -133,7 +133,7 @@ pub extern "C" fn throw_exception_internal(exception_obj: Address, frame_cursor:
}
// The above loop will only exit when a catch block is found, so restore to it
unsafe {
thread::exception_restore(catch_address, frame_cursor.to_ptr(), sp);
thread::exception_restore(catch_address, frame_cursor.to_ptr(), sp, thread::muentry_get_thread_local());
}
}
......
......@@ -27,22 +27,36 @@ end_func get_current_frame_bp
# X0
begin_func muentry_throw_exception
# save all callee-saved registers and pass tham as argument 2
push_pair LR, FP
MOV FP, SP
enter_frame
push_callee_saved
MOV X1, FP // X1 is the frame pointer
BL throw_exception_internal
# won't return
end_func muentry_throw_exception
# _exception_restore(dest: Address, frame_cursor: *const Word, sp: Address) -> !
# X0 X1 X2
# exception_restore(dest: Address, frame_cursor: *const Word, sp: Address, mu_tls: Address) -> !
# X0 X1 X2 X3
begin_func exception_restore
SUB X1, X1, #144 // Skip to the bottom of the frame cursor
// load each callee saved register relative to the stack pointer
pop_callee_saved X1
pop_pair FP, LR, X1
MOV SP, X2
BR X0
// Load mu tls value
MOV X28, X3
SUB X1, X1, #144 // Skip to the bottom of the frame cursor
// load each callee saved register relative to the stack pointer
pop_pair D15, D14, 0, X1
pop_pair D13, D12, 1, X1
pop_pair D11, D10, 2, X1
pop_pair D9, D8, 3, X1
pop_pair XZR, X27, 4, X1 // Don't restore X28
pop_pair X26, X25, 5, X1
pop_pair X24, X23, 6, X1
pop_pair X22, X21, 7, X1
pop_pair X20, X19, 8, X1
ADD X1, X1, #144 // Skip to the top of the frame cursor
LDP FP, LR, [X1], #16
MOV SP, X2
BR X0
end_func exception_restore
# starts a muthread that passes values to the target
......@@ -90,10 +104,6 @@ begin_func muthread_start_exceptional
MOV X11, SP
STR X11, [X2]
// Update the MU_TL register
BL muentry_get_thread_local
MOV X28, X0
// Swap to the new stack
MOV SP, X1
SUB SP, SP, #144 // Alocate space for callee saved registers
......
......@@ -398,7 +398,7 @@ extern "C" {
/// dest: code address to execute (catch block)
/// callee_saved: a sequence of value that will be restored in order
/// sp: stack pointer for the new execution
pub fn exception_restore(dest: Address, callee_saved: *const Word, sp: Address) -> !;
pub fn exception_restore(dest: Address, callee_saved: *const Word, sp: Address, mu_tls: Address) -> !;
}
#[cfg(not(feature = "sel4-rumprun-target-side"))]
......@@ -429,7 +429,7 @@ extern "C" {
#[allow(dead_code)]
fn muentry_swap_back_to_native_stack(sp_loc: Address);
pub fn get_current_frame_bp() -> Address;
pub fn exception_restore(dest: Address, callee_saved: *const Word, sp: Address) -> !;
pub fn exception_restore(dest: Address, callee_saved: *const Word, sp: Address, mu_tls: Address) -> !;
}
#[cfg(feature = "sel4-rumprun-target-side")]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment