Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump x86_64 from 0.14.12 to 0.15.0 #1089

Merged
merged 4 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ udp = ["smoltcp", "smoltcp/socket-udp"]
trace = []
vga = []
common-os = []
nostd = []
semihosting = ["dep:semihosting"]
shell = ["simple-shell"]

Expand Down Expand Up @@ -125,7 +126,7 @@ features = [
multiboot = "0.8"
uart_16550 = "0.3"
x86 = { version = "0.52", default-features = false }
x86_64 = "0.14"
x86_64 = "0.15"
qemu-exit = "3.0"

[target.'cfg(target_arch = "aarch64")'.dependencies]
Expand Down
8 changes: 4 additions & 4 deletions src/arch/x86_64/kernel/apic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,19 +477,19 @@ pub fn init() {
// Set gates to ISRs for the APIC interrupts we are going to enable.
unsafe {
let mut idt = IDT.lock();
idt[ERROR_INTERRUPT_NUMBER as usize]
idt[ERROR_INTERRUPT_NUMBER]
.set_handler_fn(error_interrupt_handler)
.set_stack_index(0);
idt[SPURIOUS_INTERRUPT_NUMBER as usize]
idt[SPURIOUS_INTERRUPT_NUMBER]
.set_handler_fn(spurious_interrupt_handler)
.set_stack_index(0);
#[cfg(feature = "smp")]
{
idt[TLB_FLUSH_INTERRUPT_NUMBER as usize]
idt[TLB_FLUSH_INTERRUPT_NUMBER]
.set_handler_fn(tlb_flush_handler)
.set_stack_index(0);
interrupts::add_irq_name(TLB_FLUSH_INTERRUPT_NUMBER - 32, "TLB flush");
idt[WAKEUP_INTERRUPT_NUMBER as usize]
idt[WAKEUP_INTERRUPT_NUMBER]
.set_handler_fn(wakeup_handler)
.set_stack_index(0);
interrupts::add_irq_name(WAKEUP_INTERRUPT_NUMBER - 32, "Wakeup");
Expand Down
12 changes: 6 additions & 6 deletions src/arch/x86_64/kernel/gdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ use crate::config::KERNEL_STACK_SIZE;

pub fn add_current_core() {
let gdt: &mut GlobalDescriptorTable = Box::leak(Box::new(GlobalDescriptorTable::new()));
let kernel_code_selector = gdt.add_entry(Descriptor::kernel_code_segment());
let kernel_data_selector = gdt.add_entry(Descriptor::kernel_data_segment());
let kernel_code_selector = gdt.append(Descriptor::kernel_code_segment());
let kernel_data_selector = gdt.append(Descriptor::kernel_data_segment());
#[cfg(feature = "common-os")]
{
let _user_code32_selector =
gdt.add_entry(Descriptor::UserSegment(DescriptorFlags::USER_CODE32.bits()));
let _user_data64_selector = gdt.add_entry(Descriptor::user_data_segment());
let _user_code64_selector = gdt.add_entry(Descriptor::user_code_segment());
gdt.append(Descriptor::UserSegment(DescriptorFlags::USER_CODE32.bits()));
let _user_data64_selector = gdt.append(Descriptor::user_data_segment());
let _user_code64_selector = gdt.append(Descriptor::user_code_segment());
}

// Dynamically allocate memory for a Task-State Segment (TSS) for this core.
Expand Down Expand Up @@ -53,7 +53,7 @@ pub fn add_current_core() {
}

CoreLocal::get().tss.set(tss);
let tss_selector = gdt.add_entry(Descriptor::tss_segment(tss));
let tss_selector = gdt.append(Descriptor::tss_segment(tss));

// Load the GDT for the current core.
gdt.load();
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86_64/kernel/interrupts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub(crate) fn install() {
set_general_handler!(&mut *idt, unknown, 64..);

unsafe {
for i in 32..256 {
for i in 32..=255 {
let addr = idt[i].handler_addr();
idt[i].set_handler_addr(addr).set_stack_index(0);
}
Expand Down Expand Up @@ -117,7 +117,7 @@ pub extern "C" fn irq_install_handler(

let mut idt = IDT.lock();
unsafe {
idt[(32 + irq_number) as usize]
idt[32 + irq_number]
.set_handler_addr(x86_64::VirtAddr::new(
u64::try_from(handler as usize).unwrap(),
))
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86_64/kernel/pic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ pub fn init() {
// This is especially true for real hardware. So provide a handler for them.
unsafe {
let mut idt = IDT.lock();
idt[(PIC1_INTERRUPT_OFFSET + SPURIOUS_IRQ_NUMBER) as usize]
idt[PIC1_INTERRUPT_OFFSET + SPURIOUS_IRQ_NUMBER]
.set_handler_fn(spurious_interrupt_on_master)
.set_stack_index(0);
idt[(PIC2_INTERRUPT_OFFSET + SPURIOUS_IRQ_NUMBER) as usize]
idt[PIC2_INTERRUPT_OFFSET + SPURIOUS_IRQ_NUMBER]
.set_handler_fn(spurious_interrupt_on_slave)
.set_stack_index(0);

Expand Down
2 changes: 1 addition & 1 deletion src/arch/x86_64/kernel/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ impl CpuFrequency {
// system timer with a known constant frequency.
unsafe {
let mut idt = IDT.lock();
idt[pit::PIT_INTERRUPT_NUMBER as usize]
idt[pit::PIT_INTERRUPT_NUMBER]
.set_handler_fn(Self::measure_frequency_timer_handler)
.set_stack_index(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/arch/x86_64/kernel/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ extern "x86-interrupt" fn timer_handler(_stack_frame: interrupts::ExceptionStack
pub fn install_timer_handler() {
unsafe {
let mut idt = IDT.lock();
idt[apic::TIMER_INTERRUPT_NUMBER as usize]
idt[apic::TIMER_INTERRUPT_NUMBER]
.set_handler_fn(timer_handler)
.set_stack_index(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/arch/x86_64/kernel/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ extern "x86-interrupt" fn serial_interrupt(_stack_frame: crate::interrupts::Exce
pub(crate) fn install_serial_interrupt() {
unsafe {
let mut idt = IDT.lock();
idt[SERIAL_IRQ.into()]
idt[SERIAL_IRQ]
.set_handler_fn(serial_interrupt)
.set_stack_index(0);
}
Expand Down
10 changes: 6 additions & 4 deletions src/arch/x86_64/mm/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use core::ptr;

use x86_64::instructions::tlb;
use x86_64::registers::control::Cr2;
#[cfg(feature = "common-os")]
use x86_64::registers::segmentation::SegmentSelector;
pub use x86_64::structures::idt::InterruptStackFrame as ExceptionStackFrame;
use x86_64::structures::idt::PageFaultErrorCode;
use x86_64::structures::paging::mapper::{TranslateResult, UnmapError};
Expand Down Expand Up @@ -268,7 +270,7 @@ pub(crate) extern "x86-interrupt" fn page_fault_handler(
error_code: PageFaultErrorCode,
) {
error!("Page fault (#PF)!");
error!("page_fault_linear_address = {:p}", Cr2::read());
error!("page_fault_linear_address = {:p}", Cr2::read().unwrap());
error!("error_code = {error_code:?}");
error!("fs = {:#X}", processor::readfs());
error!("gs = {:#X}", processor::readgs());
Expand All @@ -282,12 +284,12 @@ pub(crate) extern "x86-interrupt" fn page_fault_handler(
error_code: PageFaultErrorCode,
) {
unsafe {
if stack_frame.as_mut().read().code_segment != 0x08 {
if stack_frame.as_mut().read().code_segment != SegmentSelector(0x08) {
core::arch::asm!("swapgs", options(nostack));
}
}
error!("Page fault (#PF)!");
error!("page_fault_linear_address = {:p}", Cr2::read());
error!("page_fault_linear_address = {:p}", Cr2::read().unwrap());
error!("error_code = {error_code:?}");
error!("fs = {:#X}", processor::readfs());
error!("gs = {:#X}", processor::readgs());
Expand Down Expand Up @@ -397,7 +399,7 @@ pub(crate) unsafe fn print_page_tables(levels: usize) {
}

// Recursive
let mut recursive_page_table = unsafe { recursive_page_table() };
let recursive_page_table = unsafe { recursive_page_table() };
let pt = recursive_page_table.level_4_table();

// Identity mapped
Expand Down
5 changes: 4 additions & 1 deletion src/arch/x86_64/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
pub mod kernel;
pub mod mm;

#[cfg(feature = "common-os")]
use x86_64::registers::segmentation::SegmentSelector;

use crate::arch::mm::paging::ExceptionStackFrame;

/// Helper function to swap the GS register, if the user-space is
Expand All @@ -9,7 +12,7 @@ use crate::arch::mm::paging::ExceptionStackFrame;
#[inline(always)]
pub(crate) fn swapgs(stack_frame: &ExceptionStackFrame) {
use core::arch::asm;
if stack_frame.code_segment != 8 {
if stack_frame.code_segment != SegmentSelector(8) {
unsafe {
asm!("swapgs", options(nomem, nostack, preserves_flags));
}
Expand Down
8 changes: 6 additions & 2 deletions src/errno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,15 @@ pub const ERFKILL: i32 = 132;
/// Robust mutexes: Memory page has hardware error
pub const EHWPOISON: i32 = 133;

#[cfg(all(not(feature = "common-os"), not(target_arch = "riscv64")))]
#[cfg(all(
not(any(feature = "common-os", feature = "nostd")),
not(target_arch = "riscv64")
))]
#[thread_local]
pub(crate) static ERRNO: core::cell::UnsafeCell<i32> = core::cell::UnsafeCell::new(0);

/// Get the error number from the thread local storage
#[cfg(not(feature = "nostd"))]
#[no_mangle]
pub extern "C" fn sys_get_errno() -> i32 {
cfg_if::cfg_if! {
Expand All @@ -423,7 +427,7 @@ pub(crate) trait ToErrno {
{
if let Some(errno) = self.to_errno() {
cfg_if::cfg_if! {
if #[cfg(any(feature = "common-os", target_arch = "riscv64"))] {
if #[cfg(any(feature = "common-os", feature = "nostd", target_arch = "riscv64"))] {
let _ = errno;
} else {
unsafe {
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ pub(crate) extern "C" fn __sys_free(ptr: *mut u8, size: usize, align: usize) {
#[cfg(target_os = "none")]
extern "C" fn initd(_arg: usize) {
extern "C" {
#[cfg(all(not(test), not(feature = "common-os")))]
#[cfg(all(not(test), not(any(feature = "nostd", feature = "common-os"))))]
fn runtime_entry(argc: i32, argv: *const *const u8, env: *const *const u8) -> !;
#[cfg(all(not(test), feature = "common-os"))]
#[cfg(all(not(test), any(feature = "nostd", feature = "common-os")))]
fn main(argc: i32, argv: *const *const u8, env: *const *const u8);
#[cfg(feature = "newlib")]
fn init_lwip();
Expand Down Expand Up @@ -298,9 +298,9 @@ extern "C" fn initd(_arg: usize) {
#[cfg(not(test))]
unsafe {
// And finally start the application.
#[cfg(all(not(test), not(feature = "common-os")))]
#[cfg(all(not(test), not(any(feature = "nostd", feature = "common-os"))))]
runtime_entry(argc, argv, environ);
#[cfg(all(not(test), feature = "common-os"))]
#[cfg(all(not(test), any(feature = "nostd", feature = "common-os")))]
main(argc, argv, environ);
}
#[cfg(test)]
Expand Down