News for hackers. Stuff that matters.
Re:Finding a CPU Design Bug in the Xbox 360 (2018) by barbazoo on Friday June 11, 2021 @10:07PM (#27480770)
Would it be possible to tell the CPU not to apply branch prediction in this one case?
Re:Finding a CPU Design Bug in the Xbox 360 (2018) by fulafel on Saturday June 12, 2021 @03:01AM (#27482269)
There's a "branch hint" in PowerPC, I wonder if that's acted on by the Xenon CPU in question.

edit: it's discussed in the comments as well but they don't know either. The author responds: "I can’t remember how PowerPC branch hints work but if the branch hint overrode the branch predictor then it could have avoided the bug."

Re:Finding a CPU Design Bug in the Xbox 360 (2018) by kmeisthax on Friday June 11, 2021 @10:27PM (#27480883)
No, because the branch predictor is just "on" or "off". You'd be wondering if you can make it not speculatively execute specific instructions. I'm going to infer from the article that there wasn't a way to do that and it was far too late to spin a new CPU revision to prohibit speculatively executed xdcbt.
Re:Finding a CPU Design Bug in the Xbox 360 (2018) by anarazel on Saturday June 12, 2021 @02:28AM (#27482102)
I assume one could have put a serializing instruction inside the "dangerous" path, which should then lead to the speculative execution path being rolled back before reaching the dangerous instruction. Obviously it'd also be expensive...
Re:Finding a CPU Design Bug in the Xbox 360 (2018) by tardyp on Saturday June 12, 2021 @03:24AM (#27482377)
I wonder why they didn't just make two separate routines without any branch except for loop. Then you would just make another safety offset to assume for the last loop iteration prediction.
Re:Finding a CPU Design Bug in the Xbox 360 (2018) by brucedawson on Saturday June 12, 2021 @03:43PM (#27486967)
That would _probably_ be safe, but you have to be sure that the xdcbt instructions in the "special" function are far enough into the function that speculative execution can never reach there. Pipelines are way deeper than most people realize so this might require a lot of instructions before the first xdcbt.

And then, for maximum performance you want prefetch instructions to be as early as possible. So, you immediately have a contradiction.

And, assuming that you resolve this there is still the risk that a mispredicted indirect branch could end up triggering an xdcbt. So, you end up with no guarantees anyway.

Re:Finding a CPU Design Bug in the Xbox 360 (2018) by saagarjha on Saturday June 12, 2021 @12:55PM (#27485712)
Perhaps an indirect branch elsewhere may be spuriously predicted to go to the instruction?
Re:Finding a CPU Design Bug in the Xbox 360 (2018) by netr0ute on Friday June 11, 2021 @10:22PM (#27480861)
You probably could have done the equivalent if it were IA-64, but I suspect you can't do this with plain old branch-prediction mechanisms.