Use 32-bit TSS for x86 32-bit
This commit is contained in:
@@ -4,7 +4,7 @@ use core::convert::TryInto;
|
||||
use core::mem;
|
||||
|
||||
use x86::segmentation::load_cs;
|
||||
use x86::bits64::task::TaskStateSegment;
|
||||
use x86::bits32::task::TaskStateSegment;
|
||||
use x86::Ring;
|
||||
use x86::dtables::{self, DescriptorTablePointer};
|
||||
use x86::segmentation::{self, Descriptor as SegmentDescriptor, SegmentSelector};
|
||||
@@ -93,27 +93,19 @@ pub struct TssWrapper(pub TaskStateSegment);
|
||||
pub static mut KPCR: ProcessorControlRegion = ProcessorControlRegion {
|
||||
tcb_end: 0,
|
||||
user_rsp_tmp: 0,
|
||||
tss: TssWrapper(TaskStateSegment {
|
||||
reserved: 0,
|
||||
rsp: [0; 3],
|
||||
reserved2: 0,
|
||||
ist: [0; 7],
|
||||
reserved3: 0,
|
||||
reserved4: 0,
|
||||
iomap_base: 0xFFFF
|
||||
}),
|
||||
tss: TssWrapper(TaskStateSegment::new()),
|
||||
};
|
||||
|
||||
#[cfg(feature = "pti")]
|
||||
pub unsafe fn set_tss_stack(stack: usize) {
|
||||
use super::pti::{PTI_CPU_STACK, PTI_CONTEXT_STACK};
|
||||
KPCR.tss.0.rsp[0] = (PTI_CPU_STACK.as_ptr() as usize + PTI_CPU_STACK.len()) as u64;
|
||||
KPCR.tss.0.esp0 = (PTI_CPU_STACK.as_ptr() as usize + PTI_CPU_STACK.len()) as u32;
|
||||
PTI_CONTEXT_STACK = stack;
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "pti"))]
|
||||
pub unsafe fn set_tss_stack(stack: usize) {
|
||||
KPCR.tss.0.rsp[0] = stack as u64;
|
||||
KPCR.tss.0.esp0 = stack as u32;
|
||||
}
|
||||
|
||||
// Initialize GDT
|
||||
|
||||
@@ -183,7 +183,7 @@ pub unsafe fn init_generic(is_bsp: bool, idt: &mut Idt) {
|
||||
let address = base_address.data() + BACKUP_STACK_SIZE;
|
||||
|
||||
// Put them in the 1st entry of the IST.
|
||||
crate::gdt::KPCR.tss.0.ist[usize::from(index - 1)] = address as u64;
|
||||
//TODO: x86: crate::gdt::KPCR.tss.0.ist[usize::from(index - 1)] = address as u64;
|
||||
|
||||
index
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::{
|
||||
syscall::flag::{PTRACE_FLAG_IGNORE, PTRACE_STOP_PRE_SYSCALL, PTRACE_STOP_POST_SYSCALL},
|
||||
};
|
||||
use memoffset::offset_of;
|
||||
use x86::{bits64::task::TaskStateSegment, msr, segmentation::SegmentSelector};
|
||||
use x86::{bits32::task::TaskStateSegment, msr, segmentation::SegmentSelector};
|
||||
|
||||
pub unsafe fn init() {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user