NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/49330 (Attempting to compile a Xen DOM0 and DRMKMS kernel doesn't compile)



   Date: Sat, 28 Feb 2015 15:04:55 +0000 (UTC)
   From: riastradh%NetBSD.org@localhost

   Was afraid I might find a system where pci_intr_handle_t is not int.
   It shouldn't be too hard to adapt the drm code to this case: just
   introduce a new type drm_irq_t or something, as a union of all the
   possible interrupt handle types in drm, and put it in the right
   places, with the compiler's help.  But it will take some work, and
   cause more divergence from upstream.

Turns out drm doesn't actually use PCI interrupt handles -- the irq
numbers it ostensibly handles appear to be a sham.  So I committed all
the changes in drm necessary to work around this.

There remain some issues in Xen.  The attached patch makes a Xen/amd64
dom0 kernel build with drm (including Intel, Radeon, and Nouveau), but
I'm clueless about Xen, so I'm not going to commit it myself.
Index: sys/arch/amd64/amd64/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/amd64/machdep.c,v
retrieving revision 1.211
diff -p -u -r1.211 machdep.c
--- sys/arch/amd64/amd64/machdep.c	12 May 2014 22:50:03 -0000	1.211
+++ sys/arch/amd64/amd64/machdep.c	6 Mar 2015 13:47:16 -0000
@@ -1638,9 +1638,7 @@ init_x86_64(paddr_t first_avail)
 	kern_end = KERNBASE + first_avail;
 	physmem = xen_start_info.nr_pages;
 
-	uvm_page_physload(atop(avail_start),
-		atop(avail_end), atop(avail_start),
-		atop(avail_end), VM_FREELIST_DEFAULT);
+	initxen_load_memmap();
 #endif	/* !XEN */
 
 	init_x86_64_msgbuf();
Index: sys/arch/i386/i386/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.753
diff -p -u -r1.753 machdep.c
--- sys/arch/i386/i386/machdep.c	23 Jan 2015 02:52:14 -0000	1.753
+++ sys/arch/i386/i386/machdep.c	6 Mar 2015 13:47:17 -0000
@@ -1269,9 +1269,7 @@ init386(paddr_t first_avail)
 	    "0x%" PRIx64 " (%" PRId64 ")\n",
 	    (uint64_t)avail_start, (uint64_t)atop(avail_start),
 	    (uint64_t)avail_end, (uint64_t)atop(avail_end)));
-	uvm_page_physload(atop(avail_start), atop(avail_end),
-	    atop(avail_start), atop(avail_end),
-	    VM_FREELIST_DEFAULT);
+	initxen_load_memmap();
 
 	/* Reclaim the boot gdt page - see locore.s */
 	{
Index: sys/arch/x86/include/machdep.h
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/include/machdep.h,v
retrieving revision 1.7
diff -p -u -r1.7 machdep.h
--- sys/arch/x86/include/machdep.h	12 Jun 2014 19:02:35 -0000	1.7
+++ sys/arch/x86/include/machdep.h	6 Mar 2015 13:47:17 -0000
@@ -41,9 +41,13 @@ void	x86_cpu_idle_init(void);
 void	x86_cpu_idle_get(void (**)(void), char *, size_t);
 void	x86_cpu_idle_set(void (*)(void), const char *, bool);
 
+#ifdef XEN
+void	initxen_load_memmap(void);
+#else
 int	initx86_parse_memmap(struct btinfo_memmap *, struct extent *);
 int	initx86_fake_memmap(struct extent *);
 int	initx86_load_memmap(paddr_t first_avail);
+#endif
 int	x86_select_freelist(uint64_t);
 
 void	x86_startup(void);
Index: sys/arch/x86/x86/x86_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/x86_machdep.c,v
retrieving revision 1.67
diff -p -u -r1.67 x86_machdep.c
--- sys/arch/x86/x86/x86_machdep.c	11 Aug 2014 03:43:25 -0000	1.67
+++ sys/arch/x86/x86/x86_machdep.c	6 Mar 2015 13:47:17 -0000
@@ -426,13 +426,96 @@ x86_cpu_idle_set(void (*func)(void), con
 	(void)strlcpy(x86_cpu_idle_text, text, sizeof(x86_cpu_idle_text));
 }
 
-#ifndef XEN
+static struct {
+	int freelist;
+	uint64_t limit;
+} x86_freelists[VM_NFREELIST] = {
+	{ VM_FREELIST_DEFAULT, 0 },
+#ifdef VM_FREELIST_FIRST1T
+	/* 40-bit addresses needed for modern graphics.  */
+	{ VM_FREELIST_FIRST1T,	1ULL * 1024 * 1024 * 1024 * 1024 },
+#endif
+#ifdef VM_FREELIST_FIRST64G
+	/* 36-bit addresses needed for oldish graphics.  */
+	{ VM_FREELIST_FIRST64G,	64ULL * 1024 * 1024 * 1024 },
+#endif
+#ifdef VM_FREELIST_FIRST4G
+	/* 32-bit addresses needed for PCI 32-bit DMA and old graphics.  */
+	{ VM_FREELIST_FIRST4G,	4ULL * 1024 * 1024 * 1024 },
+#endif
+	/* 30-bit addresses needed for ancient graphics.  */
+	{ VM_FREELIST_FIRST1G,	1ULL * 1024 * 1024 * 1024 },
+	/* 24-bit addresses needed for ISA DMA.  */
+	{ VM_FREELIST_FIRST16,	16 * 1024 * 1024 },
+};
+
+extern paddr_t avail_start, avail_end;
+
+int
+x86_select_freelist(uint64_t maxaddr)
+{
+	unsigned int i;
+
+	if (avail_end <= maxaddr)
+		return VM_NFREELIST;
+
+	for (i = 0; i < __arraycount(x86_freelists); i++) {
+		if ((x86_freelists[i].limit - 1) <= maxaddr)
+			return x86_freelists[i].freelist;
+	}
+
+	panic("no freelist for maximum address %"PRIx64, maxaddr);
+}
+
+#ifdef XEN
+
+void
+initxen_load_memmap(void)
+{
+	paddr_t start, end, pgstart, pgend;
+	unsigned i;
+
+	start = round_page(avail_start);
+	end = trunc_page(avail_end);
+	KASSERT(start < end);
+
+	/*
+	 * x86_freelists is in descending order of address limit.
+	 * Iterate over the requested freelists in ascending order of
+	 * limit, loading what pages we can.
+	 */
+	i = __arraycount(x86_freelists);
+	while (0 < i--) {
+		if (x86_freelists[i].limit == 0) {
+			/* Default freelist.  Put the rest here.  */
+			KASSERT(x86_freelists[i].freelist ==
+			    VM_FREELIST_DEFAULT);
+			pgstart = atop(start);
+			pgend = atop(end);
+			uvm_page_physload(pgstart, pgend, pgstart, pgend,
+			    VM_FREELIST_DEFAULT);
+		} else if (x86_freelists[i].limit < start) {
+			/* No pages live below here, so leave it empty.  */
+			continue;
+		} else if (x86_freelists[i].limit <= end) {
+			/* Put what pages we can here, and move up.  */
+			pgstart = atop(start);
+			pgend = atop(x86_freelists[i].limit);
+			uvm_page_physload(pgstart, pgend, pgstart, pgend,
+			    x86_freelists[i].freelist);
+			start = x86_freelists[i].limit;
+		} else {
+			/* All pages live below here, so use default.  */
+			x86_freelists[i].freelist = VM_FREELIST_DEFAULT;
+		}
+	}
+}
+
+#else
 
 #define KBTOB(x)	((size_t)(x) * 1024UL)
 #define MBTOB(x)	((size_t)(x) * 1024UL * 1024UL)
 
-extern paddr_t avail_start, avail_end;
-
 static int
 add_mem_cluster(phys_ram_seg_t *seg_clusters, int seg_cluster_cnt,
 	struct extent *iomem_ex,
@@ -706,45 +789,6 @@ extern vaddr_t kern_end;
 extern vaddr_t module_start, module_end;
 #endif
 
-static struct {
-	int freelist;
-	uint64_t limit;
-} x86_freelists[VM_NFREELIST] = {
-	{ VM_FREELIST_DEFAULT, 0 },
-#ifdef VM_FREELIST_FIRST1T
-	/* 40-bit addresses needed for modern graphics.  */
-	{ VM_FREELIST_FIRST1T,	1ULL * 1024 * 1024 * 1024 * 1024 },
-#endif
-#ifdef VM_FREELIST_FIRST64G
-	/* 36-bit addresses needed for oldish graphics.  */
-	{ VM_FREELIST_FIRST64G,	64ULL * 1024 * 1024 * 1024 },
-#endif
-#ifdef VM_FREELIST_FIRST4G
-	/* 32-bit addresses needed for PCI 32-bit DMA and old graphics.  */
-	{ VM_FREELIST_FIRST4G,	4ULL * 1024 * 1024 * 1024 },
-#endif
-	/* 30-bit addresses needed for ancient graphics.  */
-	{ VM_FREELIST_FIRST1G,	1ULL * 1024 * 1024 * 1024 },
-	/* 24-bit addresses needed for ISA DMA.  */
-	{ VM_FREELIST_FIRST16,	16 * 1024 * 1024 },
-};
-
-int
-x86_select_freelist(uint64_t maxaddr)
-{
-	unsigned int i;
-
-	if (avail_end <= maxaddr)
-		return VM_NFREELIST;
-
-	for (i = 0; i < __arraycount(x86_freelists); i++) {
-		if ((x86_freelists[i].limit - 1) <= maxaddr)
-			return x86_freelists[i].freelist;
-	}
-
-	panic("no freelist for maximum address %"PRIx64, maxaddr);
-}
-
 int
 initx86_load_memmap(paddr_t first_avail)
 {
Index: sys/arch/xen/conf/files.xen
===================================================================
RCS file: /cvsroot/src/sys/arch/xen/conf/files.xen,v
retrieving revision 1.137
diff -p -u -r1.137 files.xen
--- sys/arch/xen/conf/files.xen	4 Jan 2015 07:34:14 -0000	1.137
+++ sys/arch/xen/conf/files.xen	6 Mar 2015 13:47:17 -0000
@@ -134,6 +134,7 @@ file	arch/x86/x86/core_machdep.c	coredum
 file	arch/xen/x86/xen_bus_dma.c	machdep
 file	arch/x86/x86/bus_space.c	machdep
 file	arch/xen/x86/consinit.c		machdep
+file	arch/x86/x86/genfb_machdep.c	machdep & genfb
 file	arch/x86/x86/identcpu.c		machdep
 file	arch/xen/x86/intr.c		machdep
 file	arch/xen/x86/xen_ipi.c		multiprocessor
Index: sys/arch/xen/include/amd64/vmparam.h
===================================================================
RCS file: /cvsroot/src/sys/arch/xen/include/amd64/vmparam.h,v
retrieving revision 1.2
diff -p -u -r1.2 vmparam.h
--- sys/arch/xen/include/amd64/vmparam.h	22 Nov 2007 16:17:02 -0000	1.2
+++ sys/arch/xen/include/amd64/vmparam.h	6 Mar 2015 13:47:17 -0000
@@ -32,7 +32,4 @@
 #undef VM_PHYSSEG_MAX
 #define	VM_PHYSSEG_MAX	1
 
-#undef VM_NFREELIST
-#undef VM_FREELIST_FIRST16
-#define	VM_NFREELIST	1
 #endif /* _VMPARAM_H_ */
Index: sys/arch/xen/xen/xen_acpi_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/xen/xen/xen_acpi_machdep.c,v
retrieving revision 1.5
diff -p -u -r1.5 xen_acpi_machdep.c
--- sys/arch/xen/xen/xen_acpi_machdep.c	18 Aug 2009 16:41:03 -0000	1.5
+++ sys/arch/xen/xen/xen_acpi_machdep.c	6 Mar 2015 13:47:17 -0000
@@ -10,6 +10,8 @@ __KERNEL_RCSID(0, "$NetBSD: xen_acpi_mac
 #define ACPI_MACHDEP_PRIVATE
 #include <machine/acpi_machdep.h>
 
+const int acpi_md_vesa_modenum = 0;
+
 int
 acpi_md_sleep(int state)
 {


Home | Main Index | Thread Index | Old Index