So that we can use write-protection for code later.
It is REPOST.
It includes suggestion from Michael Kinney <michael.d.kinney@intel.com>:
- "For IA32 assembly, can we combine into a single OR instruction that
sets both page enable and WP?"
- "For X64, does it make sense to use single OR instruction instead of 2
BTS instructions as well?"
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" <jiewen.yao@intel.com>
Suggested-by: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Cc: "Fan, Jeff" <jeff.fan@intel.com>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>
Cc: "Laszlo Ersek" <lersek@redhat.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19068
6f19259b-4bc3-4df7-8a09-
765794883524
L12: # as cr4.PGE is not set here, refresh cr3\r
movl %eax, %cr4 # in PreModifyMtrrs() to flush TLB.\r
movl %cr0, %ebx\r
- orl $0x080000000, %ebx # enable paging\r
+ orl $0x080010000, %ebx # enable paging + WP\r
movl %ebx, %cr0\r
leal DSC_OFFSET(%edi),%ebx\r
movw DSC_DS(%ebx),%ax\r
@@: ; as cr4.PGE is not set here, refresh cr3\r
mov cr4, eax ; in PreModifyMtrrs() to flush TLB.\r
mov ebx, cr0\r
- or ebx, 080000000h ; enable paging\r
+ or ebx, 080010000h ; enable paging + WP\r
mov cr0, ebx\r
lea ebx, [edi + DSC_OFFSET]\r
mov ax, [ebx + DSC_DS]\r
orb $1,%ah\r
wrmsr\r
movq %cr0, %rbx\r
- btsl $31, %ebx\r
+ orl $0x080010000, %ebx # enable paging + WP\r
movq %rbx, %cr0\r
retf\r
LongMode: # long mode (64-bit code) starts here\r
or ah, 1\r
wrmsr\r
mov rbx, cr0\r
- bts ebx, 31\r
+ or ebx, 080010000h ; enable paging + WP\r
mov cr0, rbx\r
retf\r
@LongMode: ; long mode (64-bit code) starts here\r