Fix a few nits in the earlier changes to prevent local information leakage
in AMD FPUs: - Do not clear the affected state in the case that the FPU registers for the thread that already owns the FPU are changed via fpu_setregs(). The only local information the thread would see is its own state in that case. - Fix a type mismatch for the dummy variable used in a "fld". It accepts a float, not a double. Reviewed by: bde Approved by: so (cperciva) MFC after: 1 month
This commit is contained in:
parent
9c09aaf3a3
commit
afc2ecb61b
@ -480,7 +480,6 @@ fpusetregs(struct thread *td, struct savefpu *addr)
|
|||||||
|
|
||||||
s = intr_disable();
|
s = intr_disable();
|
||||||
if (td == PCPU_GET(fpcurthread)) {
|
if (td == PCPU_GET(fpcurthread)) {
|
||||||
fpu_clean_state();
|
|
||||||
fxrstor(addr);
|
fxrstor(addr);
|
||||||
intr_restore(s);
|
intr_restore(s);
|
||||||
} else {
|
} else {
|
||||||
@ -499,10 +498,10 @@ fpusetregs(struct thread *td, struct savefpu *addr)
|
|||||||
* In order to avoid leaking this information across processes, we clean
|
* In order to avoid leaking this information across processes, we clean
|
||||||
* these values by performing a dummy load before executing fxrstor().
|
* these values by performing a dummy load before executing fxrstor().
|
||||||
*/
|
*/
|
||||||
static double dummy_variable = 0.0;
|
|
||||||
static void
|
static void
|
||||||
fpu_clean_state(void)
|
fpu_clean_state(void)
|
||||||
{
|
{
|
||||||
|
static float dummy_variable = 0.0;
|
||||||
u_short status;
|
u_short status;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -794,6 +794,11 @@ npxdna(void)
|
|||||||
PCPU_SET(fpcurthread, curthread);
|
PCPU_SET(fpcurthread, curthread);
|
||||||
pcb = PCPU_GET(curpcb);
|
pcb = PCPU_GET(curpcb);
|
||||||
|
|
||||||
|
#ifdef CPU_ENABLE_SSE
|
||||||
|
if (cpu_fxsr)
|
||||||
|
fpu_clean_state();
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((pcb->pcb_flags & PCB_NPXINITDONE) == 0) {
|
if ((pcb->pcb_flags & PCB_NPXINITDONE) == 0) {
|
||||||
/*
|
/*
|
||||||
* This is the first time this thread has used the FPU or
|
* This is the first time this thread has used the FPU or
|
||||||
@ -976,10 +981,10 @@ fpusave(addr)
|
|||||||
* In order to avoid leaking this information across processes, we clean
|
* In order to avoid leaking this information across processes, we clean
|
||||||
* these values by performing a dummy load before executing fxrstor().
|
* these values by performing a dummy load before executing fxrstor().
|
||||||
*/
|
*/
|
||||||
static double dummy_variable = 0.0;
|
|
||||||
static void
|
static void
|
||||||
fpu_clean_state(void)
|
fpu_clean_state(void)
|
||||||
{
|
{
|
||||||
|
static float dummy_variable = 0.0;
|
||||||
u_short status;
|
u_short status;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1005,10 +1010,9 @@ fpurstor(addr)
|
|||||||
{
|
{
|
||||||
|
|
||||||
#ifdef CPU_ENABLE_SSE
|
#ifdef CPU_ENABLE_SSE
|
||||||
if (cpu_fxsr) {
|
if (cpu_fxsr)
|
||||||
fpu_clean_state();
|
|
||||||
fxrstor(addr);
|
fxrstor(addr);
|
||||||
} else
|
else
|
||||||
#endif
|
#endif
|
||||||
frstor(addr);
|
frstor(addr);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user