Commit graph

60 commits

Author SHA1 Message Date
Fabian ca7dd68f6c Fix tests depending on arch 2021-01-03 22:43:08 -06:00
Fabian fe6872d55b Don't print control characters in terminal 2020-12-31 19:14:33 -06:00
Fabian b96f984963 Use softfloat f80 for x87 fpu
This fixes several long-standing issues with x87 float emulation, in particular:

- 80 bit precision floats, fixing Haiku after its switch to musl libc (hrev53728)
- the precision bit in the x87 control word
- fucom and fucomi (unordered comparisons)
- aliasing of x87 and mmx registers
- rounding during conversion to integers

Operations that are not implemented in softfloat were implemented by
converting to f64 (sine, pow, ln, etc.) and thus operate with lower
precision.

Softfloat has been combined into a single file using a script [0] and checked into the repository.

[0] 57df21e2eb/contrib/single_file_libs/combine.sh
2020-12-31 19:14:32 -06:00
Fabian 18e7741f3f Enable some qemu fpu tests that were previously not working 2020-12-31 19:14:32 -06:00
Fabian acb8ad5423 Avoid console.assert (doesn't throw) 2020-12-31 19:14:30 -06:00
Fabian 489f212c47 Fix broken string test 2020-12-31 19:14:29 -06:00
Fabian a7ae6603f0 Temporarily disable broken tests 2020-12-31 19:14:29 -06:00
Fabian 5b95165de2 Add TEST_RELEASE_BUILD to run tests on release build 2020-08-30 19:37:15 -05:00
Fabian fc35ea3ee2 Add emms after code that uses mmx registers before code that uses fpu registers 2020-08-30 19:29:54 -05:00
Fabian fd1f8e1108 Test more edge cases for sse shifts 2020-08-30 19:29:54 -05:00
Fabian 76cc19dee4 Tests for sse shifts with 64 bit shift operand 2020-08-30 19:29:54 -05:00
Fabian 1a3c491647 More tests for rep {movs,stos}{b,d} 2020-08-30 19:29:54 -05:00
Fabian 920d150c8b qemu: Enable all sse2 tests, add tests for approximate operations 2020-08-30 19:29:54 -05:00
Fabian 0a9c2bf6e2 qemu tests: init fpu before fxsave as fpu state contains undefined values from previous operations 2020-08-30 19:29:54 -05:00
Fabian 21018b880e Enable a few more sse tests 2020-08-30 19:29:53 -05:00
Fabian 6fa702c8aa Implement {min,max,div}{p,s}{s,d} sse instructions (#57) 2020-08-30 19:29:53 -05:00
Fabian 7e574dde52 Implement some floating point sse1/sse2 instructions (#57) 2020-08-30 19:29:53 -05:00
Fabian 848b07a628 Skip tests that fail due to qemu bugs 2020-08-30 19:29:53 -05:00
Fabian 7d627ac13a Make tests a bit more robust 2020-08-30 19:29:53 -05:00
Fabian c108aaaadd Extend qemu paging tests with cross-page page faults 2020-08-30 19:29:53 -05:00
Fabian 510c6c186b qemu tests: More sse shift tests 2020-08-30 19:29:53 -05:00
Fabian 9bd1e30439 qemu tests: Re-enable some sse tests and reduce diff between upstream version 2020-08-30 19:29:53 -05:00
Fabian e9eeba2248 Remove deprecated use of new Buffer 2020-08-30 19:27:07 -05:00
Ernest Wong 129269fc14 Add devices test to CI + update tests to linux4 2020-08-30 19:27:07 -05:00
Fabian 617d962eba qemutests: More rounding tests 2020-08-30 19:27:07 -05:00
Fabian 37f4a7da51 Make unhandled rejected promises fatal in tests 2020-07-21 20:10:14 -05:00
Fabian f7d7327753 qemu tests: Dump version 2020-07-21 20:10:14 -05:00
Amaan Cheval f6cceafac1 qemutests: Fix bug where test would hang forever sometimes
The stdout stream is not line-buffered, which means that occasionally the
chunk/Buffer of data that comes in immediately after we run the commands may be:

~% chmod +x /mnt/test-i386
~% /mnt/test-i386 > /mnt/result
~% echo test fini''shed
test finished
~%

Note how the data ends with the prompt, not in "test finished\n" - this will
cause the test to run indefinitely.
2020-07-21 20:10:14 -05:00
Fabian acfc4372c5 Use Westmere instead of max cpu for qemu (max is not available on older qemu versions) 2020-07-21 20:10:14 -05:00
Fabian e0dc847ded Re-enable TEST_VM86 2020-07-21 20:10:14 -05:00
Fabian 4379e5ef3e Use qemu as a test oracle instead of the local machine
Recently distributions started disabling the CONFIG_MODIFY_LDT_SYSCALL
kernel config, breaking parts of the qemu test. qemu is very suitable to
run these tests in the same configuration as v86 (booting from
linux3.iso, exchanging files using 9p fs and controlling via serial
console).
2020-07-21 20:10:14 -05:00
Fabian f03b34ecd5 Handle missing modify_ldt syscall in qemu tests properly 2020-07-21 20:10:14 -05:00
Amaan Cheval 89d80a5e3e Allocate enough space in page0 so that page1 can also fit
Without this, the MAP_FIXED call for page1 may cause a segfault by overwriting
an internally mapped structure.
2020-07-21 20:10:13 -05:00
Fabian fb1cb5e800 Run qemu tests in debug mode 2020-07-21 20:10:13 -05:00
Fabian a0f5074f18 Temporarily disable segment test in qemu 2020-07-21 20:10:13 -05:00
Awal Garg 8222d2e6e0 Squash
restore memcpy comment
delete all the things!
fix jshint issues
restore memcpy comment
remove duplicate fxsave assignment
Count cache drops
Use already available physical address instead of calling read_imm8
Remove useless assertion
Just move around to reduce later diff
Run jit paging test with assertions enabled
Run jit-paging test on CI
Extend jit-paging test
Fix deleting invalidated code across memory pages
Add jit-paging test to gitlab ci
Remove jit_in_progress
Clean up old comments, use bool for jit_jump
Fix state image not begin garbage collected
Add ENABLE_PROFILER_TIMES to configure slow profiling times
Move to jit_generate and jit_run_interpreted to separate function
Add missing struct field
Fix: Don't write jit cache entry until no more faults can happen
Download image for jit paging test
Add missing initialiser
Mark jit_{generate,run_interpreted} as static
Specify full path to profiler.h
Clean up duplicate/missing declaration after rebase
mmap error handling, line length and fix some warnings
remove further unused code
move js imports to single header file
2020-07-21 20:10:13 -05:00
Fabian 975a06269e Squash
2e469796 Minor
fab422ef Improve generation of 0f instructions
08ad7fe9 Improved if-else generation
3f81014d Minor: Align test output
4a3a84ef Generate modrm tests
61aa1875 Simplify
a6e47954 Generate decoding of immediate operands
435b2c10 Fix warnings
e4933042 Add missing immediate operand
3f3810c7 Generate immediate operands for instructions with modrm byte
a0aa7b1f Make memory layout in nasm tests clearer
6b8ef212 Remove 'g' property from instruction table (implied by 'e')
bf15c58c Remove unused declarations
1e543035 Remove useless `| 0` and `>>> 0` javascriptisms
1ccc5d53 Fix headers
8b40c532 Update qemu tests with changes from qemu
ec9b0fb5 Port xchg instructions to C
c73613e7 Port virt_boundary_* to C
d61d1241 Add headers
fd19f22c Make written value in write8 and write16 int32_t
497dcaec Generate read_imm for instructions with a modrm byte
8b7003d6 Generate read_imm8s
0cc75498 Remove read_op
9d716086 Trigger unimplemented_sse for partial sse instructions with prefix
8d5edd03 Remove unimplmented sse c-to-js hack
585d3565 Remove | 0
308124b2 Use int32_t as return value
f193f8e1 Use JS version of cvttsd2si for now
12747b97 Generate trigger_ud for missing modrm branches
770f674e Split 0f00 and 0f01 into multiple instructions depending on modrm bits
1cb372a3 Generate decoder for some 0f-prefix instructions
cec7bc63 Disable unused parameter warnings in instruction functions
807665b1 Generate read_imm for 0f/jmpcc
cdf6eccc Generate modrm decoding for shld
04528429 Create temporary files in /tmp/, not cwd
d8f3fbd8 Generate modrm/imm decoding for shld
00ef0942 Generate modrm decoding for bts
f531984b Generate modrm decoding for shrd and imul
07569c53 Generate modrm decoding cmpxchg
535ff190 Generate modrm decoding for lfs/lgs/lss
2f8ced8d Generate modrm decoding for btr and btc
95de6c66 Generate modrm decoding for movzx
c4d07e7e Generate modrm decoding for bsf and bsr
f0985d26 Generate modrm decoding for movsx
4b30937a Generate modrm decoding for xadd
a422eb27 Generate modrm decoding for movnti
e5501d3c Generate modrm decoding for mov to/from control/debug registers
bce11ec5 Generate modrm decoding for lar/lsl
5729a23c Fix access to DR4 and DR5 when cr4.DE is clear
44269a81 Specify immediate size explicitly instead of inferring it
82b2867a Fix STR instruction
98a9cc89 Log failing assertion
6d2f9964 Fix rdtsc
00260694 Log GP exceptions
7916883d Port trigger_ud and trigger_nm to C
36fedae9 Remove unused code
e08fabd0 Generate modrm decoding for 0f00 and 0f01
8ae8174d Generate modrm decoding for 0fae and 0fc7 (fxsave, cmpxchg8, etc.)
26168164 Generate modrm+immediate decoding for 0fba (bit test with immediate operand)
6adf7fa7 Simplify create_tests.js (unused prefix call)
c77cbdd8 Add comments about the implementation of pop [addr]
4640b4fe Simplify prefix call
a81a5497 Don't use var
3ca5d13d Separate call name and arguments in code generator
3191a543 Simplify other prefix call (8D/lea)
5185080e Update generated code (stylistic changes and #ud generation)
93b51d41 Remove unused wasm externals
e4af0a7f Avoid hardcoding special cases in code generator (lea, pop r/m)
654a2b49 Avoid hardcoding special cases in code generator (enter/jumpf/callf)
fd1a1e86 Commit generated code (only stylistic changes)
7310fd1a Simplify code generator by merging code for with and without 0f prefix
e7eae4af Simplify code generator by merging code for immediate operands
00fafd8a Improve assertions
db084e49 Simplify code generator (modrm if-else)
0a0e4c9e Improve code generation of switch-case
ce292795 Clarify some comments
37cf33fa Generate code in if/else blocks
cbcc33fc Document naming scheme
e30b97eb Generate modrm decoding for 0f12 (sse) instruction
24b72c2f movlpd cannot be used for register-to-register moves
72d72995 Generate modrm decoding for 0f13 (sse) instruction and disable register-to-register moving
75d76fbb Generate modrm decoding for 0f14 (sse) instruction
ac8965a7 Generate modrm decoding for 0f28-0f2b (movap, movntp)
e919d33e Generate modrm decoding for cvttsd2si
5f2ca2b4 Generate modrm decoding for andp and xorp
c8d1c6de Generate modrm decoding for 0f60-0f70 (sse instructions)
ae4ed46d Add multi-byte nop and prefetch to nasm test, generate modrm decoding
718a1acf Print qemu test error message more useful
d1ecc37e Generate modrm decoding for 0f70-0f80 (sse instructions)
6a7219a5 Generate modrm decoding for popcnt
25278217 Generate modrm decoding for 0f71-0f73 (sse shift with immediate byte)
ed1ec81b Generate modrm decoding for the remaining sse instructions (0fc0-0fff)
42bc5a6f Use 64-bit multiplication for native code
dda3fb39 Remove old modrm-decoding functions
717975ef Move register access functions to cpu.c
aee8138f Remove read_op, read_sib, read_op0F, read_disp
f31317f2 Rename xmm/mmx register access functions
a525e70b Remove 32-bit access to reg_xmm and reg_mmx
c803eabc Rename s8/s16/s32 to i8/i16/i32
9fbd2ddf Don't use uninitialised structs
942eb4f7 Use 64-bit load for mmx registers and assert reg64 and reg128 size
f94ec612 Use 64-bit writes for write_xmm64
08022de9 Use more efficient method for some 128-bit stores
9d5b084c Make timestamp counter unsigned
2ef388b3 Pass 64-bit value to safe_write64
4cb2b1be Optimise safe_write64 and safe_write128
b0ab09fb Implement psllq (660ff3)
9935e5d4 Optimise safe_read64s and safe_read128s
af9ea1cc Log cl in cpuid only if relevant
be5fe23e Add multi-op cache (disabled by default through ENABLE_JIT macro) and JIT paging test (similar to QEMU test).
aa2f286e Don't initialise group_dirtiness with 1 as it increases the binary size significantly
b8e14ed9 Remove unused reg_xmm32s
bc726e03 Implement dbg_log for native code with format characters 'd' and 'x'
454039d6 Fix store task register
63a4b349 Remove unnecessary parens and clean up some log statements
4cc96814 Add logop and dbg_trace imports
7940655d Only inhibit interrupts if the interrupt flag was 0 in STI
876c68a7 Split create_tests into create_tests and generate_interpreter
aa82499f Move detection of string instructions to x86_table
f3840ec2 Move C ast to separate file
90400703 Skip tests for lfence/mfence/sfence, clarify their encoding
4a9d8204 elf: Hide log messages when log level is zero
a601c526 Allow setting log level via settings
8a624453 Add cpu_exception_hook to debug builds
f9e335bf Nasm: Test exceptions
599ad088 logop: Format instruction pointer as unsigned
f95cf22b Don't skip zero dividing tests
2a655a0e Remove get_seg_prefix_ds from read_moffs (preparation for calling read_moffs from the code generator)
bc580b71 Remove obsolete comment
e556cee0 Fix nasmtest dependencies in makefile and clean
dcb1e72b Use all cores on travis
86efa737 Replace all instances of u32 & 0xFFFF with the respective u16 accesses
98b9f439 Use u8 instead of bit-shifts and masks from u32
b43f6569 Replace all instances of u32 >> 16 with the respective u16 accesses
9bfa72c7 Remove unnecessary parens
9cf93734 Clean up remaining instance of u32 with a mask instead of u16
22d4117f Correct order of writes in virt_boundary_write32
6734c7c1 Fix keyboard on ios, fixes #105
858a4506 Add missing file, c_ast.js
1d62e39e Move instruction naming scheme into function
f4816852 Reorder some code
69d49788 Minor improvements
0493e05f Add util.js
af9000c1 Improve full test
e5feba31 Add missing export
c7c42065 Replace prefix_call with custom_resolve_modrm
3186e6ad Add support for "%%" format string to dbg_log_wasm for printf import
efe54fad Add barebones instrumentation profiler (disabled by default).
c9f0d462 Implement movlps m64, xmm and enable its test
42869a12 Add tests for cross-page reads/writes confirmed with byte reads/writes
d68976ea Mask word values in port byte reads
9758d51e Add PS2_LOG_VERBOSE
5f52f037 Update NASM Makefile to include all dependencies to prevent unnecessary recompilation
2c71f927 Have NASM test generator use a seedable PRNG to allow for faster incremental tests
e4aa45bb Add chunk{16,32}_rw paging tests; instructions that read and write to memory
bdf538a2 add codegen to cpu constructor
aa76ce8e add resolve_modrm16
14d7ecf1 refactor codegen
b710319f [rebased] Merge branch codegen
0565ea42 minor refactoring
071dff3f temporary fix for automatic cast warnings
57c504f2 fix modrm16 issue
c2db5d9e jit modrm32
85c04245 reinstate modrm_fn0 and modrm_fn1
be65dafd add ip and previous ip manipulating functions
ae00ef89 update codegen js interface
530a74fa squashed commit for refactor
2c692199 add codegen-test to build
c15afe68 prefix gen to codegen api
c9611533 codegen tests fixes
2020-07-21 20:10:12 -05:00
Fabian dbe71128e6 Temporarily disable fxsave test 2020-07-21 20:10:11 -05:00
Fabian 3cd91a5064 Temporarily disable QEMU tests that don't compiler on newer GCC 2020-07-21 20:10:11 -05:00
copy 258eb359f1 Enable fxsave test. Replace constants that can't be represented in 64 bits 2017-06-20 18:38:58 -05:00
copy 016005fa20 Update testing readmes 2017-06-19 15:06:50 -05:00
copy e2cebe1130 qemu test: Add -mno-sse (fix for travis) 2017-06-19 14:37:12 -05:00
copy 97c44f48b5 Use -mmmx over -msse 2017-06-19 14:22:50 -05:00
copy 323d7ef255 Run qemu test on command line, add it to travis 2017-06-19 14:03:20 -05:00
copy e2c129ed23 Disable tests that require sse due to modern libc 2017-06-19 12:39:41 -05:00
Amaan Cheval ba6ac81fb6 Enable supported QEMU tests (for mmx-instructions) 2017-06-16 10:47:19 -04:00
Amaan Cheval 22cde22383 Add QEMU test for pshufw 2017-06-16 10:47:19 -04:00
Amaan Cheval d846e84236 Update QEMU tests for newly added mmx instructions 2017-06-16 10:47:19 -04:00
Amaan Cheval 34dda99378 Update QEMU tests to enable SSE tests, but disable specific ones 2017-06-16 10:47:19 -04:00
copy 0b2628e22a more tests 2015-09-12 00:18:18 +02:00