diff --git a/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S b/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S index 8ab49a523a5d..a7d8ce275cb8 100644 --- a/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S +++ b/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S @@ -1,4 +1,4 @@ -/* $NetBSD: dtrace_asm.S,v 1.8 2018/05/28 21:05:03 chs Exp $ */ +/* $NetBSD: dtrace_asm.S,v 1.9 2023/11/03 09:07:56 chs Exp $ */ /* * CDDL HEADER START @@ -39,6 +39,11 @@ #include "assym.h" +#define DTRACE_SMAP_DISABLE \ + call dtrace_smap_disable +#define DTRACE_SMAP_ENABLE \ + call dtrace_smap_enable + #define INTR_POP \ MEXITCOUNT; \ movq TF_RDI(%rsp),%rdi; \ @@ -217,8 +222,10 @@ dtrace_copy(uintptr_t src, uintptr_t dest, size_t size) xchgq %rdi, %rsi /* make %rsi source, %rdi dest */ movq %rdx, %rcx /* load count */ + DTRACE_SMAP_DISABLE repz /* repeat for count ... */ smovb /* move from %ds:rsi to %ed:rdi */ + DTRACE_SMAP_ENABLE leave ret END(dtrace_copy) @@ -231,6 +238,7 @@ dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size, ENTRY(dtrace_copystr) pushq %rbp movq %rsp, %rbp + DTRACE_SMAP_DISABLE 0: movb (%rdi), %al /* load from source */ @@ -248,6 +256,7 @@ dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size, cmpq $0, %rdx jne 0b 2: + DTRACE_SMAP_ENABLE leave ret @@ -258,7 +267,9 @@ uintptr_t dtrace_fulword(void *addr) */ ENTRY(dtrace_fulword) + DTRACE_SMAP_DISABLE movq (%rdi), %rax + DTRACE_SMAP_ENABLE ret END(dtrace_fulword) @@ -268,7 +279,9 @@ dtrace_fuword8_nocheck(void *addr) */ ENTRY(dtrace_fuword8_nocheck) xorq %rax, %rax + DTRACE_SMAP_DISABLE movb (%rdi), %al + DTRACE_SMAP_ENABLE ret END(dtrace_fuword8_nocheck) @@ -278,7 +291,9 @@ dtrace_fuword16_nocheck(void *addr) */ ENTRY(dtrace_fuword16_nocheck) xorq %rax, %rax + DTRACE_SMAP_DISABLE movw (%rdi), %ax + DTRACE_SMAP_ENABLE ret END(dtrace_fuword16_nocheck) @@ -288,7 +303,9 @@ dtrace_fuword32_nocheck(void *addr) */ ENTRY(dtrace_fuword32_nocheck) xorq %rax, %rax + DTRACE_SMAP_DISABLE movl (%rdi), %eax + DTRACE_SMAP_ENABLE ret END(dtrace_fuword32_nocheck) @@ -297,7 +314,9 @@ uint64_t dtrace_fuword64_nocheck(void *addr) */ ENTRY(dtrace_fuword64_nocheck) + DTRACE_SMAP_DISABLE movq (%rdi), %rax + DTRACE_SMAP_ENABLE ret END(dtrace_fuword64_nocheck) diff --git a/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S b/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S index fc3f569aadd9..4a97f207e2b0 100644 --- a/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S +++ b/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S @@ -1,4 +1,4 @@ -/* $NetBSD: dtrace_asm.S,v 1.7 2018/05/28 21:05:03 chs Exp $ */ +/* $NetBSD: dtrace_asm.S,v 1.8 2023/11/03 09:07:57 chs Exp $ */ /* * CDDL HEADER START @@ -38,6 +38,11 @@ #include #include +#define DTRACE_SMAP_DISABLE \ + call dtrace_smap_disable +#define DTRACE_SMAP_ENABLE \ + call dtrace_smap_enable + #define INTR_POP \ addl $16, %esp; \ popl %edi; \ @@ -225,8 +230,10 @@ void dtrace_copy(uintptr_t src, uintptr_t dest, size_t size) movl 8(%ebp), %esi /* Load source address */ movl 12(%ebp), %edi /* Load destination address */ movl 16(%ebp), %ecx /* Load count */ + DTRACE_SMAP_DISABLE repz /* Repeat for count... */ smovb /* move from %ds:si to %es:di */ + DTRACE_SMAP_ENABLE popl %edi popl %esi @@ -248,6 +255,7 @@ void dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size) movl 8(%ebp), %ebx /* Load source address */ movl 12(%ebp), %edx /* Load destination address */ movl 16(%ebp), %ecx /* Load count */ + DTRACE_SMAP_DISABLE 0: movb (%ebx), %al /* Load from source */ @@ -261,6 +269,7 @@ void dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size) jne 0b 1: + DTRACE_SMAP_ENABLE popl %ebx movl %ebp, %esp popl %ebp @@ -275,7 +284,9 @@ uintptr_t dtrace_fulword(void *addr) ENTRY(dtrace_fulword) movl 4(%esp), %ecx xorl %eax, %eax + DTRACE_SMAP_DISABLE movl (%ecx), %eax + DTRACE_SMAP_ENABLE ret END(dtrace_fulword) @@ -286,7 +297,9 @@ uint8_t dtrace_fuword8_nocheck(void *addr) ENTRY(dtrace_fuword8_nocheck) movl 4(%esp), %ecx xorl %eax, %eax + DTRACE_SMAP_DISABLE movzbl (%ecx), %eax + DTRACE_SMAP_ENABLE ret END(dtrace_fuword8_nocheck) @@ -297,7 +310,9 @@ uint16_t dtrace_fuword16_nocheck(void *addr) ENTRY(dtrace_fuword16_nocheck) movl 4(%esp), %ecx xorl %eax, %eax + DTRACE_SMAP_DISABLE movzwl (%ecx), %eax + DTRACE_SMAP_ENABLE ret END(dtrace_fuword16_nocheck) @@ -308,7 +323,9 @@ uint32_t dtrace_fuword32_nocheck(void *addr) ENTRY(dtrace_fuword32_nocheck) movl 4(%esp), %ecx xorl %eax, %eax + DTRACE_SMAP_DISABLE movl (%ecx), %eax + DTRACE_SMAP_ENABLE ret END(dtrace_fuword32_nocheck) @@ -320,8 +337,10 @@ uint64_t dtrace_fuword64_nocheck(void *addr) movl 4(%esp), %ecx xorl %eax, %eax xorl %edx, %edx + DTRACE_SMAP_DISABLE movl (%ecx), %eax movl 4(%ecx), %edx + DTRACE_SMAP_ENABLE ret END(dtrace_fuword64_nocheck) diff --git a/sys/arch/amd64/amd64/cpufunc.S b/sys/arch/amd64/amd64/cpufunc.S index 854538cd5897..b71c16c33c52 100644 --- a/sys/arch/amd64/amd64/cpufunc.S +++ b/sys/arch/amd64/amd64/cpufunc.S @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.S,v 1.66 2023/10/04 20:28:05 ad Exp $ */ +/* $NetBSD: cpufunc.S,v 1.67 2023/11/03 09:07:56 chs Exp $ */ /* * Copyright (c) 1998, 2007, 2008, 2020, 2023 The NetBSD Foundation, Inc. @@ -36,6 +36,7 @@ #include #include +#include "opt_dtrace.h" #include "opt_xen.h" #include "opt_svs.h" @@ -177,6 +178,18 @@ ENTRY(smap_disable) ret END(smap_disable) +#ifdef KDTRACE_HOOKS +ENTRY(dtrace_smap_enable) + SMAP_ENABLE + ret +END(dtrace_smap_enable) + +ENTRY(dtrace_smap_disable) + SMAP_DISABLE + ret +END(dtrace_smap_disable) +#endif + /* * %rdi = name * %rsi = sel diff --git a/sys/arch/i386/i386/cpufunc.S b/sys/arch/i386/i386/cpufunc.S index 51b51f433a5a..1581cdbbd49e 100644 --- a/sys/arch/i386/i386/cpufunc.S +++ b/sys/arch/i386/i386/cpufunc.S @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.S,v 1.50 2023/10/04 20:28:05 ad Exp $ */ +/* $NetBSD: cpufunc.S,v 1.51 2023/11/03 09:07:56 chs Exp $ */ /*- * Copyright (c) 1998, 2007, 2020, 2023 The NetBSD Foundation, Inc. @@ -38,8 +38,10 @@ #include #include -__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.50 2023/10/04 20:28:05 ad Exp $"); +#include +__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.51 2023/11/03 09:07:56 chs Exp $"); +#include "opt_dtrace.h" #include "opt_xen.h" #include @@ -72,6 +74,18 @@ ENTRY(lidt) ret END(lidt) +#ifdef KDTRACE_HOOKS +ENTRY(dtrace_smap_enable) + SMAP_ENABLE + ret +END(dtrace_smap_enable) + +ENTRY(dtrace_smap_disable) + SMAP_DISABLE + ret +END(dtrace_smap_disable) +#endif + ENTRY(x86_hotpatch) /* save EFLAGS, and disable intrs */ pushfl