summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2018-09-12 06:12:59 +0000
committerguenther <guenther@openbsd.org>2018-09-12 06:12:59 +0000
commit00ac7aa268cae987065973acd010273c2a84e88c (patch)
tree4bd02d24f5e4c7640f9934ac48767fa7d9a9f737
parentWhen shooting pages in the KVA range, all pmaps have the page mapped, (diff)
downloadwireguard-openbsd-00ac7aa268cae987065973acd010273c2a84e88c.tar.xz
wireguard-openbsd-00ac7aa268cae987065973acd010273c2a84e88c.zip
Now that the pmap is more paranoid about some shootdowns (pmap.c rev 1.119),
avoid some TLB flushes by not reloading %cr3 when the value isn't changing. original diff by and ok mlarkin@
-rw-r--r--sys/arch/amd64/amd64/locore.S10
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/arch/amd64/amd64/locore.S b/sys/arch/amd64/amd64/locore.S
index ecc9eedc05d..a205e681012 100644
--- a/sys/arch/amd64/amd64/locore.S
+++ b/sys/arch/amd64/amd64/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.108 2018/09/09 22:09:36 guenther Exp $ */
+/* $OpenBSD: locore.S,v 1.109 2018/09/12 06:12:59 guenther Exp $ */
/* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */
/*
@@ -445,9 +445,15 @@ restore_saved:
/* Stack pivot done, setup RETGUARD */
RETGUARD_SETUP_OFF(cpu_switchto, r11, 6*8)
- movq PCB_CR3(%r13),%rax
+ /* don't switch cr3 to the same thing it already was */
+ movq %cr3,%rax
+ cmpq PCB_CR3(%r13),%rax
+ movq PCB_CR3(%r13),%rax /* flags from cmpq unchanged */
+ jz .Lsame_cr3
+
movq %rax,%cr3 /* %rax used below too */
+.Lsame_cr3:
/*
* If we switched from a userland thread with a shallow call stack
* (e.g interrupt->ast->mi_ast->prempt->mi_switch->cpu_switchto)