clrssbsy
Clear Shadow Stack Busy Flag
Clears the busy flag in the shadow stack token.
Details
Clears the busy flag (bit 0) of a shadow stack token located at the memory address specified by the operand. This instruction is part of Control-flow Enforcement Technology (CET) Shadow Stack and is used to mark a shadow stack token as no longer busy (e.g., after an exception handler has completed). ZF is set to 0 on success or 1 if the token address is misaligned or the token is invalid.
Pseudocode Operation
token_addr ← m64
if (token_addr is misaligned or not_valid_token) {
ZF ← 1
} else {
[token_addr] ← [token_addr] & ~(1) // Clear bit 0
ZF ← 0
}
Example
Encoding
Operands
-
token
Mem
Reference (Intel® SDM)
Instruction Forms
| Opcode | Instruction | Op/En | 64/32-bit Mode | CPUID | Description |
|---|---|---|---|---|---|
| F3 0F AE /6 | CLRSSBSY m64 | M | V/V | CET_SS | Clear busy flag in supervisor shadow stack token reference by m64. |
Description
Operation
IF CR4.CET = 0 OR CR4.FRED = 1 THEN #UD; FI; IF IA32_S_CET.SH_STK_EN = 0 THEN #UD; FI; IF CPL > 0 THEN GP(0); FI; SSP_LA = Linear_Address(mem operand) IF SSP_LA not aligned to 8 bytes THEN #GP(0); FI; expected_token_value = SSP_LA | BUSY_BIT (* busy bit - bit position 0 - must be set *) new_token_value = SSP_LA (* Clear the busy bit *) IF shadow_stack_lock_cmpxchg8b(SSP_LA, new_token_value, expected_token_value) != expected_token_value invalid_token := 1; FI (* Set the CF if invalid token was detected *) RFLAGS.CF = (invalid_token == 1) ? 1 : 0; RFLAGS.ZF,PF,AF,OF,SF := 0; SSP := 0
Flags Affected
CF is set if an invalid token was detected, else it is cleared. ZF, PF, AF, OF, and SF are cleared. CLRSSBSY—Clear Busy Flag in a Supervisor Shadow Stack Token Vol. 2A 3-150