Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/amd64 Reported-by: syzbot+6dd5a230d19f0cbc7814@syzk...



details:   https://anonhg.NetBSD.org/src/rev/195773021b46
branches:  trunk
changeset: 972657:195773021b46
user:      ad <ad%NetBSD.org@localhost>
date:      Mon Jun 01 22:58:06 2020 +0000

description:
Reported-by: syzbot+6dd5a230d19f0cbc7814%syzkaller.appspotmail.com@localhost

Instrument STOS/MOVS for KMSAN to unbreak it.

diffstat:

 sys/arch/amd64/amd64/cpufunc.S    |   4 +++-
 sys/arch/amd64/include/frameasm.h |  25 ++++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 2 deletions(-)

diffs (76 lines):

diff -r bf53d6c39d0f -r 195773021b46 sys/arch/amd64/amd64/cpufunc.S
--- a/sys/arch/amd64/amd64/cpufunc.S    Mon Jun 01 21:54:47 2020 +0000
+++ b/sys/arch/amd64/amd64/cpufunc.S    Mon Jun 01 22:58:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpufunc.S,v 1.58 2020/05/27 20:48:42 ad Exp $  */
+/*     $NetBSD: cpufunc.S,v 1.59 2020/06/01 22:58:06 ad Exp $  */
 
 /*
  * Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -424,6 +424,7 @@
 ENTRY(x86_stos)
        movq    %rsi,%rax
        movq    %rdx,%rcx
+       KMSAN_REP_STOS(8)
        rep
        stosq
        ret
@@ -431,6 +432,7 @@
 
 ENTRY(x86_movs)
        movq    %rdx,%rcx
+       KMSAN_REP_STOS(8)
        rep
        movsq
        ret
diff -r bf53d6c39d0f -r 195773021b46 sys/arch/amd64/include/frameasm.h
--- a/sys/arch/amd64/include/frameasm.h Mon Jun 01 21:54:47 2020 +0000
+++ b/sys/arch/amd64/include/frameasm.h Mon Jun 01 22:58:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: frameasm.h,v 1.49 2020/04/26 14:49:17 maxv Exp $       */
+/*     $NetBSD: frameasm.h,v 1.50 2020/06/01 22:58:06 ad Exp $ */
 
 #ifndef _AMD64_MACHINE_FRAMEASM_H
 #define _AMD64_MACHINE_FRAMEASM_H
@@ -222,6 +222,7 @@
 #endif
 
 #ifdef KMSAN
+/* XXX this belongs somewhere else. */
 #define KMSAN_ENTER    \
        movq    %rsp,%rdi               ; \
        movq    $TF_REGSIZE+16+40,%rsi  ; \
@@ -275,11 +276,33 @@
        popq    %rdx                    ; \
        popq    %rcx                    ; \
        popq    %rax
+#define KMSAN_REP_STOS(scale)  \
+       pushq   %rax                    ; \
+       pushq   %rcx                    ; \
+       pushq   %rdx                    ; \
+       pushq   %rsi                    ; \
+       pushq   %rdi                    ; \
+       pushq   %r8                     ; \
+       pushq   %r9                     ; \
+       pushq   %r10                    ; \
+       pushq   %r11                    ; \
+       leaq    (,%rcx,scale),%rsi      ; \
+       callq   _C_LABEL(__msan_instrument_asm_store); \
+       popq    %r11                    ; \
+       popq    %r10                    ; \
+       popq    %r9                     ; \
+       popq    %r8                     ; \
+       popq    %rdi                    ; \
+       popq    %rsi                    ; \
+       popq    %rdx                    ; \
+       popq    %rcx                    ; \
+       popq    %rax
 #else
 #define KMSAN_ENTER            /* nothing */
 #define KMSAN_LEAVE            /* nothing */
 #define KMSAN_INIT_ARG(sz)     /* nothing */
 #define KMSAN_INIT_RET(sz)     /* nothing */
+#define        KMSAN_REP_STOS(scale)   /* nothing */
 #endif
 
 #ifdef KCOV



Home | Main Index | Thread Index | Old Index