Skip to content
This repository was archived by the owner on Oct 26, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 52 additions & 134 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ backend-sgx = ["sgx"]
[dependencies]
sallyport = { git = "https://github.com/enarx/sallyport", rev = "efccf0f" }
sev = { version = "0.1", features = ["openssl"], optional = true }
sgx = { git = "https://github.com/enarx/sgx", rev = "e805b51", features = ["asm", "crypto"], optional = true }
sgx = { git = "https://github.com/enarx/sgx", rev = "4bb50e55bc8717c5bc2a98d680bf1be436cda8de", features = ["asm", "crypto"], optional = true }
koine = { git = "https://github.com/enarx/koine", optional = true }
x86_64 = { version = "0.11", default-features = false, features = ["stable"], optional = true }
kvm-bindings = { version = "0.4", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion helper/parse-trace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ while read line; do
fi

if [[ $ADDR2LINE = "REGS" ]]; then
if [[ $line = *"rflags:"* ]] || [[ $line = *"rsp:"* ]] || [[ $line = *"rbp:"* ]]; then
if [[ $line = *"rflags:"* ]] || [[ $line = *"rsp:"* ]] || [[ $line = *"rbp:"* ]] || [[ $line = *"rbx:"* ]]; then
continue
fi
fi
Expand Down
16 changes: 8 additions & 8 deletions internal/shim-sev/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 12 additions & 13 deletions internal/shim-sev/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,18 @@ pub unsafe fn _enarx_asm_triple_fault() -> ! {
// Provoke an #UD, which will lead to a triple fault, because of the invalid IDT
asm!("ud2",
in("rax") frames[2], // the first two frames are from panic
in("rbx") frames[3],
in("rcx") frames[4],
in("rdx") frames[5],
in("rsi") frames[6],
in("rdi") frames[7],
in("r8") frames[8],
in("r9") frames[9],
in("r10") frames[10],
in("r11") frames[11],
in("r12") frames[12],
in("r13") frames[13],
in("r14") frames[14],
in("r15") frames[15],
in("rcx") frames[3],
in("rdx") frames[4],
in("rsi") frames[5],
in("rdi") frames[6],
in("r8") frames[7],
in("r9") frames[8],
in("r10") frames[9],
in("r11") frames[10],
in("r12") frames[11],
in("r13") frames[12],
in("r14") frames[13],
in("r15") frames[14],
options(nomem, nostack)
);

Expand Down
39 changes: 22 additions & 17 deletions internal/shim-sev/src/gdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,31 @@ pub static TSS: Lazy<TaskStateSegment> = Lazy::new(|| {

tss.privilege_stack_table[0] = INITIAL_STACK.pointer;

let ptr_interrupt_stack_table = core::ptr::addr_of_mut!(tss.interrupt_stack_table);
let mut interrupt_stack_table = unsafe { ptr_interrupt_stack_table.read_unaligned() };

// Assign the stacks for the exceptions and interrupts
interrupt_stack_table
.iter_mut()
.enumerate()
.for_each(|(idx, p)| {
let offset: u64 = align_up(
SHIM_EX_STACK_SIZE
.checked_add(Page::<Size4KiB>::SIZE.checked_mul(2).unwrap())
.unwrap(),
Page::<Size2MiB>::SIZE,
);

let stack_offset = offset.checked_mul(idx as _).unwrap();
let start = VirtAddr::new(SHIM_EX_STACK_START.checked_add(stack_offset).unwrap());

*p = init_stack_with_guard(start, SHIM_EX_STACK_SIZE, PageTableFlags::empty()).pointer;
});

unsafe {
tss.interrupt_stack_table
.iter_mut()
.enumerate()
.for_each(|(idx, p)| {
let offset: u64 = align_up(
SHIM_EX_STACK_SIZE
.checked_add(Page::<Size4KiB>::SIZE.checked_mul(2).unwrap())
.unwrap(),
Page::<Size2MiB>::SIZE,
);

let stack_offset = offset.checked_mul(idx as _).unwrap();
let start = VirtAddr::new(SHIM_EX_STACK_START.checked_add(stack_offset).unwrap());

*p = init_stack_with_guard(start, SHIM_EX_STACK_SIZE, PageTableFlags::empty())
.pointer;
});
ptr_interrupt_stack_table.write_unaligned(interrupt_stack_table);
}

tss
});

Expand Down
26 changes: 13 additions & 13 deletions internal/shim-sgx/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/shim-sgx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sgx-heap = { path = "../sgx-heap" }
sallyport = { git = "https://github.com/enarx/sallyport", rev = "efccf0f" }
rcrt1 = { git = "https://github.com/enarx/rcrt1", rev = "2205dc7" }
compiler_builtins = { version = "0.1", default-features = false, features = [ "mem" ] }
sgx = { git = "https://github.com/enarx/sgx", rev = "5292e53", features = [ "asm" ] }
sgx = { git = "https://github.com/enarx/sgx", rev = "4bb50e55bc8717c5bc2a98d680bf1be436cda8de", features = [ "asm" ] }
goblin = { version = "0.3", default-features = false, features = [ "elf64" ] }
crt0stack = { version = "0.1", default-features = false }
libc = { version = "0.2", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion internal/shim-sgx/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ impl<'a> EnarxSyscallHandler for Handler<'a> {
};

let c = self.new_cursor();
let (c, shim_nonce_ptr) = c.copy_from_slice(&report_bytes).or(Err(libc::EMSGSIZE))?;
let (c, shim_nonce_ptr) = c.copy_from_slice(report_bytes).or(Err(libc::EMSGSIZE))?;
let (_, shim_buf_ptr) = c.alloc::<u8>(buf_len).or(Err(libc::EMSGSIZE))?;
let req = request!(SYS_ENARX_GETATT => shim_nonce_ptr.as_ptr(), report_bytes.len(), shim_buf_ptr.as_ptr(), buf_len);
let result = unsafe { self.proxy(req)? };
Expand Down
2 changes: 1 addition & 1 deletion src/backend/sgx/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ fn get_quote(report: &[u8], akid: Vec<u8>, out_buf: &mut [u8]) -> Result<usize,
}

assert_eq!(quote.len(), out_buf.len(), "Unable to copy Quote to buffer");
out_buf.copy_from_slice(&quote);
out_buf.copy_from_slice(quote);

Ok(quote.len())
}
Expand Down