wrpkru
Write Protection Key Rights
WRPKRU
Writes EAX/EDX to PKRU register.
Pseudocode Operation
// Write EAX to PKRU, EDX must be zero
IF (EDX ≠ 0) THEN
#GP(0); // General Protection Fault
ELSE
PKRU ← EAX;
END;
// No flags modified; instruction is serializing
Encoding
Binary Layout
0F
+0
01
+1
EF
+2
Operands
Related
More in PKU
Reference
Instruction Forms
| Opcode | Instruction | Op/En | 64/32-bit Mode | CPUID | Description |
|---|---|---|---|---|---|
| NP 0F 01 EF | WRPKRU | ZO | V/V | OSPKE | Writes EAX into PKRU. |
Description
Writes the value of EAX into PKRU. ECX and EDX must be 0 when WRPKRU is executed; otherwise, a generalprotection exception (#GP) occurs. WRPKRU can be executed only if CR4.PKE = 1; otherwise, an invalid-opcode exception (#UD) occurs. Software can discover the value of CR4.PKE by examining CPUID.07H.00H:ECX.OSPKE[4]. On processors that support the Intel 64 Architecture, the high-order 32-bits of RCX, RDX, and RAX are ignored. WRPKRU will never execute speculatively. Memory accesses affected by PKRU register will not execute (even speculatively) until all prior executions of WRPKRU have completed execution and updated the PKRU register.
Operation
IF (ECX = 0 AND EDX = 0) THEN PKRU := EAX; ELSE #GP(0); FI;
Flags Affected
None.
C/C++ Compiler Intrinsic Equivalent
WRPKRU void _wrpkru(uint32_t);
Exceptions
Protected Mode Exceptions
#GP(0) If ECX ≠ 0.
If EDX ≠ 0.
#UD If the LOCK prefix is used.
If CR4.PKE = 0.
Real-Address Mode Exceptions
Same exceptions as in protected mode.
Virtual-8086 Mode Exceptions
Same exceptions as in protected mode.
Compatibility Mode Exceptions
Same exceptions as in protected mode.
WRPKRU-Write Data to User Page Key Register Vol. 2D 6-14
64-Bit Mode Exceptions
Same exceptions as in protected mode.
WRPKRU-Write Data to User Page Key Register Vol. 2D 6-15