Skip to content

Commit 46f57fe

Browse files
bors[bot]stlankes
andauthored
699: remove obsolete ist0 handling r=stlankes a=stlankes IST0 isn't used by common interrupt. Just to close the session. => don't create IST0 for every task, just for every core Co-authored-by: Stefan Lankes <[email protected]>
2 parents 02128c7 + a935ef4 commit 46f57fe

File tree

3 files changed

+11
-48
lines changed

3 files changed

+11
-48
lines changed

src/arch/x86_64/kernel/gdt.rs

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ pub fn add_current_core() {
2929
CoreLocal::get().kernel_stack.set(rsp);
3030

3131
// Allocate all ISTs for this core.
32-
// Every task later gets its own IST1, so the IST1 allocated here is only used by the Idle task.
3332
for i in 0..IST_ENTRIES {
3433
let ist = crate::mm::allocate(IST_SIZE, true);
3534
let ist_start = ist.as_u64() + IST_SIZE as u64 - TaskStacks::MARKER_SIZE as u64;

src/arch/x86_64/kernel/scheduler.rs

+10-41
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ struct State {
6161
pub struct BootStack {
6262
/// stack for kernel tasks
6363
stack: VirtAddr,
64-
/// stack to handle interrupts
65-
ist0: VirtAddr,
6664
}
6765

6866
pub struct CommonStack {
@@ -91,9 +89,9 @@ impl TaskStacks {
9189
} else {
9290
size.align_up(BasePageSize::SIZE as usize)
9391
};
94-
let total_size = user_stack_size + DEFAULT_STACK_SIZE + KERNEL_STACK_SIZE;
92+
let total_size = user_stack_size + DEFAULT_STACK_SIZE;
9593
let virt_addr =
96-
crate::arch::mm::virtualmem::allocate(total_size + 4 * BasePageSize::SIZE as usize)
94+
crate::arch::mm::virtualmem::allocate(total_size + 3 * BasePageSize::SIZE as usize)
9795
.expect("Failed to allocate Virtual Memory for TaskStacks");
9896
let phys_addr = crate::arch::mm::physicalmem::allocate(total_size)
9997
.expect("Failed to allocate Physical Memory for TaskStacks");
@@ -107,36 +105,26 @@ impl TaskStacks {
107105
let mut flags = PageTableEntryFlags::empty();
108106
flags.normal().writable().execute_disable();
109107

110-
// map IST0 into the address space
108+
// map kernel stack into the address space
111109
crate::arch::mm::paging::map::<BasePageSize>(
112110
virt_addr + BasePageSize::SIZE,
113111
phys_addr,
114-
KERNEL_STACK_SIZE / BasePageSize::SIZE as usize,
115-
flags,
116-
);
117-
118-
// map kernel stack into the address space
119-
crate::arch::mm::paging::map::<BasePageSize>(
120-
virt_addr + KERNEL_STACK_SIZE + 2 * BasePageSize::SIZE,
121-
phys_addr + KERNEL_STACK_SIZE,
122112
DEFAULT_STACK_SIZE / BasePageSize::SIZE as usize,
123113
flags,
124114
);
125115

126116
// map user stack into the address space
127117
crate::arch::mm::paging::map::<BasePageSize>(
128-
virt_addr + KERNEL_STACK_SIZE + DEFAULT_STACK_SIZE + 3 * BasePageSize::SIZE,
129-
phys_addr + KERNEL_STACK_SIZE + DEFAULT_STACK_SIZE,
118+
virt_addr + DEFAULT_STACK_SIZE + 2 * BasePageSize::SIZE,
119+
phys_addr + DEFAULT_STACK_SIZE,
130120
user_stack_size / BasePageSize::SIZE as usize,
131121
flags,
132122
);
133123

134124
// clear user stack
135125
unsafe {
136126
ptr::write_bytes(
137-
(virt_addr
138-
+ KERNEL_STACK_SIZE + DEFAULT_STACK_SIZE
139-
+ 3 * BasePageSize::SIZE as usize)
127+
(virt_addr + DEFAULT_STACK_SIZE + 2 * BasePageSize::SIZE as usize)
140128
.as_mut_ptr::<u8>(),
141129
0xAC,
142130
user_stack_size,
@@ -156,38 +144,30 @@ impl TaskStacks {
156144
tss.privilege_stack_table[0].as_u64() as usize + Self::MARKER_SIZE - KERNEL_STACK_SIZE,
157145
);
158146
debug!("Using boot stack {:#X}", stack);
159-
let ist0 = VirtAddr::from_usize(
160-
tss.interrupt_stack_table[0].as_u64() as usize + Self::MARKER_SIZE - KERNEL_STACK_SIZE,
161-
);
162-
debug!("IST0 is located at {:#X}", ist0);
163147

164-
TaskStacks::Boot(BootStack { stack, ist0 })
148+
TaskStacks::Boot(BootStack { stack })
165149
}
166150

167151
pub fn get_user_stack_size(&self) -> usize {
168152
match self {
169153
TaskStacks::Boot(_) => 0,
170-
TaskStacks::Common(stacks) => {
171-
stacks.total_size - DEFAULT_STACK_SIZE - KERNEL_STACK_SIZE
172-
}
154+
TaskStacks::Common(stacks) => stacks.total_size - DEFAULT_STACK_SIZE,
173155
}
174156
}
175157

176158
pub fn get_user_stack(&self) -> VirtAddr {
177159
match self {
178160
TaskStacks::Boot(_) => VirtAddr::zero(),
179161
TaskStacks::Common(stacks) => {
180-
stacks.virt_addr + KERNEL_STACK_SIZE + DEFAULT_STACK_SIZE + 3 * BasePageSize::SIZE
162+
stacks.virt_addr + DEFAULT_STACK_SIZE + 2 * BasePageSize::SIZE
181163
}
182164
}
183165
}
184166

185167
pub fn get_kernel_stack(&self) -> VirtAddr {
186168
match self {
187169
TaskStacks::Boot(stacks) => stacks.stack,
188-
TaskStacks::Common(stacks) => {
189-
stacks.virt_addr + KERNEL_STACK_SIZE + 2 * BasePageSize::SIZE
190-
}
170+
TaskStacks::Common(stacks) => stacks.virt_addr + BasePageSize::SIZE,
191171
}
192172
}
193173

@@ -197,17 +177,6 @@ impl TaskStacks {
197177
TaskStacks::Common(_) => DEFAULT_STACK_SIZE,
198178
}
199179
}
200-
201-
pub fn get_interrupt_stack(&self) -> VirtAddr {
202-
match self {
203-
TaskStacks::Boot(stacks) => stacks.ist0,
204-
TaskStacks::Common(stacks) => stacks.virt_addr + BasePageSize::SIZE,
205-
}
206-
}
207-
208-
pub fn get_interrupt_stack_size(&self) -> usize {
209-
KERNEL_STACK_SIZE
210-
}
211180
}
212181

213182
impl Drop for TaskStacks {

src/scheduler/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,8 @@ impl PerCoreScheduler {
411411
+ current_task_borrowed.stacks.get_kernel_stack_size()
412412
- TaskStacks::MARKER_SIZE)
413413
.as_u64();
414-
tss.interrupt_stack_table[0] = VirtAddr::new(rsp);
414+
tss.privilege_stack_table[0] = VirtAddr::new(rsp);
415415
CoreLocal::get().kernel_stack.set(rsp);
416-
let ist_start = (current_task_borrowed.stacks.get_interrupt_stack()
417-
+ current_task_borrowed.stacks.get_interrupt_stack_size()
418-
- TaskStacks::MARKER_SIZE)
419-
.as_u64();
420-
tss.interrupt_stack_table[0] = VirtAddr::new(ist_start);
421416
}
422417

423418
pub fn set_current_task_priority(&mut self, prio: Priority) {

0 commit comments

Comments
 (0)