Commit Graph
350 Commits
Author SHA1 Message Date
Ryan Houdek a2cd49ed66 Adds some more flags to the x87 tables 2020-08-19 23:09:55 -07:00
Stefanos Kornilios Mitsis Poiitidis b8b227f098 Merge pull request #297 from Sonicadvance1/fix_atomicswap
Fixes a potential crash in ARM64's AtomicSwap
2020-08-20 00:05:12 +03:00
Ryan Houdek bad7cd1262 Fixes a potential crash in ARM64's AtomicSwap
When RA made the source address register be the same register as the
destination register then we could have overwritten the address with the
move.
Use a temporary until we get RA constraints in place.
2020-08-19 13:51:40 -07:00
Ryan Houdek c9b2c36ef7 Removes usage of vixl's MacroAssembler
This gives us two more volatile registers to play with
2020-08-19 12:52:37 -07:00
Ryan Houdek 7ab55d058a Bug fix for crash when code overran code size
This was checking the wrong code size. Needs to check the buffer code
size instead of the max code size
2020-08-18 21:00:33 +01:00
Ryan Houdek f11f0ab989 Switches to atomic loadstores for TSO implementation
Doesn't support fallback to the true TSO implementation yet
2020-08-18 21:00:33 +01:00
Ryan Houdek 7700a4d24b Adds support for guest sigprocmask
This was causing our SIGBUS handling to fail in FTL
2020-08-18 21:00:33 +01:00
Ryan Houdek 1db1a42576 Switches the OpcodeDispatcher over to using TSO IR ops
For loadstores to memory, this will use TSO ops to emulate x86
behaviour.
In the case that the source register is the stack pointer then it falls
back down to using regular loadstores. Since it is expected that stack
pointer usage will be thread specific.

With the AArch64 implementation this makes us be quite a bit closer to
being x86 TSO compliant
2020-08-13 20:49:19 +01:00
Ryan Houdek acfb38497f AArch64 TSO signal handler hookup
This patches unaligned LORegion loadstores with DMB wrapped loadstores.
This will ensure full cacheline consistency on loadstores, at the
expense of speed.

The performance can potentially be improved with "Half-barriers"
Described a bit here: https://github.com/dotnet/runtime/issues/8072

We can worry about that path after the initial implementation
2020-08-13 20:49:19 +01:00
Ryan Houdek ea3c4be9ed Implements TSO loadstore ops for the AArch64 JIT
This is the base implementation that uses LORegion loadstore
instructions to support the load/store release semantics, which these
instructions use.

Sadly these don't match the alignment requirements of x86 loadstores, so
if it was just used everywhere then it will cause alignment faults.
This means we need to catch the sigbus and backpatch the instruction to
do safe (aka expensive) TSO.

Currently this backpatch just falls back to regular loadstores
surrounded by DMB instructions.
Basically unaligned loadstores will fall back to nearly what we are
doing now, so significantly improved but not perfect.

A follow up PR will change this over to using a helper routine to be
100% safe
2020-08-12 15:24:01 -07:00
Ryan Houdek 9d19a60a70 Implements TSO memory ops on x86 JIT 2020-08-12 15:24:01 -07:00
Ryan Houdek b2182613b2 Implements TSO ops in LLVM backend
Same limitation as the interpreter side
2020-08-12 15:24:01 -07:00
Ryan Houdek 57c704c743 Implements TSO memory ops in interpreter
This won't be true TSO on ARM but it is impossible to work around sanely
here
2020-08-12 15:24:00 -07:00
Ryan Houdek 448516882c Implements signal handling in the AArch64 JIT
Also removes the simulator for running on x86-64, which we can no longer
support.
2020-08-11 00:33:50 +01:00
Ryan Houdek f705baf2f0 Extends SignalDelegator duty
It needs to track guest SigAltAction and have its own definitions for
sigaction and sa_mask. sa_mask specifically is defined differently
between the kernel and glibc.

Also fixes some issues with the SignalDelegator that posix tests found
2020-08-11 00:33:49 +01:00
Stefanos Kornilios Mitsis Poiitidis 211aebcfa4 Merge pull request #286 from Sonicadvance1/interpreter_initialization_order
Creates the interpreter core just before the IR jit
2020-08-08 16:56:48 +03:00
Ryan Houdek 26a05a467e Creates the interpreter core just before the IR jit
Arm64 IR JIT needs the interpreter to be around first to get a pointer
to it
2020-08-08 06:45:09 -07:00
Ryan Houdek f3099647a2 Declares new sigret x86 instruction and IR op
We are rebranding an x86-64 illegal instruction near VIA's old ALTINST
instruction as an instruction to handle returning from guest signals
cleanly.

If this ever collides with a new x86-64 (unlikely) then we will need to
change the instruction.
This ends up looking similar to what we will do for thunk callbacks
2020-08-08 06:42:06 -07:00
Stefanos Kornilios Mitsis Poiitidis daa0e284b1 Merge pull request #290 from Sonicadvance1/guest_x86_code_section
Adds an x86 generated code helper class
2020-08-04 18:50:12 +03:00
Stefanos Kornilios Mitsis Poiitidis ab68990932 Merge pull request #291 from Sonicadvance1/asm_dispatcher_exit_fix
Allows ASM dispatcher to leave cleanly
2020-08-04 18:29:08 +03:00
Ryan Houdek 555589cbcb Allows ASM dispatcher to leave cleanly
This needs to live outside of the dispatcher to do correct threading
cleanup
2020-08-02 18:20:15 -07:00
Ryan Houdek 246e36c061 Adds an x86 generated code helper class
Just generates some context level x86 code space for our guest to jump
in to.
This is only currently used for sigret but will become more important as
we come to support vdso.
2020-08-02 18:14:47 -07:00
Ryan Houdek f524162ed1 Allows block cache to export virtual memory size 2020-08-02 17:53:20 -07:00
Stefanos Kornilios Mitsis Poiitidis 8c8e6294b6 Thunks: ALTINST, OP_THUNK, basic infrastructure 2020-07-20 13:52:28 +03:00
Ryan Houdek 9b78876862 Fixes LLVM not clearing code cache on ARM platforms
Surprised this hasn't caused issues before but was picked up on the
SolidRun Honeycomb LX2K
2020-07-19 12:08:27 +11:00
Ryan Houdek 2536bfe42c Correctly fixes prefix ordering in the frontend
This was sort of partially worked around.
The issue comes down to REX.W and Operand size prefix ordering on an
instruction.
When an instruction has both prefixes, then the one that has occured
later will overwrite the previous one.
Additionally in the case of 66h being reused as an escape prefix, we
needed to ignore it in this case.

The previous workaround was that if an instruction happened to have both
widening and narrowing, then widening would win(for MODRM args),
but then later on in the instruction decoding the literal constant
decoding would properly check which order the flags came in.
This resulted in literal constants working, but not modrm bytes

Instead replace the "last" flag handling with a two deep stack that we
can push and pop the flags correctly on to it, this ensures that the
flags stay around in the 66h ignoring mode (so widening doesn't get
obliterated).

This effects every instruction that supports REX.W and 66h Operand size
prefix, so it could be fixing some unknown bugs elsewhere.
Very specifically this one was found in OpenSSL, because it looks like
GCC is padding a mov instruction with 66h.

Instruction Examples:
Only difference is the prefix order being swapped
0x00000000   4                 66488b1f  mov rbx, qword [rdi]
0x00000004   4                 48668b1f  mov bx, word [rdi]
2020-07-15 00:10:20 -07:00
Ryan Houdek ac68dc40e5 Fixes INC and DEC flag setting
These two instructions explicitly don't set the CF flag.
Otherwise they behave the same as ADD/SUB flag setting
Fixes part of curl
2020-07-15 00:09:16 -07:00
Ryan Houdek 2dd7a8d16d Disables CLMUL in CPUID
This would be a pain to support in NEON since it requires a 128bit
resulting multiply
2020-07-13 10:27:48 -07:00
Stefanos Kornilios Mitsis Poiitidis f3014e43b8 Merge pull request #268 from Sonicadvance1/minor_fixes
Minor fixes
2020-07-13 12:31:09 +03:00
Ryan Houdek 383b8b7bb5 Fixes VADDV assert and implementation detail
AArch64's ADDV instruction doesn't support 8byte elements, it instead
needs to use ADDP(scalar) for the operation.

Fixes an assert and minor behaviour difference there
2020-07-12 03:41:02 +01:00
Ryan Houdek 43a8915074 Works around some vixl asserts
These don't change behaviour, but in debug mode were causing asserts
2020-07-12 03:39:55 +01:00
Ryan Houdek 80b9b45b3e Cleans up a couple warnings 2020-07-11 06:21:28 +01:00
Ryan Houdek f593906c9a Fixes LORegion feature detection problem
LORegion is a requirement of ARMv8.1, but the hypervisor of the c630
isn't exposing the identification register correctly.
If the host supports atomics, just assume it supports LORegions as well

Fixes an assert when building vixl in debug
2020-07-11 06:21:08 +01:00
Ryan Houdek 1f727c5826 Fixes Vector_FToF op on AArch64 JIT
Only fixes asserts, no code emission changes
2020-07-11 06:20:57 +01:00
Ryan Houdek cb74beadb4 Fixes Zext on FPR->GPR conversion for AArch64
The 32bit and lower sizes were making vixl asserts fire.
Wouldn't actually change emitted code
2020-07-11 06:20:50 +01:00
Ryan Houdek d281e9f7ff Fixes LDIV bug in aarch64 JIT
vixl asserts were firing for the 16bit variant, and we needed to sext
the divisor for the 32bit variant
2020-07-11 06:20:40 +01:00
Ryan Houdek a1db6a0dec Adds new signal delegator class
Allows us to register host and guest signal delegators.
Currently only host signals are handled, guest signal delegation will
take a bit of work still.
2020-07-11 06:12:06 +01:00
Stefanos Kornilios Mitsis Poiitidis 951ff40904 Frontend: Fix 15-byte long opcode assert 2020-07-08 14:00:14 +03:00
Stefanos Kornilios Mitsis Poiitidis 560d467058 VURAvg: Fix arm64 jit 2020-07-04 21:52:15 +03:00
Stefanos Kornilios Mitsis Poiitidis 8eaa11f4f2 VURAvg: Fix llvm implementation 2020-07-04 20:51:13 +03:00
Stefanos Kornilios Mitsis Poiitidis c19e8b3d2f Implement PAVGB/PAVGW 2020-07-04 19:30:53 +03:00
Ryan Houdek 9c99dbfbdc Fixes AtomicSwap IR op on x86
lock prefix needed to go before the xchg, not before the move that was
there
2020-07-02 22:18:44 -07:00
Ryan Houdek 03e084c7f0 Merge pull request #248 from FEX-Emu/fork_syscall
clone: Some support for fork, Flag validation
2020-07-02 14:39:23 -07:00
Ryan Houdek 4612fb5a67 Implements support for cache clearing in the ARM64 JIT
Previously the ARM64 JIT didn't support cache clearing at all.
This adds support for clearing the JIT cache while keeping dispatcher
helpers around and the ASM dispatcher alive.
2020-07-01 23:07:09 -07:00
Ryan Houdek bb60044e12 Splits JitArm64 IR handlers to a jump table
Improves compilation time by multiple minutes
Clang was taking multiple minutes to compile JIT.cpp for ARM.
This drops it down to a handful of seconds instead.

No functional behaviour change, only movement.
JIT compile times might deviate slightly moving from a switch to a jump
table, but will be negligible in either direction.
2020-07-02 02:46:14 +01:00
Ryan Houdek ce15a1bdcd Corrects MM register alignment in CoreState
This was misaligned by 8 bytes, which worked fine on x86, but crashed
when loaded on ARM.

Now it is correctly aligned to 128bit
2020-07-01 06:08:39 +01:00
Stefanos Kornilios Mitsis Poiitidis 2ccaea7d66 clone: Validate flags, cleanup 2020-06-30 16:23:43 +03:00
Ryan Houdek 8a5813e4d0 [WIP] Fork syscall support
Bit buggy
2020-06-30 16:22:47 +03:00
Ryan Houdek bd26d15879 Fixes LLVM multiblock
The break ir op is actually a block ender and it happened that in
regular code paths they were already ending the blocks correctly.

This enforces block ending in the Unimplemented op so multiblock still
generates the invalid code path correctly and it compiles.
We hit these a few times in multiblock for times in the code where it is
checking for CPU features and choosing a code path depending on CPUID
results.

Potentially these could be made in to no-ops since we'll never hit these
codepaths in practice, but it is nicer to break in case we actually do
hit one of these paths.
2020-06-26 12:31:15 -07:00
Ryan Houdek 2bcc46c9e5 Implements FFREEP support in the OpDispatcher
There's some history for this instruction. It is not in the official
instruction documentations from AMD or Intel but it is supported on
almost every x87 supporting CPU (I think there was some Cyrix that
missed it?)

This was originally implemented by accident on the Intel 80287 CPU.
It was then periodically documented in random documentation.

The instruction behaves exactly like FFREE but then pops the stack after
the operation.
For our current implementation of FFREE, which is a NOP, we just need to
pop the stack.
2020-06-20 08:11:26 -07:00