The branch main has been updated by kib:

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

commit 1be58e67eb24024bc808357771579d396679ecb0
Author:     Konstantin Belousov <[email protected]>
AuthorDate: 2024-09-12 02:42:23 +0000
Commit:     Konstantin Belousov <[email protected]>
CommitDate: 2024-09-16 08:10:16 +0000

    amd64 la57_trampoline: turn off global pages and PCID before turning off 
paging
    
    SDM is explicit that having CR4.PCID=1 while toggling CR3.PG causes #GP.
    To be safe and to avoid some more effects, also turn off CR4.PGE.
    
    Sponsored by:   Advanced Micro Devices (AMD)
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
---
 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)

Reply via email to