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

fixing segmentation print #153

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

elbiazo
Copy link

@elbiazo elbiazo commented Nov 19, 2023

Current segment print
image

After Fix
image

Test Code

use std::arch::asm;
use x86;

fn main() {
    unsafe {
        let cs: u16;
        let ds: u16;
        let ss: u16;
        let es: u16;
        let fs: u16;
        let gs: u16;

        asm!("mov {0:x}, cs", out(reg) cs);
        asm!("mov {0:x}, ds", out(reg) ds);
        asm!("mov {0:x}, ss", out(reg) ss);
        asm!("mov {0:x}, es", out(reg) es);
        asm!("mov {0:x}, fs", out(reg) fs);
        asm!("mov {0:x}, gs", out(reg) gs);

        println!("cs: {:#010b}", cs);
        println!("ds: {:#010b}", ds);
        println!("ss: {:#010b}", ss);
        println!("es: {:#010b}", es);
        println!("fs: {:#010b}", fs);
        println!("gs: {:#010b}", gs);
    }
    println!(
        "cs: {} \nds: {} \nss: {} \nes: {} \nfs: {} \ngs: {}",
        x86::segmentation::cs(),
        x86::segmentation::ds(),
        x86::segmentation::ss(),
        x86::segmentation::es(),
        x86::segmentation::fs(),
        x86::segmentation::gs(),
    );
}

@@ -44,6 +44,16 @@ impl SegmentSelector {
self.bits >> 3
}

/// Returns the requested privilege level of the selector.
pub fn rpl(&self) -> u16 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should return Ring

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good. replaced with Ring enum

@gz
Copy link
Owner

gz commented Nov 24, 2023

Thanks for the contribution

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

Successfully merging this pull request may close these issues.

2 participants