Fix invalid SGX exit handling
The contents of the sallyport are only valid after CSSA 2 does ERESUME
into CSSA 1. We should never evaluate the sallyport during an ERESUME
from CSSA 1 to CSSA 0.
@@ -107,12 +107,21 @@ impl super::super::Thread for Thread {
}
// If we have handled an InvalidOpcode error, evaluate the sallyport.
+ //
+ // Currently, we have no way to know if the sallyport contains a valid
+ // request by evaluating the sallyport directly. So we must presume
+ // that the sallyport is only valid when moving from CSSA 2 to CSSA 1.
+ //
+ // After the sallyport rework, we can test the sallyport itself and
+ // remove this logic.
+ if self.cssa > 0 {
if let (EENTER, ERESUME) = (how, self.how) {
match unsafe { self.block.msg.req }.num.into() {
SYS_ENARX_CPUID => return Ok(Command::CpuId(&mut self.block)),
_ => return Ok(Command::SysCall(&mut self.block)),
}
}
+ }
Ok(Command::Continue)
}
