Commit Graph

824 Commits

Author SHA1 Message Date
Zephyron 5ca1f0e365 core/arm/nce: Implement TLB caching system
Adds a software TLB cache to improve memory access performance in the NCE
(Native Code Execution) system. Key changes include:

- Implement set-associative TLB with 64 sets and 8 ways
- Add TLB lookup before memory access in HandleGuestAccessFault
- Implement LRU replacement policy with access frequency consideration
- Add thread context caching to reduce overhead
- Add proper synchronization with mutex locks
- Add helper functions for TLB management (lookup, insert, invalidate)

This change should improve performance by reducing redundant memory
translations and providing faster access to frequently used pages.
2025-02-25 18:37:14 +10:00
Zephyron 7730d14b4a build: upgrade fmt and SDL2
Update fmt library to version 11.0.2 and make necessary adjustments:
- Replace fmt/format.h includes with fmt/ranges.h
- Add const qualifiers to formatter::format functions
- Update CMake to require fmt version 11

Additional dependency updates:
- Update SDL2 bundled version from 2.28.2 to 2.32.0
- Update catch2 to version 3.8.0
- Update vcpkg baseline to c82f74667287d3dc386bce81e44964370c91a289
2025-02-16 13:38:05 +10:00
Zephyron d4d3061eb7 arm/video: Fix shader extension and exception handling
Two main changes in this commit:

1. Replace NVIDIA-specific GL_NV_gpu_shader5 extension with the more widely
   supported GL_EXT_shader_explicit_arithmetic_types_float16 in the scaleforce
   shader. This improves compatibility across different GPU vendors.

2. Refactor ARM32 exception handling:
   - Restructure exception cases for better readability
   - Update exception handling to match current Dynarmic API
   - Fix indentation in switch statement
   - Remove AccessViolation case as it's no longer supported in current API

These changes improve shader compatibility and align the exception handling
with the current Dynarmic implementation.
2025-01-18 19:09:03 +10:00
Zephyron b938893599 memory: Improve null pointer and unmapped memory handling
- Update vcpkg baseline to a42af01b72c28a8e1d7b48107b33e4f286a55ef6
- Add SPIRV-Tools and SPIRV-Headers as submodules
- Update Vulkan-related submodules to latest stable versions
- Improve memory access error handling:
  - Add specific handling for null pointer accesses in ARM32 emulation
  - Return 0 for null pointer reads instead of undefined behavior
  - Silently ignore writes to null pointers
  - Add more detailed error messages distinguishing between null pointer
    access and other unmapped memory errors
  - Treat addresses below 0x1000 as potential null pointer accesses

These changes should provide more graceful handling of null pointer
accesses and improve stability when running games that attempt invalid
memory operations.
2025-01-18 15:20:13 +10:00
Zephyron 9ae0eeeb87 Revert incorrect copyright attribution for non-contributed files
- In commit b3facaa6bb, the copyright header was
  updated to include "Citron Homebrew Project" across multiple files, regardless
  of whether any contributions were made.

- This commit removes the incorrect attribution and reverts the copyright header
  to its previous state.

- Copyright attribution should only be added when meaningful contributions have
  been made to the file.

- This commit ensures proper compliance with copyright standards and maintains
  correct attribution to the respective contributors.

- Special thanks to Tachi for pointing out the need for these corrections and
  ensuring that proper attribution practices are followed.
2025-01-14 15:33:24 +10:00
Zephyron 167a9e1a5b
arm: Skip duplicate consecutive addresses in backtrace output
Adds logic to track and skip duplicate consecutive addresses when logging
backtraces. This improves log readability by removing redundant entries
that point to the same address in sequence.
2025-01-02 17:25:36 +10:00
Zephyron 468ace6b0b
core: Update copyright headers
- Update copyright headers to include Citron Homebrew Project
- Add 2025 to copyright years
2024-12-31 17:36:08 +10:00
Zephyron b3facaa6bb
chore: update project references and add Citron copyright
- Replaced all references to the old project name with Citron.
- Added Citron copyright information alongside existing notices in all files.
2024-12-31 17:07:49 +10:00
GPUCode d4acdac168 core: Support multiple modules per patcher 2024-01-15 00:46:05 +02:00
Liam ddda76f9b0 core: track separate heap allocation for linux 2023-12-25 23:30:56 -05:00
Liam 419055e484 kernel: instantiate memory separately for each guest process 2023-12-22 21:52:49 -05:00
Fernando S f1cb14eb54
Merge pull request #12417 from liamwhite/arm64-gcc-fix
nce: hide shadowing warnings from dynarmic headers
2023-12-20 18:46:08 +01:00
Liam 4b60aec190 nce: hide shadowing warnings from dynarmic headers 2023-12-20 11:07:50 -05:00
Liam 93c19a40bf nce: increase handler stack size 2023-12-19 15:24:13 -05:00
Liam a94721fde0 nce: fix read size in simd immediate emulation 2023-12-19 12:51:19 -05:00
Liam a05c242429 nce: adjust initialization for repeated calls 2023-12-11 23:02:01 -05:00
Liam bd59934350 nce: implement instruction emulation for misaligned memory accesses 2023-12-10 18:23:42 -05:00
Liam fe5e4bd846 debug: fix reading of module names 2023-12-09 11:18:10 -05:00
Fernando S 8a79dd2d6c
Merge pull request #12236 from liamwhite/cpu-refactor
core: refactor emulated cpu core activation
2023-12-06 14:19:17 +01:00
Liam f0ee3e29cb arm: fix context save of vector regs 2023-12-04 22:19:11 -05:00
Liam 45c87c7e6e core: refactor emulated cpu core activation 2023-12-04 10:37:16 -05:00
Liam 9de99839bd nce: fix pre-text patch for single modules 2023-12-02 16:14:52 -05:00
GPUCode 4a3abba16d core: Rename patcher file 2023-11-29 23:49:16 +02:00
GPUCode 6432508740 oaknut: Address warnings 2023-11-25 00:47:43 -05:00
GPUCode 9ff8d0f3e6 Address more review comments 2023-11-25 00:47:43 -05:00
Liam cf534f5149 arm_nce: skip data aborts for crash handling parity 2023-11-25 00:47:36 -05:00
GPUCode 1cde01c8c8 arm: Print backtrace on data abort 2023-11-25 00:47:36 -05:00
Liam f542a3bb7a patch: check offsets from first code word 2023-11-25 00:47:36 -05:00
Liam 263b7a44f9 arm_nce: skip dc cvac on possibly write-protected areas 2023-11-25 00:47:36 -05:00
GPUCode 6de2edcca1 Address some review comments 2023-11-25 00:47:35 -05:00
Liam 9f91ba1f73 arm: Implement native code execution backend 2023-11-25 00:46:47 -05:00
Liam e3b510a4b4 core: check for thread dpc before eret 2023-11-13 11:28:23 -05:00
Liam 8c59543ee3 kernel: update KProcess 2023-10-21 20:03:41 -04:00
liamwhite fca7d975fd
Merge pull request #10839 from lat9nq/pgc-plus
general: Reimplement per-game configurations
2023-08-02 14:25:52 -04:00
liamwhite d3da1e6517
Merge pull request #10990 from comex/ubsan
Fixes and workarounds to make UBSan happier on macOS
2023-07-26 10:33:28 -04:00
Liam 05bc024260 core: remove remaining uses of dynamic_cast 2023-07-21 19:37:29 -04:00
lat9nq d146dd9d12 settings,general: Rename non-confirming enums 2023-07-21 10:56:54 -04:00
comex d7c532d889 Fixes and workarounds to make UBSan happier on macOS
There are still some other issues not addressed here, but it's a start.

Workarounds for false-positive reports:

- `RasterizerAccelerated`: Put a gigantic array behind a `unique_ptr`,
  because UBSan has a [hardcoded limit](https://stackoverflow.com/questions/64531383/c-runtime-error-using-fsanitize-undefined-object-has-a-possibly-invalid-vp)
  of how big it thinks objects can be, specifically when dealing with
  offset-to-top values used with multiple inheritance.  Hopefully this
  doesn't have a performance impact.

- `QueryCacheBase::QueryCacheBase`: Avoid an operation that UBSan thinks
  is UB even though it at least arguably isn't.  See the link in the
  comment for more information.

Fixes for correct reports:

- `PageTable`, `Memory`: Use `uintptr_t` values instead of pointers to
  avoid UB from pointer overflow (when pointer arithmetic wraps around
  the address space).

- `KScheduler::Reload`: `thread->GetOwnerProcess()` can be `nullptr`;
  avoid calling methods on it in this case.  (The existing code returns
  a garbage reference to a field, which is then passed into
  `LoadWatchpointArray`, and apparently it's never used, so it's
  harmless in practice but still triggers UBSan.)

- `KAutoObject::Close`: This function calls `this->Destroy()`, which
  overwrites the beginning of the object with junk (specifically a free
  list pointer).  Then it calls `this->UnregisterWithKernel()`.  UBSan
  complains about a type mismatch because the vtable has been
  overwritten, and I believe this is indeed UB.  `UnregisterWithKernel`
  also loads `m_kernel` from the 'freed' object, which seems to be
  technically safe (the overwriting doesn't extend as far as that
  field), but seems dubious.  Switch to a `static` method and load
  `m_kernel` in advance.
2023-07-15 12:00:28 -07:00
Liam 82568412f6 arm_interface: correct breakpoint rewind condition 2023-07-09 12:03:25 -04:00
Merry e3c548d081 arm_dynarmic_32: Remove disabling of block linking on arm64 2023-06-27 23:51:49 +01:00
Liam 8506915208 core: decouple ARM interface from Dynarmic 2023-06-12 22:11:51 -04:00
bunnei 9c94faaa2b core: arm_dynarmic_32: Update SaveContext/LoadContext. 2023-04-01 17:03:08 -07:00
Liam 41d99aa89d memory: rename global memory references to application memory 2023-03-23 20:28:47 -04:00
Liam fb49ec19c1 kernel: use KTypedAddress for addresses 2023-03-22 09:35:16 -04:00
Liam ceda2d280e general: rename CurrentProcess to ApplicationProcess 2023-02-13 19:03:12 -05:00
Liam 2415d37ea2 kernel/svc: switch to generated wrappers 2023-02-06 23:57:44 -05:00
Kelebek1 42b16bb33a Be careful of mangled out of bounds read 2023-01-14 19:53:55 +00:00
Kelebek1 80a55c1663 Add stacktrace symbol demangling 2023-01-14 04:43:21 +00:00
Liam 1ee0540f82 externals: update dynarmic, xbyak 2023-01-05 18:06:06 -05:00
Liam 6072b22a0b core: add option to break on unmapped access 2022-12-02 08:25:45 -05:00