Wouldn't a CP QUERY CPUID (perhaps CP QUERY VIRTUAL CPUID) via diag08, or the 
Linux command to issue CP commands, work? If the returned value begins with FF, 
you are running in a virtual machine.

Mike Walter
-Retired-
________________________________
From: Linux on 390 Port <LINUX-390@VM.MARIST.EDU> on behalf of Donald Russell 
<russell....@gmail.com>
Sent: Saturday, November 10, 2018 9:32:07 AM
To: LINUX-390@VM.MARIST.EDU
Subject: Re: Using diagnose instruction from C on RHEL 7

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 <ne...@sinenomine.net> 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 <russell....@gmail.com>
> Date: 11/10/18 06:00 (GMT-05:00)
> To: LINUX-390@VM.MARIST.EDU
> 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 lists...@vm.marist.edu with the message: INFO LINUX-390 or
> visit
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.marist.edu%2Fhtbin%2Fwlvindex%3FLINUX-390&amp;data=02%7C01%7C%7Cbd706f7ac76041ebd34308d64721f486%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636774608488539882&amp;sdata=2LtTEPaaZnylLUsnr3Ti1fUNlBc8eS8UI3VjNslNITw%3D&amp;reserved=0
> ----------------------------------------------------------------------
> For more information on Linux on System z, visit
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.linuxvm.org%2F&amp;data=02%7C01%7C%7Cbd706f7ac76041ebd34308d64721f486%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636774608488539882&amp;sdata=oDbtjoI7hX0VtVDXyxzX%2FXEhliPck8vcBW7xYaJEzu0%3D&amp;reserved=0
>
> ----------------------------------------------------------------------
> For LINUX-390 subscribe / signoff / archive access instructions,
> send email to lists...@vm.marist.edu with the message: INFO LINUX-390 or
> visit
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.marist.edu%2Fhtbin%2Fwlvindex%3FLINUX-390&amp;data=02%7C01%7C%7Cbd706f7ac76041ebd34308d64721f486%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636774608488539882&amp;sdata=2LtTEPaaZnylLUsnr3Ti1fUNlBc8eS8UI3VjNslNITw%3D&amp;reserved=0
> ----------------------------------------------------------------------
> For more information on Linux on System z, visit
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.linuxvm.org%2F&amp;data=02%7C01%7C%7Cbd706f7ac76041ebd34308d64721f486%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636774608488539882&amp;sdata=oDbtjoI7hX0VtVDXyxzX%2FXEhliPck8vcBW7xYaJEzu0%3D&amp;reserved=0
>

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to lists...@vm.marist.edu with the message: INFO LINUX-390 or visit
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.marist.edu%2Fhtbin%2Fwlvindex%3FLINUX-390&amp;data=02%7C01%7C%7Cbd706f7ac76041ebd34308d64721f486%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636774608488539882&amp;sdata=2LtTEPaaZnylLUsnr3Ti1fUNlBc8eS8UI3VjNslNITw%3D&amp;reserved=0
----------------------------------------------------------------------
For more information on Linux on System z, visit
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.linuxvm.org%2F&amp;data=02%7C01%7C%7Cbd706f7ac76041ebd34308d64721f486%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636774608488539882&amp;sdata=oDbtjoI7hX0VtVDXyxzX%2FXEhliPck8vcBW7xYaJEzu0%3D&amp;reserved=0

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to lists...@vm.marist.edu 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/

Reply via email to