Module Name: src
Committed By: bouyer
Date: Sat May 2 17:14:02 UTC 2020
Modified Files:
src/sys/arch/amd64/amd64: cpufunc.S
src/sys/arch/i386/i386: cpufunc.S
Log Message:
Move x86_hotpatch() in !XENPV section. Fixes XEN3* builds.
To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/i386/i386/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.50 src/sys/arch/amd64/amd64/cpufunc.S:1.51
--- src/sys/arch/amd64/amd64/cpufunc.S:1.50 Sat May 2 11:37:17 2020
+++ src/sys/arch/amd64/amd64/cpufunc.S Sat May 2 17:14:01 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpufunc.S,v 1.50 2020/05/02 11:37:17 maxv Exp $ */
+/* $NetBSD: cpufunc.S,v 1.51 2020/05/02 17:14:01 bouyer Exp $ */
/*
* Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -180,6 +180,44 @@ ENTRY(tsc_get_timecount)
2:
jmp 1b
END(tsc_get_timecount)
+
+/*
+ * %rdi = name
+ * %rsi = sel
+ */
+ENTRY(x86_hotpatch)
+ /* save RFLAGS, and disable intrs */
+ pushfq
+ cli
+
+ /* save CR0, and disable WP */
+ movq %cr0,%rcx
+ pushq %rcx
+ andq $~CR0_WP,%rcx
+ movq %rcx,%cr0
+
+ callq _C_LABEL(x86_hotpatch_apply)
+
+ /* write back and invalidate cache */
+ wbinvd
+
+ /* restore CR0 */
+ popq %rcx
+ movq %rcx,%cr0
+
+ /* flush instruction pipeline */
+ pushq %rax
+ callq x86_flush
+ popq %rax
+
+ /* clean up */
+ movq %rax,%rdi
+ callq _C_LABEL(x86_hotpatch_cleanup)
+
+ /* restore RFLAGS */
+ popfq
+ ret
+END(x86_hotpatch)
#endif /* !XENPV */
ENTRY(rdmsr_safe)
@@ -380,41 +418,3 @@ ENTRY(outl)
outl %eax, %dx
ret
END(outl)
-
-/*
- * %rdi = name
- * %rsi = sel
- */
-ENTRY(x86_hotpatch)
- /* save RFLAGS, and disable intrs */
- pushfq
- cli
-
- /* save CR0, and disable WP */
- movq %cr0,%rcx
- pushq %rcx
- andq $~CR0_WP,%rcx
- movq %rcx,%cr0
-
- callq _C_LABEL(x86_hotpatch_apply)
-
- /* write back and invalidate cache */
- wbinvd
-
- /* restore CR0 */
- popq %rcx
- movq %rcx,%cr0
-
- /* flush instruction pipeline */
- pushq %rax
- callq x86_flush
- popq %rax
-
- /* clean up */
- movq %rax,%rdi
- callq _C_LABEL(x86_hotpatch_cleanup)
-
- /* restore RFLAGS */
- popfq
- ret
-END(x86_hotpatch)
Index: src/sys/arch/i386/i386/cpufunc.S
diff -u src/sys/arch/i386/i386/cpufunc.S:1.39 src/sys/arch/i386/i386/cpufunc.S:1.40
--- src/sys/arch/i386/i386/cpufunc.S:1.39 Sat May 2 11:37:17 2020
+++ src/sys/arch/i386/i386/cpufunc.S Sat May 2 17:14:01 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpufunc.S,v 1.39 2020/05/02 11:37:17 maxv Exp $ */
+/* $NetBSD: cpufunc.S,v 1.40 2020/05/02 17:14:01 bouyer Exp $ */
/*-
* Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
#include <sys/errno.h>
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.39 2020/05/02 11:37:17 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.40 2020/05/02 17:14:01 bouyer Exp $");
#include "opt_xen.h"
@@ -71,6 +71,44 @@ ENTRY(lidt)
lidt (%eax)
ret
END(lidt)
+
+ENTRY(x86_hotpatch)
+ /* save EFLAGS, and disable intrs */
+ pushfl
+ cli
+
+ /* save CR0, and disable WP */
+ movl %cr0,%ecx
+ pushl %ecx
+ andl $~CR0_WP,%ecx
+ movl %ecx,%cr0
+
+ pushl 4*4(%esp) /* arg2 */
+ pushl 4*4(%esp) /* arg1 */
+ call _C_LABEL(x86_hotpatch_apply)
+ addl $2*4,%esp
+
+ /* write back and invalidate cache */
+ wbinvd
+
+ /* restore CR0 */
+ popl %ecx
+ movl %ecx,%cr0
+
+ /* flush instruction pipeline */
+ pushl %eax
+ call x86_flush
+ popl %eax
+
+ /* clean up */
+ pushl %eax
+ call _C_LABEL(x86_hotpatch_cleanup)
+ addl $4,%esp
+
+ /* restore RFLAGS */
+ popfl
+ ret
+END(x86_hotpatch)
#endif /* XENPV */
ENTRY(x86_read_flags)
@@ -274,41 +312,3 @@ ENTRY(outl)
outl %eax, %dx
ret
END(outl)
-
-ENTRY(x86_hotpatch)
- /* save EFLAGS, and disable intrs */
- pushfl
- cli
-
- /* save CR0, and disable WP */
- movl %cr0,%ecx
- pushl %ecx
- andl $~CR0_WP,%ecx
- movl %ecx,%cr0
-
- pushl 4*4(%esp) /* arg2 */
- pushl 4*4(%esp) /* arg1 */
- call _C_LABEL(x86_hotpatch_apply)
- addl $2*4,%esp
-
- /* write back and invalidate cache */
- wbinvd
-
- /* restore CR0 */
- popl %ecx
- movl %ecx,%cr0
-
- /* flush instruction pipeline */
- pushl %eax
- call x86_flush
- popl %eax
-
- /* clean up */
- pushl %eax
- call _C_LABEL(x86_hotpatch_cleanup)
- addl $4,%esp
-
- /* restore RFLAGS */
- popfl
- ret
-END(x86_hotpatch)