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 PR/52266: use rdmsr_safe(9) instead of rdms...



details:   https://anonhg.NetBSD.org/src/rev/c9f14cb0cd09
branches:  trunk
changeset: 825312:c9f14cb0cd09
user:      nonaka <nonaka%NetBSD.org@localhost>
date:      Sat Jul 08 14:35:33 2017 +0000

description:
PR/52266: use rdmsr_safe(9) instead of rdmsr(9) for old machine.

tested by simonb@

diffstat:

 sys/arch/x86/x86/lapic.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (34 lines):

diff -r 5087e70ecbda -r c9f14cb0cd09 sys/arch/x86/x86/lapic.c
--- a/sys/arch/x86/x86/lapic.c  Sat Jul 08 12:37:34 2017 +0000
+++ b/sys/arch/x86/x86/lapic.c  Sat Jul 08 14:35:33 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lapic.c,v 1.58 2017/05/23 08:54:39 nonaka Exp $        */
+/*     $NetBSD: lapic.c,v 1.59 2017/07/08 14:35:33 nonaka Exp $        */
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.58 2017/05/23 08:54:39 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.59 2017/07/08 14:35:33 nonaka Exp $");
 
 #include "acpica.h"
 #include "ioapic.h"
@@ -235,10 +235,12 @@
 bool
 lapic_is_x2apic(void)
 {
-       uint64_t r;
+       uint64_t msr;
 
-       r = rdmsr(MSR_APICBASE);
-       return (r & (APICBASE_EN | APICBASE_EXTD)) == (APICBASE_EN | APICBASE_EXTD);
+       if (rdmsr_safe(MSR_APICBASE, &msr) == EFAULT)
+               return false;
+       return (msr & (APICBASE_EN | APICBASE_EXTD)) ==
+           (APICBASE_EN | APICBASE_EXTD);
 }
 
 /*



Home | Main Index | Thread Index | Old Index