Module Name:    src
Committed By:   snj
Date:           Sat Oct  3 23:49:50 UTC 2009

Modified Files:
        src/sys/arch/amd64/amd64 [netbsd-5]: machdep.c
        src/sys/arch/i386/i386 [netbsd-5]: machdep.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1054):
        sys/arch/amd64/amd64/machdep.c: revision 1.124
        sys/arch/i386/i386/machdep.c: revision 1.660
Prepare for PCI frontend support in Xen3 domUs:
call x86_bus_space_init() and x86_bus_space_mallocok() if we have ISA or PCI
  devices configured; not only for non-Xen or dom0 Xen
On Xen, always call PHYSDEVOP_SET_IOPL on context switch
on amd64, also call PHYSDEVOP_SET_IOPL from x86_64_proc0_tss_ldt_init()


To generate a diff of this commit:
cvs rdiff -u -r1.102.4.10 -r1.102.4.11 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.644.4.10 -r1.644.4.11 src/sys/arch/i386/i386/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/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.102.4.10 src/sys/arch/amd64/amd64/machdep.c:1.102.4.11
--- src/sys/arch/amd64/amd64/machdep.c:1.102.4.10	Sat Apr  4 17:39:09 2009
+++ src/sys/arch/amd64/amd64/machdep.c	Sat Oct  3 23:49:50 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.102.4.10 2009/04/04 17:39:09 snj Exp $	*/
+/*	$NetBSD: machdep.c,v 1.102.4.11 2009/10/03 23:49:50 snj Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008
@@ -112,7 +112,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.102.4.10 2009/04/04 17:39:09 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.102.4.11 2009/10/03 23:49:50 snj Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -131,6 +131,8 @@
 #ifndef XEN
 #include "opt_physmem.h"
 #endif
+#include "isa.h"
+#include "pci.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -365,7 +367,7 @@
 	format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
 	printf("avail memory = %s\n", pbuf);
 
-#if !defined(XEN) || defined(DOM0OPS)
+#if NISA > 0 || NPCI > 0
 	/* Safe for i/o port / memory space allocation to use malloc now. */
 	x86_bus_space_mallocok();
 #endif
@@ -391,12 +393,10 @@
 	struct cpu_info *ci;
 	ci = curcpu();
 	HYPERVISOR_stack_switch(GSEL(GDATA_SEL, SEL_KPL), new->pcb_rsp0);
-	if (xendomain_is_privileged()) {
-		struct physdev_op physop;
-		physop.cmd = PHYSDEVOP_SET_IOPL;
-		physop.u.set_iopl.iopl = new->pcb_iopl;
-		HYPERVISOR_physdev_op(&physop);
-	}
+	struct physdev_op physop;
+	physop.cmd = PHYSDEVOP_SET_IOPL;
+	physop.u.set_iopl.iopl = new->pcb_iopl;
+	HYPERVISOR_physdev_op(&physop);
 	if (new->pcb_fpcpu != ci) {
 		HYPERVISOR_fpu_taskswitch(1);
 	}
@@ -429,10 +429,16 @@
 #if !defined(XEN)
 	lldt(pcb->pcb_ldt_sel);
 #else
+	{
+	struct physdev_op physop;
 	xen_set_ldt((vaddr_t) ldtstore, LDT_SIZE >> 3);
 	/* Reset TS bit and set kernel stack for interrupt handlers */
 	HYPERVISOR_fpu_taskswitch(1);
 	HYPERVISOR_stack_switch(GSEL(GDATA_SEL, SEL_KPL), pcb->pcb_rsp0);
+	physop.cmd = PHYSDEVOP_SET_IOPL;
+	physop.u.set_iopl.iopl = pcb->pcb_iopl;
+	HYPERVISOR_physdev_op(&physop);
+	}
 #endif /* XEN */
 }
 
@@ -1399,7 +1405,7 @@
 	__PRINTK(("pcb_cr3 0x%lx\n", xen_start_info.pt_base - KERNBASE));
 #endif
 
-#if !defined(XEN) || defined(DOM0OPS)
+#if NISA > 0 || NPCI > 0
 	x86_bus_space_init();
 #endif
 

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.644.4.10 src/sys/arch/i386/i386/machdep.c:1.644.4.11
--- src/sys/arch/i386/i386/machdep.c:1.644.4.10	Sat Apr  4 17:39:09 2009
+++ src/sys/arch/i386/i386/machdep.c	Sat Oct  3 23:49:50 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.644.4.10 2009/04/04 17:39:09 snj Exp $	*/
+/*	$NetBSD: machdep.c,v 1.644.4.11 2009/10/03 23:49:50 snj Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.644.4.10 2009/04/04 17:39:09 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.644.4.11 2009/10/03 23:49:50 snj Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -513,7 +513,7 @@
 	printf("avail memory = %s\n", pbuf);
 
 	/* Safe for i/o port / memory space allocation to use malloc now. */
-#if !defined(XEN) || defined(DOM0OPS)
+#if NISA > 0 || NPCI > 0
 	x86_bus_space_mallocok();
 #endif
 
@@ -580,21 +580,20 @@
 
 	HYPERVISOR_stack_switch(GSEL(GDATA_SEL, SEL_KPL), pcb->pcb_esp0);
 
-	if (xendomain_is_privileged()) {
-		int iopl = pcb->pcb_iopl;
 #ifdef XEN3
-	        struct physdev_op physop;
-		physop.cmd = PHYSDEVOP_SET_IOPL;
-		physop.u.set_iopl.iopl = iopl;
-		HYPERVISOR_physdev_op(&physop);
+	struct physdev_op physop;
+	physop.cmd = PHYSDEVOP_SET_IOPL;
+	physop.u.set_iopl.iopl = pcb->pcb_iopl;
+	HYPERVISOR_physdev_op(&physop);
 #else
+	if (xendomain_is_privileged()) {
 		dom0_op_t op;
 		op.cmd = DOM0_IOPL;
 		op.u.iopl.domain = DOMID_SELF;
-		op.u.iopl.iopl = iopl;
+		op.u.iopl.iopl = pcb->pcb_iopl;
 		HYPERVISOR_dom0_op(&op);
-#endif
 	}
+#endif
 }
 #endif /* XEN */
 

Reply via email to