diff options
author | Hendiadyoin1 <leon.a@serenityos.org> | 2022-04-06 16:31:45 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-06 18:30:22 +0200 |
commit | 7ba2e5e3e74e42d9cadee0aaec317c20e431dc2d (patch) | |
tree | f5f54957d5b102071cd8de912962d00e467b99ad /Userland/Libraries/LibX86 | |
parent | 688782efab6ac083150833d39751938b01d6417f (diff) | |
download | serenity-7ba2e5e3e74e42d9cadee0aaec317c20e431dc2d.zip |
LibX86: Add CMPXCHG8B, RDRAND and RDSEED
With this we can run following script with no errors:
```sh
for /usr/lib/*.so {
disasm "$it" > /dev/zero
}
```
Diffstat (limited to 'Userland/Libraries/LibX86')
-rw-r--r-- | Userland/Libraries/LibX86/Instruction.cpp | 23 | ||||
-rw-r--r-- | Userland/Libraries/LibX86/Instruction.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibX86/Interpreter.h | 8 |
3 files changed, 32 insertions, 1 deletions
diff --git a/Userland/Libraries/LibX86/Instruction.cpp b/Userland/Libraries/LibX86/Instruction.cpp index 34d12d12be..ed6f6767ee 100644 --- a/Userland/Libraries/LibX86/Instruction.cpp +++ b/Userland/Libraries/LibX86/Instruction.cpp @@ -153,6 +153,8 @@ static void build(InstructionDescriptor* table, u8 op, char const* mnemonic, Ins case OP_CR_reg32: case OP_reg16_RM8: case OP_reg32_RM8: + case OP_reg: + case OP_m64: case OP_mm1_rm32: case OP_rm32_mm2: case OP_mm1_mm2m64: @@ -1121,6 +1123,16 @@ static void build_sse_66_slash(u8 op, u8 slash, char const* mnemonic, Instructio build_sse_np(0xC6, "SHUFPS", OP_xmm1_xmm2m128_imm8, &Interpreter::SHUFPS_xmm1_xmm2m128_imm8); build_sse_66(0xC6, "SHUFPD", OP_xmm1_xmm2m128_imm8, &Interpreter::SHUFPD_xmm1_xmm2m128_imm8); + build_0f_slash(0xC7, 1, "CMPXCHG8B", OP_m64, &Interpreter::CMPXCHG8B_m64); + // FIXME: NP 0f c7 /2 XRSTORS[64] mem + // FIXME: NP 0F C7 / 4 XSAVEC mem + // FIXME: NP 0F C7 /5 XSAVES mem + // FIXME: VMPTRLD, VMPTRST, VMCLR, VMXON + // This is technically NFx prefixed + // FIXME: f3 0f c7 /7 RDPID + build_0f_slash(0xC7, 6, "RDRAND", OP_reg, &Interpreter::RDRAND_reg); + build_0f_slash(0xC7, 7, "RDSEED", OP_reg, &Interpreter::RDSEED_reg); + for (u8 i = 0xc8; i <= 0xcf; ++i) build_0f(i, "BSWAP", OP_reg32, &Interpreter::BSWAP_reg32); @@ -2131,6 +2143,17 @@ void Instruction::to_string_internal(StringBuilder& builder, u32 origin, SymbolP append_reg32(); append(", cl"); break; + case OP_reg: + append_mnemonic_space(); + if (m_o32) + append_reg32(); + else + append_reg16(); + break; + case OP_m64: + append_mnemonic_space(); + append_rm64(); + break; case OP_mm1_imm8: append_mnemonic_space(); append_mm_or_xmm(); diff --git a/Userland/Libraries/LibX86/Instruction.h b/Userland/Libraries/LibX86/Instruction.h index 79f9059526..1bb79cf4ca 100644 --- a/Userland/Libraries/LibX86/Instruction.h +++ b/Userland/Libraries/LibX86/Instruction.h @@ -104,6 +104,8 @@ enum InstructionFormat { OP_RM32_reg32_imm8, OP_RM16_reg16_CL, OP_RM32_reg32_CL, + OP_reg, + OP_m64, // SSE instructions mutate on some prefixes, so we have to mark them // for further parsing __SSE, diff --git a/Userland/Libraries/LibX86/Interpreter.h b/Userland/Libraries/LibX86/Interpreter.h index c8ab6c3d81..ca1cd78361 100644 --- a/Userland/Libraries/LibX86/Interpreter.h +++ b/Userland/Libraries/LibX86/Interpreter.h @@ -657,7 +657,13 @@ public: virtual void wrap_0xD3_16(Instruction const&) = 0; virtual void wrap_0xD3_32(Instruction const&) = 0; - virtual void PREFETCHTNTA(Instruction const&) = 0; + virtual void CMPXCHG8B_m64(Instruction const&) = 0; + virtual void RDRAND_reg(Instruction const&) = 0; + virtual void RDSEED_reg(Instruction const&) = 0; + + virtual void + PREFETCHTNTA(Instruction const&) + = 0; virtual void PREFETCHT0(Instruction const&) = 0; virtual void PREFETCHT1(Instruction const&) = 0; virtual void PREFETCHT2(Instruction const&) = 0; |