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

[Xen-changelog] [xen master] x86: improve NOP use for AMD CPUs



commit d7128e735031bde3efcde2dc4e7731f723f9ba60
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Dec 20 10:02:53 2017 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Dec 20 10:02:53 2017 +0100

    x86: improve NOP use for AMD CPUs
    
    For Fam10 and later AMD recommends using the "long" NOP forms. Re-write
    the present Intel code into switch() statements and add AMD logic.
    
    Default to "long" forms (which all 64-bit CPUs are supposed to
    recognize), overriding to the K8 flavor on those few (older) CPUs.
    
    This at the same time brings us in line again in this regard with
    current Linux.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/alternative.c | 41 +++++++++++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 14 deletions(-)

diff --git a/xen/arch/x86/alternative.c b/xen/arch/x86/alternative.c
index 65062c2..af7b42f 100644
--- a/xen/arch/x86/alternative.c
+++ b/xen/arch/x86/alternative.c
@@ -76,7 +76,7 @@ static const unsigned char * const p6_nops[ASM_NOP_MAX+1] 
init_or_livepatch_cons
 };
 #endif
 
-static const unsigned char * const *ideal_nops init_or_livepatch_data = 
k8_nops;
+static const unsigned char * const *ideal_nops init_or_livepatch_data = 
p6_nops;
 
 static int __init mask_nmi_callback(const struct cpu_user_regs *regs, int cpu)
 {
@@ -85,19 +85,32 @@ static int __init mask_nmi_callback(const struct 
cpu_user_regs *regs, int cpu)
 
 static void __init arch_init_ideal_nops(void)
 {
-    /*
-     * Due to a decoder implementation quirk, some
-     * specific Intel CPUs actually perform better with
-     * the "k8_nops" than with the SDM-recommended NOPs.
-     */
-    if ( (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) &&
-         !(boot_cpu_data.x86 == 6 &&
-           boot_cpu_data.x86_model >= 0x0f &&
-           boot_cpu_data.x86_model != 0x1c &&
-           boot_cpu_data.x86_model != 0x26 &&
-           boot_cpu_data.x86_model != 0x27 &&
-           boot_cpu_data.x86_model < 0x30) )
-        ideal_nops = p6_nops;
+    switch ( boot_cpu_data.x86_vendor )
+    {
+    case X86_VENDOR_INTEL:
+        /*
+         * Due to a decoder implementation quirk, some specific Intel CPUs
+         * actually perform better with the "k8_nops" than with the SDM-
+         * recommended NOPs.
+         */
+        if ( boot_cpu_data.x86 != 6 )
+            break;
+
+        switch ( boot_cpu_data.x86_model )
+        {
+        case 0x0f ... 0x1b:
+        case 0x1d ... 0x25:
+        case 0x28 ... 0x2f:
+            ideal_nops = k8_nops;
+            break;
+        }
+        break;
+
+    case X86_VENDOR_AMD:
+        if ( boot_cpu_data.x86 <= 0xf )
+            ideal_nops = k8_nops;
+        break;
+    }
 }
 
 /* Use this to add nops to a buffer, then text_poke the whole buffer. */
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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