CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86

2020-04-16 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Apr 16 17:46:44 UTC 2020

Modified Files:
src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_mainbus.c

Log Message:
Don't try to attach hypervisor on non Xen; no more error messages about
hypervisor when booting on bare metal.


To generate a diff of this commit:
cvs rdiff -u -r1.6.12.1 -r1.6.12.2 src/sys/arch/xen/x86/xen_mainbus.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/xen/x86/xen_mainbus.c
diff -u src/sys/arch/xen/x86/xen_mainbus.c:1.6.12.1 src/sys/arch/xen/x86/xen_mainbus.c:1.6.12.2
--- src/sys/arch/xen/x86/xen_mainbus.c:1.6.12.1	Thu Apr 16 08:46:35 2020
+++ src/sys/arch/xen/x86/xen_mainbus.c	Thu Apr 16 17:46:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_mainbus.c,v 1.6.12.1 2020/04/16 08:46:35 bouyer Exp $	*/
+/*	$NetBSD: xen_mainbus.c,v 1.6.12.2 2020/04/16 17:46:44 bouyer Exp $	*/
 /*	NetBSD: mainbus.c,v 1.19 2017/05/23 08:54:39 nonaka Exp 	*/
 /*	NetBSD: mainbus.c,v 1.53 2003/10/27 14:11:47 junyoung Exp 	*/
 
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_mainbus.c,v 1.6.12.1 2020/04/16 08:46:35 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_mainbus.c,v 1.6.12.2 2020/04/16 17:46:44 bouyer Exp $");
 
 #include 
 #include 
@@ -121,20 +121,31 @@ xen_mainbus_attach(device_t parent, devi
 {
 	union xen_mainbus_attach_args mba;
 
+	switch(vm_guest) {
+	case VM_GUEST_XENPV:
 #if NIPMI > 0 && defined(XENPV)
-	memset(_ipmi, 0, sizeof(mba.mba_ipmi));
-	mba.mba_ipmi.iaa_iot = x86_bus_space_io;
-	mba.mba_ipmi.iaa_memt = x86_bus_space_mem;
-	if (ipmi_probe(_ipmi))
-		config_found_ia(self, "ipmibus", _ipmi, 0);
-#endif
-
-	mba.mba_haa.haa_busname = "hypervisor";
-	config_found_ia(self, "hypervisorbus", _haa, xen_mainbus_print);
-
-	/* save/restore for Xen */
-	if (!pmf_device_register(self, NULL, NULL))
-		aprint_error_dev(self, "couldn't establish power handler\n");
+		memset(_ipmi, 0, sizeof(mba.mba_ipmi));
+		mba.mba_ipmi.iaa_iot = x86_bus_space_io;
+		mba.mba_ipmi.iaa_memt = x86_bus_space_mem;
+		if (ipmi_probe(_ipmi))
+			config_found_ia(self, "ipmibus", _ipmi, 0);
+#endif
+	/* FALLTHROUGH */
+	case VM_GUEST_XENHVM:
+		mba.mba_haa.haa_busname = "hypervisor";
+		config_found_ia(self, "hypervisorbus",
+		_haa, xen_mainbus_print);
+		break;
+	default:
+		return;
+	}
+
+	if (vm_guest == VM_GUEST_XENPV) {
+		/* save/restore for Xen */
+		if (!pmf_device_register(self, NULL, NULL))
+			aprint_error_dev(self,
+			"couldn't establish power handler\n");
+	}
 }
 
 static int



CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86

2020-04-14 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue Apr 14 16:52:36 UTC 2020

Modified Files:
src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_intr.c

Log Message:
Remove spllower alias, xen_spllower is gone


To generate a diff of this commit:
cvs rdiff -u -r1.21.2.3 -r1.21.2.4 src/sys/arch/xen/x86/xen_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/xen/x86/xen_intr.c
diff -u src/sys/arch/xen/x86/xen_intr.c:1.21.2.3 src/sys/arch/xen/x86/xen_intr.c:1.21.2.4
--- src/sys/arch/xen/x86/xen_intr.c:1.21.2.3	Sun Apr 12 19:53:37 2020
+++ src/sys/arch/xen/x86/xen_intr.c	Tue Apr 14 16:52:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_intr.c,v 1.21.2.3 2020/04/12 19:53:37 bouyer Exp $	*/
+/*	$NetBSD: xen_intr.c,v 1.21.2.4 2020/04/14 16:52:35 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.21.2.3 2020/04/12 19:53:37 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.21.2.4 2020/04/14 16:52:35 bouyer Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -495,7 +495,6 @@ xen_intr_create_intrid(int legacy_irq, s
 }
 
 #if !defined(XENPVHVM)
-__strong_alias(spllower, xen_spllower);
 __strong_alias(x86_read_psl, xen_read_psl);
 __strong_alias(x86_write_psl, xen_write_psl);
 



CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86

2020-04-12 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Apr 12 21:19:49 UTC 2020

Modified Files:
src/sys/arch/xen/x86 [bouyer-xenpvh]: autoconf.c

Log Message:
remove stray 'else'


To generate a diff of this commit:
cvs rdiff -u -r1.23.8.1 -r1.23.8.2 src/sys/arch/xen/x86/autoconf.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/xen/x86/autoconf.c
diff -u src/sys/arch/xen/x86/autoconf.c:1.23.8.1 src/sys/arch/xen/x86/autoconf.c:1.23.8.2
--- src/sys/arch/xen/x86/autoconf.c:1.23.8.1	Wed Apr  8 17:59:16 2020
+++ src/sys/arch/xen/x86/autoconf.c	Sun Apr 12 21:19:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.23.8.1 2020/04/08 17:59:16 bouyer Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.23.8.2 2020/04/12 21:19:49 bouyer Exp $	*/
 /*	NetBSD: autoconf.c,v 1.75 2003/12/30 12:33:22 pk Exp 	*/
 
 /*-
@@ -45,7 +45,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.23.8.1 2020/04/08 17:59:16 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.23.8.2 2020/04/12 21:19:49 bouyer Exp $");
 
 #include "opt_xen.h"
 #include "opt_multiprocessor.h"
@@ -126,7 +126,7 @@ cpu_configure(void)
 		/* identify hypervisor type from SMBIOS */
 		identify_hypervisor();
 #endif /* NBIOS32 > 0 */
-	} else
+	}
 #endif /* DOM0OPS */
 #ifdef PCIBIOS
 	pcibios_init();



CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86

2020-04-12 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Apr 12 19:53:37 UTC 2020

Modified Files:
src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_intr.c

Log Message:
We need to call x86_init_preempt() for all CPUs now.


To generate a diff of this commit:
cvs rdiff -u -r1.21.2.2 -r1.21.2.3 src/sys/arch/xen/x86/xen_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/xen/x86/xen_intr.c
diff -u src/sys/arch/xen/x86/xen_intr.c:1.21.2.2 src/sys/arch/xen/x86/xen_intr.c:1.21.2.3
--- src/sys/arch/xen/x86/xen_intr.c:1.21.2.2	Sun Apr 12 17:25:52 2020
+++ src/sys/arch/xen/x86/xen_intr.c	Sun Apr 12 19:53:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_intr.c,v 1.21.2.2 2020/04/12 17:25:52 bouyer Exp $	*/
+/*	$NetBSD: xen_intr.c,v 1.21.2.3 2020/04/12 19:53:37 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.21.2.2 2020/04/12 17:25:52 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.21.2.3 2020/04/12 19:53:37 bouyer Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -306,6 +306,11 @@ void xen_cpu_intr_init(struct cpu_info *
 void
 xen_cpu_intr_init(struct cpu_info *ci)
 {
+#if defined(__HAVE_PREEMPTION)
+	x86_init_preempt(ci);
+#endif
+	x86_intr_calculatemasks(ci);
+
 #if defined(INTRSTACKSIZE)
 	vaddr_t istack;
 



CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86

2020-04-12 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Apr 12 17:17:38 UTC 2020

Modified Files:
src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_ipi.c

Log Message:
Add XEN_IPI_KPREEMPT to list of valid IPIs


To generate a diff of this commit:
cvs rdiff -u -r1.35.6.1 -r1.35.6.2 src/sys/arch/xen/x86/xen_ipi.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/xen/x86/xen_ipi.c
diff -u src/sys/arch/xen/x86/xen_ipi.c:1.35.6.1 src/sys/arch/xen/x86/xen_ipi.c:1.35.6.2
--- src/sys/arch/xen/x86/xen_ipi.c:1.35.6.1	Sat Apr 11 18:26:07 2020
+++ src/sys/arch/xen/x86/xen_ipi.c	Sun Apr 12 17:17:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: xen_ipi.c,v 1.35.6.1 2020/04/11 18:26:07 bouyer Exp $ */
+/* $NetBSD: xen_ipi.c,v 1.35.6.2 2020/04/12 17:17:38 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2011, 2019 The NetBSD Foundation, Inc.
@@ -33,10 +33,10 @@
 
 /* 
  * Based on: x86/ipi.c
- * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.35.6.1 2020/04/11 18:26:07 bouyer Exp $");
+ * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.35.6.2 2020/04/12 17:17:38 bouyer Exp $");
  */
 
-__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.35.6.1 2020/04/11 18:26:07 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.35.6.2 2020/04/12 17:17:38 bouyer Exp $");
 
 #include "opt_ddb.h"
 
@@ -156,7 +156,7 @@ valid_ipimask(uint32_t ipimask)
 {
 	uint32_t masks = XEN_IPI_GENERIC | XEN_IPI_HVCB | XEN_IPI_XCALL |
 		 XEN_IPI_DDB | XEN_IPI_SYNCH_FPU |
-		 XEN_IPI_HALT | XEN_IPI_KICK | XEN_IPI_AST;
+		 XEN_IPI_HALT | XEN_IPI_KICK | XEN_IPI_AST | XEN_IPI_KPREEMPT;
 
 	if (ipimask & ~masks) {
 		return false;



CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86

2020-04-12 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Apr 12 17:16:58 UTC 2020

Modified Files:
src/sys/arch/xen/x86 [bouyer-xenpvh]: xenfunc.c

Log Message:
kpreempt_disable() only for x86_64 (which calls pmap_changeprot_local)).
On i386 curcpu() is not valid yet and we don't need preemption disabled.


To generate a diff of this commit:
cvs rdiff -u -r1.26.8.1 -r1.26.8.2 src/sys/arch/xen/x86/xenfunc.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/xen/x86/xenfunc.c
diff -u src/sys/arch/xen/x86/xenfunc.c:1.26.8.1 src/sys/arch/xen/x86/xenfunc.c:1.26.8.2
--- src/sys/arch/xen/x86/xenfunc.c:1.26.8.1	Sat Apr 11 18:26:07 2020
+++ src/sys/arch/xen/x86/xenfunc.c	Sun Apr 12 17:16:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: xenfunc.c,v 1.26.8.1 2020/04/11 18:26:07 bouyer Exp $	*/
+/*	$NetBSD: xenfunc.c,v 1.26.8.2 2020/04/12 17:16:58 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2004 Christian Limpach.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xenfunc.c,v 1.26.8.1 2020/04/11 18:26:07 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xenfunc.c,v 1.26.8.2 2020/04/12 17:16:58 bouyer Exp $");
 
 #include 
 
@@ -61,7 +61,9 @@ lidt(struct region_descriptor *rd)
 	 * will be available at the boot stage when this is called.
 	 */
 	static char xen_idt_page[PAGE_SIZE] __attribute__((__aligned__ (PAGE_SIZE)));
+#if defined(__x86_64__)
 	kpreempt_disable();
+#endif
 	memset(xen_idt_page, 0, PAGE_SIZE);
 	
 	struct trap_info *xen_idt = (void * )xen_idt_page;
@@ -96,8 +98,8 @@ lidt(struct region_descriptor *rd)
 #if defined(__x86_64__)
 	/* reset */
 	pmap_changeprot_local((vaddr_t) xen_idt, VM_PROT_READ|VM_PROT_WRITE);
-#endif /* __x86_64 */
 	kpreempt_enable();
+#endif /* __x86_64 */
 }
 
 void