How can I use syscall() from 32-bit application in 64-bit Solaris (v. 5.8)

Solaris 5.8Sun Blade 150 (64-bit) I have got SYGSYS when call syscall(...) from my 32-bit application.Is it possible to use syscall() in 32-bit applications under 64-bit Solaris?
[206 byte] By [Dear_Serga] at [2007-11-27 7:40:53]
# 1

Hello.

Solaris 64 bit should support anything from 32 bit applications that can be done from within Solaris 32.

SIGSYS means that a system call is not supported. This may have two reasons:

- The system call number you used is wrong. Example: syscall(123456)

- Your implementation of syscall() uses SYS_SYSCALL as system call and Solaris 8 does not support it (I do not believe this) instead of doing the system call directly. In this case you may try to implement the syscall() function in assembler.

Note: syscall(SYS_SYSCALL,x,y,...) is identical to syscall(x,y,...) but may be unsupported by some Solaris versions.

Martin

Martin_Rosenaua at 2007-7-12 19:21:26 > top of Java-index,Solaris Operating System,Solaris Essentials - General Technical Questions...
# 2

Hello again.

You may use the debugger (mdb) to open the core file generated by the SIGSYS trap:mdb core

Then you type::regs

to list the register values at the time of the trap (in hexadecimal form).

For Sparc machines (it is more complicated on x86 machines) g1 holds the system call number, o0 holds the first argument, o1 the second one ... o5 the 6th one. (For system calls with more than 6 arguments the 7th, 8th... argument are stored on the stack.)

If g1 is 0 you know that the system call is done indirectly using SYS_syscall so the arguments are shifted (see above) and o0 holds the system call number.

You can exit mdb using::quit

Martin

Martin_Rosenaua at 2007-7-12 19:21:26 > top of Java-index,Solaris Operating System,Solaris Essentials - General Technical Questions...
# 3

Sorry, I am deceive You.

I forgot to say that I use syscall() in 32 bit application in order to call custom kernel module, which is a 64 bit module (was compiled with -xarch=v9 option).

When I recompile one of my 32-bit applications as 64 bit, it works properly.

But I can't recompile all of needed applications (Not all of source code is available).

May be a favorable decision is in creation 32 bit module (compiled with -xarch=v9 or without -xarch )?

But when I am traying to load it, I receive massage:

can't load module: No such file or directory

Dear_Serga at 2007-7-12 19:21:26 > top of Java-index,Solaris Operating System,Solaris Essentials - General Technical Questions...
# 4

Your loadable module (not your application) must be written in a way to support both 32 and 64 bit applications in this case. Looking at OpenSolaris's file "uts/common/syscall/pipe.c" I think the following code should work:

static struct modlsys modlsys = {

&mod_syscallops, "My system call", &my_system_call

};

#ifdef KERNEL_IS_64_BITS

static struct modlsys modlsys32 = {

&mod_syscallops32, "My system call (app is 32 bits)", &my_system_call

};

#endif

static struct modlinkage modlinkage = {

MODREV_1,

&modlsys,

#ifdef KERNEL_IS_64_BITS

&modlsys32,

#endif

NULL

};

Martin

Martin_Rosenaua at 2007-7-12 19:21:26 > top of Java-index,Solaris Operating System,Solaris Essentials - General Technical Questions...
# 5
ok, MartinThank you very much for your advice.
Dear_Serga at 2007-7-12 19:21:26 > top of Java-index,Solaris Operating System,Solaris Essentials - General Technical Questions...
# 6

... but when I add to my kernel module necessary code:

#ifdef _SYSCALL32_IMPL

static struct modlsys modlsys32 =

{

&mod_syscallops32,

"modify_bits 32-bit",/* module name */

&mysysent

};

#endif

I see that they are not compiled, because symbol _SYSCALL32_IMPL is not defined.

How to compile this code properly (with_SYSCALL32_IMPL definition)?

Dear_Serga at 2007-7-12 19:21:26 > top of Java-index,Solaris Operating System,Solaris Essentials - General Technical Questions...