git: cdcaf2e07354 - stable/14 - amd64 la57_trampoline: turn off global pages and PCID before turning off paging

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 23 Sep 2024 13:03:45 UTC
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=cdcaf2e07354ca74539aecb5f23f0ed35b3c7260

commit cdcaf2e07354ca74539aecb5f23f0ed35b3c7260
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-09-12 02:42:23 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-09-23 13:03:06 +0000

    amd64 la57_trampoline: turn off global pages and PCID before turning off paging
    
    (cherry picked from commit 1be58e67eb24024bc808357771579d396679ecb0)
---
 sys/amd64/amd64/locore.S | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sys/amd64/amd64/locore.S b/sys/amd64/amd64/locore.S
index 9a991402cdc2..d05f38dbba05 100644
--- a/sys/amd64/amd64/locore.S
+++ b/sys/amd64/amd64/locore.S
@@ -94,6 +94,8 @@ ENTRY(la57_trampoline)
 	movq	%rsp,%r11
 	movq	%rbx,%r10
 	movq	%rbp,%r9
+	movq	%cr4,%r8
+	orl	$CR4_LA57,%r8d
 	leaq	la57_trampoline_end(%rip),%rsp
 
 	movq	%cr0,%rbp
@@ -110,6 +112,10 @@ ENTRY(la57_trampoline)
 l1:	movl	$(3<<3),%eax
 	movl	%eax,%ss
 
+	movl	%cr4,%eax
+	andl	$~(CR4_PGE | CR4_PCIDE),%eax
+	movl	%eax,%cr4
+
 	movl	%ebp,%eax
 	andl	$~CR0_PG,%eax
 	movl	%eax,%cr0
@@ -140,6 +146,7 @@ l1:	movl	$(3<<3),%eax
 l2:	movq	%r11,%rsp
 	movq	%r10,%rbx
 	movq	%r9,%rbp
+	movq	%r8,%cr4
 	retq
 	.p2align 4,0
 ENTRY(la57_trampoline_gdt_desc)