Commit | Line | Data |
---|---|---|
9d9baadd KC |
1 | /* timskmodutils.c |
2 | * | |
f6d0c1e6 | 3 | * Copyright (C) 2010 - 2013 UNISYS CORPORATION |
9d9baadd KC |
4 | * All rights reserved. |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or (at | |
9 | * your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | |
14 | * NON INFRINGEMENT. See the GNU General Public License for more | |
15 | * details. | |
16 | */ | |
17 | ||
9d9baadd KC |
18 | #include "timskmod.h" |
19 | ||
20 | #define MYDRVNAME "timskmodutils" | |
21 | ||
fcd0157e KC |
22 | /* s-Par uses the Intel processor's VT-X features to separate groups of |
23 | * processors into partitions. The firmware sets the hypervisor bit and | |
24 | * reports an ID in the HV capabilities leaf so that the partition's OS | |
25 | * knows s-Par is present and managing the processors. | |
26 | */ | |
27 | ||
28 | #define UNISYS_SPAR_LEAF_ID 0x40000000 | |
29 | ||
30 | /* The s-Par leaf ID returns "UnisysSpar64" encoded across ebx, ecx, edx */ | |
31 | #define UNISYS_SPAR_ID_EBX 0x73696e55 | |
32 | #define UNISYS_SPAR_ID_ECX 0x70537379 | |
33 | #define UNISYS_SPAR_ID_EDX 0x34367261 | |
34 | ||
35 | int unisys_spar_platform; | |
36 | EXPORT_SYMBOL_GPL(unisys_spar_platform); | |
37 | ||
670db786 | 38 | static __init uint32_t visorutil_spar_detect(void) |
fcd0157e KC |
39 | { |
40 | unsigned int eax, ebx, ecx, edx; | |
41 | ||
42 | if (cpu_has_hypervisor) { | |
43 | /* check the ID */ | |
44 | cpuid(UNISYS_SPAR_LEAF_ID, &eax, &ebx, &ecx, &edx); | |
45 | return (ebx == UNISYS_SPAR_ID_EBX) && | |
46 | (ecx == UNISYS_SPAR_ID_ECX) && | |
47 | (edx == UNISYS_SPAR_ID_EDX); | |
670db786 | 48 | } else { |
fcd0157e | 49 | return 0; |
670db786 | 50 | } |
fcd0157e KC |
51 | } |
52 | ||
2291b268 | 53 | static __init int visorutil_mod_init(void) |
fcd0157e KC |
54 | { |
55 | if (visorutil_spar_detect()) { | |
779d0752 | 56 | unisys_spar_platform = true; |
fcd0157e | 57 | return 0; |
2291b268 | 58 | } else { |
fcd0157e | 59 | return -ENODEV; |
2291b268 | 60 | } |
fcd0157e KC |
61 | } |
62 | ||
63 | static __exit void | |
64 | visorutil_mod_exit(void) | |
65 | { | |
66 | } | |
67 | ||
68 | module_init(visorutil_mod_init); | |
69 | module_exit(visorutil_mod_exit); | |
70 | ||
37b7e990 | 71 | MODULE_LICENSE("GPL"); |