Skip to content

Set Target Operating Mode - #18

Merged
phil-opp merged 1 commit into
masterfrom
unknown repository
Jul 10, 2018
Merged

Set Target Operating Mode#18
phil-opp merged 1 commit into
masterfrom
unknown repository

Conversation

@IsaacWoods

@IsaacWoods IsaacWoods commented Jul 1, 2018

Copy link
Copy Markdown
Member

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

phil-opp commented Jul 5, 2018

Copy link
Copy Markdown
Member

@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
Copy Markdown
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
Copy Markdown
Member

Thanks @IsaacWoods!

@IsaacWoods

Copy link
Copy Markdown
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