From owner-p4-projects@FreeBSD.ORG Wed Jan 11 14:20:29 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6EFEC16A422; Wed, 11 Jan 2006 14:20:28 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E57C716A420; Wed, 11 Jan 2006 14:20:27 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail6.speedfactory.net [66.23.216.219]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2ADEE43D45; Wed, 11 Jan 2006 14:20:26 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.5b3) with ESMTP id 5794944 for multiple; Wed, 11 Jan 2006 09:18:51 -0500 Received: from zion.baldwin.cx (zion.baldwin.cx [192.168.0.7]) (authenticated bits=0) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k0BEKM4F071494; Wed, 11 Jan 2006 09:20:24 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: Kip Macy Date: Wed, 11 Jan 2006 09:20:20 -0500 User-Agent: KMail/1.8.3 References: <200601110347.k0B3le2N025056@repoman.freebsd.org> In-Reply-To: <200601110347.k0B3le2N025056@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200601110920.21204.jhb@freebsd.org> X-Virus-Scanned: ClamAV 0.87.1/1238/Wed Jan 11 05:19:06 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.4 required=4.2 tests=ALL_TRUSTED autolearn=failed version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx X-Server: High Performance Mail Server - http://surgemail.com r=1653887525 Cc: Perforce Change Reviews Subject: Re: PERFORCE change 89485 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2006 14:20:29 -0000 On Tuesday 10 January 2006 10:47 pm, Kip Macy wrote: > http://perforce.freebsd.org/chv.cgi?CH=3D89485 > > Change 89485 by kmacy@kmacy:freebsd7_xen3 on 2006/01/11 03:47:18 > > add dom0 io apic support > determination of ioapic_read / ioapic_write functions is made at runtime > > Affected files ... > > .. //depot/projects/xen3/src/sys/i386-xen/conf/XENCONF#2 edit > .. //depot/projects/xen3/src/sys/i386-xen/i386-xen/io_apic.c#1 add > .. //depot/projects/xen3/src/sys/i386-xen/i386-xen/machdep.c#5 edit > .. //depot/projects/xen3/src/sys/i386/i386/io_apic.c#3 edit > .. //depot/projects/xen3/src/sys/i386/i386/machdep.c#2 edit > .. //depot/projects/xen3/src/sys/i386/i386/mptable.c#2 edit > > Differences ... > > =3D=3D=3D=3D //depot/projects/xen3/src/sys/i386/i386/io_apic.c#3 (text+ko= ) =3D=3D=3D=3D > > @@ -539,34 +508,42 @@ > void * > ioapic_create(uintptr_t addr, int32_t apic_id, int intbase) > { > - struct ioapic *io; > + struct ioapic *io, tio; > struct ioapic_intsrc *intpin; > - volatile ioapic_t *apic; > u_int numintr, i; > uint32_t value; > > + io =3D &tio; > + /* XXX should xen just ignore this? */ > /* Map the register window so we can access the device. */ > - apic =3D (ioapic_t *)pmap_mapdev(addr, IOAPIC_MEM_REGION); > + io->io_addr =3D (ioapic_t *)pmap_mapdev(addr, IOAPIC_MEM_REGION); > + > + /* set the nominal apic_id for the initial read */ > + io->io_apic_id =3D apic_id; > + > mtx_lock_spin(&icu_lock); > - value =3D ioapic_read(apic, IOAPIC_VER); > + /* fetch the APIC id in case we're running under xen */ > + io->io_apic_id =3D access.apic_read(io, IOAPIC_ID) >> APIC_ID_SHIFT; > + value =3D access.apic_read(io, IOAPIC_VER); > mtx_unlock_spin(&icu_lock); > > /* If it's version register doesn't seem to work, punt. */ > if (value =3D=3D 0xffffffff) { > - pmap_unmapdev((vm_offset_t)apic, IOAPIC_MEM_REGION); > + pmap_unmapdev((vm_offset_t)io->io_addr, IOAPIC_MEM_REGION); > + free(io, M_IOAPIC); You haven't malloced an io here, so you shouldn't free it. The reason=20 ioapic_read/ioapic_write currently take the ioapic_t addr directly is to=20 avoid the need for the tio hack. I think you can make Xen work if you thin= k=20 a bit more creatively. First off, don't pass in the raw address and don't= =20 call pmap_mapdev() (since you aren't going to use the pointer anyway) for=20 Xen. Instead, pass the APIC ID in as the 'addr' variable and just use that= =20 as io_addr and as the argument you pass to your xen functions. Thus, you e= nd=20 up with something like this: xen_ioapic_read(addr, reg) { u.apic.id =3D addr; u.apic.reg =3D reg; /* hypervisor call */ } And in ioapic_create() you start off doing something like this: if (running_xen) apic =3D (void *)addr; if (!running_xen) apic =3D pmap_mapdev(); /* read IOAPIC_VER */ /* test for 0xffffffff */ /* read numintr value */ if (!running_xen) { update_apic_id(); } This would imply that Xen needs its own APIC enumerator, but that is probab= ly=20 sensible and those are fairly easy to write. This would also simplify the= =20 diffs here a bunch I think. > return (NULL); > } > > - /* Determine the number of vectors and set the APIC ID. */ Comment is still valid. > numintr =3D ((value & IOART_VER_MAXREDIR) >> MAXREDIRSHIFT) + 1; > io =3D malloc(sizeof(struct ioapic) + > numintr * sizeof(struct ioapic_intsrc), M_IOAPIC, M_WAITOK); > io->io_pic =3D ioapic_template; =2D-=20 John Baldwin =A0<>< =A0http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" =A0=3D =A0http://www.FreeBSD.org