Commit graph

9648 commits

Author SHA1 Message Date
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
Tobias
04868ab9da
file_sys/content_archive: Detect compressed NCAs (#11047) 2023-07-12 23:17:18 +02:00
bunnei
28598c9090
Merge pull request #10985 from liamwhite/handle-translate
k_server_session: translate special header for non-HLE requests
2023-07-11 16:49:24 -07:00
bunnei
ce7c418e0c
Merge pull request #10996 from Kelebek1/readblock_optimisation
Use spans over guest memory where possible instead of copying data
2023-07-10 18:54:19 -07:00
Liam
82568412f6 arm_interface: correct breakpoint rewind condition 2023-07-09 12:03:25 -04:00
Liam
4540bcfaf7 k_server_session: translate special header for non-HLE requests 2023-07-08 01:01:49 -04:00
liamwhite
8bf46f48f8
vfs_real: use open file size for getting size (#11016) 2023-07-06 23:43:53 +02:00
german77
9cd698e8ad service: nfc: Ensure controller is in the correct mode 2023-07-02 19:21:16 -06:00
Kelebek1
6f7cb69c94 Use spans over guest memory where possible instead of copying data. 2023-07-02 23:09:48 +01:00
liamwhite
95ceae40e6
Merge pull request #10998 from Morph1984/qt-stop-messing-with-me
core_timing: Remove GetCurrentTimerResolution in CoreTiming loop
2023-07-02 17:38:28 -04:00
liamwhite
daaf03942f
Merge pull request #10969 from Morph1984/k-synchronize
kernel: Synchronize
2023-07-02 17:38:14 -04:00
Morph
c3fbc8d2fe core_timing: Remove GetCurrentTimerResolution in CoreTiming loop
Other programs may change this value, but if thousands of syscalls in this loop is undesirable, then we can just set this once.
2023-07-02 15:08:04 -04:00
liamwhite
eaa62aee98
Merge pull request #10942 from FernandoS27/android-is-a-pain-in-the-a--
Memory Tracking: Add mechanism to register small writes when gpu page is contested by GPU
2023-07-02 11:29:01 -04:00
liamwhite
87080e71c5
Merge pull request #10710 from liamwhite/romfs2
fsmitm_romfsbuild: avoid full path lookups
2023-07-02 11:28:55 -04:00
Morph
b94e576653 kernel: Synchronize 2023-07-01 16:21:22 -04:00
Morph
1a46823ec5 parcel: Optimize small_vector sizes 2023-06-30 22:05:28 -04:00
Morph
310b6cf4af general: Use ScratchBuffer where possible 2023-06-30 21:49:59 -04:00
Fernando Sahmkow
0e6b559c98 Memory Tracker: Use 64 bit atomics instead of 128 bits 2023-06-29 12:25:12 +02:00
Fernando Sahmkow
da440da9f5 Memory Tracking: Optimize tracking to only use atomic writes when contested with the host GPU 2023-06-28 21:32:45 +02:00
Fernando Sahmkow
47d0d292d5 MemoryTracking: Initial setup of atomic writes. 2023-06-28 19:34:21 +02:00
Liam
edd54abee4 fsmitm_romfsbuild: avoid full path lookups 2023-06-27 23:25:47 -04:00
Merry
e3c548d081 arm_dynarmic_32: Remove disabling of block linking on arm64 2023-06-27 23:51:49 +01:00
german77
bf641e2964 core: hid: Allow to read bin files while switch controller is available 2023-06-24 18:59:55 -06:00
german77
5aa208e264 input_common: Dont try to read/write data from 3rd party controllers 2023-06-24 18:59:55 -06:00
liamwhite
a674022434
Merge pull request #10859 from liamwhite/no-more-atomic-wait
general: remove atomic signal and wait
2023-06-23 09:27:14 -04:00
liamwhite
87b9b5d10f
Merge pull request #10842 from german77/native_mifare
input_common: Implement native mifare/skylander support for joycons/pro controller
2023-06-23 09:27:00 -04:00
Liam
1dd166f766 vfs_real: lock concurrent accesses 2023-06-23 00:57:24 -04:00
bunnei
2fc5dedf69
Merge pull request #10457 from Kelebek1/optimise
Remove memory allocations in some hot paths
2023-06-22 21:53:07 -07:00
bunnei
3f3e4efb30
Merge pull request #10806 from liamwhite/worst-fs-implementation-ever
vfs_real: misc optimizations
2023-06-22 21:46:50 -07:00
Liam
1586f1c0b1 general: remove atomic signal and wait 2023-06-22 09:25:23 -04:00
Kelebek1
5da70f7197 Remove memory allocations in some hot paths 2023-06-22 08:05:10 +01:00
bunnei
e3122c5b46
Merge pull request #10086 from Morph1984/coretiming-ng-1
core_timing: Use CNTPCT as the guest CPU tick
2023-06-21 21:12:46 -07:00
bunnei
8cb6b33809
Merge pull request #10841 from liamwhite/math-is-hard
vfs_concat: fix offset calculation when not aligned to file boundary
2023-06-21 21:07:08 -07:00
Narr the Reg
84d43489c5 input_common: Implement native mifare support 2023-06-21 17:54:58 -06:00
lat9nq
ae1a8a7dc7 time_zone_manager: Add null terminator
We aren't null-terminating this string after the copy, and we need to.
2023-06-20 15:54:28 -04:00
lat9nq
fd5d7947f6 time_zone_manager: Stop on comma
This is a deviation from the reference time zone implementation. The
actual code will set a pointer to the time zone name here, but for us we
have a limited number of characters to work with, and the name of the
time zone here could be larger than 8 characters.

We can make the assumption that time zone names greater than five
characters in length include a comma that denotes more data. Nintendo
just truncates that data for the name, so we can do the same.

time_zone_manager: Check for length of array

Just to be double sure that we never break past the array length,
directly compare against it.
2023-06-20 15:54:05 -04:00
Liam
e5f1b22e16 vfs_concat: verify short read 2023-06-19 09:47:05 -04:00
Liam
b0beca52a3 vfs_concat: fix offset calculation when not aligned to file boundary 2023-06-18 22:21:29 -04:00
bunnei
6e293be20b
Merge pull request #10797 from lat9nq/tzdb-patch
time: Various time zone fixes
2023-06-17 23:47:16 -07:00
lat9nq
b99c4dd568 time_zone_service: Always write time zone rule data
Switch firmware will initialize this data even if the given parameters
are invalid. We should do the same.
2023-06-17 20:53:39 -04:00
lat9nq
e34e1b1c95 k_thread: Use a mutex and cond_var to sync bool
std::atomic<bool> is broken on MinGW and causes deadlocks there.
Use a normal cond var in its stead.
2023-06-17 15:25:36 -04:00
liamwhite
a1adcc31d3
Merge pull request #10731 from german77/misc_fixes
service: nfc: Accuracy fixes
2023-06-16 18:18:24 -04:00
Liam
94e7cb05da vfs_real: ensure size cache is reset on write 2023-06-16 16:43:14 -04:00
Liam
bf47f777b1 patch_manager: remove unnecessary GetSize calls 2023-06-16 16:29:10 -04:00
Liam
734242c5bc vfs_real: misc optimizations 2023-06-16 16:29:06 -04:00
lat9nq
8d8f850bd6 time_zone_manager: Compare to the correct boolean
Reference implementation does not compare the booleans as we had them.
Use the correct ones as in the reference.

Also adds an assert. I have been made aware of a crash here and am
not able to reproduce currently.
2023-06-15 23:05:41 -04:00
lat9nq
03e8d9aca7 nx_tzdb: Correct Antarctica spelling 2023-06-15 23:03:54 -04:00
bunnei
ce0510913a
Merge pull request #10729 from liamwhite/windows-is-a-meme
vfs_real: add file LRU cache for open file limits
2023-06-14 18:32:25 -07:00
Narr the Reg
61b4588517 service: nfc: Read tag protocol only for nfc backend 2023-06-14 18:16:23 -06:00
Narr the Reg
b1b13ddc6b service: nfc: Accuracy fixes 2023-06-14 18:08:35 -06:00