Both engines refused SHLD and SHRD (0F A4/A5, 0F AC/AD) as illegal
instructions. They are now declared in the x86 registry and run on the
shared semantics for 16-, 32- and 64-bit register and memory
destinations, with the count in an 8-bit immediate or in CL.
- instructions.toml, x86_table.rs (generated), generate_x86.py,
x86_decode.rs: the two operations and two operand encodings,
rm_reg_imm and rm_reg_cl (ModRM destination, reg source, count).
- x86_exec.rs: the destination is shifted with the vacated bits filled
from the source register. The count is masked to five bits (six for
64-bit operands), a masked count of zero changes nothing, CF takes the
last bit shifted out, ZF/SF/PF follow the result and OF is set only
for a count of one. A 16-bit count above 16 is undefined in the SDM;
the flags are kept and no test relies on the result.
- cpu_known_answers.rs: eight SDM-derived cases move from refused to
verified.
- tests/x86: 72 assembled SHLD and SHRD instructions, with a
bit-at-a-time reference in x86_integer.rs. A destination the
reference marks undefined now skips the memory operand check too.
- docs/cpu/instruction-registry.md, CHANGELOG.md.
Nothing is lowered to ARM64.
Signed-off-by: maridogolpeador <354308468+maridogolpeador@users.noreply.github.com>
Conflicts: CHANGELOG.md and the rejected-encodings list in
x86_integer.rs, where both sides are kept; the case list in
tests/x86/assemble.py, which now has the fences followed by MOVNTI; and
the generated x86_table.rs and tests/x86/integer.txt, rebuilt with
generate_x86.py and assemble.py from the merged sources.
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
Conflicts: CHANGELOG.md, where both entries are kept; the generated
crates/loader/src/x86_table.rs, rebuilt with generate_x86.py from the
merged instructions.toml; and one sentence of
docs/cpu/instruction-registry.md, where the list of rejected
instructions now drops both RCL/RCR (from #351) and the fences.
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
Conflicts in CHANGELOG.md, where both new entries are kept, and in the
generated crates/loader/src/x86_table.rs, which is rebuilt with
generate_x86.py from the merged instructions.toml.
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
Both engines refused MOVNTI (0F C3 /r) as an illegal instruction. It is
the SSE2 move still missing next to the XMM moves already implemented.
- instructions.toml, x86_table.rs (generated): MOVNTI for 32- and
64-bit operands with a memory destination only.
- x86_exec.rs: an ordinary store of the register, as the other
non-temporal stores already are.
- cpu_known_answers.rs: the SDM-derived case that ends in a MOVNTI
moves from refused to verified.
- tests/x86: four assembled instructions with the text-only reference;
the register form and the 66 prefix join the rejected encodings.
MASKMOVDQU stays rejected and SSE2 stays unreported by CPUID.
Signed-off-by: sahib453 <117431595+sahib453@users.noreply.github.com>
Both engines refused the three fences as illegal instructions, and no
document said what ordering guest memory accesses have.
- instructions.toml, x86_table.rs (generated): the register forms of
0F AE digits 5, 6 and 7. The memory forms stay undeclared.
- x86_exec.rs: a fence changes nothing. Each engine runs one guest
instruction at a time on one host thread and completes its loads and
stores before the next, so accesses are already totally ordered.
- docs/cpu/instruction-registry.md: states that ordering, why the
fences are no-ops under it, and that it holds only while guest
threads do not run on several host threads.
- Tests: five single-thread known-answer cases, three assembled
fixtures, two rejected memory forms, and MASKMOVDQU as the refused
SSE2 instruction in cpu_features.rs now that MFENCE runs.
No multi-thread behaviour is established.
Signed-off-by: sahib453 <117431595+sahib453@users.noreply.github.com>
Both engines refused XCHG with the register in the opcode (91 to 97,
and 90 with REX.B) as an illegal instruction. Assemblers choose this
form whenever one operand is the accumulator.
- instructions.toml, x86_table.rs (generated): one form per opcode 91
to 97. A row of eight would have to start at 90, which is NOP.
- x86_decode.rs: 90 stays NOP without REX.B and decodes as the 91 form
with register r8 when REX.B is set. F3 before it is rejected.
- x86_exec.rs: exchange the accumulator with the named register at 16,
32 and 64 bits.
- cpu_known_answers.rs: three SDM-derived cases move from refused to
verified.
- tests/x86: 20 assembled instructions, checked by the existing
text-only reference. `xchg r8, rax` leaves the rejected list.
Nothing is lowered to ARM64.
Signed-off-by: sahib453 <117431595+sahib453@users.noreply.github.com>
Both engines refused RCL and RCR (group 2, digits 2 and 3) as illegal
instructions. They are now declared in the x86 registry and run on the
shared semantics for 8-, 16-, 32- and 64-bit register and memory
operands, with a count of one, CL or an immediate.
- instructions.toml, x86_table.rs (generated): the two operations, with
CF as an input.
- x86_exec.rs: rotation over the operand plus CF. The masked count is
reduced modulo the operand width plus one, CF takes the last bit
rotated out, and OF is set only for a count of one.
- cpu_known_answers.rs: fourteen SDM-derived cases move from refused to
verified, and the shift sweep runs both instructions at every width.
- tests/x86: 80 assembled RCL and RCR instructions, with a single-step
reference in x86_integer.rs. `rcl al, 1` leaves the rejected list.
Nothing is lowered to ARM64. SHLD and SHRD stay rejected.
Signed-off-by: sahib453 <117431595+sahib453@users.noreply.github.com>
Declare MOVS and STOS for 8- to 64-bit elements through a new string
encoding that accepts REP, and add the direction flag with CLD and STD.
A REP form runs one element per step and stays on the instruction until
RCX is zero. Every element therefore counts against the step budget, a
repeat can stop part-way and resume, and a fault keeps the elements
already done. FS and GS apply to the MOVS source only. Both engines use
the shared semantics; there is no bulk-copy path.
Fourteen SDM-derived cases already in cpu_known_answers.rs move from
refused to verified, and ten more are now refused at their second
instruction because CLD runs. tests/cpu_rep.rs adds a byte-array model
over every form, direction and count.
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
CPUID returns a fixed table that never reads the host: a synthetic
vendor, and a feature bit only when every instruction of that feature
is implemented. Today that is CMOV, POPCNT, LZCNT and long mode. SSE
and SSE2 stay unreported while parts of them are rejected. Unlisted
leaves return zeros.
tests/cpu_features.rs pins every leaf in both engines, requires each
reported feature's instruction set among the executed fixtures, and
holds a refused witness instruction for each unreported feature, so a
bit cannot be set early or forgotten later.
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
Declare XADD and CMPXCHG in the instruction registry for 8- to 64-bit
register and memory destinations. The LOCK prefix is accepted on the
forms the registry marks lockable and only with a memory destination;
every other use stays an illegal instruction.
Both engines run the new forms on the shared semantics. A failed
CMPXCHG still writes its destination, so it faults on memory that
cannot be written, and a fault changes nothing. The registry document
states the ordering, alignment, compare-failure and fault rules a guest
scheduler has to preserve. Nothing is lowered to ARM64 atomics.
Fourteen SDM-derived cases already in cpu_known_answers.rs move from
refused to verified. Adds 62 LLVM-assembled fixtures with reference
arms, generator checks for the lock key and tests/x86_atomic.rs.
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
BSF, BSR and BT were decoded and executed by the interpreter, but every
occurrence of them in a translated block fell back to the shared semantics,
because `is_native` did not list them. The static probe therefore counted
them among the instructions the ARM64 DBT does not support.
Lower them to ARM64:
- BSF writes the index of the lowest set bit of the source and BSR the index
of the highest set bit. The lowest set bit is the highest set bit of the
reversed value, so BSF is `RBIT` followed by `CLZ`, and BSR is 63 minus the
leading zero count.
- A zero source sets the zero flag and leaves the destination undefined, so
the destination keeps its value. The interpreter and the independent
reference apply the same rule, and the reference marks the destination as
undefined so it is not compared.
- BT sets the carry flag from the tested bit, with the bit index masked to
the operand width. The bit string is not modified.
Only the `0F A3` form of BT is lowered. The `0F BA` group form takes an
immediate index and may write memory, so it stays on the shared semantics and
is not advertised as natively supported.
The new encodings of RBIT, CLZ and LSLV were cross-checked against LLVM 23.1.6
`llvm-mc -show-encoding`.
The BSF, BSR and BT fixtures in `tests/x86/integer.txt` already cover the
16-bit, 32-bit and 64-bit forms with register and memory sources, and the
fixture test asserts that a native form never reaches the shared-semantics
helper, so those fixtures now exercise the new native path against the
independent reference. A new test pins the zero source, the highest bit, the
operand widths, the flag results and the masked bit index.
Closes#196
Signed-off-by: Swastick Chowdhury <28708247+Swastickc@users.noreply.github.com>
Keep every upstream test and the new assembler forms. Keep the shared
decoder and lowering, which already cover the merged MOVZX, MOVSX and
segment fixes, and adopt upstream's rule that GS applies when FS and GS
overrides are combined. Add segment regressions for RIP-relative operands,
negative displacements and fault addresses in both engines.
Signed-off-by: jelly013 <22855910+jelly013@users.noreply.github.com>
Add the scalar and packed binary32 and binary64 arithmetic, compares and
conversions, computed exactly and rounded once in software. Follow MXCSR
rounding, sticky flags, denormals-are-zero, flush-to-zero, tininess after
rounding and x86 NaN selection. Stop on unmasked exceptions without a
result. Host floating point is not used, and no form is lowered to NEON.
Verify 6,824 vectors computed with exact fractions by an independent Python
reference in both engines, and round-to-nearest results against the host.
List the behaviour that is implemented but left unasserted.
Refs #127, #128
Signed-off-by: jelly013 <22855910+jelly013@users.noreply.github.com>
Add XMM0-XMM15 and MXCSR to the guest state and extend the registry with
mandatory prefixes, so the shared decoder covers the SSE and SSE2 moves and
packed integer operations. Reject opcodes where 0x66 could be both an
operand size and a mandatory prefix.
Translate operations with identical NEON lane semantics to ARM64; other
forms call the shared semantics and are counted. Raise a distinct
general-protection exit for misaligned 16-byte operands and reserved MXCSR
bits. Floating-point arithmetic is not implemented.
Verify 374 LLVM-assembled instructions against a byte-array reference that
reads only their assembly text, and mixed sequences between the engines.
Refs #124, #125, #126, #128
Signed-off-by: jelly013 <22855910+jelly013@users.noreply.github.com>
Add a declarative x86-64 instruction registry with a validating generator,
and decode through its tables in the static probe, the interpreter and the
native DBT. Move integer semantics into shared reviewed primitives and
extend them to 8-, 16-, 32- and 64-bit register and memory operands.
Store all six arithmetic flags in the guest state so they survive helper
calls and block boundaries, and correct unsigned branch conditions. Lower
common forms to ARM64; other forms call the shared semantics and are
counted. Report probe support from the decoder that executes.
Verify 985 LLVM-assembled instructions against a bit-level reference that
reads only their assembly text, and random sequences between the engines.
Refs #64, #65, #66, #68, #70, #71, #73, #118, #119, #120, #121, #122,
Signed-off-by: jelly013 <22855910+jelly013@users.noreply.github.com>
#123, #194, #195, #196