Re:Finding a CPU Design Bug in the Xbox 360
by luc157 on Monday January 08, 2018 @01:51AM
(#16095100)
As I understand it, the function that used the xdcbt instruction had an oversight that led to the first set of crashes, so it was rewritten to fix that issue. Even with the fix, the game programmer decided to remove the PREFETCH_EX flag, which is what caused the copy routine to use xdcbt in the first place. So xdcbt ended up in the compiled code, but the flag that caused it to be used wasn't there. The branch predictor ran it anyway, in an unsafe way, leading to the next set of crashes.
Re:Finding a CPU Design Bug in the Xbox 360
by brucedawson on Monday January 08, 2018 @02:02AM
(#16095132)
I think that the developer didn't yet have the fixed version. They thought they would be safe because they weren't passing PREFETCH_EX, but the branch predictor decided otherwise.
There were other ways that xdcbt could cause problems (what if the block of memory was freed before being purged from L1) so who knows, and I don't remember for sure.
Re:Finding a CPU Design Bug in the Xbox 360
by Gibbon1 on Monday January 08, 2018 @05:59AM
(#16095954)
I'm going to assume that somewhere in the code was something like
if(flags | PREFETCH_EX)
{
xdcbt
}
else
{
safe way
}
And the branch predictor would decide the xdcbt branch was most likely, executes xdcbt and then realizes oops and does it the safe way. Which would be okay except xdcbt is evil, it breaks cache coherency.
Re:Finding a CPU Design Bug in the Xbox 360
by unwind on Monday January 08, 2018 @08:55AM
(#16096704)
Nitpick: you meant & for a bitwise AND, of course.
Re:Finding a CPU Design Bug in the Xbox 360
by djhworld on Monday January 08, 2018 @09:31AM
(#16096916)
Wow, interesting to see feature flags causing this undesired effect!
Re:Finding a CPU Design Bug in the Xbox 360
by syncsynchalt on Monday January 08, 2018 @05:01PM
(#16101094)
Any if statement could cause this, doesn't have to be feature flags.
An untrained branch predictor could still take the "wrong" path even if none of the code that calls that if statement takes the bad path. That's presumably what happened here, the calling program removed all instances of PREFETCH_EX but the CPU would still sometimes execute that branch, such as on the first run through that function.
This is a lot like the problem of "don't think of a pink elephant". The mere existence of the "evil opcode" in the library means the CPU might execute it under certain circumstances.
Re:Finding a CPU Design Bug in the Xbox 360
by xenadu02 on Monday January 08, 2018 @03:48AM
(#16095496)
Even if they had the fixed version the branch predictor could still decide to predict the instruction would be hit right? Your ultimate analysis seems correct: the instruction is unsafe to have anywhere.
Re:Finding a CPU Design Bug in the Xbox 360
by syncsynchalt on Monday January 08, 2018 @05:03PM
(#16101110)
In humans we have a similar problem: https://en.wikipedia.org/wiki/Ironic_process_theory aka "don't think of a pink elephant"
Was the game no longer "using the xdcbt instruction", but the branch predictor caused issues, because they put a jmp instruction in front of it instead of removing the instruction entirely?