[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-4.1-testing] x86/emulator: workaround for AMD erratum 573



# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1331108264 0
# Node ID 0bea45ab39f716d9d3d370f33ebb92a92f27e7ad
# Parent  04e5091cc08fc9a2420aa2f5f6526422097dc172
x86/emulator: workaround for AMD erratum 573

The only cases where we might end up emulating fsincos (as any other
x87 operations without memory operands) are
- when a HVM guest is in real mode (not applicable on AMD)
- between two half page table updates in PAE mode (unlikely, and not
  doing the emulation here does affect only performance, not
  correctness)
- when a guest maliciously (or erroneously) modifies an (MMIO or page
  table update) instruction under emulation (unspecified behavior)

Hence, in order to avoid the erratum to cause harm to the entire host,
don't emulate fsincos on the affected AMD CPU families.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Keir Fraser <keir@xxxxxxx>
xen-unstable changeset:   24417:1452fb248cd5
xen-unstable date:        Fri Dec 16 15:45:40 2011 +0100
---


diff -r 04e5091cc08f -r 0bea45ab39f7 tools/tests/x86_emulator/x86_emulate.c
--- a/tools/tests/x86_emulator/x86_emulate.c    Wed Mar 07 08:16:53 2012 +0000
+++ b/tools/tests/x86_emulator/x86_emulate.c    Wed Mar 07 08:17:44 2012 +0000
@@ -3,5 +3,7 @@
 #include <string.h>
 #include <public/xen.h>
 
+#define cpu_has_amd_erratum(nr) 0
+
 #include "x86_emulate/x86_emulate.h"
 #include "x86_emulate/x86_emulate.c"
diff -r 04e5091cc08f -r 0bea45ab39f7 xen/arch/x86/x86_emulate.c
--- a/xen/arch/x86/x86_emulate.c        Wed Mar 07 08:16:53 2012 +0000
+++ b/xen/arch/x86/x86_emulate.c        Wed Mar 07 08:17:44 2012 +0000
@@ -10,8 +10,14 @@
  */
 
 #include <asm/x86_emulate.h>
+#include <asm/processor.h> /* current_cpu_info */
+#include <asm/amd.h> /* cpu_has_amd_erratum() */
 
 /* Avoid namespace pollution. */
 #undef cmpxchg
+#undef cpuid
+
+#define cpu_has_amd_erratum(nr) \
+        cpu_has_amd_erratum(&current_cpu_data, AMD_ERRATUM_##nr)
 
 #include "x86_emulate/x86_emulate.c"
diff -r 04e5091cc08f -r 0bea45ab39f7 xen/arch/x86/x86_emulate/x86_emulate.c
--- a/xen/arch/x86/x86_emulate/x86_emulate.c    Wed Mar 07 08:16:53 2012 +0000
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c    Wed Mar 07 08:17:44 2012 +0000
@@ -2578,6 +2578,9 @@
     case 0xd9: /* FPU 0xd9 */
         switch ( modrm )
         {
+        case 0xfb: /* fsincos */
+            fail_if(cpu_has_amd_erratum(573));
+            /* fall through */
         case 0xc0 ... 0xc7: /* fld %stN */
         case 0xc8 ... 0xcf: /* fxch %stN */
         case 0xd0: /* fnop */
@@ -2603,7 +2606,6 @@
         case 0xf8: /* fprem */
         case 0xf9: /* fyl2xp1 */
         case 0xfa: /* fsqrt */
-        case 0xfb: /* fsincos */
         case 0xfc: /* frndint */
         case 0xfd: /* fscale */
         case 0xfe: /* fsin */
diff -r 04e5091cc08f -r 0bea45ab39f7 xen/include/asm-x86/amd.h
--- a/xen/include/asm-x86/amd.h Wed Mar 07 08:16:53 2012 +0000
+++ b/xen/include/asm-x86/amd.h Wed Mar 07 08:17:44 2012 +0000
@@ -138,6 +138,12 @@
     AMD_OSVW_ERRATUM(1, AMD_MODEL_RANGE(0xf, 0x41, 0x2, 0xff, 0xf),     \
                         AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0xff, 0xf))
 
+#define AMD_ERRATUM_573                                                        
\
+    AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x0f, 0x0, 0x0, 0xff, 0xf),     \
+                       AMD_MODEL_RANGE(0x10, 0x0, 0x0, 0xff, 0xf),     \
+                       AMD_MODEL_RANGE(0x11, 0x0, 0x0, 0xff, 0xf),     \
+                       AMD_MODEL_RANGE(0x12, 0x0, 0x0, 0xff, 0xf))
+
 struct cpuinfo_x86;
 int cpu_has_amd_erratum(const struct cpuinfo_x86 *, int, ...);
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.