From: Pavel Zholkover <paulzhol@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] plan9 go output faults on 9vx but ok on cpu
Date: Fri, 14 Jan 2011 19:32:39 +0200 [thread overview]
Message-ID: <AANLkTim9Vw10LF626ZSx1QLBQeAr75oUBVgpQwZp-MFC@mail.gmail.com> (raw)
In-Reply-To: <AANLkTi=Z7+g+o-KYvWci2Tf27m5qgYvcAcTEvWmBa75a@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 997 bytes --]
Hi,
Attached a patch to get cross compiled go binaries to run on 9vx and
native Plan 9.
I tried the 9vx-0.12 binaries from http://swtch.com/9vx on a x86-64
linux, but they don't contain support for the CMPXCHG instruction.
After recompiling 9vx from rminnich branch, I can get hello.go to run
correctly both on 9vx and a Plan 9 terminal inside qemu-kvm with this
patch.
Unfortunately rfork seems to be broken (on the 9vx); The PUSHAL, POPAL
instructions are not supported so I had to comment out
PUSHAL
CALL runtime·emptyfunc(SB)
POPAL
in src/runtime/plan9/386/sys.s, and then 9vx crashes:
% goroutines
9vx panic: kernel fault: signo=11 addr=0[ffffffffbf44a000] 1 eip=0
esp=7f37b5eecd70
aborting, to dump core.
I have no idea what is causing it to die, I've tried adding a bunch of
INT $3 to see how far in the flow I can get, but all I get this:
9vx panic: unknown trap/intr: 0x203
aborting, to dump core.
for an INT $3 just before
CALL SI // fn()
Pavel
[-- Attachment #2: golang_plan9_9vx.diff --]
[-- Type: text/x-patch, Size: 3739 bytes --]
diff -r ad4f2cbb85ef src/cmd/8l/obj.c
--- a/src/cmd/8l/obj.c Thu Jan 13 20:05:08 2011 -0800
+++ b/src/cmd/8l/obj.c Fri Jan 14 19:04:02 2011 +0200
@@ -185,6 +185,7 @@
INITRND = 0;
break;
case 2: /* plan 9 */
+ tlsoffset = -8;
HEADR = 32L;
if(INITTEXT == -1)
INITTEXT = 4096+32;
diff -r ad4f2cbb85ef src/cmd/8l/pass.c
--- a/src/cmd/8l/pass.c Thu Jan 13 20:05:08 2011 -0800
+++ b/src/cmd/8l/pass.c Fri Jan 14 19:04:02 2011 +0200
@@ -243,6 +243,7 @@
Prog *p, *q;
Sym *s;
int32 vexit;
+ Sym *plan9_tos;
if(debug['v'])
Bprint(&bso, "%5.2f mkfwd\n", cputime());
@@ -253,6 +254,10 @@
Bflush(&bso);
s = lookup("exit", 0);
vexit = s->value;
+
+ if(HEADTYPE == 2)
+ plan9_tos = lookup("_tos", 0);
+
for(cursym = textp; cursym != nil; cursym = cursym->next) {
for(p = cursym->text; p != P; p = p->link) {
if(HEADTYPE == 10) { // Windows
@@ -296,9 +301,15 @@
if(HEADTYPE == 2) { // Plan 9
if(p->from.type == D_INDIR+D_GS
&& p->to.type >= D_AX && p->to.type <= D_DI) {
+ q = appendp(p);
+ q->from = p->from;
+ q->from.type = D_INDIR + p->to.type;
+ q->to = p->to;
+ q->as = p->as;
p->as = AMOVL;
- p->from.type = D_ADDR+D_STATIC;
- p->from.offset += 0xdfffefc0;
+ p->from.type = D_EXTERN;
+ p->from.sym = plan9_tos;
+ p->from.offset = 0;
}
}
if(p->as == ACALL || (p->as == AJMP && p->to.type != D_BRANCH)) {
@@ -382,6 +393,7 @@
int a;
Prog *pmorestack;
Sym *symmorestack;
+ Sym *plan9_tos;
pmorestack = P;
symmorestack = lookup("runtime.morestack", 0);
@@ -392,6 +404,9 @@
pmorestack = symmorestack->text;
symmorestack->text->from.scale |= NOSPLIT;
}
+
+ if(HEADTYPE == 2)
+ plan9_tos = lookup("_tos", 0);
for(cursym = textp; cursym != nil; cursym = cursym->next) {
if(cursym->text == nil || cursym->text->link == nil)
@@ -436,9 +451,15 @@
case 2: // Plan 9
p->as = AMOVL;
- p->from.type = D_ADDR+D_STATIC;
- p->from.offset = 0xdfffefc0;
+ p->from.type = D_EXTERN;
+ p->from.sym = plan9_tos;
p->to.type = D_CX;
+
+ p = appendp(p);
+ p->as = AMOVL;
+ p->from.type = D_INDIR+D_CX;
+ p->from.offset = tlsoffset + 0;
+ p->to.type = D_CX;
break;
default:
diff -r ad4f2cbb85ef src/pkg/runtime/mkasmh.sh
--- a/src/pkg/runtime/mkasmh.sh Thu Jan 13 20:05:08 2011 -0800
+++ b/src/pkg/runtime/mkasmh.sh Fri Jan 14 19:04:02 2011 +0200
@@ -25,9 +25,9 @@
echo '#define m(r) 4(r)'
;;
plan9)
- echo '#define get_tls(r)'
- echo '#define g(r) 0xdfffefc0'
- echo '#define m(r) 0xdfffefc4'
+ echo '#define get_tls(r) MOVL _tos(SB), r '
+ echo '#define g(r) -8(r)'
+ echo '#define m(r) -4(r)'
;;
linux)
# On Linux systems, what we call 0(GS) and 4(GS) for g and m
diff -r ad4f2cbb85ef src/pkg/runtime/plan9/386/defs.h
--- a/src/pkg/runtime/plan9/386/defs.h Thu Jan 13 20:05:08 2011 -0800
+++ b/src/pkg/runtime/plan9/386/defs.h Fri Jan 14 19:04:02 2011 +0200
@@ -1,1 +1,2 @@
// nothing to see here
+#define tos_pid 48
diff -r ad4f2cbb85ef src/pkg/runtime/plan9/386/sys.s
--- a/src/pkg/runtime/plan9/386/sys.s Thu Jan 13 20:05:08 2011 -0800
+++ b/src/pkg/runtime/plan9/386/sys.s Fri Jan 14 19:04:02 2011 +0200
@@ -58,18 +58,19 @@
MOVL BX, m(AX)
// Initialize AX from _tos->pid
- MOVL 0xdfffeff8, AX
+ MOVL _tos(SB), AX
+ MOVL tos_pid(AX), AX
MOVL AX, m_procid(BX) // save pid as m->procid
-
+
CALL runtime·stackcheck(SB) // smashes AX, CX
MOVL 0(DX), DX // paranoia; check they are not nil
MOVL 0(BX), BX
// more paranoia; check that stack splitting code works
- PUSHAL
- CALL runtime·emptyfunc(SB)
- POPAL
+// PUSHAL
+// CALL runtime·emptyfunc(SB)
+// POPAL
CALL SI // fn()
CALL runtime·exit(SB)
[-- Attachment #3: hello.go --]
[-- Type: application/octet-stream, Size: 59 bytes --]
package main
func main() {
println("Hello Go!")
}
[-- Attachment #4: goroutines.go --]
[-- Type: application/octet-stream, Size: 225 bytes --]
package main
import "runtime"
func until(id int) {
for i := 0; i < 10; i++ {
println("id:", id, i)
runtime.Gosched()
}
}
func main() {
runtime.GOMAXPROCS(2)
go until(2)
until(1)
}
[-- Attachment #5: goroutines --]
[-- Type: application/octet-stream, Size: 122007 bytes --]
[-- Attachment #6: hello --]
[-- Type: application/octet-stream, Size: 96564 bytes --]
next prev parent reply other threads:[~2011-01-14 17:32 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-11 7:54 Skip Tavakkolian
2011-01-11 14:11 ` erik quanstrom
2011-01-11 15:06 ` Devon H. O'Dell
2011-01-11 17:03 ` Charles Forsyth
2011-01-11 17:51 ` ron minnich
2011-01-11 19:35 ` Pavel Zholkover
2011-01-11 23:58 ` Charles Forsyth
2011-01-11 16:25 ` ron minnich
2011-01-12 8:32 ` Skip Tavakkolian
2011-01-12 16:12 ` andrey mirtchovski
2011-01-12 22:03 ` ron minnich
2011-01-13 5:54 ` ron minnich
2011-01-14 17:32 ` Pavel Zholkover [this message]
2011-01-15 2:00 ` Anthony Martin
2011-01-15 9:47 ` Pavel Zholkover
2011-01-15 9:01 ` kokamoto
2011-01-15 9:19 ` Pavel Zholkover
2011-01-15 9:30 ` lucio
2011-01-15 9:58 ` Pavel Zholkover
2011-01-15 10:29 ` lucio
2011-01-15 10:40 ` lucio
2011-01-15 11:25 ` Pavel Zholkover
2011-01-16 1:51 ` kokamoto
2011-01-16 2:04 ` kokamoto
2011-01-16 6:21 ` kokamoto
2011-01-17 12:03 ` kokamoto
2011-01-17 15:20 ` [9fans] how to make hardware work? sergey.kish
2011-01-16 2:06 ` [9fans] plan9 go output faults on 9vx but ok on cpu Skip Tavakkolian
2011-01-11 17:03 ` Pavel Zholkover
2011-01-11 18:55 ` Anthony Martin
2011-01-11 19:06 ` Anthony Martin
2011-01-11 22:58 ` ron minnich
2011-01-12 22:31 ` Anthony Martin
2011-01-12 22:36 ` erik quanstrom
2011-01-12 23:28 ` Pavel Zholkover
2011-01-12 23:29 ` Charles Forsyth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTim9Vw10LF626ZSx1QLBQeAr75oUBVgpQwZp-MFC@mail.gmail.com \
--to=paulzhol@gmail.com \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).