Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src-draft/trunk]: src/sys/arch/x86 Use static constant rather than stack mem...
details: https://anonhg.NetBSD.org/src-all/rev/be4174d6c523
branches: trunk
changeset: 934576:be4174d6c523
user: Taylor R Campbell <riastradh%NetBSD.org@localhost>
date: Sun Jun 14 05:15:54 2020 +0000
description:
Use static constant rather than stack memset buffer for zero fpregs.
diffstat:
sys/arch/x86/include/cpufunc.h | 6 +++---
sys/arch/x86/include/fpu.h | 2 +-
sys/arch/x86/x86/fpu.c | 5 ++---
3 files changed, 6 insertions(+), 7 deletions(-)
diffs (71 lines):
diff -r 75dbad3a3753 -r be4174d6c523 sys/arch/x86/include/cpufunc.h
--- a/sys/arch/x86/include/cpufunc.h Sun Jun 14 00:57:26 2020 +0000
+++ b/sys/arch/x86/include/cpufunc.h Sun Jun 14 05:15:54 2020 +0000
@@ -381,7 +381,7 @@
}
static inline void
-frstor(void *addr)
+frstor(const void *addr)
{
const uint8_t *area = addr;
@@ -407,7 +407,7 @@
}
static inline void
-fxrstor(void *addr)
+fxrstor(const void *addr)
{
const uint8_t *area = addr;
@@ -452,7 +452,7 @@
}
static inline void
-xrstor(void *addr, uint64_t mask)
+xrstor(const void *addr, uint64_t mask)
{
const uint8_t *area = addr;
uint32_t low, high;
diff -r 75dbad3a3753 -r be4174d6c523 sys/arch/x86/include/fpu.h
--- a/sys/arch/x86/include/fpu.h Sun Jun 14 00:57:26 2020 +0000
+++ b/sys/arch/x86/include/fpu.h Sun Jun 14 05:15:54 2020 +0000
@@ -15,7 +15,7 @@
void fpuinit_mxcsr_mask(void);
void fpu_area_save(void *, uint64_t);
-void fpu_area_restore(void *, uint64_t);
+void fpu_area_restore(const void *, uint64_t);
void fpu_save(void);
diff -r 75dbad3a3753 -r be4174d6c523 sys/arch/x86/x86/fpu.c
--- a/sys/arch/x86/x86/fpu.c Sun Jun 14 00:57:26 2020 +0000
+++ b/sys/arch/x86/x86/fpu.c Sun Jun 14 05:15:54 2020 +0000
@@ -269,7 +269,7 @@
}
void
-fpu_area_restore(void *area, uint64_t xsave_features)
+fpu_area_restore(const void *area, uint64_t xsave_features)
{
clts();
@@ -435,7 +435,7 @@
void
fpu_kern_leave(void)
{
- union savefpu zero_fpu __aligned(64);
+ static const union savefpu zero_fpu __aligned(64);
struct cpu_info *ci = curcpu();
int s;
@@ -447,7 +447,6 @@
* through Spectre-class attacks to userland, even if there are
* no bugs in fpu state management.
*/
- memset(&zero_fpu, 0, sizeof(zero_fpu));
fpu_area_restore(&zero_fpu, x86_xsave_features);
/*
Home |
Main Index |
Thread Index |
Old Index