Skip to content

Commit

Permalink
Merge pull request #15548 from unknownbrackets/crash-alignment
Browse files Browse the repository at this point in the history
Crash: Recover from unaligned CPU access
  • Loading branch information
hrydgard committed May 22, 2022
2 parents 4c6f6b6 + 21fb6e5 commit 957c37b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Core/MemFault.cpp
Expand Up @@ -111,15 +111,17 @@ bool HandleFault(uintptr_t hostAddress, void *ctx) {
#endif

// Check whether hostAddress is within the PSP memory space, which (likely) means it was a guest executable that did the bad access.
bool invalidHostAddress = hostAddress == (uintptr_t)0xFFFFFFFFFFFFFFFFULL;
if (hostAddress < baseAddress || hostAddress >= baseAddress + addressSpaceSize) {
// Host address outside - this was a different kind of crash.
return false;
if (!invalidHostAddress)
return false;
}


// OK, a guest executable did a bad access. Take care of it.

uint32_t guestAddress = (uint32_t)(hostAddress - baseAddress);
uint32_t guestAddress = invalidHostAddress ? 0xFFFFFFFFUL : (uint32_t)(hostAddress - baseAddress);

// TODO: Share the struct between the various analyzers, that will allow us to share most of
// the implementations here.
Expand Down

0 comments on commit 957c37b

Please sign in to comment.