From 21a0e33342fc8e5d8a92fd2bed10632aa32a6785 Mon Sep 17 00:00:00 2001 From: bluhm Date: Wed, 10 Jul 2024 12:36:13 +0000 Subject: [PATCH] Use AMD SEV C-bit in inital page tables setup by locore0. Similar to the NX-bit apply the C-bit to the PTEs built by locore0. Right now, pg_crypt is initialized to 0, so nothing will change. from hshoexer@; OK mlarkin@ --- sys/arch/amd64/amd64/locore0.S | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/sys/arch/amd64/amd64/locore0.S b/sys/arch/amd64/amd64/locore0.S index b0f4f553ef3..bbfed3aa963 100644 --- a/sys/arch/amd64/amd64/locore0.S +++ b/sys/arch/amd64/amd64/locore0.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore0.S,v 1.23 2024/05/12 16:49:38 guenther Exp $ */ +/* $OpenBSD: locore0.S,v 1.24 2024/07/10 12:36:13 bluhm Exp $ */ /* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */ /* @@ -314,17 +314,21 @@ cont: NDML3_ENTRIES + NDML2_ENTRIES + 3) * NBPG) #define fillkpt \ -1: movl %eax,(%ebx) ; /* store phys addr */ \ - movl $0,4(%ebx) ; /* upper 32 bits 0 */ \ - addl $8,%ebx ; /* next pte/pde */ \ - addl $NBPG,%eax ; /* next phys page */ \ - loop 1b ; /* till finished */ + pushl %ebp ; /* save */ \ + movl RELOC((pg_crypt + 4)), %ebp ; /* C bit? */ \ +1: movl %eax,(%ebx) ; /* store phys addr */ \ + movl %ebp,4(%ebx) ; /* upper 32 bits */ \ + addl $8,%ebx ; /* next pte/pde */ \ + addl $NBPG,%eax ; /* next phys page */ \ + loop 1b ; /* till finished */ \ + popl %ebp ; /* restore */ #define fillkpt_nx \ pushl %ebp ; /* save */ \ -1: movl %eax,(%ebx) ; /* store phys addr */ \ movl RELOC((pg_nx + 4)), %ebp ; /* NX bit? */ \ + orl RELOC((pg_crypt + 4)), %ebp ; /* C bit? */ \ +1: movl %eax,(%ebx) ; /* store phys addr */ \ movl %ebp,4(%ebx) ; /* upper 32 bits */ \ addl $8,%ebx ; /* next pte/pde */ \ addl $NBPG,%eax ; /* next phys page */ \ @@ -510,6 +514,7 @@ store_pte: movl %eax, (%ebx) pushl %ebp movl RELOC((pg_nx + 4)), %ebp + orl RELOC((pg_crypt + 4)), %ebp movl %ebp, 4(%ebx) popl %ebp addl $8, %ebx @@ -535,6 +540,7 @@ store_pte: movl %eax,(%ebx) pushl %ebp movl RELOC((pg_nx + 4)), %ebp + orl RELOC((pg_crypt + 4)), %ebp movl %ebp, 4(%ebx) popl %ebp -- 2.20.1