Skip to content

Commit

Permalink
Merge pull request #19627 from hrydgard/consider-kernel-vram-invalid
Browse files Browse the repository at this point in the history
Memory::IsValidAddress: Consider VRAM with a kernel flag invalid.
  • Loading branch information
hrydgard authored Nov 13, 2024
2 parents 2d96304 + d2ffac5 commit b566267
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Core/MemMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ inline bool IsValidAddress(const u32 address) {
if ((address & 0x3E000000) == 0x08000000) {
return true;
} else if ((address & 0x3F800000) == 0x04000000) {
return true;
return address < 0x80000000; // Let's disallow kernel-flagged VRAM. We don't have it mapped and I am not sure if it's accessible.
} else if ((address & 0xBFFFC000) == 0x00010000) {
return true;
} else if ((address & 0x3F000000) >= 0x08000000 && (address & 0x3F000000) < 0x08000000 + g_MemorySize) {
Expand All @@ -300,7 +300,7 @@ inline bool IsValid4AlignedAddress(const u32 address) {
if ((address & 0x3E000003) == 0x08000000) {
return true;
} else if ((address & 0x3F800003) == 0x04000000) {
return true;
return address < 0x80000000; // Let's disallow kernel-flagged VRAM. We don't have it mapped and I am not sure if it's accessible.
} else if ((address & 0xBFFFC003) == 0x00010000) {
return true;
} else if ((address & 0x3F000000) >= 0x08000000 && (address & 0x3F000000) < 0x08000000 + g_MemorySize) {
Expand All @@ -310,12 +310,15 @@ inline bool IsValid4AlignedAddress(const u32 address) {
}
}


inline u32 MaxSizeAtAddress(const u32 address){
if ((address & 0x3E000000) == 0x08000000) {
return 0x08000000 + g_MemorySize - (address & 0x3FFFFFFF);
} else if ((address & 0x3F800000) == 0x04000000) {
return 0x04800000 - (address & 0x3FFFFFFF);
if (address & 0x80000000) {
return 0;
} else {
return 0x04800000 - (address & 0x3FFFFFFF);
}
} else if ((address & 0xBFFFC000) == 0x00010000) {
return 0x00014000 - (address & 0x3FFFFFFF);
} else if ((address & 0x3F000000) >= 0x08000000 && (address & 0x3F000000) < 0x08000000 + g_MemorySize) {
Expand Down

0 comments on commit b566267

Please sign in to comment.