* On AuthenticAMD processors, the fxrstor instruction does not restore * the x87's stored last instruction pointer, last data pointer, and last * opcode values, except in the rare case in which the exception summary * (ES) bit in the x87 status word is set to 1. * * In order to avoid leaking this information across processes, we clean * these values by performing a dummy load before executin
| 1008 | * these values by performing a dummy load before executing fxrstor(). |
| 1009 | */ |
| 1010 | static void |
| 1011 | fpu_clean_state(void) |
| 1012 | { |
| 1013 | static float dummy_variable = 0.0; |
| 1014 | u_short status; |
| 1015 | |
| 1016 | /* |
| 1017 | * Clear the ES bit in the x87 status word if it is currently |
| 1018 | * set, in order to avoid causing a fault in the upcoming load. |
| 1019 | */ |
| 1020 | fnstsw(&status); |
| 1021 | if (status & 0x80) |
| 1022 | fnclex(); |
| 1023 | |
| 1024 | /* |
| 1025 | * Load the dummy variable into the x87 stack. This mangles |
| 1026 | * the x87 stack, but we don't care since we're about to call |
| 1027 | * fxrstor() anyway. |
| 1028 | */ |
| 1029 | __asm __volatile("ffree %%st(7); flds %0" : : "m" (dummy_variable)); |
| 1030 | } |
| 1031 | |
| 1032 | /* |
| 1033 | * This really sucks. We want the acpi version only, but it requires |
no outgoing calls
no test coverage detected