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

2024-04-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 18 16:40:17 UTC 2024

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: viac7temp.c

Log Message:
Pull up following revision(s) (requested by andvar in ticket #1835):

sys/arch/x86/x86/viac7temp.c: revision 1.10

viac7temp(4): define module metadata using MODULE() macro and implement
viac7temp_modcmd() to handle module load/unload events.

Fixes PR kern/58148. Look OK by mrg@.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.32.1 src/sys/arch/x86/x86/viac7temp.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/viac7temp.c
diff -u src/sys/arch/x86/x86/viac7temp.c:1.8 src/sys/arch/x86/x86/viac7temp.c:1.8.32.1
--- src/sys/arch/x86/x86/viac7temp.c:1.8	Sun Aug 10 16:44:34 2014
+++ src/sys/arch/x86/x86/viac7temp.c	Thu Apr 18 16:40:17 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: viac7temp.c,v 1.8 2014/08/10 16:44:34 tls Exp $ */
+/* $NetBSD: viac7temp.c,v 1.8.32.1 2024/04/18 16:40:17 martin Exp $ */
 
 /*-
  * Copyright (c) 2009 Jared D. McNeill 
@@ -27,11 +27,12 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: viac7temp.c,v 1.8 2014/08/10 16:44:34 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: viac7temp.c,v 1.8.32.1 2024/04/18 16:40:17 martin Exp $");
 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -162,3 +163,32 @@ viac7temp_refresh_xcall(void *arg0, void
 	edata->value_cur += 27315;
 	edata->state = ENVSYS_SVALID;
 }
+
+MODULE(MODULE_CLASS_DRIVER, viac7temp, NULL);
+
+#ifdef _MODULE
+#include "ioconf.c"
+#endif
+
+static int
+viac7temp_modcmd(modcmd_t cmd, void *arg __unused)
+{
+	int error = 0;
+
+	switch (cmd) {
+	case MODULE_CMD_INIT:
+#ifdef _MODULE
+		error = config_init_component(cfdriver_ioconf_viac7temp,
+		cfattach_ioconf_viac7temp, cfdata_ioconf_viac7temp);
+#endif
+		return error;
+	case MODULE_CMD_FINI:
+#ifdef _MODULE
+		error = config_fini_component(cfdriver_ioconf_viac7temp,
+		cfattach_ioconf_viac7temp, cfdata_ioconf_viac7temp);
+#endif
+		return error;
+	default:
+		return ENOTTY;
+	}
+}



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

2024-04-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 18 16:40:17 UTC 2024

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: viac7temp.c

Log Message:
Pull up following revision(s) (requested by andvar in ticket #1835):

sys/arch/x86/x86/viac7temp.c: revision 1.10

viac7temp(4): define module metadata using MODULE() macro and implement
viac7temp_modcmd() to handle module load/unload events.

Fixes PR kern/58148. Look OK by mrg@.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.32.1 src/sys/arch/x86/x86/viac7temp.c

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



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

2023-07-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jul 29 11:01:15 UTC 2023

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

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

sys/arch/x86/x86/coretemp.c: revision 1.38-1.39 (patch)

coretemp(4): Change limits of Tjmax.
 - Change the lower limit from 70 to 60. At least, some BIOSes can change
   the value down to 62.
 - Change the upper limit from 110 to 120. At least, some BIOSes can change
   the value up to 115.
 - Print error message when rdmsr(TEMPERATURE_TARGET) failed.
 - When Tjmax exceeded the limit, print warning message and use the value
   as it is.
 - KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.36.4.1 -r1.36.4.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.36.4.1 src/sys/arch/x86/x86/coretemp.c:1.36.4.2
--- src/sys/arch/x86/x86/coretemp.c:1.36.4.1	Wed Jul 15 14:02:36 2020
+++ src/sys/arch/x86/x86/coretemp.c	Sat Jul 29 11:01:14 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: coretemp.c,v 1.36.4.1 2020/07/15 14:02:36 martin Exp $ */
+/* $NetBSD: coretemp.c,v 1.36.4.2 2023/07/29 11:01:14 martin Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: coretemp.c,v 1.36.4.1 2020/07/15 14:02:36 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coretemp.c,v 1.36.4.2 2023/07/29 11:01:14 martin Exp $");
 
 #include 
 #include 
@@ -102,6 +102,10 @@ __KERNEL_RCSID(0, "$NetBSD: coretemp.c,v
 
 #define MSR_TEMP_TARGET_READOUT		__BITS(16, 23)
 
+#define TJMAX_DEFAULT		100
+#define TJMAX_LIMIT_LOW		60
+#define TJMAX_LIMIT_HIGH	120
+
 static int	coretemp_match(device_t, cfdata_t, void *);
 static void	coretemp_attach(device_t, device_t, void *);
 static int	coretemp_detach(device_t, int);
@@ -259,16 +263,15 @@ coretemp_tjmax(device_t self)
 {
 	struct coretemp_softc *sc = device_private(self);
 	struct cpu_info *ci = sc->sc_ci;
-	uint32_t model, stepping;
 	uint64_t msr;
+	uint32_t model, stepping;
+	int tjmax;
 
 	model = CPUID_TO_MODEL(ci->ci_signature);
 	stepping = CPUID_TO_STEPPING(ci->ci_signature);
 
-	/*
-	 * Use 100C as the initial value.
-	 */
-	sc->sc_tjmax = 100;
+	/* Set the initial value. */
+	sc->sc_tjmax = TJMAX_DEFAULT;
 
 	if ((model == 0x0f && stepping >= 2) || (model == 0x0e)) {
 		/*
@@ -304,20 +307,20 @@ coretemp_tjmax(device_t self)
 			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.
-		 * It is not fully known which CPU models have the MSR.
-		 */
-		if (rdmsr_safe(MSR_TEMPERATURE_TARGET, ) == EFAULT)
-			return;
-
-		msr = __SHIFTOUT(msr, MSR_TEMP_TARGET_READOUT);
-
-		if (msr >= 70 && msr <= 110) {
-			sc->sc_tjmax = msr;
+		/* Attempt to get Tj(max) from IA32_TEMPERATURE_TARGET. */
+		if (rdmsr_safe(MSR_TEMPERATURE_TARGET, ) == EFAULT) {
+			aprint_error_dev(sc->sc_dev,
+			"Failed to read TEMPERATURE_TARGET MSR. "
+			"Use the default (%d)\n", sc->sc_tjmax);
 			return;
 		}
+
+		tjmax = __SHIFTOUT(msr, MSR_TEMP_TARGET_READOUT);
+		if ((tjmax < TJMAX_LIMIT_LOW) || (tjmax > TJMAX_LIMIT_HIGH))
+			aprint_error_dev(sc->sc_dev,
+			"WARNING: Tjmax(%d) might exceeded the limit.\n",
+			tjmax);
+		sc->sc_tjmax = tjmax;
 	}
 }
 
@@ -334,7 +337,7 @@ coretemp_refresh(struct sysmon_envsys *s
 static void
 coretemp_refresh_xcall(void *arg0, void *arg1)
 {
-struct coretemp_softc *sc = arg0;
+	struct coretemp_softc *sc = arg0;
 	envsys_data_t *edata = arg1;
 	uint64_t msr;
 



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

2023-07-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jul 29 11:01:15 UTC 2023

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

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

sys/arch/x86/x86/coretemp.c: revision 1.38-1.39 (patch)

coretemp(4): Change limits of Tjmax.
 - Change the lower limit from 70 to 60. At least, some BIOSes can change
   the value down to 62.
 - Change the upper limit from 110 to 120. At least, some BIOSes can change
   the value up to 115.
 - Print error message when rdmsr(TEMPERATURE_TARGET) failed.
 - When Tjmax exceeded the limit, print warning message and use the value
   as it is.
 - KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.36.4.1 -r1.36.4.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.



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

2023-07-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jul 27 16:40:50 UTC 2023

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

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1667):

sys/arch/x86/x86/errata.c: revision 1.32

fix the cpuids for the zen2 client CPUs.

i'm not exactly how i came up with the values i had, though one
of them was still valid and matched my test systems.


To generate a diff of this commit:
cvs rdiff -u -r1.26.2.1 -r1.26.2.2 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.26.2.1 src/sys/arch/x86/x86/errata.c:1.26.2.2
--- src/sys/arch/x86/x86/errata.c:1.26.2.1	Tue Jul 25 09:12:36 2023
+++ src/sys/arch/x86/x86/errata.c	Thu Jul 27 16:40:50 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: errata.c,v 1.26.2.1 2023/07/25 09:12:36 martin Exp $	*/
+/*	$NetBSD: errata.c,v 1.26.2.2 2023/07/27 16:40:50 martin Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: errata.c,v 1.26.2.1 2023/07/25 09:12:36 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: errata.c,v 1.26.2.2 2023/07/27 16:40:50 martin Exp $");
 
 #include 
 #include 
@@ -96,8 +96,8 @@ static const u_int cpurevs[] = {
 	ML_A1, 0x0730F01, ZP_B1, 0x0800F11, ZP_B2, 0x0800F12,
 	PiR_B2, 0x0800F82, Rome_B0, 0x0830F10,
 	/* XXX client Zen2 names aren't known yet. */
-	Z2_XB, 0x0840F70, Z2_Ren, 0x0860F80, Z2_Luc, 0x0870F10,
-	Z2_Mat, 0x0890F70, Z2_VG, 0x0890F80, Z2_Men, 0x08A0F10,
+	Z2_XB, 0x0840F70, Z2_Ren, 0x0860F01, Z2_Luc, 0x0860F81,
+	Z2_Mat, 0x0870F10, Z2_VG, 0x0890F02, Z2_Men, 0x08A0F00,
 	Milan_B1, 0x0A00F11, Milan_B2, 0x0A00F12,
 	Genoa_B1, 0x0A10F11,
 	OINK



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

2023-07-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jul 27 16:40:50 UTC 2023

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

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1667):

sys/arch/x86/x86/errata.c: revision 1.32

fix the cpuids for the zen2 client CPUs.

i'm not exactly how i came up with the values i had, though one
of them was still valid and matched my test systems.


To generate a diff of this commit:
cvs rdiff -u -r1.26.2.1 -r1.26.2.2 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.



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

2023-07-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jul 25 11:34:37 UTC 2023

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

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

sys/arch/x86/x86/fpu.c: revision 1.86

x86/fpu: Align savefpu to 64 bytes in fpuinit_mxcsr_mask.
16 bytes is not enough.

(Is this why it never worked on Xen some years back?  Got lucky and
accidentally had 64-byte alignment on native x86, but not in the call
stack in Xen?)


To generate a diff of this commit:
cvs rdiff -u -r1.55.2.1 -r1.55.2.2 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.55.2.1 src/sys/arch/x86/x86/fpu.c:1.55.2.2
--- src/sys/arch/x86/x86/fpu.c:1.55.2.1	Sun Oct 18 18:42:10 2020
+++ src/sys/arch/x86/x86/fpu.c	Tue Jul 25 11:34:37 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.55.2.1 2020/10/18 18:42:10 martin Exp $	*/
+/*	$NetBSD: fpu.c,v 1.55.2.2 2023/07/25 11:34:37 martin Exp $	*/
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.  All
@@ -96,7 +96,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.55.2.1 2020/10/18 18:42:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.55.2.2 2023/07/25 11:34:37 martin Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -153,7 +153,7 @@ void
 fpuinit_mxcsr_mask(void)
 {
 #ifndef XENPV
-	union savefpu fpusave __aligned(16);
+	union savefpu fpusave __aligned(64);
 	u_long psl;
 
 	memset(, 0, sizeof(fpusave));



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

2023-07-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jul 25 11:34:37 UTC 2023

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

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

sys/arch/x86/x86/fpu.c: revision 1.86

x86/fpu: Align savefpu to 64 bytes in fpuinit_mxcsr_mask.
16 bytes is not enough.

(Is this why it never worked on Xen some years back?  Got lucky and
accidentally had 64-byte alignment on native x86, but not in the call
stack in Xen?)


To generate a diff of this commit:
cvs rdiff -u -r1.55.2.1 -r1.55.2.2 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.



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

2023-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jun 21 19:52:39 UTC 2023

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

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

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

Add Intel lam and AMD vnmi.


To generate a diff of this commit:
cvs rdiff -u -r1.33.2.7 -r1.33.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.33.2.7 src/sys/arch/x86/x86/procfs_machdep.c:1.33.2.8
--- src/sys/arch/x86/x86/procfs_machdep.c:1.33.2.7	Mon Jan 23 12:23:53 2023
+++ src/sys/arch/x86/x86/procfs_machdep.c	Wed Jun 21 19:52:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.33.2.7 2023/01/23 12:23:53 martin Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.33.2.8 2023/06/21 19:52:39 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.33.2.7 2023/01/23 12:23:53 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.33.2.8 2023/06/21 19:52:39 martin Exp $");
 
 #include 
 #include 
@@ -151,7 +151,7 @@ static const char * const x86_features[]
 	"avx_vnni", "avx512_bf16", 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, "lam", NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (13) AMD 0x8008 ebx */
 	"clzero", "irperf", "xsaveerptr", NULL, "rdpru", NULL, NULL, NULL,
@@ -172,7 +172,7 @@ static const char * const x86_features[]
 	NULL, NULL, "pausefilter", NULL, "pfthreshold", "avic", NULL,
 	"v_vmsave_vmload",
 	"vgif", NULL, "x2avic", NULL, "v_spec_ctrl", NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+	NULL, "vnmi", NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (16) 0x0007:0 ecx */
 	NULL, "avx512vbmi", "umip", "pku",



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

2023-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jun 21 19:52:39 UTC 2023

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

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

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

Add Intel lam and AMD vnmi.


To generate a diff of this commit:
cvs rdiff -u -r1.33.2.7 -r1.33.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.



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

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:20:45 UTC 2023

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: efi.c

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

sys/arch/x86/x86/efi_machdep.c: revision 1.3
(applied to sys/arch/x86/x86/efi.c)

x86/efi: Print uuids in slightly more standard notation.

Anyone need a spare hyphen?  We had a few extras, apparently.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.19.4.1 src/sys/arch/x86/x86/efi.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/efi.c
diff -u src/sys/arch/x86/x86/efi.c:1.19 src/sys/arch/x86/x86/efi.c:1.19.4.1
--- src/sys/arch/x86/x86/efi.c:1.19	Mon Dec  3 19:46:43 2018
+++ src/sys/arch/x86/x86/efi.c	Wed Feb 22 19:20:45 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: efi.c,v 1.19 2018/12/03 19:46:43 cherry Exp $	*/
+/*	$NetBSD: efi.c,v 1.19.4.1 2023/02/22 19:20:45 martin Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.19 2018/12/03 19:46:43 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.19.4.1 2023/02/22 19:20:45 martin Exp $");
 
 #include 
 #include 
@@ -134,7 +134,7 @@ efi_aprintuuid(const struct uuid * uuid)
 	aprint_debug("-%04" PRIx16 "", uuid->time_mid);
 	aprint_debug("-%04" PRIx16 "", uuid->time_hi_and_version);
 	aprint_debug("-%02" PRIx8 "", uuid->clock_seq_hi_and_reserved);
-	aprint_debug("-%02" PRIx8 "", uuid->clock_seq_low);
+	aprint_debug("%02" PRIx8 "", uuid->clock_seq_low);
 	aprint_debug("-");
 	for (i = 0; i < _UUID_NODE_LEN; i++) {
 		aprint_debug("%02" PRIx8 "", uuid->node[i]);



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

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:20:45 UTC 2023

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: efi.c

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

sys/arch/x86/x86/efi_machdep.c: revision 1.3
(applied to sys/arch/x86/x86/efi.c)

x86/efi: Print uuids in slightly more standard notation.

Anyone need a spare hyphen?  We had a few extras, apparently.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.19.4.1 src/sys/arch/x86/x86/efi.c

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



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

2023-01-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 23 12:23:53 UTC 2023

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

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

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

Add x2avic. Modify comment.


To generate a diff of this commit:
cvs rdiff -u -r1.33.2.6 -r1.33.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.



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

2023-01-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 23 12:23:53 UTC 2023

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

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

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

Add x2avic. Modify comment.


To generate a diff of this commit:
cvs rdiff -u -r1.33.2.6 -r1.33.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.33.2.6 src/sys/arch/x86/x86/procfs_machdep.c:1.33.2.7
--- src/sys/arch/x86/x86/procfs_machdep.c:1.33.2.6	Fri Sep 16 18:36:43 2022
+++ src/sys/arch/x86/x86/procfs_machdep.c	Mon Jan 23 12:23:53 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.33.2.6 2022/09/16 18:36:43 martin Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.33.2.7 2023/01/23 12:23:53 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.33.2.6 2022/09/16 18:36:43 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.33.2.7 2023/01/23 12:23:53 martin Exp $");
 
 #include 
 #include 
@@ -171,7 +171,7 @@ static const char * const x86_features[]
 	"tsc_scale", "vmcb_clean", "flushbyasid", "decodeassists",
 	NULL, NULL, "pausefilter", NULL, "pfthreshold", "avic", NULL,
 	"v_vmsave_vmload",
-	"vgif", NULL, NULL, NULL, "v_spec_ctrl", NULL, NULL, NULL,
+	"vgif", NULL, "x2avic", NULL, "v_spec_ctrl", NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (16) 0x0007:0 ecx */
@@ -183,7 +183,7 @@ static const char * const x86_features[]
 	NULL, "cldemote", NULL, "movdiri",
 	"movdir64b", "enqcmd", "sgx_lc", NULL},
 
-	{ /* (17) 0x8007 ebx */
+	{ /* (17) AMD 0x8007 ebx */
 	"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,



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

2022-09-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 16 18:36:43 UTC 2022

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

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

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

Add tdx_guest, brs, hfi, ibt, amx_bf16, amx_tile and amx_int8.


To generate a diff of this commit:
cvs rdiff -u -r1.33.2.5 -r1.33.2.6 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.33.2.5 src/sys/arch/x86/x86/procfs_machdep.c:1.33.2.6
--- src/sys/arch/x86/x86/procfs_machdep.c:1.33.2.5	Mon Jan 31 17:54:59 2022
+++ src/sys/arch/x86/x86/procfs_machdep.c	Fri Sep 16 18:36:43 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.33.2.5 2022/01/31 17:54:59 martin Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.33.2.6 2022/09/16 18:36:43 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.33.2.5 2022/01/31 17:54:59 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.33.2.6 2022/09/16 18:36:43 martin Exp $");
 
 #include 
 #include 
@@ -122,7 +122,7 @@ static const char * const x86_features[]
 	{ /* (8) Linux mapping */
 	"tpr_shadow", "vnmi", "flexpriority", "ept", "vpid", NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, "vmmcall",
-	NULL, "ept_ad", NULL, NULL, NULL, NULL, NULL, NULL,
+	NULL, "ept_ad", NULL, NULL, NULL, NULL, "tdx_guest", NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (9) Intel-defined: 0007 ebx */
@@ -157,13 +157,13 @@ static const char * const x86_features[]
 	"clzero", "irperf", "xsaveerptr", NULL, "rdpru", NULL, NULL, NULL,
 	NULL, "wbnoinvd", NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, "ppin",
-	NULL, "virt_ssbd", NULL, "cppc", NULL, NULL, NULL, NULL},
+	NULL, "virt_ssbd", NULL, "cppc", NULL, NULL, NULL, "brs"},
 
 	{ /* (14) 0x0006 eax */
 	"dtherm", "ida", "arat", NULL, "pln", NULL, "pts", "hwp",
 	"hwp_notify", "hwp_act_window", "hwp_epp","hwp_pkg_req",
 	NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, "hfi", NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (15) AMD 0x800a edx */
@@ -193,8 +193,8 @@ static const char * const x86_features[]
 	NULL, NULL, "avx512_4vnniw", "avx512_4fmaps", "fsrm", NULL, NULL, NULL,
 	"vp2intersect", NULL, "md_clear", NULL, NULL, NULL, "serialize", NULL,
 	"tsxldtrk", NULL, "pconfig", "arch_lbr",
-	NULL, NULL, NULL, "avx512_fp16",
-	NULL, NULL, NULL, NULL,
+	"ibt", NULL, "amx_bf16", "avx512_fp16",
+	"amx_tile", "amx_int8", NULL, NULL,
 	"flush_l1d", "arch_capabilities", NULL, "ssbd"},
 
 	{ /* (19) AMD 0x801f eax */



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

2022-09-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 16 18:36:43 UTC 2022

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

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

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

Add tdx_guest, brs, hfi, ibt, amx_bf16, amx_tile and amx_int8.


To generate a diff of this commit:
cvs rdiff -u -r1.33.2.5 -r1.33.2.6 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.



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

2022-05-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri May 13 11:10:38 UTC 2022

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

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1443):

sys/arch/x86/x86/pmap.c: revision 1.414

return after calling xen_pagezero(), don't fall back to the legacy
pmap_zero_page() method.

This should only affect performances.


To generate a diff of this commit:
cvs rdiff -u -r1.334.2.6 -r1.334.2.7 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.



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

2022-05-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri May 13 11:10:38 UTC 2022

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

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1443):

sys/arch/x86/x86/pmap.c: revision 1.414

return after calling xen_pagezero(), don't fall back to the legacy
pmap_zero_page() method.

This should only affect performances.


To generate a diff of this commit:
cvs rdiff -u -r1.334.2.6 -r1.334.2.7 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.334.2.6 src/sys/arch/x86/x86/pmap.c:1.334.2.7
--- src/sys/arch/x86/x86/pmap.c:1.334.2.6	Fri Sep  3 10:27:33 2021
+++ src/sys/arch/x86/x86/pmap.c	Fri May 13 11:10:38 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.334.2.6 2021/09/03 10:27:33 martin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.334.2.7 2022/05/13 11:10:38 martin Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.334.2.6 2021/09/03 10:27:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.334.2.7 2022/05/13 11:10:38 martin Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -3187,8 +3187,10 @@ pmap_zero_page(paddr_t pa)
 	pagezero(PMAP_DIRECT_MAP(pa));
 #else
 #if defined(XENPV)
-	if (XEN_VERSION_SUPPORTED(3, 4))
+	if (XEN_VERSION_SUPPORTED(3, 4)) {
 		xen_pagezero(pa);
+		return;
+	}
 #endif
 	struct cpu_info *ci;
 	pt_entry_t *zpte;



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

2022-01-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 31 17:54:59 UTC 2022

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

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

sys/arch/x86/x86/procfs_machdep.c: revision 1.43
sys/arch/x86/x86/procfs_machdep.c: revision 1.44

Update for cpuid flags:
  - The table 11 was changed from CPUID 0x0f leaf 0 %edx to a Linux mapping.
  - The table 12 was changed from CPUID 0x0f leaf 1 %edx to CPUID 0x07 leaf 1
%edx. Print avx_vnni and avx512_bf16.
  - Print cppc, enqcmd and arch_lbr.
  - Modify linux mapping. No used on NetBSD.

Fix procfs_machdep.c rev. 1.143. Print CPUID 0x0007:1 %eax correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.33.2.4 -r1.33.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.33.2.4 src/sys/arch/x86/x86/procfs_machdep.c:1.33.2.5
--- src/sys/arch/x86/x86/procfs_machdep.c:1.33.2.4	Fri Dec  3 19:49:35 2021
+++ src/sys/arch/x86/x86/procfs_machdep.c	Mon Jan 31 17:54:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.33.2.4 2021/12/03 19:49:35 martin Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.33.2.5 2022/01/31 17:54:59 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.33.2.4 2021/12/03 19:49:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.33.2.5 2022/01/31 17:54:59 martin Exp $");
 
 #include 
 #include 
@@ -120,10 +120,8 @@ static const char * const x86_features[]
 	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",
+	"tpr_shadow", "vnmi", "flexpriority", "ept", "vpid", NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, "vmmcall",
 	NULL, "ept_ad", NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
@@ -141,15 +139,16 @@ static const char * const x86_features[]
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
-	{ /* (11) 0x000f:0 edx */
-	NULL, "cqm_llc", NULL, NULL, NULL, NULL, NULL, NULL,
+	{ /* (11) Linux mapping */
+	"cqm_llc", "cqm_occup_llc", "cqm_mbm_total", "cqm_mbm_local",
+	NULL, NULL, "split_lock_detect", 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},
 
-	{ /* (12) 0x000f:1 edx */
-	"cqm_occup_llc", "cqm_mbm_total", "cqm_mbm_local", NULL,
+	{ /* (12) Intel-defined 0x0007:1 eax */
 	NULL, NULL, NULL, NULL,
+	"avx_vnni", "avx512_bf16", 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},
@@ -158,7 +157,7 @@ static const char * const x86_features[]
 	"clzero", "irperf", "xsaveerptr", NULL, "rdpru", NULL, NULL, NULL,
 	NULL, "wbnoinvd", NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, "ppin",
-	NULL, "virt_ssbd", NULL, NULL, NULL, NULL, NULL, NULL},
+	NULL, "virt_ssbd", NULL, "cppc", NULL, NULL, NULL, NULL},
 
 	{ /* (14) 0x0006 eax */
 	"dtherm", "ida", "arat", NULL, "pln", NULL, "pts", "hwp",
@@ -181,7 +180,8 @@ static const char * const x86_features[]
 	"gfni", "vaes", "vpclmulqdq", "avx512_vnni",
 	"avx512_bitalg", "tme", "avx512_vpopcntdq", NULL,
 	"la57", NULL, NULL, NULL, NULL, NULL, "rdpid", NULL,
-	NULL, "cldemote", NULL, "movdiri", "movdir64b", NULL, "sgx_lc", NULL},
+	NULL, "cldemote", NULL, "movdiri",
+	"movdir64b", "enqcmd", "sgx_lc", NULL},
 
 	{ /* (17) 0x8007 ebx */
 	"overflow_recov", "succor", NULL, "smca", NULL, NULL, NULL, NULL,
@@ -192,7 +192,8 @@ static const char * const x86_features[]
 	{ /* (18) Intel 0x0007 edx */
 	NULL, NULL, "avx512_4vnniw", "avx512_4fmaps", "fsrm", NULL, NULL, NULL,
 	"vp2intersect", NULL, "md_clear", NULL, NULL, NULL, "serialize", NULL,
-	"tsxldtrk", NULL, "pconfig", NULL, NULL, NULL, NULL, "avx512_fp16",
+	"tsxldtrk", NULL, "pconfig", "arch_lbr",
+	NULL, NULL, NULL, "avx512_fp16",
 	NULL, NULL, NULL, NULL,
 	"flush_l1d", "arch_capabilities", NULL, "ssbd"},
 
@@ -307,14 +308,11 @@ procfs_getonecpufeatures(struct cpu_info
 		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_features[11] is Linux defined mapping */
 
-		x86_cpuid2(0x0f, 1, descs);
-		procfs_getonefeatreg(descs[3], x86_features[12], p 

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

2022-01-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 31 17:54:59 UTC 2022

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

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

sys/arch/x86/x86/procfs_machdep.c: revision 1.43
sys/arch/x86/x86/procfs_machdep.c: revision 1.44

Update for cpuid flags:
  - The table 11 was changed from CPUID 0x0f leaf 0 %edx to a Linux mapping.
  - The table 12 was changed from CPUID 0x0f leaf 1 %edx to CPUID 0x07 leaf 1
%edx. Print avx_vnni and avx512_bf16.
  - Print cppc, enqcmd and arch_lbr.
  - Modify linux mapping. No used on NetBSD.

Fix procfs_machdep.c rev. 1.143. Print CPUID 0x0007:1 %eax correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.33.2.4 -r1.33.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.



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

2021-12-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec  7 12:39:24 UTC 2021

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: identcpu.c

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

sys/arch/x86/x86/identcpu.c: revision 1.121

make a numeric literal unsigned as it is bit-negated.


To generate a diff of this commit:
cvs rdiff -u -r1.93.2.2 -r1.93.2.3 src/sys/arch/x86/x86/identcpu.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/identcpu.c
diff -u src/sys/arch/x86/x86/identcpu.c:1.93.2.2 src/sys/arch/x86/x86/identcpu.c:1.93.2.3
--- src/sys/arch/x86/x86/identcpu.c:1.93.2.2	Tue Dec  7 12:35:27 2021
+++ src/sys/arch/x86/x86/identcpu.c	Tue Dec  7 12:39:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: identcpu.c,v 1.93.2.2 2021/12/07 12:35:27 martin Exp $	*/
+/*	$NetBSD: identcpu.c,v 1.93.2.3 2021/12/07 12:39:23 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.93.2.2 2021/12/07 12:35:27 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.93.2.3 2021/12/07 12:39:23 martin Exp $");
 
 #include "opt_xen.h"
 
@@ -478,7 +478,7 @@ cpu_probe_cyrix_cmn(struct cpu_info *ci)
 	/* cyrix's workaround  for the "coma bug" */
 	cyrix_write_reg(0x31, cyrix_read_reg(0x31) | 0xf8);
 	cyrix_write_reg(0x32, cyrix_read_reg(0x32) | 0x7f);
-	cyrix_write_reg(0x33, cyrix_read_reg(0x33) & ~0xff);
+	cyrix_write_reg(0x33, cyrix_read_reg(0x33) & ~0xffu);
 	cyrix_write_reg(0x3c, cyrix_read_reg(0x3c) | 0x87);
 	/* disable access to ccr4/ccr5 */
 	cyrix_write_reg(0xC3, c3);



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

2021-12-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec  7 12:39:24 UTC 2021

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: identcpu.c

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

sys/arch/x86/x86/identcpu.c: revision 1.121

make a numeric literal unsigned as it is bit-negated.


To generate a diff of this commit:
cvs rdiff -u -r1.93.2.2 -r1.93.2.3 src/sys/arch/x86/x86/identcpu.c

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



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

2021-12-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec  7 12:35:27 UTC 2021

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: identcpu.c

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

sys/arch/x86/x86/identcpu.c: revision 1.103
sys/arch/x86/x86/identcpu.c: revision 1.104
sys/arch/x86/x86/identcpu.c: revision 1.105

Add EX2 for Vortex86 SoCs (Andrius V)

use __arraycount, and fix comparison

flip the comparison again


To generate a diff of this commit:
cvs rdiff -u -r1.93.2.1 -r1.93.2.2 src/sys/arch/x86/x86/identcpu.c

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



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

2021-12-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec  7 12:35:27 UTC 2021

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: identcpu.c

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

sys/arch/x86/x86/identcpu.c: revision 1.103
sys/arch/x86/x86/identcpu.c: revision 1.104
sys/arch/x86/x86/identcpu.c: revision 1.105

Add EX2 for Vortex86 SoCs (Andrius V)

use __arraycount, and fix comparison

flip the comparison again


To generate a diff of this commit:
cvs rdiff -u -r1.93.2.1 -r1.93.2.2 src/sys/arch/x86/x86/identcpu.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/identcpu.c
diff -u src/sys/arch/x86/x86/identcpu.c:1.93.2.1 src/sys/arch/x86/x86/identcpu.c:1.93.2.2
--- src/sys/arch/x86/x86/identcpu.c:1.93.2.1	Thu Sep 26 18:50:18 2019
+++ src/sys/arch/x86/x86/identcpu.c	Tue Dec  7 12:35:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: identcpu.c,v 1.93.2.1 2019/09/26 18:50:18 martin Exp $	*/
+/*	$NetBSD: identcpu.c,v 1.93.2.2 2021/12/07 12:35:27 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.93.2.1 2019/09/26 18:50:18 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.93.2.2 2021/12/07 12:35:27 martin Exp $");
 
 #include "opt_xen.h"
 
@@ -704,7 +704,7 @@ cpu_probe_vortex86(struct cpu_info *ci)
 #define PCI_MODE1_DATA_REG	0x0cfc
 #define PCI_MODE1_ENABLE	0x8000UL
 
-	uint32_t reg;
+	uint32_t reg, idx;
 
 	if (cpu_vendor != CPUVENDOR_VORTEX86)
 		return;
@@ -718,17 +718,18 @@ cpu_probe_vortex86(struct cpu_info *ci)
 	outl(PCI_MODE1_ADDRESS_REG, PCI_MODE1_ENABLE | 0x90);
 	reg = inl(PCI_MODE1_DATA_REG);
 
-	if ((reg & 0xf8ff) != 0x30504d44) {
-		reg = 0;
+	if ((reg & 0xf0ff) != 0x30504d44) {
+		idx = 0;
 	} else {
-		reg = (reg >> 24) & 7;
+		idx = (reg >> 24) & 0xf;
 	}
 
 	static const char *cpu_vortex86_flavor[] = {
-	"??", "SX", "DX", "MX", "DX2", "MX+", "DX3", "EX",
+	"??", "SX", "DX", "MX", "DX2", "MX+", "DX3", "EX", "EX2",
 	};
+	idx = idx < __arraycount(cpu_vortex86_flavor) ? idx : 0;
 	snprintf(cpu_brand_string, sizeof(cpu_brand_string), "Vortex86%s",
-	cpu_vortex86_flavor[reg]);
+	cpu_vortex86_flavor[idx]);
 
 #undef PCI_MODE1_ENABLE
 #undef PCI_MODE1_ADDRESS_REG



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

2021-12-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Dec  3 19:49:35 UTC 2021

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

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

sys/arch/x86/x86/procfs_machdep.c   1.40-1.42

- Add v_spec_ctrl, avx512_fp16, sme, sev, sev_es, sgx, sgx_lc,
  serialize and tsxldtrk.
- Whitespace fix.


To generate a diff of this commit:
cvs rdiff -u -r1.33.2.3 -r1.33.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.33.2.3 src/sys/arch/x86/x86/procfs_machdep.c:1.33.2.4
--- src/sys/arch/x86/x86/procfs_machdep.c:1.33.2.3	Fri Jul 10 10:36:56 2020
+++ src/sys/arch/x86/x86/procfs_machdep.c	Fri Dec  3 19:49:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.33.2.3 2020/07/10 10:36:56 martin Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.33.2.4 2021/12/03 19:49:35 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.33.2.3 2020/07/10 10:36:56 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.33.2.4 2021/12/03 19:49:35 martin Exp $");
 
 #include 
 #include 
@@ -82,11 +82,13 @@ static const char * const x86_features[]
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (3) Linux mapping */
-	"cxmmx", NULL, "cyrix_arr", "centaur_mcr", NULL,
-	"constant_tsc", 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},
+	"cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr", NULL, NULL, NULL, NULL,
+	"constant_tsc", "up", "art", "arch_perfmon",
+	"pebs", "bts", NULL, NULL,
+	"rep_good", NULL, NULL, "acc_power",
+	"nopl", NULL, "xtopology", "tsc_reliable",
+	"nonstop_tsc", "cpuid", "extd_apicid", "amd_dcm",
+	"aperfmperf", "rapl", "nonstop_tsc_s3", "tsc_known_freq"},
 
 	{ /* (4) Intel-defined: 0x0001 ecx */
 	"pni", "pclmulqdq", "dtes64", "monitor", "ds_cpl", "vmx", "smx", "est",
@@ -112,7 +114,7 @@ static const char * const x86_features[]
 
 	{ /* (7) Linux mapping */
 	NULL, NULL, "cpb", "ebp", NULL, "pln", "pts", "dtherm",
-	"hw_pstate", "proc_feedback", "sme", NULL,
+	"hw_pstate", "proc_feedback", NULL, NULL,
 	NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, "ibrs", "ibpb", "stibp", NULL, NULL, NULL, NULL},
@@ -126,7 +128,7 @@ static const char * const x86_features[]
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (9) Intel-defined: 0007 ebx */
-	"fsgsbase", "tsc_adjust", NULL, "bmi1", "hle", "avx2", NULL, "smep",
+	"fsgsbase", "tsc_adjust", "sgx", "bmi1", "hle", "avx2", NULL, "smep",
 	"bmi2", "erms", "invpcid", "rtm", "cqm", NULL, "mpx", "rdt_a",
 	"avx512f", "avx512dq", "rdseed", "adx",
 	"smap", "avx512ifma", NULL, "clflushopt",
@@ -165,12 +167,12 @@ static const char * const x86_features[]
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
-	{ /* (15) 0x800a edx */
+	{ /* (15) AMD 0x800a edx */
 	"npt", "lbrv", "svm_lock", "nrip_save",
 	"tsc_scale", "vmcb_clean", "flushbyasid", "decodeassists",
 	NULL, NULL, "pausefilter", NULL, "pfthreshold", "avic", NULL,
 	"v_vmsave_vmload",
-	"vgif", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	"vgif", NULL, NULL, NULL, "v_spec_ctrl", NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (16) 0x0007:0 ecx */
@@ -179,7 +181,7 @@ static const char * const x86_features[]
 	"gfni", "vaes", "vpclmulqdq", "avx512_vnni",
 	"avx512_bitalg", "tme", "avx512_vpopcntdq", NULL,
 	"la57", NULL, NULL, NULL, NULL, NULL, "rdpid", NULL,
-	NULL, "cldemote", NULL, "movdiri", "movdir64b", NULL, NULL, NULL},
+	NULL, "cldemote", NULL, "movdiri", "movdir64b", NULL, "sgx_lc", NULL},
 
 	{ /* (17) 0x8007 ebx */
 	"overflow_recov", "succor", NULL, "smca", NULL, NULL, NULL, NULL,
@@ -189,10 +191,16 @@ static const char * const x86_features[]
 
 	{ /* (18) Intel 0x0007 edx */
 	NULL, NULL, "avx512_4vnniw", "avx512_4fmaps", "fsrm", NULL, NULL, NULL,
-	"vp2intersect", NULL, "md_clear", NULL, NULL, NULL, NULL, NULL,
-	NULL, NULL, "pconfig", NULL, NULL, NULL, NULL, NULL,
+	"vp2intersect", NULL, "md_clear", NULL, NULL, NULL, "serialize", NULL,
+	"tsxldtrk", NULL, "pconfig", NULL, NULL, NULL, NULL, "avx512_fp16",
 	NULL, NULL, NULL, NULL,
 	"flush_l1d", "arch_capabilities", NULL, "ssbd"},
+
+	{ /* (19) AMD 0x801f eax */
+	"sme", "sev", NULL, "sev_es", 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},
 };
 
 static int	procfs_getonecpu(int, struct cpu_info *, char *, size_t *);
@@ 

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

2021-12-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Dec  3 19:49:35 UTC 2021

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

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

sys/arch/x86/x86/procfs_machdep.c   1.40-1.42

- Add v_spec_ctrl, avx512_fp16, sme, sev, sev_es, sgx, sgx_lc,
  serialize and tsxldtrk.
- Whitespace fix.


To generate a diff of this commit:
cvs rdiff -u -r1.33.2.3 -r1.33.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.



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

2021-09-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep  3 10:27:33 UTC 2021

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

Log Message:
Pull up following revision(s) (requested by manu in ticket #1341):

sys/arch/x86/x86/pmap.c: revision 1.410

Make pat_init() a NOOP on XENPV; it causes a trap with Xen 4.15


To generate a diff of this commit:
cvs rdiff -u -r1.334.2.5 -r1.334.2.6 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.334.2.5 src/sys/arch/x86/x86/pmap.c:1.334.2.6
--- src/sys/arch/x86/x86/pmap.c:1.334.2.5	Thu Sep  3 13:45:24 2020
+++ src/sys/arch/x86/x86/pmap.c	Fri Sep  3 10:27:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.334.2.5 2020/09/03 13:45:24 martin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.334.2.6 2021/09/03 10:27:33 martin Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.334.2.5 2020/09/03 13:45:24 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.334.2.6 2021/09/03 10:27:33 martin Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -806,6 +806,7 @@ pmap_exec_fixup(struct vm_map *map, stru
 void
 pat_init(struct cpu_info *ci)
 {
+#ifndef XENPV
 	uint64_t pat;
 
 	if (!(ci->ci_feat_val[0] & CPUID_PAT))
@@ -819,6 +820,7 @@ pat_init(struct cpu_info *ci)
 
 	wrmsr(MSR_CR_PAT, pat);
 	cpu_pat_enabled = true;
+#endif
 }
 
 static pt_entry_t



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

2021-09-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep  3 10:27:33 UTC 2021

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

Log Message:
Pull up following revision(s) (requested by manu in ticket #1341):

sys/arch/x86/x86/pmap.c: revision 1.410

Make pat_init() a NOOP on XENPV; it causes a trap with Xen 4.15


To generate a diff of this commit:
cvs rdiff -u -r1.334.2.5 -r1.334.2.6 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.



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

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

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

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

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.146.2.1 -r1.146.2.2 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.146.2.1 src/sys/arch/x86/x86/intr.c:1.146.2.2
--- src/sys/arch/x86/x86/intr.c:1.146.2.1	Mon Nov 11 17:20:00 2019
+++ src/sys/arch/x86/x86/intr.c	Fri Feb 19 17:47:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.146.2.1 2019/11/11 17:20:00 martin Exp $	*/
+/*	$NetBSD: intr.c,v 1.146.2.2 2021/02/19 17:47:13 martin Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.146.2.1 2019/11/11 17:20:00 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.146.2.2 2021/02/19 17:47:13 martin Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -704,6 +704,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
@@ -1042,12 +1045,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-9] src/sys/arch/x86/x86

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

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

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

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.146.2.1 -r1.146.2.2 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.



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

2020-09-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep  3 13:45:24 UTC 2020

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

Log Message:
Apply patch, requested by bouyer in ticket #1075:

sys/arch/x86/x86/pmap.c (apply patch)

Fix double count on ptp entries in pmap_enter_gnt(), which causes a KASSERT
at pmap_destroy() time. Call pmap_free_ptp() if needed. We can have a 0 wire
count if we had an old mapping and grant map hypercall failed,
and this was the only page in this ptp.

while there remove ptp != NULL checks for gnt operations: we always have
a ptp here.


To generate a diff of this commit:
cvs rdiff -u -r1.334.2.4 -r1.334.2.5 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.



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

2020-09-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep  3 13:45:24 UTC 2020

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

Log Message:
Apply patch, requested by bouyer in ticket #1075:

sys/arch/x86/x86/pmap.c (apply patch)

Fix double count on ptp entries in pmap_enter_gnt(), which causes a KASSERT
at pmap_destroy() time. Call pmap_free_ptp() if needed. We can have a 0 wire
count if we had an old mapping and grant map hypercall failed,
and this was the only page in this ptp.

while there remove ptp != NULL checks for gnt operations: we always have
a ptp here.


To generate a diff of this commit:
cvs rdiff -u -r1.334.2.4 -r1.334.2.5 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.334.2.4 src/sys/arch/x86/x86/pmap.c:1.334.2.5
--- src/sys/arch/x86/x86/pmap.c:1.334.2.4	Wed Sep  2 12:40:06 2020
+++ src/sys/arch/x86/x86/pmap.c	Thu Sep  3 13:45:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.334.2.4 2020/09/02 12:40:06 martin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.334.2.5 2020/09/03 13:45:24 martin Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.334.2.4 2020/09/02 12:40:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.334.2.5 2020/09/03 13:45:24 martin Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -4559,28 +4559,21 @@ pmap_enter_gnt(struct pmap *pmap, vaddr_
 	if (__predict_false(op->status != GNTST_okay)) {
 		printf("%s: GNTTABOP_map_grant_ref status: %d\n",
 		__func__, op->status);
-		if (ptp != NULL) {
-			if (have_oldpa) {
-ptp->wire_count--;
-			}
+		if (have_oldpa) {
+			ptp->wire_count--;
 		}
 	} else {
 		pgnt->pd_gnt_refs++;
-		if (ptp != NULL) {
-			if (!have_oldpa) {
-ptp->wire_count++;
-			}
+		if (!have_oldpa) {
+			ptp->wire_count++;
 		}
+		KASSERT(ptp->wire_count > 1);
 	}
 
 	/*
 	 * Update statistics and PTP's reference count.
 	 */
 	pmap_stats_update_bypte(pmap, 0, opte);
-	if (ptp != NULL && !have_oldpa) {
-		ptp->wire_count++;
-	}
-	KASSERT(ptp == NULL || ptp->wire_count > 1);
 
 	/*
 	 * If old page is pv-tracked, remove pv_entry from its list.
@@ -4599,6 +4592,8 @@ pmap_enter_gnt(struct pmap *pmap, vaddr_
 		old_pve = pmap_remove_pv(old_pp, ptp, va);
 		old_pp->pp_attrs |= pmap_pte_to_pp_attrs(opte);
 	}
+	if (ptp->wire_count <= 1)
+		pmap_free_ptp(pmap, ptp, va, ptes, pdes);
 
 	pmap_unmap_ptes(pmap, pmap2);
 
@@ -4687,7 +4682,7 @@ pmap_remove_gnt(struct pmap *pmap, vaddr
 		 * being used, free it!
 		 */
 
-		if (ptp && ptp->wire_count <= 1)
+		if (ptp->wire_count <= 1)
 			pmap_free_ptp(pmap, ptp, va, ptes, pdes);
 	}
 	pmap_unmap_ptes(pmap, pmap2); /* unlock pmap */



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

2020-09-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep  2 12:40:06 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1073):

sys/arch/x86/x86/pmap.c: revision 1.404

Fix braino in pmap_find_gnt(), really return the gnt entry covering the range
and not one that starts just after.

Fixes a KASSERT in pmap_remove_gnt().


To generate a diff of this commit:
cvs rdiff -u -r1.334.2.3 -r1.334.2.4 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.334.2.3 src/sys/arch/x86/x86/pmap.c:1.334.2.4
--- src/sys/arch/x86/x86/pmap.c:1.334.2.3	Sun Jun  7 12:54:39 2020
+++ src/sys/arch/x86/x86/pmap.c	Wed Sep  2 12:40:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.334.2.3 2020/06/07 12:54:39 martin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.334.2.4 2020/09/02 12:40:06 martin Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.334.2.3 2020/06/07 12:54:39 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.334.2.4 2020/09/02 12:40:06 martin Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -4408,7 +4408,7 @@ pmap_find_gnt(struct pmap *pmap, vaddr_t
 	headp = pmap->pm_data;
 	KASSERT(headp != NULL);
 	SLIST_FOREACH(pgnt, headp, pd_gnt_list) {
-		if (pgnt->pd_gnt_sva >= sva && pgnt->pd_gnt_sva <= eva)
+		if (pgnt->pd_gnt_sva <= sva && eva <= pgnt->pd_gnt_eva)
 			return pgnt;
 		/* check that we're not overlapping part of a region */
 		KASSERT(pgnt->pd_gnt_sva >= eva || pgnt->pd_gnt_eva <= sva);



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

2020-09-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep  2 12:40:06 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1073):

sys/arch/x86/x86/pmap.c: revision 1.404

Fix braino in pmap_find_gnt(), really return the gnt entry covering the range
and not one that starts just after.

Fixes a KASSERT in pmap_remove_gnt().


To generate a diff of this commit:
cvs rdiff -u -r1.334.2.3 -r1.334.2.4 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.



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

2020-08-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug  2 07:33:38 UTC 2020

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

Log Message:
Apply patch, requested by msaitoh in ticket #1031:

sys/arch/x86/x86/cpu.c  patch

Fix a panic on a CPU which has no rdtsc instruction. This bug was
added in ticket #1015.


To generate a diff of this commit:
cvs rdiff -u -r1.171.2.2 -r1.171.2.3 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.171.2.2 src/sys/arch/x86/x86/cpu.c:1.171.2.3
--- src/sys/arch/x86/x86/cpu.c:1.171.2.2	Wed Jul 15 17:25:08 2020
+++ src/sys/arch/x86/x86/cpu.c	Sun Aug  2 07:33:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.171.2.2 2020/07/15 17:25:08 martin Exp $	*/
+/*	$NetBSD: cpu.c,v 1.171.2.3 2020/08/02 07:33:38 martin Exp $	*/
 
 /*
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.171.2.2 2020/07/15 17:25:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.171.2.3 2020/08/02 07:33:38 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -1267,18 +1267,19 @@ cpu_get_tsc_freq(struct cpu_info *ci)
 {
 	uint64_t freq = 0, last_tsc;
 
-	if (cpu_hascounter())
+	if (cpu_hascounter()) {
 		freq = cpu_tsc_freq_cpuid(ci);
 
-	if (freq != 0) {
-		/* Use TSC frequency taken from CPUID. */
-		ci->ci_data.cpu_cc_freq = freq;
-	} else {
-		/* Calibrate TSC frequency. */
-		last_tsc = cpu_counter_serializing();
-		x86_delay(10);
-		ci->ci_data.cpu_cc_freq =
-		(cpu_counter_serializing() - last_tsc) * 10;
+		if (freq != 0) {
+			/* Use TSC frequency taken from CPUID. */
+			ci->ci_data.cpu_cc_freq = freq;
+		} else {
+			/* Calibrate TSC frequency. */
+			last_tsc = cpu_counter_serializing();
+			x86_delay(10);
+			ci->ci_data.cpu_cc_freq =
+			(cpu_counter_serializing() - last_tsc) * 10;
+		}
 	}
 }
 



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

2020-08-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug  2 07:33:38 UTC 2020

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

Log Message:
Apply patch, requested by msaitoh in ticket #1031:

sys/arch/x86/x86/cpu.c  patch

Fix a panic on a CPU which has no rdtsc instruction. This bug was
added in ticket #1015.


To generate a diff of this commit:
cvs rdiff -u -r1.171.2.2 -r1.171.2.3 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.



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

2020-07-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jul 15 14:02:36 UTC 2020

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

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

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.36 -r1.36.4.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.36 src/sys/arch/x86/x86/coretemp.c:1.36.4.1
--- src/sys/arch/x86/x86/coretemp.c:1.36	Wed Jul 11 03:36:32 2018
+++ src/sys/arch/x86/x86/coretemp.c	Wed Jul 15 14:02:36 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: coretemp.c,v 1.36 2018/07/11 03:36:32 msaitoh Exp $ */
+/* $NetBSD: coretemp.c,v 1.36.4.1 2020/07/15 14:02:36 martin Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: coretemp.c,v 1.36 2018/07/11 03:36:32 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coretemp.c,v 1.36.4.1 2020/07/15 14:02:36 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-9] src/sys/arch/x86/x86

2020-07-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jul 15 14:02:36 UTC 2020

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

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

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.36 -r1.36.4.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.



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

2020-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jul 10 10:36:56 UTC 2020

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

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

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.33.2.2 -r1.33.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.33.2.2 src/sys/arch/x86/x86/procfs_machdep.c:1.33.2.3
--- src/sys/arch/x86/x86/procfs_machdep.c:1.33.2.2	Tue Apr 14 17:15:02 2020
+++ src/sys/arch/x86/x86/procfs_machdep.c	Fri Jul 10 10:36:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.33.2.2 2020/04/14 17:15:02 martin Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.33.2.3 2020/07/10 10:36:56 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.33.2.2 2020/04/14 17:15:02 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.33.2.3 2020/07/10 10:36:56 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-9] src/sys/arch/x86/x86

2020-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jul 10 10:36:56 UTC 2020

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

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

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.33.2.2 -r1.33.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.



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

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

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

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

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.9.4.1 -r1.9.4.2 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.



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

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

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

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

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.9.4.1 -r1.9.4.2 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.9.4.1 src/sys/arch/x86/x86/cpu_rng.c:1.9.4.2
--- src/sys/arch/x86/x86/cpu_rng.c:1.9.4.1	Fri Nov  1 18:17:55 2019
+++ src/sys/arch/x86/x86/cpu_rng.c	Sat Jun 20 16:03:35 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_rng.c,v 1.9.4.1 2019/11/01 18:17:55 martin Exp $ */
+/* $NetBSD: cpu_rng.c,v 1.9.4.2 2020/06/20 16:03:35 martin Exp $ */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -142,6 +142,7 @@ exhausted:
 static size_t
 cpu_rng_via(cpu_rng_t *out)
 {
+	u_long psl;
 	uint32_t creg0, rndsts;
 
 	/*
@@ -155,9 +156,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 */
@@ -171,7 +172,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-9] src/sys/arch/x86/x86

2020-06-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jun  7 12:54:39 UTC 2020

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

Log Message:
Apply patch, requested by bouyer in ticket #941:

sys/arch/x86/x86/pmap.c (apply patch)

Fix Xen dom0 kernel build with options DIAGNOSTIC.


To generate a diff of this commit:
cvs rdiff -u -r1.334.2.2 -r1.334.2.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.334.2.2 src/sys/arch/x86/x86/pmap.c:1.334.2.3
--- src/sys/arch/x86/x86/pmap.c:1.334.2.2	Sun May 31 10:39:35 2020
+++ src/sys/arch/x86/x86/pmap.c	Sun Jun  7 12:54:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.334.2.2 2020/05/31 10:39:35 martin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.334.2.3 2020/06/07 12:54:39 martin Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.334.2.2 2020/05/31 10:39:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.334.2.3 2020/06/07 12:54:39 martin Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -4461,7 +4461,7 @@ pmap_free_gnt(struct pmap *pmap, struct 
 	struct pmap_data_gnt_head *headp = pmap->pm_data;
 	int nentries = (pgnt->pd_gnt_eva - pgnt->pd_gnt_sva) / PAGE_SIZE;
 	KASSERT(nentries >= 1);
-	KASSERT(mutex_owned(>pm_lock));
+	KASSERT(mutex_owned(pmap->pm_lock));
 	KASSERT(pgnt->pd_gnt_refs == 0);
 	SLIST_REMOVE(headp, pgnt, pmap_data_gnt, pd_gnt_list);
 	kmem_free(pgnt, sizeof(*pgnt) +



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

2020-06-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jun  7 12:54:39 UTC 2020

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

Log Message:
Apply patch, requested by bouyer in ticket #941:

sys/arch/x86/x86/pmap.c (apply patch)

Fix Xen dom0 kernel build with options DIAGNOSTIC.


To generate a diff of this commit:
cvs rdiff -u -r1.334.2.2 -r1.334.2.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.



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

2020-05-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon May 25 15:39:54 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #922):

sys/arch/x86/x86/cpu_topology.c: revision 1.18

assert smt_bits value only after it is computed.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.14.4.1 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.



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

2020-05-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon May 25 15:39:54 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #922):

sys/arch/x86/x86/cpu_topology.c: revision 1.18

assert smt_bits value only after it is computed.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.14.4.1 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.14 src/sys/arch/x86/x86/cpu_topology.c:1.14.4.1
--- src/sys/arch/x86/x86/cpu_topology.c:1.14	Wed Nov 21 10:34:53 2018
+++ src/sys/arch/x86/x86/cpu_topology.c	Mon May 25 15:39:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_topology.c,v 1.14 2018/11/21 10:34:53 msaitoh Exp $	*/
+/*	$NetBSD: cpu_topology.c,v 1.14.4.1 2020/05/25 15:39:54 martin Exp $	*/
 
 /*-
  * Copyright (c) 2009 Mindaugas Rasiukevicius ,
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.14 2018/11/21 10:34:53 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.14.4.1 2020/05/25 15:39:54 martin Exp $");
 
 #include 
 #include 
@@ -157,8 +157,9 @@ x86_cpu_topology(struct cpu_info *ci)
 		x86_cpuid(0x801e, descs);
 		const u_int threads = ((descs[1] >> 8) & 0xff) + 1;
 
-		KASSERT(smt_bits == 0 && smt_bits <= core_bits);
+		KASSERT(smt_bits == 0);
 		smt_bits = ilog2(threads);
+		KASSERT(smt_bits <= core_bits);
 		core_bits -= smt_bits;
 	}
 



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

2020-01-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jan 21 11:36:37 UTC 2020

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

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

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.171 -r1.171.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.



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

2020-01-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jan 21 11:36:37 UTC 2020

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

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

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.171 -r1.171.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.171 src/sys/arch/x86/x86/cpu.c:1.171.2.1
--- src/sys/arch/x86/x86/cpu.c:1.171	Wed May 29 16:54:41 2019
+++ src/sys/arch/x86/x86/cpu.c	Tue Jan 21 11:36:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.171 2019/05/29 16:54:41 maxv Exp $	*/
+/*	$NetBSD: cpu.c,v 1.171.2.1 2020/01/21 11:36:36 martin Exp $	*/
 
 /*
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.171 2019/05/29 16:54:41 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.171.2.1 2020/01/21 11:36:36 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -521,6 +521,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-9] src/sys/arch/x86/x86

2019-12-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Dec 29 09:33:43 UTC 2019

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: x86_machdep.c

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

sys/arch/x86/x86/x86_machdep.c: revision 1.134

to know this in order to set module_machine correctly, which in turn is
needed to set the module_base path from which modules are loaded and
which provides the value of sysctl(8) variable kern.module.path

Thanks to jnemeth@ for pointing out the problem.


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.127.2.1 src/sys/arch/x86/x86/x86_machdep.c

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



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

2019-12-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Dec 29 09:33:43 UTC 2019

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: x86_machdep.c

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

sys/arch/x86/x86/x86_machdep.c: revision 1.134

to know this in order to set module_machine correctly, which in turn is
needed to set the module_base path from which modules are loaded and
which provides the value of sysctl(8) variable kern.module.path

Thanks to jnemeth@ for pointing out the problem.


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.127.2.1 src/sys/arch/x86/x86/x86_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/x86_machdep.c
diff -u src/sys/arch/x86/x86/x86_machdep.c:1.127 src/sys/arch/x86/x86/x86_machdep.c:1.127.2.1
--- src/sys/arch/x86/x86/x86_machdep.c:1.127	Wed May 29 16:54:41 2019
+++ src/sys/arch/x86/x86/x86_machdep.c	Sun Dec 29 09:33:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_machdep.c,v 1.127 2019/05/29 16:54:41 maxv Exp $	*/
+/*	$NetBSD: x86_machdep.c,v 1.127.2.1 2019/12/29 09:33:43 martin Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,13 +31,14 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.127 2019/05/29 16:54:41 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.127.2.1 2019/12/29 09:33:43 martin Exp $");
 
 #include "opt_modular.h"
 #include "opt_physmem.h"
 #include "opt_splash.h"
 #include "opt_kaslr.h"
 #include "opt_svs.h"
+#include "opt_xen.h"
 
 #include 
 #include 



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

2019-12-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec 17 12:56:45 UTC 2019

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: bus_space.c

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

sys/arch/x86/x86/bus_space.c: revision 1.42
sys/arch/x86/x86/bus_space.c: revision 1.43

Use LFENCE/SFENCE/MFENCE in x86 bus_space_barrier.

These are needed for BUS_SPACE_MAP_PREFETCHABLE mappings.  On x86,
these are WC-type memory regions, which means -- unlike normal
WB-type memory regions -- loads can be reordered with loads,
requiring LFENCE, and stores can be reordered with stores, requiring
SFENCE.

Reference: AMD64 Architecture Programmer's Manual, Volume 2: System
Programming, Sec. 7.4.1 `Memory Barrier Interaction with Memory
Types', Table 7-3 `Memory Access Ordering Rules'.

Skip fences in bus_space_barrier on I/O space.

I/O operations are issued in program order.  Not that I/O operations
are usually a performance bottleneck anyway, but maybe it is slightly
cheaper to avoid stalling on store buffers or pending loads, and
there's very little cost to the skipping criterion here.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.41.4.1 src/sys/arch/x86/x86/bus_space.c

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



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

2019-12-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec 17 12:56:45 UTC 2019

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: bus_space.c

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

sys/arch/x86/x86/bus_space.c: revision 1.42
sys/arch/x86/x86/bus_space.c: revision 1.43

Use LFENCE/SFENCE/MFENCE in x86 bus_space_barrier.

These are needed for BUS_SPACE_MAP_PREFETCHABLE mappings.  On x86,
these are WC-type memory regions, which means -- unlike normal
WB-type memory regions -- loads can be reordered with loads,
requiring LFENCE, and stores can be reordered with stores, requiring
SFENCE.

Reference: AMD64 Architecture Programmer's Manual, Volume 2: System
Programming, Sec. 7.4.1 `Memory Barrier Interaction with Memory
Types', Table 7-3 `Memory Access Ordering Rules'.

Skip fences in bus_space_barrier on I/O space.

I/O operations are issued in program order.  Not that I/O operations
are usually a performance bottleneck anyway, but maybe it is slightly
cheaper to avoid stalling on store buffers or pending loads, and
there's very little cost to the skipping criterion here.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.41.4.1 src/sys/arch/x86/x86/bus_space.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/bus_space.c
diff -u src/sys/arch/x86/x86/bus_space.c:1.41 src/sys/arch/x86/x86/bus_space.c:1.41.4.1
--- src/sys/arch/x86/x86/bus_space.c:1.41	Mon Feb 11 14:59:33 2019
+++ src/sys/arch/x86/x86/bus_space.c	Tue Dec 17 12:56:45 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_space.c,v 1.41 2019/02/11 14:59:33 cherry Exp $	*/
+/*	$NetBSD: bus_space.c,v 1.41.4.1 2019/12/17 12:56:45 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.41 2019/02/11 14:59:33 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.41.4.1 2019/12/17 12:56:45 martin Exp $");
 
 #include 
 #include 
@@ -878,7 +878,43 @@ bus_space_barrier(bus_space_tag_t tag, b
 		  bus_size_t offset, bus_size_t len, int flags)
 {
 
-	/* Function call is enough to prevent reordering of loads. */
+	/* I/O instructions always happen in program order.  */
+	if (x86_bus_space_is_io(tag))
+		return;
+
+	/*
+	 * For default mappings, which are mapped with UC-type memory
+	 * regions, all loads and stores are issued in program order.
+	 *
+	 * For BUS_SPACE_MAP_PREFETCHABLE mappings, which are mapped
+	 * with WC-type memory regions, loads and stores may be issued
+	 * out of order, potentially requiring any of the three x86
+	 * fences -- LFENCE, SFENCE, MFENCE.
+	 *
+	 * For BUS_SPACE_MAP_CACHEABLE mappings, which are mapped with
+	 * WB-type memory regions (like normal memory), store/load may
+	 * be reordered to load/store, potentially requiring MFENCE.
+	 *
+	 * We can't easily tell here how the region was mapped (without
+	 * consulting the page tables), so just issue the fence
+	 * unconditionally.  Chances are either it's necessary or the
+	 * cost is small in comparison to device register I/O.
+	 */
+	switch (flags) {
+	case 0:
+		break;
+	case BUS_SPACE_BARRIER_READ:
+		x86_lfence();
+		break;
+	case BUS_SPACE_BARRIER_WRITE:
+		x86_sfence();
+		break;
+	case BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE:
+		x86_mfence();
+		break;
+	default:
+		panic("unknown bus space barrier: 0x%x", (unsigned)flags);
+	}
 }
 
 void *



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

2019-12-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Dec 14 12:24:23 UTC 2019

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: spectre.c

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

sys/arch/x86/x86/spectre.c: revision 1.32

Check CPUID.IBRS in addition to ARCH_CAP.IBRS_ALL. For clarity, and also
because VirtualBox clears the former but forgets to clear the latter (which
makes us hit a #GP on RDMSR).


To generate a diff of this commit:
cvs rdiff -u -r1.29.2.2 -r1.29.2.3 src/sys/arch/x86/x86/spectre.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/spectre.c
diff -u src/sys/arch/x86/x86/spectre.c:1.29.2.2 src/sys/arch/x86/x86/spectre.c:1.29.2.3
--- src/sys/arch/x86/x86/spectre.c:1.29.2.2	Tue Nov 12 18:24:37 2019
+++ src/sys/arch/x86/x86/spectre.c	Sat Dec 14 12:24:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: spectre.c,v 1.29.2.2 2019/11/12 18:24:37 martin Exp $	*/
+/*	$NetBSD: spectre.c,v 1.29.2.3 2019/12/14 12:24:23 martin Exp $	*/
 
 /*
  * Copyright (c) 2018-2019 NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.29.2.2 2019/11/12 18:24:37 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.29.2.3 2019/12/14 12:24:23 martin Exp $");
 
 #include "opt_spectre.h"
 
@@ -126,20 +126,20 @@ v2_detect_method(void)
 		if (cpuid_level >= 7) {
 			x86_cpuid(7, descs);
 
-			if (descs[3] & CPUID_SEF_ARCH_CAP) {
-msr = rdmsr(MSR_IA32_ARCH_CAPABILITIES);
-if (msr & IA32_ARCH_IBRS_ALL) {
-	v2_mitigation_method =
-	V2_MITIGATION_INTEL_ENHANCED_IBRS;
-	return;
+			if (descs[3] & CPUID_SEF_IBRS) {
+if (descs[3] & CPUID_SEF_ARCH_CAP) {
+	msr = rdmsr(MSR_IA32_ARCH_CAPABILITIES);
+	if (msr & IA32_ARCH_IBRS_ALL) {
+		v2_mitigation_method =
+		V2_MITIGATION_INTEL_ENHANCED_IBRS;
+		return;
+	}
 }
-			}
 #ifdef __x86_64__
-			if (descs[3] & CPUID_SEF_IBRS) {
 v2_mitigation_method = V2_MITIGATION_INTEL_IBRS;
 return;
-			}
 #endif
+			}
 		}
 		v2_mitigation_method = V2_MITIGATION_NONE;
 	} else if (cpu_vendor == CPUVENDOR_AMD) {



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

2019-12-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Dec 14 12:24:23 UTC 2019

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: spectre.c

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

sys/arch/x86/x86/spectre.c: revision 1.32

Check CPUID.IBRS in addition to ARCH_CAP.IBRS_ALL. For clarity, and also
because VirtualBox clears the former but forgets to clear the latter (which
makes us hit a #GP on RDMSR).


To generate a diff of this commit:
cvs rdiff -u -r1.29.2.2 -r1.29.2.3 src/sys/arch/x86/x86/spectre.c

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



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

2019-11-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov 11 17:20:00 UTC 2019

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

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

sys/arch/x86/x86/intr.c: revision 1.147

 Fix a bug that evcnt_detach() called twice when the idt vector is full.

OK'd by knakahara.


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.146.2.1 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.



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

2019-11-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov 11 17:20:00 UTC 2019

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

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

sys/arch/x86/x86/intr.c: revision 1.147

 Fix a bug that evcnt_detach() called twice when the idt vector is full.

OK'd by knakahara.


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.146.2.1 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.146 src/sys/arch/x86/x86/intr.c:1.146.2.1
--- src/sys/arch/x86/x86/intr.c:1.146	Mon Jun 17 06:38:30 2019
+++ src/sys/arch/x86/x86/intr.c	Mon Nov 11 17:20:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.146 2019/06/17 06:38:30 msaitoh Exp $	*/
+/*	$NetBSD: intr.c,v 1.146.2.1 2019/11/11 17:20:00 martin Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.146 2019/06/17 06:38:30 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.146.2.1 2019/11/11 17:20:00 martin Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -475,8 +475,10 @@ intr_free_io_intrsource_direct(struct in
 	SIMPLEQ_REMOVE(_interrupt_sources, isp, intrsource, is_list);
 
 	/* Is this interrupt established? */
-	if (isp->is_evname[0] != '\0')
+	if (isp->is_evname[0] != '\0') {
 		evcnt_detach(>is_evcnt);
+		isp->is_evname[0] = '\0';
+	}
 
 	kmem_free(isp->is_saved_evcnt,
 	sizeof(*(isp->is_saved_evcnt)) * ncpu);
@@ -679,6 +681,7 @@ intr_allocate_slot(struct pic *pic, int 
 	}
 	if (idtvec == 0) {
 		evcnt_detach(>ci_isources[slot]->is_evcnt);
+		ci->ci_isources[slot]->is_evname[0] = '\0';
 		ci->ci_isources[slot] = NULL;
 		return EBUSY;
 	}



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

2019-11-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Nov  1 18:17:55 UTC 2019

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

Log Message:
Pull up following revision(s) (requested by taca in ticket #390):

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

Check CPU support of RDRAND before calling cpu_rng_rdrand().
cpu_earlyrng() checks CPU support of RDSEED and RDRAND before calling
cpu_rng_rdseed() and cpu_rng_rdrand().

But cpu_rng_rdseed() did not check CPU support of RDRAND and system had
crashed on such an environment.  There is no such case with real CPU but
some VM environment.

Fix kern/54655 and confirmed by msaitoh@.
Needs pullup to netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.9.4.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.



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

2019-11-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Nov  1 18:17:55 UTC 2019

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

Log Message:
Pull up following revision(s) (requested by taca in ticket #390):

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

Check CPU support of RDRAND before calling cpu_rng_rdrand().
cpu_earlyrng() checks CPU support of RDSEED and RDRAND before calling
cpu_rng_rdseed() and cpu_rng_rdrand().

But cpu_rng_rdseed() did not check CPU support of RDRAND and system had
crashed on such an environment.  There is no such case with real CPU but
some VM environment.

Fix kern/54655 and confirmed by msaitoh@.
Needs pullup to netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.9.4.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.9 src/sys/arch/x86/x86/cpu_rng.c:1.9.4.1
--- src/sys/arch/x86/x86/cpu_rng.c:1.9	Wed Aug 22 12:07:43 2018
+++ src/sys/arch/x86/x86/cpu_rng.c	Fri Nov  1 18:17:55 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_rng.c,v 1.9 2018/08/22 12:07:43 maxv Exp $ */
+/* $NetBSD: cpu_rng.c,v 1.9.4.1 2019/11/01 18:17:55 martin Exp $ */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -53,6 +53,8 @@ static enum {
 	CPU_RNG_VIA
 } cpu_rng_mode __read_mostly = CPU_RNG_NONE;
 
+static bool has_rdrand;
+
 bool
 cpu_rng_init(void)
 {
@@ -131,7 +133,10 @@ cpu_rng_rdseed(cpu_rng_t *out)
 	 * to be seeded even in this case.
 	 */
 exhausted:
-	return cpu_rng_rdrand(out);
+	if (has_rdrand)
+		return cpu_rng_rdrand(out);
+	else
+		return 0;
 }
 
 static size_t
@@ -213,7 +218,7 @@ cpu_earlyrng(void *out, size_t sz)
 	int i;
 
 	bool has_rdseed = (cpu_feature[5] & CPUID_SEF_RDSEED) != 0;
-	bool has_rdrand = (cpu_feature[1] & CPUID2_RDRAND) != 0;
+	has_rdrand = (cpu_feature[1] & CPUID2_RDRAND) != 0;
 
 	KASSERT(sz + sizeof(uint64_t) <= SHA512_DIGEST_LENGTH);