104 karma · joined March 4, 2024
It does not really matter how execution ended up in the HV in the first place. The misprediction happens due to having a branch-to-register instruction.
If Google decides to pull this off, then I guess reflashing to a custom ROM with this crap patched out will be a very first step I'll be recommending to anyone who cares.
The trick is this (copied vebratim from Linux):
#define __is_constexpr(x) (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
Explanation: if x is a constant expression, then multiplying it by zero yields a constant 0, and casting a constant 0 to void* makes a null pointer constant. And the ternary expression, if one of its sides is a null pointer constant, collapses to the type of the other side (thus the type of the returned pointer will be int*, and the sizeof will match). And if x was not constant, then the lefthand side would not be considered a null pointer constant by type inference, the type of the ternary expression will be void*, and the sizeof check will not match.
With a few more clever tricks, it's even possible to implement a compile-time "type ternary expression", like this: TYPE_IF(2 * 2 == 4, int, long). This is left as an exercise for the reader.
It seems that GitHub still serves the commit history through the existing forks of the repo. According to archive.org, this commit corresponds to the last release of yuzu-mainline before the repo takedown: http://web.archive.org/web/20240304185516/https://github.com...