1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:47:35 +00:00

UserspaceEmulator: Recognize xor/sub zeroing idioms and don't taint

"xor reg,reg" or "sub reg,reg" both zero out the register, which means
we know for sure the result is 0. So mark the value as initialized,
and make sure we don't taint the CPU flags.

This removes some false positives from the uninitialized memory use
detection mechanism.

Fixes #2850.
This commit is contained in:
Andreas Kling 2020-07-27 13:12:17 +02:00
parent f8becd4df8
commit 31b94114c0
3 changed files with 72 additions and 38 deletions

View file

@ -950,7 +950,7 @@ private:
void generic_RM16_imm8(Op, const X86::Instruction&);
template<bool update_dest, typename Op>
void generic_RM16_unsigned_imm8(Op, const X86::Instruction&);
template<bool update_dest, typename Op>
template<bool update_dest, bool is_zero_idiom_if_both_operands_same, typename Op>
void generic_RM16_reg16(Op, const X86::Instruction&);
template<bool update_dest, typename Op>
void generic_RM32_imm32(Op, const X86::Instruction&);
@ -958,17 +958,17 @@ private:
void generic_RM32_imm8(Op, const X86::Instruction&);
template<bool update_dest, typename Op>
void generic_RM32_unsigned_imm8(Op, const X86::Instruction&);
template<bool update_dest, typename Op>
template<bool update_dest, bool is_zero_idiom_if_both_operands_same, typename Op>
void generic_RM32_reg32(Op, const X86::Instruction&);
template<bool update_dest, typename Op>
void generic_RM8_imm8(Op, const X86::Instruction&);
template<bool update_dest, typename Op>
template<bool update_dest, bool is_zero_idiom_if_both_operands_same, typename Op>
void generic_RM8_reg8(Op, const X86::Instruction&);
template<bool update_dest, typename Op>
template<bool update_dest, bool is_zero_idiom_if_both_operands_same, typename Op>
void generic_reg16_RM16(Op, const X86::Instruction&);
template<bool update_dest, typename Op>
template<bool update_dest, bool is_zero_idiom_if_both_operands_same, typename Op>
void generic_reg32_RM32(Op, const X86::Instruction&);
template<bool update_dest, typename Op>
template<bool update_dest, bool is_zero_idiom_if_both_operands_same, typename Op>
void generic_reg8_RM8(Op, const X86::Instruction&);
template<typename Op>