Commit Graph

143 Commits

Author SHA1 Message Date
Henrik Rydgård 34473fc621 Add a compat flag to map some extra memory at address 0.
Can be used to work around certain types of crashes without having to
disable fast memory.
2026-01-23 15:14:15 +01:00
Henrik Rydgård 5f7a937466 Rename ValidSize to ClampValidSizeAt 2025-12-30 20:31:07 +01:00
Henrik Rydgård 5260be6f69 Warning fixes, alignment checks 2025-05-15 09:48:23 +02:00
Henrik Rydgård 644f5e4e6c Expose PSPModule (so the debugger can access it later) 2025-03-31 09:56:08 +02:00
Henrik Rydgård 2b558eb545 Fix regression in Tomb Raider Legends
Need to make sure a buffer size check happens before the buffer is
accessed - since the game calls sceAtracSetDataAndGetID with both buffer
and bufferSize as 0, and it expects to receive TOO_SMALL and not a
memory exception.

Thanks to @sum2012 for quick investigationh help.
2025-03-23 07:11:01 +01:00
Henrik Rydgård e45333d1d8 Fix the sceSas context connection 2025-03-18 09:36:34 +01:00
Nemoumbra 1fc49d8011 Added host ptr -> virt ptr converters 2025-02-12 04:13:12 +03:00
Nemoumbra 9528d5d8be Added proper const overloads for PSPPointer methods 2025-02-12 03:26:01 +03:00
Henrik Rydgård 2edc3085a5 PSPPointer<>: Replace some fiddly memsets with use of a new FillWithZero function. 2025-01-05 23:43:41 +01:00
White Blood Cell ee0b0fce6c sceNetInet and sceNetResolver support.
Co-authored-by: AdamN <anr2000@gmail.com>
2025-01-04 17:28:36 +01:00
Henrik Rydgård d2ffac57dc Memory::IsValidAddress: Consider VRAM with a kernel flag invalid.
We don't have it mapped in our memory map, so this can actually crash
checked reads like Read_U32.

Since it isn't mapped, and it can't possibly be valid in retail PSP
games to access VRAM this way, I don't think this will cause any
problems.

However, if it does, we'll have to add the corresponding mappings to the
memory map.
2024-11-12 10:41:14 +01:00
Henrik Rydgård 5926886c0c Some include cleanup, delete some obsolete code 2024-07-25 14:52:41 +02:00
Henrik Rydgård c332d564db IRInterpreter: Cache the MIPSState pointer in a local, faster address check 2024-05-10 23:21:51 +02:00
Henrik Rydgård 70ae4a35c1 Fix faulty formula for block transfer size-check. 2024-05-10 13:50:49 +02:00
Henrik Rydgård 0b91aa50ee Improve memory safety, add bugfix to little-used sysclib functions 2024-05-05 14:19:49 +02:00
Henrik Rydgård c004bea5e4 Use memchr in IsValidNullTerminatedString 2024-05-05 12:23:36 +02:00
Henrik Rydgård 85f8fd0bdb Safety fix for GetCharPointer
Uses IsValidNullTerminatedString from #19103 by Kethen
2024-05-05 12:09:08 +02:00
Katharine Chui 47c7fab928 optimize Memory::IsValidNullTerminatedString 2024-05-03 21:00:26 +08:00
Katharine Chui b570cacd90 add Memory::IsValidNullTerminatedString 2024-05-01 22:58:01 +08:00
Ethan O'Brien 8426b35a80 Cleanup emscripten libretro build target 2023-08-12 14:38:35 -05:00
Unknown W. Brackets 9cebfc31b3 Debugger: Avoid unaligned reads in expressions.
Potentially, a watch or break condition could crash if it was unaligned
between mirrors.  This might happen if it's not the condition you wanted,
especially.  Play it safe.
2023-04-12 01:14:30 -07:00
Henrik Rydgård e1a48d74c4 A bit more GetPointer cleanup.
Probably not worth it for performance reasons, but some semantic cleanup
is good, especially the accidental GetPointer -> writable casts without
using GetPointerWrite.

Using Unchecked on already checked pointers, or when we'd crash anyway
if it returned nullptr, is good for clarity.
2023-01-10 12:13:47 +01:00
Henrik Rydgård 91b7bf986e Can do an unchecked GetPointer here 2023-01-01 20:48:03 +01:00
Henrik Rydgård a4d3e0ead8 Add range checks in replaced memcpy/memset functions. (#16693)
* Add range checks in replaced memcpy/memset functions.

Keep seeing especially Replace_memcpy as a semi-rare crash in the
reports. Hopefully this will take care of it, though if games hit this,
they're probably on their way to failing somehow anyway.

* Alternate approach, correctly causing memory exceptions if not ignoring
2023-01-01 18:25:40 +00:00
Henrik Rydgård 65c016d154 Fix dialog rendering (PPGe). Fixes #15954
Was caused by 867eb99 , part of #15950 .
2022-09-04 00:42:14 +02:00
Unknown W. Brackets ccd4e92184 Kernel: Use PSPPointer for status objects.
Code makes more sense when reading ->size rather than offset 0.
2022-09-03 10:44:12 -07:00
Unknown W. Brackets 3a372aa615 HLE: Remove misc usage of WriteStruct().
Prefer PSPPointer and notifying.
2022-09-03 10:44:11 -07:00
Henrik Rydgård e6403d7157 Split GetPointer into two versions, to help with const correctness 2022-07-24 13:26:19 +02:00
Unknown W. Brackets 2479d52202 Global: Reduce includes of common headers.
In many places, string, map, or Common.h were included but not needed.
2022-01-30 16:35:33 -08:00
Unknown W. Brackets 32ea8734fb MemMap: Cleanup memory mirror pointers. 2021-04-23 22:43:21 -07:00
Unknown W. Brackets 744d17e13c Core: Correct ValidSize outside scratchpad.
And simplify all the scratchpad valid checks.
2021-04-21 19:32:22 -07:00
Unknown W. Brackets 124774fecb Debugger: Provide memory mapping ranges.
Most of these are entirely static, but introspection is good for APIs.
2021-04-04 21:27:30 -07:00
Unknown W. Brackets bab9581901 Core: Unbreak ValidSize limits.
Broken in bdd2029.
2021-03-28 19:42:29 -07:00
aliaspider 9a3e5879bb Global: Correct many endian types and casts. 2021-02-18 22:25:24 -08:00
Henrik Rydgård 5ed5947804 Merge pull request #13943 from unknownbrackets/dialog
Dialog: Simulate volatile memory lock behavior
2021-02-15 16:47:06 +01:00
Gleb Mazovetskiy 0fb42e07a6 CMake: Rename USE_ADDRESS_SANITIZER to USE_ASAN
For consistency with USE_UBSAN
2021-01-29 23:10:22 +00:00
Unknown W. Brackets e42dac2fb4 Dialog: Simulate volatile memory lock behavior.
Also simply clear to zero, which isn't exactly correct but should be
fairly close.  See #8288 (NBA Live 08 hang.)
2021-01-18 11:07:21 -08:00
Henrik Rydgård ad2ec61c98 Retry the masked memory experiment on iOS. Turns out it was the shader generator bug that broke things. 2020-11-03 21:04:03 +01:00
Henrik Rydgård f429c97392 Disable masked memory on iOS again. The cure was worse than the disease apparently.
Needs more investigation before we re-enable.

See #13616
2020-11-03 15:46:21 +01:00
Henrik Rydgård f050d51973 Enable masked memory addressing on iOS
(removes the need for functioning memory mirrors)

I have a theory that this is related to the iOS 14 problems: #13451
2020-11-03 00:20:19 +01:00
Henrik Rydgård ee11c796a1 Revert "Try my theory about memory mirrors on iOS 14. See #13451"
This reverts commit 0f647684a3.
2020-10-23 06:57:56 +02:00
Henrik Rydgård 0f647684a3 Try my theory about memory mirrors on iOS 14. See #13451 2020-10-22 10:12:21 +02:00
Henrik Rydgård b8e8325888 Fix text issue in God Eater Burst. Forgot that games can allocate texture in volatile memory too.
We considered any texture from kernel memory "reliable", which is wrong
since games can allocate out of the upper half of kernel RAM, which is
called "volatile" memory.

Fixes issue #13511
2020-10-14 00:09:08 +02:00
Henrik Rydgård 3e3a40da8c Mark the PPGe font texture as reliable to avoid hashing it. 2020-09-22 21:13:30 +02:00
Henrik Rydgård a22181df1c Partially fix Katamari (flicker due to choice of the wrong depth buffer still happening). 2020-09-01 22:54:36 +02:00
Henrik Rydgård 92bbe974cd Prevent reporting a bad memory access just because Tekken creates a mutex with a null name. 2020-07-20 10:01:22 +02:00
Henrik Rydgård 0829543987 Third part of getting rid of PanicAlert 2020-07-19 20:34:02 +02:00
Henrik Rydgård 626d173d10 Split the fault handling from MemMap.cpp to MemFault.cpp. 2020-07-15 12:12:57 +02:00
Henrik Rydgård c3016fe6a5 Mac/Linux buildfixes 2020-07-14 09:25:45 +02:00
Henrik Rydgard 1fce6de8b1 Simple exception handler so we can ignore accesses that happen within the PSP memory space. 2020-07-14 09:25:45 +02:00