CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: mrg Date: Mon Jul 31 02:38:16 UTC 2023 Modified Files: src/sys/arch/amd64/amd64: db_interface.c Log Message: when cpus are paused (spinning) in DDB, call x86_pause() in the loop, hopefully this can reduce power usage while doing nothing. ok chs@ XXX: pullup-* XXX: apply to i386 To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/arch/amd64/amd64/db_interface.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/db_interface.c diff -u src/sys/arch/amd64/amd64/db_interface.c:1.41 src/sys/arch/amd64/amd64/db_interface.c:1.42 --- src/sys/arch/amd64/amd64/db_interface.c:1.41 Wed Oct 26 23:38:06 2022 +++ src/sys/arch/amd64/amd64/db_interface.c Mon Jul 31 02:38:16 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: db_interface.c,v 1.41 2022/10/26 23:38:06 riastradh Exp $ */ +/* $NetBSD: db_interface.c,v 1.42 2023/07/31 02:38:16 mrg Exp $ */ /* * Mach Operating System @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.41 2022/10/26 23:38:06 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.42 2023/07/31 02:38:16 mrg Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -303,7 +303,7 @@ ddb_suspend(struct trapframe *frame) atomic_or_32(>ci_flags, CPUF_PAUSE); while (ci->ci_flags & CPUF_PAUSE) - ; + x86_pause(); ci->ci_ddb_regs = 0; tlbflushg(); }
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: mrg Date: Mon Jul 31 02:38:16 UTC 2023 Modified Files: src/sys/arch/amd64/amd64: db_interface.c Log Message: when cpus are paused (spinning) in DDB, call x86_pause() in the loop, hopefully this can reduce power usage while doing nothing. ok chs@ XXX: pullup-* XXX: apply to i386 To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/arch/amd64/amd64/db_interface.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: riastradh Date: Mon Feb 27 16:24:28 UTC 2023 Modified Files: src/sys/arch/amd64/amd64: amd64_trap.S Log Message: amd64_trap.S: Annotate trap vectors with their mnemonics. Derived from Intel and AMD manuals. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3 (3A, 3B, 3C, & 3D: System Programming Guide, Order Number: 325384-077US, April 2022. https://cdrdv2.intel.com/v1/dl/getContent/671447 AMD64 Technology: AMD64 Architecture Programmers' Manual, Volume 2: System Programming, Publication No. 24953, Revision 3.40, January 2023. https://www.amd.com/system/files/TechDocs/24593.pdf No functional change intended. XXX Should apply the same treatment to i386_trap.S. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sys/arch/amd64/amd64/amd64_trap.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/amd64_trap.S diff -u src/sys/arch/amd64/amd64/amd64_trap.S:1.54 src/sys/arch/amd64/amd64/amd64_trap.S:1.55 --- src/sys/arch/amd64/amd64/amd64_trap.S:1.54 Wed Sep 7 00:40:18 2022 +++ src/sys/arch/amd64/amd64/amd64_trap.S Mon Feb 27 16:24:28 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: amd64_trap.S,v 1.54 2022/09/07 00:40:18 knakahara Exp $ */ +/* $NetBSD: amd64_trap.S,v 1.55 2023/02/27 16:24:28 riastradh Exp $ */ /* * Copyright (c) 1998, 2007, 2008, 2017 The NetBSD Foundation, Inc. @@ -159,7 +159,7 @@ TEXT_USER_BEGIN -IDTVEC(trap00) +IDTVEC(trap00) /* #DE - Divide-by-zero error */ ZTRAP(T_DIVIDE) IDTVEC_END(trap00) @@ -178,7 +178,7 @@ IDTVEC_END(trap00) * not a problem, because in this particular case, the frame is known not * to contain secrets. */ -IDTVEC(trap01) +IDTVEC(trap01) /* #DB - Debug */ #ifndef XENPV subq $(TF_REGSIZE+16),%rsp @@ -247,7 +247,7 @@ IDTVEC_END(trap01) * We need to be careful about %gs too, because it is possible that we were * running in kernel mode with a userland %gs. */ -IDTVEC(trap02) +IDTVEC(trap02) /* NMI - Non-maskable interrupt */ #if defined(XENPV) ZTRAP(T_NMI) #else /* XENPV */ @@ -302,7 +302,7 @@ IDTVEC(trap02) #endif /* XENPV */ IDTVEC_END(trap02) -IDTVEC(trap03) +IDTVEC(trap03) /* #BP - Breakpoint */ #ifndef KDTRACE_HOOKS ZTRAP(T_BPTFLT) #else @@ -331,19 +331,19 @@ IDTVEC(trap03) #endif IDTVEC_END(trap03) -IDTVEC(trap04) +IDTVEC(trap04) /* #OF - Overflow */ ZTRAP(T_OFLOW) IDTVEC_END(trap04) -IDTVEC(trap05) +IDTVEC(trap05) /* #BR - BOUND range exceeded */ ZTRAP(T_BOUND) IDTVEC_END(trap05) -IDTVEC(trap06) +IDTVEC(trap06) /* #UD - Invalid opcode */ ZTRAP(T_PRIVINFLT) IDTVEC_END(trap06) -IDTVEC(trap07) +IDTVEC(trap07) /* #NM - Device not available (x87) */ ZTRAP_NJ(T_DNA) INTRENTRY #ifdef DIAGNOSTIC @@ -358,7 +358,7 @@ IDTVEC_END(trap07) * Double faults execute on a particular stack, and we must not jump out * of it. So don't enable interrupts. */ -IDTVEC(trap08) +IDTVEC(trap08) /* #DF - Double fault */ #if defined(XENPV) TRAP(T_DOUBLEFLT) #else /* XENPV */ @@ -399,11 +399,11 @@ IDTVEC(trap08) #endif /* XENPV */ IDTVEC_END(trap08) -IDTVEC(trap09) +IDTVEC(trap09) /* Coprocessor segment overrun (legacy x87) */ ZTRAP(T_FPOPFLT) IDTVEC_END(trap09) -IDTVEC(trap10) +IDTVEC(trap10) /* #TS - Invalid TSS */ TRAP(T_TSSFLT) IDTVEC_END(trap10) @@ -416,26 +416,26 @@ IDTVEC_END(trap10) #define kernuser_reenter alltraps #endif /* XENPV */ -IDTVEC(trap11) /* #NP() Segment not present */ +IDTVEC(trap11) /* #NP - Segment not present */ TRAP_NJ(T_SEGNPFLT) jmp kernuser_reenter IDTVEC_END(trap11) -IDTVEC(trap12) /* #SS() Stack exception */ +IDTVEC(trap12) /* #SS - Stack fault */ TRAP_NJ(T_STKFLT) jmp kernuser_reenter IDTVEC_END(trap12) -IDTVEC(trap13) /* #GP() General protection */ +IDTVEC(trap13) /* #GP - General protection */ TRAP_NJ(T_PROTFLT) jmp kernuser_reenter IDTVEC_END(trap13) -IDTVEC(trap14) +IDTVEC(trap14) /* #PF - Page fault */ TRAP(T_PAGEFLT) IDTVEC_END(trap14) -IDTVEC(trap15) +IDTVEC(trap15) /* XXX ??? */ ZTRAP_NJ(T_ASTFLT) INTRENTRY #ifdef DIAGNOSTIC @@ -444,7 +444,7 @@ IDTVEC(trap15) jmp .Lalltraps_checkusr IDTVEC_END(trap15) -IDTVEC(trap16) +IDTVEC(trap16) /* #MF - x87 floating-point exception */ ZTRAP_NJ(T_ARITHTRAP) .Ldo_fputrap: INTRENTRY @@ -464,30 +464,30 @@ IDTVEC(trap16) jmp .Lalltraps_checkusr IDTVEC_END(trap16) -IDTVEC(trap17) +IDTVEC(trap17) /* #AC - Alignment check */ TRAP(T_ALIGNFLT) IDTVEC_END(trap17) -IDTVEC(trap18) +IDTVEC(trap18) /* #MC - Machine check */ ZTRAP(T_MCA) IDTVEC_END(trap18) -IDTVEC(trap19) +IDTVEC(trap19) /* #XM - SIMD floating-point exception */ ZTRAP_NJ(T_XMM) jmp .Ldo_fputrap IDTVEC_END(trap19) -IDTVEC(trap20) -IDTVEC(trap21) +IDTVEC(trap20) /* #VE - Virtualization (Intel) */ +IDTVEC(trap21) /* #CP - Control protection */ IDTVEC(trap22) IDTVEC(trap23) IDTVEC(trap24)
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: riastradh Date: Mon Feb 27 16:24:28 UTC 2023 Modified Files: src/sys/arch/amd64/amd64: amd64_trap.S Log Message: amd64_trap.S: Annotate trap vectors with their mnemonics. Derived from Intel and AMD manuals. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3 (3A, 3B, 3C, & 3D: System Programming Guide, Order Number: 325384-077US, April 2022. https://cdrdv2.intel.com/v1/dl/getContent/671447 AMD64 Technology: AMD64 Architecture Programmers' Manual, Volume 2: System Programming, Publication No. 24953, Revision 3.40, January 2023. https://www.amd.com/system/files/TechDocs/24593.pdf No functional change intended. XXX Should apply the same treatment to i386_trap.S. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sys/arch/amd64/amd64/amd64_trap.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: christos Date: Mon Dec 26 17:46:00 UTC 2022 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: sysret -> sysretl for new binutils To generate a diff of this commit: cvs rdiff -u -r1.214 -r1.215 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.214 src/sys/arch/amd64/amd64/locore.S:1.215 --- src/sys/arch/amd64/amd64/locore.S:1.214 Tue Sep 6 20:40:18 2022 +++ src/sys/arch/amd64/amd64/locore.S Mon Dec 26 12:46:00 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.214 2022/09/07 00:40:18 knakahara Exp $ */ +/* $NetBSD: locore.S,v 1.215 2022/12/26 17:46:00 christos Exp $ */ /* * Copyright-o-rama! @@ -1527,7 +1527,7 @@ SYSCALL_ENTRY syscall_svs,is_svs=1 #endif IDTVEC(syscall32) - sysret /* go away please */ + sysretl /* go away please */ IDTVEC_END(syscall32) TEXT_USER_END
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: christos Date: Mon Dec 26 17:46:00 UTC 2022 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: sysret -> sysretl for new binutils To generate a diff of this commit: cvs rdiff -u -r1.214 -r1.215 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: skrll Date: Sun Dec 18 07:53:31 UTC 2022 Modified Files: src/sys/arch/amd64/amd64: copy.S Log Message: Typo in comment To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/arch/amd64/amd64/copy.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: skrll Date: Sun Dec 18 07:53:31 UTC 2022 Modified Files: src/sys/arch/amd64/amd64: copy.S Log Message: Typo in comment To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/arch/amd64/amd64/copy.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/copy.S diff -u src/sys/arch/amd64/amd64/copy.S:1.34 src/sys/arch/amd64/amd64/copy.S:1.35 --- src/sys/arch/amd64/amd64/copy.S:1.34 Tue Jun 30 16:20:00 2020 +++ src/sys/arch/amd64/amd64/copy.S Sun Dec 18 07:53:30 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: copy.S,v 1.34 2020/06/30 16:20:00 maxv Exp $ */ +/* $NetBSD: copy.S,v 1.35 2022/12/18 07:53:30 skrll Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -120,7 +120,7 @@ END(do_pmap_load) * However the use of 'rep movsb' for the final bytes should be killed. * * Newer Intel cpus have a much lower setup time, and may (someday) - * be ably to do cache-line size copies + * be able to do cache-line size copies */ /*
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: knakahara Date: Tue Sep 13 05:36:29 UTC 2022 Modified Files: src/sys/arch/amd64/amd64: lock_stubs.S Log Message: Fix PR kern/57007. I missed applying a part of the original patch. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/arch/amd64/amd64/lock_stubs.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/lock_stubs.S diff -u src/sys/arch/amd64/amd64/lock_stubs.S:1.37 src/sys/arch/amd64/amd64/lock_stubs.S:1.38 --- src/sys/arch/amd64/amd64/lock_stubs.S:1.37 Wed Sep 7 00:40:18 2022 +++ src/sys/arch/amd64/amd64/lock_stubs.S Tue Sep 13 05:36:29 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: lock_stubs.S,v 1.37 2022/09/07 00:40:18 knakahara Exp $ */ +/* $NetBSD: lock_stubs.S,v 1.38 2022/09/13 05:36:29 knakahara Exp $ */ /* * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -124,13 +124,13 @@ ENTRY(mutex_spin_exit) movl CPU_INFO_MTX_OLDSPL(%r8), %edi incl CPU_INFO_MTX_COUNT(%r8) jnz 1f - cmpl CPU_INFO_ILEVEL(%r8), %edi + cmpb CPU_INFO_ILEVEL(%r8), %dil jae 1f - movl CPU_INFO_IUNMASK(%r8,%rdi,4), %esi + movq CPU_INFO_IUNMASK(%r8,%rdi,8), %rsi CLI(ax) - testl CPU_INFO_IPENDING(%r8), %esi + testq CPU_INFO_IPENDING(%r8), %rsi jnz _C_LABEL(Xspllower) - movl %edi, CPU_INFO_ILEVEL(%r8) + movb %dil, CPU_INFO_ILEVEL(%r8) STI(ax) 1: rep /* double byte ret as branch */ ret /* target: see AMD docs */ @@ -141,23 +141,27 @@ ENTRY(mutex_spin_exit) movb $0x00, MTX_LOCK(%rdi) movl CPU_INFO_MTX_OLDSPL(%rsi), %ecx incl CPU_INFO_MTX_COUNT(%rsi) - movl CPU_INFO_ILEVEL(%rsi),%edx + movzbl CPU_INFO_ILEVEL(%rsi),%edx cmovnzl %edx,%ecx - pushq %rbx cmpl %edx,%ecx /* new level is lower? */ jae 2f + xorq %rdi,%rdi /* rdi: ci_ipending mask */ + notq %rdi + shrq $8,%rdi + movq %rcx,%r9 /* r9: shifted new level */ + shlq $56,%r9 1: - movl CPU_INFO_IPENDING(%rsi),%eax - testl %eax,CPU_INFO_IUNMASK(%rsi,%rcx,4)/* deferred interrupts? */ + movq CPU_INFO_IPENDING(%rsi),%rax + testq %rax,CPU_INFO_IUNMASK(%rsi,%rcx,8)/* deferred interrupts? */ jnz 3f - movl %eax,%ebx - cmpxchg8b CPU_INFO_ISTATE(%rsi) /* swap in new ilevel */ + movq %rax,%r8 + andq %rdi,%r8 + orq %r9,%r8 + cmpxchgq %r8,CPU_INFO_ISTATE(%rsi) /* swap in new ilevel */ jnz 4f 2: - popq %rbx ret 3: - popq %rbx movl %ecx, %edi jmp _C_LABEL(Xspllower) 4:
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: knakahara Date: Tue Sep 13 05:36:29 UTC 2022 Modified Files: src/sys/arch/amd64/amd64: lock_stubs.S Log Message: Fix PR kern/57007. I missed applying a part of the original patch. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/arch/amd64/amd64/lock_stubs.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: knakahara Date: Mon Sep 12 02:21:11 UTC 2022 Modified Files: src/sys/arch/amd64/amd64: vector.S Log Message: Update register name at fault. Pointed out by hgutch@n.o, thanks. In vetor.S:r1.78 IDTVEC(handle_hypervisor_callback) movlCPUVAR(ILEVEL),%edi pushq %rdi /* for Xdoreti */ So, use %edi as before. To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/arch/amd64/amd64/vector.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: knakahara Date: Mon Sep 12 02:21:11 UTC 2022 Modified Files: src/sys/arch/amd64/amd64: vector.S Log Message: Update register name at fault. Pointed out by hgutch@n.o, thanks. In vetor.S:r1.78 IDTVEC(handle_hypervisor_callback) movlCPUVAR(ILEVEL),%edi pushq %rdi /* for Xdoreti */ So, use %edi as before. To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/arch/amd64/amd64/vector.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/vector.S diff -u src/sys/arch/amd64/amd64/vector.S:1.79 src/sys/arch/amd64/amd64/vector.S:1.80 --- src/sys/arch/amd64/amd64/vector.S:1.79 Wed Sep 7 00:40:18 2022 +++ src/sys/arch/amd64/amd64/vector.S Mon Sep 12 02:21:11 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: vector.S,v 1.79 2022/09/07 00:40:18 knakahara Exp $ */ +/* $NetBSD: vector.S,v 1.80 2022/09/12 02:21:11 knakahara Exp $ */ /* * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc. @@ -728,7 +728,7 @@ ENTRY(hypervisor_callback) pushq $T_ASTFLT INTRENTRY IDTVEC(handle_hypervisor_callback) - movzbl CPUVAR(ILEVEL),%rdi + movzbl CPUVAR(ILEVEL),%edi pushq %rdi /* for Xdoreti */ incl CPUVAR(IDEPTH) movq %rsp,%rdi
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: riastradh Date: Mon Jun 27 23:36:48 UTC 2022 Modified Files: src/sys/arch/amd64/amd64: db_machdep.c Log Message: amd64: Handle __syscall trap frames specially too. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/amd64/amd64/db_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/db_machdep.c diff -u src/sys/arch/amd64/amd64/db_machdep.c:1.12 src/sys/arch/amd64/amd64/db_machdep.c:1.13 --- src/sys/arch/amd64/amd64/db_machdep.c:1.12 Sun Jun 26 22:31:12 2022 +++ src/sys/arch/amd64/amd64/db_machdep.c Mon Jun 27 23:36:48 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: db_machdep.c,v 1.12 2022/06/26 22:31:12 riastradh Exp $ */ +/* $NetBSD: db_machdep.c,v 1.13 2022/06/27 23:36:48 riastradh Exp $ */ /* * Mach Operating System @@ -26,7 +26,7 @@ * rights to redistribute these changes. */ #include -__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.12 2022/06/26 22:31:12 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.13 2022/06/27 23:36:48 riastradh Exp $"); #include #include @@ -130,7 +130,7 @@ db_nextframe(long **nextframe, long **re case SYSCALL: tf = (struct trapframe *)argp; syscallno = db_get_value((long)>tf_rax, 8, false); - if (syscallno == SYS_syscall) { + if (syscallno == SYS_syscall || syscallno == SYS___syscall) { syscallno = db_get_value((long)>tf_rdi, 8, false); (*pr)("--- syscall (number %"DDB_EXPR_FMT"u" " via SYS_syscall) ---\n",
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: riastradh Date: Mon Jun 27 23:36:48 UTC 2022 Modified Files: src/sys/arch/amd64/amd64: db_machdep.c Log Message: amd64: Handle __syscall trap frames specially too. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/amd64/amd64/db_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: riastradh Date: Sun Jun 26 22:31:12 UTC 2022 Modified Files: src/sys/arch/amd64/amd64: db_machdep.c Log Message: amd64: Print effective syscall number for SYS_syscall stack traces. This time with compile-testing, at least. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/amd64/amd64/db_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/db_machdep.c diff -u src/sys/arch/amd64/amd64/db_machdep.c:1.11 src/sys/arch/amd64/amd64/db_machdep.c:1.12 --- src/sys/arch/amd64/amd64/db_machdep.c:1.11 Sun Jun 26 22:29:28 2022 +++ src/sys/arch/amd64/amd64/db_machdep.c Sun Jun 26 22:31:12 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: db_machdep.c,v 1.11 2022/06/26 22:29:28 riastradh Exp $ */ +/* $NetBSD: db_machdep.c,v 1.12 2022/06/26 22:31:12 riastradh Exp $ */ /* * Mach Operating System @@ -26,11 +26,12 @@ * rights to redistribute these changes. */ #include -__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.11 2022/06/26 22:29:28 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.12 2022/06/26 22:31:12 riastradh Exp $"); #include #include #include +#include #include #include @@ -111,6 +112,7 @@ db_nextframe(long **nextframe, long **re struct x86_64_frame *fp; struct intrframe *ifp; int traptype, trapno, err, i; + db_expr_t syscallno; switch (is_trap) { case NONE: @@ -127,8 +129,16 @@ db_nextframe(long **nextframe, long **re case SYSCALL: tf = (struct trapframe *)argp; - (*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n", - db_get_value((long)>tf_rax, 8, false)); + syscallno = db_get_value((long)>tf_rax, 8, false); + if (syscallno == SYS_syscall) { + syscallno = db_get_value((long)>tf_rdi, 8, false); + (*pr)("--- syscall (number %"DDB_EXPR_FMT"u" + " via SYS_syscall) ---\n", + syscallno); + } else { + (*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n", + syscallno); + } return 0; case TRAP:
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: riastradh Date: Sun Jun 26 22:31:12 UTC 2022 Modified Files: src/sys/arch/amd64/amd64: db_machdep.c Log Message: amd64: Print effective syscall number for SYS_syscall stack traces. This time with compile-testing, at least. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/amd64/amd64/db_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: riastradh Date: Sun Jun 26 22:29:28 UTC 2022 Modified Files: src/sys/arch/amd64/amd64: db_machdep.c Log Message: Revert "amd64: Print effective syscall number for SYS_syscall stack traces." Built the wrong kernel (arm64 is not amd64), oops. Will redo. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amd64/amd64/db_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/db_machdep.c diff -u src/sys/arch/amd64/amd64/db_machdep.c:1.10 src/sys/arch/amd64/amd64/db_machdep.c:1.11 --- src/sys/arch/amd64/amd64/db_machdep.c:1.10 Sun Jun 26 22:18:30 2022 +++ src/sys/arch/amd64/amd64/db_machdep.c Sun Jun 26 22:29:28 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: db_machdep.c,v 1.10 2022/06/26 22:18:30 riastradh Exp $ */ +/* $NetBSD: db_machdep.c,v 1.11 2022/06/26 22:29:28 riastradh Exp $ */ /* * Mach Operating System @@ -26,7 +26,7 @@ * rights to redistribute these changes. */ #include -__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.10 2022/06/26 22:18:30 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.11 2022/06/26 22:29:28 riastradh Exp $"); #include #include @@ -111,7 +111,6 @@ db_nextframe(long **nextframe, long **re struct x86_64_frame *fp; struct intrframe *ifp; int traptype, trapno, err, i; - db_expr_t syscallno; switch (is_trap) { case NONE: @@ -128,16 +127,8 @@ db_nextframe(long **nextframe, long **re case SYSCALL: tf = (struct trapframe *)argp; - syscallno = db_get_value((long)>tf_rax, 8, false); - if (syscallno == SYS_syscall) { - syscallno = db_get_value((long)>tf_rdi, 8, false); - (*pr)("--- syscall (number %"DDB_EXPR_FMT"u" - " via SYS_syscall) ---\n", - syscallno); - } else { - (*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n", - syscallno); - } + (*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n", + db_get_value((long)>tf_rax, 8, false)); return 0; case TRAP:
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: riastradh Date: Sun Jun 26 22:29:28 UTC 2022 Modified Files: src/sys/arch/amd64/amd64: db_machdep.c Log Message: Revert "amd64: Print effective syscall number for SYS_syscall stack traces." Built the wrong kernel (arm64 is not amd64), oops. Will redo. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amd64/amd64/db_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: riastradh Date: Sun Jun 26 22:18:30 UTC 2022 Modified Files: src/sys/arch/amd64/amd64: db_machdep.c Log Message: amd64: Print effective syscall number for SYS_syscall stack traces. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/amd64/amd64/db_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/db_machdep.c diff -u src/sys/arch/amd64/amd64/db_machdep.c:1.9 src/sys/arch/amd64/amd64/db_machdep.c:1.10 --- src/sys/arch/amd64/amd64/db_machdep.c:1.9 Mon Dec 13 01:25:29 2021 +++ src/sys/arch/amd64/amd64/db_machdep.c Sun Jun 26 22:18:30 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: db_machdep.c,v 1.9 2021/12/13 01:25:29 chs Exp $ */ +/* $NetBSD: db_machdep.c,v 1.10 2022/06/26 22:18:30 riastradh Exp $ */ /* * Mach Operating System @@ -26,7 +26,7 @@ * rights to redistribute these changes. */ #include -__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.9 2021/12/13 01:25:29 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.10 2022/06/26 22:18:30 riastradh Exp $"); #include #include @@ -111,6 +111,7 @@ db_nextframe(long **nextframe, long **re struct x86_64_frame *fp; struct intrframe *ifp; int traptype, trapno, err, i; + db_expr_t syscallno; switch (is_trap) { case NONE: @@ -127,8 +128,16 @@ db_nextframe(long **nextframe, long **re case SYSCALL: tf = (struct trapframe *)argp; - (*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n", - db_get_value((long)>tf_rax, 8, false)); + syscallno = db_get_value((long)>tf_rax, 8, false); + if (syscallno == SYS_syscall) { + syscallno = db_get_value((long)>tf_rdi, 8, false); + (*pr)("--- syscall (number %"DDB_EXPR_FMT"u" + " via SYS_syscall) ---\n", + syscallno); + } else { + (*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n", + syscallno); + } return 0; case TRAP:
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: riastradh Date: Sun Jun 26 22:18:30 UTC 2022 Modified Files: src/sys/arch/amd64/amd64: db_machdep.c Log Message: amd64: Print effective syscall number for SYS_syscall stack traces. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/amd64/amd64/db_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: riastradh Date: Sun May 23 08:59:08 UTC 2021 Modified Files: src/sys/arch/amd64/amd64: db_disasm.c Log Message: ddb/amd64: Don't go out of the way to detect invalid addresses. db_disasm had logic to detect invalid addresses before trying to disassemble them. But when disassembling a null instruction address, the logic to detect invalid addresses itself tried to dereference an invalid address. db_get_value can already handle this situation gracefully, so there is no need for this faulty fault-avoidance logic. Fixes double-fault in ddb on calling null function pointers. With any luck, this should make diagnosing such bugs easier in the future! To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/arch/amd64/amd64/db_disasm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: riastradh Date: Sun May 23 08:59:08 UTC 2021 Modified Files: src/sys/arch/amd64/amd64: db_disasm.c Log Message: ddb/amd64: Don't go out of the way to detect invalid addresses. db_disasm had logic to detect invalid addresses before trying to disassemble them. But when disassembling a null instruction address, the logic to detect invalid addresses itself tried to dereference an invalid address. db_get_value can already handle this situation gracefully, so there is no need for this faulty fault-avoidance logic. Fixes double-fault in ddb on calling null function pointers. With any luck, this should make diagnosing such bugs easier in the future! To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/arch/amd64/amd64/db_disasm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/db_disasm.c diff -u src/sys/arch/amd64/amd64/db_disasm.c:1.27 src/sys/arch/amd64/amd64/db_disasm.c:1.28 --- src/sys/arch/amd64/amd64/db_disasm.c:1.27 Sat Mar 9 08:42:25 2019 +++ src/sys/arch/amd64/amd64/db_disasm.c Sun May 23 08:59:08 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: db_disasm.c,v 1.27 2019/03/09 08:42:25 maxv Exp $ */ +/* $NetBSD: db_disasm.c,v 1.28 2021/05/23 08:59:08 riastradh Exp $ */ /* * Mach Operating System @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.27 2019/03/09 08:42:25 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.28 2021/05/23 08:59:08 riastradh Exp $"); #ifndef _KERNEL #include @@ -1191,33 +1191,8 @@ db_disasm(db_addr_t loc, bool altfmt) uint64_t imm64; int len; struct i_addr address; -#ifdef _KERNEL - pt_entry_t *pte, *pde; -#endif u_int rex = 0; -#ifdef _KERNEL - /* - * Don't try to disassemble the location if the mapping is invalid. - * If we do, we'll fault, and end up debugging the debugger! - * in the case of largepages, "pte" is really the pde and "pde" is - * really the entry for the pdp itself. - */ - if ((vaddr_t)loc >= VM_MIN_KERNEL_ADDRESS) - pte = kvtopte((vaddr_t)loc); - else - pte = vtopte((vaddr_t)loc); - if ((vaddr_t)pte >= VM_MIN_KERNEL_ADDRESS) - pde = kvtopte((vaddr_t)pte); - else - pde = vtopte((vaddr_t)pte); - - if ((*pde & PTE_P) == 0 || (*pte & PTE_P) == 0) { - db_printf("invalid address\n"); - return (loc); - } -#endif - get_value_inc(inst, loc, 1, false); short_addr = false; size = LONG;
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: simonb Date: Sun Jan 24 14:17:11 UTC 2021 Modified Files: src/sys/arch/amd64/amd64: machdep.c Log Message: Fix a tyop in a comment. To generate a diff of this commit: cvs rdiff -u -r1.357 -r1.358 src/sys/arch/amd64/amd64/machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/machdep.c diff -u src/sys/arch/amd64/amd64/machdep.c:1.357 src/sys/arch/amd64/amd64/machdep.c:1.358 --- src/sys/arch/amd64/amd64/machdep.c:1.357 Mon Sep 7 00:47:27 2020 +++ src/sys/arch/amd64/amd64/machdep.c Sun Jan 24 14:17:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.357 2020/09/07 00:47:27 mrg Exp $ */ +/* $NetBSD: machdep.c,v 1.358 2021/01/24 14:17:10 simonb Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011 @@ -110,7 +110,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.357 2020/09/07 00:47:27 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.358 2021/01/24 14:17:10 simonb Exp $"); #include "opt_modular.h" #include "opt_user_ldt.h" @@ -344,7 +344,7 @@ cpu_startup(void) consinit(); /* - * Initialize error message buffer (et end of core). + * Initialize error message buffer (at end of core). */ if (msgbuf_p_cnt == 0) panic("msgbuf paddr map has not been set up");
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: simonb Date: Sun Jan 24 14:17:11 UTC 2021 Modified Files: src/sys/arch/amd64/amd64: machdep.c Log Message: Fix a tyop in a comment. To generate a diff of this commit: cvs rdiff -u -r1.357 -r1.358 src/sys/arch/amd64/amd64/machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: thorpej Date: Fri Nov 20 17:44:56 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: netbsd32_machdep.c Log Message: malloc(9) -> kmem(9) To generate a diff of this commit: cvs rdiff -u -r1.136 -r1.137 src/sys/arch/amd64/amd64/netbsd32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/netbsd32_machdep.c diff -u src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.136 src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.137 --- src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.136 Sat Apr 25 15:26:16 2020 +++ src/sys/arch/amd64/amd64/netbsd32_machdep.c Fri Nov 20 17:44:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_machdep.c,v 1.136 2020/04/25 15:26:16 bouyer Exp $ */ +/* $NetBSD: netbsd32_machdep.c,v 1.137 2020/11/20 17:44:56 thorpej Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.136 2020/04/25 15:26:16 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.137 2020/11/20 17:44:56 thorpej Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -50,7 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_mac #include #include #include -#include +#include #include #include #include @@ -632,14 +632,16 @@ x86_64_set_ldt32(struct lwp *l, void *ar if (ua.num < 0 || ua.num > MAX_USERLDT_SLOTS) return EINVAL; - descv = malloc(sizeof(*descv) * ua.num, M_TEMP, M_WAITOK); + const size_t alloc_size = sizeof(*descv) * ua.num; + + descv = kmem_alloc(alloc_size, KM_SLEEP); error = copyin((void *)(uintptr_t)ua32.desc, descv, sizeof(*descv) * ua.num); if (error == 0) error = x86_set_ldt1(l, , descv); *retval = ua.start; - free(descv, M_TEMP); + kmem_free(descv, alloc_size); return error; } @@ -660,14 +662,16 @@ x86_64_get_ldt32(struct lwp *l, void *ar if (ua.num < 0 || ua.num > MAX_USERLDT_SLOTS) return EINVAL; - cp = malloc(ua.num * sizeof(union descriptor), M_TEMP, M_WAITOK); + const size_t alloc_size = ua.num * sizeof(union descriptor); + + cp = kmem_alloc(alloc_size, KM_SLEEP); error = x86_get_ldt1(l, , cp); *retval = ua.num; if (error == 0) error = copyout(cp, (void *)(uintptr_t)ua32.desc, ua.num * sizeof(*cp)); - free(cp, M_TEMP); + kmem_free(cp, alloc_size); return error; } #endif
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: thorpej Date: Fri Nov 20 17:44:56 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: netbsd32_machdep.c Log Message: malloc(9) -> kmem(9) To generate a diff of this commit: cvs rdiff -u -r1.136 -r1.137 src/sys/arch/amd64/amd64/netbsd32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: mrg Date: Mon Sep 7 00:47:27 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: machdep.c Log Message: adjust some fallback code to be slightly less ugly and avoid upsetting GCC 9. To generate a diff of this commit: cvs rdiff -u -r1.356 -r1.357 src/sys/arch/amd64/amd64/machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/machdep.c diff -u src/sys/arch/amd64/amd64/machdep.c:1.356 src/sys/arch/amd64/amd64/machdep.c:1.357 --- src/sys/arch/amd64/amd64/machdep.c:1.356 Tue Jul 14 00:45:52 2020 +++ src/sys/arch/amd64/amd64/machdep.c Mon Sep 7 00:47:27 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.356 2020/07/14 00:45:52 yamaguchi Exp $ */ +/* $NetBSD: machdep.c,v 1.357 2020/09/07 00:47:27 mrg Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011 @@ -110,7 +110,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.356 2020/07/14 00:45:52 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.357 2020/09/07 00:47:27 mrg Exp $"); #include "opt_modular.h" #include "opt_user_ldt.h" @@ -1518,9 +1518,12 @@ init_x86_64_ksyms(void) tesym = (vaddr_t)symtab->esym + KERNBASE; #endif ksyms_addsyms_elf(symtab->nsym, (void *)tssym, (void *)tesym); - } else - ksyms_addsyms_elf(*(long *)(void *), - ((long *)(void *)) + 1, esym); + } else { + uintptr_t endp = (uintptr_t)(void *) + + ksyms_addsyms_elf(*(long *)endp, + ((long *)endp) + 1, esym); + } #endif } #endif /* XENPV */
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: mrg Date: Mon Sep 7 00:47:27 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: machdep.c Log Message: adjust some fallback code to be slightly less ugly and avoid upsetting GCC 9. To generate a diff of this commit: cvs rdiff -u -r1.356 -r1.357 src/sys/arch/amd64/amd64/machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Sat Aug 29 07:16:04 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: spl.S Log Message: 'doreti_checkast' isn't global anymore, localify. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/arch/amd64/amd64/spl.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/spl.S diff -u src/sys/arch/amd64/amd64/spl.S:1.46 src/sys/arch/amd64/amd64/spl.S:1.47 --- src/sys/arch/amd64/amd64/spl.S:1.46 Sun May 17 12:11:11 2020 +++ src/sys/arch/amd64/amd64/spl.S Sat Aug 29 07:16:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: spl.S,v 1.46 2020/05/17 12:11:11 ad Exp $ */ +/* $NetBSD: spl.S,v 1.47 2020/08/29 07:16:03 maxv Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -331,9 +331,7 @@ IDTVEC(doreti) 5: testb $SEL_RPL,TF_CS(%rsp) jz 6f - - .type _C_LABEL(doreti_checkast), @function -LABEL(doreti_checkast) +.Ldoreti_checkast: movq CPUVAR(CURLWP),%r14 CHECK_ASTPENDING(%r14) je 3f @@ -345,7 +343,7 @@ LABEL(doreti_checkast) KMSAN_INIT_ARG(8) call _C_LABEL(trap) CLI(si) - jmp doreti_checkast + jmp .Ldoreti_checkast 3: CHECK_DEFERRED_SWITCH jnz 9f @@ -356,6 +354,5 @@ LABEL(doreti_checkast) STI(si) call _C_LABEL(do_pmap_load) CLI(si) - jmp doreti_checkast /* recheck ASTs */ -END(doreti_checkast) + jmp .Ldoreti_checkast /* recheck ASTs */ IDTVEC_END(doreti)
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Sat Aug 29 07:16:04 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: spl.S Log Message: 'doreti_checkast' isn't global anymore, localify. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/arch/amd64/amd64/spl.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: bouyer Date: Sun Jun 21 16:57:18 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: amd64_trap.S locore.S Log Message: On amd64, Xen PV calls syscalls and traps with events enabled. Disable events on entry to be safe. It should have been mostly safe for most cases, but for FPU traps we need to reload the FPU state if we got interrupted at trap entry. Hopefully fixes: panic: kernel diagnostic assertion "curlwp->l_md.md_flags & MDL_FPU_IN_CPU" failed: file "/home/source/ab/HEAD/src/sys/arch/x86/x86/fpu.c", line 524 when running tests. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/arch/amd64/amd64/amd64_trap.S cvs rdiff -u -r1.209 -r1.210 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: bouyer Date: Sun Jun 21 16:57:18 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: amd64_trap.S locore.S Log Message: On amd64, Xen PV calls syscalls and traps with events enabled. Disable events on entry to be safe. It should have been mostly safe for most cases, but for FPU traps we need to reload the FPU state if we got interrupted at trap entry. Hopefully fixes: panic: kernel diagnostic assertion "curlwp->l_md.md_flags & MDL_FPU_IN_CPU" failed: file "/home/source/ab/HEAD/src/sys/arch/x86/x86/fpu.c", line 524 when running tests. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/arch/amd64/amd64/amd64_trap.S cvs rdiff -u -r1.209 -r1.210 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/amd64_trap.S diff -u src/sys/arch/amd64/amd64/amd64_trap.S:1.51 src/sys/arch/amd64/amd64/amd64_trap.S:1.52 --- src/sys/arch/amd64/amd64/amd64_trap.S:1.51 Sat Dec 7 10:19:35 2019 +++ src/sys/arch/amd64/amd64/amd64_trap.S Sun Jun 21 16:57:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: amd64_trap.S,v 1.51 2019/12/07 10:19:35 maxv Exp $ */ +/* $NetBSD: amd64_trap.S,v 1.52 2020/06/21 16:57:18 bouyer Exp $ */ /* * Copyright (c) 1998, 2007, 2008, 2017 The NetBSD Foundation, Inc. @@ -90,7 +90,7 @@ */ #ifdef XENPV -#define PRE_TRAP movq (%rsp),%rcx ; movq 8(%rsp),%r11 ; addq $0x10,%rsp +#define PRE_TRAP CLI(cx); movq (%rsp),%rcx ; movq 8(%rsp),%r11 ; addq $0x10,%rsp #else #define PRE_TRAP #endif @@ -231,9 +231,9 @@ IDTVEC(trap01) movw %ds,TF_DS(%rsp) jmp .Lalltraps_noentry -#else +#else /* !XENPV */ ZTRAP(T_TRCTRAP) -#endif +#endif /* !XENPV */ IDTVEC_END(trap01) /* @@ -250,7 +250,7 @@ IDTVEC_END(trap01) IDTVEC(trap02) #if defined(XENPV) ZTRAP(T_NMI) -#else +#else /* XENPV */ ZTRAP_NJ(T_NMI) subq $TF_REGSIZE,%rsp INTR_SAVE_GPRS @@ -299,7 +299,7 @@ IDTVEC(trap02) INTR_RESTORE_GPRS addq $TF_REGSIZE+16,%rsp iretq -#endif +#endif /* XENPV */ IDTVEC_END(trap02) IDTVEC(trap03) @@ -361,7 +361,7 @@ IDTVEC_END(trap07) IDTVEC(trap08) #if defined(XENPV) TRAP(T_DOUBLEFLT) -#else +#else /* XENPV */ TRAP_NJ(T_DOUBLEFLT) subq $TF_REGSIZE,%rsp INTR_SAVE_GPRS @@ -396,7 +396,7 @@ IDTVEC(trap08) INTR_RESTORE_GPRS addq $TF_REGSIZE+16,%rsp iretq -#endif +#endif /* XENPV */ IDTVEC_END(trap08) IDTVEC(trap09) @@ -414,7 +414,7 @@ IDTVEC_END(trap10) * in order to copy the user segment registers into the fault frame. */ #define kernuser_reenter alltraps -#endif +#endif /* XENPV */ IDTVEC(trap11) /* #NP() Segment not present */ TRAP_NJ(T_SEGNPFLT) @@ -448,6 +448,14 @@ IDTVEC(trap16) ZTRAP_NJ(T_ARITHTRAP) .Ldo_fputrap: INTRENTRY +#ifdef XENPV + /* traps are called with interrupts enabled, and we may have been + * interrupted just before the CLI in the trap macro. + * we have to check if a FPU reload is needed. + */ + movqCPUVAR(CURLWP),%r14 + HANDLE_DEFERRED_FPU +#endif /* XENPV */ #ifdef DIAGNOSTIC movl CPUVAR(ILEVEL),%ebx #endif Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.209 src/sys/arch/amd64/amd64/locore.S:1.210 --- src/sys/arch/amd64/amd64/locore.S:1.209 Wed May 27 19:33:40 2020 +++ src/sys/arch/amd64/amd64/locore.S Sun Jun 21 16:57:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.209 2020/05/27 19:33:40 ad Exp $ */ +/* $NetBSD: locore.S,v 1.210 2020/06/21 16:57:18 bouyer Exp $ */ /* * Copyright-o-rama! @@ -1481,7 +1481,13 @@ IDTVEC(\name) movq $2,TF_ERR(%rsp) /* syscall instruction size */ movq $T_ASTFLT,TF_TRAPNO(%rsp) #else - /* Xen already switched to kernel stack */ + /* + * Xen already switched to kernel stack. + * But it didn't disable events + */ + pushq %rsi + CLI(si) + popq %rsi addq $0x10,%rsp /* gap to match cs:rip */ pushq $2 /* error code */ pushq $T_ASTFLT @@ -1524,6 +1530,9 @@ IDTVEC_END(syscall32) TEXT_USER_BEGIN IDTVEC(osyscall) #ifdef XENPV + pushq %rsi + CLI(si) + popq %rsi movq (%rsp),%rcx movq 8(%rsp),%r11 addq $0x10,%rsp
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Sat Jun 6 07:03:21 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: db_machdep.c Log Message: If the frame is not aligned, leave right away. This place probably needs to be revisited, because %rbp could easily contain garbage. Reported-by: syzbot+ecb40cf7f8acc102c...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/amd64/amd64/db_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/db_machdep.c diff -u src/sys/arch/amd64/amd64/db_machdep.c:1.7 src/sys/arch/amd64/amd64/db_machdep.c:1.8 --- src/sys/arch/amd64/amd64/db_machdep.c:1.7 Thu May 14 16:57:53 2020 +++ src/sys/arch/amd64/amd64/db_machdep.c Sat Jun 6 07:03:21 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: db_machdep.c,v 1.7 2020/05/14 16:57:53 maxv Exp $ */ +/* $NetBSD: db_machdep.c,v 1.8 2020/06/06 07:03:21 maxv Exp $ */ /* * Mach Operating System @@ -26,7 +26,7 @@ * rights to redistribute these changes. */ #include -__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.7 2020/05/14 16:57:53 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.8 2020/06/06 07:03:21 maxv Exp $"); #include #include @@ -151,6 +151,8 @@ db_nextframe(long **nextframe, long **re db_get_value((long)>tf_rbp, 8, false); if (fp == NULL) return 0; + if (((uintptr_t)fp & 7) != 0) + return 0; *nextframe = (long *)>f_frame; *retaddr = (long *)>f_retaddr; *arg0 = (long *)>f_arg0;
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Sat Jun 6 07:03:21 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: db_machdep.c Log Message: If the frame is not aligned, leave right away. This place probably needs to be revisited, because %rbp could easily contain garbage. Reported-by: syzbot+ecb40cf7f8acc102c...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/amd64/amd64/db_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: ad Date: Wed May 27 20:48:43 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: cpufunc.S Log Message: - mismatched END pointed out by maxv@ - ditch the frame, tracer should be able to deal without it in leaf on x86_64 To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/sys/arch/amd64/amd64/cpufunc.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/cpufunc.S diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.57 src/sys/arch/amd64/amd64/cpufunc.S:1.58 --- src/sys/arch/amd64/amd64/cpufunc.S:1.57 Wed May 27 19:33:40 2020 +++ src/sys/arch/amd64/amd64/cpufunc.S Wed May 27 20:48:42 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.S,v 1.57 2020/05/27 19:33:40 ad Exp $ */ +/* $NetBSD: cpufunc.S,v 1.58 2020/05/27 20:48:42 ad Exp $ */ /* * Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc. @@ -422,22 +422,16 @@ ENTRY(outl) END(outl) ENTRY(x86_stos) - pushq %rbp - movq %rsp,%rbp movq %rsi,%rax movq %rdx,%rcx rep stosq - leave ret END(x86_stos) ENTRY(x86_movs) - pushq %rbp - movq %rsp,%rbp movq %rdx,%rcx rep movsq - leave ret -END(x86_stos) +END(x86_movs)
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: ad Date: Wed May 27 20:48:43 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: cpufunc.S Log Message: - mismatched END pointed out by maxv@ - ditch the frame, tracer should be able to deal without it in leaf on x86_64 To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/sys/arch/amd64/amd64/cpufunc.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Wed May 20 18:52:48 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: cpufunc.S Log Message: this is kmsan To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/arch/amd64/amd64/cpufunc.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Wed May 20 18:52:48 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: cpufunc.S Log Message: this is kmsan To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/arch/amd64/amd64/cpufunc.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/cpufunc.S diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.55 src/sys/arch/amd64/amd64/cpufunc.S:1.56 --- src/sys/arch/amd64/amd64/cpufunc.S:1.55 Wed May 20 18:39:25 2020 +++ src/sys/arch/amd64/amd64/cpufunc.S Wed May 20 18:52:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.S,v 1.55 2020/05/20 18:39:25 ad Exp $ */ +/* $NetBSD: cpufunc.S,v 1.56 2020/05/20 18:52:48 maxv Exp $ */ /* * Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc. @@ -206,7 +206,8 @@ ENTRY(x86_hotpatch) END(x86_hotpatch) #endif /* !XENPV */ -/* Could be exact same as cpu_counter but for KASAN fussiness. */ +/* Could be exact same as cpu_counter, but KMSAN needs to have the correct + * size of the return value. */ ENTRY(cpu_counter32) movq CPUVAR(CURLWP), %rcx 1:
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: ad Date: Wed May 20 18:39:25 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: cpufunc.S Log Message: Deal with KMSAN fussiness. Pointed out by msaitoh@. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sys/arch/amd64/amd64/cpufunc.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: ad Date: Wed May 20 18:39:25 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: cpufunc.S Log Message: Deal with KMSAN fussiness. Pointed out by msaitoh@. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sys/arch/amd64/amd64/cpufunc.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/cpufunc.S diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.54 src/sys/arch/amd64/amd64/cpufunc.S:1.55 --- src/sys/arch/amd64/amd64/cpufunc.S:1.54 Tue May 19 21:54:10 2020 +++ src/sys/arch/amd64/amd64/cpufunc.S Wed May 20 18:39:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.S,v 1.54 2020/05/19 21:54:10 ad Exp $ */ +/* $NetBSD: cpufunc.S,v 1.55 2020/05/20 18:39:25 ad Exp $ */ /* * Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc. @@ -206,7 +206,23 @@ ENTRY(x86_hotpatch) END(x86_hotpatch) #endif /* !XENPV */ -ENTRY(tsc_get_timecount) +/* Could be exact same as cpu_counter but for KASAN fussiness. */ +ENTRY(cpu_counter32) + movq CPUVAR(CURLWP), %rcx +1: + movq L_NCSW(%rcx), %rdi + rdtsc + addl CPUVAR(CC_SKEW), %eax + cmpq %rdi, L_NCSW(%rcx) + jne 2f + KMSAN_INIT_RET(4) + ret +2: + jmp 1b +END(cpu_counter32) +STRONG_ALIAS(tsc_get_timecount, cpu_counter32) + +ENTRY(cpu_counter) movq CPUVAR(CURLWP), %rcx 1: movq L_NCSW(%rcx), %rdi @@ -216,14 +232,11 @@ ENTRY(tsc_get_timecount) addq CPUVAR(CC_SKEW), %rax cmpq %rdi, L_NCSW(%rcx) jne 2f - KMSAN_INIT_RET(4) + KMSAN_INIT_RET(8) ret 2: jmp 1b -END(tsc_get_timecount) - -STRONG_ALIAS(cpu_counter, tsc_get_timecount) -STRONG_ALIAS(cpu_counter32, tsc_get_timecount) +END(cpu_counter) ENTRY(rdmsr_safe) movq CPUVAR(CURLWP), %r8
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: ad Date: Tue May 19 21:54:10 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: cpufunc.S Log Message: xen needs the TSC funcs too To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/sys/arch/amd64/amd64/cpufunc.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/cpufunc.S diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.53 src/sys/arch/amd64/amd64/cpufunc.S:1.54 --- src/sys/arch/amd64/amd64/cpufunc.S:1.53 Tue May 19 21:40:55 2020 +++ src/sys/arch/amd64/amd64/cpufunc.S Tue May 19 21:54:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.S,v 1.53 2020/05/19 21:40:55 ad Exp $ */ +/* $NetBSD: cpufunc.S,v 1.54 2020/05/19 21:54:10 ad Exp $ */ /* * Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc. @@ -167,25 +167,6 @@ END(x86_write_flags) STRONG_ALIAS(x86_write_psl,x86_write_flags) -ENTRY(tsc_get_timecount) - movq CPUVAR(CURLWP), %rcx -1: - movq L_NCSW(%rcx), %rdi - rdtsc - shlq $32, %rdx - orq %rdx, %rax - addq CPUVAR(CC_SKEW), %rax - cmpq %rdi, L_NCSW(%rcx) - jne 2f - KMSAN_INIT_RET(4) - ret -2: - jmp 1b -END(tsc_get_timecount) - -STRONG_ALIAS(cpu_counter, tsc_get_timecount) -STRONG_ALIAS(cpu_counter32, tsc_get_timecount) - /* * %rdi = name * %rsi = sel @@ -225,6 +206,25 @@ ENTRY(x86_hotpatch) END(x86_hotpatch) #endif /* !XENPV */ +ENTRY(tsc_get_timecount) + movq CPUVAR(CURLWP), %rcx +1: + movq L_NCSW(%rcx), %rdi + rdtsc + shlq $32, %rdx + orq %rdx, %rax + addq CPUVAR(CC_SKEW), %rax + cmpq %rdi, L_NCSW(%rcx) + jne 2f + KMSAN_INIT_RET(4) + ret +2: + jmp 1b +END(tsc_get_timecount) + +STRONG_ALIAS(cpu_counter, tsc_get_timecount) +STRONG_ALIAS(cpu_counter32, tsc_get_timecount) + ENTRY(rdmsr_safe) movq CPUVAR(CURLWP), %r8 movq L_PCB(%r8), %r8
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: ad Date: Tue May 19 21:54:10 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: cpufunc.S Log Message: xen needs the TSC funcs too To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/sys/arch/amd64/amd64/cpufunc.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: ad Date: Sun May 17 12:11:11 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: spl.S Log Message: comments To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/arch/amd64/amd64/spl.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/spl.S diff -u src/sys/arch/amd64/amd64/spl.S:1.45 src/sys/arch/amd64/amd64/spl.S:1.46 --- src/sys/arch/amd64/amd64/spl.S:1.45 Sat May 2 11:12:49 2020 +++ src/sys/arch/amd64/amd64/spl.S Sun May 17 12:11:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: spl.S,v 1.45 2020/05/02 11:12:49 maxv Exp $ */ +/* $NetBSD: spl.S,v 1.46 2020/05/17 12:11:11 ad Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -157,7 +157,12 @@ IDTVEC(softintr) movq L_PCB(%r15),%rcx movq PCB_RSP(%rcx),%rsp - xchgq %r15,CPUVAR(CURLWP) /* must be globally visible */ + /* + * for non-interlocked mutex release to work safely the change + * to ci_curlwp must not languish in the store buffer. therefore + * we use XCHG and not MOV here. see kern_mutex.c. + */ + xchgq %r15,CPUVAR(CURLWP) /* restore curlwp */ popq %r15 /* unwind switchframe */ addq $(5 * 8),%rsp jmp *%r13 /* back to Xspllower/Xdoreti */
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: ad Date: Sun May 17 12:11:11 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: spl.S Log Message: comments To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/arch/amd64/amd64/spl.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Thu May 14 16:57:53 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: db_machdep.c Log Message: Don't even try to go past a syscall. Fixes severe panic recursions in KUBSAN. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/amd64/amd64/db_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/db_machdep.c diff -u src/sys/arch/amd64/amd64/db_machdep.c:1.6 src/sys/arch/amd64/amd64/db_machdep.c:1.7 --- src/sys/arch/amd64/amd64/db_machdep.c:1.6 Fri Mar 16 08:48:34 2018 +++ src/sys/arch/amd64/amd64/db_machdep.c Thu May 14 16:57:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: db_machdep.c,v 1.6 2018/03/16 08:48:34 maxv Exp $ */ +/* $NetBSD: db_machdep.c,v 1.7 2020/05/14 16:57:53 maxv Exp $ */ /* * Mach Operating System @@ -26,7 +26,7 @@ * rights to redistribute these changes. */ #include -__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.6 2018/03/16 08:48:34 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.7 2020/05/14 16:57:53 maxv Exp $"); #include #include @@ -125,22 +125,23 @@ db_nextframe(long **nextframe, long **re *arg0 = (long *)>f_arg0; break; - case TRAP: case SYSCALL: + tf = (struct trapframe *)argp; + (*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n", + db_get_value((long)>tf_rax, 8, false)); + return 0; + + case TRAP: case INTERRUPT: default: - /* The only argument to trap() or syscall() is the trapframe. */ + /* The only argument to trap() is the trapframe. */ tf = (struct trapframe *)argp; switch (is_trap) { case TRAP: (*pr)("--- trap (number %"DDB_EXPR_FMT"u) ---\n", db_get_value((long)>tf_trapno, 8, false)); break; - case SYSCALL: - (*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n", -db_get_value((long)>tf_rax, 8, false)); - break; case INTERRUPT: (*pr)("--- interrupt ---\n"); break;
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Thu May 14 16:57:53 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: db_machdep.c Log Message: Don't even try to go past a syscall. Fixes severe panic recursions in KUBSAN. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/amd64/amd64/db_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: ad Date: Fri May 8 21:58:03 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: cpufunc.S Log Message: cpu_counter: only need to clear %eax (zero extends). To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/arch/amd64/amd64/cpufunc.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/cpufunc.S diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.51 src/sys/arch/amd64/amd64/cpufunc.S:1.52 --- src/sys/arch/amd64/amd64/cpufunc.S:1.51 Sat May 2 17:14:01 2020 +++ src/sys/arch/amd64/amd64/cpufunc.S Fri May 8 21:58:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.S,v 1.51 2020/05/02 17:14:01 bouyer Exp $ */ +/* $NetBSD: cpufunc.S,v 1.52 2020/05/08 21:58:03 ad Exp $ */ /* * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc. @@ -253,7 +253,7 @@ ENTRY(msr_onfault) END(msr_onfault) ENTRY(cpu_counter) - xorq %rax, %rax + xorl %eax, %eax rdtsc shlq $32, %rdx orq %rdx, %rax
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: ad Date: Fri May 8 21:58:03 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: cpufunc.S Log Message: cpu_counter: only need to clear %eax (zero extends). To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/arch/amd64/amd64/cpufunc.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Tue May 5 06:32:43 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: Fix KASAN, init_xen_early must be called after kasan_early_init. To generate a diff of this commit: cvs rdiff -u -r1.207 -r1.208 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.207 src/sys/arch/amd64/amd64/locore.S:1.208 --- src/sys/arch/amd64/amd64/locore.S:1.207 Sat May 2 19:01:08 2020 +++ src/sys/arch/amd64/amd64/locore.S Tue May 5 06:32:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.207 2020/05/02 19:01:08 christos Exp $ */ +/* $NetBSD: locore.S,v 1.208 2020/05/05 06:32:43 maxv Exp $ */ /* * Copyright-o-rama! @@ -991,14 +991,15 @@ longmode_hi: #endif /* XENPV */ pushq %rdi -#if defined(XEN) && !defined(XENPV) - call _C_LABEL(init_xen_early) -#endif call _C_LABEL(init_bootspace) #ifdef KASAN movq _C_LABEL(lwp0uarea)(%rip),%rdi call _C_LABEL(kasan_early_init) #endif + /* <-- DO NOT INSERT C CALLS BEFORE THIS POINT --> */ +#if defined(XEN) && !defined(XENPV) + call _C_LABEL(init_xen_early) +#endif call _C_LABEL(init_slotspace) popq %rdi call _C_LABEL(init_x86_64)
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Tue May 5 06:32:43 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: Fix KASAN, init_xen_early must be called after kasan_early_init. To generate a diff of this commit: cvs rdiff -u -r1.207 -r1.208 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: christos Date: Sat May 2 19:01:08 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: Fix build without XEN To generate a diff of this commit: cvs rdiff -u -r1.206 -r1.207 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.206 src/sys/arch/amd64/amd64/locore.S:1.207 --- src/sys/arch/amd64/amd64/locore.S:1.206 Sat May 2 12:44:34 2020 +++ src/sys/arch/amd64/amd64/locore.S Sat May 2 15:01:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.206 2020/05/02 16:44:34 bouyer Exp $ */ +/* $NetBSD: locore.S,v 1.207 2020/05/02 19:01:08 christos Exp $ */ /* * Copyright-o-rama! @@ -1005,7 +1005,8 @@ longmode_hi: call _C_LABEL(main) END(start) -#ifndef XENPV +#if defined(XEN) +# if !defined(XENPV) /* entry point for Xen PVH */ .code32 ENTRY(start_xen32) @@ -1062,8 +1063,7 @@ ENTRY(start_xen32) jmp .Lbiosbasemem_finished END(start_xen32) .code64 -#endif /* XENPV */ -#if defined(XEN) +# endif /* !XENPV */ /* space for the hypercall call page */ #define HYPERCALL_PAGE_OFFSET 0x1000 .align HYPERCALL_PAGE_OFFSET
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: christos Date: Sat May 2 19:01:08 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: Fix build without XEN To generate a diff of this commit: cvs rdiff -u -r1.206 -r1.207 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Sat May 2 11:12:50 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: spl.S Log Message: Remove unused. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/arch/amd64/amd64/spl.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/spl.S diff -u src/sys/arch/amd64/amd64/spl.S:1.44 src/sys/arch/amd64/amd64/spl.S:1.45 --- src/sys/arch/amd64/amd64/spl.S:1.44 Sat Apr 25 15:26:16 2020 +++ src/sys/arch/amd64/amd64/spl.S Sat May 2 11:12:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: spl.S,v 1.44 2020/04/25 15:26:16 bouyer Exp $ */ +/* $NetBSD: spl.S,v 1.45 2020/05/02 11:12:49 maxv Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -187,7 +187,6 @@ ENTRY(softint_trigger) ret END(softint_trigger) - /* * Xrecurse_preempt() * @@ -255,10 +254,7 @@ ENTRY(spllower) 2: movq %r8,%rbx jmp _C_LABEL(Xspllower) - - .align 16 END(spllower) -LABEL(spllower_end) /* * void Xspllower(int s); @@ -277,9 +273,6 @@ LABEL(spllower_end) * the sending CPU will never see the that CPU accept the IPI * (see pmap_tlb_shootnow). */ - nop - .align 4 /* Avoid confusion with cx8_spllower_end */ - IDTVEC(spllower) pushq %rbx pushq %r13
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Sat May 2 11:12:50 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: spl.S Log Message: Remove unused. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/arch/amd64/amd64/spl.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Fri May 1 07:03:02 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: vector.S Log Message: Explicitly align to 8 bytes, found by kUBSan. Reported-by: syzbot+f1e1561ed739db869...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sys/arch/amd64/amd64/vector.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/vector.S diff -u src/sys/arch/amd64/amd64/vector.S:1.75 src/sys/arch/amd64/amd64/vector.S:1.76 --- src/sys/arch/amd64/amd64/vector.S:1.75 Mon Apr 27 16:55:50 2020 +++ src/sys/arch/amd64/amd64/vector.S Fri May 1 07:03:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vector.S,v 1.75 2020/04/27 16:55:50 bouyer Exp $ */ +/* $NetBSD: vector.S,v 1.76 2020/05/01 07:03:02 maxv Exp $ */ /* * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc. @@ -630,6 +630,7 @@ INTRSTUB(x2apic_level,31,voidop,x2apic_a */ #define INTRSTUB_ARRAY_16(name) ; \ .type _C_LABEL(name ## _stubs), @object ; \ + .align 8; \ LABEL(name ## _stubs); \ INTRSTUB_ENTRY(name ## 0) ; \ INTRSTUB_ENTRY(name ## 1) ; \ @@ -654,6 +655,7 @@ END(name ## _stubs) */ #define INTRSTUB_ARRAY_32(name) ; \ .type _C_LABEL(name ## _stubs), @object ; \ + .align 8; \ LABEL(name ## _stubs); \ INTRSTUB_ENTRY(name ## 0) ; \ INTRSTUB_ENTRY(name ## 1) ; \ @@ -745,6 +747,7 @@ END(entry_xenev) .quad entry_xenev , _C_LABEL(Xrecurse_ ## name ## sir); \ .quad _C_LABEL(Xresume_ ## name ## sir); + .align 8 LABEL(xenev_stubs) XENINTRSTUB_ENTRY(xenev, SIR_XENIPL_VM) ; XENINTRSTUB_ENTRY(xenev, SIR_XENIPL_SCHED) ;
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Fri May 1 07:03:02 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: vector.S Log Message: Explicitly align to 8 bytes, found by kUBSan. Reported-by: syzbot+f1e1561ed739db869...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sys/arch/amd64/amd64/vector.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Thu Apr 30 17:21:12 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: The labels are already global, drop unused. To generate a diff of this commit: cvs rdiff -u -r1.203 -r1.204 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Thu Apr 30 17:21:12 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: The labels are already global, drop unused. To generate a diff of this commit: cvs rdiff -u -r1.203 -r1.204 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.203 src/sys/arch/amd64/amd64/locore.S:1.204 --- src/sys/arch/amd64/amd64/locore.S:1.203 Thu Apr 30 17:17:33 2020 +++ src/sys/arch/amd64/amd64/locore.S Thu Apr 30 17:21:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.203 2020/04/30 17:17:33 maxv Exp $ */ +/* $NetBSD: locore.S,v 1.204 2020/04/30 17:21:12 maxv Exp $ */ /* * Copyright-o-rama! @@ -1610,11 +1610,6 @@ LABEL(hp_stac) LABEL(hp_stac_end) #ifdef SVS - .globl svs_enter, svs_enter_end - .globl svs_enter_altstack, svs_enter_altstack_end - .globl svs_leave, svs_leave_end - .globl svs_leave_altstack, svs_leave_altstack_end - LABEL(svs_enter) movabs SVS_UTLS+UTLS_KPDIRPA,%rax movq %rax,%cr3 @@ -1656,9 +1651,6 @@ LABEL(svs_leave_nmi) LABEL(svs_leave_nmi_end) #endif - .globl ibrs_enter, ibrs_enter_end - .globl ibrs_leave, ibrs_leave_end - /* IBRS <- 1 */ LABEL(ibrs_enter) movl $MSR_IA32_SPEC_CTRL,%ecx @@ -1683,8 +1675,6 @@ LABEL(noibrs_leave) NOIBRS_LEAVE LABEL(noibrs_leave_end) - .globl mds_leave, mds_leave_end - LABEL(mds_leave) pushq $GSEL(GDATA_SEL, SEL_KPL) verw (%rsp)
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: bouyer Date: Mon Apr 27 16:55:50 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: vector.S Log Message: Limit the amount of code in TEXT_USER_BEGIN/TEXT_USER_END for hypervisor_pvhvm_callback, for the benefit of SVS. Suggested by maxv@ To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/sys/arch/amd64/amd64/vector.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/vector.S diff -u src/sys/arch/amd64/amd64/vector.S:1.74 src/sys/arch/amd64/amd64/vector.S:1.75 --- src/sys/arch/amd64/amd64/vector.S:1.74 Sat Apr 25 15:26:16 2020 +++ src/sys/arch/amd64/amd64/vector.S Mon Apr 27 16:55:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vector.S,v 1.74 2020/04/25 15:26:16 bouyer Exp $ */ +/* $NetBSD: vector.S,v 1.75 2020/04/27 16:55:50 bouyer Exp $ */ /* * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc. @@ -761,12 +761,10 @@ ENTRY(hypervisor_callback) movq (%rsp),%rcx movq 8(%rsp),%r11 addq $16,%rsp - jmp _C_LABEL(Xhypervisor_pvhvm_callback) - TEXT_USER_BEGIN -IDTVEC(hypervisor_pvhvm_callback) pushq $0 /* Dummy error code */ pushq $T_ASTFLT INTRENTRY +IDTVEC(handle_hypervisor_callback) movlCPUVAR(ILEVEL),%edi pushq %rdi /* for Xdoreti */ incl CPUVAR(IDEPTH) @@ -781,9 +779,17 @@ IDTVEC(hypervisor_pvhvm_callback) 1: #endif jmp _C_LABEL(Xdoreti) +IDTVEC_END(handle_hypervisor_callback) +END(hypervisor_callback) + + TEXT_USER_BEGIN +IDTVEC(hypervisor_pvhvm_callback) + pushq $0 /* Dummy error code */ + pushq $T_ASTFLT + INTRENTRY + jmp _C_LABEL(Xhandle_hypervisor_callback) IDTVEC_END(hypervisor_pvhvm_callback) TEXT_USER_END -END(hypervisor_callback) #endif /* XEN */ #ifdef XENPV
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: bouyer Date: Mon Apr 27 16:55:50 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: vector.S Log Message: Limit the amount of code in TEXT_USER_BEGIN/TEXT_USER_END for hypervisor_pvhvm_callback, for the benefit of SVS. Suggested by maxv@ To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/sys/arch/amd64/amd64/vector.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Sun Apr 26 14:07:43 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: Put the template functions in the rodata section; they get hotpatched into other places, but never execute directly. To generate a diff of this commit: cvs rdiff -u -r1.201 -r1.202 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.201 src/sys/arch/amd64/amd64/locore.S:1.202 --- src/sys/arch/amd64/amd64/locore.S:1.201 Sat Apr 25 15:26:16 2020 +++ src/sys/arch/amd64/amd64/locore.S Sun Apr 26 14:07:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.201 2020/04/25 15:26:16 bouyer Exp $ */ +/* $NetBSD: locore.S,v 1.202 2020/04/26 14:07:43 maxv Exp $ */ /* * Copyright-o-rama! @@ -1587,6 +1587,8 @@ END(intrfastexit) TEXT_USER_END + .section .rodata + #ifdef SVS .globl svs_enter, svs_enter_end .globl svs_enter_altstack, svs_enter_altstack_end
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Sun Apr 26 14:07:43 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: Put the template functions in the rodata section; they get hotpatched into other places, but never execute directly. To generate a diff of this commit: cvs rdiff -u -r1.201 -r1.202 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: christos Date: Thu Apr 23 16:16:15 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: netbsd32_machdep.c Log Message: use shortcut variables for readability. To generate a diff of this commit: cvs rdiff -u -r1.133 -r1.134 src/sys/arch/amd64/amd64/netbsd32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/netbsd32_machdep.c diff -u src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.133 src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.134 --- src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.133 Wed Dec 11 21:15:42 2019 +++ src/sys/arch/amd64/amd64/netbsd32_machdep.c Thu Apr 23 12:16:14 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_machdep.c,v 1.133 2019/12/12 02:15:42 pgoyette Exp $ */ +/* $NetBSD: netbsd32_machdep.c,v 1.134 2020/04/23 16:16:14 christos Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.133 2019/12/12 02:15:42 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.134 2020/04/23 16:16:14 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -214,18 +214,20 @@ netbsd32_sendsig_siginfo(const ksiginfo_ int onstack, error; int sig = ksi->ksi_signo; struct netbsd32_sigframe_siginfo *fp, frame; - sig_t catcher = SIGACTION(p, sig).sa_handler; + const struct sigaction *sa = (p, sig); + sig_t catcher = sa->sa_handler; struct trapframe *tf = l->l_md.md_regs; + struct sigaltstack * const ss = >l_sigstk; /* Do we need to jump onto the signal stack? */ onstack = - (l->l_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 && - (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0; + (ss->ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 && + (sa->sa_flags & SA_ONSTACK) != 0; /* Allocate space for the signal handler context. */ if (onstack) fp = (struct netbsd32_sigframe_siginfo *) - ((char *)l->l_sigstk.ss_sp + l->l_sigstk.ss_size); + ((char *)ss->ss_sp + ss->ss_size); else fp = (struct netbsd32_sigframe_siginfo *)tf->tf_rsp; @@ -252,7 +254,7 @@ netbsd32_sendsig_siginfo(const ksiginfo_ frame.sf_uc.uc_flags = _UC_SIGMASK; frame.sf_uc.uc_sigmask = *mask; frame.sf_uc.uc_link = (uint32_t)(uintptr_t)l->l_ctxlink; - frame.sf_uc.uc_flags |= (l->l_sigstk.ss_flags & SS_ONSTACK) + frame.sf_uc.uc_flags |= (ss->ss_flags & SS_ONSTACK) ? _UC_SETSTACK : _UC_CLRSTACK; sendsig_reset(l, sig);
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: christos Date: Thu Apr 23 16:16:15 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: netbsd32_machdep.c Log Message: use shortcut variables for readability. To generate a diff of this commit: cvs rdiff -u -r1.133 -r1.134 src/sys/arch/amd64/amd64/netbsd32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: christos Date: Sat Feb 29 15:00:28 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: db_interface.c Log Message: Fix boot -c or -d by avoiding ipi handling before the vector is initialized. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/arch/amd64/amd64/db_interface.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/db_interface.c diff -u src/sys/arch/amd64/amd64/db_interface.c:1.36 src/sys/arch/amd64/amd64/db_interface.c:1.37 --- src/sys/arch/amd64/amd64/db_interface.c:1.36 Thu Feb 14 02:12:40 2019 +++ src/sys/arch/amd64/amd64/db_interface.c Sat Feb 29 10:00:28 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: db_interface.c,v 1.36 2019/02/14 07:12:40 cherry Exp $ */ +/* $NetBSD: db_interface.c,v 1.37 2020/02/29 15:00:28 christos Exp $ */ /* * Mach Operating System @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.36 2019/02/14 07:12:40 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.37 2020/02/29 15:00:28 christos Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -150,7 +150,9 @@ db_suspend_others(void) xen_broadcast_ipi(XEN_IPI_DDB); #else #if NLAPIC > 0 - x86_ipi(ddb_vec, LAPIC_DEST_ALLEXCL, LAPIC_DLMODE_FIXED); + if (ddb_vec != 0) + x86_ipi(ddb_vec, LAPIC_DEST_ALLEXCL, + LAPIC_DLMODE_FIXED); #endif #endif /* XENPV */ }
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: christos Date: Sat Feb 29 15:00:28 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: db_interface.c Log Message: Fix boot -c or -d by avoiding ipi handling before the vector is initialized. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/arch/amd64/amd64/db_interface.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: ad Date: Mon Jan 13 11:40:15 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: It looks like Xen cpu_hatch() calls cpu_switchto() with prevlwp=NULL, instead of calling idle_loop() directly. I can't test a change to cpu_hatch() right now so allow for prevlwp=NULL. To generate a diff of this commit: cvs rdiff -u -r1.198 -r1.199 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: ad Date: Mon Jan 13 11:40:15 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: It looks like Xen cpu_hatch() calls cpu_switchto() with prevlwp=NULL, instead of calling idle_loop() directly. I can't test a change to cpu_hatch() right now so allow for prevlwp=NULL. To generate a diff of this commit: cvs rdiff -u -r1.198 -r1.199 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.198 src/sys/arch/amd64/amd64/locore.S:1.199 --- src/sys/arch/amd64/amd64/locore.S:1.198 Thu Jan 9 00:42:24 2020 +++ src/sys/arch/amd64/amd64/locore.S Mon Jan 13 11:40:15 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.198 2020/01/09 00:42:24 manu Exp $ */ +/* $NetBSD: locore.S,v 1.199 2020/01/13 11:40:15 ad Exp $ */ /* * Copyright-o-rama! @@ -1079,10 +1079,14 @@ ENTRY(cpu_switchto) movq %rdi,%r13 /* oldlwp */ movq %rsi,%r12 /* newlwp */ + testq %r13,%r13 /* oldlwp = NULL ? */ + jz .Lskip_save + /* Save old context. */ movq L_PCB(%r13),%rax movq %rsp,PCB_RSP(%rax) movq %rbp,PCB_RBP(%rax) +.Lskip_save: /* Switch to newlwp's stack. */ movq L_PCB(%r12),%r14
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: manu Date: Sun Dec 15 02:58:22 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: Fix typo that caused two instructions to be commented out Oddly, that did not break booting. To generate a diff of this commit: cvs rdiff -u -r1.194 -r1.195 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.194 src/sys/arch/amd64/amd64/locore.S:1.195 --- src/sys/arch/amd64/amd64/locore.S:1.194 Sun Dec 15 02:56:40 2019 +++ src/sys/arch/amd64/amd64/locore.S Sun Dec 15 02:58:21 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.194 2019/12/15 02:56:40 manu Exp $ */ +/* $NetBSD: locore.S,v 1.195 2019/12/15 02:58:21 manu Exp $ */ /* * Copyright-o-rama! @@ -544,7 +544,7 @@ next: pop %r8 mov $(KERNTEXTOFF - KERNBASE), %rdi /* dest */ mov %r8, %rsi sub $(start - kernel_text), %rsi /* src */ - mov $(__kernel_end - kernel_text), %rcx /* size *. + mov $(__kernel_end - kernel_text), %rcx /* size */ mov %rcx, %r12 movq %rdi, %r11 /* for misaligned check */
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: manu Date: Sun Dec 15 02:58:22 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: Fix typo that caused two instructions to be commented out Oddly, that did not break booting. To generate a diff of this commit: cvs rdiff -u -r1.194 -r1.195 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: ad Date: Fri Dec 13 20:14:25 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: machdep.c Log Message: Break the global uvm_pageqlock into a per-page identity lock and a private lock for use of the pagedaemon policy code. Discussed on tech-kern. PR kern/54209: NetBSD 8 large memory performance extremely low PR kern/54210: NetBSD-8 processes presumably not exiting PR kern/54727: writing a large file causes unreasonable system behaviour To generate a diff of this commit: cvs rdiff -u -r1.343 -r1.344 src/sys/arch/amd64/amd64/machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/machdep.c diff -u src/sys/arch/amd64/amd64/machdep.c:1.343 src/sys/arch/amd64/amd64/machdep.c:1.344 --- src/sys/arch/amd64/amd64/machdep.c:1.343 Tue Dec 10 02:06:07 2019 +++ src/sys/arch/amd64/amd64/machdep.c Fri Dec 13 20:14:25 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.343 2019/12/10 02:06:07 manu Exp $ */ +/* $NetBSD: machdep.c,v 1.344 2019/12/13 20:14:25 ad Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011 @@ -110,7 +110,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.343 2019/12/10 02:06:07 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.344 2019/12/13 20:14:25 ad Exp $"); #include "opt_modular.h" #include "opt_multiboot.h" @@ -865,7 +865,7 @@ sparse_dump_mark(void) pfn++) { pg = PHYS_TO_VM_PAGE(ptoa(pfn)); - if (pg->uanon || (pg->pqflags & PQ_FREE) || + if (pg->uanon || (pg->flags & PG_FREE) || (pg->uobject && pg->uobject->pgops)) { p = VM_PAGE_TO_PHYS(pg) / PAGE_SIZE; clrbit(sparse_dump_physmap, p);
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: ad Date: Fri Dec 13 20:14:25 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: machdep.c Log Message: Break the global uvm_pageqlock into a per-page identity lock and a private lock for use of the pagedaemon policy code. Discussed on tech-kern. PR kern/54209: NetBSD 8 large memory performance extremely low PR kern/54210: NetBSD-8 processes presumably not exiting PR kern/54727: writing a large file causes unreasonable system behaviour To generate a diff of this commit: cvs rdiff -u -r1.343 -r1.344 src/sys/arch/amd64/amd64/machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Sat Dec 7 10:19:35 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: amd64_trap.S Log Message: Panic instead of printf, same as syscall. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/arch/amd64/amd64/amd64_trap.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/amd64_trap.S diff -u src/sys/arch/amd64/amd64/amd64_trap.S:1.50 src/sys/arch/amd64/amd64/amd64_trap.S:1.51 --- src/sys/arch/amd64/amd64/amd64_trap.S:1.50 Thu Nov 14 16:23:52 2019 +++ src/sys/arch/amd64/amd64/amd64_trap.S Sat Dec 7 10:19:35 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: amd64_trap.S,v 1.50 2019/11/14 16:23:52 maxv Exp $ */ +/* $NetBSD: amd64_trap.S,v 1.51 2019/12/07 10:19:35 maxv Exp $ */ /* * Copyright (c) 1998, 2007, 2008, 2017 The NetBSD Foundation, Inc. @@ -694,13 +694,8 @@ calltrap: STI(si) movabsq $4f,%rdi movl CPUVAR(ILEVEL),%esi - movl %ebx,%edx - xorq %rax,%rax - call _C_LABEL(printf) - movl %ebx,%edi - call _C_LABEL(spllower) - jmp .Lalltraps_checkast -4: .asciz "WARNING: SPL NOT LOWERED ON TRAP EXIT %x %x\n" + call _C_LABEL(panic) +4: .asciz "spl not lowered on trap exit, ilevel=%x" #endif END(alltraps)
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Sat Dec 7 10:19:35 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: amd64_trap.S Log Message: Panic instead of printf, same as syscall. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/arch/amd64/amd64/amd64_trap.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: rin Date: Wed Nov 27 09:02:00 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: process_machdep.c Log Message: Use bool for "write" in ptrace_machdep_dorequest() for clarity. No functional changes. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/arch/amd64/amd64/process_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: rin Date: Wed Nov 27 09:02:00 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: process_machdep.c Log Message: Use bool for "write" in ptrace_machdep_dorequest() for clarity. No functional changes. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/arch/amd64/amd64/process_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/process_machdep.c diff -u src/sys/arch/amd64/amd64/process_machdep.c:1.44 src/sys/arch/amd64/amd64/process_machdep.c:1.45 --- src/sys/arch/amd64/amd64/process_machdep.c:1.44 Tue Aug 6 01:34:29 2019 +++ src/sys/arch/amd64/amd64/process_machdep.c Wed Nov 27 09:01:59 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: process_machdep.c,v 1.44 2019/08/06 01:34:29 kamil Exp $ */ +/* $NetBSD: process_machdep.c,v 1.45 2019/11/27 09:01:59 rin Exp $ */ /* * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -74,7 +74,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.44 2019/08/06 01:34:29 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.45 2019/11/27 09:01:59 rin Exp $"); #include "opt_xen.h" #include @@ -315,15 +315,15 @@ ptrace_machdep_dorequest( struct iovec iov; struct vmspace *vm; int error; - int write = 0; + bool write = false; switch (req) { case PT_SETXSTATE: - write = 1; + write = true; /* FALLTHROUGH */ case PT_GETXSTATE: - /* write = 0 done above. */ + /* write = false done above. */ if (!process_machdep_validxstate(lt->l_proc)) return EINVAL; if (__predict_false(l->l_proc->p_flag & PK_32)) {
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: rin Date: Wed Nov 20 10:57:08 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: netbsd32_machdep.c Log Message: Fix netbsd32_process_write_dbregs() for amd64: - Zero-clear regs64 so that random values are not written into the preserved registers. - Cast 32-bit registers (int) to u_int, in order to avoid undesired sign extension when filled into 64-bit registers (long). XXX pullup to netbsd-9 To generate a diff of this commit: cvs rdiff -u -r1.129 -r1.130 src/sys/arch/amd64/amd64/netbsd32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Fri Nov 15 09:50:01 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: cpu_in_cksum.S Log Message: Since cpu_in_cksum.S can be built outside of the kernel, add an ugly #ifdef _KERNEL for kMSan. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/amd64/amd64/cpu_in_cksum.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/cpu_in_cksum.S diff -u src/sys/arch/amd64/amd64/cpu_in_cksum.S:1.4 src/sys/arch/amd64/amd64/cpu_in_cksum.S:1.5 --- src/sys/arch/amd64/amd64/cpu_in_cksum.S:1.4 Thu Nov 14 16:23:52 2019 +++ src/sys/arch/amd64/amd64/cpu_in_cksum.S Fri Nov 15 09:50:01 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_in_cksum.S,v 1.4 2019/11/14 16:23:52 maxv Exp $ */ +/* $NetBSD: cpu_in_cksum.S,v 1.5 2019/11/15 09:50:01 maxv Exp $ */ /*- * Copyright (c) 2008 Joerg Sonnenberger . @@ -30,7 +30,11 @@ */ #include +#ifdef _KERNEL #include +#else +#define KMSAN_INIT_RET(sz) /* nothing */ +#endif #include "assym.h" ENTRY(cpu_in_cksum)
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Fri Nov 15 09:50:01 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: cpu_in_cksum.S Log Message: Since cpu_in_cksum.S can be built outside of the kernel, add an ugly #ifdef _KERNEL for kMSan. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/amd64/amd64/cpu_in_cksum.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: christos Date: Thu Sep 26 01:39:22 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: netbsd32_machdep.c Log Message: - promote regs from int to u_int in comparisons with unsigned constants - cast -1 to __greg32_t which is unsigned and the LHS. To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/sys/arch/amd64/amd64/netbsd32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: christos Date: Thu Sep 26 01:39:22 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: netbsd32_machdep.c Log Message: - promote regs from int to u_int in comparisons with unsigned constants - cast -1 to __greg32_t which is unsigned and the LHS. To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/sys/arch/amd64/amd64/netbsd32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/netbsd32_machdep.c diff -u src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.127 src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.128 --- src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.127 Wed Aug 21 08:46:56 2019 +++ src/sys/arch/amd64/amd64/netbsd32_machdep.c Wed Sep 25 21:39:22 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_machdep.c,v 1.127 2019/08/21 12:46:56 maxv Exp $ */ +/* $NetBSD: netbsd32_machdep.c,v 1.128 2019/09/26 01:39:22 christos Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.127 2019/08/21 12:46:56 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.128 2019/09/26 01:39:22 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -437,7 +437,7 @@ netbsd32_process_write_regs(struct lwp * if (!VALID_USER_DSEL32(regs->r_ds) || !VALID_USER_DSEL32(regs->r_ss)) return EINVAL; - if (regs->r_eip >= VM_MAXUSER_ADDRESS32) + if ((u_int)regs->r_eip >= VM_MAXUSER_ADDRESS32) return EINVAL; tf->tf_rax = regs->r_eax; @@ -479,7 +479,7 @@ netbsd32_process_write_dbregs(struct lwp /* Check that DR0-DR3 contain user-space address */ for (i = 0; i < X86_DBREGS; i++) { - if (regs->dr[i] >= VM_MAXUSER_ADDRESS32) + if ((u_int)regs->dr[i] >= VM_MAXUSER_ADDRESS32) return EINVAL; } @@ -811,7 +811,7 @@ cpu_getmcontext32(struct lwp *l, mcontex gr[_REG32_ERR]= tf->tf_err; if ((ras_eip = (__greg32_t)(uintptr_t)ras_lookup(l->l_proc, - (void *) (uintptr_t)gr[_REG32_EIP])) != -1) + (void *) (uintptr_t)gr[_REG32_EIP])) != (__greg32_t)-1) gr[_REG32_EIP] = ras_eip; *flags |= _UC_CPU;
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: kamil Date: Wed Sep 18 20:18:27 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: trap.c Log Message: Avoid VLA to appease stack-protector This has been reproduced with -O0 and -fsanitize=undefined. To generate a diff of this commit: cvs rdiff -u -r1.123 -r1.124 src/sys/arch/amd64/amd64/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: kamil Date: Wed Sep 18 20:18:27 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: trap.c Log Message: Avoid VLA to appease stack-protector This has been reproduced with -O0 and -fsanitize=undefined. To generate a diff of this commit: cvs rdiff -u -r1.123 -r1.124 src/sys/arch/amd64/amd64/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/trap.c diff -u src/sys/arch/amd64/amd64/trap.c:1.123 src/sys/arch/amd64/amd64/trap.c:1.124 --- src/sys/arch/amd64/amd64/trap.c:1.123 Wed Aug 21 17:14:05 2019 +++ src/sys/arch/amd64/amd64/trap.c Wed Sep 18 20:18:27 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.123 2019/08/21 17:14:05 maxv Exp $ */ +/* $NetBSD: trap.c,v 1.124 2019/09/18 20:18:27 kamil Exp $ */ /* * Copyright (c) 1998, 2000, 2017 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.123 2019/08/21 17:14:05 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.124 2019/09/18 20:18:27 kamil Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -351,7 +351,7 @@ trap(struct trapframe *frame) { static const char lcall[7] = { 0x9a, 0, 0, 0, 0, 7, 0 }; const size_t sz = sizeof(lcall); - char tmp[sz]; + char tmp[sizeof(lcall) /* Avoids VLA */]; /* Check for the oosyscall lcall instruction. */ if (p->p_emul == _netbsd32 &&
Re: CVS commit: src/sys/arch/amd64/amd64
On 05.09.2019 14:57, Maxime Villard wrote: > Module Name: src > Committed By: maxv > Date: Thu Sep 5 12:57:30 UTC 2019 > > Modified Files: > src/sys/arch/amd64/amd64: lock_stubs.S > > Log Message: > Remove unused, and style. > > > To generate a diff of this commit: > cvs rdiff -u -r1.31 -r1.32 src/sys/arch/amd64/amd64/lock_stubs.S > > Please note that diffs are not public domain; they are subject to the > copyright notices on the relevant files. > > > Modified files: > > Index: src/sys/arch/amd64/amd64/lock_stubs.S > diff -u src/sys/arch/amd64/amd64/lock_stubs.S:1.31 > src/sys/arch/amd64/amd64/lock_stubs.S:1.32 > --- src/sys/arch/amd64/amd64/lock_stubs.S:1.31Mon Feb 11 14:59:32 2019 > +++ src/sys/arch/amd64/amd64/lock_stubs.S Thu Sep 5 12:57:30 2019 > @@ -1,6 +1,6 @@ > -/* $NetBSD: lock_stubs.S,v 1.31 2019/02/11 14:59:32 cherry Exp $ */ > +/* $NetBSD: lock_stubs.S,v 1.32 2019/09/05 12:57:30 maxv Exp $ */ > > -/*- > +/* > * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. > * All rights reserved. > * This is our style use /*- for comments that shall not be reformatted (originally indent(1) specific). signature.asc Description: OpenPGP digital signature
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Thu Sep 5 12:57:30 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: lock_stubs.S Log Message: Remove unused, and style. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/arch/amd64/amd64/lock_stubs.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Thu Sep 5 12:57:30 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: lock_stubs.S Log Message: Remove unused, and style. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/arch/amd64/amd64/lock_stubs.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/lock_stubs.S diff -u src/sys/arch/amd64/amd64/lock_stubs.S:1.31 src/sys/arch/amd64/amd64/lock_stubs.S:1.32 --- src/sys/arch/amd64/amd64/lock_stubs.S:1.31 Mon Feb 11 14:59:32 2019 +++ src/sys/arch/amd64/amd64/lock_stubs.S Thu Sep 5 12:57:30 2019 @@ -1,6 +1,6 @@ -/* $NetBSD: lock_stubs.S,v 1.31 2019/02/11 14:59:32 cherry Exp $ */ +/* $NetBSD: lock_stubs.S,v 1.32 2019/09/05 12:57:30 maxv Exp $ */ -/*- +/* * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. * All rights reserved. * @@ -15,7 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in the *documentation and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -29,15 +29,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* - * AMD64 lock stubs. Calling convention: - * - * %rdi arg 1 - * %rsi arg 2 - * %rdx arg 3 - * %rax return value - */ - #include "opt_multiprocessor.h" #include "opt_lockdebug.h" @@ -46,31 +37,30 @@ #include "assym.h" -#define ENDLABEL(name,a) .align a; LABEL(name) -#define LOCK(num) \ +#define LOCK \ HOTPATCH(HP_NAME_NOLOCK, 1) ; \ lock -#define RET(num) \ +#define RET \ HOTPATCH(HP_NAME_RETFENCE, 3) ; \ ret; nop; nop ; \ ret #ifndef LOCKDEBUG + .align 64 + /* * void mutex_enter(kmutex_t *mtx); * * Acquire a mutex and post a load fence. */ - .align 64 - ENTRY(mutex_enter) movq CPUVAR(CURLWP), %rcx xorq %rax, %rax - LOCK(1) + LOCK cmpxchgq %rcx, (%rdi) jnz 1f - RET(1) + RET 1: jmp _C_LABEL(mutex_vector_enter) END(mutex_enter) @@ -114,7 +104,7 @@ ENTRY(mutex_spin_enter) testb %al, %al jnz 1f #endif - RET(2) + RET 1: jmp _C_LABEL(mutex_spin_retry) /* failed; hard case */ END(mutex_spin_enter) @@ -211,11 +201,11 @@ ENTRY(rw_enter) 0: testb $(RW_WRITE_LOCKED|RW_WRITE_WANTED), %al jnz 3f - leaq RW_READ_INCR(%rax), %rdx - LOCK(2) + leaq RW_READ_INCR(%rax), %rdx + LOCK cmpxchgq %rdx, (%rdi) jnz 1f - RET(3) + RET 1: jmp 0b @@ -225,10 +215,10 @@ ENTRY(rw_enter) 2: movq CPUVAR(CURLWP), %rcx xorq %rax, %rax orq $RW_WRITE_LOCKED, %rcx - LOCK(3) + LOCK cmpxchgq %rcx, (%rdi) jnz 3f - RET(4) + RET 3: jmp _C_LABEL(rw_vector_enter) END(rw_enter) @@ -251,7 +241,7 @@ ENTRY(rw_exit) cmpq $RW_READ_INCR, %rax jb 3f leaq -RW_READ_INCR(%rax), %rdx - LOCK(4) + LOCK cmpxchgq %rdx, (%rdi) jnz 1f ret @@ -264,7 +254,7 @@ ENTRY(rw_exit) 2: leaq -RW_WRITE_LOCKED(%rax), %rdx subq CPUVAR(CURLWP), %rdx jnz 3f - LOCK(5) + LOCK cmpxchgq %rdx, (%rdi) jnz 3f ret @@ -288,12 +278,12 @@ ENTRY(rw_tryenter) 0: testb $(RW_WRITE_LOCKED|RW_WRITE_WANTED), %al jnz 4f - leaq RW_READ_INCR(%rax), %rdx - LOCK(8) + leaq RW_READ_INCR(%rax), %rdx + LOCK cmpxchgq %rdx, (%rdi) jnz 1f movl %edx, %eax /* nonzero */ - RET(5) + RET 1: jmp 0b @@ -303,12 +293,12 @@ ENTRY(rw_tryenter) 2: movq CPUVAR(CURLWP), %rcx xorq %rax, %rax orq $RW_WRITE_LOCKED, %rcx - LOCK(9) + LOCK cmpxchgq %rcx, (%rdi) movl $0, %eax setz %al 3: - RET(6) + RET ret 4: xorl %eax, %eax @@ -328,10 +318,10 @@ END(__cpu_simple_lock_init) ENTRY(__cpu_simple_lock) movl $0x0100, %eax 1: - LOCK(6) + LOCK cmpxchgb %ah, (%rdi) jnz 2f - RET(7) + RET 2: movl $0x0100, %eax pause @@ -349,10 +339,10 @@ END(__cpu_simple_unlock) ENTRY(__cpu_simple_lock_try) movl $0x0100, %eax - LOCK(7) + LOCK cmpxchgb %ah, (%rdi) movl $0, %eax setz %al - RET(8) + RET END(__cpu_simple_lock_try)
Re: CVS commit: src/sys/arch/amd64/amd64
Le 21/08/2019 à 23:47, matthew green a écrit : "Maxime Villard" writes: Module Name:src Committed By: maxv Date: Wed Aug 21 16:35:10 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: Switch from printf to panic. These messages were notorious for being unreadable, and at least a clean panic allows the user to inspect the system via DDB. Also simplify the output, EAX gets overwritten with the error code so it indicates nothing meaningful. thanks for this. i'd been working on the same myself. do you have a reliable way to trigger this issue? i thought that returning to userland with a lock held would do it, but i wasn't able to get that to work reliably. there's more work related to crash dumps i'd like to work on but i got distracted by testing a change similar to this one and didn't get back to it yet. if you hard-code a splhigh() in a syscall and invoke it, you can see the message; to get the unreadable/garbage output you likely need to have two threads that invoke the syscall at the same time
re: CVS commit: src/sys/arch/amd64/amd64
"Maxime Villard" writes: > Module Name: src > Committed By: maxv > Date: Wed Aug 21 16:35:10 UTC 2019 > > Modified Files: > src/sys/arch/amd64/amd64: locore.S > > Log Message: > Switch from printf to panic. These messages were notorious for being > unreadable, and at least a clean panic allows the user to inspect the > system via DDB. Also simplify the output, EAX gets overwritten with > the error code so it indicates nothing meaningful. thanks for this. i'd been working on the same myself. do you have a reliable way to trigger this issue? i thought that returning to userland with a lock held would do it, but i wasn't able to get that to work reliably. there's more work related to crash dumps i'd like to work on but i got distracted by testing a change similar to this one and didn't get back to it yet. .mrg.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Wed Aug 21 17:14:05 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: trap.c Log Message: Style and cleanup. To generate a diff of this commit: cvs rdiff -u -r1.122 -r1.123 src/sys/arch/amd64/amd64/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/trap.c diff -u src/sys/arch/amd64/amd64/trap.c:1.122 src/sys/arch/amd64/amd64/trap.c:1.123 --- src/sys/arch/amd64/amd64/trap.c:1.122 Wed Aug 21 17:06:36 2019 +++ src/sys/arch/amd64/amd64/trap.c Wed Aug 21 17:14:05 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.122 2019/08/21 17:06:36 maxv Exp $ */ +/* $NetBSD: trap.c,v 1.123 2019/08/21 17:14:05 maxv Exp $ */ /* * Copyright (c) 1998, 2000, 2017 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.122 2019/08/21 17:06:36 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.123 2019/08/21 17:14:05 maxv Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -110,21 +110,17 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.1 #ifdef KDTRACE_HOOKS #include - /* - * This is a hook which is initialized by the dtrace module - * to handle traps which might occur during DTrace probe - * execution. + * This is a hook which is initialized by the dtrace module to handle traps + * which might occur during DTrace probe execution. */ -dtrace_trap_func_t dtrace_trap_func = NULL; - -dtrace_doubletrap_func_t dtrace_doubletrap_func = NULL; +dtrace_trap_func_t dtrace_trap_func = NULL; +dtrace_doubletrap_func_t dtrace_doubletrap_func = NULL; #endif void nmitrap(struct trapframe *); void doubletrap(struct trapframe *); void trap(struct trapframe *); -void trap_return_fault_return(struct trapframe *) __dead; const char * const trap_type[] = { "privileged instruction fault", /* 0 T_PRIVINFLT */ @@ -149,7 +145,7 @@ const char * const trap_type[] = { "SSE FP exception", /* 19 T_XMM */ "reserved trap", /* 20 T_RESERVED */ }; -int trap_types = __arraycount(trap_type); +int trap_types = __arraycount(trap_type); #ifdef TRAP_SIGDEBUG static void sigdebug(const struct trapframe *, const ksiginfo_t *, int); @@ -274,7 +270,7 @@ trap(struct trapframe *frame) p = l->l_proc; } else { /* - * this can happen eg. on break points in early on boot. + * This can happen eg on break points in early on boot. */ pcb = NULL; p = NULL; @@ -454,9 +450,7 @@ trap(struct trapframe *frame) ksi.ksi_code = FPE_INTDIV; break; default: -#ifdef DIAGNOSTIC - panic("unhandled type %x\n", type); -#endif + KASSERT(0); break; } goto trapsignal; @@ -493,7 +487,7 @@ trap(struct trapframe *frame) } } - goto faultcommon; + goto pagefltcommon; case T_PAGEFLT|T_USER: { register vaddr_t va; @@ -506,7 +500,7 @@ trap(struct trapframe *frame) if (p->p_emul->e_usertrap != NULL && (*p->p_emul->e_usertrap)(l, cr2, frame) != 0) return; -faultcommon: +pagefltcommon: vm = p->p_vmspace; if (__predict_false(vm == NULL)) { goto we_re_toast;
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Wed Aug 21 17:14:05 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: trap.c Log Message: Style and cleanup. To generate a diff of this commit: cvs rdiff -u -r1.122 -r1.123 src/sys/arch/amd64/amd64/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Wed Aug 21 17:06:36 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: trap.c Log Message: Remove the single-step check, it is wrong. There is no way we could single-step on these entry points. If there were, we would be running with the wrong GS.base, and we would have died long before. To generate a diff of this commit: cvs rdiff -u -r1.121 -r1.122 src/sys/arch/amd64/amd64/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Wed Aug 21 17:06:36 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: trap.c Log Message: Remove the single-step check, it is wrong. There is no way we could single-step on these entry points. If there were, we would be running with the wrong GS.base, and we would have died long before. To generate a diff of this commit: cvs rdiff -u -r1.121 -r1.122 src/sys/arch/amd64/amd64/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/trap.c diff -u src/sys/arch/amd64/amd64/trap.c:1.121 src/sys/arch/amd64/amd64/trap.c:1.122 --- src/sys/arch/amd64/amd64/trap.c:1.121 Sat Jul 13 17:03:01 2019 +++ src/sys/arch/amd64/amd64/trap.c Wed Aug 21 17:06:36 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.121 2019/07/13 17:03:01 mlelstv Exp $ */ +/* $NetBSD: trap.c,v 1.122 2019/08/21 17:06:36 maxv Exp $ */ /* * Copyright (c) 1998, 2000, 2017 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.121 2019/07/13 17:03:01 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.122 2019/08/21 17:06:36 maxv Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -151,8 +151,6 @@ const char * const trap_type[] = { }; int trap_types = __arraycount(trap_type); -#define IDTVEC(name) __CONCAT(X, name) - #ifdef TRAP_SIGDEBUG static void sigdebug(const struct trapframe *, const ksiginfo_t *, int); #define SIGDEBUG(a, b, c) sigdebug(a, b, c) @@ -265,8 +263,6 @@ trap(struct trapframe *frame) struct proc *p; struct pcb *pcb; extern char kcopy_fault[]; - extern char IDTVEC(osyscall)[]; - extern char IDTVEC(syscall32)[]; ksiginfo_t ksi; void *onfault; int type, error; @@ -657,12 +653,6 @@ faultcommon: if (x86_dbregs_user_trap()) break; - /* Check whether they single-stepped into a lcall. */ - if (frame->tf_rip == (uint64_t)IDTVEC(osyscall) || - frame->tf_rip == (uint64_t)IDTVEC(syscall32)) { - frame->tf_rflags &= ~PSL_T; - return; - } goto we_re_toast; case T_BPTFLT|T_USER: /* bpt instruction fault */
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Wed Aug 21 16:35:10 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: Switch from printf to panic. These messages were notorious for being unreadable, and at least a clean panic allows the user to inspect the system via DDB. Also simplify the output, EAX gets overwritten with the error code so it indicates nothing meaningful. To generate a diff of this commit: cvs rdiff -u -r1.185 -r1.186 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Wed Aug 21 16:35:10 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: Switch from printf to panic. These messages were notorious for being unreadable, and at least a clean panic allows the user to inspect the system via DDB. Also simplify the output, EAX gets overwritten with the error code so it indicates nothing meaningful. To generate a diff of this commit: cvs rdiff -u -r1.185 -r1.186 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.185 src/sys/arch/amd64/amd64/locore.S:1.186 --- src/sys/arch/amd64/amd64/locore.S:1.185 Sat May 18 13:32:12 2019 +++ src/sys/arch/amd64/amd64/locore.S Wed Aug 21 16:35:10 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.185 2019/05/18 13:32:12 maxv Exp $ */ +/* $NetBSD: locore.S,v 1.186 2019/08/21 16:35:10 maxv Exp $ */ /* * Copyright-o-rama! @@ -1322,19 +1322,11 @@ ENTRY(handle_syscall) jmp syscall_sysret #ifdef DIAGNOSTIC - /* Report SPL error */ .Lspl_error: movabsq $4f,%rdi - movl TF_RAX(%rsp),%esi - movl TF_RDI(%rsp),%edx - movl %ebx,%ecx - movl CPUVAR(ILEVEL),%r8d - xorq %rax,%rax - call _C_LABEL(printf) - movl $IPL_NONE,%edi - call _C_LABEL(spllower) - jmp .Lsyscall_checkast -4: .asciz "WARNING: SPL NOT LOWERED ON SYSCALL %d %d EXIT %x %x\n" + movl CPUVAR(ILEVEL),%esi + call _C_LABEL(panic) +4: .asciz "spl not lowered on syscall, ilevel=%x" #endif /* AST pending or pmap load needed */
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Wed Aug 21 12:46:56 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: netbsd32_machdep.c Log Message: Style and remove dead stuff. To generate a diff of this commit: cvs rdiff -u -r1.126 -r1.127 src/sys/arch/amd64/amd64/netbsd32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/netbsd32_machdep.c diff -u src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.126 src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.127 --- src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.126 Wed Aug 21 12:33:12 2019 +++ src/sys/arch/amd64/amd64/netbsd32_machdep.c Wed Aug 21 12:46:56 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_machdep.c,v 1.126 2019/08/21 12:33:12 maxv Exp $ */ +/* $NetBSD: netbsd32_machdep.c,v 1.127 2019/08/21 12:46:56 maxv Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.126 2019/08/21 12:33:12 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.127 2019/08/21 12:46:56 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -84,8 +84,8 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_mac #include /* Provide a the name of the architecture we're emulating */ -const char machine32[] = "i386"; -const char machine_arch32[] = "i386"; +const char machine32[] = "i386"; +const char machine_arch32[] = "i386"; #ifdef USER_LDT static int x86_64_get_ldt32(struct lwp *, void *, register_t *); @@ -104,10 +104,8 @@ static int x86_64_set_mtrr32(struct lwp #endif int check_sigcontext32(struct lwp *, const struct netbsd32_sigcontext *); - -void netbsd32_buildcontext(struct lwp *l, struct trapframe *tf, void *fp, -sig_t catcher, int onstack); - +void netbsd32_buildcontext(struct lwp *, struct trapframe *, void *, +sig_t, int); int netbsd32_sendsig_siginfo(const ksiginfo_t *, const sigset_t *); #ifdef EXEC_AOUT @@ -288,7 +286,7 @@ netbsd32_sendsig(const ksiginfo_t *ksi, #ifdef COREDUMP /* * Dump the machine specific segment at the start of a core dump. - */ + */ struct md_core32 { struct reg32 intreg; struct fpreg32 freg; @@ -389,7 +387,7 @@ int netbsd32_process_read_fpregs(struct lwp *l, struct fpreg32 *regs, size_t *sz) { - __CTASSERT(sizeof *regs == sizeof (struct save87)); + __CTASSERT(sizeof(*regs) == sizeof(struct save87)); process_read_fpregs_s87(l, (struct save87 *)regs); return 0; } @@ -467,7 +465,7 @@ netbsd32_process_write_fpregs(struct lwp size_t sz) { - __CTASSERT(sizeof *regs == sizeof (struct save87)); + __CTASSERT(sizeof(*regs) == sizeof(struct save87)); process_write_fpregs_s87(l, (const struct save87 *)regs); return 0; } @@ -515,11 +513,11 @@ netbsd32_sysarch(struct lwp *l, const st error = x86_iopl(l, NETBSD32PTR64(SCARG(uap, parms)), retval); break; - case X86_GET_LDT: + case X86_GET_LDT: error = x86_64_get_ldt32(l, NETBSD32PTR64(SCARG(uap, parms)), retval); break; - case X86_SET_LDT: + case X86_SET_LDT: error = x86_64_set_ldt32(l, NETBSD32PTR64(SCARG(uap, parms)), retval); break; @@ -548,7 +546,7 @@ x86_64_set_ldt32(struct lwp *l, void *ar int error; if ((error = copyin(args, , sizeof(ua32))) != 0) - return (error); + return error; ua.start = ua32.start; ua.num = ua32.num; @@ -621,18 +619,18 @@ x86_64_get_mtrr32(struct lwp *l, void *a error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_MTRR_GET, NULL, NULL, NULL, NULL); if (error) - return (error); + return error; - error = copyin(args, , sizeof args32); + error = copyin(args, , sizeof(args32)); if (error != 0) return error; if (args32.mtrrp == 0) { n = (MTRR_I686_NFIXED_SOFT + MTRR_I686_NVAR_MAX); - return copyout(, (void *)(uintptr_t)args32.n, sizeof n); + return copyout(, (void *)(uintptr_t)args32.n, sizeof(n)); } - error = copyin((void *)(uintptr_t)args32.n, , sizeof n); + error = copyin((void *)(uintptr_t)args32.n, , sizeof(n)); if (error != 0) return error; @@ -652,7 +650,7 @@ x86_64_get_mtrr32(struct lwp *l, void *a m32.type = mp->type; m32.flags = mp->flags; m32.owner = mp->owner; - error = copyout(, m32p, sizeof m32); + error = copyout(, m32p, sizeof(m32)); if (error != 0) break; mp++; @@ -663,7 +661,7 @@ fail: kmem_free(m64p, size); if (error != 0) n = 0; - copyout(, (void *)(uintptr_t)args32.n, sizeof n); + copyout(, (void *)(uintptr_t)args32.n, sizeof(n)); return error; } @@ -685,13 +683,13 @@ x86_64_set_mtrr32(struct lwp *l, void *a error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_MTRR_SET, NULL, NULL, NULL, NULL); if (error) - return (error); + return error; - error = copyin(args, , sizeof args32); + error = copyin(args, , sizeof(args32)); if (error != 0) return error; - error = copyin((void *)(uintptr_t)args32.n, , sizeof n); + error
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Wed Aug 21 12:46:56 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: netbsd32_machdep.c Log Message: Style and remove dead stuff. To generate a diff of this commit: cvs rdiff -u -r1.126 -r1.127 src/sys/arch/amd64/amd64/netbsd32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Wed Aug 21 12:33:12 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: netbsd32_machdep.c Log Message: Don't depend on #ifdef USER_LDT in cpu_mcontext32_validate(), but rather on whether the proc uses a user-set LDT. Same as check_sigcontext32(). To generate a diff of this commit: cvs rdiff -u -r1.125 -r1.126 src/sys/arch/amd64/amd64/netbsd32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Wed Aug 21 12:33:12 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: netbsd32_machdep.c Log Message: Don't depend on #ifdef USER_LDT in cpu_mcontext32_validate(), but rather on whether the proc uses a user-set LDT. Same as check_sigcontext32(). To generate a diff of this commit: cvs rdiff -u -r1.125 -r1.126 src/sys/arch/amd64/amd64/netbsd32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/netbsd32_machdep.c diff -u src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.125 src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.126 --- src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.125 Sat Jul 20 18:25:11 2019 +++ src/sys/arch/amd64/amd64/netbsd32_machdep.c Wed Aug 21 12:33:12 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_machdep.c,v 1.125 2019/07/20 18:25:11 christos Exp $ */ +/* $NetBSD: netbsd32_machdep.c,v 1.126 2019/08/21 12:33:12 maxv Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.125 2019/07/20 18:25:11 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.126 2019/08/21 12:33:12 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -903,12 +903,6 @@ startlwp32(void *arg) userret(l); } -/* - * For various reasons, the amd64 port can't do what the i386 port does, - * and relies on catching invalid user contexts on exit from the kernel. - * These functions perform the needed checks. - */ - int check_sigcontext32(struct lwp *l, const struct netbsd32_sigcontext *scp) { @@ -923,21 +917,22 @@ check_sigcontext32(struct lwp *l, const return EINVAL; if (__predict_false(pmap->pm_ldt != NULL)) { - /* Only when the LDT is user-set (with USER_LDT) */ + /* Allow unfamiliar segment register values (USER_LDT). */ if (!USERMODE(scp->sc_cs)) return EINVAL; } else { if (!VALID_USER_CSEL32(scp->sc_cs)) return EINVAL; if (scp->sc_fs != 0 && !VALID_USER_DSEL32(scp->sc_fs) && - !(VALID_USER_FSEL32(scp->sc_fs) && pcb->pcb_fs != 0)) + !(VALID_USER_FSEL32(scp->sc_fs) && pcb->pcb_fs != 0)) return EINVAL; if (scp->sc_gs != 0 && !VALID_USER_DSEL32(scp->sc_gs) && - !(VALID_USER_GSEL32(scp->sc_gs) && pcb->pcb_gs != 0)) + !(VALID_USER_GSEL32(scp->sc_gs) && pcb->pcb_gs != 0)) return EINVAL; if (scp->sc_es != 0 && !VALID_USER_DSEL32(scp->sc_es)) return EINVAL; - if (!VALID_USER_DSEL32(scp->sc_ds) || !VALID_USER_DSEL32(scp->sc_ss)) + if (!VALID_USER_DSEL32(scp->sc_ds) || + !VALID_USER_DSEL32(scp->sc_ss)) return EINVAL; } @@ -950,36 +945,37 @@ check_sigcontext32(struct lwp *l, const int cpu_mcontext32_validate(struct lwp *l, const mcontext32_t *mcp) { + struct pmap *pmap = l->l_proc->p_vmspace->vm_map.pmap; const __greg32_t *gr; struct trapframe *tf; + struct pcb *pcb; gr = mcp->__gregs; tf = l->l_md.md_regs; + pcb = lwp_getpcb(l); if (((gr[_REG32_EFL] ^ tf->tf_rflags) & PSL_USERSTATIC) != 0) return EINVAL; -#ifdef USER_LDT - /* Userland is allowed to have unfamiliar segment register values */ - if (!USERMODE(gr[_REG32_CS])) - return EINVAL; -#else - struct pcb *pcb = lwp_getpcb(l); - - if (!VALID_USER_CSEL32(gr[_REG32_CS])) - return EINVAL; - if (gr[_REG32_FS] != 0 && !VALID_USER_DSEL32(gr[_REG32_FS]) && - !(VALID_USER_FSEL32(gr[_REG32_FS]) && pcb->pcb_fs != 0)) - return EINVAL; - if (gr[_REG32_GS] != 0 && !VALID_USER_DSEL32(gr[_REG32_GS]) && - !(VALID_USER_GSEL32(gr[_REG32_GS]) && pcb->pcb_gs != 0)) - return EINVAL; - if (gr[_REG32_ES] != 0 && !VALID_USER_DSEL32(gr[_REG32_ES])) - return EINVAL; - if (!VALID_USER_DSEL32(gr[_REG32_DS]) || - !VALID_USER_DSEL32(gr[_REG32_SS])) - return EINVAL; -#endif + if (__predict_false(pmap->pm_ldt != NULL)) { + /* Allow unfamiliar segment register values (USER_LDT). */ + if (!USERMODE(gr[_REG32_CS])) + return EINVAL; + } else { + if (!VALID_USER_CSEL32(gr[_REG32_CS])) + return EINVAL; + if (gr[_REG32_FS] != 0 && !VALID_USER_DSEL32(gr[_REG32_FS]) && + !(VALID_USER_FSEL32(gr[_REG32_FS]) && pcb->pcb_fs != 0)) + return EINVAL; + if (gr[_REG32_GS] != 0 && !VALID_USER_DSEL32(gr[_REG32_GS]) && + !(VALID_USER_GSEL32(gr[_REG32_GS]) && pcb->pcb_gs != 0)) + return EINVAL; + if (gr[_REG32_ES] != 0 && !VALID_USER_DSEL32(gr[_REG32_ES])) + return EINVAL; + if (!VALID_USER_DSEL32(gr[_REG32_DS]) || + !VALID_USER_DSEL32(gr[_REG32_SS])) + return EINVAL; + } if (gr[_REG32_EIP] >= VM_MAXUSER_ADDRESS32) return EINVAL;
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: kamil Date: Tue Aug 6 01:34:29 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: process_machdep.c Log Message: Do not dereference user pointer in ptrace_machdep_dorequest()/amd64 Always use copyin(9) for reading user memory. This fixes SMAP crash on some amd64 machines. Reported by To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/arch/amd64/amd64/process_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/process_machdep.c diff -u src/sys/arch/amd64/amd64/process_machdep.c:1.43 src/sys/arch/amd64/amd64/process_machdep.c:1.44 --- src/sys/arch/amd64/amd64/process_machdep.c:1.43 Wed Jul 24 16:36:47 2019 +++ src/sys/arch/amd64/amd64/process_machdep.c Tue Aug 6 01:34:29 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: process_machdep.c,v 1.43 2019/07/24 16:36:47 bouyer Exp $ */ +/* $NetBSD: process_machdep.c,v 1.44 2019/08/06 01:34:29 kamil Exp $ */ /* * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -74,7 +74,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.43 2019/07/24 16:36:47 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.44 2019/08/06 01:34:29 kamil Exp $"); #include "opt_xen.h" #include @@ -327,14 +327,21 @@ ptrace_machdep_dorequest( if (!process_machdep_validxstate(lt->l_proc)) return EINVAL; if (__predict_false(l->l_proc->p_flag & PK_32)) { - struct netbsd32_iovec *user_iov = addr; - iov.iov_base = NETBSD32PTR64(user_iov->iov_base); - iov.iov_len = user_iov->iov_len; + struct netbsd32_iovec user_iov; + if ((error = copyin(addr, _iov, sizeof(user_iov))) + != 0) +return error; + + iov.iov_base = NETBSD32PTR64(user_iov.iov_base); + iov.iov_len = user_iov.iov_len; } else { - struct iovec *user_iov; - user_iov = (struct iovec*)addr; - iov.iov_base = user_iov->iov_base; - iov.iov_len = user_iov->iov_len; + struct iovec user_iov; + if ((error = copyin(addr, _iov, sizeof(user_iov))) + != 0) +return error; + + iov.iov_base = user_iov.iov_base; + iov.iov_len = user_iov.iov_len; } error = proc_vmspace_getref(l->l_proc, );
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: kamil Date: Tue Aug 6 01:34:29 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: process_machdep.c Log Message: Do not dereference user pointer in ptrace_machdep_dorequest()/amd64 Always use copyin(9) for reading user memory. This fixes SMAP crash on some amd64 machines. Reported by To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/arch/amd64/amd64/process_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.