Editing Nopl

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
[[Category:Research]] {{DISPLAYTITLE:nopl}}
[[Category:Research]] {{DISPLAYTITLE:nopl}}
During research for my [[AMD Geode]] projects, I found an amazing saga based around a CPU instruction. Nobody else has written this up from what I can see, so here's my take.
During research for my [[Geode Repair]] projects, I found an amazing saga based around a CPU instruction. Nobody else has written this up from what I can see, so here's my take.


== Background ==
== Background ==
Line 32: Line 32:
In 1998 Christian Ludloff documented in his [https://web.archive.org/web/19981205142152/http://sandpile.org:80/80x86/opcodes2.shtml updated map of 2 byte x86 opcodes] that the 0F 18 through 0F 1F range of opcodes were hinting NOPs. The first being the 0F 18 opcode which maps to PREFETCHh instructions. I believe this information was documented first in the [https://www.cs.cmu.edu/afs/cs/academic/class/15213-s01/docs/intel-opt.pdf Intel Architecture Optimization Reference Manual].
In 1998 Christian Ludloff documented in his [https://web.archive.org/web/19981205142152/http://sandpile.org:80/80x86/opcodes2.shtml updated map of 2 byte x86 opcodes] that the 0F 18 through 0F 1F range of opcodes were hinting NOPs. The first being the 0F 18 opcode which maps to PREFETCHh instructions. I believe this information was documented first in the [https://www.cs.cmu.edu/afs/cs/academic/class/15213-s01/docs/intel-opt.pdf Intel Architecture Optimization Reference Manual].


Later in 2003 Christian Ludloff clarified in an email thread [https://web.archive.org/web/20041106070621/http://www.sandpile.org/post/msgs/20004129.htm Undocumented opcodes (HINT_NOP)] that these hinting NOPs were declared by Intel in their 1995 patent [https://patents.google.com/patent/US5701442A/en US5701442]. The idea behind this patent from my reading is that you can encode a program written in another ISA as a series of opcodes that are run as NOPs on older machines and the new ISA on a newer machine.
Later in 2003 Christian Ludloff clarified in an email thread [http://www.sandpile.org/post/msgs/20004129.htm Undocumented opcodes (HINT_NOP)] that these hinting NOPs were declared by Intel in their 1995 patent [https://patents.google.com/patent/US5701442A/en US5701442]. The idea behind this patent from my reading is that you can encode a program written in another ISA as a series of opcodes that are run as NOPs on older machines and the new ISA on a newer machine.


I'm not sure why, but third party x86 CPUs aside from AMD didn't implement these NOPs. Perhaps Intel kept this patent close to their heart? Or maybe it's just not worth spending silicon and research on NOPs that nobody used?
I'm not sure why, but third party x86 CPUs aside from AMD didn't implement these NOPs. Perhaps Intel kept this patent close to their heart? Or maybe it's just not worth spending silicon and research on NOPs that nobody used?
Line 56: Line 56:
In 2007 [http://lkml.iu.edu/hypermail/linux/kernel/0709.2/2726.html x86: multi-byte single instruction NOPs] was committed to Linux. This added a set of 'P6 NOPs' that used the multi-byte NOP opcodes and used them for i686 or newer x86 CPUs. Which type of NOPs to use were decided at runtime, so running an i686 kernel on an i586 machine would not cause any issues with this. Strangely on 64-bit systems the NOPs were only used if your CPU vendor was Intel.  
In 2007 [http://lkml.iu.edu/hypermail/linux/kernel/0709.2/2726.html x86: multi-byte single instruction NOPs] was committed to Linux. This added a set of 'P6 NOPs' that used the multi-byte NOP opcodes and used them for i686 or newer x86 CPUs. Which type of NOPs to use were decided at runtime, so running an i686 kernel on an i586 machine would not cause any issues with this. Strangely on 64-bit systems the NOPs were only used if your CPU vendor was Intel.  


In 2008 the Debian bugs [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=463606 Linux 2.6.24 fails to boot on MS Virtual PC 2007] and [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=464962 -686 build uses long noops, that are unsupported by Transmeta Crusoe, immediate crash on boot] were reported. After a lot of discussion, the following CPUs were reported to not support multi-byte NOPs:
In 2008 the Debian bugs [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=463606 Linux 2.6.24 fails to boot on MS Virtual PC 2007] and [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=464962 -686 build uses long noops, that are unsupported by Transmeta Crusoe, immediate crash on boot] were reported, as well as the Linux. After a lot of discussion, the following CPUs were reported to not support multi-byte NOPs:


* VIA C3 Nehemiah
* VIA C3 Nehemiah
Line 90: Line 90:
Instead of only adding multi-byte NOPs to i686 and better machines during the kernel build, the plan was to only use multi-byte NOPs at runtime based on whether the CPU supported running multi-byte NOPs.
Instead of only adding multi-byte NOPs to i686 and better machines during the kernel build, the plan was to only use multi-byte NOPs at runtime based on whether the CPU supported running multi-byte NOPs.


Unfortunately the developers found the GNU Assembler would add multi-byte NOPs all the time for i686 and Virtual PC would freeze during detection of multi-byte NOP support. In the end they just threw their arms up and said 'no multi-byte NOPs at all on 32-bit x86'.
Unfortunately the developers found the GNU Assembler would add multi-byte NOPs all the time for i686 and Virtual PC would freeze during detection of multi-byte NOP support. In the end they just threw their arms up and said 'no multi-byte NOPs at all on 32-bit x86.


As a result, the 'nopl' flag found in /proc/cpuinfo which would have shown if the CPU supported multi-byte NOPs is always hidden on 32-bit x86 and always shown on 64-bit x86, making it effectively useless.
As a result, the 'nopl' flag found in /proc/cpuinfo which would have shown if the CPU supported multi-byte NOPs is always hidden on 32-bit x86 and always shown on 64-bit x86, making it effectively useless.


== GNU Assembler confusion ==
== GNU Assembler confusion ==
In 2008 in the midst of the kernel fallout the GNU Assembler bug [https://sourceware.org/bugzilla/show_bug.cgi?id=6957 i386 NOPs must be derived from march not mtune] was reported.
In 2008 in the midst of the kernel fallout the GNU Assembler bug [https://sourceware.org/bugzilla/show_bug.cgi?id=6957 i386 NOPs must be derived from march not mtune].


When compiling code you can specify which CPU family to support and which specific CPU to optimize for. The kernel developers found that the GNU Assembler wouldn't add multi-byte NOPs if you targeted the i686 family, instead it only added them if you targeted the i686 CPU (the Pentium Pro). This was confusing for a few reasons:
When compiling code you can specify which CPU family to support and which specific CPU to optimize for. The kernel developers found that the GNU Assembler wouldn't add multi-byte NOPs if you targeted the i686 family, instead it only added them if you targeted the i686 CPU (the Pentium Pro). This was confusing for a few reasons:
Line 178: Line 178:
In 2020 [https://github.com/sarah-walker-pcem/pcem/commit/b973755ca376dbb47c3a8c85a53f4058f0ccc54d Add hintable NOPs for Pentium Pro and II.] was committed to PCem.
In 2020 [https://github.com/sarah-walker-pcem/pcem/commit/b973755ca376dbb47c3a8c85a53f4058f0ccc54d Add hintable NOPs for Pentium Pro and II.] was committed to PCem.


In 2022 [https://github.com/joncampbell123/dosbox-x/pull/3390 src/cpu: Implement hinting NOPs] was merged to DOSBox-X, the only DOSBox variant that supports Pentium Pro and newer CPUs.
As of 2022 no DOSBox variant supports these hinting NOPs.


== Intel CET ==
== Intel CET ==
Line 207: Line 207:
* To others i686 is a baseline for various 32-bit x86 processors
* To others i686 is a baseline for various 32-bit x86 processors


Something else to just tack on here is that I spent a non-trivial amount of time trying to dig up old copies of Intel web pages and documentation. By the way Intel: When you make a new revision of a document you don't have to destroy the old ones.
Something else to just tack on here is that I spent a non-trivial amount of time trying to dig up old copies of Intel web pages and documentation. When you make a new revision of a document you don't have to destroy the old ones.
Please note that all contributions to JookWiki are considered to be released under the Creative Commons Zero (Public Domain) (see JookWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)