@@ -308,7 +308,7 @@ mod x86_64 {
308
308
#[ inline]
309
309
pub unsafe fn write ( frame : PhysFrame , flags : Cr3Flags ) {
310
310
unsafe {
311
- Cr3 :: write_raw ( frame, flags. bits ( ) as u16 ) ;
311
+ Cr3 :: write_raw_impl ( false , frame, flags. bits ( ) as u16 ) ;
312
312
}
313
313
}
314
314
@@ -322,7 +322,7 @@ mod x86_64 {
322
322
#[ inline]
323
323
pub unsafe fn write_pcid ( frame : PhysFrame , pcid : Pcid ) {
324
324
unsafe {
325
- Cr3 :: write_raw ( frame, pcid. value ( ) ) ;
325
+ Cr3 :: write_raw_impl ( false , frame, pcid. value ( ) ) ;
326
326
}
327
327
}
328
328
@@ -334,8 +334,13 @@ mod x86_64 {
334
334
/// changing the page mapping.
335
335
#[ inline]
336
336
pub unsafe fn write_raw ( frame : PhysFrame , val : u16 ) {
337
+ unsafe { Self :: write_raw_impl ( false , frame, val) }
338
+ }
339
+
340
+ #[ inline]
341
+ unsafe fn write_raw_impl ( top_bit : bool , frame : PhysFrame , val : u16 ) {
337
342
let addr = frame. start_address ( ) ;
338
- let value = addr. as_u64 ( ) | val as u64 ;
343
+ let value = ( ( top_bit as u64 ) << 63 ) | addr. as_u64 ( ) | val as u64 ;
339
344
340
345
unsafe {
341
346
asm ! ( "mov cr3, {}" , in( reg) value, options( nostack, preserves_flags) ) ;
0 commit comments