Skip to content

No kernel data segment? #160

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

Closed
samueltardieu opened this issue Jun 16, 2020 · 3 comments
Closed

No kernel data segment? #160

samueltardieu opened this issue Jun 16, 2020 · 3 comments

Comments

@samueltardieu
Copy link
Contributor

There seems to be no Descriptor::kernel_data_segment(). If I understand correctly, the presence of such a segment is expected in IA32_STAR when doing a syscall, as it is used to load the SS register. Or did I misunderstand the x86_64/amd64 manual?

If needed, I'd be happy to propose a PR.

@xfoxfu
Copy link

xfoxfu commented Jun 19, 2020

In GlobalDescriptorTable document, there says Data segment registers in ring 0 can be loaded with the null segment selector. So I think using just the null segment selector maybe is ok.

@samueltardieu
Copy link
Contributor Author

Unfortunately when doing a syscall the data selector is necessarily the one after the code selector (there is only one offset for both kernel code and data segment in register IA32_STAR), so I cannot use the null segment selector which is at offset 0.

Note that even the code to install this offset into IA32_STAR checks that the data selector is located right after the code selector: https://github.com/rust-osdev/x86_64/blob/master/src/registers/model_specific.rs#L339-L341

@phil-opp
Copy link
Member

phil-opp commented Oct 4, 2020

This seems to be resolved by #181. It introduced a new kernel_data_segment function.

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

No branches or pull requests

3 participants