From owner-freebsd-sparc64@FreeBSD.ORG Tue Jan 28 19:48:36 2014 Return-Path: Delivered-To: sparc64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 86CA295D; Tue, 28 Jan 2014 19:48:36 +0000 (UTC) Received: from h2.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 378A112A8; Tue, 28 Jan 2014 19:48:35 +0000 (UTC) Received: from h2.funkthat.com (localhost [127.0.0.1]) by h2.funkthat.com (8.14.3/8.14.3) with ESMTP id s0SJmTrd079342 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 28 Jan 2014 11:48:29 -0800 (PST) (envelope-from jmg@h2.funkthat.com) Received: (from jmg@localhost) by h2.funkthat.com (8.14.3/8.14.3/Submit) id s0SJmSFB079341; Tue, 28 Jan 2014 11:48:28 -0800 (PST) (envelope-from jmg) Date: Tue, 28 Jan 2014 11:48:28 -0800 From: John-Mark Gurney To: Craig Butler Subject: Re: Call for help: clang/llvm for sparc64 Message-ID: <20140128194828.GD13704@funkthat.com> Mail-Followup-To: Craig Butler , Roman Divacky , Kurt Lidl , sparc64@freebsd.org References: <20140117221330.GA2788@freebsd.org> <1390175474.8376.3.camel@atlas.lerwick.hopto.org> <3866560.132.1390324121556.JavaMail.craig@w520> <20140121170801.GA56661@freebsd.org> <52E553E6.6020902@pix.net> <20140126190349.GA89295@freebsd.org> <20140127200331.GA80131@freebsd.org> <3051948.261.1390859647458.JavaMail.craig@w520> <20140127215402.GA85169@freebsd.org> <1390903475.4428.12.camel@zbox.lerwick.hopto.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="YZ5djTAD1cGYuMQK" Content-Disposition: inline In-Reply-To: <1390903475.4428.12.camel@zbox.lerwick.hopto.org> User-Agent: Mutt/1.4.2.3i X-Operating-System: FreeBSD 7.2-RELEASE i386 X-PGP-Fingerprint: 54BA 873B 6515 3F10 9E88 9322 9CB1 8F74 6D3F A396 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.2.2 (h2.funkthat.com [127.0.0.1]); Tue, 28 Jan 2014 11:48:29 -0800 (PST) Cc: Roman Divacky , Kurt Lidl , sparc64@freebsd.org X-BeenThere: freebsd-sparc64@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Porting FreeBSD to the Sparc List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Jan 2014 19:48:36 -0000 --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Craig Butler wrote this message on Tue, Jan 28, 2014 at 10:04 +0000: > On Mon, 2014-01-27 at 22:54 +0100, Roman Divacky wrote: > > > On Mon, Jan 27, 2014 at 09:50:52PM +0000, Craig Butler wrote: > > > > > > > > > > Btw, can someone test this patch? ie. compile (with gcc) sparc64 > > > > kernel > > > > with it and boot it? > > > > > > > > > Yes, I had to fix that but forgot to upstream it. > > > > > > > > > > Index: sparc64/include/pcpu.h > > > > > =================================================================== > > > > > --- sparc64/include/pcpu.h (revision 259767) > > > > > +++ sparc64/include/pcpu.h (working copy) > > > > > @@ -70,9 +70,26 @@ > > > > > struct pcb; > > > > > struct pcpu; > > > > > > > > > > -register struct pcb *curpcb __asm__(__XSTRING(PCB_REG)); > > > > > -register struct pcpu *pcpup __asm__(__XSTRING(PCPU_REG)); > > > > > +static __inline __pure2 struct pcb * > > > > > +__curpcb(void) > > > > > +{ > > > > > + struct pcb *pcb; > > > > > > > > > > + __asm("ldx [%" __XSTRING(PCB_REG) "], %0" : "=r" (pcb)); > > > > > + return (pcb); > > > > > +} > > > > > +#define curpcb (__curpcb()) > > > > > + > > > > > +static __inline __pure2 struct pcpu * > > > > > +__curpcpu(void) > > > > > +{ > > > > > + struct pcpu *pcpu; > > > > > + > > > > > + __asm("ldx [%" __XSTRING(PCPU_REG) "], %0" : "=r" (pcpu)); > > > > > + return (pcpu); > > > > > +} > > > > > +#define pcpup (__curpcpu()) > > > > > + > > > > > #define PCPU_GET(member) (pcpup->pc_ ## member) > > > > > > > > > > static __inline __pure2 struct thread * > > > > > > > > > > > > > > > the llvm sparc64 is not yet ready for wide consumption. Once llvm > > > > > 3.4 is imported > > > > > (days now) the sparc64 backend will be enabled as well. Then I plan > > > > > to backport > > > > > all the fixes from llvm trunk to enable it to selfhost. So that we > > > > > can build > > > > > llvm 3.5 with llvm itself. This is necesary as llvm is becoming > > > > > c++11 only. > > > > > > > > > > > Do you want us to apply that patch to /usr/src/sys/sparc64/include/pcpu.h then make with gcc ?? > > > Do we have to pull down HEAD or can this be applied over a 9.2|10-RELEASE ? > > > Which gcc ?? > > > > -current and in-base gcc I would think would be the best. But 10.0R should work > > too. > > > > Roman > > > Hello Roman, Kurt and list > > I think the diff got broken somehow, it was failing bulk at 70 and kept > creating a reject.. so I went ahead an altered the file anyway. > > I can confirm that the code does indeed compile however the installed > kernel panics on boot (just after ZFS)... something it doesn't do on a > stock kernel. > > //// > sym1: No NVRAM, ID 7, Fast-40, LVD, parity checking > nexus0: type unknown (no driver attached) > uart0: at port 0x3f8-0x3ff > irq 43 on isa0 > uart0: console (9600,n,8,1) > uart1: at port 0x2e8-0x2ef > irq 43 on isa0 > ZFS WARNING: Recommended minimum kmem_size is 512MB; expect unstable > behavior. > Consider tuning vm.kmem_size and vm.kmem_size_max > in /boot/loader.conf. > ZFS filesystem version: 5 > ZFS storage pool version: features support (5000) > Timecounter "tick" frequency 0 Hz quality 1000 > panic: trap: division by zero (kernel) > cpuid = 0 > KDB: stack backtrace: > #0 0xc0883d78 at trap+0x558 > Uptime: 1s > Automatic reboot in 15 seconds - press a key on the console to abort > Rebooting... > Resettin > LOM event: +11h2m54s host reset > //// > > --- sparc64/include/pcpu.h.orig 2014-01-28 04:40:28.058580261 +0000 > +++ sparc64/include/pcpu.h 2014-01-28 04:45:01.423571144 +0000 > @@ -70,8 +70,25 @@ > struct pcb; > struct pcpu; > > -register struct pcb *curpcb __asm__(__XSTRING(PCB_REG)); > -register struct pcpu *pcpup __asm__(__XSTRING(PCPU_REG)); > +static __inline __pure2 struct pcb * > +__curpcb(void) > + { > + struct pcb *pcb; > + > + __asm("ldx [%" __XSTRING(PCB_REG) "], %0" : "=r" (pcb)); > + return (pcb); > + } > +#define curpcb (__curpcb()) > + > +static __inline __pure2 struct pcpu * > +__curpcpu(void) > + { > + struct pcpu *pcpu; > + > + __asm("ldx [%" __XSTRING(PCPU_REG) "], %0" : "=r" (pcpu)); > + return (pcpu); > + } > +#define pcpup (__curpcpu()) > > #define PCPU_GET(member) (pcpup->pc_ ## member) > > > I ran the buildkernel and installkernel in a script session, I can make > these available if desired. After talking w/ Roman, I belive that this patch is wrong... The reason the ldx works for curthread is that it is the first member of pcpu... For pcpu and curpcb, we just need to mov the register... Here is a new patch.. I have not tried to compile, so adjust as necessary... If you do need to adjust the patch, please reply with the working and compilable patch so I can commit... Thanks for the testing. -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." --YZ5djTAD1cGYuMQK Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="sparc64.pcbpcpu.patch" Index: sparc64/include/pcpu.h =================================================================== --- sparc64/include/pcpu.h (revision 261142) +++ sparc64/include/pcpu.h (working copy) @@ -70,9 +70,28 @@ extern void *dpcpu0; struct pcb; struct pcpu; -register struct pcb *curpcb __asm__(__XSTRING(PCB_REG)); -register struct pcpu *pcpup __asm__(__XSTRING(PCPU_REG)); +static __inline __pure2 struct pcb * +__curpcb(void) +{ + struct pcb *pcb; + __asm("mov " __XSTRING(PCB_REG) ", %0" : "=r" (pcb)); + + return (pcb); +} +#define curpcb (__curpcb()) + +static __inline __pure2 struct pcpu * +__pcpu(void) +{ + struct pcpu *pcpu; + + __asm("mov " __XSTRING(PCPU_REG) ", %0" : "=r" (pcpu)); + + return (pcpu); +} +#define pcpu (__pcpu()) + #define PCPU_GET(member) (pcpup->pc_ ## member) static __inline __pure2 struct thread * --YZ5djTAD1cGYuMQK--