Skip to content

Pass UnwindInfo in BootInfo #164

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

Open
Andy-Python-Programmer opened this issue May 15, 2021 · 4 comments
Open

Pass UnwindInfo in BootInfo #164

Andy-Python-Programmer opened this issue May 15, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@Andy-Python-Programmer
Copy link

It will be nice to pass UnwindInfo in BootInfo so that we can load the kernel ELF in the kernel to do stack unwinding.

#[derive(Debug, Copy, Clone)]
#[repr(C)]
pub struct UnwindInfo {
    /// The base address of the kernel. The kernel base is required
    /// for stack unwinding during kernel panics.
    pub kernel_base: VirtAddr,
    /// The size of the kernel, required to calculate the end of the
    /// kernel base.
    pub kernel_size: usize,

    pub stack_top: VirtAddr,
    pub stack_size: usize
}
@phil-opp
Copy link
Member

Sounds reasonable to me! While you can already find out the kernel start address and size through a linker script, I agree that a boot info field would be easier. For stack top and size there is currently no workaround except for setting these to fixed values in the bootloader config.

@phil-opp phil-opp added the enhancement New feature or request label May 16, 2021
@ethindp
Copy link
Contributor

ethindp commented May 21, 2021

@phil-opp Couldn't you just pass that after finding the address in the bootloader? I'm confused about the problem.

@phil-opp
Copy link
Member

There is no problem here, we just need to do it. Happy to merge a PR for this!

@phil-opp
Copy link
Member

Some adjustments to the code from the OP that I would make:

#[derive(Debug, Copy, Clone)]
#[repr(C)]
pub struct KernelInfo {
    pub kernel_base: u64
    pub kernel_size: u64,
    pub stack_top: u64,
    pub stack_size: u64,
}

Basically:

  • Name the struct KernelInfo instead of UnwindInfo since it isn't directly related to unwinding and might have other use cases too.
  • Don't use the VirtAddr type of the x86_64 crate to keep the BootInfo stable (otherwise updating the x86_64 version would be a breaking change).
  • Don't use platform dependent size types such as usize. Use u64 instead. (This might be overcautious, but it makes sure that the BootInfo always has the same size independent of the target platform.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants