← Back to context

Comment by amluto

6 years ago

For what it’s worth, CPU compatibility with old segmented code (like Windows 3.11) is a bit iffy these days for a silly legacy reason. The old x87 floating point coprocessor had two registers FCS and FDS — they’re the CS and DS segments at the time of the last x87 data instruction. This was used for the 386’s asynchronous FPU exception handling. Fast forward to the ultramodern 486, and floating point exception handling was cleaned up and FCS and FDS became unnecessary, but they were kept for compatibility. All was well.

Unfortunately, AMD made a mistake in AMD64: the new 64-bit floating point context switching instructions couldn’t switch the FCS and FDS registers. This not only broke some very old software when run on a new kernel or hypervisor, but it also created a potential information leak.

Sadly, new CPUs “fix” this in an unfortunate way. Trying to read FCS or FDS gives zero. Now some very old software is broken.