[Libre-soc-bugs] [Bug 982] Support PowerPC ABI in ISACaller

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Sun Sep 17 21:30:46 BST 2023


https://bugs.libre-soc.org/show_bug.cgi?id=982

--- Comment #34 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
(In reply to Dmitry Selyutin from comment #32)
critical information. is that known? i may have missed it
> 
> Yep, I implemented it. 

i saw.  the commit is *tend* of thousands of lines long which is
precisely why the hard rule exists, as it is massively overloading
both my server and also my tablet.  it was 4 minutes to load the diff.

> These are basically useless w/o information on
> arguments. Check Ctrl+F on this bug page for SYSARGS. :-)

ok i see. ok that's auto-parseable. that's great, because autogenerating
the actual calls *even if "safed"* like in qemu-user, shouuuld be
reasonably straightforward.

i don't know how easy it would be to grab the size of data structs
for each object out from somewhere? even if it's done by hand
(or put into a lookup dictionary).

> 
> > sim.gpr (or, self.gpr)
> > sim.mem (or, self.mem. look in mem.py)
> > as in: the implementation of write() would be done *by hand* by:
> > 
> >     fd = self.gpr(3)
> >     buf = self.gpr(4)
> >     count = self.gpr(5)
> >     actual_buf = bytes()
> >     for i in range(count):
> >        actual_bytes.append(self.mem.ld(buf+i, 1) # something like that
> >     self.gpr(3) = sys.write(fd, actual_bytes)
> 
> Aha, good enough to go. A temporary buffer for passing into the host syscall
> then.

yes. sigh.

> On a per-syscall basis, unfortunately.

yes. sigh. but there *might* be enough information to actually
autogenerate (dynamic, runtime) everything.  

> 
> > siiiigh, yeeeees. i had a think and i don't believe the cavatools trick will
> > work in ISACaller: instead we will have to *literally* implement the syscalls
> > one by one.
> > 
> > and errno somehow will need to get created/emulated/set, no idea how to do
> > that.
> 
> Thanks God even as bad OS as Linux doesn't have this idiotic errno concept
> in kernel. They return a negative result to represent the error. That is,
> kernel returns -EINTR, and the userspace moves it to errno. "syscall" does
> the same stuff though, so we'll likely have to pick this from
> ctypes.get_errno().

i hesitate to actually allow the syscall itself, rather than an
"explicit emulated" one, but the issue of memory (see below) may
force our hand.



> Here comes a microkernel in ISACaller, lol.

userspace emulation of POSIX, in python... yes!


> 
> Hard to start, annoying to invent a reusable code, but still pretty doable
> and straightforward.

ohh fer goodness sake. i just realised, any memory allocated
(for the syscalls) you can't just discard it, you actually *need*
to keep it under a lookup table.

so when you get a shared memory lock you absolutely cannot just
blithely allocate a new area buffer.

ok this is complicated.

we *may* need to make a special version of sim.mem that *actually is
backed by a mmapped/malloced area of memory*, such that there is a
*DIRECT* one-to-one relationship between the addresses of the
emulator and when the syscalls take place.

this would have the advantage of not needing to map in/out in the
syscalls, you just literally pass the pointer-register to the syscall.

there is a way to call syscalls...

https://stackoverflow.com/questions/37032203/make-syscall-in-python

although this looks more complete/comprehensive:
https://github.com/ssavvides/execute-syscall

i *have* seen something that allows *direct* function calling... oh god
https://dev.to/adwaithrajesh/calling-asm-function-from-python-part-maybe-0-46e1

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-soc-bugs mailing list