Skip to content

Set Target Operating Mode #18

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

Merged
merged 1 commit into from Jul 10, 2018
Merged

Set Target Operating Mode #18

merged 1 commit into from Jul 10, 2018

Conversation

IsaacWoods
Copy link
Member

@IsaacWoods IsaacWoods commented Jul 1, 2018

This sets the Target Operating Mode in the second stage before we enter Long Mode. This tells the firmware that we are only planning to operate in 64-bit mode and will not switch back to Legacy Mode, allowing it to make optimisations that it otherwise wouldn't be able to make safely.

Afaict, this was first implemented by AMD for the Opteron in ~2003, and is documented in section 12.21 of this document. Other docs are sparse, but it should be a nop on processors that don't support the function, and this should handle the error codes correctly (it sets the carry flag if the function is not supported).

While the docs only specify that it allows the BIOS to make optimizations that are not visible to system software, the default mode only allows the processor to run in Legacy Mode, and so I wonder if any firmwares that have SMM bugs in x86_64 mode may be fixed by this - that is just postulation tho

Edit: Travis failure is not related - merging #17 should fix this build as well

@phil-opp
Copy link
Member

phil-opp commented Jul 5, 2018

@IsaacWoods Thanks for the PRs! From a quick glance the changes look good to me. I'll take a closer look next week, because I'm short on time at the moment.

@phil-opp
Copy link
Member

That's an interesting feature. Nobody seems to know whether this actually has any effect, but everybody does it, including Linux :D. But it is at least documented and a seems to be a nop if not supported, so I think there is no harm in merging it. And who knows, maybe it improves performance or fixes SMM bugs^^.

@phil-opp phil-opp merged commit 261660b into rust-osdev:master Jul 10, 2018
@phil-opp
Copy link
Member

Thanks @IsaacWoods!

@IsaacWoods
Copy link
Member Author

Yep, I have no idea if it has any real effects, but I figured it can't hurt and some OEMs might make use of it

@IsaacWoods IsaacWoods deleted the optimize_firmware branch July 10, 2018 18:19
Nickforall pushed a commit to Nickforall/bootloader that referenced this pull request Dec 17, 2018
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