Skip to contentSkip to conversation

Make x86 mfence and lfence illegal without SSE2

PATCH Applied Martin Simmons 2 participants 2 messages Jun 6, 2011 – Jun 7, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make x86 mfence and lfence illegal without SSE2

Hi,

While trying to use qemu -cpu pentium3 to test for incorrect uses of certain SSE2 instructions, I found that QEMU allowed the mfence and lfence instructions to be executed even though Pentium 3 doesn't support them.

According to the processor specs (and experience on a real Pentium 3), these instructions are only available with SSE2, but QEMU is checking for SSE. The check for the related sfence instruction is correct (it works with SSE).

This trival patch fixes the test:

target-i386/translate.c +1 -1
@@ -7560,7 +7560,7 @@
             break;
         case 5: /* lfence */
         case 6: /* mfence */
-            if ((modrm & 0xc7) != 0xc0 || !(s->cpuid_features & CPUID_SSE))
+            if ((modrm & 0xc7) != 0xc0 || !(s->cpuid_features & CPUID_SSE2))
                 goto illegal_op;
             break;
         case 7: /* sfence / clflush */

__Martin

#1 lore raw
Quoted 6 lines · Martin Simmons

Hi,

While trying to use qemu -cpu pentium3 to test for incorrect uses of certain SSE2 instructions, I found that QEMU allowed the mfence and lfence instructions to be executed even though Pentium 3 doesn't support them.

Quoted 7 lines

According to the processor specs (and experience on a real Pentium 3), these instructions are only available with SSE2, but QEMU is checking for SSE. The check for the related sfence instruction is correct (it works with SSE).

This trival patch fixes the test:

Thanks, applied to the trivial patches tree:
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches

Stefan