Merge remote-tracking branch 'origin/main' into task/215-vopc64-xlate

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
elforeign committed 2026-11-24 10:05:34 -06:00
commit 27daa701c1
10 files changed
+539 -158

No files matched your search

+2
View File
@@ -17,6 +17,8 @@ remains unsupported.
### Added
- Added decoding and Metal shader translation for the sixteen Wave32 VOPC 64-bit integer compares (#215). They read VGPR pairs, known even-aligned SGPR pairs or sign-extended inline integers and write the Wave32 VCC mask. The guide-derived oracle passes on native Metal (4,640 cases in 3,818 programs on a local Apple M5 under API and shader validation); acceptance is pending.
- Added XADD and CMPXCHG for 8- to 64-bit register and memory destinations, and the LOCK prefix on their memory forms (#198). LOCK anywhere else, CMPXCHG8B and CMPXCHG16B stay rejected. Both engines run the new forms on the shared semantics, one instruction at a time, so a locked instruction is indivisible today and LOCK changes no result; `docs/cpu/instruction-registry.md` states the ordering, alignment, compare-failure and fault rules a guest scheduler must preserve. A failed compare still writes the destination, so it faults on memory that cannot be written. Nothing is lowered to ARM64 atomic instructions, and no multi-thread behaviour is established. Fourteen SDM-derived cases already in `cpu_known_answers.rs` moved from refused to verified, with 62 LLVM-assembled fixtures and five new tests in `x86_atomic.rs`; not compared with x86 hardware and awaiting independent review.
- Added CPUID with a fixed, host-independent guest contract (#130). It reports a synthetic processor with the vendor string `Xenora guest` and sets a feature bit only when every instruction of that feature is implemented: CMOV, POPCNT, LZCNT and long mode today. SSE and SSE2 are not reported while parts of them, such as RSQRTPS and MFENCE, are still rejected, so the table is truthful about Xenora and not a plausible hardware model. Unlisted leaves return zeros. `tests/cpu_features.rs` pins every leaf in both engines, requires each reported feature's instructions among the executed fixtures, and holds a refused witness instruction for 31 unreported features. `docs/cpu/instruction-registry.md` gives the table and the rule for reporting a new feature. Not compared with a processor; awaiting independent review.
- Added six Wave32 gfx1030 VOP1 integer forms through the semantic registry, including bit scans and a two-register swap under EXEC (AMD RDNA 2 ISA guide section 12.8, #215). The compiler accepts 752 guide-derived cases and rejects 610 programs at the oracle’s expected offsets. Native Metal verification and independent acceptance are pending.
- Added delay-loaded imports to the static PE probe (#244). `xenora probe --mode static` now reads the PE32+ delay-load directory and lists each delay-loaded import in `imports.csv` with its DLL, symbol or ordinal, and delay import address table slot. A new `import_table` column, inserted after `iat_rva`, marks every row `ordinary` or `delayed`; `import_kind` stays the last column. The existing totals and `missing_imports.csv` still cover ordinary imports only, and the JSON report adds `delayed_imports`, `delayed_imported_dlls_count` and `delay_import_error`. The table is bounded by the directory's declared size, which must hold the empty descriptor that ends it, and each descriptor's DLL name, import address table and import name table must be present and start in section data. A table that breaks these rules, is truncated, sets a reserved attribute bit or uses the earlier virtual-address descriptor form is reported with the entries read before the problem. `xenora imports sync` leaves delayed rows out of its backlog. Inspection stays static: nothing is bound or executed. Covered by an original fixture (`fixtures/pe/delay-imports.exe`, generated by `fixtures/pe/delay-imports.py`) whose imports were cross-checked locally with `llvm-readobj --coff-imports` from LLVM 23.1.6; awaiting independent review.
- Added the sixteen gfx1030 SOPK integer forms through the semantic registry: `s_movk_i32`, `s_cmovk_i32`, `s_cmpk_{eq,lg,gt,ge,lt,le}_{i32,u32}`, `s_addk_i32` and `s_mulk_i32` (AMD guide sections 12.2 and 13.1.2), with SDST s0-s105 only and SIMM16 sign-extended (zero-extended for the unsigned compares). The registry gained the operand rules `sopk_sgpr` and `sopk_compare` and the operations `mov` and `cmov`; the decoder and the scalar translation fold them like SOP2 and SOPC. An independent guide-derived oracle (`tests/validation/tests/sopk.rs`, 4,184 cases and 398 rejections on both CPU interpreters and native Metal), an LLVM-assembled fixture `scalar-immediate.s` with IR and MSL goldens, and the LLVM three-way decoder check cover them (part of #215).
+29
View File
@@ -123,6 +123,35 @@ impl CpuState {
}
}
/// CPUID leaf 1, EDX: CMOVcc.
pub const CPUID_CMOV: u32 = 1 << 15;
/// CPUID leaf 1, ECX: POPCNT.
pub const CPUID_POPCNT: u32 = 1 << 23;
/// CPUID leaf 0x8000_0001, ECX: LZCNT.
pub const CPUID_LZCNT: u32 = 1 << 5;
/// CPUID leaf 0x8000_0001, EDX: 64-bit mode.
pub const CPUID_LONG_MODE: u32 = 1 << 29;
/// What the guest's CPUID returns in EAX, EBX, ECX and EDX.
///
/// The table is fixed and never reads the host. It names a synthetic
/// processor, not an Intel or AMD product, and sets a feature bit only when
/// every instruction of that feature is implemented. A leaf that is not
/// listed returns zeros.
pub fn cpuid(leaf: u32, _subleaf: u32) -> [u32; 4] {
let word = |text: &[u8; 4]| u32::from_le_bytes(*text);
match leaf {
// Highest basic leaf, then "Xenora guest" in EBX, EDX, ECX.
0 => [1, word(b"Xeno"), word(b"uest"), word(b"ra g")],
// No family, model or stepping: this is no shipped processor.
1 => [0, 0, CPUID_POPCNT, CPUID_CMOV],
// Highest extended leaf.
0x8000_0000 => [0x8000_0001, 0, 0, 0],
0x8000_0001 => [0, 0, CPUID_LZCNT, CPUID_LONG_MODE],
_ => [0; 4],
}
}
/// Termination reason for guest execution.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ExitReason {
+10 -1
View File
@@ -10,7 +10,7 @@
//! the state unchanged. Flags that the architecture leaves undefined keep their
//! previous value, which is permitted but not something guests may rely on.
use crate::cpu::{CpuState, ExitReason, RFlags, Register};
use crate::cpu::{CpuState, ExitReason, RFlags, Register, cpuid};
use crate::memory::GuestMemory;
use crate::x86_decode::{Encoding, Insn, MemOperand, RegOperand, RmOperand, Segment};
use crate::x86_simd;
@@ -19,6 +19,7 @@ use crate::x86_table::Op;
const RAX: usize = Register::Rax as usize;
const RCX: usize = Register::Rcx as usize;
const RDX: usize = Register::Rdx as usize;
const RBX: usize = Register::Rbx as usize;
const RSP: usize = Register::Rsp as usize;
const RBP: usize = Register::Rbp as usize;
@@ -573,6 +574,14 @@ pub fn execute(
cpu.gpr[RSP] = sp.wrapping_add(8).wrapping_add(insn.imm);
}
Op::Nop => {}
Op::Cpuid => {
// The leaf is EAX and the subleaf ECX. Each result is a 32-bit
// register write, so the upper halves are cleared.
let values = cpuid(cpu.gpr[RAX] as u32, cpu.gpr[RCX] as u32);
for (register, value) in [RAX, RBX, RCX, RDX].into_iter().zip(values) {
cpu.gpr[register] = u64::from(value);
}
}
Op::Clc => cpu.flags.cf = false,
Op::Stc => cpu.flags.cf = true,
Op::Cmc => cpu.flags.cf = !cpu.flags.cf,
+166 -156
View File
@@ -66,6 +66,7 @@ pub enum Op {
Clc,
Stc,
Cmc,
Cpuid,
Movaps,
Movups,
Movdqa,
@@ -204,7 +205,7 @@ pub enum Op {
}
impl Op {
pub const ALL: &[Op] = &[Op::Add, Op::Or, Op::Adc, Op::Sbb, Op::And, Op::Sub, Op::Xor, Op::Cmp, Op::Test, Op::Inc, Op::Dec, Op::Neg, Op::Not, Op::Mov, Op::Movzx, Op::Movsx, Op::Movsxd, Op::Lea, Op::Xchg, Op::Xadd, Op::Cmpxchg, Op::Bswap, Op::Cwde, Op::Cdq, Op::Rol, Op::Ror, Op::Shl, Op::Shr, Op::Sar, Op::Mul, Op::Imul, Op::Imul2, Op::Div, Op::Idiv, Op::Cmov, Op::Setcc, Op::Bt, Op::Bts, Op::Btr, Op::Btc, Op::Bsf, Op::Bsr, Op::Popcnt, Op::Tzcnt, Op::Lzcnt, Op::Push, Op::Pop, Op::Leave, Op::Call, Op::Jmp, Op::Jcc, Op::Ret, Op::Nop, Op::Hlt, Op::Syscall, Op::Clc, Op::Stc, Op::Cmc, Op::Movaps, Op::Movups, Op::Movdqa, Op::Movdqu, Op::Movntdq, Op::Movntps, Op::Movss, Op::Movsd, Op::Movq, Op::Movd, Op::Movlps, Op::Movhps, Op::Movmskps, Op::Movmskpd, Op::Pmovmskb, Op::Pand, Op::Pandn, Op::Por, Op::Pxor, Op::Punpcklbw, Op::Punpcklwd, Op::Punpckldq, Op::Packsswb, Op::Pcmpgtb, Op::Pcmpgtw, Op::Pcmpgtd, Op::Packuswb, Op::Punpckhbw, Op::Punpckhwd, Op::Punpckhdq, Op::Packssdw, Op::Punpcklqdq, Op::Punpckhqdq, Op::Pcmpeqb, Op::Pcmpeqw, Op::Pcmpeqd, Op::Paddq, Op::Pmullw, Op::Psubusb, Op::Psubusw, Op::Pminub, Op::Paddusb, Op::Paddusw, Op::Pmaxub, Op::Pavgb, Op::Pavgw, Op::Pmulhuw, Op::Pmulhw, Op::Psubsb, Op::Psubsw, Op::Pminsw, Op::Paddsb, Op::Paddsw, Op::Pmaxsw, Op::Pmuludq, Op::Pmaddwd, Op::Psadbw, Op::Psubb, Op::Psubw, Op::Psubd, Op::Psubq, Op::Paddb, Op::Paddw, Op::Paddd, Op::Psrlw, Op::Psraw, Op::Psllw, Op::Psrld, Op::Psrad, Op::Pslld, Op::Psrlq, Op::Psllq, Op::Psrldq, Op::Pslldq, Op::Pshufd, Op::Pshufhw, Op::Pshuflw, Op::Shufps, Op::Shufpd, Op::Pinsrw, Op::Pextrw, Op::Ldmxcsr, Op::Stmxcsr, Op::Sqrtps, Op::Sqrtpd, Op::Sqrtss, Op::Sqrtsd, Op::Addps, Op::Addpd, Op::Addss, Op::Addsd, Op::Mulps, Op::Mulpd, Op::Mulss, Op::Mulsd, Op::Subps, Op::Subpd, Op::Subss, Op::Subsd, Op::Minps, Op::Minpd, Op::Minss, Op::Minsd, Op::Divps, Op::Divpd, Op::Divss, Op::Divsd, Op::Maxps, Op::Maxpd, Op::Maxss, Op::Maxsd, Op::Cmpps, Op::Cmppd, Op::Cmpss, Op::Cmpsd, Op::Ucomiss, Op::Comiss, Op::Ucomisd, Op::Comisd, Op::Cvtps2pd, Op::Cvtpd2ps, Op::Cvtss2sd, Op::Cvtsd2ss, Op::Cvtdq2ps, Op::Cvtps2dq, Op::Cvttps2dq, Op::Cvttpd2dq, Op::Cvtdq2pd, Op::Cvtpd2dq, Op::Cvtsi2ss, Op::Cvttss2si, Op::Cvtss2si, Op::Cvtsi2sd, Op::Cvttsd2si, Op::Cvtsd2si];
pub const ALL: &[Op] = &[Op::Add, Op::Or, Op::Adc, Op::Sbb, Op::And, Op::Sub, Op::Xor, Op::Cmp, Op::Test, Op::Inc, Op::Dec, Op::Neg, Op::Not, Op::Mov, Op::Movzx, Op::Movsx, Op::Movsxd, Op::Lea, Op::Xchg, Op::Xadd, Op::Cmpxchg, Op::Bswap, Op::Cwde, Op::Cdq, Op::Rol, Op::Ror, Op::Shl, Op::Shr, Op::Sar, Op::Mul, Op::Imul, Op::Imul2, Op::Div, Op::Idiv, Op::Cmov, Op::Setcc, Op::Bt, Op::Bts, Op::Btr, Op::Btc, Op::Bsf, Op::Bsr, Op::Popcnt, Op::Tzcnt, Op::Lzcnt, Op::Push, Op::Pop, Op::Leave, Op::Call, Op::Jmp, Op::Jcc, Op::Ret, Op::Nop, Op::Hlt, Op::Syscall, Op::Clc, Op::Stc, Op::Cmc, Op::Cpuid, Op::Movaps, Op::Movups, Op::Movdqa, Op::Movdqu, Op::Movntdq, Op::Movntps, Op::Movss, Op::Movsd, Op::Movq, Op::Movd, Op::Movlps, Op::Movhps, Op::Movmskps, Op::Movmskpd, Op::Pmovmskb, Op::Pand, Op::Pandn, Op::Por, Op::Pxor, Op::Punpcklbw, Op::Punpcklwd, Op::Punpckldq, Op::Packsswb, Op::Pcmpgtb, Op::Pcmpgtw, Op::Pcmpgtd, Op::Packuswb, Op::Punpckhbw, Op::Punpckhwd, Op::Punpckhdq, Op::Packssdw, Op::Punpcklqdq, Op::Punpckhqdq, Op::Pcmpeqb, Op::Pcmpeqw, Op::Pcmpeqd, Op::Paddq, Op::Pmullw, Op::Psubusb, Op::Psubusw, Op::Pminub, Op::Paddusb, Op::Paddusw, Op::Pmaxub, Op::Pavgb, Op::Pavgw, Op::Pmulhuw, Op::Pmulhw, Op::Psubsb, Op::Psubsw, Op::Pminsw, Op::Paddsb, Op::Paddsw, Op::Pmaxsw, Op::Pmuludq, Op::Pmaddwd, Op::Psadbw, Op::Psubb, Op::Psubw, Op::Psubd, Op::Psubq, Op::Paddb, Op::Paddw, Op::Paddd, Op::Psrlw, Op::Psraw, Op::Psllw, Op::Psrld, Op::Psrad, Op::Pslld, Op::Psrlq, Op::Psllq, Op::Psrldq, Op::Pslldq, Op::Pshufd, Op::Pshufhw, Op::Pshuflw, Op::Shufps, Op::Shufpd, Op::Pinsrw, Op::Pextrw, Op::Ldmxcsr, Op::Stmxcsr, Op::Sqrtps, Op::Sqrtpd, Op::Sqrtss, Op::Sqrtsd, Op::Addps, Op::Addpd, Op::Addss, Op::Addsd, Op::Mulps, Op::Mulpd, Op::Mulss, Op::Mulsd, Op::Subps, Op::Subpd, Op::Subss, Op::Subsd, Op::Minps, Op::Minpd, Op::Minss, Op::Minsd, Op::Divps, Op::Divpd, Op::Divss, Op::Divsd, Op::Maxps, Op::Maxpd, Op::Maxss, Op::Maxsd, Op::Cmpps, Op::Cmppd, Op::Cmpss, Op::Cmpsd, Op::Ucomiss, Op::Comiss, Op::Ucomisd, Op::Comisd, Op::Cvtps2pd, Op::Cvtpd2ps, Op::Cvtss2sd, Op::Cvtsd2ss, Op::Cvtdq2ps, Op::Cvtps2dq, Op::Cvttps2dq, Op::Cvttpd2dq, Op::Cvtdq2pd, Op::Cvtpd2dq, Op::Cvtsi2ss, Op::Cvttss2si, Op::Cvtss2si, Op::Cvtsi2sd, Op::Cvttsd2si, Op::Cvtsd2si];
/// Lower-case mnemonic stem.
pub const fn name(self) -> &'static str {
@@ -267,6 +268,7 @@ impl Op {
Op::Clc => "clc",
Op::Stc => "stc",
Op::Cmc => "cmc",
Op::Cpuid => "cpuid",
Op::Movaps => "movaps",
Op::Movups => "movups",
Op::Movdqa => "movdqa",
@@ -466,6 +468,7 @@ impl Op {
Op::Clc => 0,
Op::Stc => 0,
Op::Cmc => 1,
Op::Cpuid => 0,
Op::Movaps => 0,
Op::Movups => 0,
Op::Movdqa => 0,
@@ -665,6 +668,7 @@ impl Op {
Op::Clc => 1,
Op::Stc => 1,
Op::Cmc => 1,
Op::Cpuid => 0,
Op::Movaps => 0,
Op::Movups => 0,
Op::Movdqa => 0,
@@ -864,6 +868,7 @@ impl Op {
Op::Clc => 1,
Op::Stc => 1,
Op::Cmc => 1,
Op::Cpuid => 0,
Op::Movaps => 0,
Op::Movups => 0,
Op::Movdqa => 0,
@@ -1063,6 +1068,7 @@ impl Op {
Op::Clc => 0,
Op::Stc => 0,
Op::Cmc => 0,
Op::Cpuid => 0,
Op::Movaps => 0,
Op::Movups => 0,
Op::Movdqa => 0,
@@ -1262,6 +1268,7 @@ impl Op {
Op::Clc => false,
Op::Stc => false,
Op::Cmc => false,
Op::Cpuid => false,
Op::Movaps => false,
Op::Movups => false,
Op::Movdqa => false,
@@ -1461,6 +1468,7 @@ impl Op {
Op::Clc => false,
Op::Stc => false,
Op::Cmc => false,
Op::Cpuid => false,
Op::Movaps => false,
Op::Movups => false,
Op::Movdqa => false,
@@ -1660,6 +1668,7 @@ impl Op {
Op::Clc => false,
Op::Stc => false,
Op::Cmc => false,
Op::Cpuid => false,
Op::Movaps => true,
Op::Movups => true,
Op::Movdqa => true,
@@ -1799,7 +1808,7 @@ impl Op {
}
}
pub static FORMS: [Form; 362] = [
pub static FORMS: [Form; 363] = [
Form { op: Op::Movsxd, encoding: Encoding::RegRm, size: OperandSize::Wide, immediate: Immediate::None, source: 4, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
Form { op: Op::Push, encoding: Encoding::OpReg, size: OperandSize::Quad, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
Form { op: Op::Pop, encoding: Encoding::OpReg, size: OperandSize::Quad, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
@@ -1848,6 +1857,7 @@ pub static FORMS: [Form; 362] = [
Form { op: Op::Clc, encoding: Encoding::None, size: OperandSize::None, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
Form { op: Op::Stc, encoding: Encoding::None, size: OperandSize::None, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
Form { op: Op::Syscall, encoding: Encoding::None, size: OperandSize::None, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
Form { op: Op::Cpuid, encoding: Encoding::None, size: OperandSize::None, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
Form { op: Op::Movzx, encoding: Encoding::RegRm, size: OperandSize::Variable, immediate: Immediate::None, source: 1, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
Form { op: Op::Movzx, encoding: Encoding::RegRm, size: OperandSize::Variable, immediate: Immediate::None, source: 2, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
Form { op: Op::Movsx, encoding: Encoding::RegRm, size: OperandSize::Variable, immediate: Immediate::None, source: 1, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
@@ -2166,47 +2176,47 @@ pub static FORMS: [Form; 362] = [
/// Form per ModRM digit; 65535 marks an unsupported digit.
pub static GROUPS: [[u16; 8]; 22] = [
[246, 255, 264, 273, 282, 291, 300, 309],
[247, 256, 265, 274, 283, 292, 301, 310],
[248, 257, 266, 275, 284, 293, 302, 311],
[249, 258, 267, 276, 285, 294, 303, 312],
[6, 65535, 65535, 65535, 65535, 65535, 65535, 65535],
[332, 333, 65535, 65535, 334, 335, 65535, 336],
[337, 338, 65535, 65535, 339, 340, 65535, 341],
[333, 334, 65535, 65535, 335, 336, 65535, 337],
[338, 339, 65535, 65535, 340, 341, 65535, 342],
[33, 65535, 65535, 65535, 65535, 65535, 65535, 65535],
[34, 65535, 65535, 65535, 65535, 65535, 65535, 65535],
[342, 343, 65535, 65535, 344, 345, 65535, 346],
[347, 348, 65535, 65535, 349, 350, 65535, 351],
[352, 353, 65535, 65535, 354, 355, 65535, 356],
[357, 358, 65535, 65535, 359, 360, 65535, 361],
[18, 65535, 316, 317, 318, 319, 320, 321],
[19, 65535, 322, 323, 324, 325, 326, 327],
[328, 329, 65535, 65535, 65535, 65535, 65535, 65535],
[330, 331, 41, 65535, 42, 65535, 5, 65535],
[343, 344, 65535, 65535, 345, 346, 65535, 347],
[348, 349, 65535, 65535, 350, 351, 65535, 352],
[353, 354, 65535, 65535, 355, 356, 65535, 357],
[358, 359, 65535, 65535, 360, 361, 65535, 362],
[18, 65535, 317, 318, 319, 320, 321, 322],
[19, 65535, 323, 324, 325, 326, 327, 328],
[329, 330, 65535, 65535, 65535, 65535, 65535, 65535],
[331, 332, 41, 65535, 42, 65535, 5, 65535],
[28, 65535, 65535, 65535, 65535, 65535, 65535, 65535],
[65535, 65535, 186, 187, 65535, 65535, 65535, 65535],
[65535, 65535, 65535, 65535, 312, 313, 314, 315],
[65535, 65535, 158, 65535, 160, 65535, 162, 65535],
[65535, 65535, 164, 65535, 166, 65535, 168, 65535],
[65535, 65535, 170, 173, 65535, 65535, 172, 174],
[65535, 65535, 187, 188, 65535, 65535, 65535, 65535],
[65535, 65535, 65535, 65535, 313, 314, 315, 316],
[65535, 65535, 159, 65535, 161, 65535, 163, 65535],
[65535, 65535, 165, 65535, 167, 65535, 169, 65535],
[65535, 65535, 171, 174, 65535, 65535, 173, 175],
];
pub static ONE_BYTE: [Entry; 256] = [
Entry::Form(240), Entry::Form(241), Entry::Form(242), Entry::Form(243),
Entry::Form(244), Entry::Form(245), Entry::Unsupported, Entry::Unsupported,
Entry::Form(249), Entry::Form(250), Entry::Form(251), Entry::Form(252),
Entry::Form(253), Entry::Form(254), Entry::Unsupported, Entry::Unsupported,
Entry::Form(258), Entry::Form(259), Entry::Form(260), Entry::Form(261),
Entry::Form(262), Entry::Form(263), Entry::Unsupported, Entry::Unsupported,
Entry::Form(267), Entry::Form(268), Entry::Form(269), Entry::Form(270),
Entry::Form(271), Entry::Form(272), Entry::Unsupported, Entry::Unsupported,
Entry::Form(276), Entry::Form(277), Entry::Form(278), Entry::Form(279),
Entry::Form(280), Entry::Form(281), Entry::Unsupported, Entry::Unsupported,
Entry::Form(285), Entry::Form(286), Entry::Form(287), Entry::Form(288),
Entry::Form(289), Entry::Form(290), Entry::Unsupported, Entry::Unsupported,
Entry::Form(294), Entry::Form(295), Entry::Form(296), Entry::Form(297),
Entry::Form(298), Entry::Form(299), Entry::Unsupported, Entry::Unsupported,
Entry::Form(303), Entry::Form(304), Entry::Form(305), Entry::Form(306),
Entry::Form(307), Entry::Form(308), Entry::Unsupported, Entry::Unsupported,
Entry::Form(241), Entry::Form(242), Entry::Form(243), Entry::Form(244),
Entry::Form(245), Entry::Form(246), Entry::Unsupported, Entry::Unsupported,
Entry::Form(250), Entry::Form(251), Entry::Form(252), Entry::Form(253),
Entry::Form(254), Entry::Form(255), Entry::Unsupported, Entry::Unsupported,
Entry::Form(259), Entry::Form(260), Entry::Form(261), Entry::Form(262),
Entry::Form(263), Entry::Form(264), Entry::Unsupported, Entry::Unsupported,
Entry::Form(268), Entry::Form(269), Entry::Form(270), Entry::Form(271),
Entry::Form(272), Entry::Form(273), Entry::Unsupported, Entry::Unsupported,
Entry::Form(277), Entry::Form(278), Entry::Form(279), Entry::Form(280),
Entry::Form(281), Entry::Form(282), Entry::Unsupported, Entry::Unsupported,
Entry::Form(286), Entry::Form(287), Entry::Form(288), Entry::Form(289),
Entry::Form(290), Entry::Form(291), Entry::Unsupported, Entry::Unsupported,
Entry::Form(295), Entry::Form(296), Entry::Form(297), Entry::Form(298),
Entry::Form(299), Entry::Form(300), Entry::Unsupported, Entry::Unsupported,
Entry::Form(304), Entry::Form(305), Entry::Form(306), Entry::Form(307),
Entry::Form(308), Entry::Form(309), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
@@ -2262,14 +2272,14 @@ pub static TWO_BYTE: [Entry; 256] = [
Entry::Unsupported, Entry::Form(47), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(70), Entry::Form(71), Entry::Form(89), Entry::Form(91),
Entry::Form(180), Entry::Form(182), Entry::Form(93), Entry::Form(95),
Entry::Form(71), Entry::Form(72), Entry::Form(90), Entry::Form(92),
Entry::Form(181), Entry::Form(183), Entry::Form(94), Entry::Form(96),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Group(16),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(66), Entry::Form(67), Entry::Unsupported, Entry::Form(79),
Entry::Unsupported, Entry::Unsupported, Entry::Form(220), Entry::Form(221),
Entry::Form(67), Entry::Form(68), Entry::Unsupported, Entry::Form(80),
Entry::Unsupported, Entry::Unsupported, Entry::Form(221), Entry::Form(222),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
@@ -2278,10 +2288,10 @@ pub static TWO_BYTE: [Entry; 256] = [
Entry::Form(12), Entry::Form(12), Entry::Form(12), Entry::Form(12),
Entry::Form(12), Entry::Form(12), Entry::Form(12), Entry::Form(12),
Entry::Form(12), Entry::Form(12), Entry::Form(12), Entry::Form(12),
Entry::Form(97), Entry::Form(188), Entry::Unsupported, Entry::Unsupported,
Entry::Form(101), Entry::Form(104), Entry::Form(107), Entry::Form(110),
Entry::Form(192), Entry::Form(196), Entry::Form(224), Entry::Form(228),
Entry::Form(200), Entry::Form(204), Entry::Form(208), Entry::Form(212),
Entry::Form(98), Entry::Form(189), Entry::Unsupported, Entry::Unsupported,
Entry::Form(102), Entry::Form(105), Entry::Form(108), Entry::Form(111),
Entry::Form(193), Entry::Form(197), Entry::Form(225), Entry::Form(229),
Entry::Form(201), Entry::Form(205), Entry::Form(209), Entry::Form(213),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
@@ -2298,18 +2308,18 @@ pub static TWO_BYTE: [Entry; 256] = [
Entry::Form(13), Entry::Form(13), Entry::Form(13), Entry::Form(13),
Entry::Form(13), Entry::Form(13), Entry::Form(13), Entry::Form(13),
Entry::Form(13), Entry::Form(13), Entry::Form(13), Entry::Form(13),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Form(58),
Entry::Unsupported, Entry::Unsupported, Entry::Form(48), Entry::Form(59),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Form(59),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Form(60),
Entry::Unsupported, Entry::Unsupported, Entry::Group(17), Entry::Form(9),
Entry::Form(62), Entry::Form(63), Entry::Unsupported, Entry::Form(60),
Entry::Unsupported, Entry::Unsupported, Entry::Form(48), Entry::Form(49),
Entry::Unsupported, Entry::Unsupported, Entry::Group(18), Entry::Form(61),
Entry::Form(53), Entry::Form(54), Entry::Form(50), Entry::Form(51),
Entry::Form(64), Entry::Form(65), Entry::Form(216), Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(178), Entry::Unsupported,
Entry::Form(52), Entry::Form(52), Entry::Form(52), Entry::Form(52),
Entry::Form(52), Entry::Form(52), Entry::Form(52), Entry::Form(52),
Entry::Form(63), Entry::Form(64), Entry::Unsupported, Entry::Form(61),
Entry::Unsupported, Entry::Unsupported, Entry::Form(49), Entry::Form(50),
Entry::Unsupported, Entry::Unsupported, Entry::Group(18), Entry::Form(62),
Entry::Form(54), Entry::Form(55), Entry::Form(51), Entry::Form(52),
Entry::Form(65), Entry::Form(66), Entry::Form(217), Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(179), Entry::Unsupported,
Entry::Form(53), Entry::Form(53), Entry::Form(53), Entry::Form(53),
Entry::Form(53), Entry::Form(53), Entry::Form(53), Entry::Form(53),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
@@ -2329,14 +2339,14 @@ pub static TWO_BYTE_66: [Entry; 256] = [
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(72), Entry::Form(73), Entry::Form(90), Entry::Form(92),
Entry::Form(181), Entry::Form(183), Entry::Form(94), Entry::Form(96),
Entry::Form(73), Entry::Form(74), Entry::Form(91), Entry::Form(93),
Entry::Form(182), Entry::Form(184), Entry::Form(95), Entry::Form(97),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(68), Entry::Form(69), Entry::Unsupported, Entry::Form(80),
Entry::Unsupported, Entry::Unsupported, Entry::Form(222), Entry::Form(223),
Entry::Form(69), Entry::Form(70), Entry::Unsupported, Entry::Form(81),
Entry::Unsupported, Entry::Unsupported, Entry::Form(223), Entry::Form(224),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
@@ -2345,18 +2355,18 @@ pub static TWO_BYTE_66: [Entry; 256] = [
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(98), Entry::Form(189), Entry::Unsupported, Entry::Unsupported,
Entry::Form(102), Entry::Form(105), Entry::Form(108), Entry::Form(111),
Entry::Form(193), Entry::Form(197), Entry::Form(225), Entry::Form(229),
Entry::Form(201), Entry::Form(205), Entry::Form(209), Entry::Form(213),
Entry::Form(112), Entry::Form(113), Entry::Form(114), Entry::Form(115),
Entry::Form(116), Entry::Form(117), Entry::Form(118), Entry::Form(119),
Entry::Form(120), Entry::Form(121), Entry::Form(122), Entry::Form(123),
Entry::Form(124), Entry::Form(125), Entry::Form(87), Entry::Form(74),
Entry::Form(175), Entry::Group(19), Entry::Group(20), Entry::Group(21),
Entry::Form(126), Entry::Form(127), Entry::Form(128), Entry::Unsupported,
Entry::Form(99), Entry::Form(190), Entry::Unsupported, Entry::Unsupported,
Entry::Form(103), Entry::Form(106), Entry::Form(109), Entry::Form(112),
Entry::Form(194), Entry::Form(198), Entry::Form(226), Entry::Form(230),
Entry::Form(202), Entry::Form(206), Entry::Form(210), Entry::Form(214),
Entry::Form(113), Entry::Form(114), Entry::Form(115), Entry::Form(116),
Entry::Form(117), Entry::Form(118), Entry::Form(119), Entry::Form(120),
Entry::Form(121), Entry::Form(122), Entry::Form(123), Entry::Form(124),
Entry::Form(125), Entry::Form(126), Entry::Form(88), Entry::Form(75),
Entry::Form(176), Entry::Group(19), Entry::Group(20), Entry::Group(21),
Entry::Form(127), Entry::Form(128), Entry::Form(129), Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(88), Entry::Form(75),
Entry::Unsupported, Entry::Unsupported, Entry::Form(89), Entry::Form(76),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
@@ -2373,22 +2383,22 @@ pub static TWO_BYTE_66: [Entry; 256] = [
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(217), Entry::Unsupported,
Entry::Form(184), Entry::Form(185), Entry::Form(179), Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(218), Entry::Unsupported,
Entry::Form(185), Entry::Form(186), Entry::Form(180), Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Form(157), Entry::Form(163), Entry::Form(169),
Entry::Form(129), Entry::Form(130), Entry::Form(86), Entry::Form(99),
Entry::Form(131), Entry::Form(132), Entry::Form(133), Entry::Form(100),
Entry::Form(134), Entry::Form(135), Entry::Form(136), Entry::Form(103),
Entry::Form(137), Entry::Form(159), Entry::Form(165), Entry::Form(138),
Entry::Form(139), Entry::Form(140), Entry::Form(231), Entry::Form(78),
Entry::Form(141), Entry::Form(142), Entry::Form(143), Entry::Form(106),
Entry::Form(144), Entry::Form(145), Entry::Form(146), Entry::Form(109),
Entry::Unsupported, Entry::Form(161), Entry::Form(167), Entry::Form(171),
Entry::Form(147), Entry::Form(148), Entry::Form(149), Entry::Unsupported,
Entry::Form(150), Entry::Form(151), Entry::Form(152), Entry::Form(153),
Entry::Form(154), Entry::Form(155), Entry::Form(156), Entry::Unsupported,
Entry::Unsupported, Entry::Form(158), Entry::Form(164), Entry::Form(170),
Entry::Form(130), Entry::Form(131), Entry::Form(87), Entry::Form(100),
Entry::Form(132), Entry::Form(133), Entry::Form(134), Entry::Form(101),
Entry::Form(135), Entry::Form(136), Entry::Form(137), Entry::Form(104),
Entry::Form(138), Entry::Form(160), Entry::Form(166), Entry::Form(139),
Entry::Form(140), Entry::Form(141), Entry::Form(232), Entry::Form(79),
Entry::Form(142), Entry::Form(143), Entry::Form(144), Entry::Form(107),
Entry::Form(145), Entry::Form(146), Entry::Form(147), Entry::Form(110),
Entry::Unsupported, Entry::Form(162), Entry::Form(168), Entry::Form(172),
Entry::Form(148), Entry::Form(149), Entry::Form(150), Entry::Unsupported,
Entry::Form(151), Entry::Form(152), Entry::Form(153), Entry::Form(154),
Entry::Form(155), Entry::Form(156), Entry::Form(157), Entry::Unsupported,
];
pub static TWO_BYTE_F3: [Entry; 256] = [
@@ -2396,81 +2406,14 @@ pub static TWO_BYTE_F3: [Entry; 256] = [
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(81), Entry::Form(82), Entry::Unsupported, Entry::Unsupported,
Entry::Form(82), Entry::Form(83), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(234), Entry::Unsupported,
Entry::Form(235), Entry::Form(236), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Form(190), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(194), Entry::Form(198), Entry::Form(226), Entry::Form(230),
Entry::Form(202), Entry::Form(206), Entry::Form(210), Entry::Form(214),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Form(76),
Entry::Form(176), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(85), Entry::Form(77),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(55), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(56), Entry::Form(57), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(218), Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(232), Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
];
pub static TWO_BYTE_F2: [Entry; 256] = [
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(83), Entry::Form(84), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(237), Entry::Unsupported,
Entry::Form(238), Entry::Form(239), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(235), Entry::Unsupported,
Entry::Form(236), Entry::Form(237), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
@@ -2481,15 +2424,16 @@ pub static TWO_BYTE_F2: [Entry; 256] = [
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Form(191), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(195), Entry::Form(199), Entry::Form(227), Entry::Unsupported,
Entry::Form(195), Entry::Form(199), Entry::Form(227), Entry::Form(231),
Entry::Form(203), Entry::Form(207), Entry::Form(211), Entry::Form(215),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Form(77),
Entry::Form(177), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(86), Entry::Form(78),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
@@ -2504,9 +2448,8 @@ pub static TWO_BYTE_F2: [Entry; 256] = [
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(56), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(57), Entry::Form(58), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(219), Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
@@ -2524,3 +2467,70 @@ pub static TWO_BYTE_F2: [Entry; 256] = [
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
];
pub static TWO_BYTE_F2: [Entry; 256] = [
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(84), Entry::Form(85), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(238), Entry::Unsupported,
Entry::Form(239), Entry::Form(240), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Form(192), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(196), Entry::Form(200), Entry::Form(228), Entry::Unsupported,
Entry::Form(204), Entry::Form(208), Entry::Form(212), Entry::Form(216),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(178), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(220), Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(234), Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
];
+282
View File
@@ -0,0 +1,282 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//! The guest CPUID contract (issue #130).
//!
//! CPUID reports a fixed synthetic processor. A feature bit is set only when
//! every instruction of that feature is implemented, so each bit that is set
//! is checked against instructions that run, and each bit software commonly
//! tests that is clear has a witness instruction of that feature which both
//! engines refuse. The witness must be removed before its bit can be set.
//!
//! Bit positions and the feature each instruction belongs to are from the
//! Intel SDM Vol. 2, CPUID and the instruction entries. Encodings were
//! assembled with `clang -target x86_64-apple-macos` and read with `objdump`.
use xenora_loader::cpu::{
CPUID_CMOV, CPUID_LONG_MODE, CPUID_LZCNT, CPUID_POPCNT, CpuState, ExitReason, Interpreter,
RFlags, cpuid,
};
use xenora_loader::dbt::DbtEngine;
use xenora_loader::memory::{GuestMemory, MemoryPermissions};
use xenora_loader::x86_decode::decode;
const ENTRY: u64 = 0x1000;
const RAX: usize = 0;
const RCX: usize = 1;
const RDX: usize = 2;
const RBX: usize = 3;
const RSI: usize = 6;
/// Index of a CPUID result, which come in the order EAX, EBX, ECX, EDX.
const EBX: usize = 1;
const ECX: usize = 2;
const EDX: usize = 3;
fn image(code: &[u8]) -> GuestMemory {
let mut memory = GuestMemory::new();
memory
.map_region_with_data(ENTRY, code.len(), MemoryPermissions::READ_EXECUTE, code)
.unwrap();
memory
}
/// Final state and exit reason from the interpreter, then from the DBT.
fn both(cpu: &CpuState, code: &[u8], budget: usize) -> [(&'static str, CpuState, ExitReason); 2] {
let mut memory = image(code);
let interpreted = Interpreter::new(cpu.clone(), &mut memory, budget).run();
let mut memory = image(code);
let mut state = cpu.clone();
let translated = DbtEngine::new(64 * 1024)
.unwrap()
.run(&mut state, &mut memory, budget);
[
(
"interpreter",
interpreted.final_state,
interpreted.exit_reason,
),
("DBT", translated.final_state, translated.exit_reason),
]
}
const SET: RFlags = RFlags {
cf: true,
zf: true,
sf: true,
of: true,
pf: true,
af: true,
};
#[test]
fn every_leaf_returns_its_documented_values() {
// (leaf, subleaf, [EAX, EBX, ECX, EDX])
let leaves: &[(u32, u32, [u32; 4])] = &[
// Highest basic leaf 1, and "Xeno", "uest", "ra g" as little-endian text.
(0, 0, [1, 0x6F6E_6558, 0x7473_6575, 0x6720_6172]),
// POPCNT is ECX bit 23 and CMOV is EDX bit 15. No signature.
(1, 0, [0, 0, 0x0080_0000, 0x0000_8000]),
(1, 0xFFFF_FFFF, [0, 0, 0x0080_0000, 0x0000_8000]),
// Highest extended leaf.
(0x8000_0000, 0, [0x8000_0001, 0, 0, 0]),
// LZCNT is ECX bit 5 and long mode is EDX bit 29.
(0x8000_0001, 0, [0, 0, 0x0000_0020, 0x2000_0000]),
(0x8000_0001, 7, [0, 0, 0x0000_0020, 0x2000_0000]),
// Everything else, above or between the highest leaves, is zeros.
(2, 0, [0; 4]),
(4, 0, [0; 4]),
(6, 0, [0; 4]),
(7, 0, [0; 4]),
(7, 1, [0; 4]),
(0xB, 0, [0; 4]),
(0xD, 1, [0; 4]),
(0x16, 0, [0; 4]),
(0x4000_0000, 0, [0; 4]),
(0x7FFF_FFFF, 0, [0; 4]),
(0x8000_0002, 0, [0; 4]),
(0x8000_0008, 0, [0; 4]),
(0xFFFF_FFFF, 0, [0; 4]),
];
for &(leaf, subleaf, wanted) in leaves {
// Only EAX and ECX select the leaf: the upper halves are noise.
let mut cpu = CpuState::new(ENTRY, 0);
for (index, register) in cpu.gpr.iter_mut().enumerate() {
*register = 0xA5A5_0000_1111_0000 + index as u64;
}
cpu.gpr[RAX] = 0xDEAD_BEEF_0000_0000 | u64::from(leaf);
cpu.gpr[RCX] = 0xFEED_FACE_0000_0000 | u64::from(subleaf);
cpu.flags = SET;
// Each result is a 32-bit register write, so it clears the upper half.
// CPUID changes no flag and no other register.
let mut expected = cpu.clone();
expected.rip = ENTRY + 2;
for (register, value) in [RAX, RBX, RCX, RDX].into_iter().zip(wanted) {
expected.gpr[register] = u64::from(value);
}
for (engine, state, exit) in both(&cpu, &[0x0F, 0xA2], 1) {
let what = format!("leaf {leaf:#x} subleaf {subleaf:#x} on the {engine}");
assert_eq!(exit, ExitReason::StepLimitExceeded, "{what}");
assert_eq!(state, expected, "{what}");
}
// The function a runtime service would read agrees with the instruction.
assert_eq!(cpuid(leaf, subleaf), wanted, "leaf {leaf:#x}");
}
let [_, ebx, ecx, edx] = cpuid(0, 0);
let vendor: Vec<u8> = [ebx, edx, ecx]
.into_iter()
.flat_map(u32::to_le_bytes)
.collect();
assert_eq!(vendor, b"Xenora guest");
assert_eq!(
(CPUID_POPCNT, CPUID_CMOV, CPUID_LZCNT, CPUID_LONG_MODE),
(1 << 23, 1 << 15, 1 << 5, 1 << 29)
);
}
#[test]
fn reported_features_have_all_their_instructions_in_the_fixtures() {
// `tests/x86_integer.rs` runs every line of this file through both engines
// against an independent reference. Here each reported feature must have
// its whole instruction set among those lines.
let fixture = include_str!("x86/integer.txt");
let decodable = |text: &str| {
let line = fixture
.lines()
.find(|line| line.split_once(" | ").is_some_and(|(_, asm)| asm == text))
.unwrap_or_else(|| panic!("no fixture for {text}"));
let code: Vec<u8> = line
.split_once(" | ")
.unwrap()
.0
.split(' ')
.map(|byte| u8::from_str_radix(byte, 16).unwrap())
.collect();
decode(ENTRY, |at| {
code.get((at - ENTRY) as usize).copied().ok_or(())
})
.unwrap_or_else(|error| panic!("{text}: {error:?}"));
};
let memory = |bits: u32| {
let width = match bits {
16 => "word",
32 => "dword",
_ => "qword",
};
format!("{width} ptr [rsi + 4*rdi + 16]")
};
// 16-, 32- and 64-bit destinations (RBX and R10) from a register and from memory.
let sizes = [
(16, "bx", "r9w", "r10w"),
(32, "ebx", "r9d", "r10d"),
(64, "rbx", "r9", "r10"),
];
assert_ne!(cpuid(1, 0)[EDX] & CPUID_CMOV, 0);
for condition in "o no b ae e ne be a s ns p np l ge le g".split(' ') {
for (bits, low, source, high) in sizes {
decodable(&format!("cmov{condition} {low}, {source}"));
decodable(&format!("cmov{condition} {high}, {}", memory(bits)));
}
}
for (feature, bit, name) in [
(cpuid(1, 0)[ECX], CPUID_POPCNT, "popcnt"),
(cpuid(0x8000_0001, 0)[ECX], CPUID_LZCNT, "lzcnt"),
] {
assert_ne!(feature & bit, 0, "{name}");
for (bits, low, source, high) in sizes {
decodable(&format!("{name} {low}, {source}"));
decodable(&format!("{name} {high}, {}", memory(bits)));
}
}
// Long mode: 64-bit operands and the registers only it has.
assert_ne!(cpuid(0x8000_0001, 0)[EDX] & CPUID_LONG_MODE, 0);
decodable("add r9, r12");
decodable("movabs r15, 0x8877665544332211");
}
#[test]
fn unreported_features_each_have_an_instruction_that_is_refused() {
// (feature, leaf, result register, bit, an instruction of that feature)
let witnesses: &[(&str, u32, usize, u32, &[u8])] = &[
("FPU", 1, EDX, 0, &[0xD9, 0xE8]), // fld1
("TSC", 1, EDX, 4, &[0x0F, 0x31]), // rdtsc
("CX8", 1, EDX, 8, &[0x0F, 0xC7, 0x0E]), // cmpxchg8b [rsi]
("CLFSH", 1, EDX, 19, &[0x0F, 0xAE, 0x3E]), // clflush [rsi]
("MMX", 1, EDX, 23, &[0x0F, 0x77]), // emms
("FXSR", 1, EDX, 24, &[0x0F, 0xAE, 0x06]), // fxsave [rsi]
("SSE", 1, EDX, 25, &[0x0F, 0x52, 0xC1]), // rsqrtps xmm0, xmm1
("SSE2", 1, EDX, 26, &[0x0F, 0xAE, 0xF0]), // mfence
("SSE3", 1, ECX, 0, &[0xF2, 0x0F, 0x7C, 0xC1]), // haddps xmm0, xmm1
(
"PCLMULQDQ",
1,
ECX,
1,
&[0x66, 0x0F, 0x3A, 0x44, 0xC1, 0x00],
), // pclmulqdq xmm0, xmm1, 0
("SSSE3", 1, ECX, 9, &[0x66, 0x0F, 0x38, 0x00, 0xC1]), // pshufb xmm0, xmm1
("FMA", 1, ECX, 12, &[0xC4, 0xE2, 0x71, 0x98, 0xC2]), // vfmadd132ps xmm0, xmm1, xmm2
("CMPXCHG16B", 1, ECX, 13, &[0x48, 0x0F, 0xC7, 0x0E]), // cmpxchg16b [rsi]
("SSE4.1", 1, ECX, 19, &[0x66, 0x0F, 0x38, 0x40, 0xC1]), // pmulld xmm0, xmm1
("SSE4.2", 1, ECX, 20, &[0xF2, 0x0F, 0x38, 0xF1, 0xC1]), // crc32 eax, ecx
("MOVBE", 1, ECX, 22, &[0x0F, 0x38, 0xF0, 0x06]), // movbe eax, [rsi]
("AESNI", 1, ECX, 25, &[0x66, 0x0F, 0x38, 0xDC, 0xC1]), // aesenc xmm0, xmm1
("XSAVE", 1, ECX, 26, &[0x0F, 0x01, 0xD0]), // xgetbv
("AVX", 1, ECX, 28, &[0xC5, 0xF4, 0x58, 0xC2]), // vaddps ymm0, ymm1, ymm2
("F16C", 1, ECX, 29, &[0xC4, 0xE2, 0x79, 0x13, 0xC1]), // vcvtph2ps xmm0, xmm1
("RDRAND", 1, ECX, 30, &[0x0F, 0xC7, 0xF0]), // rdrand eax
("BMI1", 7, EBX, 3, &[0xC4, 0xE2, 0x70, 0xF2, 0xC2]), // andn eax, ecx, edx
("AVX2", 7, EBX, 5, &[0xC5, 0xF5, 0xFE, 0xC2]), // vpaddd ymm0, ymm1, ymm2
("BMI2", 7, EBX, 8, &[0xC4, 0xE2, 0x73, 0xF6, 0xC2]), // mulx eax, ecx, edx
("RDSEED", 7, EBX, 18, &[0x0F, 0xC7, 0xF8]), // rdseed eax
("ADX", 7, EBX, 19, &[0x66, 0x0F, 0x38, 0xF6, 0xC1]), // adcx eax, ecx
("SHA", 7, EBX, 29, &[0x0F, 0x38, 0xC9, 0xC1]), // sha1msg1 xmm0, xmm1
("LAHF/SAHF", 0x8000_0001, ECX, 0, &[0x9F]), // lahf
("PREFETCHW", 0x8000_0001, ECX, 8, &[0x0F, 0x0D, 0x0E]), // prefetchw [rsi]
("SYSCALL/SYSRET", 0x8000_0001, EDX, 11, &[0x48, 0x0F, 0x07]), // sysretq
("RDTSCP", 0x8000_0001, EDX, 27, &[0x0F, 0x01, 0xF9]), // rdtscp
];
for &(feature, leaf, register, bit, code) in witnesses {
assert_eq!(
cpuid(leaf, 0)[register] >> bit & 1,
0,
"{feature} is reported"
);
let mut padded = code.to_vec();
padded.extend([0x90; 8]);
let mut cpu = CpuState::new(ENTRY, 0);
cpu.gpr[RSI] = ENTRY;
for (engine, state, exit) in both(&cpu, &padded, 1) {
assert!(
matches!(exit, ExitReason::IllegalInstruction(_)),
"{feature}: {code:02X?} ran on the {engine} ({exit:?}); report the feature only \
once all of it is implemented"
);
assert_eq!(state, cpu, "{feature} on the {engine}");
}
}
}
#[test]
fn a_guest_can_use_an_instruction_after_testing_its_feature_bit() {
// mov eax, 1
// cpuid
// bt ecx, 23 ; POPCNT
// jnc done
// popcnt rax, rsi
// done: hlt
let code = [
0xB8, 0x01, 0x00, 0x00, 0x00, 0x0F, 0xA2, 0x0F, 0xBA, 0xE1, 0x17, 0x73, 0x05, 0xF3, 0x48,
0x0F, 0xB8, 0xC6, 0xF4,
];
let mut cpu = CpuState::new(ENTRY, 0);
cpu.gpr[RSI] = 0xF0F0_0000_0000_0001;
for (engine, state, exit) in both(&cpu, &code, 16) {
assert_eq!(exit, ExitReason::Halt, "{engine}");
// Nine bits are set in RSI. Leaf 1 leaves EAX zero, so a skipped
// POPCNT would show as 0.
assert_eq!(state.gpr[RAX], 9, "{engine}");
assert_eq!(state.rip, ENTRY + code.len() as u64, "{engine}");
}
}
+1 -1
View File
@@ -95,7 +95,7 @@ def cases():
out += [f"{op} ah, bl", f"{op} cl, dh", f"{op} {mem(8)}, ch"]
out += ["mov ah, bl", "mov dl, ch", "mov bh, 0x21", "xchg ah, bl", "mov sil, dil",
"movabs r15, 0x8877665544332211", "mov rcx, -2", "bswap ebx", "bswap r9",
"cbw", "cwde", "cdqe", "cwd", "cdq", "cqo", "clc", "stc", "cmc", "nop",
"cbw", "cwde", "cdqe", "cwd", "cdq", "cqo", "clc", "stc", "cmc", "nop", "cpuid",
"nop dword ptr [rax + 8]", "pause", "push r9", "push rbx", "push -5", "push 0x12345678",
f"push {mem(64)}", "pop rbx", "pop r12", f"pop {mem(64)}", "leave"]
return list(dict.fromkeys(out))
+1
View File
@@ -1034,6 +1034,7 @@ f8 | clc
f9 | stc
f5 | cmc
90 | nop
0f a2 | cpuid
0f 1f 40 08 | nop dword ptr [rax + 8]
f3 90 | pause
41 51 | push r9
+18
View File
@@ -729,6 +729,24 @@ fn reference(m: &mut Machine, text: &str) -> Outcome {
Outcome::Done(none)
}
"nop" | "pause" => Outcome::Done(none),
"cpuid" => {
// Xenora's guest CPUID contract, restated: the vendor "Xenora guest"
// and the four features whose every instruction exists, CMOV and
// POPCNT in leaf 1, LZCNT and long mode in leaf 0x8000_0001.
let word = |text: &[u8; 4]| u32::from_le_bytes(*text);
let values = match m.gpr[RAX] as u32 {
0 => [1, word(b"Xeno"), word(b"uest"), word(b"ra g")],
1 => [0, 0, 1 << 23, 1 << 15],
0x8000_0000 => [0x8000_0001, 0, 0, 0],
0x8000_0001 => [0, 0, 1 << 5, 1 << 29],
_ => [0; 4],
};
// EAX, EBX, ECX and EDX, each zero-extended.
for (index, value) in [0, 3, 1, 2].into_iter().zip(values) {
m.gpr[index] = u64::from(value);
}
Outcome::Done(none)
}
"push" => {
m.pushed = read(m, places[0], 64) as u64;
m.gpr[4] -= 8;
+8
View File
@@ -90,6 +90,7 @@ syscall = { terminator = true, ref = "sdm SYSCALL" }
clc = { writes = "cf", ref = "sdm CLC" }
stc = { writes = "cf", ref = "sdm STC" }
cmc = { reads = "cf", writes = "cf", ref = "sdm CMC" }
cpuid = { ref = "sdm CPUID" }
# SSE and SSE2 moves and packed integer operations. None reads or writes RFLAGS.
movaps = { ref = "sdm MOVAPS" }
@@ -567,6 +568,13 @@ opcode = 0x05
enc = "none"
size = "n"
[[form]]
op = "cpuid"
map = "0f"
opcode = 0xA2
enc = "none"
size = "n"
[[form]]
op = "movzx"
map = "0f"
+22
View File
@@ -59,6 +59,28 @@ These rules hold for both engines and are what a guest scheduler has to preserve
The SDM cases for these forms in `tests/cpu_known_answers.rs` were written before this implementation, by another contributor. `tests/x86_atomic.rs` adds the LOCK rules, both compare outcomes at every width, unaligned operands and faults. None of it has been compared with x86 hardware, and nothing here establishes multi-thread behaviour.
## Guest CPUID
CPUID (`0F A2`) returns a fixed table that never reads the host. It describes a synthetic processor: the vendor string is `Xenora guest`, not Intel's or AMD's, and leaf 1 reports no family, model or stepping.
| Leaf (EAX) | EAX | EBX | ECX | EDX |
| --- | --- | --- | --- | --- |
| 0 | 1, the highest basic leaf | `Xeno` | `uest` | `ra g` |
| 1 | 0 | 0 | POPCNT (bit 23) | CMOV (bit 15) |
| 0x8000_0000 | 0x8000_0001, the highest extended leaf | 0 | 0 | 0 |
| 0x8000_0001 | 0 | 0 | LZCNT (bit 5) | long mode (bit 29) |
| any other | 0 | 0 | 0 | 0 |
A feature bit is set only when every instruction of that feature is implemented. That is stricter than "some of it works", and it has consequences:
- SSE and SSE2 are not reported, although most of their instructions exist, because parts are still rejected: RSQRTPS and MFENCE, for example. BMI1 is not reported although TZCNT exists, because ANDN does not. The x87 FPU, MMX, FXSAVE, CMPXCHG8B, the time-stamp counter, LAHF and SYSRET are absent too.
- The table is therefore truthful about Xenora, not plausible as hardware: every real 64-bit processor reports the FPU and SSE2. A guest that tests a bit before using a feature avoids it; a guest that assumes SSE2 because it runs in 64-bit mode still gets every form that exists and an illegal-instruction exit for one that does not.
- A leaf that is not listed returns zeros, whatever the subleaf. Intel processors answer a leaf above the highest basic one with that leaf's data instead; software is expected to read the highest leaf first.
`xenora_loader::cpu::cpuid` is the one copy of the table. A runtime service that reports processor features should read it rather than keep its own list.
`tests/cpu_features.rs` pins every leaf in both engines. For each reported feature it requires the feature's whole instruction set among the fixtures that `tests/x86_integer.rs` executes. For each feature software commonly tests that is not reported, it holds one instruction of that feature that both engines must refuse. To report a new feature: implement all of its instructions, remove its witness, add its instruction list to the reported set, then set the bit. The pairing of instructions with feature bits follows the Intel SDM; nothing was compared with a processor.
## Rejected on purpose
LOCK except as described above, F2 or F3 where it is neither PAUSE nor part of a declared form, F2 combined with F3, address-size overrides, an ignored segment override after FS or GS, 16-bit stack and branch forms, 16-bit BSWAP and MOVSXD, bit tests of memory by a register index, RCL, RCR, SHLD, SHRD, string instructions, MMX, the RCP and RSQRT approximations, SSE3 and later, VEX, CMPXCHG8B, CMPXCHG16B and fences. The DBT also refuses raw SYSCALL.