CVS commit: [netbsd-8] src/sys/arch/x86/x86

2021-02-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Feb 19 17:49:19 UTC 2021

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: intr.c

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #1657):

sys/arch/x86/x86/intr.c: revision 1.154 (via patch)

Fix x86's pci_intr_disestablish clean up routine.  Pointed out by t-kusaba@IIJ, 
thanks.

Fix panic on x86 by the following code.


sc_ih = pci_intr_establish_xname(sc_pc, ...);
pci_intr_disestablish(sc_pc, sc_ih);
sc_ih = pci_intr_establish(sc_pc, ...);


ena(4) do such processing when ifconfig down/up.

XXX pullup-8,9


To generate a diff of this commit:
cvs rdiff -u -r1.101.2.7 -r1.101.2.8 src/sys/arch/x86/x86/intr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/intr.c
diff -u src/sys/arch/x86/x86/intr.c:1.101.2.7 src/sys/arch/x86/x86/intr.c:1.101.2.8
--- src/sys/arch/x86/x86/intr.c:1.101.2.7	Thu Nov 14 15:58:06 2019
+++ src/sys/arch/x86/x86/intr.c	Fri Feb 19 17:49:19 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.101.2.7 2019/11/14 15:58:06 martin Exp $	*/
+/*	$NetBSD: intr.c,v 1.101.2.8 2021/02/19 17:49:19 martin Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.101.2.7 2019/11/14 15:58:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.101.2.8 2021/02/19 17:49:19 martin Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -807,6 +807,9 @@ intr_source_free(struct cpu_info *ci, in
 	ci->ci_isources[slot] = NULL;
 	if (pic != _pic)
 		idt_vec_free(idtvec);
+
+	isp->is_recurse = NULL;
+	isp->is_resume = NULL;
 }
 
 #ifdef MULTIPROCESSOR
@@ -1161,12 +1164,12 @@ intr_disestablish_xcall(void *arg1, void
 	else
 		(*pic->pic_hwunmask)(pic, ih->ih_pin);
 
-	/* Re-enable interrupts. */
-	x86_write_psl(psl);
-
 	/* If the source is free we can drop it now. */
 	intr_source_free(ci, ih->ih_slot, pic, idtvec);
 
+	/* Re-enable interrupts. */
+	x86_write_psl(psl);
+
 	DPRINTF(("%s: remove slot %d (pic %s pin %d vec %d)\n",
 	device_xname(ci->ci_dev), ih->ih_slot, pic->pic_name,
 	ih->ih_pin, idtvec));



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2020-08-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug 18 09:41:10 UTC 2020

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: ipmi.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #1597):

sys/dev/ipmi.c: revision 1.5
(applied to sys/arch/x86/x86/ipmi.c)

ipmi(4): Fixed a bug that incorrect condition is notified.

When the value obtained from the sensor is below the lower limit of
the critical threshold, it is notified that the value is below the lower
limit of the warning threshold.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.64.10.1 src/sys/arch/x86/x86/ipmi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/ipmi.c
diff -u src/sys/arch/x86/x86/ipmi.c:1.64 src/sys/arch/x86/x86/ipmi.c:1.64.10.1
--- src/sys/arch/x86/x86/ipmi.c:1.64	Thu Jul  7 06:55:40 2016
+++ src/sys/arch/x86/x86/ipmi.c	Tue Aug 18 09:41:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipmi.c,v 1.64 2016/07/07 06:55:40 msaitoh Exp $ */
+/*	$NetBSD: ipmi.c,v 1.64.10.1 2020/08/18 09:41:10 martin Exp $ */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.64 2016/07/07 06:55:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.64.10.1 2020/08/18 09:41:10 martin Exp $");
 
 #include 
 #include 
@@ -1667,14 +1667,14 @@ ipmi_sensor_status(struct ipmi_softc *sc
 		edata->value_cur > psensor->i_limits.sel_warnmax)
 			return ENVSYS_SWARNOVER;
 
-		if (psensor->i_props & PROP_WARNMIN &&
-		edata->value_cur < psensor->i_limits.sel_warnmin)
-			return ENVSYS_SWARNUNDER;
-
 		if (psensor->i_props & PROP_CRITMIN &&
 		edata->value_cur < psensor->i_limits.sel_critmin)
 			return ENVSYS_SCRITUNDER;
 
+		if (psensor->i_props & PROP_WARNMIN &&
+		edata->value_cur < psensor->i_limits.sel_warnmin)
+			return ENVSYS_SWARNUNDER;
+
 		break;
 
 	case IPMI_SENSOR_TYPE_INTRUSION:



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 17:27:48 UTC 2020

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: errata.c

Log Message:
Pull up the following, requested by msaitoh in ticket #1595:

sys/arch/x86/include/specialreg.h   1.129 via patch
sys/arch/x86/x86/errata.c   1.24-1.26

- Add six errata for AMD Family 17h (Ryzen etc), tested by
  Patrick Welche and mrg@.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.23.10.1 src/sys/arch/x86/x86/errata.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/errata.c
diff -u src/sys/arch/x86/x86/errata.c:1.23 src/sys/arch/x86/x86/errata.c:1.23.10.1
--- src/sys/arch/x86/x86/errata.c:1.23	Tue Jan  5 10:20:22 2016
+++ src/sys/arch/x86/x86/errata.c	Wed Aug  5 17:27:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: errata.c,v 1.23 2016/01/05 10:20:22 hannken Exp $	*/
+/*	$NetBSD: errata.c,v 1.23.10.1 2020/08/05 17:27:48 martin Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: errata.c,v 1.23 2016/01/05 10:20:22 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: errata.c,v 1.23.10.1 2020/08/05 17:27:48 martin Exp $");
 
 #include 
 #include 
@@ -70,8 +70,8 @@ typedef enum cpurev {
 	BH_E4, CH_CG, CH_D0, DH_CG, DH_D0, DH_E3, DH_E6, JH_E1,
 	JH_E6, SH_B0, SH_B3, SH_C0, SH_CG, SH_D0, SH_E4, SH_E5,
 	DR_BA, DR_B2, DR_B3, RB_C2, RB_C3, BL_C2, BL_C3, DA_C2,
-	DA_C3, HY_D0, HY_D1, HY_D1_G34R1,  PH_E0, LN_B0,
-	OINK
+	DA_C3, HY_D0, HY_D1, HY_D1_G34R1,  PH_E0, LN_B0, KB_A1,
+	ML_A1, ZP_B1, ZP_B2, PiR_B2, OINK
 } cpurev_t;
 
 static const u_int cpurevs[] = {
@@ -89,7 +89,9 @@ static const u_int cpurevs[] = {
 	RB_C2, 0x0100f42, RB_C3, 0x0100f43, BL_C2, 0x0100f52,
 	BL_C3, 0x0100f53, DA_C2, 0x0100f62, DA_C3, 0x0100f63,
 	HY_D0, 0x0100f80, HY_D1, 0x0100f81, HY_D1_G34R1, 0x0100f91,
-	PH_E0, 0x0100fa0, LN_B0, 0x0300f10,
+	PH_E0, 0x0100fa0, LN_B0, 0x0300f10, KB_A1, 0x0700F01,
+	ML_A1, 0x0730F01, ZP_B1, 0x0800F11, ZP_B2, 0x0800F12,
+	PiR_B2, 0x0800F82,
 	OINK
 };
 
@@ -142,6 +144,22 @@ static const uint8_t x86_errata_set11[] 
 	DA_C3, HY_D0, HY_D1, HY_D1_G34R1,  PH_E0, LN_B0, OINK
 };
 
+static const uint8_t x86_errata_set12[] = {
+	KB_A1, OINK
+};
+
+static const uint8_t x86_errata_set13[] = {
+	ZP_B1, ZP_B2, PiR_B2, OINK
+};
+
+static const uint8_t x86_errata_set14[] = {
+	ZP_B1, OINK
+};
+
+static const uint8_t x86_errata_set15[] = {
+	KB_A1, ML_A1, OINK
+};
+
 static bool x86_errata_setmsr(struct cpu_info *, errata_t *);
 static bool x86_errata_testmsr(struct cpu_info *, errata_t *);
 
@@ -285,6 +303,62 @@ static errata_t errata[] = {
 		721, FALSE, MSR_DE_CFG, x86_errata_set11,
 		x86_errata_setmsr, DE_CFG_ERRATA_721
 	},
+	/*
+	 * 776: Incorrect Processor Branch Prediction for Two Consecutive
+	 * Linear Pages
+	 */
+	{
+		776, FALSE, MSR_IC_CFG, x86_errata_set12,
+		x86_errata_setmsr, IC_CFG_ERRATA_776
+	},
+	/*
+	 * 793: Specific Combination of Writes to Write Combined Memory
+	 * Types and Locked Instructions May Cause Core Hang
+	 */
+	{
+		793, FALSE, MSR_LS_CFG, x86_errata_set15,
+		x86_errata_setmsr, LS_CFG_ERRATA_793
+	},
+	/*
+	 * 1021: Load Operation May Receive Stale Data From Older Store
+	 * Operation
+	 */
+	{
+		1021, FALSE, MSR_DE_CFG, x86_errata_set13,
+		x86_errata_setmsr, DE_CFG_ERRATA_1021
+	},
+	/*
+	 * 1033: A Lock Operation May Cause the System to Hang
+	 */
+	{
+		1033, FALSE, MSR_LS_CFG, x86_errata_set14,
+		x86_errata_setmsr, LS_CFG_ERRATA_1033
+	},
+	/*
+	 * 1049: FCMOV Instruction May Not Execute Correctly
+	 */
+	{
+		1049, FALSE, MSR_FP_CFG, x86_errata_set13,
+		x86_errata_setmsr, FP_CFG_ERRATA_1049
+	},
+#if 0	/* Should we apply this errata? The other OSes don't. */
+	/*
+	 * 1091: Address Boundary Crossing Load Operation May Receive
+	 * Stale Data
+	 */
+	{
+		1091, FALSE, MSR_LS_CFG2, x86_errata_set13,
+		x86_errata_setmsr, LS_CFG2_ERRATA_1091
+	},
+#endif
+	/*
+	 * 1095: Potential Violation of Read Ordering In Lock Operation
+	 * In SMT (Simultaneous Multithreading) Mode
+	 */
+	{
+		1095, FALSE, MSR_LS_CFG, x86_errata_set13,
+		x86_errata_setmsr, LS_CFG_ERRATA_1095
+	},
 };
 
 static bool 



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 16:05:49 UTC 2020

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: coretemp.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1589):

sys/arch/x86/x86/coretemp.c: revision 1.37

   Add special handling for model 0x0f stepping >=2 or mode 0x0e to get Tjmax.


To generate a diff of this commit:
cvs rdiff -u -r1.35.10.1 -r1.35.10.2 src/sys/arch/x86/x86/coretemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/coretemp.c
diff -u src/sys/arch/x86/x86/coretemp.c:1.35.10.1 src/sys/arch/x86/x86/coretemp.c:1.35.10.2
--- src/sys/arch/x86/x86/coretemp.c:1.35.10.1	Thu Jul 26 23:23:50 2018
+++ src/sys/arch/x86/x86/coretemp.c	Wed Aug  5 16:05:49 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: coretemp.c,v 1.35.10.1 2018/07/26 23:23:50 snj Exp $ */
+/* $NetBSD: coretemp.c,v 1.35.10.2 2020/08/05 16:05:49 martin Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: coretemp.c,v 1.35.10.1 2018/07/26 23:23:50 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coretemp.c,v 1.35.10.2 2020/08/05 16:05:49 martin Exp $");
 
 #include 
 #include 
@@ -271,6 +271,19 @@ coretemp_tjmax(device_t self)
 	sc->sc_tjmax = 100;
 
 	if ((model == 0x0f && stepping >= 2) || (model == 0x0e)) {
+		/*
+		 * Check MSR_IA32_PLATFORM_ID(0x17) bit 28. It's not documented
+		 * in the datasheet, but the following page describes the
+		 * detail:
+		 *   http://software.intel.com/en-us/articles/
+		 * mobile-intel-core2-processor-detection-table/
+		 *   Was: http://softwarecommunity.intel.com/Wiki/Mobility/
+		 * 720.htm
+		 */
+		if (rdmsr_safe(MSR_IA32_PLATFORM_ID, ) != 0)
+			goto notee;
+		if ((model < 0x17) && ((msr & __BIT(28)) == 0))
+			goto notee;
 
 		if (rdmsr_safe(MSR_IA32_EXT_CONFIG, ) == EFAULT)
 			return;
@@ -290,6 +303,7 @@ coretemp_tjmax(device_t self)
 		} else
 			sc->sc_tjmax = 90;
 	} else {
+notee:
 		/*
 		 * Attempt to get Tj(max) from IA32_TEMPERATURE_TARGET,
 		 * but only consider the interval [70, 110] C as valid.



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2020-07-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 20 18:40:09 UTC 2020

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: procfs_machdep.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1581):

sys/arch/x86/x86/procfs_machdep.c: revision 1.37
sys/arch/x86/x86/procfs_machdep.c: revision 1.38

  Add AMD protected processor identification number (PPIN).

  Lowercase ppin.


To generate a diff of this commit:
cvs rdiff -u -r1.15.2.10 -r1.15.2.11 src/sys/arch/x86/x86/procfs_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/procfs_machdep.c
diff -u src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.10 src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.11
--- src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.10	Wed Apr 15 14:25:09 2020
+++ src/sys/arch/x86/x86/procfs_machdep.c	Mon Jul 20 18:40:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.15.2.10 2020/04/15 14:25:09 martin Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.15.2.11 2020/07/20 18:40:08 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.10 2020/04/15 14:25:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.11 2020/07/20 18:40:08 martin Exp $");
 
 #include 
 #include 
@@ -155,7 +155,7 @@ static const char * const x86_features[]
 	{ /* (13) AMD 0x8008 ebx */
 	"clzero", "irperf", "xsaveerptr", NULL, "rdpru", NULL, NULL, NULL,
 	NULL, "wbnoinvd", NULL, NULL, NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, "ppin",
 	NULL, "virt_ssbd", NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (14) 0x0006 eax */



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2020-06-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jun 20 16:05:06 UTC 2020

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: cpu_rng.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1560):

sys/arch/x86/x86/cpu_rng.c: revision 1.16

Use x86_read_psl/x86_disable_intr/x86_read_psl to defer interrupts.

Using x86_disable_intr/x86_enable_intr causes a bit of a snag when we
try it early at boot before we're ready to handle interrupts, because
it has the effect of enabling interrupts!

Fixes instant reset at boot on VIA CPUs.  The instant reset on boot
is new since the entropy rework, which initialized the x86 CPU RNG
earlier than before, but in principle this could also cause other
problems while not early at boot too.

XXX pullup


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.5.12.1 src/sys/arch/x86/x86/cpu_rng.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/cpu_rng.c
diff -u src/sys/arch/x86/x86/cpu_rng.c:1.5 src/sys/arch/x86/x86/cpu_rng.c:1.5.12.1
--- src/sys/arch/x86/x86/cpu_rng.c:1.5	Mon Feb 29 00:17:54 2016
+++ src/sys/arch/x86/x86/cpu_rng.c	Sat Jun 20 16:05:06 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_rng.c,v 1.5 2016/02/29 00:17:54 riastradh Exp $ */
+/* $NetBSD: cpu_rng.c,v 1.5.12.1 2020/06/20 16:05:06 martin Exp $ */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -136,6 +136,7 @@ exhausted:
 static size_t
 cpu_rng_via(cpu_rng_t *out)
 {
+	u_long psl;
 	uint32_t creg0, rndsts;
 
 	/*
@@ -149,9 +150,9 @@ cpu_rng_via(cpu_rng_t *out)
 	 * even if such a fault is generated.
 	 *
 	 * XXX can this really happen if we don't use "rep xstorrng"?
-	 *
 	 */
 	kpreempt_disable();
+	psl = x86_read_psl();
 	x86_disable_intr();
 	creg0 = rcr0();
 	lcr0(creg0 & ~(CR0_EM|CR0_TS)); /* Permit access to SIMD/FPU path */
@@ -165,7 +166,7 @@ cpu_rng_via(cpu_rng_t *out)
 	: "=a" (rndsts), "+D" (out) : "d" (0) : "memory");
 	/* Put CR0 back how it was */
 	lcr0(creg0);
-	x86_enable_intr();
+	x86_write_psl(psl);
 	kpreempt_enable();
 
 	/*



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2020-01-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jan 21 16:47:24 UTC 2020

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: cpu.c

Log Message:
Pull up following revision(s) (requested by pgoyette in ticket #1483):

sys/arch/x86/x86/cpu.c: revision 1.181

If "application processors" were skipped/disabled at boot time (due to
RB_MD1 being set), don't try to examine the featurebus info, since it
was never retrieved.  Addresses kern/54815

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.130.2.8 -r1.130.2.9 src/sys/arch/x86/x86/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.130.2.8 src/sys/arch/x86/x86/cpu.c:1.130.2.9
--- src/sys/arch/x86/x86/cpu.c:1.130.2.8	Sat Mar  9 17:10:19 2019
+++ src/sys/arch/x86/x86/cpu.c	Tue Jan 21 16:47:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.130.2.8 2019/03/09 17:10:19 martin Exp $	*/
+/*	$NetBSD: cpu.c,v 1.130.2.9 2020/01/21 16:47:24 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.130.2.8 2019/03/09 17:10:19 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.130.2.9 2020/01/21 16:47:24 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -535,6 +535,16 @@ cpu_rescan(device_t self, const char *if
 	struct cpufeature_attach_args cfaa;
 	struct cpu_info *ci = sc->sc_info;
 
+	/*
+	 * If we booted with RB_MD1 to disable multiprocessor, the
+	 * auto-configuration data still contains the additional
+	 * CPUs.   But their initialization was mostly bypassed
+	 * during attach, so we have to make sure we don't look at
+	 * their featurebus info, since it wasn't retrieved.
+	 */
+	if (ci == NULL)
+		return 0;
+
 	memset(, 0, sizeof(cfaa));
 	cfaa.ci = ci;
 



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2019-03-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Mar  7 17:01:18 UTC 2019

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: procfs_machdep.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1204):

sys/arch/x86/x86/procfs_machdep.c: revision 1.28

- Add wbnoinvd, virt_ssbd, tme, cldemote, movdiri, movdir64b and pconfig.
- Move AMD 0x8008 ebx's ibpb, ibrs and stibp to x86_features[8] linux
   mapping.


To generate a diff of this commit:
cvs rdiff -u -r1.15.2.7 -r1.15.2.8 src/sys/arch/x86/x86/procfs_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/procfs_machdep.c
diff -u src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.7 src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.8
--- src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.7	Sun Nov 18 11:16:52 2018
+++ src/sys/arch/x86/x86/procfs_machdep.c	Thu Mar  7 17:01:18 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.15.2.7 2018/11/18 11:16:52 martin Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.15.2.8 2019/03/07 17:01:18 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.7 2018/11/18 11:16:52 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.8 2019/03/07 17:01:18 martin Exp $");
 
 #include 
 #include 
@@ -115,14 +115,14 @@ static const char * const x86_features[]
 	"hw_pstate", "proc_feedback", "sme", NULL,
 	NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+	NULL, "ibrs", "ibpb", "stibp", NULL, NULL, NULL, NULL},
 
 	{ /* (8) Linux mapping */
 	"tpr_shadow", "vnmi", "flexpriority", "ept",
 	"vpid", "npt", "lbrv", "svm_lock",
 	"nrip_save", "tsc_scale", "vmcb_clean", "flushbyasid",
 	"decodeassists", "pausefilter", "pfthreshold", "vmmcall",
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	NULL, "ept_ad", NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (9) Intel-defined: 0007 ebx */
@@ -153,9 +153,9 @@ static const char * const x86_features[]
 
 	{ /* (13) AMD 0x8008 ebx */
 	"clzero", "irperf", "xsaveerptr", NULL, NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL, "ibpb", NULL, "ibrs", "stibp",
+	NULL, "wbnoinvd", NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+	NULL, "virt_ssbd", NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (14) 0x0006 eax */
 	"dtherm", "ida", "arat", NULL, "pln", NULL, "pts", "hwp",
@@ -176,9 +176,9 @@ static const char * const x86_features[]
 	NULL, "avx512vbmi", "umip", "pku",
 	"ospke", NULL, "avx512_vbmi2", NULL,
 	"gfni", "vaes", "vpclmulqdq", "avx512_vnni",
-	"avx512_bitalg", NULL, "avx512_vpopcntdq", NULL,
+	"avx512_bitalg", "tme", "avx512_vpopcntdq", NULL,
 	"la57", NULL, NULL, NULL, NULL, NULL, "rdpid", NULL,
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+	NULL, "cldemote", NULL, "movdiri", "movdir64b", NULL, NULL, NULL},
 
 	{ /* (17) 0x8007 ebx */
 	"overflow_recov", "succor", NULL, "smca", NULL, NULL, NULL, NULL,
@@ -189,7 +189,7 @@ static const char * const x86_features[]
 	{ /* (18) Intel 0x0007 edx */
 	NULL, NULL, "avx512_4vnniw", "avx512_4fmaps", NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	NULL, NULL, "pconfig", NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL,
 	"flush_l1d", "arch_capabilities", NULL, "ssbd"},
 };



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2018-11-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Nov 18 11:16:52 UTC 2018

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: procfs_machdep.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1094):

sys/arch/x86/x86/procfs_machdep.c: revision 1.25

- I misread ci_acpiid as ci_apicid... LAPIC ID is in ci_cpuid.
   Print it correctly.

- ci_initapicid(Initial APIC ID) is uint32_t, so use %u.


To generate a diff of this commit:
cvs rdiff -u -r1.15.2.6 -r1.15.2.7 src/sys/arch/x86/x86/procfs_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/procfs_machdep.c
diff -u src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.6 src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.7
--- src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.6	Sun Sep 23 17:35:33 2018
+++ src/sys/arch/x86/x86/procfs_machdep.c	Sun Nov 18 11:16:52 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.15.2.6 2018/09/23 17:35:33 martin Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.15.2.7 2018/11/18 11:16:52 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.6 2018/09/23 17:35:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.7 2018/11/18 11:16:52 martin Exp $");
 
 #include 
 #include 
@@ -421,9 +421,9 @@ procfs_getonecpu(int xcpu, struct cpu_in
 		left = 0;
 
 	l = snprintf(p, left,
-	"apicid\t\t: %d\n"
-	"initial apicid\t: %d\n",
-	ci->ci_acpiid,
+	"apicid\t\t: %lu\n"
+	"initial apicid\t: %u\n",
+	ci->ci_cpuid,
 	ci->ci_initapicid
 	);
 	size += l;



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2018-08-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug  7 13:28:59 UTC 2018

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: cpu.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #960):

sys/arch/x86/x86/cpu.c: revision 1.159

Oh. Don't call svs_pdir_switch if SVS is disabled, that's not needed.

I was playing around with PMCs, and was wondering why some cache misses
were occurring in svs_pdir_switch while I had SVS disabled.


To generate a diff of this commit:
cvs rdiff -u -r1.130.2.6 -r1.130.2.7 src/sys/arch/x86/x86/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.130.2.6 src/sys/arch/x86/x86/cpu.c:1.130.2.7
--- src/sys/arch/x86/x86/cpu.c:1.130.2.6	Sat Apr 14 10:11:49 2018
+++ src/sys/arch/x86/x86/cpu.c	Tue Aug  7 13:28:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.130.2.6 2018/04/14 10:11:49 martin Exp $	*/
+/*	$NetBSD: cpu.c,v 1.130.2.7 2018/08/07 13:28:59 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.130.2.6 2018/04/14 10:11:49 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.130.2.7 2018/08/07 13:28:59 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -1265,7 +1265,9 @@ void
 cpu_load_pmap(struct pmap *pmap, struct pmap *oldpmap)
 {
 #ifdef SVS
-	svs_pdir_switch(pmap);
+	if (svs_enabled) {
+		svs_pdir_switch(pmap);
+	}
 #endif
 
 #ifdef PAE



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2018-07-26 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Jul 26 23:23:50 UTC 2018

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: coretemp.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #936):
sys/arch/x86/x86/coretemp.c: revision 1.36
- Detect and set Atom's Tj(max) to 90 if it's not the 45nm D400/D500/N400
   series (90 for Diamondville and 100 for Pineview). From FreeBSD r221509.
- Reduce diff a little against FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.35.10.1 src/sys/arch/x86/x86/coretemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/coretemp.c
diff -u src/sys/arch/x86/x86/coretemp.c:1.35 src/sys/arch/x86/x86/coretemp.c:1.35.10.1
--- src/sys/arch/x86/x86/coretemp.c:1.35	Thu Jul  7 06:55:40 2016
+++ src/sys/arch/x86/x86/coretemp.c	Thu Jul 26 23:23:50 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: coretemp.c,v 1.35 2016/07/07 06:55:40 msaitoh Exp $ */
+/* $NetBSD: coretemp.c,v 1.35.10.1 2018/07/26 23:23:50 snj Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: coretemp.c,v 1.35 2016/07/07 06:55:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coretemp.c,v 1.35.10.1 2018/07/26 23:23:50 snj Exp $");
 
 #include 
 #include 
@@ -265,14 +265,12 @@ coretemp_tjmax(device_t self)
 	model = CPUID_TO_MODEL(ci->ci_signature);
 	stepping = CPUID_TO_STEPPING(ci->ci_signature);
 
-	sc->sc_tjmax = 100;
-
 	/*
-	 * On some Core 2 CPUs, there is an undocumented
-	 * MSR that tells if Tj(max) is 100 or 85. Note
-	 * that MSR_IA32_EXT_CONFIG is not safe on all CPUs.
+	 * Use 100C as the initial value.
 	 */
-	if ((model == 0x0F && stepping >= 2) || (model == 0x0E)) {
+	sc->sc_tjmax = 100;
+
+	if ((model == 0x0f && stepping >= 2) || (model == 0x0e)) {
 
 		if (rdmsr_safe(MSR_IA32_EXT_CONFIG, ) == EFAULT)
 			return;
@@ -285,6 +283,12 @@ coretemp_tjmax(device_t self)
 		/* The mobile Penryn family. */
 		sc->sc_tjmax = 105;
 		return;
+	} else if (model == 0x1c) {
+		if (stepping == 0x0a) {
+			/* 45nm Atom D400, N400 and D500 series */
+			sc->sc_tjmax = 100;
+		} else
+			sc->sc_tjmax = 90;
 	} else {
 		/*
 		 * Attempt to get Tj(max) from IA32_TEMPERATURE_TARGET,



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2018-06-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jun  9 15:14:49 UTC 2018

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: procfs_machdep.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #867):

sys/arch/x86/x86/procfs_machdep.c: revision 1.23

Add SSBD bit for Intel.


To generate a diff of this commit:
cvs rdiff -u -r1.15.2.4 -r1.15.2.5 src/sys/arch/x86/x86/procfs_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/procfs_machdep.c
diff -u src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.4 src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.5
--- src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.4	Fri Mar 16 13:08:14 2018
+++ src/sys/arch/x86/x86/procfs_machdep.c	Sat Jun  9 15:14:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.15.2.4 2018/03/16 13:08:14 martin Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.15.2.5 2018/06/09 15:14:49 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.4 2018/03/16 13:08:14 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.5 2018/06/09 15:14:49 martin Exp $");
 
 #include 
 #include 
@@ -190,7 +190,7 @@ static const char * const x86_features[]
 	NULL, NULL, "avx512_4vnniw", "avx512_4fmaps", NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL, NULL, "arch_capabilities", NULL, NULL},
+	NULL, NULL, NULL, NULL, NULL, "arch_capabilities", NULL, "ssbd"},
 };
 
 static int	procfs_getonecpu(int, struct cpu_info *, char *, size_t *);



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2018-04-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 12 13:08:16 UTC 2018

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: dbregs.c

Log Message:
Pull up following revision(s) (requested by kamil in ticket #712):

sys/arch/x86/x86/dbregs.c: revision 1.7-1.9

Fix the check, should be >=.

Hum, don't let userland set bit 13, because this can crash the kernel.

Add paranoid code to X86 Debug Registers

Reset certain bits in DR6 and DR7 in x86_dbregs_setup_initdbstate().
Reset X86_BREAKPOINT_CONDITION_DETECTED in DR6.
Reset X86_DR7_GENERAL_DETECT_ENABLE in DR7.

It's allowed by devices or software before the kernel boot, to
use these registers for their own purposes. Handle this paranoid case
explicitly setting the mentioned bits to zero.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.6.1 src/sys/arch/x86/x86/dbregs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/dbregs.c
diff -u src/sys/arch/x86/x86/dbregs.c:1.6 src/sys/arch/x86/x86/dbregs.c:1.6.6.1
--- src/sys/arch/x86/x86/dbregs.c:1.6	Thu Feb 23 12:01:12 2017
+++ src/sys/arch/x86/x86/dbregs.c	Thu Apr 12 13:08:16 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: dbregs.c,v 1.6 2017/02/23 12:01:12 martin Exp $	*/
+/*	$NetBSD: dbregs.c,v 1.6.6.1 2018/04/12 13:08:16 martin Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -43,6 +43,18 @@ extern struct pool x86_dbregspl;
 
 static struct dbreg initdbstate;
 
+#define X86_BREAKPOINT_CONDITION_DETECTED	( \
+	X86_DR6_DR0_BREAKPOINT_CONDITION_DETECTED | \
+	X86_DR6_DR1_BREAKPOINT_CONDITION_DETECTED | \
+	X86_DR6_DR2_BREAKPOINT_CONDITION_DETECTED | \
+	X86_DR6_DR3_BREAKPOINT_CONDITION_DETECTED )
+
+#define X86_GLOBAL_BREAKPOINT	( \
+	X86_DR7_GLOBAL_DR0_BREAKPOINT | \
+	X86_DR7_GLOBAL_DR1_BREAKPOINT | \
+	X86_DR7_GLOBAL_DR2_BREAKPOINT | \
+	X86_DR7_GLOBAL_DR3_BREAKPOINT )
+
 void
 x86_dbregs_setup_initdbstate(void)
 {
@@ -56,19 +68,17 @@ x86_dbregs_setup_initdbstate(void)
 	initdbstate.dr[6] = rdr6();
 	initdbstate.dr[7] = rdr7();
 	/* DR8-DR15 are reserved - skip */
-}
 
-#define X86_BREAKPOINT_CONDITION_DETECTED	( \
-	X86_DR6_DR0_BREAKPOINT_CONDITION_DETECTED | \
-	X86_DR6_DR1_BREAKPOINT_CONDITION_DETECTED | \
-	X86_DR6_DR2_BREAKPOINT_CONDITION_DETECTED | \
-	X86_DR6_DR3_BREAKPOINT_CONDITION_DETECTED )
+	/*
+	 * Paranoid case.
+	 *
+	 * Explicitly reset some bits just in case they could be
+	 * set by brave software/hardware before the kernel boot.
+	 */
+	initdbstate.dr[6] &= ~X86_BREAKPOINT_CONDITION_DETECTED;
 
-#define X86_GLOBAL_BREAKPOINT	( \
-	X86_DR7_GLOBAL_DR0_BREAKPOINT | \
-	X86_DR7_GLOBAL_DR1_BREAKPOINT | \
-	X86_DR7_GLOBAL_DR2_BREAKPOINT | \
-	X86_DR7_GLOBAL_DR3_BREAKPOINT )
+	initdbstate.dr[7] &= ~X86_DR7_GENERAL_DETECT_ENABLE;
+}
 
 void
 x86_dbregs_clear(struct lwp *l)
@@ -188,14 +198,14 @@ x86_dbregs_validate(const struct dbreg *
 
 	/* Check that DR0-DR3 contain user-space address */
 	for (i = 0; i < X86_DBREGS; i++)
-		if (regs->dr[i] > (vaddr_t)VM_MAXUSER_ADDRESS)
+		if (regs->dr[i] >= (vaddr_t)VM_MAXUSER_ADDRESS)
 			return EINVAL;
 
+	if (regs->dr[7] & X86_DR7_GENERAL_DETECT_ENABLE)
+		return EINVAL;
+
 	/*
 	 * Skip checks for reserved registers (DR4-DR5, DR8-DR15).
-	 *
-	 * Don't validate DR6-DR7 as some bits are set by hardware and a user
-	 * cannot overwrite them.
 	 */
 
 	return 0;



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2018-04-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr  9 18:12:50 UTC 2018

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: cpu_topology.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #717):

sys/arch/x86/x86/cpu_topology.c: revision 1.11-1.13

Check for undefined behaviour when doing right-shift.

CPUID tells the ApicIdCoreIdSize in bits.

Compute Core/SMT-IDs for AMD family 17h (Ryzen).


To generate a diff of this commit:
cvs rdiff -u -r1.9.22.1 -r1.9.22.2 src/sys/arch/x86/x86/cpu_topology.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/cpu_topology.c
diff -u src/sys/arch/x86/x86/cpu_topology.c:1.9.22.1 src/sys/arch/x86/x86/cpu_topology.c:1.9.22.2
--- src/sys/arch/x86/x86/cpu_topology.c:1.9.22.1	Tue Nov 21 15:03:20 2017
+++ src/sys/arch/x86/x86/cpu_topology.c	Mon Apr  9 18:12:50 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_topology.c,v 1.9.22.1 2017/11/21 15:03:20 martin Exp $	*/
+/*	$NetBSD: cpu_topology.c,v 1.9.22.2 2018/04/09 18:12:50 martin Exp $	*/
 
 /*-
  * Copyright (c) 2009 Mindaugas Rasiukevicius ,
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.9.22.1 2017/11/21 15:03:20 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.9.22.2 2018/04/09 18:12:50 martin Exp $");
 
 #include 
 #include 
@@ -108,6 +108,7 @@ x86_cpu_topology(struct cpu_info *ci)
 			core_max = lp_max;
 			break;
 		}
+
 		/* Number of Cores (NC) per package (ecx[7:0]). */
 		x86_cpuid(0x8008, descs);
 		core_max = (descs[2] & 0xff) + 1;
@@ -116,9 +117,9 @@ x86_cpu_topology(struct cpu_info *ci)
 		if (n != 0) {
 			/*
 			 * Extended Method.
-			 * core_bits = 2 ^ n (power of two)
+			 * core_max = 2 ^ n (power of two)
 			 */
-			core_bits = 1 << n;
+			core_bits = n;
 		}
 		break;
 	default:
@@ -150,8 +151,21 @@ x86_cpu_topology(struct cpu_info *ci)
 		}
 	}
 
+	/* Family 0x17 supports SMT */
+	if (cpu_vendor == CPUVENDOR_AMD && cpu_family == 0x17) { /* XXX */
+		x86_cpuid(0x801e, descs);
+		const u_int threads = ((descs[1] >> 8) & 0xff) + 1;
+
+		KASSERT(smt_bits == 0 && smt_bits <= core_bits);
+		smt_bits = ilog2(threads);
+		core_bits -= smt_bits;
+	}
+
 	if (smt_bits + core_bits) {
-		ci->ci_package_id = apic_id >> (smt_bits + core_bits);
+		if (smt_bits + core_bits < sizeof(apic_id) * NBBY)
+			ci->ci_package_id = apic_id >> (smt_bits + core_bits);
+		else
+			ci->ci_package_id = 0;
 	}
 	if (core_bits) {
 		u_int core_mask = __BITS(smt_bits, smt_bits + core_bits - 1);



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2018-04-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr  2 08:43:58 UTC 2018

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: svs.c

Log Message:
Pull up the following revisions, requested by maxv in ticket #683:

sys/arch/x86/x86/svs.c  1.15-1.17

Fix sysctl type, should be bool.

Use EOPNOTSUPP instead of EINVAL.

Improve the detection. Future generations of Intel CPUs will have a bit to
say they are not affected by Meltdown.


To generate a diff of this commit:
cvs rdiff -u -r1.14.2.2 -r1.14.2.3 src/sys/arch/x86/x86/svs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/svs.c
diff -u src/sys/arch/x86/x86/svs.c:1.14.2.2 src/sys/arch/x86/x86/svs.c:1.14.2.3
--- src/sys/arch/x86/x86/svs.c:1.14.2.2	Thu Mar 22 16:59:04 2018
+++ src/sys/arch/x86/x86/svs.c	Mon Apr  2 08:43:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: svs.c,v 1.14.2.2 2018/03/22 16:59:04 martin Exp $	*/
+/*	$NetBSD: svs.c,v 1.14.2.3 2018/04/02 08:43:58 martin Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.14.2.2 2018/03/22 16:59:04 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.14.2.3 2018/04/02 08:43:58 martin Exp $");
 
 #include "opt_svs.h"
 
@@ -720,9 +720,10 @@ int
 sysctl_machdep_svs_enabled(SYSCTLFN_ARGS)
 {
 	struct sysctlnode node;
-	int error, val;
+	int error;
+	bool val;
 
-	val = *(int *)rnode->sysctl_data;
+	val = *(bool *)rnode->sysctl_data;
 
 	node = *rnode;
 	node.sysctl_data = 
@@ -732,7 +733,10 @@ sysctl_machdep_svs_enabled(SYSCTLFN_ARGS
 		return error;
 
 	if (val == 1) {
-		error = EINVAL;
+		if (svs_enabled)
+			error = 0;
+		else
+			error = EOPNOTSUPP;
 	} else {
 		if (svs_enabled)
 			error = svs_disable();
@@ -746,8 +750,21 @@ sysctl_machdep_svs_enabled(SYSCTLFN_ARGS
 void
 svs_init(void)
 {
+	uint64_t msr;
+
 	if (cpu_vendor != CPUVENDOR_INTEL) {
 		return;
 	}
+	if (cpu_info_primary.ci_feat_val[7] & CPUID_SEF_ARCH_CAP) {
+		msr = rdmsr(MSR_IA32_ARCH_CAPABILITIES);
+		if (msr & IA32_ARCH_RDCL_NO) {
+			/*
+			 * The processor indicates it is not vulnerable to the
+			 * Rogue Data Cache Load (Meltdown) flaw.
+			 */
+			return;
+		}
+	}
+
 	svs_enable();
 }



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2018-03-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar 26 11:19:39 UTC 2018

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: intr.c

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #658):
sys/arch/x86/x86/intr.c: revision 1.124
Fix "intrctl list" causes panic while attaching MSI/MSI-X devices.
When there are devices which is already pci_intr_alloc'ed, however is not
established yet, "intrctl list" causes panic. E.g.
# while true; do intrctl list > /dev/null ; done&
# drvctl -d ixg0 && drvctl -r pci0
And add some KASSERTMSG to similar but not the same code.
Pointed out by msaitoh@n.o.
XXX pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.101.2.3 -r1.101.2.4 src/sys/arch/x86/x86/intr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/intr.c
diff -u src/sys/arch/x86/x86/intr.c:1.101.2.3 src/sys/arch/x86/x86/intr.c:1.101.2.4
--- src/sys/arch/x86/x86/intr.c:1.101.2.3	Fri Mar 16 13:17:56 2018
+++ src/sys/arch/x86/x86/intr.c	Mon Mar 26 11:19:39 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.101.2.3 2018/03/16 13:17:56 martin Exp $	*/
+/*	$NetBSD: intr.c,v 1.101.2.4 2018/03/26 11:19:39 martin Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.101.2.3 2018/03/16 13:17:56 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.101.2.4 2018/03/26 11:19:39 martin Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -1839,6 +1839,9 @@ intr_get_affinity(struct intrsource *isp
 		return;
 	}
 
+	KASSERTMSG(isp->is_handlers != NULL,
+	"Don't get affinity for the device which is not established.");
+
 	ci = isp->is_handlers->ih_cpu;
 	if (ci == NULL) {
 		kcpuset_zero(cpuset);
@@ -1891,6 +1894,9 @@ intr_set_affinity(struct intrsource *isp
 	}
 
 	ih = isp->is_handlers;
+	KASSERTMSG(ih != NULL,
+	"Don't set affinity for the device which is not established.");
+
 	oldci = ih->ih_cpu;
 	if (newci == oldci) /* nothing to do */
 		return 0;
@@ -1957,6 +1963,13 @@ intr_is_affinity_intrsource(struct intrs
 
 	KASSERT(mutex_owned(_lock));
 
+	/*
+	 * The device is already pci_intr_alloc'ed, however it is not
+	 * established yet.
+	 */
+	if (isp->is_handlers == NULL)
+		return false;
+
 	ci = isp->is_handlers->ih_cpu;
 	KASSERT(ci != NULL);
 



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2018-03-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Mar 16 13:08:14 UTC 2018

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: procfs_machdep.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #634):
sys/arch/x86/x86/procfs_machdep.c: revision 1.22
- Add AMD CPUID leaf 0x8008 ebx's xsaveerptr, ibpb, ibrs, stibp.
- Add Intel CPUID leaf 7 ebx's umip, avx512_vbmi2, gfni, vaes, vpclmulqdq,
   avx512_vnni and avx512_bitalg.
- Add Intel CPUID leaf 7 edx's avx512_4vnniw, avx512_4fmaps and
   arch_capabilities.


To generate a diff of this commit:
cvs rdiff -u -r1.15.2.3 -r1.15.2.4 src/sys/arch/x86/x86/procfs_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/procfs_machdep.c
diff -u src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.3 src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.4
--- src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.3	Sat Jan 13 21:44:20 2018
+++ src/sys/arch/x86/x86/procfs_machdep.c	Fri Mar 16 13:08:14 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.15.2.3 2018/01/13 21:44:20 snj Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.15.2.4 2018/03/16 13:08:14 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.3 2018/01/13 21:44:20 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.4 2018/03/16 13:08:14 martin Exp $");
 
 #include 
 #include 
@@ -151,9 +151,9 @@ static const char * const x86_features[]
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
-	{ /* (13) 0x8008 ebx */
-	"clzero", "irperf", NULL, NULL, NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	{ /* (13) AMD 0x8008 ebx */
+	"clzero", "irperf", "xsaveerptr", NULL, NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, "ibpb", NULL, "ibrs", "stibp",
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
@@ -173,8 +173,10 @@ static const char * const x86_features[]
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (16) 0x0007:0 ecx */
-	NULL, "avx512vbmi", NULL, "pku", "ospke", NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL, NULL, NULL, "avx512_vpopcntdq", NULL,
+	NULL, "avx512vbmi", "umip", "pku",
+	"ospke", NULL, "avx512_vbmi2", NULL,
+	"gfni", "vaes", "vpclmulqdq", "avx512_vnni",
+	"avx512_bitalg", NULL, "avx512_vpopcntdq", NULL,
 	"la57", NULL, NULL, NULL, NULL, NULL, "rdpid", NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
@@ -183,6 +185,12 @@ static const char * const x86_features[]
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+
+	{ /* (18) Intel 0x0007 edx */
+	NULL, NULL, "avx512_4vnniw", "avx512_4fmaps", NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL, "arch_capabilities", NULL, NULL},
 };
 
 static int	procfs_getonecpu(int, struct cpu_info *, char *, size_t *);
@@ -336,6 +344,14 @@ procfs_getonecpufeatures(struct cpu_info
 		diff = last - *left;
 	}
 
+	if ((cpu_vendor == CPUVENDOR_INTEL)
+	&& (ci->ci_max_cpuid >= 0x0007)) {
+		x86_cpuid(0x0007, descs);
+		procfs_getonefeatreg(descs[3], x86_features[18], p + diff,
+		left);
+		diff = last - *left;
+	}
+
 	return 0; /* XXX */
 }
 



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2018-03-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Mar  6 08:45:59 UTC 2018

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: pmap.c

Log Message:
Also pull up r1.267, requested by mrg in ticket #593: avoid a NULL pointer
deref and simplify.


To generate a diff of this commit:
cvs rdiff -u -r1.245.6.2 -r1.245.6.3 src/sys/arch/x86/x86/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.245.6.2 src/sys/arch/x86/x86/pmap.c:1.245.6.3
--- src/sys/arch/x86/x86/pmap.c:1.245.6.2	Tue Feb 27 09:07:33 2018
+++ src/sys/arch/x86/x86/pmap.c	Tue Mar  6 08:45:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.245.6.2 2018/02/27 09:07:33 martin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.245.6.3 2018/03/06 08:45:59 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.245.6.2 2018/02/27 09:07:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.245.6.3 2018/03/06 08:45:59 martin Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -1737,8 +1737,8 @@ pmap_pp_needs_pve(struct pmap_page *pp)
 	 * since the first pv entry is stored in the pmap_page.
 	 */
 
-	return (pp->pp_flags & PP_EMBEDDED) != 0 ||
-		!LIST_EMPTY(>pp_head.pvh_list);
+	return pp && ((pp->pp_flags & PP_EMBEDDED) != 0 ||
+	!LIST_EMPTY(>pp_head.pvh_list));
 }
 
 /*
@@ -4123,7 +4123,7 @@ pmap_enter_ma(struct pmap *pmap, vaddr_t
 	 */
 
 	bool needpves = pmap_pp_needs_pve(new_pp);
-	if (new_pp && needpves) {
+	if (needpves) {
 		new_pve = pool_cache_get(_pv_cache, PR_NOWAIT);
 		new_sparepve = pool_cache_get(_pv_cache, PR_NOWAIT);
 	} else {



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2018-02-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Feb  5 15:11:54 UTC 2018

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: vmt.c

Log Message:
Pull up following revision(s) (requested by nakayama in ticket #532):
sys/arch/x86/x86/vmt.c: revision 1.20
Add line break.


To generate a diff of this commit:
cvs rdiff -u -r1.17.2.1 -r1.17.2.2 src/sys/arch/x86/x86/vmt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/vmt.c
diff -u src/sys/arch/x86/x86/vmt.c:1.17.2.1 src/sys/arch/x86/x86/vmt.c:1.17.2.2
--- src/sys/arch/x86/x86/vmt.c:1.17.2.1	Wed Oct 25 07:05:55 2017
+++ src/sys/arch/x86/x86/vmt.c	Mon Feb  5 15:11:54 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: vmt.c,v 1.17.2.1 2017/10/25 07:05:55 snj Exp $ */
+/* $NetBSD: vmt.c,v 1.17.2.2 2018/02/05 15:11:54 martin Exp $ */
 /* $OpenBSD: vmt.c,v 1.11 2011/01/27 21:29:25 dtucker Exp $ */
 
 /*
@@ -179,6 +179,7 @@ vmt_attach(device_t parent, device_t sel
 	struct vmt_softc *sc = device_private(self);
 
 	aprint_naive("\n");
+	aprint_normal("\n");
 
 	sc->sc_dev = self;
 	sc->sc_log = NULL;



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2018-01-13 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Jan 13 21:44:20 UTC 2018

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: procfs_machdep.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #492):
sys/arch/x86/x86/procfs_machdep.c: revision 1.21
Print intel_pt in /proc/cpuinfo.


To generate a diff of this commit:
cvs rdiff -u -r1.15.2.2 -r1.15.2.3 src/sys/arch/x86/x86/procfs_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/procfs_machdep.c
diff -u src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.2 src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.3
--- src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.2	Tue Nov 21 15:11:52 2017
+++ src/sys/arch/x86/x86/procfs_machdep.c	Sat Jan 13 21:44:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.15.2.2 2017/11/21 15:11:52 martin Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.15.2.3 2018/01/13 21:44:20 snj Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.2 2017/11/21 15:11:52 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.3 2018/01/13 21:44:20 snj Exp $");
 
 #include 
 #include 
@@ -113,7 +113,7 @@ static const char * const x86_features[]
 	{ /* (7) Linux mapping */
 	NULL, NULL, "cpb", "ebp", NULL, "pln", "pts", "dtherm",
 	"hw_pstate", "proc_feedback", "sme", NULL,
-	NULL, NULL, NULL, "intel_pt",
+	NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
@@ -130,7 +130,7 @@ static const char * const x86_features[]
 	"bmi2", "erms", "invpcid", "rtm", "cqm", NULL, "mpx", "rdt_a",
 	"avx512f", "avx512dq", "rdseed", "adx",
 	"smap", NULL, NULL, "clflushopt",
-	"clwb", NULL, "avx512pf", "avx512er",
+	"clwb", "intel_pt", "avx512pf", "avx512er",
 	"avx512cd", "sha_ni", "avx512bw", "avx512vl"},
 
 	{ /* (10) 0x000d:1 eax */



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2017-12-21 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Dec 21 19:33:15 UTC 2017

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: fpu.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #442):
sys/arch/x86/x86/fpu.c: 1.19 via patch
Mask mxcsr, otherwise userland could set reserved bits to 1 and make
xrstor fault.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.12.8.1 src/sys/arch/x86/x86/fpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/fpu.c
diff -u src/sys/arch/x86/x86/fpu.c:1.12 src/sys/arch/x86/x86/fpu.c:1.12.8.1
--- src/sys/arch/x86/x86/fpu.c:1.12	Thu Sep 29 17:01:43 2016
+++ src/sys/arch/x86/x86/fpu.c	Thu Dec 21 19:33:15 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.12 2016/09/29 17:01:43 maxv Exp $	*/
+/*	$NetBSD: fpu.c,v 1.12.8.1 2017/12/21 19:33:15 snj Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.  All
@@ -96,7 +96,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.12 2016/09/29 17:01:43 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.12.8.1 2017/12/21 19:33:15 snj Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -591,6 +591,7 @@ process_write_fpregs_xmm(struct lwp *l, 
 		memcpy(_save->sv_xmm, fpregs, sizeof(fpu_save->sv_xmm));
 		/* Invalid bits in the mxcsr_mask will cause faults */
 		fpu_save->sv_xmm.fx_mxcsr_mask &= __INITIAL_MXCSR_MASK__;
+		fpu_save->sv_xmm.fx_mxcsr &= fpu_save->sv_xmm.fx_mxcsr_mask;
 	} else {
 		process_xmm_to_s87(fpregs, _save->sv_87);
 	}



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2017-11-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Nov 30 14:23:12 UTC 2017

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: lapic.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #403):
sys/arch/x86/x86/lapic.c: revision 1.63
Fix stack overflow, found when testing a new feature.


To generate a diff of this commit:
cvs rdiff -u -r1.58.2.3 -r1.58.2.4 src/sys/arch/x86/x86/lapic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/lapic.c
diff -u src/sys/arch/x86/x86/lapic.c:1.58.2.3 src/sys/arch/x86/x86/lapic.c:1.58.2.4
--- src/sys/arch/x86/x86/lapic.c:1.58.2.3	Thu Nov 30 14:21:48 2017
+++ src/sys/arch/x86/x86/lapic.c	Thu Nov 30 14:23:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lapic.c,v 1.58.2.3 2017/11/30 14:21:48 martin Exp $	*/
+/*	$NetBSD: lapic.c,v 1.58.2.4 2017/11/30 14:23:12 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.58.2.3 2017/11/30 14:21:48 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.58.2.4 2017/11/30 14:23:12 martin Exp $");
 
 #include "acpica.h"
 #include "ioapic.h"
@@ -250,7 +250,7 @@ lapic_is_x2apic(void)
 static void
 lapic_setup_bsp(paddr_t lapic_base)
 {
-	u_int regs[4];
+	u_int regs[6];
 	const char *reason = NULL;
 	const char *hw_vendor;
 	bool bios_x2apic;



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2017-11-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Nov 30 14:21:48 UTC 2017

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: lapic.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #402):
sys/arch/x86/x86/lapic.c: revision 1.61
Fix a bug introduced in r1.55, this should be LAPIC_BASE.


To generate a diff of this commit:
cvs rdiff -u -r1.58.2.2 -r1.58.2.3 src/sys/arch/x86/x86/lapic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/lapic.c
diff -u src/sys/arch/x86/x86/lapic.c:1.58.2.2 src/sys/arch/x86/x86/lapic.c:1.58.2.3
--- src/sys/arch/x86/x86/lapic.c:1.58.2.2	Fri Jul 14 08:41:18 2017
+++ src/sys/arch/x86/x86/lapic.c	Thu Nov 30 14:21:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lapic.c,v 1.58.2.2 2017/07/14 08:41:18 martin Exp $	*/
+/*	$NetBSD: lapic.c,v 1.58.2.3 2017/11/30 14:21:48 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.58.2.2 2017/07/14 08:41:18 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.58.2.3 2017/11/30 14:21:48 martin Exp $");
 
 #include "acpica.h"
 #include "ioapic.h"
@@ -367,7 +367,7 @@ lapic_map(paddr_t lapic_base)
 	if (CPUID_TO_FAMILY(curcpu()->ci_signature) >= 6) {
 		lapic_base = (paddr_t)rdmsr(MSR_APICBASE);
 		if ((lapic_base & APICBASE_PHYSADDR) == 0) {
-			lapic_base |= APICBASE_PHYSADDR;
+			lapic_base |= LAPIC_BASE;
 		}
 		wrmsr(MSR_APICBASE, lapic_base | APICBASE_EN);
 		lapic_base &= APICBASE_PHYSADDR;



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2017-11-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 21 15:11:52 UTC 2017

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: procfs_machdep.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #367):
sys/arch/x86/x86/procfs_machdep.c: revision 1.20
sys/arch/x86/x86/procfs_machdep.c: revision 1.17
sys/arch/x86/x86/procfs_machdep.c: revision 1.18
  Print the following cpuid bits:
   0x000d:1 eax (xsaveopt, xsavec, xgetbv1, xsaves)
   0x000f:0 edx (cqm_llc)
   0x000f:1 edx (cqm_occup_llc)
   0x0006   eax (dtherm, ida, arat, pln, pts, hwp, hwp_notify,
 hwp_act_window, hwp_epp, hwp_pkg_req)
- Use per cpu ci->ci_max_cupid instead of global "cpuid_level" variable.
- Print AMD specific cpuid leafs:
 0x8008 ebx
0x800a edx
0x8007 ebx
  Fix the location of AMD's smca(Scalable MCA) bit. Thanks Yasushi Oshima for
finding this bug.


To generate a diff of this commit:
cvs rdiff -u -r1.15.2.1 -r1.15.2.2 src/sys/arch/x86/x86/procfs_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/procfs_machdep.c
diff -u src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.1 src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.2
--- src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.1	Thu Aug 31 11:34:54 2017
+++ src/sys/arch/x86/x86/procfs_machdep.c	Tue Nov 21 15:11:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.15.2.1 2017/08/31 11:34:54 martin Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.15.2.2 2017/11/21 15:11:52 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.1 2017/08/31 11:34:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.2 2017/11/21 15:11:52 martin Exp $");
 
 #include 
 #include 
@@ -55,6 +55,8 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_machd
 #include 
 #include 
 #include 
+#include 
+#include 
 
 /*
  *  The feature table. The order is the same as Linux's
@@ -106,11 +108,11 @@ static const char * const x86_features[]
 	"fma4", "tce", NULL, "nodeid_msr",
 	NULL, "tbm", "topoext", "perfctr_core",
 	"perfctr_nb", NULL, "bpext", "ptsc",
-	"perfctr_l2", "mwaitx", NULL, NULL},
+	"perfctr_llc", "mwaitx", NULL, NULL},
 
 	{ /* (7) Linux mapping */
 	NULL, NULL, "cpb", "ebp", NULL, "pln", "pts", "dtherm",
-	"hw_pstate", "proc_feedback", NULL, NULL,
+	"hw_pstate", "proc_feedback", "sme", NULL,
 	NULL, NULL, NULL, "intel_pt",
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
@@ -131,7 +133,7 @@ static const char * const x86_features[]
 	"clwb", NULL, "avx512pf", "avx512er",
 	"avx512cd", "sha_ni", "avx512bw", "avx512vl"},
 
-	{ /* (10) 0x000d eax */
+	{ /* (10) 0x000d:1 eax */
 	"xsaveopt", "xsavec", "xgetbv1", "xsaves", NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -165,8 +167,9 @@ static const char * const x86_features[]
 	{ /* (15) 0x800a edx */
 	"npt", "lbrv", "svm_lock", "nrip_save",
 	"tsc_scale", "vmcb_clean", "flushbyasid", "decodeassists",
-	NULL, NULL, "pausefilter", NULL, "pfthreshold", "avic", NULL, NULL,
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	NULL, NULL, "pausefilter", NULL, "pfthreshold", "avic", NULL,
+	"v_vmsave_vmload",
+	"vgif", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (16) 0x0007:0 ecx */
@@ -176,7 +179,7 @@ static const char * const x86_features[]
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (17) 0x8007 ebx */
-	"overflow_recov", "succor", "smca", NULL, NULL, NULL, NULL, NULL,
+	"overflow_recov", "succor", NULL, "smca", NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
@@ -248,6 +251,7 @@ procfs_getonecpufeatures(struct cpu_info
 {
 	size_t last = *left;
 	size_t diff;
+	u_int descs[4];
 
 	procfs_getonefeatreg(ci->ci_feat_val[0], x86_features[0], p, left);
 	diff = last - *left;
@@ -278,18 +282,59 @@ procfs_getonecpufeatures(struct cpu_info
 	left);
 	diff = last - *left;
 
-	/* (10) 0x000d eax */
-	/* (11) 0x000f(ecx=0) edx */
-	/* (12) 0x000f(ecx=1) edx */
-	/* (13) 0x8008 ebx */
-	/* (14) 0x0006 eax */
-	/* (15) 0x800a edx */
+	if (ci->ci_max_cpuid >= 0x0d) {
+		x86_cpuid2(0x0d, 1, descs);
+		procfs_getonefeatreg(descs[0], x86_features[10], p + diff,
+		left);
+		diff = last - *left;
+	}
+
+	if (ci->ci_max_cpuid >= 0x0f) {
+		x86_cpuid2(0x0f, 0, descs);
+		procfs_getonefeatreg(descs[3], x86_features[11], p + diff,
+		left);
+		diff = last - *left;
+
+		x86_cpuid2(0x0f, 1, descs);
+		procfs_getonefeatreg(descs[3], 

CVS commit: [netbsd-8] src/sys/arch/x86/x86

2017-10-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Oct 25 07:05:55 UTC 2017

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: vmt.c

Log Message:
Pull up following revision(s) (requested by maya in ticket #325):
sys/arch/x86/x86/vmt.c: revision 1.18
Check that the host supports GET_SPEED as well as GET_VERSION
before deciding vmt_probe has succeeded.
qemu supports GET_VERSION but not the RPC protocol so the probe succeeds
but the attach fails, resulting in "vmt0: failed to open backdoor RPC
channel (TCLO protocol)".  All known versions of vmware support GET_SPEED
and no known qemu versions do, so this prevents it from attempting to
attach (and failing) on qemu while still working on vmware.
stop checking vmt_type to avoid having to adapt this code.
- Taken from openbsd


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.17.2.1 src/sys/arch/x86/x86/vmt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/vmt.c
diff -u src/sys/arch/x86/x86/vmt.c:1.17 src/sys/arch/x86/x86/vmt.c:1.17.2.1
--- src/sys/arch/x86/x86/vmt.c:1.17	Thu Jun  1 02:45:08 2017
+++ src/sys/arch/x86/x86/vmt.c	Wed Oct 25 07:05:55 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vmt.c,v 1.17 2017/06/01 02:45:08 chs Exp $ */
+/* $NetBSD: vmt.c,v 1.17.2.1 2017/10/25 07:05:55 snj Exp $ */
 /* $OpenBSD: vmt.c,v 1.11 2011/01/27 21:29:25 dtucker Exp $ */
 
 /*
@@ -126,28 +126,34 @@ static void vmt_pswitch_event(void *);
 
 extern char hostname[MAXHOSTNAMELEN];
 
-static bool
-vmt_probe(uint32_t *type)
+static void
+vmt_probe_cmd(struct vm_backdoor *frame, uint16_t cmd)
 {
-	struct vm_backdoor frame;
+	memset(frame, 0, sizeof(*frame));
 
-	memset(, 0, sizeof(frame));
+	(frame->eax).word = VM_MAGIC;
+	(frame->ebx).word = ~VM_MAGIC;
+	(frame->ecx).part.low = cmd;
+	(frame->ecx).part.high = 0x;
+	(frame->edx).part.low  = VM_PORT_CMD;
+	(frame->edx).part.high = 0;
 
-	frame.eax.word = VM_MAGIC;
-	frame.ebx.word = ~VM_MAGIC;
-	frame.ecx.part.low = VM_CMD_GET_VERSION;
-	frame.ecx.part.high = 0x;
-	frame.edx.part.low  = VM_PORT_CMD;
-	frame.edx.part.high = 0;
+	vm_cmd(frame);
+}
 
-	vm_cmd();
+static bool
+vmt_probe(void)
+{
+	struct vm_backdoor frame;
 
+	vmt_probe_cmd(, VM_CMD_GET_VERSION);
 	if (frame.eax.word == 0x ||
 	frame.ebx.word != VM_MAGIC)
 		return false;
 
-	if (type)
-		*type = frame.ecx.word;
+	vmt_probe_cmd(, VM_CMD_GET_SPEED);
+	if (frame.eax.word == VM_MAGIC)
+		return false;
 
 	return true;
 }
@@ -163,23 +169,7 @@ vmt_match(device_t parent, cfdata_t matc
 	if ((ci->ci_flags & (CPUF_BSP|CPUF_SP|CPUF_PRIMARY)) == 0)
 		return 0;
 
-	return vmt_probe(NULL);
-}
-
-static const char *
-vmt_type(void)
-{
-	uint32_t vmwaretype = 0;
-
-	vmt_probe();
-
-	switch (vmwaretype) {
-	case 1:	return "Express";
-	case 2:	return "ESX Server";
-	case 3:	return "VMware Server";
-	case 4: return "Workstation";
-	default: return "Unknown";
-	}
+	return vmt_probe();
 }
 
 static void
@@ -189,7 +179,6 @@ vmt_attach(device_t parent, device_t sel
 	struct vmt_softc *sc = device_private(self);
 
 	aprint_naive("\n");
-	aprint_normal(": %s\n", vmt_type());
 
 	sc->sc_dev = self;
 	sc->sc_log = NULL;



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2017-08-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Aug 31 11:34:54 UTC 2017

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: procfs_machdep.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #247):
sys/arch/x86/x86/procfs_machdep.c: revision 1.16
  Check buffer length correctly to not to print a garbage character.
Fixes PR#52352 reported by Yasushi Oshima.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.15.2.1 src/sys/arch/x86/x86/procfs_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/procfs_machdep.c
diff -u src/sys/arch/x86/x86/procfs_machdep.c:1.15 src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.1
--- src/sys/arch/x86/x86/procfs_machdep.c:1.15	Mon May 15 04:21:14 2017
+++ src/sys/arch/x86/x86/procfs_machdep.c	Thu Aug 31 11:34:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.15 2017/05/15 04:21:14 msaitoh Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.15.2.1 2017/08/31 11:34:54 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15 2017/05/15 04:21:14 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.1 2017/08/31 11:34:54 martin Exp $");
 
 #include 
 #include 
@@ -203,7 +203,7 @@ procfs_getcpuinfstr(char *bf, size_t *le
 	for (CPU_INFO_FOREACH(cii, ci)) {
 		procfs_getonecpu(i++, ci, bf, );
 		total += used + 1;
-		if (used + 1 < size) {
+		if (used + 1 <= size) {
 			bf += used;
 			*bf++ = '\n';
 			size -= used + 1;



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2017-08-24 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Aug 25 05:42:55 UTC 2017

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: pmc.c

Log Message:
Pull up following revision(s) (requested by jdolecek in ticket #225):
sys/arch/x86/x86/pmc.c: revision 1.11
Fix GCC warning on NET4501, PR/52451.


To generate a diff of this commit:
cvs rdiff -u -r1.7.2.1 -r1.7.2.2 src/sys/arch/x86/x86/pmc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/pmc.c
diff -u src/sys/arch/x86/x86/pmc.c:1.7.2.1 src/sys/arch/x86/x86/pmc.c:1.7.2.2
--- src/sys/arch/x86/x86/pmc.c:1.7.2.1	Tue Aug  1 23:18:30 2017
+++ src/sys/arch/x86/x86/pmc.c	Fri Aug 25 05:42:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmc.c,v 1.7.2.1 2017/08/01 23:18:30 snj Exp $	*/
+/*	$NetBSD: pmc.c,v 1.7.2.2 2017/08/25 05:42:55 snj Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmc.c,v 1.7.2.1 2017/08/01 23:18:30 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmc.c,v 1.7.2.2 2017/08/25 05:42:55 snj Exp $");
 
 #include "opt_pmc.h"
 
@@ -138,7 +138,7 @@ static int
 pmc_nmi(const struct trapframe *tf, void *dummy)
 {
 	struct cpu_info *ci = curcpu();
-	pmc_state_t *pmc;
+	pmc_state_t *pmc = NULL;
 	pmc_cpu_t *cpu;
 	uint64_t ctr;
 	size_t i;



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2017-08-24 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Aug 25 05:41:55 UTC 2017

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: idt.c

Log Message:
Pull up following revision(s) (requested by jdolecek in ticket #224):
sys/arch/x86/x86/idt.c: revision 1.5
Remove incorrect KASSERT, only the allocation is protected by cpu_lock.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.8.1 src/sys/arch/x86/x86/idt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/idt.c
diff -u src/sys/arch/x86/x86/idt.c:1.4 src/sys/arch/x86/x86/idt.c:1.4.8.1
--- src/sys/arch/x86/x86/idt.c:1.4	Sat Aug 27 14:19:47 2016
+++ src/sys/arch/x86/x86/idt.c	Fri Aug 25 05:41:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: idt.c,v 1.4 2016/08/27 14:19:47 maxv Exp $	*/
+/*	$NetBSD: idt.c,v 1.4.8.1 2017/08/25 05:41:55 snj Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2009 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: idt.c,v 1.4 2016/08/27 14:19:47 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: idt.c,v 1.4.8.1 2017/08/25 05:41:55 snj Exp $");
 
 #include 
 #include 
@@ -119,7 +119,6 @@ void
 idt_vec_set(int vec, void (*function)(void))
 {
 
-	KASSERT(mutex_owned(_lock) || !mp_online);
 	KASSERT(idt_allocmap[vec] == 1);
 	setgate([vec], function, 0, SDT_SYS386IGT, SEL_KPL,
 	GSEL(GCODE_SEL, SEL_KPL));



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2017-07-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jul 14 08:41:18 UTC 2017

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: lapic.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #135):
sys/arch/x86/x86/lapic.c: revision 1.60
PR/52266: Before access MSR[APICBASE], need to check if APIC is present.


To generate a diff of this commit:
cvs rdiff -u -r1.58.2.1 -r1.58.2.2 src/sys/arch/x86/x86/lapic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/lapic.c
diff -u src/sys/arch/x86/x86/lapic.c:1.58.2.1 src/sys/arch/x86/x86/lapic.c:1.58.2.2
--- src/sys/arch/x86/x86/lapic.c:1.58.2.1	Mon Jul 10 12:26:21 2017
+++ src/sys/arch/x86/x86/lapic.c	Fri Jul 14 08:41:18 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lapic.c,v 1.58.2.1 2017/07/10 12:26:21 martin Exp $	*/
+/*	$NetBSD: lapic.c,v 1.58.2.2 2017/07/14 08:41:18 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.58.2.1 2017/07/10 12:26:21 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.58.2.2 2017/07/14 08:41:18 martin Exp $");
 
 #include "acpica.h"
 #include "ioapic.h"
@@ -237,7 +237,8 @@ lapic_is_x2apic(void)
 {
 	uint64_t msr;
 
-	if (rdmsr_safe(MSR_APICBASE, ) == EFAULT)
+	if (!ISSET(cpu_feature[0], CPUID_APIC) ||
+	rdmsr_safe(MSR_APICBASE, ) == EFAULT)
 		return false;
 	return (msr & (APICBASE_EN | APICBASE_EXTD)) ==
 	(APICBASE_EN | APICBASE_EXTD);



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2017-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 10 12:26:21 UTC 2017

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: lapic.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #110):
sys/arch/x86/x86/lapic.c: revision 1.59
PR/52266: use rdmsr_safe(9) instead of rdmsr(9) for old machine.
tested by simonb@


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.58.2.1 src/sys/arch/x86/x86/lapic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/lapic.c
diff -u src/sys/arch/x86/x86/lapic.c:1.58 src/sys/arch/x86/x86/lapic.c:1.58.2.1
--- src/sys/arch/x86/x86/lapic.c:1.58	Tue May 23 08:54:39 2017
+++ src/sys/arch/x86/x86/lapic.c	Mon Jul 10 12:26:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lapic.c,v 1.58 2017/05/23 08:54:39 nonaka Exp $	*/
+/*	$NetBSD: lapic.c,v 1.58.2.1 2017/07/10 12:26:21 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__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.58.2.1 2017/07/10 12:26:21 martin Exp $");
 
 #include "acpica.h"
 #include "ioapic.h"
@@ -235,10 +235,12 @@ lapic_enable_x2apic(void)
 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, ) == EFAULT)
+		return false;
+	return (msr & (APICBASE_EN | APICBASE_EXTD)) ==
+	(APICBASE_EN | APICBASE_EXTD);
 }
 
 /*



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2017-07-05 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Jul  5 20:23:09 UTC 2017

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: pmap.c

Log Message:
Pull up following revision(s) (requested by jdolecek in ticket #98):
sys/arch/x86/x86/pmap.c: revision 1.252
remove panicstr KASSERT() in pmap_kremove_local() - kernel dump can
legitimely invoked also without panic - via reboot -d
fixes PR kern/49610 by Manuel Bouyer


To generate a diff of this commit:
cvs rdiff -u -r1.245 -r1.245.6.1 src/sys/arch/x86/x86/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.245 src/sys/arch/x86/x86/pmap.c:1.245.6.1
--- src/sys/arch/x86/x86/pmap.c:1.245	Fri Mar 24 10:58:06 2017
+++ src/sys/arch/x86/x86/pmap.c	Wed Jul  5 20:23:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.245 2017/03/24 10:58:06 maxv Exp $	*/
+/*	$NetBSD: pmap.c,v 1.245.6.1 2017/07/05 20:23:08 snj Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.245 2017/03/24 10:58:06 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.245.6.1 2017/07/05 20:23:08 snj Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -1146,14 +1146,13 @@ pmap_kremove(vaddr_t sva, vsize_t len)
 /*
  * pmap_kremove_local: like pmap_kremove(), but only worry about
  * TLB invalidations on the current CPU.  this is only intended
- * for use while writing kernel crash dumps.
+ * for use while writing kernel crash dumps, either after panic
+ * or via reboot -d.
  */
 
 void
 pmap_kremove_local(vaddr_t sva, vsize_t len)
 {
-
-	KASSERT(panicstr != NULL);
 	pmap_kremove1(sva, len, true);
 }
 



CVS commit: [netbsd-8] src/sys/arch/x86/x86

2017-06-13 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Jun 14 04:47:33 UTC 2017

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: cpu.c

Log Message:
Pull up following revision(s) (requested by pgoyette in ticket #28):
sys/arch/x86/x86/cpu.c: revision 1.131
Further reduce the loop counter so that hatching completes before the
boot processor times us out.
Add a nice big XXX comment for why the counter is so low.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.130.2.1 src/sys/arch/x86/x86/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.130 src/sys/arch/x86/x86/cpu.c:1.130.2.1
--- src/sys/arch/x86/x86/cpu.c:1.130	Wed May 31 14:41:07 2017
+++ src/sys/arch/x86/x86/cpu.c	Wed Jun 14 04:47:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.130 2017/05/31 14:41:07 kre Exp $	*/
+/*	$NetBSD: cpu.c,v 1.130.2.1 2017/06/14 04:47:33 snj Exp $	*/
 
 /*-
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.130 2017/05/31 14:41:07 kre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.130.2.1 2017/06/14 04:47:33 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -835,7 +835,13 @@ cpu_hatch(void *v)
 			}
 			x86_mwait(0, 0);
 		} else {
-			for (i = 100; i != 0; i--) {
+	/*
+	 * XXX The loop repetition count could be a lot higher, but
+	 * XXX currently qemu emulator takes a _very_long_time_ to
+	 * XXX execute the pause instruction.  So for now, use a low
+	 * XXX value to allow the cpu to hatch before timing out.
+	 */
+			for (i = 50; i != 0; i--) {
 x86_pause();
 			}
 		}