Module Name: src Committed By: maxv Date: Mon Jul 9 18:43:05 UTC 2018
Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: Small optimization: don't execute the Meltdown/SpectreV2 cswitch code if we're leaving a softint. We were executing the softint with the LWP's context, so no need to switch the SVS/IBRS contexts, we already are in the desired contexts. To generate a diff of this commit: cvs rdiff -u -r1.167 -r1.168 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.167 src/sys/arch/amd64/amd64/locore.S:1.168 --- src/sys/arch/amd64/amd64/locore.S:1.167 Fri Jun 29 19:21:43 2018 +++ src/sys/arch/amd64/amd64/locore.S Mon Jul 9 18:43:05 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.167 2018/06/29 19:21:43 maxv Exp $ */ +/* $NetBSD: locore.S,v 1.168 2018/07/09 18:43:05 maxv Exp $ */ /* * Copyright-o-rama! @@ -1088,26 +1088,6 @@ ENTRY(cpu_switchto) movq %rbp,PCB_RBP(%rax) .Lskip_save: -#ifdef SVS - pushq %rdx - movb _C_LABEL(svs_enabled),%dl - testb %dl,%dl - jz .Lskip_svs - callq _C_LABEL(svs_lwp_switch) -.Lskip_svs: - popq %rdx - - /* RDI/RSI got clobbered. */ - movq %r13,%rdi - movq %r12,%rsi -#endif - -#ifndef XEN - pushq %rdx - callq _C_LABEL(speculation_barrier) - popq %rdx -#endif - /* Switch to newlwp's stack. */ movq L_PCB(%r12),%r14 movq PCB_RSP(%r14),%rsp @@ -1124,6 +1104,24 @@ ENTRY(cpu_switchto) testb %dl,%dl /* returning = true ? */ jnz .Lswitch_return +#ifdef SVS + pushq %rdx + movb _C_LABEL(svs_enabled),%dl + testb %dl,%dl + jz .Lskip_svs + callq _C_LABEL(svs_lwp_switch) +.Lskip_svs: + popq %rdx +#endif + +#ifndef XEN + pushq %rdx + movq %r13,%rdi + movq %r12,%rsi + callq _C_LABEL(speculation_barrier) + popq %rdx +#endif + /* Switch ring0 stack */ #ifdef SVS movb _C_LABEL(svs_enabled),%al