Supervisor state is the domain of the kernel in most contemporary systems, including Linux. What you need to do for DIAG A0 is write a kernel module.
Your next hurdle is interfacing kernel modules. There was one guy who implemented a generic DIAG interface early in the life of Linux on Z. But it was mostly used just for DIAG 08 and so fell out of use when the IBM DIAG 08 interface (with no support for other DIAG codes) came on the scene. -- R; <>< On Sat, Nov 10, 2018, 10:32 Donald Russell <[email protected] wrote: > Thanks Neale! > > In my case I’m using diag a0. Though I may want to do this for other diag > instructions too. > > Getting in/out of supervisor state is my next hurdle. :-) > > I was going to use stidp to make sure I was actually on VM but that got > “Illegal Instruction” when it ran. > Maybe there’s a function I can call, or I can read /proc/cpuinfo to verify > A-it’s IBM/S390 and B-VM is running. I don’t like the idea of reading a > whole “file” to provide what a single instruction can give me. > > I still have to figure out how to get in and out of supervisor state for > the diag though. > > Thanks for tip on generating the machine code. That’s great! :-) > > Cheers, > Don > > > > > On Sat, Nov 10, 2018 at 03:31 Neale Ferguson <[email protected]> wrote: > > > .byte 0x83, 0x12, 0x00, 0x08 > > > > == diag 1,2,8 (CP command) > > > > You can either load r1/r2 in the _asm_ section or tell gcc to bind the > > variables to the registers. > > > > Remember, though, that diag is a privileged instruction and won't work in > > a userland program. > > > > In what particular diag are you interested? > > > > > > -------- Original message -------- > > From: Donald Russell <[email protected]> > > Date: 11/10/18 06:00 (GMT-05:00) > > To: [email protected] > > Subject: [LINUX-390] Using diagnose instruction from C on RHEL 7 > > > > Hello, > > > > I want to write a program in C and use a diagnose instruction. > > > > I thought I could do > > > > __asm___( “ diag ... “ ...); > > > > but that fails because diag is not a real instruction mnemonic. When I > use > > gcc to compile and link I get an error: > > > > Program.c(.text+0x578): undefined reference to ‘x480a032’ > > collect2: error: ld returned 1 exit status > > > > I thought I could code dc x’8312....’ and force the use of registers 1 > and > > 2 but it complains that dc is not valid. (The doc says instructions > > including directives are ok. But obviously not dc directives. :-) I > also > > tried upper case just to be thorough) > > > > How can I coerce C into generating a diagnose instruction? > > > > Thanks, > > Don > > > > ---------------------------------------------------------------------- > > For LINUX-390 subscribe / signoff / archive access instructions, > > send email to [email protected] with the message: INFO LINUX-390 or > > visit > > http://www.marist.edu/htbin/wlvindex?LINUX-390 > > ---------------------------------------------------------------------- > > For more information on Linux on System z, visit > > http://wiki.linuxvm.org/ > > > > ---------------------------------------------------------------------- > > For LINUX-390 subscribe / signoff / archive access instructions, > > send email to [email protected] with the message: INFO LINUX-390 or > > visit > > http://www.marist.edu/htbin/wlvindex?LINUX-390 > > ---------------------------------------------------------------------- > > For more information on Linux on System z, visit > > http://wiki.linuxvm.org/ > > > > ---------------------------------------------------------------------- > For LINUX-390 subscribe / signoff / archive access instructions, > send email to [email protected] with the message: INFO LINUX-390 or > visit > http://www.marist.edu/htbin/wlvindex?LINUX-390 > ---------------------------------------------------------------------- > For more information on Linux on System z, visit > http://wiki.linuxvm.org/ > ---------------------------------------------------------------------- For LINUX-390 subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO LINUX-390 or visit http://www.marist.edu/htbin/wlvindex?LINUX-390 ---------------------------------------------------------------------- For more information on Linux on System z, visit http://wiki.linuxvm.org/
