Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86/x86 Mmh, check the highest leaf before calling ...



details:   https://anonhg.NetBSD.org/src/rev/8feaae5abb6d
branches:  trunk
changeset: 451726:8feaae5abb6d
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Jun 01 06:54:28 2019 +0000

description:
Mmh, check the highest leaf before calling x86_cpuid(), otherwise on old
CPUs we might be getting garbage. While here fix a typo.

Likely fixes PR/54256.

diffstat:

 sys/arch/x86/x86/spectre.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (38 lines):

diff -r 00dc7820ebd6 -r 8feaae5abb6d sys/arch/x86/x86/spectre.c
--- a/sys/arch/x86/x86/spectre.c        Sat Jun 01 05:55:45 2019 +0000
+++ b/sys/arch/x86/x86/spectre.c        Sat Jun 01 06:54:28 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spectre.c,v 1.28 2019/05/18 08:54:38 maxv Exp $        */
+/*     $NetBSD: spectre.c,v 1.29 2019/06/01 06:54:28 maxv Exp $        */
 
 /*
  * Copyright (c) 2018-2019 NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.28 2019/05/18 08:54:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.29 2019/06/01 06:54:28 maxv Exp $");
 
 #include "opt_spectre.h"
 
@@ -673,6 +673,10 @@
                return;
        }
 
+       if (cpuid_level < 7) {
+               return;
+       }
+
        x86_cpuid(0x7, descs);
        if (descs[3] & CPUID_SEF_ARCH_CAP) {
                msr = rdmsr(MSR_IA32_ARCH_CAPABILITIES);
@@ -850,7 +854,7 @@
 #endif
 
        /*
-        * Microarchectural Data Sampling.
+        * Microarchitectural Data Sampling.
         *
         * cpu0 is the one that detects the method and sets the global
         * variable.



Home | Main Index | Thread Index | Old Index