1 /* Copyright (C) 2010 - 2013 UNISYS CORPORATION
2  * All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or (at
7  * your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
12  * NON INFRINGEMENT.  See the GNU General Public License for more
13  * details.
14  */
15 
16 /* Linux GCC Version (32-bit and 64-bit) */
17 static inline unsigned long
__unisys_vmcall_gnuc(unsigned long tuple,unsigned long reg_ebx,unsigned long reg_ecx)18 __unisys_vmcall_gnuc(unsigned long tuple, unsigned long reg_ebx,
19 		     unsigned long reg_ecx)
20 {
21 	unsigned long result = 0;
22 	unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
23 
24 	cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx);
25 	if (!(cpuid_ecx & 0x80000000))
26 		return -1;
27 
28 	__asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) :
29 		"a"(tuple), "b"(reg_ebx), "c"(reg_ecx));
30 	return result;
31 }
32 
33 static inline unsigned long
__unisys_extended_vmcall_gnuc(unsigned long long tuple,unsigned long long reg_ebx,unsigned long long reg_ecx,unsigned long long reg_edx)34 __unisys_extended_vmcall_gnuc(unsigned long long tuple,
35 			      unsigned long long reg_ebx,
36 			      unsigned long long reg_ecx,
37 			      unsigned long long reg_edx)
38 {
39 	unsigned long result = 0;
40 	unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
41 
42 	cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx);
43 	if (!(cpuid_ecx & 0x80000000))
44 		return -1;
45 
46 	__asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) :
47 		"a"(tuple), "b"(reg_ebx), "c"(reg_ecx), "d"(reg_edx));
48 	return result;
49 }
50