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

2018-11-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Nov 18 19:39:50 UTC 2018

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

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

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.6.4.3 -r1.6.4.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.6.4.3 src/sys/arch/x86/x86/procfs_machdep.c:1.6.4.4
--- src/sys/arch/x86/x86/procfs_machdep.c:1.6.4.3	Mon Sep 11 05:50:12 2017
+++ src/sys/arch/x86/x86/procfs_machdep.c	Sun Nov 18 19:39:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.6.4.3 2017/09/11 05:50:12 snj Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.6.4.4 2018/11/18 19:39:49 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.6.4.3 2017/09/11 05:50:12 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.6.4.4 2018/11/18 19:39:49 martin Exp $");
 
 #include 
 #include 
@@ -359,9 +359,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-7] src/sys/arch/x86/x86

2018-01-03 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Jan  3 20:17:40 UTC 2018

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

Log Message:
Apply patch (requested by maxv in ticket #1531):
amd64: Make the direct map non executable.


To generate a diff of this commit:
cvs rdiff -u -r1.183.2.6 -r1.183.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.183.2.6 src/sys/arch/x86/x86/pmap.c:1.183.2.7
--- src/sys/arch/x86/x86/pmap.c:1.183.2.6	Mon Mar  6 03:27:19 2017
+++ src/sys/arch/x86/x86/pmap.c	Wed Jan  3 20:17:40 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.183.2.6 2017/03/06 03:27:19 snj Exp $	*/
+/*	$NetBSD: pmap.c,v 1.183.2.7 2018/01/03 20:17:40 snj Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.183.2.6 2017/03/06 03:27:19 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.183.2.7 2018/01/03 20:17:40 snj Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -1523,7 +1523,7 @@ pmap_bootstrap(vaddr_t kva_start)
 		}
 	}
 
-	kpm->pm_pdir[PDIR_SLOT_DIRECT] = dmpdp | PG_KW | PG_V | PG_U;
+	kpm->pm_pdir[PDIR_SLOT_DIRECT] = dmpdp | PG_KW | PG_V | PG_U | pg_nx;
 
 	tlbflush();
 



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

2017-12-12 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Dec 12 09:12:57 UTC 2017

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

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1540):
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.9 -r1.9.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.9 src/sys/arch/x86/x86/fpu.c:1.9.8.1
--- src/sys/arch/x86/x86/fpu.c:1.9	Tue Feb 25 22:16:52 2014
+++ src/sys/arch/x86/x86/fpu.c	Tue Dec 12 09:12:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.9 2014/02/25 22:16:52 dsl Exp $	*/
+/*	$NetBSD: fpu.c,v 1.9.8.1 2017/12/12 09:12:57 snj Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.  All
@@ -100,7 +100,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.9 2014/02/25 22:16:52 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.9.8.1 2017/12/12 09:12:57 snj Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -617,6 +617,7 @@ process_write_fpregs_xmm(struct lwp *lwp
 		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-7] src/sys/arch/x86/x86

2017-09-10 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Sep 11 05:50:12 UTC 2017

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

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1505):
sys/arch/x86/x86/procfs_machdep.c: 1.15-1.16
- Print 0x0007:0 ecx leaf bits.
- Don't print fdiv_bug on amd64.
- Print APIC ID, Initial APIC ID and clflush size.
--
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.6.4.2 -r1.6.4.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.6.4.2 src/sys/arch/x86/x86/procfs_machdep.c:1.6.4.3
--- src/sys/arch/x86/x86/procfs_machdep.c:1.6.4.2	Thu Dec  8 08:06:38 2016
+++ src/sys/arch/x86/x86/procfs_machdep.c	Mon Sep 11 05:50:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.6.4.2 2016/12/08 08:06:38 snj Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.6.4.3 2017/09/11 05:50:12 snj Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.6.4.2 2016/12/08 08:06:38 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.6.4.3 2017/09/11 05:50:12 snj Exp $");
 
 #include 
 #include 
@@ -131,7 +131,7 @@ static const char * const x86_features[]
 	"clwb", NULL, "avx512pf", "avx512er",
 	"avx512cd", "sha_ni", "avx512bw", "avx512vl"},
 
-	{ /* (10) 000d eax */
+	{ /* (10) 0x000d 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,
@@ -148,6 +148,38 @@ 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},
+
+	{ /* (13) 0x8008 ebx */
+	"clzero", "irperf", 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, NULL, NULL},
+
+	{ /* (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, NULL, NULL, NULL, NULL, NULL},
+
+	{ /* (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, 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,
+	"la57", NULL, NULL, NULL, NULL, NULL, "rdpid", NULL,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+
+	{ /* (17) 0x8007 ebx */
+	"overflow_recov", "succor", "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, NULL},
 };
 
 static int	procfs_getonecpu(int, struct cpu_info *, char *, size_t *);
@@ -171,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;
@@ -246,9 +278,18 @@ procfs_getonecpufeatures(struct cpu_info
 	left);
 	diff = last - *left;
 
-	/* (10) 000d eax */
+	/* (10) 0x000d eax */
 	/* (11) 0x000f(ecx=0) edx */
 	/* (12) 0x000f(ecx=1) edx */
+	/* (13) 0x8008 ebx */
+	/* (14) 0x0006 eax */
+	/* (15) 0x800a edx */
+
+	procfs_getonefeatreg(ci->ci_feat_val[6], x86_features[16], p + diff,
+	left);
+	diff = last - *left;
+
+	/* (17) 0x8007 ebx */
 
 	return 0; /* XXX */
 }
@@ -318,17 +359,36 @@ 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,
+	ci->ci_initapicid
+	);
+	size += l;
+	if (l < left) {
+		left -= l;
+		p += l;
+	} else
+		left = 0;
+
+	l = snprintf(p, left,
+#ifdef __i386__
 	"fdiv_bug\t: %s\n"
+#endif
 	"fpu\t\t: %s\n"
 	"fpu_exception\t: yes\n"
 	"cpuid level\t: %d\n"
 	"wp\t\t: %s\n"
-	"flags\t\t: %s\n",
+	"flags\t\t: %s\n"
+	"clflush size\t: %d\n",
+#ifdef __i386__
 	i386_fpu_fdivbug ? "yes" : "no",	/* an old pentium */
+#endif
 	i386_fpu_present ? "yes" : "no",	/* not a 486SX */
 	cpuid_level,
 	(rcr0() & CR0_WP) ? "yes" : 

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

2016-12-08 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Dec  8 08:06:38 UTC 2016

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

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1293):
sys/arch/x86/x86/procfs_machdep.c: revisions 1.12-1.14
Update for x86 /proc/cpuinfo:
- Add ptsc, avx512dq, avx512bw, avx512vl and rdt_a.
- Update VIA/Cyrix/Centaur-defined bits. Part of PR#39950.
- Remove pcommit.
- Update some Linux mapping unused in /proc/cpuinfo.


To generate a diff of this commit:
cvs rdiff -u -r1.6.4.1 -r1.6.4.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.6.4.1 src/sys/arch/x86/x86/procfs_machdep.c:1.6.4.2
--- src/sys/arch/x86/x86/procfs_machdep.c:1.6.4.1	Sun Mar  6 17:58:22 2016
+++ src/sys/arch/x86/x86/procfs_machdep.c	Thu Dec  8 08:06:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.6.4.1 2016/03/06 17:58:22 martin Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.6.4.2 2016/12/08 08:06:38 snj Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.6.4.1 2016/03/06 17:58:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.6.4.2 2016/12/08 08:06:38 snj Exp $");
 
 #include 
 #include 
@@ -61,13 +61,13 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_machd
  *  x86/include/asm/cpufeatures.h.
  */
 static const char * const x86_features[][32] = {
-	{ /* (0) Common */
+	{ /* (0) Common: 0x001 edx */
 	"fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
 	"cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
 	"pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx",
 	"fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe"},
 
-	{ /* (1) AMD-defined: 8001 edx */
+	{ /* (1) AMD-defined: 0x8001 edx */
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL,
@@ -86,7 +86,7 @@ static const char * const x86_features[]
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
-	{ /* (4) Intel-defined: 8001 ecx */
+	{ /* (4) Intel-defined: 0x0001 ecx */
 	"pni", "pclmulqdq", "dtes64", "monitor", "ds_cpl", "vmx", "smx", "est",
 	"tm2", "ssse3", "cid", "sdbg", "fma", "cx16", "xtpr", "pdcm",
 	NULL, "pcid", "dca", "sse4_1", "sse4_2", "x2apic", "movbe", "popcnt",
@@ -95,7 +95,7 @@ static const char * const x86_features[]
 
 	{ /* (5) VIA/Cyrix/Centaur-defined */
 	NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	"ace2", "ace2_en", "phe", "phe_en", "pmm", "pmm_en", NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
@@ -105,12 +105,13 @@ static const char * const x86_features[]
 	"3dnowprefetch", "osvw", "ibs", "xop", "skinit", "wdt", NULL, "lwp",
 	"fma4", "tce", NULL, "nodeid_msr",
 	NULL, "tbm", "topoext", "perfctr_core",
-	"perfctr_nb", NULL, "bpext", NULL, "perfctr_l2", "mwaitx", NULL, NULL},
+	"perfctr_nb", NULL, "bpext", "ptsc",
+	"perfctr_l2", "mwaitx", NULL, NULL},
 
 	{ /* (7) Linux mapping */
-	"ida", "arat", "cpb", "ebp", NULL, "pln", "pts", "dtherm",
-	"hw_pstate", "proc_feedback", "hwp", "hwp_notify", "hwp_act_window",
-	"hwp_epp", "hwp_pkg_req", "intel_pt",
+	NULL, NULL, "cpb", "ebp", NULL, "pln", "pts", "dtherm",
+	"hw_pstate", "proc_feedback", NULL, NULL,
+	NULL, NULL, NULL, "intel_pt",
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
@@ -124,11 +125,11 @@ static const char * const x86_features[]
 
 	{ /* (9) Intel-defined: 0007 ebx */
 	"fsgsbase", "tsc_adjust", NULL, "bmi1", "hle", "avx2", NULL, "smep",
-	"bmi2", "erms", "invpcid", "rtm", "cqm", NULL, "mpx", NULL,
-	"avx512f", NULL, "rdseed", "adx",
-	"smap", NULL, "pcommit", "clflushopt",
+	"bmi2", "erms", "invpcid", "rtm", "cqm", NULL, "mpx", "rdt_a",
+	"avx512f", "avx512dq", "rdseed", "adx",
+	"smap", NULL, NULL, "clflushopt",
 	"clwb", NULL, "avx512pf", "avx512er",
-	"avx512cd", "sha_ni", NULL, NULL},
+	"avx512cd", "sha_ni", "avx512bw", "avx512vl"},
 
 	{ /* (10) 000d eax */
 	"xsaveopt", "xsavec", "xgetbv1", "xsaves", NULL, NULL, NULL, NULL,



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

2016-03-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar  6 17:58:22 UTC 2016

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

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

sys/arch/x86/x86/procfs_machdep.c   1.7-1.11

x86's /proc/cpuinfo fixes:
- Always output 2 digits for the cpu frequency decimal part.
- Update x86's feature bits in /proc/cpuinfo (PR#49246).
- Fix a bug that /proc/cpuinfo's CPU model was incorrect on many newer
  CPUs and CPU family was incorrect on some AMD CPUs.
- Add comment. Fix comment.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.4.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.6 src/sys/arch/x86/x86/procfs_machdep.c:1.6.4.1
--- src/sys/arch/x86/x86/procfs_machdep.c:1.6	Sat Apr  5 18:43:09 2014
+++ src/sys/arch/x86/x86/procfs_machdep.c	Sun Mar  6 17:58:22 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.6 2014/04/05 18:43:09 christos Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.6.4.1 2016/03/06 17:58:22 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.6 2014/04/05 18:43:09 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.6.4.1 2016/03/06 17:58:22 martin Exp $");
 
 #include 
 #include 
@@ -56,50 +56,97 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_machd
 #include 
 #include 
 
-static const char * const x86_features[] = {
-	/* Intel-defined */
+/*
+ *  The feature table. The order is the same as Linux's
+ *  x86/include/asm/cpufeatures.h.
+ */
+static const char * const x86_features[][32] = {
+	{ /* (0) Common */
 	"fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
 	"cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
 	"pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx",
-	"fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", NULL,
-#ifdef __x86_64__
-	/* AMD-defined */
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
-	NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL, 
-	NULL, NULL, NULL, NULL, "nx", NULL, "mmxext", NULL, 
-	NULL, "fxsr_opt", "rdtscp", NULL, NULL, "lm", "3dnowext", "3dnow",
-
-	/* Transmeta-defined */
-	"recovery", "longrun", NULL, "lrti", 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, 
-
-	/* Linux-defined */
-	"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, 
-
-	/* Intel-defined */
-	"pni", NULL, NULL, "monitor", "ds_cpi", "vmx", NULL, "est", 
-	"tm2", NULL, "cid", NULL, NULL, "cx16", "xtpr", NULL, 
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
-
-	/* VIA/Cyrix/Centaur-defined */
-	NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en", 
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
-
-	/* AMD defined */
-	"lahf_lm", "cmp_legacy", "svm", NULL, "cr8_legacy", 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, 
-#endif
+	"fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe"},
+
+	{ /* (1) AMD-defined: 8001 edx */
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL,
+	NULL, "fxsr_opt", "pdpe1gb", "rdtscp", NULL, "lm", "3dnowext","3dnow"},
+
+	{ /* (2) Transmeta-defined */
+	"recovery", "longrun", NULL, "lrti", 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},
+
+	{ /* (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},
+
+	{ /* (4) Intel-defined: 8001 ecx */
+	"pni", "pclmulqdq", "dtes64", "monitor", "ds_cpl", "vmx", "smx", "est",
+	"tm2", "ssse3", "cid", "sdbg", "fma", "cx16", "xtpr", "pdcm",
+	NULL, "pcid", "dca", "sse4_1", "sse4_2", "x2apic", "movbe", "popcnt",
+	"tsc_deadline_timer", "aes", "xsave", NULL,
+	"avx", "f16c", "rdrand", "hypervisor"},
+
+	{ /* (5) VIA/Cyrix/Centaur-defined */
+	NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
+	NULL, NULL, NULL, NULL, NULL, NULL, 

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

2016-02-26 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Feb 26 21:50:54 UTC 2016

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

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1100):
sys/arch/x86/x86/pmap.c: revision 1.190
Operation pmap_pp_clear_attrs() may remove the "used" attribute from a page
that is still cached in the TLB of other CPUs.
Call pmap_tlb_shootnow() here before enabling preemption to clear the
TLB entries on other CPUs.
Should prevent tmpfs data corruption under load.
Ok: Chuck Silvers


To generate a diff of this commit:
cvs rdiff -u -r1.183.2.3 -r1.183.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.183.2.3 src/sys/arch/x86/x86/pmap.c:1.183.2.4
--- src/sys/arch/x86/x86/pmap.c:1.183.2.3	Fri Feb 12 10:55:35 2016
+++ src/sys/arch/x86/x86/pmap.c	Fri Feb 26 21:50:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.183.2.3 2016/02/12 10:55:35 snj Exp $	*/
+/*	$NetBSD: pmap.c,v 1.183.2.4 2016/02/26 21:50:54 snj Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.183.2.3 2016/02/12 10:55:35 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.183.2.4 2016/02/26 21:50:54 snj Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -3867,6 +3867,7 @@ startover:
 	}
 	result = pp->pp_attrs & clearbits;
 	pp->pp_attrs &= ~clearbits;
+	pmap_tlb_shootnow();
 	kpreempt_enable();
 
 	return result != 0;



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

2016-02-12 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Feb 12 10:55:35 UTC 2016

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

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1115):
sys/arch/x86/x86/pmap.c: patch
Use IPL_NONE for pserialized lock.  Assert sleepable.  (OOPS.)


To generate a diff of this commit:
cvs rdiff -u -r1.183.2.2 -r1.183.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.183.2.2 src/sys/arch/x86/x86/pmap.c:1.183.2.3
--- src/sys/arch/x86/x86/pmap.c:1.183.2.2	Thu Apr 23 07:31:16 2015
+++ src/sys/arch/x86/x86/pmap.c	Fri Feb 12 10:55:35 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.183.2.2 2015/04/23 07:31:16 snj Exp $	*/
+/*	$NetBSD: pmap.c,v 1.183.2.3 2016/02/12 10:55:35 snj Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.183.2.2 2015/04/23 07:31:16 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.183.2.3 2016/02/12 10:55:35 snj Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -490,7 +490,7 @@ void
 pmap_pv_init(void)
 {
 
-	mutex_init(_unmanaged.lock, MUTEX_DEFAULT, IPL_VM);
+	mutex_init(_unmanaged.lock, MUTEX_DEFAULT, IPL_NONE);
 	pv_unmanaged.psz = pserialize_create();
 	pv_unmanaged.list = NULL;
 }
@@ -504,6 +504,9 @@ pmap_pv_track(paddr_t start, psize_t siz
 	KASSERT(start == trunc_page(start));
 	KASSERT(size == trunc_page(size));
 
+	/* We may sleep for allocation.  */
+	ASSERT_SLEEPABLE();
+
 	npages = size >> PAGE_SHIFT;
 	pvt = kmem_zalloc(offsetof(struct pv_track, pvt_pages[npages]),
 	KM_SLEEP);
@@ -526,6 +529,9 @@ pmap_pv_untrack(paddr_t start, psize_t s
 	KASSERT(start == trunc_page(start));
 	KASSERT(size == trunc_page(size));
 
+	/* We may sleep for pserialize_perform.  */
+	ASSERT_SLEEPABLE();
+
 	mutex_enter(_unmanaged.lock);
 	for (pvtp = _unmanaged.list;
 	 (pvt = *pvtp) != NULL;



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

2015-11-07 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sun Nov  8 00:38:45 UTC 2015

Modified Files:
src/sys/arch/x86/x86 [netbsd-7]: sys_machdep.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #1013):
sys/arch/x86/x86/sys_machdep.c: revision 1.29
fix broken error handling; error was used uninitialized. Changing the
compilation flags broke all threaded programs for me.
XXX: pullup-7


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.28.2.1 src/sys/arch/x86/x86/sys_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/sys_machdep.c
diff -u src/sys/arch/x86/x86/sys_machdep.c:1.28 src/sys/arch/x86/x86/sys_machdep.c:1.28.2.1
--- src/sys/arch/x86/x86/sys_machdep.c:1.28	Sat Jun 28 21:13:12 2014
+++ src/sys/arch/x86/x86/sys_machdep.c	Sun Nov  8 00:38:45 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_machdep.c,v 1.28 2014/06/28 21:13:12 dholland Exp $	*/
+/*	$NetBSD: sys_machdep.c,v 1.28.2.1 2015/11/08 00:38:45 riz Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.28 2014/06/28 21:13:12 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.28.2.1 2015/11/08 00:38:45 riz Exp $");
 
 #include "opt_mtrr.h"
 #include "opt_perfctrs.h"
@@ -659,7 +659,6 @@ x86_set_sdbase(void *arg, char which, lw
 #else
 	struct pcb *pcb;
 	vaddr_t base;
-	int error;
 
 	if (l->l_proc->p_flag & PK_32) {
 		return x86_set_sdbase32(arg, which, l, direct);
@@ -668,7 +667,7 @@ x86_set_sdbase(void *arg, char which, lw
 	if (direct) {
 		base = (vaddr_t)arg;
 	} else {
-		error = copyin(arg, , sizeof(base));
+		int error = copyin(arg, , sizeof(base));
 		if (error != 0)
 			return error;
 	}
@@ -676,10 +675,6 @@ x86_set_sdbase(void *arg, char which, lw
 	if (base >= VM_MAXUSER_ADDRESS)
 		return EINVAL;
 
-	if (error) {
-		return error;
-	}
-
 	pcb = lwp_getpcb(l);
 
 	kpreempt_disable();
@@ -699,7 +694,7 @@ x86_set_sdbase(void *arg, char which, lw
 	}
 	kpreempt_enable();
 
-	return error;
+	return 0;
 #endif
 }
 



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

2015-11-07 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sun Nov  8 00:31:00 UTC 2015

Modified Files:
src/sys/arch/x86/x86 [netbsd-7]: bus_dma.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #1011):
sys/arch/x86/x86/bus_dma.c: revision 1.72
sys/arch/x86/x86/bus_dma.c: revision 1.73
sys/arch/x86/x86/bus_dma.c: revision 1.74
- If we succeeded allocating a buffer that did not need bouncing before, but
  the buffer in the previous mapping did, clear the bounce bit. Fixes the
  ld_virtio.c bug with machines 8GB and dd if=/dev/zero of=crash bs=1g count=4.
- Allocate with M_ZERO instead of doing memset
- The panic string can take a format, use it.
- When checking for the bounce buffer boundary check addr + len < limit, not
  addr < limit.
make sure we have a cookie before we try to clear it.
fix operator precedence.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.71.4.1 src/sys/arch/x86/x86/bus_dma.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_dma.c
diff -u src/sys/arch/x86/x86/bus_dma.c:1.71 src/sys/arch/x86/x86/bus_dma.c:1.71.4.1
--- src/sys/arch/x86/x86/bus_dma.c:1.71	Tue Dec 24 15:42:56 2013
+++ src/sys/arch/x86/x86/bus_dma.c	Sun Nov  8 00:31:00 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma.c,v 1.71 2013/12/24 15:42:56 christos Exp $	*/
+/*	$NetBSD: bus_dma.c,v 1.71.4.1 2015/11/08 00:31:00 riz Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2007 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.71 2013/12/24 15:42:56 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.71.4.1 2015/11/08 00:31:00 riz Exp $");
 
 /*
  * The following is included because _bus_dma_uiomove is derived from
@@ -291,11 +291,10 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 	error = 0;
 	mapsize = sizeof(struct x86_bus_dmamap) +
 	(sizeof(bus_dma_segment_t) * (nsegments - 1));
-	if ((mapstore = malloc(mapsize, M_DMAMAP,
-	(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL)
+	if ((mapstore = malloc(mapsize, M_DMAMAP, M_ZERO |
+	((flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK))) == NULL)
 		return (ENOMEM);
 
-	memset(mapstore, 0, mapsize);
 	map = (struct x86_bus_dmamap *)mapstore;
 	map->_dm_size = size;
 	map->_dm_segcnt = nsegments;
@@ -331,12 +330,11 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 	/*
 	 * Allocate our cookie.
 	 */
-	if ((cookiestore = malloc(cookiesize, M_DMAMAP,
-	(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL) {
+	if ((cookiestore = malloc(cookiesize, M_DMAMAP, M_ZERO |
+	((flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK))) == NULL) {
 		error = ENOMEM;
 		goto out;
 	}
-	memset(cookiestore, 0, cookiesize);
 	cookie = (struct x86_bus_dma_cookie *)cookiestore;
 	cookie->id_flags = cookieflags;
 	map->_dm_cookie = cookie;
@@ -399,6 +397,8 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dm
 	}
 	error = _bus_dmamap_load_buffer(t, map, buf, buflen, vm, flags);
 	if (error == 0) {
+		if (cookie != NULL)
+			cookie->id_flags &= ~X86_DMA_IS_BOUNCING;
 		map->dm_mapsize = buflen;
 		return 0;
 	}
@@ -797,7 +797,7 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm
 	 */
 	if ((ops & (BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)) != 0 &&
 	(ops & (BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)) != 0)
-		panic("_bus_dmamap_sync: mix PRE and POST");
+		panic("%s: mix PRE and POST", __func__);
 
 #ifdef DIAGNOSTIC
 	if ((ops & (BUS_DMASYNC_PREWRITE|BUS_DMASYNC_POSTREAD)) != 0) {
@@ -927,16 +927,17 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm
 	}
 
 	case X86_DMA_BUFTYPE_RAW:
-		panic("_bus_dmamap_sync: X86_DMA_BUFTYPE_RAW");
+		panic("%s: X86_DMA_BUFTYPE_RAW", __func__);
 		break;
 
 	case X86_DMA_BUFTYPE_INVALID:
-		panic("_bus_dmamap_sync: X86_DMA_BUFTYPE_INVALID");
+		panic("%s: X86_DMA_BUFTYPE_INVALID", __func__);
 		break;
 
 	default:
-		printf("unknown buffer type %d\n", cookie->id_buftype);
-		panic("_bus_dmamap_sync");
+		panic("%s: unknown buffer type %d", __func__,
+		cookie->id_buftype);
+		break;
 	}
 end:
 	if (ops & (BUS_DMASYNC_PREWRITE|BUS_DMASYNC_POSTWRITE)) {
@@ -1244,19 +1245,20 @@ _bus_dmamap_load_buffer(bus_dma_tag_t t,
 		curaddr = _BUS_VIRT_TO_BUS(pmap, vaddr);
 
 		/*
+		 * Compute the segment size, and adjust counts.
+		 */
+		sgsize = PAGE_SIZE - ((u_long)vaddr & PGOFSET);
+		if (buflen < sgsize)
+			sgsize = buflen;
+
+		/*
 		 * If we're beyond the bounce threshold, notify
 		 * the caller.
 		 */
 		if (map->_dm_bounce_thresh != 0 &&
-		curaddr >= map->_dm_bounce_thresh)
+		curaddr + sgsize >= map->_dm_bounce_thresh)
 			return (EINVAL);
 
-		/*
-		 * Compute the segment size, and adjust counts.
-		 */
-		sgsize = PAGE_SIZE - ((u_long)vaddr & PGOFSET);
-		if (buflen < sgsize)
-			sgsize = buflen;
 
 		error = _bus_dmamap_load_busaddr(t, map, curaddr, sgsize);
 		if (error)



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

2015-11-06 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Fri Nov  6 22:50:56 UTC 2015

Modified Files:
src/sys/arch/x86/x86 [netbsd-7]: cpu_ucode_intel.c

Log Message:
Pull up following revision(s) (requested by jym in ticket #994):
sys/arch/x86/x86/cpu_ucode_intel.c: revision 1.10
sys/arch/x86/x86/cpu_ucode_intel.c: revision 1.9
kmem_free() the address returned by kmem_alloc().  found by Brainy.
use the newly aligned location if we needed it.  found by kre.
Cache CPU index in the non-preemptible part otherwise it can be
unreliable (and report a CPU as patched while it was not).


To generate a diff of this commit:
cvs rdiff -u -r1.5.4.2 -r1.5.4.3 src/sys/arch/x86/x86/cpu_ucode_intel.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_ucode_intel.c
diff -u src/sys/arch/x86/x86/cpu_ucode_intel.c:1.5.4.2 src/sys/arch/x86/x86/cpu_ucode_intel.c:1.5.4.3
--- src/sys/arch/x86/x86/cpu_ucode_intel.c:1.5.4.2	Tue Aug 11 05:13:44 2015
+++ src/sys/arch/x86/x86/cpu_ucode_intel.c	Fri Nov  6 22:50:56 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_ucode_intel.c,v 1.5.4.2 2015/08/11 05:13:44 snj Exp $ */
+/* $NetBSD: cpu_ucode_intel.c,v 1.5.4.3 2015/11/06 22:50:56 riz Exp $ */
 /*
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_intel.c,v 1.5.4.2 2015/08/11 05:13:44 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_intel.c,v 1.5.4.3 2015/11/06 22:50:56 riz Exp $");
 
 #include "opt_xen.h"
 #include "opt_cpu_ucode.h"
@@ -109,8 +109,9 @@ int
 cpu_ucode_intel_apply(struct cpu_ucode_softc *sc, int cpuno)
 {
 	uint32_t ucodetarget, oucodeversion, nucodeversion;
-	int platformid;
+	int platformid, cpuid;
 	struct intel1_ucode_header *uh;
+	void *uha;
 	size_t newbufsize = 0;
 	int rv = 0;
 
@@ -126,12 +127,12 @@ cpu_ucode_intel_apply(struct cpu_ucode_s
 	if ((uintptr_t)(sc->sc_blob) & 15) {
 		/* Make the buffer 16 byte aligned */
 		newbufsize = sc->sc_blobsize + 15;
-		uh = kmem_alloc(newbufsize, KM_SLEEP);
-		if (uh == NULL) {
+		uha = kmem_alloc(newbufsize, KM_SLEEP);
+		if (uha == NULL) {
 			printf("%s: memory allocation failed\n", __func__);
 			return EINVAL;
 		}
-		uh = (struct intel1_ucode_header *)roundup2((uintptr_t)uh, 16);
+		uh = (struct intel1_ucode_header *)roundup2((uintptr_t)uha, 16);
 		/* Copy to the new area */
 		memcpy(uh, sc->sc_blob, sc->sc_blobsize);
 	}
@@ -144,8 +145,9 @@ cpu_ucode_intel_apply(struct cpu_ucode_s
 		rv = EEXIST; /* ??? */
 		goto out;
 	}
-	wrmsr(MSR_BIOS_UPDT_TRIG, (uintptr_t)(sc->sc_blob) + 48);
+	wrmsr(MSR_BIOS_UPDT_TRIG, (uintptr_t)uh + 48);
 	intel_getcurrentucode(, );
+	cpuid = curcpu()->ci_index;
 
 	kpreempt_enable();
 
@@ -154,11 +156,11 @@ cpu_ucode_intel_apply(struct cpu_ucode_s
 		goto out;
 	}
 
-	printf("cpu %d: ucode 0x%x->0x%x\n", curcpu()->ci_index,
+	printf("cpu %d: ucode 0x%x->0x%x\n", cpuid,
 	   oucodeversion, nucodeversion);
 out:
 	if (newbufsize != 0)
-		kmem_free(uh, newbufsize);
+		kmem_free(uha, newbufsize);
 	return rv;
 }
 #endif /* ! XEN */



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

2015-11-05 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Fri Nov  6 00:40:02 UTC 2015

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

Log Message:
Pull up following revision(s) (requested by nat in ticket #984):
sys/arch/x86/x86/cpu.c: revision 1.116
Don't disable/re-enable interrupts if they are already disabled.
Addresses PR 48196.
This commit was improved and approved by christos@


To generate a diff of this commit:
cvs rdiff -u -r1.111.2.1 -r1.111.2.2 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.111.2.1 src/sys/arch/x86/x86/cpu.c:1.111.2.2
--- src/sys/arch/x86/x86/cpu.c:1.111.2.1	Mon Jan 12 21:06:41 2015
+++ src/sys/arch/x86/x86/cpu.c	Fri Nov  6 00:40:02 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.111.2.1 2015/01/12 21:06:41 snj Exp $	*/
+/*	$NetBSD: cpu.c,v 1.111.2.2 2015/11/06 00:40:02 riz Exp $	*/
 
 /*-
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.111.2.1 2015/01/12 21:06:41 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.111.2.2 2015/11/06 00:40:02 riz Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -1278,6 +1278,7 @@ cpu_load_pmap(struct pmap *pmap, struct 
 {
 #ifdef PAE
 	struct cpu_info *ci = curcpu();
+	bool interrupts_enabled;
 	pd_entry_t *l3_pd = ci->ci_pae_l3_pdir;
 	int i;
 
@@ -1286,11 +1287,16 @@ cpu_load_pmap(struct pmap *pmap, struct 
 	 * while this doesn't block NMIs, it's probably ok as NMIs unlikely
 	 * reload cr3.
 	 */
-	x86_disable_intr();
+	interrupts_enabled = (x86_read_flags() & PSL_I) != 0;
+	if (interrupts_enabled)
+		x86_disable_intr();
+
 	for (i = 0 ; i < PDP_SIZE; i++) {
 		l3_pd[i] = pmap->pm_pdirpa[i] | PG_V;
 	}
-	x86_enable_intr();
+	
+	if (interrupts_enabled)
+		x86_enable_intr();
 	tlbflush();
 #else /* PAE */
 	lcr3(pmap_pdirpa(pmap, 0));



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

2015-08-10 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Aug 11 05:07:16 UTC 2015

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

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #948):
sys/arch/x86/x86/mpacpi.c: revisions 1.99, 1.100
sys/arch/x86/x86/lapic.c: revision 1.49
- Add lapic_dump() to print lapic's setting.
- Add mpacpi_dump() to dump mp_intrs[].
--
Configure ioapic before lapic because lapic(lapic_set_lvt()) checks the
existence of ioapic. This change fixes a problem that some machines hang
after attaching ehci (little after writing EHCI_USBINTR to enable interrupt).
Even though cold == 1, LAPIC_LVINT0 was not set as masked. Perhaps it's the
reason of the problem.
This problem was observed on SuperMicro X10SLX-F, X10SDV-TLN4F and
Shuttle DS57U without wm(4) driver.


To generate a diff of this commit:
cvs rdiff -u -r1.47.4.1 -r1.47.4.2 src/sys/arch/x86/x86/lapic.c
cvs rdiff -u -r1.97 -r1.97.10.1 src/sys/arch/x86/x86/mpacpi.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.47.4.1 src/sys/arch/x86/x86/lapic.c:1.47.4.2
--- src/sys/arch/x86/x86/lapic.c:1.47.4.1	Fri May 22 16:53:32 2015
+++ src/sys/arch/x86/x86/lapic.c	Tue Aug 11 05:07:16 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: lapic.c,v 1.47.4.1 2015/05/22 16:53:32 snj Exp $	*/
+/*	$NetBSD: lapic.c,v 1.47.4.2 2015/08/11 05:07:16 snj Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: lapic.c,v 1.47.4.1 2015/05/22 16:53:32 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: lapic.c,v 1.47.4.2 2015/08/11 05:07:16 snj Exp $);
 
 #include opt_ddb.h
 #include opt_mpbios.h		/* for MPDEBUG */
@@ -76,6 +76,8 @@ static void 	lapic_map(paddr_t);
 static void lapic_hwmask(struct pic *, int);
 static void lapic_hwunmask(struct pic *, int);
 static void lapic_setup(struct pic *, struct cpu_info *, int, int, int);
+/* Make it public to call via ddb */
+void	lapic_dump(void);
 
 struct pic local_pic = {
 	.pic_name = lapic,
@@ -194,18 +196,8 @@ lapic_set_lvt(void)
 	}
 
 #ifdef MULTIPROCESSOR
-	if (mp_verbose) {
-		apic_format_redir (device_xname(ci-ci_dev), timer, 0, 0,
-		i82489_readreg(LAPIC_LVTT));
-		apic_format_redir (device_xname(ci-ci_dev), pcint, 0, 0,
-		i82489_readreg(LAPIC_PCINT));
-		apic_format_redir (device_xname(ci-ci_dev), lint, 0, 0,
-		i82489_readreg(LAPIC_LVINT0));
-		apic_format_redir (device_xname(ci-ci_dev), lint, 1, 0,
-		i82489_readreg(LAPIC_LVINT1));
-		apic_format_redir (device_xname(ci-ci_dev), err, 0, 0,
-		i82489_readreg(LAPIC_LVERR));
-	}
+	if (mp_verbose)
+		lapic_dump();
 #endif
 }
 
@@ -616,3 +608,20 @@ lapic_setup(struct pic *pic, struct cpu_
 int pin, int idtvec, int type)
 {
 }
+
+void
+lapic_dump(void)
+{
+	struct cpu_info *ci = curcpu();
+
+	apic_format_redir (device_xname(ci-ci_dev), timer, 0, 0,
+	i82489_readreg(LAPIC_LVTT));
+	apic_format_redir (device_xname(ci-ci_dev), pcint, 0, 0,
+	i82489_readreg(LAPIC_PCINT));
+	apic_format_redir (device_xname(ci-ci_dev), lint, 0, 0,
+	i82489_readreg(LAPIC_LVINT0));
+	apic_format_redir (device_xname(ci-ci_dev), lint, 1, 0,
+	i82489_readreg(LAPIC_LVINT1));
+	apic_format_redir (device_xname(ci-ci_dev), err, 0, 0,
+	i82489_readreg(LAPIC_LVERR));
+}

Index: src/sys/arch/x86/x86/mpacpi.c
diff -u src/sys/arch/x86/x86/mpacpi.c:1.97 src/sys/arch/x86/x86/mpacpi.c:1.97.10.1
--- src/sys/arch/x86/x86/mpacpi.c:1.97	Mon Mar 25 01:30:37 2013
+++ src/sys/arch/x86/x86/mpacpi.c	Tue Aug 11 05:07:16 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpacpi.c,v 1.97 2013/03/25 01:30:37 chs Exp $	*/
+/*	$NetBSD: mpacpi.c,v 1.97.10.1 2015/08/11 05:07:16 snj Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,10 +36,11 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: mpacpi.c,v 1.97 2013/03/25 01:30:37 chs Exp $);
+__KERNEL_RCSID(0, $NetBSD: mpacpi.c,v 1.97.10.1 2015/08/11 05:07:16 snj Exp $);
 
 #include acpica.h
 #include opt_acpi.h
+#include opt_ddb.h
 #include opt_mpbios.h
 #include opt_multiprocessor.h
 #include pchb.h
@@ -123,6 +124,10 @@ static void mpacpi_print_isa_intr(int);
 
 static void mpacpi_user_continue(const char *fmt, ...);
 
+#ifdef DDB
+void mpacpi_dump(void);
+#endif
+
 int mpacpi_nioapic;			/* number of ioapics */
 int mpacpi_ncpu;			/* number of cpus */
 int mpacpi_nintsrc;			/* number of non-device interrupts */
@@ -447,6 +452,8 @@ mpacpi_scan_apics(device_t self, int *nc
 	mpacpi_ncpu = mpacpi_nintsrc = mpacpi_nioapic = 0;
 	acpi_madt_walk(mpacpi_count, self);
 
+	acpi_madt_walk(mpacpi_config_ioapic, self);
+
 #if NLAPIC  0
 	lapic_boot_init(mpacpi_lapic_base);
 #endif
@@ -456,8 +463,6 @@ mpacpi_scan_apics(device_t self, int *nc
 	if (mpacpi_ncpu == 0)
 		goto done;
 
-	acpi_madt_walk(mpacpi_config_ioapic, self);
-
 #if NPCI  0
 	

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

2015-08-10 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Aug 11 05:11:08 UTC 2015

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

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #946):
sys/arch/x86/x86/coretemp.c: revision 1.34
- Change the Upper limit of Tjmax from 100 to 110 because some new
  CPUs have 105. This change is the same as FreeBSD.
- Print Tjmax with aprint_verbose().
- Reduce the diff against FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.32.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.32 src/sys/arch/x86/x86/coretemp.c:1.32.4.1
--- src/sys/arch/x86/x86/coretemp.c:1.32	Sun Nov 17 18:08:08 2013
+++ src/sys/arch/x86/x86/coretemp.c	Tue Aug 11 05:11:08 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: coretemp.c,v 1.32 2013/11/17 18:08:08 martin Exp $ */
+/* $NetBSD: coretemp.c,v 1.32.4.1 2015/08/11 05:11:08 snj Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: coretemp.c,v 1.32 2013/11/17 18:08:08 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: coretemp.c,v 1.32.4.1 2015/08/11 05:11:08 snj Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -168,7 +168,7 @@ coretemp_attach(device_t parent, device_
 	msr = __SHIFTOUT(msr, MSR_THERM_STATUS_RESOLUTION);
 
 	aprint_naive(\n);
-	aprint_normal(: thermal sensor, %u C resolution\n, (uint32_t)msr);
+	aprint_normal(: thermal sensor, %u C resolution, (uint32_t)msr);
 
 	sc-sc_sensor.units = ENVSYS_STEMP;
 	sc-sc_sensor.state = ENVSYS_SINVALID;
@@ -191,11 +191,14 @@ coretemp_attach(device_t parent, device_
 		goto fail;
 
 	coretemp_tjmax(self);
+	aprint_verbose(, Tjmax=%d, sc-sc_tjmax);
+	aprint_normal(\n);
 	return;
 
 fail:
 	sysmon_envsys_destroy(sc-sc_sme);
 	sc-sc_sme = NULL;
+	aprint_normal(\n);
 }
 
 static int
@@ -265,20 +268,11 @@ coretemp_tjmax(device_t self)
 	sc-sc_tjmax = 100;
 
 	/*
-	 * The mobile Penryn family.
-	 */
-	if (model == 0x17  stepping == 0x06) {
-		sc-sc_tjmax = 105;
-		return;
-	}
-
-	/*
 	 * 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.
 	 */
-	if ((model == 0x0F  stepping = 2) ||
-	(model == 0x0E)) {
+	if ((model == 0x0F  stepping = 2) || (model == 0x0E)) {
 
 		if (rdmsr_safe(MSR_IA32_EXT_CONFIG, msr) == EFAULT)
 			return;
@@ -287,21 +281,22 @@ coretemp_tjmax(device_t self)
 			sc-sc_tjmax = 85;
 			return;
 		}
-	}
-
-	/*
-	 * Attempt to get Tj(max) from IA32_TEMPERATURE_TARGET,
-	 * but only consider the interval [70, 100] C as valid.
-	 * It is not fully known which CPU models have the MSR.
-	 */
-	if (model == 0x0E) {
-
+	} else if (model == 0x17  stepping == 0x06) {
+		/* The mobile Penryn family. */
+		sc-sc_tjmax = 105;
+		return;
+	} else {
+		/*
+		 * 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, msr) == EFAULT)
 			return;
 
 		msr = __SHIFTOUT(msr, MSR_TEMP_TARGET_READOUT);
 
-		if (msr = 70  msr = 100) {
+		if (msr = 70  msr = 110) {
 			sc-sc_tjmax = msr;
 			return;
 		}



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

2015-08-10 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Aug 11 05:13:45 UTC 2015

Modified Files:
src/sys/arch/x86/x86 [netbsd-7]: cpu_ucode_intel.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #945):
sys/arch/x86/x86/cpu_ucode_intel.c: revisions 1.7, 1.8
Re-allocale buffer if a buffer for microcode is not 16byte aligned.
--
Use roundup2() and uintptr_t. Adviced by riastradh@.


To generate a diff of this commit:
cvs rdiff -u -r1.5.4.1 -r1.5.4.2 src/sys/arch/x86/x86/cpu_ucode_intel.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_ucode_intel.c
diff -u src/sys/arch/x86/x86/cpu_ucode_intel.c:1.5.4.1 src/sys/arch/x86/x86/cpu_ucode_intel.c:1.5.4.2
--- src/sys/arch/x86/x86/cpu_ucode_intel.c:1.5.4.1	Fri Jan  9 10:33:07 2015
+++ src/sys/arch/x86/x86/cpu_ucode_intel.c	Tue Aug 11 05:13:44 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_ucode_intel.c,v 1.5.4.1 2015/01/09 10:33:07 martin Exp $ */
+/* $NetBSD: cpu_ucode_intel.c,v 1.5.4.2 2015/08/11 05:13:44 snj Exp $ */
 /*
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cpu_ucode_intel.c,v 1.5.4.1 2015/01/09 10:33:07 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu_ucode_intel.c,v 1.5.4.2 2015/08/11 05:13:44 snj Exp $);
 
 #include opt_xen.h
 #include opt_cpu_ucode.h
@@ -111,40 +111,54 @@ cpu_ucode_intel_apply(struct cpu_ucode_s
 	uint32_t ucodetarget, oucodeversion, nucodeversion;
 	int platformid;
 	struct intel1_ucode_header *uh;
+	size_t newbufsize = 0;
+	int rv = 0;
 
 	if (sc-loader_version != CPU_UCODE_LOADER_INTEL1
 	|| cpuno != CPU_UCODE_CURRENT_CPU)
 		return EINVAL;
 
-	/* XXX relies on malloc alignment */
-	if ((uintptr_t)(sc-sc_blob)  15) {
-		printf(ucode alignment bad\n);
-		return EINVAL;
-	}
-
 	uh = (struct intel1_ucode_header *)(sc-sc_blob);
 	if (uh-uh_header_ver != 1 || uh-uh_loader_rev != 1)
 		return EINVAL;
 	ucodetarget = uh-uh_rev;
 
+	if ((uintptr_t)(sc-sc_blob)  15) {
+		/* Make the buffer 16 byte aligned */
+		newbufsize = sc-sc_blobsize + 15;
+		uh = kmem_alloc(newbufsize, KM_SLEEP);
+		if (uh == NULL) {
+			printf(%s: memory allocation failed\n, __func__);
+			return EINVAL;
+		}
+		uh = (struct intel1_ucode_header *)roundup2((uintptr_t)uh, 16);
+		/* Copy to the new area */
+		memcpy(uh, sc-sc_blob, sc-sc_blobsize);
+	}
+
 	kpreempt_disable();
 
 	intel_getcurrentucode(oucodeversion, platformid);
 	if (oucodeversion = ucodetarget) {
 		kpreempt_enable();
-		return EEXIST; /* ??? */
+		rv = EEXIST; /* ??? */
+		goto out;
 	}
 	wrmsr(MSR_BIOS_UPDT_TRIG, (uintptr_t)(sc-sc_blob) + 48);
 	intel_getcurrentucode(nucodeversion, platformid);
 
 	kpreempt_enable();
 
-	if (nucodeversion != ucodetarget)
-		return EIO;
+	if (nucodeversion != ucodetarget) {
+		rv = EIO;
+		goto out;
+	}
 
 	printf(cpu %d: ucode 0x%x-0x%x\n, curcpu()-ci_index,
 	   oucodeversion, nucodeversion);
-
-	return 0;
+out:
+	if (newbufsize != 0)
+		kmem_free(uh, newbufsize);
+	return rv;
 }
 #endif /* ! XEN */



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

2015-08-10 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Aug 11 05:15:25 UTC 2015

Modified Files:
src/sys/arch/x86/x86 [netbsd-7]: mpacpi.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #947):
sys/arch/x86/x86/mpacpi.c: revision 1.98
Fix wrong output in mpacpi_pci_foundbus() with MPVERBOSE. Assign
vaues before printing them.


To generate a diff of this commit:
cvs rdiff -u -r1.97.10.1 -r1.97.10.2 src/sys/arch/x86/x86/mpacpi.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/mpacpi.c
diff -u src/sys/arch/x86/x86/mpacpi.c:1.97.10.1 src/sys/arch/x86/x86/mpacpi.c:1.97.10.2
--- src/sys/arch/x86/x86/mpacpi.c:1.97.10.1	Tue Aug 11 05:07:16 2015
+++ src/sys/arch/x86/x86/mpacpi.c	Tue Aug 11 05:15:25 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpacpi.c,v 1.97.10.1 2015/08/11 05:07:16 snj Exp $	*/
+/*	$NetBSD: mpacpi.c,v 1.97.10.2 2015/08/11 05:15:25 snj Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: mpacpi.c,v 1.97.10.1 2015/08/11 05:07:16 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: mpacpi.c,v 1.97.10.2 2015/08/11 05:15:25 snj Exp $);
 
 #include acpica.h
 #include opt_acpi.h
@@ -500,6 +500,12 @@ mpacpi_pci_foundbus(struct acpi_devnode 
 	}
 
 	mpr = kmem_zalloc(sizeof(struct mpacpi_pcibus), KM_SLEEP);
+	mpr-mpr_handle = ad-ad_handle;
+	mpr-mpr_buf = buf;
+	mpr-mpr_seg = ad-ad_pciinfo-ap_segment;
+	mpr-mpr_bus = ad-ad_pciinfo-ap_downbus;
+	TAILQ_INSERT_TAIL(mpacpi_pcibusses, mpr, mpr_list);
+
 	if ((ad-ad_devinfo-Flags  ACPI_PCI_ROOT_BRIDGE) != 0) {
 		if (mp_verbose)
 			printf(mpacpi: found root PCI bus %d\n,
@@ -511,12 +517,6 @@ mpacpi_pci_foundbus(struct acpi_devnode 
 			mpr-mpr_bus);
 	}
 
-	mpr-mpr_handle = ad-ad_handle;
-	mpr-mpr_buf = buf;
-	mpr-mpr_seg = ad-ad_pciinfo-ap_segment;
-	mpr-mpr_bus = ad-ad_pciinfo-ap_downbus;
-	TAILQ_INSERT_TAIL(mpacpi_pcibusses, mpr, mpr_list);
-
 	/*
 	 * XXX this wrongly assumes that bus numbers are unique
 	 * even between segments.



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

2015-05-22 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri May 22 16:53:32 UTC 2015

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

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #795):
sys/arch/x86/x86/lapic.c: revision 1.48
Workaround for lapic_set_lvt: bad pin value %d panic on some (broken?) BIOS
system. Don't panic when a local APIC's interrput input pin number (LINTx)  1.
Instead, print warning message and continue. The default is pin 1.
Same as Linux (and perhaps FreeBSD). Tested with Shuttle DS57U.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.47.4.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.47 src/sys/arch/x86/x86/lapic.c:1.47.4.1
--- src/sys/arch/x86/x86/lapic.c:1.47	Fri Nov 15 08:47:55 2013
+++ src/sys/arch/x86/x86/lapic.c	Fri May 22 16:53:32 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: lapic.c,v 1.47 2013/11/15 08:47:55 msaitoh Exp $	*/
+/*	$NetBSD: lapic.c,v 1.47.4.1 2015/05/22 16:53:32 snj Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: lapic.c,v 1.47 2013/11/15 08:47:55 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: lapic.c,v 1.47.4.1 2015/05/22 16:53:32 snj Exp $);
 
 #include opt_ddb.h
 #include opt_mpbios.h		/* for MPDEBUG */
@@ -182,11 +182,10 @@ lapic_set_lvt(void)
 		mpi = mp_intrs[i];
 		if (mpi-ioapic == NULL  (mpi-cpu_id == MPS_ALL_APICS ||
 		mpi-cpu_id == ci-ci_cpuid)) {
-#ifdef DIAGNOSTIC
 			if (mpi-ioapic_pin  1)
-panic(lapic_set_lvt: bad pin value %d,
-mpi-ioapic_pin);
-#endif
+aprint_error_dev(ci-ci_dev,
+%s: WARNING: bad pin value %d\n,
+__func__, mpi-ioapic_pin);
 			if (mpi-ioapic_pin == 0)
 i82489_writereg(LAPIC_LVINT0, mpi-redir);
 			else



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

2015-04-19 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sun Apr 19 16:47:39 UTC 2015

Modified Files:
src/sys/arch/x86/x86 [netbsd-7]: intel_busclock.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #702):
sys/arch/x86/x86/intel_busclock.c: revision 1.21
Update from Intel SDM:
- Add busclock values for Airmont.


To generate a diff of this commit:
cvs rdiff -u -r1.19.2.1 -r1.19.2.2 src/sys/arch/x86/x86/intel_busclock.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/intel_busclock.c
diff -u src/sys/arch/x86/x86/intel_busclock.c:1.19.2.1 src/sys/arch/x86/x86/intel_busclock.c:1.19.2.2
--- src/sys/arch/x86/x86/intel_busclock.c:1.19.2.1	Thu Jan  8 11:15:45 2015
+++ src/sys/arch/x86/x86/intel_busclock.c	Sun Apr 19 16:47:39 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel_busclock.c,v 1.19.2.1 2015/01/08 11:15:45 martin Exp $	*/
+/*	$NetBSD: intel_busclock.c,v 1.19.2.2 2015/04/19 16:47:39 riz Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: intel_busclock.c,v 1.19.2.1 2015/01/08 11:15:45 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: intel_busclock.c,v 1.19.2.2 2015/04/19 16:47:39 riz Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -272,6 +272,56 @@ p3_get_bus_clock(struct cpu_info *ci)
 			goto print_msr;
 		}
 		break;
+	case 0x4c: /* Airmont */
+		if (rdmsr_safe(MSR_FSB_FREQ, msr) == EFAULT) {
+			aprint_debug_dev(ci-ci_dev,
+			unable to determine bus speed);
+			goto print_msr;
+		}
+		bus = (msr  0)  0xf;
+		switch (bus) {
+		case 0:
+			bus_clock =  8333;
+			break;
+		case 1:
+			bus_clock = 1;
+			break;
+		case 2:
+			bus_clock = 1;
+			break;
+		case 3:
+			bus_clock = 11650;
+			break;
+		case 4:
+			bus_clock =  8333;
+			break;
+		case 5:
+			bus_clock = 1;
+			break;
+		case 6:
+			bus_clock = 1;
+			break;
+		case 7:
+			bus_clock = 11666;
+			break;
+		case 12:
+			bus_clock =  8000;
+			break;
+		case 13:
+			bus_clock =  9333;
+			break;
+		case 14:
+			bus_clock =  9000;
+			break;
+		case 15:
+			bus_clock =  ;
+			break;
+		default:
+			aprint_debug(%s: unknown Airmont FSB_FREQ value %d,
+			device_xname(ci-ci_dev), bus);
+			goto print_msr;
+		}
+		break;
 	default:
 		aprint_debug(%s: unknown i686 model %02x, can't get bus clock,
 		device_xname(ci-ci_dev),



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

2015-01-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jan 28 11:13:02 UTC 2015

Modified Files:
src/sys/arch/x86/x86 [netbsd-7]: consinit.c

Log Message:
Pull up following revision(s) (requested by is in ticket #462):
sys/arch/x86/x86/consinit.c: revision 1.28
Add support for the (cobalt) nullcons to amd64 and i386.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.27.4.1 src/sys/arch/x86/x86/consinit.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/consinit.c
diff -u src/sys/arch/x86/x86/consinit.c:1.27 src/sys/arch/x86/x86/consinit.c:1.27.4.1
--- src/sys/arch/x86/x86/consinit.c:1.27	Wed Mar 12 12:54:33 2014
+++ src/sys/arch/x86/x86/consinit.c	Wed Jan 28 11:13:02 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: consinit.c,v 1.27 2014/03/12 12:54:33 martin Exp $	*/
+/*	$NetBSD: consinit.c,v 1.27.4.1 2015/01/28 11:13:02 martin Exp $	*/
 
 /*
  * Copyright (c) 1998
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: consinit.c,v 1.27 2014/03/12 12:54:33 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: consinit.c,v 1.27.4.1 2015/01/28 11:13:02 martin Exp $);
 
 #include opt_kgdb.h
 #include opt_puc.h
@@ -39,6 +39,9 @@ __KERNEL_RCSID(0, $NetBSD: consinit.c,v
 #include machine/bootinfo.h
 #include arch/x86/include/genfb_machdep.h
 
+#include dev/cons.h
+
+#include nullcons.h
 #include genfb.h
 #include vga.h
 #include ega.h
@@ -235,6 +238,14 @@ dokbd:
 		return;
 	}
 #endif
+#if (NNULLCONS  0)
+	if (!strcmp(consinfo-devname, nullcons)) {
+		void nullcninit(struct consdev *cn);
+
+		nullcninit(0);
+		return;
+	}
+#endif
 	panic(invalid console device %s, consinfo-devname);
 }
 



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

2015-01-12 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Jan 12 21:06:42 UTC 2015

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

Log Message:
Pull up following revision(s) (requested by christos in ticket #414):
sys/arch/x86/x86/cpu.c: revision 1.113
PR/49104: Jarle Greipsland: Don't touch cr4 in cpus that don't have it.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.111.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.111 src/sys/arch/x86/x86/cpu.c:1.111.2.1
--- src/sys/arch/x86/x86/cpu.c:1.111	Mon May 12 11:56:02 2014
+++ src/sys/arch/x86/x86/cpu.c	Mon Jan 12 21:06:41 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.111 2014/05/12 11:56:02 joerg Exp $	*/
+/*	$NetBSD: cpu.c,v 1.111.2.1 2015/01/12 21:06:41 snj Exp $	*/
 
 /*-
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.111 2014/05/12 11:56:02 joerg Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.111.2.1 2015/01/12 21:06:41 snj Exp $);
 
 #include opt_ddb.h
 #include opt_mpbios.h		/* for MPDEBUG */
@@ -552,11 +552,10 @@ cpu_childdetached(device_t self, device_
 void
 cpu_init(struct cpu_info *ci)
 {
-	uint32_t cr4;
+	uint32_t cr4 = 0;
 
 	lcr0(rcr0() | CR0_WP);
 
-	cr4 = rcr4();
 	/*
 	 * On a P6 or above, enable global TLB caching if the
 	 * hardware supports it.
@@ -581,7 +580,10 @@ cpu_init(struct cpu_info *ci)
 	if (cpu_feature[1]  CPUID2_XSAVE)
 		cr4 |= CR4_OSXSAVE;
 
-	lcr4(cr4);
+	if (cr4) {
+		cr4 |= rcr4();
+		lcr4(cr4);
+	}
 
 	/* If xsave is enabled, enable all fpu features */
 	if (cr4  CR4_OSXSAVE)



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

2015-01-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jan  8 11:15:45 UTC 2015

Modified Files:
src/sys/arch/x86/x86 [netbsd-7]: intel_busclock.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #393):
sys/arch/x86/x86/intel_busclock.c: revision 1.20
- Round off some bus clock values.
- Add 333.33MHz for Pentium 4.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.19.2.1 src/sys/arch/x86/x86/intel_busclock.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/intel_busclock.c
diff -u src/sys/arch/x86/x86/intel_busclock.c:1.19 src/sys/arch/x86/x86/intel_busclock.c:1.19.2.1
--- src/sys/arch/x86/x86/intel_busclock.c:1.19	Fri Jul 25 14:34:22 2014
+++ src/sys/arch/x86/x86/intel_busclock.c	Thu Jan  8 11:15:45 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel_busclock.c,v 1.19 2014/07/25 14:34:22 msaitoh Exp $	*/
+/*	$NetBSD: intel_busclock.c,v 1.19.2.1 2015/01/08 11:15:45 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: intel_busclock.c,v 1.19 2014/07/25 14:34:22 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: intel_busclock.c,v 1.19.2.1 2015/01/08 11:15:45 martin Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -316,7 +316,7 @@ p4_get_bus_clock(struct cpu_info *ci)
 		switch (bus) {
 		case 0:
 			bus_clock = (CPUID_TO_MODEL(ci-ci_signature) == 2) ?
-			1 : 2;
+			1 : 26667;
 			break;
 		case 1:
 			bus_clock = 1;
@@ -325,7 +325,10 @@ p4_get_bus_clock(struct cpu_info *ci)
 			bus_clock = 2;
 			break;
 		case 3:
-			bus_clock = 1;
+			bus_clock = 16667;
+			break;
+		case 4:
+			bus_clock = 3;
 			break;
 		default:
 			aprint_debug(%s: unknown Pentium 4 (model %d) 



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

2014-10-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 30 18:58:45 UTC 2014

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

Log Message:
Pull up following revision(s) (requested by riz in ticket #171):
sys/arch/x86/x86/identcpu.c: revision 1.46
sys/arch/x86/x86/identcpu.c: revision 1.47
Force x86_xsave_features to 0 when running under XEN.
This prevents the use of xsave and xrstor thus fixing
the problem in PR/49150.  The basic problem is that the way AMD
implements those instructions means that information can leak
between domains so XEN treats them as privileged.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.45.2.1 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.45 src/sys/arch/x86/x86/identcpu.c:1.45.2.1
--- src/sys/arch/x86/x86/identcpu.c:1.45	Tue Jul  8 19:35:36 2014
+++ src/sys/arch/x86/x86/identcpu.c	Thu Oct 30 18:58:45 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: identcpu.c,v 1.45 2014/07/08 19:35:36 msaitoh Exp $	*/
+/*	$NetBSD: identcpu.c,v 1.45.2.1 2014/10/30 18:58:45 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: identcpu.c,v 1.45 2014/07/08 19:35:36 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: identcpu.c,v 1.45.2.1 2014/10/30 18:58:45 martin Exp $);
 
 #include opt_xen.h
 
@@ -757,7 +757,9 @@ cpu_probe_fpu(struct cpu_info *ci)
 	/* XXX these probably ought to be per-cpu */
 	if (descs[2]  512)
 	x86_fpu_save_size = descs[2];
+#ifndef XEN
 	x86_xsave_features = (uint64_t)descs[3]  32 | descs[0];
+#endif
 }
 
 void



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

2014-10-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 14 07:37:37 UTC 2014

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

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #140):
sys/arch/x86/x86/pmap.c: revision 1.184
Add a missing || defined(XEN) which cause Xen non-DIAGNOSTIC kernels
to panic at boot.


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.183.2.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.183 src/sys/arch/x86/x86/pmap.c:1.183.2.1
--- src/sys/arch/x86/x86/pmap.c:1.183	Sat Jun 14 02:54:47 2014
+++ src/sys/arch/x86/x86/pmap.c	Tue Oct 14 07:37:37 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.183 2014/06/14 02:54:47 pgoyette Exp $	*/
+/*	$NetBSD: pmap.c,v 1.183.2.1 2014/10/14 07:37:37 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.183 2014/06/14 02:54:47 pgoyette Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.183.2.1 2014/10/14 07:37:37 martin Exp $);
 
 #include opt_user_ldt.h
 #include opt_lockdebug.h
@@ -4126,7 +4126,7 @@ pmap_get_physpage(vaddr_t va, int level,
 		pmap_pte_flush();
 		pmap_update_pg((vaddr_t)early_zerop);
 		memset(early_zerop, 0, PAGE_SIZE);
-#if defined(DIAGNOSTIC)
+#if defined(DIAGNOSTIC) || defined(XEN)
 		pmap_pte_set(early_zero_pte, 0);
 		pmap_pte_flush();
 #endif /* defined(DIAGNOSTIC) */