Source-Changes-HG archive

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

[src-draft/trunk]: src/sys/arch/aarch64 Load zero fpregs from static const bu...



details:   https://anonhg.NetBSD.org/src-all/rev/17bd6d46b6be
branches:  trunk
changeset: 934577:17bd6d46b6be
user:      Taylor R Campbell <riastradh%NetBSD.org@localhost>
date:      Sun Jun 14 05:27:01 2020 +0000

description:
Load zero fpregs from static const buffer, not stack memset buffer.

Maybe this should just use a series of EOR instructions to avoid
hitting memory altogether?

diffstat:

 sys/arch/aarch64/aarch64/fpu.c     |  5 ++---
 sys/arch/aarch64/include/machdep.h |  2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diffs (34 lines):

diff -r be4174d6c523 -r 17bd6d46b6be sys/arch/aarch64/aarch64/fpu.c
--- a/sys/arch/aarch64/aarch64/fpu.c    Sun Jun 14 05:15:54 2020 +0000
+++ b/sys/arch/aarch64/aarch64/fpu.c    Sun Jun 14 05:27:01 2020 +0000
@@ -213,7 +213,7 @@
 void
 fpu_kern_leave(void)
 {
-       struct fpreg zero_fpregs;
+       static const struct fpreg zero_fpreg;
        struct cpu_info *ci = curcpu();
        int s;
 
@@ -225,8 +225,7 @@
         * through Spectre-class attacks to userland, even if there are
         * no bugs in fpu state management.
         */
-       memset(&zero_fpregs, 0, sizeof(zero_fpregs));
-       load_fpregs(&zero_fpregs);
+       load_fpregs(&zero_fpreg);
 
        /*
         * Disable the fpu so that the kernel can't accidentally use
diff -r be4174d6c523 -r 17bd6d46b6be sys/arch/aarch64/include/machdep.h
--- a/sys/arch/aarch64/include/machdep.h        Sun Jun 14 05:15:54 2020 +0000
+++ b/sys/arch/aarch64/include/machdep.h        Sun Jun 14 05:27:01 2020 +0000
@@ -142,7 +142,7 @@
 /* fpu.c */
 void fpu_attach(struct cpu_info *);
 struct fpreg;
-void load_fpregs(struct fpreg *);
+void load_fpregs(const struct fpreg *);
 void save_fpregs(struct fpreg *);
 void fpu_kern_enter(void);
 void fpu_kern_leave(void);



Home | Main Index | Thread Index | Old Index