From 1cb8952b14406100dcf071e13d0e2d90c58c70fb Mon Sep 17 00:00:00 2001 From: mio Date: Tue, 18 Feb 2025 12:13:24 +0800 Subject: [PATCH] Default x86 CPU model to UC_CPU_X86_HASWELL Rationale: Previouly, Unicorn uses several hacks to pretend it supports floating point instructions while not properly setting up something like CPU features. Therefore, once related registers like CR4 is reset, the hacks stop working and UC_ERR_INSN_INVALID is thrown. Setting the default model to a CPu that has basical floating point support should have the minimal break changes. --- qemu/target/i386/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu/target/i386/cpu.c b/qemu/target/i386/cpu.c index 5b735d7c..86103b09 100644 --- a/qemu/target/i386/cpu.c +++ b/qemu/target/i386/cpu.c @@ -5085,9 +5085,9 @@ X86CPU *cpu_x86_init(struct uc_struct *uc) if (uc->cpu_model == INT_MAX) { #ifdef TARGET_X86_64 - uc->cpu_model = UC_CPU_X86_QEMU64; // qemu64 + uc->cpu_model = UC_CPU_X86_HASWELL; // qemu64 #else - uc->cpu_model = UC_CPU_X86_QEMU32; // qemu32 + uc->cpu_model = UC_CPU_X86_HASWELL; // qemu32 #endif } else if (uc->cpu_model >= ARRAY_SIZE(builtin_x86_defs)) { free(cpu);