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)



The following reply was made to PR kern/49330; it has been noted by GNATS.

From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: kern-bug-people%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost,
	gnats-admin%netbsd.org@localhost, brad%anduin.eldar.org@localhost
Subject: Re: kern/49330 (Attempting to compile a Xen DOM0 and DRMKMS kernel doesn't compile)
Date: Fri, 6 Mar 2015 14:08:24 +0000

 This is a multi-part message in MIME format.
 --=_ngjbvaBAGjbjnb156wY3Fz/JsuWfskOa
 
    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.
 
 --=_ngjbvaBAGjbjnb156wY3Fz/JsuWfskOa
 Content-Type: text/plain; charset="ISO-8859-1"; name="xenkms"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="xenkms.patch"
 
 Index: sys/arch/amd64/amd64/machdep.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 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 =3D KERNBASE + first_avail;
  	physmem =3D xen_start_info.nr_pages;
 =20
 -	uvm_page_physload(atop(avail_start),
 -		atop(avail_end), atop(avail_start),
 -		atop(avail_end), VM_FREELIST_DEFAULT);
 +	initxen_load_memmap();
  #endif	/* !XEN */
 =20
  	init_x86_64_msgbuf();
 Index: sys/arch/i386/i386/machdep.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 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();
 =20
  	/* Reclaim the boot gdt page - see locore.s */
  	{
 Index: sys/arch/x86/include/machdep.h
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 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);
 =20
 +#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);
 =20
  void	x86_startup(void);
 Index: sys/arch/x86/x86/x86_machdep.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 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));
  }
 =20
 -#ifndef XEN
 +static struct {
 +	int freelist;
 +	uint64_t limit;
 +} x86_freelists[VM_NFREELIST] =3D {
 +	{ 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 <=3D maxaddr)
 +		return VM_NFREELIST;
 +
 +	for (i =3D 0; i < __arraycount(x86_freelists); i++) {
 +		if ((x86_freelists[i].limit - 1) <=3D 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 =3D round_page(avail_start);
 +	end =3D 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 =3D __arraycount(x86_freelists);
 +	while (0 < i--) {
 +		if (x86_freelists[i].limit =3D=3D 0) {
 +			/* Default freelist.  Put the rest here.  */
 +			KASSERT(x86_freelists[i].freelist =3D=3D
 +			    VM_FREELIST_DEFAULT);
 +			pgstart =3D atop(start);
 +			pgend =3D 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 <=3D end) {
 +			/* Put what pages we can here, and move up.  */
 +			pgstart =3D atop(start);
 +			pgend =3D atop(x86_freelists[i].limit);
 +			uvm_page_physload(pgstart, pgend, pgstart, pgend,
 +			    x86_freelists[i].freelist);
 +			start =3D x86_freelists[i].limit;
 +		} else {
 +			/* All pages live below here, so use default.  */
 +			x86_freelists[i].freelist =3D VM_FREELIST_DEFAULT;
 +		}
 +	}
 +}
 +
 +#else
 =20
  #define KBTOB(x)	((size_t)(x) * 1024UL)
  #define MBTOB(x)	((size_t)(x) * 1024UL * 1024UL)
 =20
 -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
 =20
 -static struct {
 -	int freelist;
 -	uint64_t limit;
 -} x86_freelists[VM_NFREELIST] =3D {
 -	{ 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 <=3D maxaddr)
 -		return VM_NFREELIST;
 -
 -	for (i =3D 0; i < __arraycount(x86_freelists); i++) {
 -		if ((x86_freelists[i].limit - 1) <=3D 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
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 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
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 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
 =20
 -#undef VM_NFREELIST
 -#undef VM_FREELIST_FIRST16
 -#define	VM_NFREELIST	1
  #endif /* _VMPARAM_H_ */
 Index: sys/arch/xen/xen/xen_acpi_machdep.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 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>
 =20
 +const int acpi_md_vesa_modenum =3D 0;
 +
  int
  acpi_md_sleep(int state)
  {
 
 --=_ngjbvaBAGjbjnb156wY3Fz/JsuWfskOa--
 


Home | Main Index | Thread Index | Old Index