Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86 Use static constant rather than stack memset bu...



details:   https://anonhg.NetBSD.org/src/rev/28cf9fe94457
branches:  trunk
changeset: 972960:28cf9fe94457
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Jun 14 16:12:05 2020 +0000

description:
Use static constant rather than stack memset buffer for zero fpregs.

diffstat:

 sys/arch/x86/include/cpufunc.h |  8 ++++----
 sys/arch/x86/include/fpu.h     |  4 ++--
 sys/arch/x86/x86/fpu.c         |  9 ++++-----
 3 files changed, 10 insertions(+), 11 deletions(-)

diffs (98 lines):

diff -r 54f5a0b002e3 -r 28cf9fe94457 sys/arch/x86/include/cpufunc.h
--- a/sys/arch/x86/include/cpufunc.h    Sun Jun 14 16:10:18 2020 +0000
+++ b/sys/arch/x86/include/cpufunc.h    Sun Jun 14 16:12:05 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpufunc.h,v 1.39 2020/05/02 11:37:17 maxv Exp $        */
+/*     $NetBSD: cpufunc.h,v 1.40 2020/06/14 16:12:05 riastradh Exp $   */
 
 /*
  * Copyright (c) 1998, 2007, 2019 The NetBSD Foundation, Inc.
@@ -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 54f5a0b002e3 -r 28cf9fe94457 sys/arch/x86/include/fpu.h
--- a/sys/arch/x86/include/fpu.h        Sun Jun 14 16:10:18 2020 +0000
+++ b/sys/arch/x86/include/fpu.h        Sun Jun 14 16:12:05 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu.h,v 1.20 2019/11/27 06:24:33 maxv Exp $    */
+/*     $NetBSD: fpu.h,v 1.21 2020/06/14 16:12:05 riastradh Exp $       */
 
 #ifndef        _X86_FPU_H_
 #define        _X86_FPU_H_
@@ -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 54f5a0b002e3 -r 28cf9fe94457 sys/arch/x86/x86/fpu.c
--- a/sys/arch/x86/x86/fpu.c    Sun Jun 14 16:10:18 2020 +0000
+++ b/sys/arch/x86/x86/fpu.c    Sun Jun 14 16:12:05 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu.c,v 1.64 2020/06/13 19:01:11 riastradh Exp $       */
+/*     $NetBSD: fpu.c,v 1.65 2020/06/14 16:12:05 riastradh Exp $       */
 
 /*
  * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc.  All
@@ -96,7 +96,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.64 2020/06/13 19:01:11 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.65 2020/06/14 16:12:05 riastradh Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -267,7 +267,7 @@
 }
 
 void
-fpu_area_restore(void *area, uint64_t xsave_features)
+fpu_area_restore(const void *area, uint64_t xsave_features)
 {
        clts();
 
@@ -392,7 +392,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;
 
@@ -404,7 +404,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