From 16455e91dbf14e4d04e0c72cbc7bfb9ed9188e72 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 11 Apr 2020 13:53:12 +0200 Subject: [PATCH] LibX86: Don't choke on invalid LOCK prefixes for now This might be interesting information later, but I'm not sure how to encode it at the moment. --- Libraries/LibX86/Instruction.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Libraries/LibX86/Instruction.cpp b/Libraries/LibX86/Instruction.cpp index 38fefd36f2..a5b53451bd 100644 --- a/Libraries/LibX86/Instruction.cpp +++ b/Libraries/LibX86/Instruction.cpp @@ -950,12 +950,6 @@ Instruction::Instruction(InstructionStream& stream, bool o32, bool a32) return; } - if (m_has_lock_prefix && !m_descriptor->lock_prefix_allowed) { - fprintf(stderr, "Instruction not allowed with LOCK prefix, this will raise #UD\n"); - m_descriptor = nullptr; - return; - } - m_imm1_bytes = m_descriptor->imm1_bytes_for_address_size(m_a32); m_imm2_bytes = m_descriptor->imm2_bytes_for_address_size(m_a32); @@ -964,6 +958,13 @@ Instruction::Instruction(InstructionStream& stream, bool o32, bool a32) m_imm2 = stream.read(m_imm2_bytes); if (m_imm1_bytes) m_imm1 = stream.read(m_imm1_bytes); + +#ifdef DISALLOW_INVALID_LOCK_PREFIX + if (m_has_lock_prefix && !m_descriptor->lock_prefix_allowed) { + fprintf(stderr, "Instruction not allowed with LOCK prefix, this will raise #UD\n"); + m_descriptor = nullptr; + } +#endif } u32 InstructionStream::read(unsigned count)