lkml.org 
[lkml]   [2022]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/8] x86/boot: Set cr0 to known state in trampoline
Date
Ensure WP bit to be set to prevent boot code from writing to
non-writable memory pages.

Signed-off-by: Evgeniy Baskov <baskov@ispras.ru>

diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index d33f060900d2..5273367283b7 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -619,9 +619,8 @@ SYM_CODE_START(trampoline_32bit_src)
/* Set up new stack */
leal TRAMPOLINE_32BIT_STACK_END(%ecx), %esp

- /* Disable paging */
- movl %cr0, %eax
- btrl $X86_CR0_PG_BIT, %eax
+ /* Disable paging and setup CR0 */
+ movl $(CR0_STATE & ~X86_CR0_PG), %eax
movl %eax, %cr0

/* Check what paging mode we want to be in after the trampoline */
--
2.35.1
\
 
 \ /
  Last update: 2022-08-01 18:40    [W:0.100 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site