hypervisor: emulator: adjust iced-x86 feature flags

The fastfmt feature and VEX support use techniques that appear to leak
memory in the eye of LLVM's address sanitizer.

While at it, disable a bunch of instruction set decoding support we
never intend to support.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2025-01-02 05:38:38 +00:00 committed by Wei Liu
parent 2932658acd
commit 1180f757b3
3 changed files with 20 additions and 21 deletions

View File

@ -43,7 +43,16 @@ vmm-sys-util = { workspace = true, features = ["with-serde"] }
[target.'cfg(target_arch = "x86_64")'.dependencies.iced-x86]
default-features = false
features = ["decoder", "fast_fmt", "instr_info", "op_code_info", "std"]
features = [
"decoder",
"instr_info",
"no_d3now",
"no_evex",
"no_vex",
"no_xop",
"op_code_info",
"std",
]
optional = true
version = "1.21.0"

View File

@ -140,16 +140,3 @@ pub trait InstructionHandler<T: CpuStateManager> {
platform: &mut dyn PlatformEmulator<CpuState = T>,
) -> Result<(), EmulationError<Exception>>;
}
macro_rules! insn_format {
($insn:ident) => {{
let mut output = String::new();
let mut formatter = FastFormatter::new();
formatter
.options_mut()
.set_space_after_operand_separator(true);
formatter.format(&$insn, &mut output);
output
}};
}

View File

@ -599,8 +599,8 @@ impl<T: CpuStateManager> Emulator<'_, T> {
decoder.decode_out(&mut insn);
if decoder.last_error() != DecoderError::None {
return Err(EmulationError::InstructionFetchingError(anyhow!(
"{:#x?}",
insn_format!(insn)
"{:?}",
insn.code()
)));
}
}
@ -609,14 +609,17 @@ impl<T: CpuStateManager> Emulator<'_, T> {
Emulator::get_handler(insn.code())
.ok_or_else(|| {
EmulationError::UnsupportedInstruction(anyhow!(
"{:#x?} {:?} {:?}",
insn_format!(insn),
insn.mnemonic(),
insn.code()
"{:?} {:x?}",
insn.code(),
insn_stream
))
})?
.emulate(&insn, &mut state, self.platform)
.context(anyhow!("Failed to emulate {:#x?}", insn_format!(insn)))?;
.context(anyhow!(
"Failed to emulate {:?} {:x?}",
insn.code(),
insn_stream
))?;
last_decoded_ip = decoder.ip();
num_insn_emulated += 1;