From 95a0a18880d22990bd4dcdbe3b6e3cabeaf9a31e Mon Sep 17 00:00:00 2001 From: maxv Date: Sun, 19 Jul 2020 07:35:08 +0000 Subject: [PATCH] Revert most of ad's movs/stos change. Instead do a lot simpler: declare svs_quad_copy() used by SVS only, with no need for instrumentation, because SVS is disabled when sanitizers are on. --- sys/arch/amd64/amd64/cpufunc.S | 11 +++++++---- sys/arch/amd64/include/frameasm.h | 24 +----------------------- sys/arch/i386/i386/cpufunc.S | 20 ++------------------ sys/arch/x86/include/pmap.h | 4 ++-- sys/arch/x86/x86/svs.c | 6 +++--- 5 files changed, 15 insertions(+), 50 deletions(-) diff --git a/sys/arch/amd64/amd64/cpufunc.S b/sys/arch/amd64/amd64/cpufunc.S index 7b137339b8a0..8dcc9b8212a2 100644 --- a/sys/arch/amd64/amd64/cpufunc.S +++ b/sys/arch/amd64/amd64/cpufunc.S @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.S,v 1.63 2020/06/24 18:09:37 maxv Exp $ */ +/* $NetBSD: cpufunc.S,v 1.64 2020/07/19 07:35:08 maxv Exp $ */ /* * Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc. @@ -446,10 +446,13 @@ ENTRY(outl) ret END(outl) -ENTRY(x86_movs) +/* + * Used by SVS only, to make an atomic but fast copy. Doesn't have + * sanitizer instrumentation, but sanitizers disable SVS, so no problem. + */ +ENTRY(svs_quad_copy) movq %rdx,%rcx - KMSAN_REP_STOS(8) rep movsq ret -END(x86_movs) +END(svs_quad_copy) diff --git a/sys/arch/amd64/include/frameasm.h b/sys/arch/amd64/include/frameasm.h index d4f85d8579ce..1e3b363a89c3 100644 --- a/sys/arch/amd64/include/frameasm.h +++ b/sys/arch/amd64/include/frameasm.h @@ -1,4 +1,4 @@ -/* $NetBSD: frameasm.h,v 1.51 2020/06/21 16:53:37 bouyer Exp $ */ +/* $NetBSD: frameasm.h,v 1.52 2020/07/19 07:35:08 maxv Exp $ */ #ifndef _AMD64_MACHINE_FRAMEASM_H #define _AMD64_MACHINE_FRAMEASM_H @@ -276,33 +276,11 @@ 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 diff --git a/sys/arch/i386/i386/cpufunc.S b/sys/arch/i386/i386/cpufunc.S index 4043d5f65ab9..931f0962aa27 100644 --- a/sys/arch/i386/i386/cpufunc.S +++ b/sys/arch/i386/i386/cpufunc.S @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.S,v 1.48 2020/06/24 18:09:37 maxv Exp $ */ +/* $NetBSD: cpufunc.S,v 1.49 2020/07/19 07:35:08 maxv Exp $ */ /*- * Copyright (c) 1998, 2007, 2020 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include #include -__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.48 2020/06/24 18:09:37 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.49 2020/07/19 07:35:08 maxv Exp $"); #include "opt_xen.h" @@ -353,19 +353,3 @@ ENTRY(outl) outl %eax, %dx ret END(outl) - -ENTRY(x86_movs) - pushl %ebp - movl %esp,%ebp - pushl %edi - pushl %esi - movl 8(%ebp),%edi - movl 12(%ebp),%esi - movl 16(%ebp),%ecx - rep - movsl - popl %esi - popl %edi - leave - ret -END(x86_movs) diff --git a/sys/arch/x86/include/pmap.h b/sys/arch/x86/include/pmap.h index 34c149a955e3..b210a7d910b7 100644 --- a/sys/arch/x86/include/pmap.h +++ b/sys/arch/x86/include/pmap.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.124 2020/07/14 00:45:53 yamaguchi Exp $ */ +/* $NetBSD: pmap.h,v 1.125 2020/07/19 07:35:08 maxv Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -612,7 +612,7 @@ extern vaddr_t pmap_direct_end; #endif /* __HAVE_DIRECT_MAP */ -void x86_movs(void *, void *, long); +void svs_quad_copy(void *, void *, long); #endif /* _KERNEL */ diff --git a/sys/arch/x86/x86/svs.c b/sys/arch/x86/x86/svs.c index 0cc350a5e06c..01aa8f7f1eb9 100644 --- a/sys/arch/x86/x86/svs.c +++ b/sys/arch/x86/x86/svs.c @@ -1,4 +1,4 @@ -/* $NetBSD: svs.c,v 1.38 2020/07/14 00:45:53 yamaguchi Exp $ */ +/* $NetBSD: svs.c,v 1.39 2020/07/19 07:35:08 maxv Exp $ */ /* * Copyright (c) 2018-2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.38 2020/07/14 00:45:53 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.39 2020/07/19 07:35:08 maxv Exp $"); #include "opt_svs.h" #include "opt_user_ldt.h" @@ -704,7 +704,7 @@ svs_pdir_switch(struct pmap *pmap) /* Copy user slots. */ mutex_enter(&ci->ci_svs_mtx); - x86_movs(ci->ci_svs_updir, pmap->pm_pdir, PDIR_SLOT_USERLIM); + svs_quad_copy(ci->ci_svs_updir, pmap->pm_pdir, PDIR_SLOT_USERLIM); mutex_exit(&ci->ci_svs_mtx); if (svs_pcid) {