CVS commit: src/sys/arch/xen/x86

2023-11-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Nov  6 17:01:07 UTC 2023

Modified Files:
src/sys/arch/xen/x86: xen_ipi.c

Log Message:
xen_ipi: valid_ipimask: Sprinkle __diagused to fix clang !DIAGNOSTIC build


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



CVS commit: src/sys/arch/xen/x86

2023-11-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Nov  6 17:01:07 UTC 2023

Modified Files:
src/sys/arch/xen/x86: xen_ipi.c

Log Message:
xen_ipi: valid_ipimask: Sprinkle __diagused to fix clang !DIAGNOSTIC build


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 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.41 src/sys/arch/xen/x86/xen_ipi.c:1.42
--- src/sys/arch/xen/x86/xen_ipi.c:1.41	Sun Aug  6 16:07:53 2023
+++ src/sys/arch/xen/x86/xen_ipi.c	Mon Nov  6 17:01:07 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: xen_ipi.c,v 1.41 2023/08/06 16:07:53 riastradh Exp $ */
+/* $NetBSD: xen_ipi.c,v 1.42 2023/11/06 17:01:07 rin Exp $ */
 
 /*-
  * Copyright (c) 2011, 2019 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  * Based on: x86/ipi.c
  */
 
-__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.41 2023/08/06 16:07:53 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.42 2023/11/06 17:01:07 rin Exp $");
 
 #include "opt_ddb.h"
 
@@ -149,7 +149,7 @@ xen_ipi_init(void)
 	hypervisor_unmask_event(evtchn);
 }
 
-static inline bool /* helper */
+static inline bool __diagused
 valid_ipimask(uint32_t ipimask)
 {
 	uint32_t masks = XEN_IPI_GENERIC | XEN_IPI_HVCB | XEN_IPI_XCALL |



CVS commit: src/sys/arch/xen/x86

2023-10-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue Oct 17 13:27:58 UTC 2023

Modified Files:
src/sys/arch/xen/x86: pvh_consinit.c

Log Message:
Make sure to always fall back to xen_early_console, even for dom0


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

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



CVS commit: src/sys/arch/xen/x86

2023-10-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue Oct 17 13:27:58 UTC 2023

Modified Files:
src/sys/arch/xen/x86: pvh_consinit.c

Log Message:
Make sure to always fall back to xen_early_console, even for dom0


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/xen/x86/pvh_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/xen/x86/pvh_consinit.c
diff -u src/sys/arch/xen/x86/pvh_consinit.c:1.5 src/sys/arch/xen/x86/pvh_consinit.c:1.6
--- src/sys/arch/xen/x86/pvh_consinit.c:1.5	Mon Oct 16 17:31:18 2023
+++ src/sys/arch/xen/x86/pvh_consinit.c	Tue Oct 17 13:27:58 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: pvh_consinit.c,v 1.5 2023/10/16 17:31:18 bouyer Exp $ */
+/* $NetBSD: pvh_consinit.c,v 1.6 2023/10/17 13:27:58 bouyer Exp $ */
 
 /*
  * Copyright (c) 2020 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pvh_consinit.c,v 1.5 2023/10/16 17:31:18 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pvh_consinit.c,v 1.6 2023/10/17 13:27:58 bouyer Exp $");
 
 #include "xencons.h"
 #include 
@@ -51,6 +51,11 @@ xen_pvh_consinit(void)
 	 * boot stage.
 	 */
 	static int initted = 0;
+
+	if (initted == 0) {
+		/* fall back to printk() until we can setup our console */
+		xen_early_console();
+	}
 	if (xendomain_is_dom0()) {
 		union xen_cmdline_parseinfo xcp;
 		xen_parse_cmdline(XEN_PARSE_CONSOLE, );
@@ -61,12 +66,12 @@ xen_pvh_consinit(void)
 		if (strcmp(xcp.xcp_console, "tty0") == 0 || /* linux name */
 		strcmp(xcp.xcp_console, "pc") == 0) { /* NetBSD name */
 #endif /* CONS_OVERRIDE */
+			initted++;
 			return 0; /* native console code will do it */
 		}
 	}
 	if (initted == 0 && !xendomain_is_dom0()) {
-		/* pmap not up yet, fall back to printk() */
-		xen_early_console();
+		/* pmap not up yet */
 		initted++;
 		return 1;
 	} else if (initted > 1) {



CVS commit: src/sys/arch/xen/x86

2023-08-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Aug  6 16:07:53 UTC 2023

Modified Files:
src/sys/arch/xen/x86: xen_ipi.c

Log Message:
xen/x86: Get the right intrframe pointer in ddb ipi.

This was broken with the transition from evtchn_set_handler to
intr_establish_xname in 2017, remained broken with the transition
from intr_establish_xname to xen_intr_establish_xname in 2018, and
still remained broken when xen_intr_establish_xname was changed back
to evtchn_set_handler in 2020.

The mechanism is grody -- instead of a secret second argument to the
interrupt handler, the intrframe pointer should be replaced by a
struct cpu_info member that is saved and restored by the interrupt
handler calling logic.  But we should make sure the replacement
actually works first -- which is not trivial in part because the
users are hidden behind sketchy function pointer casts.

With any luck, this will make `mach cpu N' work in ddb on Xen.

XXX pullup-10
XXX pullup-9 (by patch)


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 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.40 src/sys/arch/xen/x86/xen_ipi.c:1.41
--- src/sys/arch/xen/x86/xen_ipi.c:1.40	Wed Jan  5 20:21:29 2022
+++ src/sys/arch/xen/x86/xen_ipi.c	Sun Aug  6 16:07:53 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: xen_ipi.c,v 1.40 2022/01/05 20:21:29 christos Exp $ */
+/* $NetBSD: xen_ipi.c,v 1.41 2023/08/06 16:07:53 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011, 2019 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  * Based on: x86/ipi.c
  */
 
-__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.40 2022/01/05 20:21:29 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.41 2023/08/06 16:07:53 riastradh Exp $");
 
 #include "opt_ddb.h"
 
@@ -90,18 +90,15 @@ static void (*xen_ipifunc[XEN_NIPIS])(st
 };
 
 static int
-xen_ipi_handler(void *arg)
+xen_ipi_handler(void *arg, struct intrframe *regs)
 {
 	uint32_t pending;
 	int bit;
 	struct cpu_info *ci;
-	struct intrframe *regs;
 
 	ci = curcpu();
-	regs = arg;
 
 	KASSERT(ci == arg);
-	
 	pending = atomic_swap_32(>ci_ipis, 0);
 
 	KDASSERT((pending >> XEN_NIPIS) == 0);
@@ -142,8 +139,9 @@ xen_ipi_init(void)
 	snprintf(intr_xname, sizeof(intr_xname), "%s ipi",
 	device_xname(ci->ci_dev));
 
-	if (event_set_handler(evtchn, xen_ipi_handler, ci, IPL_HIGH, NULL,
-	intr_xname, true, ci) == NULL) {
+	if (event_set_handler(evtchn,
+		__FPTRCAST(int (*)(void *), xen_ipi_handler), ci, IPL_HIGH,
+		NULL, intr_xname, true, ci) == NULL) {
 		panic("%s: unable to register ipi handler\n", __func__);
 		/* NOTREACHED */
 	}



CVS commit: src/sys/arch/xen/x86

2023-08-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Aug  6 16:07:53 UTC 2023

Modified Files:
src/sys/arch/xen/x86: xen_ipi.c

Log Message:
xen/x86: Get the right intrframe pointer in ddb ipi.

This was broken with the transition from evtchn_set_handler to
intr_establish_xname in 2017, remained broken with the transition
from intr_establish_xname to xen_intr_establish_xname in 2018, and
still remained broken when xen_intr_establish_xname was changed back
to evtchn_set_handler in 2020.

The mechanism is grody -- instead of a secret second argument to the
interrupt handler, the intrframe pointer should be replaced by a
struct cpu_info member that is saved and restored by the interrupt
handler calling logic.  But we should make sure the replacement
actually works first -- which is not trivial in part because the
users are hidden behind sketchy function pointer casts.

With any luck, this will make `mach cpu N' work in ddb on Xen.

XXX pullup-10
XXX pullup-9 (by patch)


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



CVS commit: src/sys/arch/xen/x86

2023-07-22 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Jul 22 19:13:17 UTC 2023

Modified Files:
src/sys/arch/xen/x86: consinit.c pvh_consinit.c
Added Files:
src/sys/arch/xen/x86: xen_def_cons.h

Log Message:
xen: declare 'default_consinfo' as extern in a header

this makes pvh_consinit.c actually compile with CONS_OVERRIDE set.
i didn't see any good header to add to (bootinfo.h and cpu.h both
seem to be poor choices but were considered), hence the new one
with just this definition.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/xen/x86/consinit.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/xen/x86/pvh_consinit.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/xen/x86/xen_def_cons.h

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



CVS commit: src/sys/arch/xen/x86

2023-07-22 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Jul 22 19:13:17 UTC 2023

Modified Files:
src/sys/arch/xen/x86: consinit.c pvh_consinit.c
Added Files:
src/sys/arch/xen/x86: xen_def_cons.h

Log Message:
xen: declare 'default_consinfo' as extern in a header

this makes pvh_consinit.c actually compile with CONS_OVERRIDE set.
i didn't see any good header to add to (bootinfo.h and cpu.h both
seem to be poor choices but were considered), hence the new one
with just this definition.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/xen/x86/consinit.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/xen/x86/pvh_consinit.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/xen/x86/xen_def_cons.h

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/consinit.c
diff -u src/sys/arch/xen/x86/consinit.c:1.16 src/sys/arch/xen/x86/consinit.c:1.17
--- src/sys/arch/xen/x86/consinit.c:1.16	Sat Oct 13 17:58:55 2012
+++ src/sys/arch/xen/x86/consinit.c	Sat Jul 22 19:13:17 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: consinit.c,v 1.16 2012/10/13 17:58:55 jdc Exp $	*/
+/*	$NetBSD: consinit.c,v 1.17 2023/07/22 19:13:17 mrg Exp $	*/
 /*	NetBSD: consinit.c,v 1.4 2004/03/13 17:31:34 bjh21 Exp 	*/
 
 /*
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.16 2012/10/13 17:58:55 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.17 2023/07/22 19:13:17 mrg Exp $");
 
 #include "opt_kgdb.h"
 
@@ -75,6 +75,7 @@ __KERNEL_RCSID(0, "$NetBSD: consinit.c,v
 #include 
 #include 
 #include 
+#include "xen_def_cons.h"
 #endif
 
 #include "com.h"

Index: src/sys/arch/xen/x86/pvh_consinit.c
diff -u src/sys/arch/xen/x86/pvh_consinit.c:1.3 src/sys/arch/xen/x86/pvh_consinit.c:1.4
--- src/sys/arch/xen/x86/pvh_consinit.c:1.3	Fri Mar 24 12:28:42 2023
+++ src/sys/arch/xen/x86/pvh_consinit.c	Sat Jul 22 19:13:17 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: pvh_consinit.c,v 1.3 2023/03/24 12:28:42 bouyer Exp $ */
+/* $NetBSD: pvh_consinit.c,v 1.4 2023/07/22 19:13:17 mrg Exp $ */
 
 /*
  * Copyright (c) 2020 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pvh_consinit.c,v 1.3 2023/03/24 12:28:42 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pvh_consinit.c,v 1.4 2023/07/22 19:13:17 mrg Exp $");
 
 #include "xencons.h"
 #include 
@@ -41,6 +41,8 @@ __KERNEL_RCSID(0, "$NetBSD: pvh_consinit
 #include 
 #include 
 
+#include "xen_def_cons.h"
+
 static int pvh_xenconscn_getc(dev_t);
 static void pvh_xenconscn_putc(dev_t, int);
 static void pvh_xenconscn_pollc(dev_t, int);

Added files:

Index: src/sys/arch/xen/x86/xen_def_cons.h
diff -u /dev/null src/sys/arch/xen/x86/xen_def_cons.h:1.1
--- /dev/null	Sat Jul 22 19:13:17 2023
+++ src/sys/arch/xen/x86/xen_def_cons.h	Sat Jul 22 19:13:17 2023
@@ -0,0 +1,10 @@
+/*	$NetBSD: xen_def_cons.h,v 1.1 2023/07/22 19:13:17 mrg Exp $	*/
+
+/*
+ * Written by Matthew R. Green, July 20, 2023
+ * Public domain.
+ */
+
+#include 
+
+extern const struct btinfo_console default_consinfo;



CVS commit: src/sys/arch/xen/x86

2023-03-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Mar  1 08:13:44 UTC 2023

Modified Files:
src/sys/arch/xen/x86: hypervisor_machdep.c

Log Message:
xen/x86: Need kpreempt_disable/enable around curcpu() access.

This is called with `hardware' interrupts enabled (between sti and
cli), so presumably preemption is possible here.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/xen/x86/hypervisor_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/xen/x86/hypervisor_machdep.c
diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.45 src/sys/arch/xen/x86/hypervisor_machdep.c:1.46
--- src/sys/arch/xen/x86/hypervisor_machdep.c:1.45	Wed Sep  7 00:40:19 2022
+++ src/sys/arch/xen/x86/hypervisor_machdep.c	Wed Mar  1 08:13:44 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor_machdep.c,v 1.45 2022/09/07 00:40:19 knakahara Exp $	*/
+/*	$NetBSD: hypervisor_machdep.c,v 1.46 2023/03/01 08:13:44 riastradh Exp $	*/
 
 /*
  *
@@ -54,7 +54,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.45 2022/09/07 00:40:19 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.46 2023/03/01 08:13:44 riastradh Exp $");
 
 #include 
 #include 
@@ -192,6 +192,8 @@ stipending(void)
 	volatile struct vcpu_info *vci;
 	int ret;
 
+	kpreempt_disable();
+
 	ret = 0;
 	ci = curcpu();
 	vci = ci->ci_vcpu;
@@ -227,6 +229,8 @@ stipending(void)
 		x86_enable_intr();
 	}
 
+	kpreempt_enable();
+
 	return (ret);
 }
 



CVS commit: src/sys/arch/xen/x86

2023-03-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Mar  1 08:13:44 UTC 2023

Modified Files:
src/sys/arch/xen/x86: hypervisor_machdep.c

Log Message:
xen/x86: Need kpreempt_disable/enable around curcpu() access.

This is called with `hardware' interrupts enabled (between sti and
cli), so presumably preemption is possible here.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/xen/x86/hypervisor_machdep.c

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



CVS commit: src/sys/arch/xen/x86

2023-02-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 00:35:01 UTC 2023

Modified Files:
src/sys/arch/xen/x86: cpu.c

Log Message:
xen/x86/cpu.c: Nix trailing whitespace.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.144 -r1.145 src/sys/arch/xen/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/xen/x86/cpu.c
diff -u src/sys/arch/xen/x86/cpu.c:1.144 src/sys/arch/xen/x86/cpu.c:1.145
--- src/sys/arch/xen/x86/cpu.c:1.144	Sat Feb 25 00:32:38 2023
+++ src/sys/arch/xen/x86/cpu.c	Sat Feb 25 00:35:01 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.144 2023/02/25 00:32:38 riastradh Exp $	*/
+/*	$NetBSD: cpu.c,v 1.145 2023/02/25 00:35:01 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.144 2023/02/25 00:32:38 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.145 2023/02/25 00:35:01 riastradh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -521,7 +521,7 @@ cpu_attach_common(device_t parent, devic
 		(void *)pcb->pcb_rsp
 #endif
 		);
-		
+
 	}
 #endif /* MPVERBOSE */
 }
@@ -690,10 +690,10 @@ cpu_boot_secondary(struct cpu_info *ci)
 
 /*
  * APs end up here immediately after initialisation and VCPUOP_up in
- * mp_cpu_start(). 
+ * mp_cpu_start().
  * At this point, we are running in the idle pcb/idle stack of the new
  * CPU.  This function jumps to the idle loop and starts looking for
- * work. 
+ * work.
  */
 extern void x86_64_tls_switch(struct lwp *);
 void
@@ -931,8 +931,8 @@ xen_init_i386_vcpuctxt(struct cpu_info *
 
 	gdt_prepframes(frames, (vaddr_t)ci->ci_gdt, gdt_ents);
 
-	/* 
-	 * Initialise the vcpu context: 
+	/*
+	 * Initialise the vcpu context:
 	 * We use this cpu's idle_loop() pcb context.
 	 */
 
@@ -1160,7 +1160,7 @@ cpu_load_pmap(struct pmap *pmap, struct 
 
 /*
  * pmap_cpu_init_late: perform late per-CPU initialization.
- * 
+ *
  * Short note about percpu PDIR pages. Both the PAE and __x86_64__ architectures
  * have per-cpu PDIR tables, for two different reasons:
  *  - on PAE, this is to get around Xen's pagetable setup constraints (multiple
@@ -1170,7 +1170,7 @@ cpu_load_pmap(struct pmap *pmap, struct 
  *(see cpu_load_pmap()).
  *
  * What this means for us is that the PDIR of the pmap_kernel() is considered
- * to be a canonical "SHADOW" PDIR with the following properties: 
+ * to be a canonical "SHADOW" PDIR with the following properties:
  *  - its recursive mapping points to itself
  *  - per-cpu recursive mappings point to themselves on __x86_64__
  *  - per-cpu L4 pages' kernel entries are expected to be in sync with



CVS commit: src/sys/arch/xen/x86

2023-02-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 00:35:01 UTC 2023

Modified Files:
src/sys/arch/xen/x86: cpu.c

Log Message:
xen/x86/cpu.c: Nix trailing whitespace.

No functional change intended.


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

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



CVS commit: src/sys/arch/xen/x86

2023-02-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 00:32:38 UTC 2023

Modified Files:
src/sys/arch/xen/x86: cpu.c

Log Message:
xen/x86/cpu.c: Membar audit.

I see no reason for store-before-load ordering here; as far as I'm
aware, evtchn_upcall_mask is only shared between a (v)CPU and its
(hypervisor) interrupts, not other (v)CPUs.


To generate a diff of this commit:
cvs rdiff -u -r1.143 -r1.144 src/sys/arch/xen/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/xen/x86/cpu.c
diff -u src/sys/arch/xen/x86/cpu.c:1.143 src/sys/arch/xen/x86/cpu.c:1.144
--- src/sys/arch/xen/x86/cpu.c:1.143	Sat Feb 25 00:31:40 2023
+++ src/sys/arch/xen/x86/cpu.c	Sat Feb 25 00:32:38 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.143 2023/02/25 00:31:40 riastradh Exp $	*/
+/*	$NetBSD: cpu.c,v 1.144 2023/02/25 00:32:38 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.143 2023/02/25 00:31:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.144 2023/02/25 00:32:38 riastradh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -848,7 +848,7 @@ xen_init_amd64_vcpuctxt(struct cpu_info 
 	/* resume with interrupts off */
 	vci = ci->ci_vcpu;
 	vci->evtchn_upcall_mask = 1;
-	xen_mb();
+	__insn_barrier();
 
 	/* resume in kernel-mode */
 	initctx->flags = VGCF_in_kernel | VGCF_online;
@@ -945,7 +945,7 @@ xen_init_i386_vcpuctxt(struct cpu_info *
 	/* resume with interrupts off */
 	vci = ci->ci_vcpu;
 	vci->evtchn_upcall_mask = 1;
-	xen_mb();
+	__insn_barrier();
 
 	/* resume in kernel-mode */
 	initctx->flags = VGCF_in_kernel | VGCF_online;



CVS commit: src/sys/arch/xen/x86

2023-02-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 00:32:38 UTC 2023

Modified Files:
src/sys/arch/xen/x86: cpu.c

Log Message:
xen/x86/cpu.c: Membar audit.

I see no reason for store-before-load ordering here; as far as I'm
aware, evtchn_upcall_mask is only shared between a (v)CPU and its
(hypervisor) interrupts, not other (v)CPUs.


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

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



CVS commit: src/sys/arch/xen/x86

2023-02-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 00:32:13 UTC 2023

Modified Files:
src/sys/arch/xen/x86: xen_intr.c

Log Message:
xen_intr.c: Use kpreempt_disable/enable around access to curcpu().

curcpu() is not otherwise guaranteed to be stable at these points.

While here, nix nonsensical membars.  This need only be synchronized
with interrupts on the same CPU.

Proposed on port-xen:
https://mail-index.netbsd.org/port-xen/2022/07/13/msg010250.html

XXX pullup-8 (in __sti/__cli, __save/restore_flags in include/xen.h)
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 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.30 src/sys/arch/xen/x86/xen_intr.c:1.31
--- src/sys/arch/xen/x86/xen_intr.c:1.30	Tue May 24 14:00:23 2022
+++ src/sys/arch/xen/x86/xen_intr.c	Sat Feb 25 00:32:13 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_intr.c,v 1.30 2022/05/24 14:00:23 bouyer Exp $	*/
+/*	$NetBSD: xen_intr.c,v 1.31 2023/02/25 00:32:13 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.30 2022/05/24 14:00:23 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.31 2023/02/25 00:32:13 riastradh Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_pci.h"
@@ -83,19 +83,28 @@ static const char *xen_ipi_names[XEN_NIP
 void
 x86_disable_intr(void)
 {
+
+	kpreempt_disable();
 	curcpu()->ci_vcpu->evtchn_upcall_mask = 1;
-	x86_lfence();
+	kpreempt_enable();
+
+	__insn_barrier();
 }
 
 void
 x86_enable_intr(void)
 {
-	volatile struct vcpu_info *_vci = curcpu()->ci_vcpu;
+	struct cpu_info *ci;
+
 	__insn_barrier();
-	_vci->evtchn_upcall_mask = 0;
-	x86_lfence(); /* unmask then check (avoid races) */
-	if (__predict_false(_vci->evtchn_upcall_pending))
+
+	kpreempt_disable();
+	ci = curcpu();
+	ci->ci_vcpu->evtchn_upcall_mask = 0;
+	__insn_barrier();
+	if (__predict_false(ci->ci_vcpu->evtchn_upcall_pending))
 		hypervisor_force_callback();
+	kpreempt_enable();
 }
 
 #endif /* !XENPVHVM */
@@ -103,20 +112,27 @@ x86_enable_intr(void)
 u_long
 xen_read_psl(void)
 {
+	u_long psl;
+
+	kpreempt_disable();
+	psl = curcpu()->ci_vcpu->evtchn_upcall_mask;
+	kpreempt_enable();
 
-	return (curcpu()->ci_vcpu->evtchn_upcall_mask);
+	return psl;
 }
 
 void
 xen_write_psl(u_long psl)
 {
-	struct cpu_info *ci = curcpu();
+	struct cpu_info *ci;
 
+	kpreempt_disable();
+	ci = curcpu();
 	ci->ci_vcpu->evtchn_upcall_mask = psl;
-	xen_rmb();
-	if (ci->ci_vcpu->evtchn_upcall_pending && psl == 0) {
+	__insn_barrier();
+	if (__predict_false(ci->ci_vcpu->evtchn_upcall_pending) && psl == 0)
 		hypervisor_force_callback();
-	}
+	kpreempt_enable();
 }
 
 void *



CVS commit: src/sys/arch/xen/x86

2023-02-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 00:32:13 UTC 2023

Modified Files:
src/sys/arch/xen/x86: xen_intr.c

Log Message:
xen_intr.c: Use kpreempt_disable/enable around access to curcpu().

curcpu() is not otherwise guaranteed to be stable at these points.

While here, nix nonsensical membars.  This need only be synchronized
with interrupts on the same CPU.

Proposed on port-xen:
https://mail-index.netbsd.org/port-xen/2022/07/13/msg010250.html

XXX pullup-8 (in __sti/__cli, __save/restore_flags in include/xen.h)
XXX pullup-9
XXX pullup-10


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



CVS commit: src/sys/arch/xen/x86

2022-05-31 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue May 31 18:01:22 UTC 2022

Modified Files:
src/sys/arch/xen/x86: hypervisor_machdep.c

Log Message:
When we have pending events in stipending(), evt_set_pending() has to set
the ih_pending flag for each handler too. Xen/i386 should be stable again.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/xen/x86/hypervisor_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/xen/x86/hypervisor_machdep.c
diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.42 src/sys/arch/xen/x86/hypervisor_machdep.c:1.43
--- src/sys/arch/xen/x86/hypervisor_machdep.c:1.42	Tue May 31 14:21:44 2022
+++ src/sys/arch/xen/x86/hypervisor_machdep.c	Tue May 31 18:01:22 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor_machdep.c,v 1.42 2022/05/31 14:21:44 bouyer Exp $	*/
+/*	$NetBSD: hypervisor_machdep.c,v 1.43 2022/05/31 18:01:22 bouyer Exp $	*/
 
 /*
  *
@@ -54,7 +54,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.42 2022/05/31 14:21:44 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.43 2022/05/31 18:01:22 bouyer Exp $");
 
 #include 
 #include 
@@ -159,10 +159,17 @@ evt_set_pending(unsigned int port, unsig
 	KASSERT(args != NULL);
 
 	int *ret = args;
+	struct intrhand *ih;
 
 	if (evtsource[port]) {
 		hypervisor_set_ipending(evtsource[port]->ev_imask, l1i, l2i);
 		evtsource[port]->ev_evcnt.ev_count++;
+		ih = evtsource[port]->ev_handlers;
+		while (ih != NULL) {
+			ih->ih_pending++;
+			ih = ih->ih_evt_next;
+		}
+
 		if (*ret == 0 && curcpu()->ci_ilevel <
 		evtsource[port]->ev_maxlevel)
 			*ret = 1;



CVS commit: src/sys/arch/xen/x86

2022-05-31 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue May 31 18:01:22 UTC 2022

Modified Files:
src/sys/arch/xen/x86: hypervisor_machdep.c

Log Message:
When we have pending events in stipending(), evt_set_pending() has to set
the ih_pending flag for each handler too. Xen/i386 should be stable again.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/xen/x86/hypervisor_machdep.c

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



CVS commit: src/sys/arch/xen/x86

2022-05-31 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue May 31 14:21:44 UTC 2022

Modified Files:
src/sys/arch/xen/x86: hypervisor_machdep.c

Log Message:
Revert previous; evt_set_pending() will set ret to 1 if needed to this was
not our bug.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/xen/x86/hypervisor_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/xen/x86/hypervisor_machdep.c
diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.41 src/sys/arch/xen/x86/hypervisor_machdep.c:1.42
--- src/sys/arch/xen/x86/hypervisor_machdep.c:1.41	Tue May 31 12:52:59 2022
+++ src/sys/arch/xen/x86/hypervisor_machdep.c	Tue May 31 14:21:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor_machdep.c,v 1.41 2022/05/31 12:52:59 bouyer Exp $	*/
+/*	$NetBSD: hypervisor_machdep.c,v 1.42 2022/05/31 14:21:44 bouyer Exp $	*/
 
 /*
  *
@@ -54,7 +54,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.41 2022/05/31 12:52:59 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.42 2022/05/31 14:21:44 bouyer Exp $");
 
 #include 
 #include 
@@ -208,7 +208,6 @@ stipending(void)
 	 */
 
 	while (vci->evtchn_upcall_pending) {
-		ret = 1;
 		x86_disable_intr();
 
 		vci->evtchn_upcall_pending = 0;



CVS commit: src/sys/arch/xen/x86

2022-05-31 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue May 31 14:21:44 UTC 2022

Modified Files:
src/sys/arch/xen/x86: hypervisor_machdep.c

Log Message:
Revert previous; evt_set_pending() will set ret to 1 if needed to this was
not our bug.


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

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



CVS commit: src/sys/arch/xen/x86

2022-05-31 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue May 31 12:52:59 UTC 2022

Modified Files:
src/sys/arch/xen/x86: hypervisor_machdep.c

Log Message:
stipending(): if we're going to process some interrupts don't return 0.
Hopefully fixes random hang seen in i386 Xen PV.

The bug has been there ~forever but was masked by the fact that spllower()
did call event handlers much more often.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/xen/x86/hypervisor_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/xen/x86/hypervisor_machdep.c
diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.40 src/sys/arch/xen/x86/hypervisor_machdep.c:1.41
--- src/sys/arch/xen/x86/hypervisor_machdep.c:1.40	Thu May 19 09:54:27 2022
+++ src/sys/arch/xen/x86/hypervisor_machdep.c	Tue May 31 12:52:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor_machdep.c,v 1.40 2022/05/19 09:54:27 bouyer Exp $	*/
+/*	$NetBSD: hypervisor_machdep.c,v 1.41 2022/05/31 12:52:59 bouyer Exp $	*/
 
 /*
  *
@@ -54,7 +54,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.40 2022/05/19 09:54:27 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.41 2022/05/31 12:52:59 bouyer Exp $");
 
 #include 
 #include 
@@ -208,6 +208,7 @@ stipending(void)
 	 */
 
 	while (vci->evtchn_upcall_pending) {
+		ret = 1;
 		x86_disable_intr();
 
 		vci->evtchn_upcall_pending = 0;



CVS commit: src/sys/arch/xen/x86

2022-05-31 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue May 31 12:52:59 UTC 2022

Modified Files:
src/sys/arch/xen/x86: hypervisor_machdep.c

Log Message:
stipending(): if we're going to process some interrupts don't return 0.
Hopefully fixes random hang seen in i386 Xen PV.

The bug has been there ~forever but was masked by the fact that spllower()
did call event handlers much more often.


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

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



CVS commit: src/sys/arch/xen/x86

2022-05-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu May 26 11:06:14 UTC 2022

Modified Files:
src/sys/arch/xen/x86: pintr.c

Log Message:
aprint_debug(): if a hypercall fail, print the return code.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/xen/x86/pintr.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/pintr.c
diff -u src/sys/arch/xen/x86/pintr.c:1.23 src/sys/arch/xen/x86/pintr.c:1.24
--- src/sys/arch/xen/x86/pintr.c:1.23	Tue May 24 15:51:10 2022
+++ src/sys/arch/xen/x86/pintr.c	Thu May 26 11:06:14 2022
@@ -103,7 +103,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.23 2022/05/24 15:51:10 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.24 2022/05/26 11:06:14 bouyer Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -208,7 +208,7 @@ xen_map_msi_pirq(struct pic *pic, int co
 		}
 		aprint_debug("\n");
 	} else {
-		aprint_debug(" fail\n");
+		aprint_debug(" fail %d\n", ret);
 	}
 	return ret;
 }
@@ -246,7 +246,7 @@ xen_map_msix_pirq(struct pic *pic, int c
 		aprint_debug(" map %d", i);
 		ret = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, _irq);
 		if (ret) {
-			aprint_debug(" fail\n");
+			aprint_debug(" fail %d\n", ret);
 			goto fail;
 		}
 		msi_i->mp_xen_pirq[i] = map_irq.pirq;



CVS commit: src/sys/arch/xen/x86

2022-05-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu May 26 11:06:14 UTC 2022

Modified Files:
src/sys/arch/xen/x86: pintr.c

Log Message:
aprint_debug(): if a hypercall fail, print the return code.


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

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



CVS commit: src/sys/arch/xen/x86

2022-05-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue May 24 15:51:10 UTC 2022

Modified Files:
src/sys/arch/xen/x86: pintr.c

Log Message:
Remove useless info from debug printf, fix format warning on i386


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/xen/x86/pintr.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/pintr.c
diff -u src/sys/arch/xen/x86/pintr.c:1.22 src/sys/arch/xen/x86/pintr.c:1.23
--- src/sys/arch/xen/x86/pintr.c:1.22	Tue May 24 14:00:23 2022
+++ src/sys/arch/xen/x86/pintr.c	Tue May 24 15:51:10 2022
@@ -103,7 +103,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.22 2022/05/24 14:00:23 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.23 2022/05/24 15:51:10 bouyer Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -236,9 +236,9 @@ xen_map_msix_pirq(struct pic *pic, int c
  	map_irq.devfn = (msi_i->mp_dev << 3) | msi_i->mp_fun;
  	map_irq.table_base = msi_i->mp_table_base;
 
-	aprint_debug("xen_map_msix_pirq bus %d devfn 0x%x (%d %d) count %d base 0x%lx",
+	aprint_debug("xen_map_msix_pirq bus %d devfn 0x%x (%d %d) count %d",
 	map_irq.bus, map_irq.devfn, msi_i->mp_dev, msi_i->mp_fun,
-	count, map_irq.table_base);
+	count);
 
 	for (i = 0; i < count; i++) {
 		map_irq.entry_nr = i;



CVS commit: src/sys/arch/xen/x86

2022-05-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue May 24 15:51:10 UTC 2022

Modified Files:
src/sys/arch/xen/x86: pintr.c

Log Message:
Remove useless info from debug printf, fix format warning on i386


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

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



CVS commit: src/sys/arch/xen/x86

2022-05-11 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed May 11 16:22:46 UTC 2022

Modified Files:
src/sys/arch/xen/x86: x86_xpmap.c

Log Message:
In bootstrap, after switching to a new page table make sure that
now-unused memory is unmapped.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/arch/xen/x86/x86_xpmap.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/x86_xpmap.c
diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.90 src/sys/arch/xen/x86/x86_xpmap.c:1.91
--- src/sys/arch/xen/x86/x86_xpmap.c:1.90	Sun Sep  6 02:18:53 2020
+++ src/sys/arch/xen/x86/x86_xpmap.c	Wed May 11 16:22:46 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_xpmap.c,v 1.90 2020/09/06 02:18:53 riastradh Exp $	*/
+/*	$NetBSD: x86_xpmap.c,v 1.91 2022/05/11 16:22:46 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.90 2020/09/06 02:18:53 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.91 2022/05/11 16:22:46 bouyer Exp $");
 
 #include "opt_xen.h"
 #include "opt_ddb.h"
@@ -911,7 +911,7 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 	/* Unpin old PGD */
 	xpq_queue_unpin_table(xpmap_ptom_masked(old_pgd - KERNBASE));
 
-	/* Mark old tables RW */
+	/* Mark old tables RW if used, unmap otherwise */
 	page = old_pgd;
 	addr = xpmap_mtop((paddr_t)L2[pl2_pi(page)] & PTE_4KFRAME);
 	pte = (pd_entry_t *)((u_long)addr + KERNBASE);
@@ -925,6 +925,12 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 		 */
 		pte++;
 	}
+	while (page < old_pgd + (old_count * PAGE_SIZE)) {
+		addr = xpmap_ptom(((u_long)pte) - KERNBASE);
+		xpq_queue_pte_update(addr, 0);
+		page += PAGE_SIZE;
+		pte++;
+	}
 	xpq_flush_queue();
 }
 



CVS commit: src/sys/arch/xen/x86

2022-05-11 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed May 11 16:22:46 UTC 2022

Modified Files:
src/sys/arch/xen/x86: x86_xpmap.c

Log Message:
In bootstrap, after switching to a new page table make sure that
now-unused memory is unmapped.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/arch/xen/x86/x86_xpmap.c

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



CVS commit: src/sys/arch/xen/x86

2022-01-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan  5 20:21:29 UTC 2022

Modified Files:
src/sys/arch/xen/x86: xen_ipi.c

Log Message:
remove DIAGNOSTIC so that function is defined for KASSERTMSG. Hope that the
compiler removes it.


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



CVS commit: src/sys/arch/xen/x86

2022-01-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan  5 20:21:29 UTC 2022

Modified Files:
src/sys/arch/xen/x86: xen_ipi.c

Log Message:
remove DIAGNOSTIC so that function is defined for KASSERTMSG. Hope that the
compiler removes it.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 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.39 src/sys/arch/xen/x86/xen_ipi.c:1.40
--- src/sys/arch/xen/x86/xen_ipi.c:1.39	Thu May  7 15:48:58 2020
+++ src/sys/arch/xen/x86/xen_ipi.c	Wed Jan  5 15:21:29 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: xen_ipi.c,v 1.39 2020/05/07 19:48:58 bouyer Exp $ */
+/* $NetBSD: xen_ipi.c,v 1.40 2022/01/05 20:21:29 christos Exp $ */
 
 /*-
  * Copyright (c) 2011, 2019 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  * Based on: x86/ipi.c
  */
 
-__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.39 2020/05/07 19:48:58 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.40 2022/01/05 20:21:29 christos Exp $");
 
 #include "opt_ddb.h"
 
@@ -151,7 +151,6 @@ xen_ipi_init(void)
 	hypervisor_unmask_event(evtchn);
 }
 
-#ifdef DIAGNOSTIC
 static inline bool /* helper */
 valid_ipimask(uint32_t ipimask)
 {
@@ -166,7 +165,6 @@ valid_ipimask(uint32_t ipimask)
 	}
 
 }
-#endif
 
 int
 xen_send_ipi(struct cpu_info *ci, uint32_t ipimask)



CVS commit: src/sys/arch/xen/x86

2019-06-07 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Fri Jun  7 12:43:52 UTC 2019

Modified Files:
src/sys/arch/xen/x86: xen_intr.c

Log Message:
Fix build for the XEN3_PVHVM kernel by conditoinally compiling
redundant functions x86_enable_intr()/x86_disable_intr()


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 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.16 src/sys/arch/xen/x86/xen_intr.c:1.17
--- src/sys/arch/xen/x86/xen_intr.c:1.16	Thu May  9 17:09:51 2019
+++ src/sys/arch/xen/x86/xen_intr.c	Fri Jun  7 12:43:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_intr.c,v 1.16 2019/05/09 17:09:51 bouyer Exp $	*/
+/*	$NetBSD: xen_intr.c,v 1.17 2019/06/07 12:43:52 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.16 2019/05/09 17:09:51 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.17 2019/06/07 12:43:52 cherry Exp $");
 
 #include 
 #include 
@@ -99,6 +99,7 @@ xen_spllower(int nlevel)
 }
 
 
+#if !defined(XENPVHVM)
 void
 x86_disable_intr(void)
 {
@@ -117,6 +118,8 @@ x86_enable_intr(void)
 		hypervisor_force_callback();
 }
 
+#endif /* !XENPVHVM */
+
 u_long
 xen_read_psl(void)
 {



CVS commit: src/sys/arch/xen/x86

2019-06-07 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Fri Jun  7 12:43:52 UTC 2019

Modified Files:
src/sys/arch/xen/x86: xen_intr.c

Log Message:
Fix build for the XEN3_PVHVM kernel by conditoinally compiling
redundant functions x86_enable_intr()/x86_disable_intr()


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



re: CVS commit: src/sys/arch/xen/x86

2016-12-27 Thread matthew green
> XXX: The tradeoff is a (predicted) single word size comparison
>  penalty, so perhaps a decision needs performance stats.

compared to a TLB shootdown?  let's just move along and
try not to hear the noise this _may_ generate..


.mrg.


Re: CVS commit: src/sys/arch/xen/x86

2016-08-09 Thread Maxime Villard

Le 08/08/2016 à 04:27, Cherry G. Mathew a écrit :

On 2 August 2016 at 19:51, Maxime Villard > wrote:

Module Name:src
Committed By:   maxv
Date:   Tue Aug  2 14:21:53 UTC 2016

Modified Files:
src/sys/arch/xen/x86: x86_xpmap.c

Log Message:
Map the kernel text, rodata and data+bss independently on Xen, with
respectively RX, R and RW.



Hi - wondering why you're getting more divergence from generic x86 -


We are not getting more divergence.


is there a way to do this (and the pg_nx stuff for eg:) without having to 
special case this in Xen ?


Not really. On a normal x86, when the kernel starts, the CPU does not yet have
64bit registers, paging, WP, NX, MSRs, etc. The kernel itself enables them,
and to do so, it uses temporary variables and a temporary page tree before
relocating itself at KERNBASE. All this needs to be done in assembly.

On Xen, however, when the kernel starts, the CPU already has 64bit registers,
paging etc, so the only thing the kernel has to do is creating its own page
table, and for that purpose it also uses temporary variables, such as pg_nx.
This time, it all can be done in C.

This initialization process is referred to as the locore, and even if machdep
and pmap can be shared between amd64<->i386<->PAE<->Xen, the locore cannot. When
it comes to pg_nx, we cannot use pmap_pg_nx, since it is part of the pmap, which
is shared and initialized later. For that same reason, we use nox_flag in
assembly in the amd64 and i386 locores.


Re: CVS commit: src/sys/arch/xen/x86

2016-08-07 Thread Cherry G. Mathew
On 2 August 2016 at 19:51, Maxime Villard  wrote:

> Module Name:src
> Committed By:   maxv
> Date:   Tue Aug  2 14:21:53 UTC 2016
>
> Modified Files:
> src/sys/arch/xen/x86: x86_xpmap.c
>
> Log Message:
> Map the kernel text, rodata and data+bss independently on Xen, with
> respectively RX, R and RW.
>
>
>
Hi - wondering why you're getting more divergence from generic x86 - is
there a way to do this (and the pg_nx stuff for eg:) without having to
special case this in Xen ?

-- 
~~Cherry


Re: CVS commit: src/sys/arch/xen/x86

2013-11-11 Thread Jukka Ruohonen
On Sun, Nov 10, 2013 at 11:17:54AM -0800, John Nemeth wrote:
 } x86_wbind()? Which however appears to be (icorrectly?) #ifndef'd for Xen.
 
  Uh, the function for Xen would be wbinvd(), which would create
 a very nice infinite loop as all that function does is call
 xpq_flush_cache().  This change was fully discussed on tech-xen@.

My point kind of was that why not fix the trivial function for Xen instead
of a direct asm() call?

- Jukka.


Re: CVS commit: src/sys/arch/xen/x86

2013-11-11 Thread Jukka Ruohonen
On Mon, Nov 11, 2013 at 02:52:30AM -0800, John Nemeth wrote:
  My point is, if you want to know, go read the thread in port-xen@,
 or the code.  Also, what trivial function for Xen?

The wrappers in cpufunc.S'es.

- Jukka.


Re: CVS commit: src/sys/arch/xen/x86

2013-11-11 Thread John Nemeth
On Nov 11, 12:30pm, Jukka Ruohonen wrote:
} On Sun, Nov 10, 2013 at 11:17:54AM -0800, John Nemeth wrote:
}  } x86_wbind()? Which however appears to be (icorrectly?) #ifndef'd for Xen.
}  
}   Uh, the function for Xen would be wbinvd(), which would create
}  a very nice infinite loop as all that function does is call
}  xpq_flush_cache().  This change was fully discussed on tech-xen@.

 Oops, that should be port-xen@

} My point kind of was that why not fix the trivial function for Xen instead
} of a direct asm() call?

 My point is, if you want to know, go read the thread in port-xen@,
or the code.  Also, what trivial function for Xen?

}-- End of excerpt from Jukka Ruohonen


Re: CVS commit: src/sys/arch/xen/x86

2013-11-11 Thread Jukka Ruohonen

Thanks for the explanation!

Btw, it was not criticism but a question.

- Jukka.

On Mon, Nov 11, 2013 at 12:31:19PM -0800, John Nemeth wrote:
 On Nov 11,  1:05pm, Jukka Ruohonen wrote:
 } On Mon, Nov 11, 2013 at 02:52:30AM -0800, John Nemeth wrote:
 }   My point is, if you want to know, go read the thread in port-xen@,
 }  or the code.  Also, what trivial function for Xen?
 } 
 } The wrappers in cpufunc.S'es.
 
  So that would be sys/arch/amd64/amd64/cpufunc.S where the
 function is wrapped with ifndef XEN, or sys/arch/i386/i386/i386func.S
 which has a comment near the top that says, These are _not_ shared
 with NetBSD/xen. The Xen version of wbinvd() is located in
 sys/arch/xen/x86/xenfunc.c and it is indeed a simple wrapper
 function, containing the single line, xpq_flush_cache();, as I
 alluded to earlier in text that you snipped.
 
  Xen domU kernels are essentially userland applications for
 the Xen hypervisor.  They do not have direct hardware access and
 are not privileged.  They must make a hypervisor syscall to
 perform many normal kernel functions.  xpq_flush_cache() did this.
 However, it was using a privileged operation that only dom0 kernels
 (or domU kernels that were specially granted the privilege) are
 allowed to do.  Even Xen dom0 kernels which are allowed direct
 hardware access are basically a userland application for the Xen
 hypervisor and must a hypervisor syscall for many things.  Now,
 I suppose I could have created a sys/arch/xen/xen/cpufunc.S with
 the single function xen_wbinvd() that contains the single line
 wbinvd, but why bother?
 
  It is apparent that you are completely unfamiliar with the
 code that you are criticising, and as such this will be my last
 post on the subject.  I don't know if you are famailiar with
 nxr.netbsd.org, but it is a great tool for chasing down things like
 this.  Putting wbinvd in the Definition box would have turned up
 all this stuff.
 
 }-- End of excerpt from Jukka Ruohonen


Re: CVS commit: src/sys/arch/xen/x86

2013-11-11 Thread John Nemeth
On Nov 11,  1:05pm, Jukka Ruohonen wrote:
} On Mon, Nov 11, 2013 at 02:52:30AM -0800, John Nemeth wrote:
}   My point is, if you want to know, go read the thread in port-xen@,
}  or the code.  Also, what trivial function for Xen?
} 
} The wrappers in cpufunc.S'es.

 So that would be sys/arch/amd64/amd64/cpufunc.S where the
function is wrapped with ifndef XEN, or sys/arch/i386/i386/i386func.S
which has a comment near the top that says, These are _not_ shared
with NetBSD/xen. The Xen version of wbinvd() is located in
sys/arch/xen/x86/xenfunc.c and it is indeed a simple wrapper
function, containing the single line, xpq_flush_cache();, as I
alluded to earlier in text that you snipped.

 Xen domU kernels are essentially userland applications for
the Xen hypervisor.  They do not have direct hardware access and
are not privileged.  They must make a hypervisor syscall to
perform many normal kernel functions.  xpq_flush_cache() did this.
However, it was using a privileged operation that only dom0 kernels
(or domU kernels that were specially granted the privilege) are
allowed to do.  Even Xen dom0 kernels which are allowed direct
hardware access are basically a userland application for the Xen
hypervisor and must a hypervisor syscall for many things.  Now,
I suppose I could have created a sys/arch/xen/xen/cpufunc.S with
the single function xen_wbinvd() that contains the single line
wbinvd, but why bother?

 It is apparent that you are completely unfamiliar with the
code that you are criticising, and as such this will be my last
post on the subject.  I don't know if you are famailiar with
nxr.netbsd.org, but it is a great tool for chasing down things like
this.  Putting wbinvd in the Definition box would have turned up
all this stuff.

}-- End of excerpt from Jukka Ruohonen


Re: CVS commit: src/sys/arch/xen/x86

2013-11-10 Thread Jukka Ruohonen
On Sun, Nov 10, 2013 at 01:19:13AM +, John Nemeth wrote:
 Module Name:  src
 Committed By: jnemeth
 Date: Sun Nov 10 01:19:13 UTC 2013
 
 Modified Files:
   src/sys/arch/xen/x86: x86_xpmap.c
 
 Log Message:
 Change xpq_flush_cache to just do WBINVD letting the hypervisor trap and
 handle it as MMUEXT_FLUSH_CACHE is a privileged hypervisor operation.

x86_wbind()? Which however appears to be (icorrectly?) #ifndef'd for Xen.

- Jukka.


Re: CVS commit: src/sys/arch/xen/x86

2013-11-10 Thread John Nemeth
On Nov 10,  4:50pm, Jukka Ruohonen wrote:
} On Sun, Nov 10, 2013 at 01:19:13AM +, John Nemeth wrote:
}  Module Name:src
}  Committed By:   jnemeth
}  Date:   Sun Nov 10 01:19:13 UTC 2013
}  
}  Modified Files:
}  src/sys/arch/xen/x86: x86_xpmap.c
}  
}  Log Message:
}  Change xpq_flush_cache to just do WBINVD letting the hypervisor trap and
}  handle it as MMUEXT_FLUSH_CACHE is a privileged hypervisor operation.
} 
} x86_wbind()? Which however appears to be (icorrectly?) #ifndef'd for Xen.

 Uh, the function for Xen would be wbinvd(), which would create
a very nice infinite loop as all that function does is call
xpq_flush_cache().  This change was fully discussed on tech-xen@.

}-- End of excerpt from Jukka Ruohonen


CVS commit: src/sys/arch/xen/x86

2010-03-09 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Mar  9 23:12:06 UTC 2010

Modified Files:
src/sys/arch/xen/x86: xen_bus_dma.c

Log Message:
Although Xen's documentation states that the address_bits field is not used
by XENMEM_decrease_reservation, it is checked by the hypervisor. In certain
circumstances (stack leak), the field could have an improper value, leading
to a fail of the hypercall.

Set it to 0 (no addressing restriction) to avoid that.

Patch tested by Sam Fourman and h...@.

This should fix the rare failed allocating DMA memory encountered
under NetBSD dom0. Will ask for a pull-up.


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

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



CVS commit: src/sys/arch/xen/x86

2010-03-09 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Mar  9 23:12:06 UTC 2010

Modified Files:
src/sys/arch/xen/x86: xen_bus_dma.c

Log Message:
Although Xen's documentation states that the address_bits field is not used
by XENMEM_decrease_reservation, it is checked by the hypervisor. In certain
circumstances (stack leak), the field could have an improper value, leading
to a fail of the hypercall.

Set it to 0 (no addressing restriction) to avoid that.

Patch tested by Sam Fourman and h...@.

This should fix the rare failed allocating DMA memory encountered
under NetBSD dom0. Will ask for a pull-up.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/xen/x86/xen_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/xen/x86/xen_bus_dma.c
diff -u src/sys/arch/xen/x86/xen_bus_dma.c:1.19 src/sys/arch/xen/x86/xen_bus_dma.c:1.20
--- src/sys/arch/xen/x86/xen_bus_dma.c:1.19	Tue Mar  2 00:13:50 2010
+++ src/sys/arch/xen/x86/xen_bus_dma.c	Tue Mar  9 23:12:06 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_bus_dma.c,v 1.19 2010/03/02 00:13:50 jym Exp $	*/
+/*	$NetBSD: xen_bus_dma.c,v 1.20 2010/03/09 23:12:06 jym Exp $	*/
 /*	NetBSD bus_dma.c,v 1.21 2005/04/16 07:53:35 yamt Exp */
 
 /*-
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: xen_bus_dma.c,v 1.19 2010/03/02 00:13:50 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: xen_bus_dma.c,v 1.20 2010/03/09 23:12:06 jym Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -95,6 +95,7 @@
 		xenguest_handle(res.extent_start) = mfn;
 		res.nr_extents = 1;
 		res.extent_order = 0;
+		res.address_bits = 0;
 		res.domid = DOMID_SELF;
 		error = HYPERVISOR_memory_op(XENMEM_decrease_reservation, res);
 		if (error != 1) {



Re: CVS commit: src/sys/arch/xen/x86

2010-03-03 Thread Izumi Tsutsui
 OT: these are a little unclear to me. Could someone outline what
 
   roundup
   roundup2
   rounddown
   howmany

They are in sys/param.h.

 #define howmany(x, y)   (((x)+((y)-1))/(y))
how many y-byte blocks are required to store x-bytes region?

 #define roundup(x, y)   x)+((y)-1))/(y))*(y))
 #define rounddown(x,y)  (((x)/(y))*(y))
roundup or rounddown x per y, as is?

 #define roundup2(x, m)  (((x) + (m) - 1)  ~((m) - 1))
optimized version (avoid division op) roundup()
where m is a power of two

---
Izumi Tsutsui


CVS commit: src/sys/arch/xen/x86

2010-03-02 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Wed Mar  3 00:09:03 UTC 2010

Modified Files:
src/sys/arch/xen/x86: cpu.c

Log Message:
Use roundup2() instead of hardcoding the CACHE_LINE_SIZE rounding
operation.


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

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



CVS commit: src/sys/arch/xen/x86

2010-03-02 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Wed Mar  3 00:09:03 UTC 2010

Modified Files:
src/sys/arch/xen/x86: cpu.c

Log Message:
Use roundup2() instead of hardcoding the CACHE_LINE_SIZE rounding
operation.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/xen/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/xen/x86/cpu.c
diff -u src/sys/arch/xen/x86/cpu.c:1.41 src/sys/arch/xen/x86/cpu.c:1.42
--- src/sys/arch/xen/x86/cpu.c:1.41	Wed Feb 24 22:37:55 2010
+++ src/sys/arch/xen/x86/cpu.c	Wed Mar  3 00:09:03 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.41 2010/02/24 22:37:55 dyoung Exp $	*/
+/*	$NetBSD: cpu.c,v 1.42 2010/03/03 00:09:03 jym Exp $	*/
 /* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp  */
 
 /*-
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.41 2010/02/24 22:37:55 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.42 2010/03/03 00:09:03 jym Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -236,8 +236,7 @@
 		aprint_naive(: Application Processor\n);
 		ptr = (uintptr_t)kmem_zalloc(sizeof(*ci) + CACHE_LINE_SIZE - 1,
 		KM_SLEEP);
-		ci = (struct cpu_info *)((ptr + CACHE_LINE_SIZE - 1) 
-		~(CACHE_LINE_SIZE - 1));
+		ci = (struct cpu_info *)roundup2(ptr, CACHE_LINE_SIZE);
 		ci-ci_curldt = -1;
 	} else {
 		aprint_naive(: %s Processor\n,
@@ -372,8 +371,7 @@
 		aprint_naive(: Application Processor\n);
 		ptr = (uintptr_t)kmem_alloc(sizeof(*ci) + CACHE_LINE_SIZE - 1,
 		KM_SLEEP);
-		ci = (struct cpu_info *)((ptr + CACHE_LINE_SIZE - 1) 
-		~(CACHE_LINE_SIZE - 1));
+		ci = (struct cpu_info *)roundup2(ptr, CACHE_LINE_SIZE);
 		memset(ci, 0, sizeof(*ci));
 #ifdef TRAPLOG
 		ci-ci_tlog_base = kmem_zalloc(sizeof(struct tlog), KM_SLEEP);



CVS commit: src/sys/arch/xen/x86

2010-03-01 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Mar  2 00:13:50 UTC 2010

Modified Files:
src/sys/arch/xen/x86: xen_bus_dma.c

Log Message:
Catch the return value from the XENMEM_decrease_reservation hypercall,
and not some error value stored earlier.

While here, fix a typo in a comment.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/xen/x86/xen_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/xen/x86/xen_bus_dma.c
diff -u src/sys/arch/xen/x86/xen_bus_dma.c:1.18 src/sys/arch/xen/x86/xen_bus_dma.c:1.19
--- src/sys/arch/xen/x86/xen_bus_dma.c:1.18	Sat Feb 27 09:22:40 2010
+++ src/sys/arch/xen/x86/xen_bus_dma.c	Tue Mar  2 00:13:50 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_bus_dma.c,v 1.18 2010/02/27 09:22:40 jym Exp $	*/
+/*	$NetBSD: xen_bus_dma.c,v 1.19 2010/03/02 00:13:50 jym Exp $	*/
 /*	NetBSD bus_dma.c,v 1.21 2005/04/16 07:53:35 yamt Exp */
 
 /*-
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: xen_bus_dma.c,v 1.18 2010/02/27 09:22:40 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: xen_bus_dma.c,v 1.19 2010/03/02 00:13:50 jym Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -81,7 +81,7 @@
 	npagesreq = (size  PAGE_SHIFT);
 	KASSERT(npages = npagesreq);
 
-	/* get npages from UWM, and give them back to the hypervisor */
+	/* get npages from UVM, and give them back to the hypervisor */
 	error = uvm_pglistalloc(((psize_t)npages)  PAGE_SHIFT,
 0, avail_end, 0, 0, mlistp, npages, (flags  BUS_DMA_NOWAIT) == 0);
 	if (error)
@@ -96,8 +96,8 @@
 		res.nr_extents = 1;
 		res.extent_order = 0;
 		res.domid = DOMID_SELF;
-		if (HYPERVISOR_memory_op(XENMEM_decrease_reservation, res)
-		!= 1) {
+		error = HYPERVISOR_memory_op(XENMEM_decrease_reservation, res);
+		if (error != 1) {
 #ifdef DEBUG
 			printf(xen_alloc_contig: XENMEM_decrease_reservation 
 			failed: err %d (pa %# PRIxPADDR  mfn %#lx)\n,



CVS commit: src/sys/arch/xen/x86

2010-03-01 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Mar  2 00:13:50 UTC 2010

Modified Files:
src/sys/arch/xen/x86: xen_bus_dma.c

Log Message:
Catch the return value from the XENMEM_decrease_reservation hypercall,
and not some error value stored earlier.

While here, fix a typo in a comment.


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

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



CVS commit: src/sys/arch/xen/x86

2010-02-27 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sat Feb 27 09:22:40 UTC 2010

Modified Files:
src/sys/arch/xen/x86: xen_bus_dma.c

Log Message:
Make a XENMEM_decrease_reservation DEBUG printf() more meaningful.


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

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



CVS commit: src/sys/arch/xen/x86

2010-02-27 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sat Feb 27 09:22:40 UTC 2010

Modified Files:
src/sys/arch/xen/x86: xen_bus_dma.c

Log Message:
Make a XENMEM_decrease_reservation DEBUG printf() more meaningful.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/xen/x86/xen_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/xen/x86/xen_bus_dma.c
diff -u src/sys/arch/xen/x86/xen_bus_dma.c:1.17 src/sys/arch/xen/x86/xen_bus_dma.c:1.18
--- src/sys/arch/xen/x86/xen_bus_dma.c:1.17	Fri Feb 12 01:55:46 2010
+++ src/sys/arch/xen/x86/xen_bus_dma.c	Sat Feb 27 09:22:40 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_bus_dma.c,v 1.17 2010/02/12 01:55:46 jym Exp $	*/
+/*	$NetBSD: xen_bus_dma.c,v 1.18 2010/02/27 09:22:40 jym Exp $	*/
 /*	NetBSD bus_dma.c,v 1.21 2005/04/16 07:53:35 yamt Exp */
 
 /*-
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: xen_bus_dma.c,v 1.17 2010/02/12 01:55:46 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: xen_bus_dma.c,v 1.18 2010/02/27 09:22:40 jym Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -100,7 +100,8 @@
 		!= 1) {
 #ifdef DEBUG
 			printf(xen_alloc_contig: XENMEM_decrease_reservation 
-			failed!\n);
+			failed: err %d (pa %# PRIxPADDR  mfn %#lx)\n,
+			error, pa, mfn);
 #endif
 			xpmap_phys_to_machine_mapping[
 			(pa - XPMAP_OFFSET)  PAGE_SHIFT] = mfn;



CVS commit: src/sys/arch/xen/x86

2010-02-15 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Mon Feb 15 23:53:56 UTC 2010

Modified Files:
src/sys/arch/xen/x86: mainbus.c

Log Message:
Don't use the global variable pci_mode, but use a local copy of
the return value of pci_mode_detect(), instead.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/xen/x86/mainbus.c

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