[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 19:19:06 BST 2023


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

--- Comment #28 from Dmitry Selyutin <ghostmansd at gmail.com> ---
OK, I made a start on system calls mapping:

https://git.libre-soc.org/?p=openpower-isa.git;a=commitdiff;h=74ea3c42bef943da263395d19c50ad4dba605b9f

There's a tool which parses the Linux kernel tree and obtains all system calls
available, considering the ABI and other stuff. The only argument is the path
to the Linux kernel source code. An example of how its output looks like
(beware, huge!):

https://git.libre-soc.org/?p=openpower-isa.git;a=commitdiff;h=48ec1783c5f7cc64629fba65575db2d3881e8026

I committed this since we're unlikely to take Linux kernel with us. Linux keeps
userspace ABI stable (ugly but stable). So the situation we need to generate
again is unlikely to happen. Note that this is an exception I committed this
artifact: I don't usually do it, it's a bad practice, terrible and even
disasterous things can happen.


How do you use it?

>>> syscall_id = 286 # some deliberate example
>>> from openpower.syscalls import tables
>>> (name, entries) = tables.SYSNUMS["ppc"]["common"][str(syscall_id)]
>>> print(name, entries)
openat ['sys_openat', 'compat_sys_openat']
>>> native = int(tables.SYSNUMS["x86-64"]["common"][name])
>>> print(native)
257
>>> print(tables.SYSARGS[name])
{'dfd': 'int', 'filename': 'const char __user *', 'flags': 'int', 'mode':
'umode_t'}


I suppose this should be sufficient to start playing with mapping emulated PPC
system calls to architecture the simulator runs on. Beware, SYSARGS table, as
well as entries upon lookup, are here for a reason: different architectures
pass arguments differently (ditto pipe, compat_arg_u64_dual and similar stuff).
Linux vaunted userspace ABI is a gory mess.


What's missing here?
1. Host architecture detection, including "running 32-bit code on 64-bit
architecture" (not sure whether we need it though).
2. Logic for looking into different ABIs (e.g. some system calls might not be
in "common" ABI section).
3. The actual call redirection. This is easy enough, because libc already has a
shim "syscall". As long as the arguments match each other on two hosts,
obviously. Otherwise there must be a bunch of "special cases" and "let's
inspect the arguments logic".

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


More information about the libre-soc-bugs mailing list