1584 Commits
Author SHA1 Message Date
Ryan Houdek db6f4786d2 ARM64: Fixes bugs in unaligned atomic signal handlers
There were two bugs in here.

The first bug here is with with the CMPXCHG emulation.
1) If the *Expected* value did *NOT* match what was in memory
2) *AND* The *Desired* value matched the memory value
3) The CAS would incorrectly return success for this CMPXCHG
4) Thus setting ZF incorrectly

The second bug comes from atomic memory operations (Add, CLR, EOR, SET, SWAP).
This operation is a Load + <Op> + CAS
1) If the memory backing between the Load and CAS changes
2) The CAS would then fail
3) On Atomic memory operations this should then retry to ensure it completes successfully
4) We were not retrying on failure in this case
5) Thus something like `LOCK INC` would have never atomically incremented correctly
6) We can't use our ASM unit tests to test this, since it needs thread contention.
2021-06-30 21:43:44 -07:00
Lioncash 448cbc8e3d Arm64: Use regular function pointers with CAS handling functions
Given these are called in a loop repeatedly, where we know we'll always
have a set function to call, std::function adds a little bit of
overhead.
2021-06-30 22:03:08 -04:00
Lioncash c9615032a9 OpcodeDispatcher: Make use of if constexpr
Given these arguments are template arguments we can use if constexpr
with these branches to guarantee their elision.
2021-06-30 21:11:28 -04:00
Lioncash c4216755ab Context: Add alias for exit handler
Places the definition in one place so it doesn't need to be written
several times.
2021-06-30 19:50:57 -04:00
Ryan Houdek 09071e4279 Merge pull request #1135 from lioncash/ctx
Context: Place return value from GenerateIR into a struct
2021-06-30 16:39:24 -07:00
Lioncash 46a6e79233 Context: Place return value from GenerateIR into a struct
This makes it a little more straightforward to see what these return
values mean without needing to look at the implementation.

These tuples were also getting a little bit large.
2021-06-30 19:30:03 -04:00
Lioncash 9d5f9d6783 OpcodeDispatcher: Mark lookup tables as static in Get{Src,Dst}Size
Same behavior, but allows clang to elide pushing all of these values on
and off the stack, particularly given these are called quite frequently
throughout the opcode dispatcher.
2021-06-30 18:22:14 -04:00
Stefanos Kornilios Mitsis Poiitidis 176b3292ed Merge pull request #1132 from Sonicadvance1/move_elfutils_frontend
Moves ELF handlers from FEXCore to frontend
2021-06-29 09:38:30 +03:00
Stefanos Kornilios Mitsis Poiitidis 2d8304547e Merge pull request #1128 from Sonicadvance1/remove_logs
Remove logs that are just noise at this point
2021-06-29 09:34:12 +03:00
Stefanos Kornilios Mitsis Poiitidis 4880097f89 Merge pull request #1122 from Sonicadvance1/CreateAppConfig
FEXConfig: Have it create AppConfig folder on save
2021-06-29 09:29:59 +03:00
Ryan Houdek ed4c5d9704 Remove logs that are just noise at this point
Don't print how many instructions are installed in the tables.
  This isn't useful anymore

Not installing signal 32 and 33 are something we don't support right now. Stop complaining in that case.

Stop printing when a thread is starting up and shutting down. If you want to see this then gdb shows it well.

Don't print clone flags unless we are hitting a case where we are printing another log message.
2021-06-27 02:09:27 -07:00
Ryan Houdek 069e279a18 Moves ELF handlers from FEXCore to frontend
Only the frontends need to deal with ELF files specifically.
The backend doesn't need to be aware of them at all.
Since the ELF handling is the frontend's responsibility, move all the code to the frontend.
2021-06-27 02:07:56 -07:00
Ryan Houdek bb85f90f78 FEXConfig: Have it create AppConfig folder on save
Otherwise it will claim that the AppConfig was saved and won't actually be
2021-06-25 04:03:16 -07:00
Ryan Houdek d4dd4d0972 Copy over siginfo_t to the guest more correctly
si_addr will still be incorrect. What matters more here is that SIGCHLD gets correct information.
The guest needs SIGCHLD ifnromation to be filled out correctly, otherwise TTY handoff hangs
with the child process stopped.
2021-06-24 20:42:39 -07:00
Ryan Houdek 79db23b7d3 Define some of 32-bit x86 siginfo_t 2021-06-24 20:42:39 -07:00
Ryan Houdek fbfc774446 Implements support for deferred signal handler installation
I saw a red herring that I thought the high cpu usage in steamwebhelper could come from signal handlers.
This turned out to not be the case, but now I've got this implemented.

Installs the few signal handlers that we need upfront but for everything that isn't a mandatory signal
we instead now wait until the guest also installs that signal handler.
This fixes #1107
2021-06-24 20:42:39 -07:00
Ryan Houdek d587485383 Implements 32-bit iret instruction
This is necessary for wine and some wine-like emulation layers.

With this implemented then some Saint's Row games start running.

Fixes #1100
2021-06-21 00:20:44 -07:00
Lioncash e369626929 BitUtils: Add BitCast
libc++ doesn't implement std::bit_cast, so we can provide our own for
the time being.
2021-06-17 01:30:07 -04:00
Lioncash cba4ca7d01 General: Resolve -Wcast-qual warnings
Ensures that qualifiers are preserved on references and pointers to
prevent undefined behavior.
2021-06-17 01:25:39 -04:00
Lioncash ef7aff796f General: Resolve -Wignored-qualifiers warnings
Removes const qualifiers that don't do anything to the interface.
2021-06-16 21:51:45 -04:00
Lioncash e6e170805e Core: Remove unused DefaultFallbackCore
This doesn't seem to be hooked up to anything.
2021-06-16 19:58:05 -04:00
Ryan Houdek 1f89ca7218 Merge pull request #1090 from lioncash/array
Frontend: Make lookup tables static in MapModRMToReg
2021-06-16 14:44:35 -07:00
Lioncash a9623f0e2a Frontend: Shrink MapModRMToReg array size from uint64_t to uint32_t
This function only returns a 32-bit value, so we can save some space by
using uint32_t instead.
2021-06-16 16:59:56 -04:00
Lioncash c40ca14b5b Frontend: Make lookup tables static in MapModRMToReg
Allows clang to emit better code, since it doesn't need to push all the
values onto the stack and off again for every invocation.
2021-06-16 16:47:12 -04:00
Lioncash 100bc4c833 Context: Move GPR size retrieval to its own function
This is repeated in quite a few spots, so we can place it in a utility
function and just call it instead.
2021-06-16 16:14:26 -04:00
Lioncash 72a625da4a OpcodeDispatcher: Make gpr indices in SyscallOp constexpr
Places them in RO where they can't be modified.

While we're in the area, we can use an alias to prevent duplicated array
types, and also add a static assert to ensure the arrays are always the
same size.

This allows us to avoid needing to bounds check several accesses in a
row that we know will always be successful.
2021-06-16 14:24:45 -04:00
Stefanos Kornilios Mitsis Poiitidis 779aca7e95 Merge pull request #1085 from Sonicadvance1/transparent_huge_pages
Enables transparent huge pages in our 64-bit VA allocator
2021-06-14 17:04:40 +03:00
Stefanos Kornilios Mitsis Poiitidis 3252f793df Merge pull request #1084 from Sonicadvance1/cleanup_stacks_after_fork
Core: After fork make sure to cleanup stacks
2021-06-14 17:03:49 +03:00
Stefanos Kornilios Mitsis Poiitidis 9635b34450 Merge pull request #1083 from Sonicadvance1/more_cpuid_fixes
CPUID: Improvements to have a more sane configuration
2021-06-14 10:14:34 +03:00
Stefanos Kornilios Mitsis Poiitidis 50b5ad5762 Merge pull request #1070 from Sonicadvance1/remove_warnings
Remove most warnings in FEX again
2021-06-14 10:12:03 +03:00
Ryan Houdek 10ac1518e1 Enables transparent huge pages in our 64-bit VA allocator
Transparent huge pages is a feature that the linux kernel opportunistically uses.
Depending on kernel configuration this feature is either enabled always, or when you madvise the region.

To ensure we hit both cases, madvise the regions we allocate in the 64-bit VMA allocator always

Can reduce kernel bookkeeping memory usage for our abusive allocator
2021-06-12 18:52:51 -07:00
Ryan Houdek ff1c59b6af CPUID: Improvements to have a more sane configuration
When running the cpuid application (http://www.etallen.com/cpuid.html) I noticed
that we were returning some garbage data here.

After initially implementing support for leaf functions, it still didn't resolve the issue.
So I had to fix those in the x86-64 JIT.

I then went through and solved more issues with the function results.

- We now return a more sane CPU family that is near the feature set we support
- APICID now understands how to fill out the data correctly depending on emulated core counts
- Disabled some CPU features that we don't actually support
- Found two more cache functions that we weren't populating
  - Filled with generic data cache size data
  - Only thing that matters is that we ensure that cacheline size is reported as 64bytes
  - L1D: 32KB, L1I: 32KB, L2: 512KB, L3: 8MB claimed for caches
- Implemented Leafs for functions
  - 7h - Only has leaf 0
  - Dh - Extended CPU features support
    - Another register that lets you claim support for x87, SSE, and AVX
    - Leaf 1 & 2 has some additional data
  - 4h & 8000'0001Dh - Extended cache properties
    - Almost the same as each other. One reports slightly less data though
2021-06-12 18:49:43 -07:00
Ryan Houdek 085fca01bc Core: After fork make sure to cleanup stacks
After FEX has forked, there aren't any other threads in the process but their stacks remain.
We need to have some book keeping in place to have the stack ranges available to clean up
after fork.

We now keep both live stacks and dead stacks in a dequeue and on fork we will walk both to
clean up all stack objects that aren't our current thread.
2021-06-12 18:45:13 -07:00
Ryan Houdek 3d759a91ca Jit64: Fixes register overwrite in CPUID
rsi is a SSA argument, so we need to make sure to move the leaf argument first.
the leaf argument was getting corrupted when moving to the ABI.

Will be necessary once CPUID supports leafs
2021-06-12 18:29:59 -07:00
Lioncash d08189c3ed Passes: Log out errors and warnings through a format specifier
Passing in the string directly through the format string input can
unintentionally cause the output string to be interpreted as a format
string.

We can specify a separate format string to ensure it always prints
without any potential mangling.
2021-06-11 22:27:02 -04:00
Lioncash 2ad9ced80a Passes: Replace <iostream> header with narrower equivalents
<iostream> injects a static constructor in translation units that
include it, even if its facilities aren't used.

We can make use of <sstream> to avoid needing to execute those on
startup.
2021-06-11 22:24:45 -04:00
Lioncash 120ba3d171 PassManager: std::move exit handler function
Avoids allocations if the internal std::function buffer ever happens to
be large enough to warrant it.
2021-06-11 22:05:17 -04:00
Lioncash 6084bdf982 Passes: Return by unique_ptr where applicable
Same behavior, but makes the ownership intentions explicit in the
interface.
2021-06-11 22:05:15 -04:00
Lioncash 6fc117a67c HostAllocator: Make Create64BitAllocator() return a unique_ptr
Communicates the ownership intent in the interface.

Also removes the prototype for CreateBasicAllocator, as it isn't
implemented anywhere.
2021-06-11 19:11:46 -04:00
Lioncash 1b72f73224 GlobalAllocator: Add virtual destructor to interface
Prevents any potential destruction issues from occurring in the
interface.
2021-06-11 19:04:25 -04:00
Lioncash b6edc8dc53 RegisterAllocationPass: Prevent leaks in BucketList
release() relinquishes control of the allocated memory, but doesn't
deallocate it. We need reset() for this.
2021-06-11 17:49:56 -04:00
Ryan Houdek adc5e4d6b9 JitArm64: Remove warnings in JIT.cpp 2021-06-10 15:06:53 -07:00
Ryan Houdek 903704ad48 JitArm64: Remove warning in ALUOps 2021-06-10 15:06:53 -07:00
Ryan Houdek 1d2f6c3ba8 JitArm64: Remove warnings in VectorOps.cpp 2021-06-10 15:06:53 -07:00
Ryan Houdek a67b0c151e IREmitter: Remove warning 2021-06-10 14:57:02 -07:00
Ryan Houdek ba18b5dca9 ELFSymbolDatabase: Remove warning 2021-06-10 14:56:51 -07:00
Ryan Houdek 0f1a41154d RAPass: Remove warning 2021-06-10 14:56:39 -07:00
Ryan Houdek 97dfe9b26e IRValidation: Remove warning 2021-06-10 14:56:29 -07:00
Ryan Houdek f94ce4c95b IRCompaction: Remove warning 2021-06-10 14:56:17 -07:00
Ryan Houdek 0e1892622c OpcodeDispatcher: Remove warning 2021-06-10 14:56:06 -07:00