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>
A program built with the mingw-w64 runtime gets argc, argv and envp for
main from __p___argc, __p___argv, __p__environ, _configure_narrow_argv
and _initialize_narrow_environment. None resolved, so the loader refused
the program before its entry point, and a host could not say what the
program's arguments are.
The five services are added to the typed registry, and
ServicesState::set_program_arguments lets a host supply argv. The
environment table is empty.
Part of Gate A2.
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>
`xenora probe` and `xenora imports sync` defaulted to a folder named after
one commercial game. Give both one shared default, `diagnostics/probe`, and
ignore it in Git. Keep the old ignore rules so existing local reports stay
out of commits.
Closes#364
Signed-off-by: jelly013 <22855910+jelly013@users.noreply.github.com>
The instruction registry document listed fences among the forms
rejected on purpose. This branch accepts them and explains why in the
new memory-ordering section, so the list no longer names them.
Signed-off-by: sahib453 <117431595+sahib453@users.noreply.github.com>
The instruction registry document listed RCL and RCR among the forms
rejected on purpose. This branch implements them, so the list no longer
names them. SHLD and SHRD stay on it.
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>
- Check the mapping budget before anything is mapped, and map the header
bytes straight from the file instead of copying them first.
- Refuse bytes that are not the PE32+ headers that were parsed: the
optional header magic and size, the section count, the preferred base
and SizeOfHeaders must agree before anything is patched.
- Write the load base into the mapped ImageBase field after relocations
are applied, so a DIR64 entry aimed at that field cannot move it twice.
- Describe the ImageBase rewrite as Xenora's policy, and document the
zero fill past SizeOfHeaders and the stricter page rule.
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
Let a wait whose deadline has passed time out instead of taking a later
signal. Keep the main thread's pending wait, with its objects and deadline,
when a run that stopped on its budget continues from the same context. Count
every call that ends a turn, and neither sleep nor report a deadlock with a
spent budget.
Retry blocked threads again when one of them ends in the pass, so that a
thread waiting for it is not reported as deadlocked or timed out. Refuse to
open an ended main thread by its ID. Test that a second scheduler cannot
attach while one runs.
Addresses review of #339.
Refs #323
Signed-off-by: jelly013 <22855910+jelly013@users.noreply.github.com>
With the overflow exception unmasked, an overflow whose result is exact
before the exponent is bounded set the MXCSR precision flag as well as
the overflow flag. The Intel SDM (Vol. 1, D.4.2.3, Table D-16) reports
precision there only if rounding with an unbounded exponent is inexact.
- softfloat.rs: Control reads the overflow mask, and round() reports
precision on an unmasked overflow only when the result was rounded.
The masked response is unchanged.
- cpu_known_answers.rs: the five exact-overflow cases are no longer an
ignored defect, three more cover the other rounding modes, and the
scalar and conversion sweeps now compare the precision flag here.
- docs/cpu/instruction-registry.md: the behaviour is no longer listed
as unasserted.
Signed-off-by: sahib453 <117431595+sahib453@users.noreply.github.com>
Address review feedback: introduce AMD RDNA2 desktop GPU (gfx1030) before the internal codename, define the LLVM three-way decoder check, document the Apple M5 status spelling, use GitHub logins in acceptance records, and mark the independence rule as proposed pending maintainer confirmation.
Signed-off-by: Vedant Dadhich <vedantdadhich21@gmail.com>
Add scripts/cpu-tests.sh, which lists the default-feature workspace test
targets, runs shard K of N of them in a fixed round-robin order, and checks
that N shards cover every target exactly once. It fails when Cargo cannot
build the workspace instead of running a partial list. The full gate
(cargo test --locked --workspace) and scripts/test-gpu.sh are unchanged.
Record the measured gate cost and the selected-versus-full comparison in
docs/testing/cpu-coverage.md, index it in docs/README.md, and add a
changelog entry.
Signed-off-by: Swastickc <28708247+Swastickc@users.noreply.github.com>
* isa, decoder: VOP3 encodings of the eleven registry VOP2 integer forms (#215)
Eleven [[encoding_variant]] entries re-encode the VOP2 integer forms as
VOP3A (_e64) under operand rule vop3_vgpr2: two VGPR sources, no
modifiers, SRC2 the unused inline zero. Opcodes from the pinned XML,
checked against llvm-mc. Decoder known words and per-bit rejections.
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
* fixtures, decoder, shader: LLVM-assembled fixture and goldens for the eleven VOP3 VOP2 variants (#215)
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
* ref, validation: independent guide-derived oracle for VOP3 integer VOP2 forms and Wave32 VOP3 compares (#215)
crates/ref and tests/validation/independent_ref.rs decode and run the eleven
VOP3A (_e64) integer VOP2 forms and the sixteen V_CMP_*_{I32,U32}_e64 compares
writing a 32-bit lane mask to one SGPR (s0-s105) or vcc_lo, derived from the
AMD RDNA 2 guide only. New suites vop3_integer.rs and vop3_compare.rs, with
ignored native Metal parts.
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
* isa, decoder, shader: add VOP3A encodings for the sixteen integer compares (#215)
Sixteen gfx1030 Wave32 integer compares gain their VOP3A (_e64) encoding
as registry variants, with an explicit SGPR mask destination (guide 3.9,
13.3.3; pinned XML OPR_SREG), VCCZ branching through vcc_lo and
translation errors for reads of runtime-only SGPR results.
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
* fixtures, shader, validation: VOP3A compare fixture and native Metal runs (#215)
A fixture with all sixteen VOP3A integer compares (vcc_lo destination,
runtime s_cbranch_vccz) ties the new variants to fixture coverage, with
IR and MSL goldens. The VOP3 integer and compare Metal oracles now run in
the GPU gate: the translator they waited for is in this branch.
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
* changelog: VOP3A integer and compare encodings (#215)
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
* shader, fixtures, docs: e64 compare names in the IR; status rows for the 27 VOP3A forms (#215)
The IR names a VOP3A compare by its _e64 mnemonic and prints its SGPR
destination; VOPC output is unchanged. The compare fixture now uses a
mid-range second source (so swapped unsigned opcodes change the golden)
and one plain SGPR destination. docs/status.toml and the rendered
instruction table list the 27 new forms.
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
* docs: use a recognized lowering phrase for the VOP3A integer rows (#215)
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
* isa: VOP3A variants exist only for the 32-bit VOPC compares (#215)
After main gained the 16-bit compares (#327), the dispatch test expected a
VOP3A encoding for every non-64-bit compare. Only the 32-bit ones have one.
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
---------
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
* gpu: bind a texture and sampler to guest draws through descriptor tables (#303)
A guest command list had no way to bind a texture: GraphicsCommand stopped
at vertex and index buffers. This adds the smallest D3D12-shaped binding the
translated image_sample_lz pixel stage needs: shader-visible CBV_SRV_UAV and
sampler heaps, CreateShaderResourceView for one-level RGBA8 and BC1 2D
textures, a point/clamp CreateSampler, a root signature with one pixel-stage
SRV table and one sampler table, and SetDescriptorHeaps and
SetGraphicsRootDescriptorTable. Everything else fails explicitly before any
draw.
The native path hands the bound level to a textured backend.
NativeCompute::render_rgba8_sampled_bc1 binds a BC1 level natively to
fragment texture 0 and sampler 0. The software reference point-samples with
clamp addressing.
BC1 fixtures use only endpoint colours. Apple's hardware decoder gives
171/84 for the interpolated palette entries where the spec-exact decoder
gives 170/85.
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
* gpu: tighten guest texture binding after independent review (#303)
The independent review found binding rules that diverged from D3D12:
changing descriptor heaps kept tables bound in the old heaps, setting the
same root signature again cleared its tables, and unsupported draw shapes
were drawn as one triangle. Now heap changes and a different root signature
invalidate tables, while redundant sets keep them. Table bases are checked
against the bound heap of their type when bound. Textured draws other than
one instance of three vertices fail, and zero vertices or instances draw
nothing.
Descriptor handle offsets can no longer carry into another heap's ID. SRVs
of array or multi-level textures are rejected. A texture whose state
excludes pixel-shader reads is not sampled. Vertex buffer offsets are
overflow-checked. The tests now cover swapped root parameters, a second
sampler slot, off-centre and out-of-range coordinates, state transitions,
draw shapes and resource bounds.
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
* loader: format the guest texture test (#303)
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
* gpu: close the review's remaining texture-binding gaps (#303)
The re-review found three partial fixes. The public software reference
could overflow on a huge viewport. A texture in a combined write and read
state could be sampled. The sampler-slot test used two identical filled
slots. The viewport is now bounded to 4096 pixels. A sampled texture must be
COMMON or a read-only state that includes PIXEL_SHADER_RESOURCE. The sampler
heap now leaves its middle slot empty. The docs now state the start-instance
rule and when table bases are checked.
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
---------
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
Windows maps the first SizeOfHeaders bytes of an image read-only at its
base, and programs read them: the mingw-w64 C runtime walks its own
section table before main. The loader mapped sections only, so that read
faulted.
Map the headers in whole 4 KiB pages before the sections, with the
optional header's ImageBase field set to the base the image is loaded
at. Refuse the load with PeError::InvalidHeaderSize when SizeOfHeaders
ends before the section table, runs past the file, or its pages reach
into a section. The header pages count toward the mapping budget.
ParsedPe::parse is unchanged.
The hand-built image in pe_mapping_limits.rs wrote SizeOfHeaders as
zero; it now writes a valid value.
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
Add the promotion rule for moving desktop gfx1030 forms from local CPU and Metal results to fixture verified. The rule records clean-commit evidence, independent-runner requirements, exact commands, raw-log location, review-log summaries, failure handling and status regeneration. This is documentation only: no status rows, tests or fixtures change. Part of #302.
Signed-off-by: Vedant Dadhich <vedantdadhich21@gmail.com>
Run guest threads on one host thread with independent CPU contexts, guarded
stacks and TEBs, in first-in, first-out order with bounded turns that end at
translated-block boundaries. Add CreateThread, ExitThread, TerminateThread,
GetExitCodeThread, SuspendThread, ResumeThread and SwitchToThread, and let
waits on threads, events, semaphores and mutexes block only the caller.
Report deadlocks, abandoned mutexes and per-thread faults.
Reclaim per-thread state at thread end without passing held locks to a thread
that reuses the TEB address, and bound pending one-time initializations.
Guest threads never run concurrently. Critical sections, SRW locks,
condition variables and Sleep do not block per thread yet.
Verify with C programs compiled for x86-64 Windows and run as translated
guest code at several quanta.
Refs #323
Signed-off-by: jelly013 <22855910+jelly013@users.noreply.github.com>
scripts/test-gpu.sh now runs vop2_vcc_matches_guide_on_native_metal,
which passes under API and shader validation.
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
scripts/test-gpu.sh now runs vopc16_match_the_guide_on_native_metal:
1,572 cases in 1,420 programs pass under API and shader validation.
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
v_cmp_{lt,eq,le,gt,ne,ge}_{i16,u16}_e32 (opcodes 137-142, 169-174) now
compile for gfx1030: both operands use bits 15:0 of the VGPR, SGPR or
VCC_LO source, inline integers at 16 bits, literals rejected, writing the
Wave32 VCC mask. The B1 oracle's last native Metal skip is removed.
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
Sync with main after #215/#198/#130 landings. Keep the guest string-scan
changelog entry alongside the upstream SOP1 registry note, and correct the
runtime_services fuzz harness so corpus bytes drive dispatch instead of the
65,536-byte writable fill (withdrawing the earlier campaign counts).
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
Co-authored-by: Cursor <cursoragent@cursor.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>