[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 0/3] x86: Initial pieces for guest CET support
On 28.04.2021 14:25, Andrew Cooper wrote: > On 27/04/2021 11:13, Andrew Cooper wrote: >> There are 3 emulator complexities for shadow stack instructions. SSP >> itself as a register, WRUSS no longer being CPL-based for >> user/supervisor, and the fact that RSTORSSP in particular uses an atomic >> block which microcode can express, but can't be encoded at an ISA >> level. I've got no idea what to do about this last problem, because we >> can't map the two guest frames and re-issue the instruction - the >> aliasing check on the tokens forces us to map the two frames in their >> correct linear addresses. > > Actually, RSTORSSP isn't too difficult. I'd mis-read the pseudocode. > > The atomic block is a check&edit of the token on the remote stack (not > both stacks, as I'd mistakenly thought). The purpose is to prevent two > concurrent RSTORSSP's moving two threads onto the same shadow stack. > > Without microcode superpowers, the best we can do this with a read, > check, cmpxchg() loop. > > The common case will be no conflict, as stack switching will be well > formed (outside of debugging). Any conflict here from real code is > going to yield #GP/#CP on one of the threads participating, so in the > case of a conflict in the emulator, a likely consequence of the 2nd > iteration is going to be a hard failure. > > That said, malicious cases within the guest, or from foreign mappings, > can cause the cmpxchg() loop to take an unbounded time, so after 3 > retries or so, we need to escalate to vcpu_pause_all_except_self(), and > or the ARM stop_machine() big hammer. > > I'm tempted to just throw #GP back after 3 retries. Its potentially > non-architectural behaviour, but won't occur in non-malicious > circumstances, and all fallback mechanisms have system-wide implications > that we oughtn't to be bowing to in a malicious circumstance. I agree. Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |