Linux Kernel Drama: AMD's Spectral Chicken
Within the Linux x86 header file for MSRs there is the "ZEN2_SPECTRAL_CHICKEN" and within the AMD CPU code path is a bit of code for dealing with this chicken bit, and a code comment: "On Zen2 we offer this chicken (bit) on the altar of Speculation. This suppresses speculation from the middle of a basic block, i.e. it suppresses non-branch predictions. We use STIBP as a heuristic to filter out Zen2 from the rest of F17H."
Borislav Petkov, a longtime Linux engineer who originally worked for AMD more than a decade ago at the since-closed AMD Operating System Research Center and years since was employed by SUSE while a few months ago re-joined AMD, sought to clean-up this AMD Spectral Chicken code.
He sent out a patch with the message:
"We've had enough fun with the spectral chicken bit - name it what it really does: it suppresses non-branch predictions.
Rename defines to make it clear that it is Zen2 only.
No functional changes."
The AMD Zen 2 spectral chicken MSR bit is renamed to "ZEN2_DE_CFG2" and "ZEN2_DE_CFG2_SUPPRESS_NOBR_PRED" as well as cleaning up the code comment to refer to it as suppressing speculation for non-branch predictions. While nothing overly dramatic about this non-functional change, the original author of that code happened to be an Intel engineer.
Peter Zijlstra responded:
"NAK [Not Acknowledge], I had to write all this without *any* official communication from AMD, mostly on hear-say.
This gets to be the spectral chicken forever more as punishment. Next time AMD can try again, and if they manage to get their act together and publish something before I get to write the code and invent a name for a magical bit, they get to name it how they like."
To which Petkov raised that it's unlikely Peter will ever need to write such code again, to which Thomas Gleixner called that a purely speculative assumption.
For those not aware, a chicken bit typically refers to a bit that can be used for disabling some chip functionality should it prove faulty or problematic.
So it looks like the AMD spectral chicken code will be sticking around the Linux kernel for a bit more light-hearted fun.
This code was originally authored by an Intel Linux engineer as part of the speculative execution efforts and at the time AMD had less Linux engineers than they do now. In recent years AMD has been ramping up their Linux engineering staff to better handle their Linux kernel contributions and the timely enablement of new features both for Ryzen and EPYC. AMD's Linux kernel contributions have increased significantly in recent times and for enhancing their recent generations of products. So next time such an issue comes up if it's tackled by AMD engineers directly, they'll be able to name such bits as they wish while the Zen 2 Spectral Chicken looks like it will remain unchanged.