diff options
author | Eduardo Habkost <ehabkost@redhat.com> | 2008-11-17 16:03:20 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2008-12-31 09:52:29 -0500 |
commit | 63d1142f8f69e39468bc6079ab2239e902828134 (patch) | |
tree | 1f6b12fca77403b7ee3323b2ef18ef53e5593094 /arch/x86/include | |
parent | 6aa07a0d77f6aafbe69e4e8609ffaf2b7ee1b591 (diff) |
KVM: SVM: move has_svm() code to asm/virtext.h
Use a trick to keep the printk()s on has_svm() working as before. gcc
will take care of not generating code for the 'msg' stuff when the
function is called with a NULL msg argument.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/include')
-rw-r--r-- | arch/x86/include/asm/virtext.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/arch/x86/include/asm/virtext.h b/arch/x86/include/asm/virtext.h index 6bcf0acb4ef1..6f0d409c3682 100644 --- a/arch/x86/include/asm/virtext.h +++ b/arch/x86/include/asm/virtext.h | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <asm/system.h> | 19 | #include <asm/system.h> |
20 | 20 | ||
21 | #include <asm/vmx.h> | 21 | #include <asm/vmx.h> |
22 | #include <asm/svm.h> | ||
22 | 23 | ||
23 | /* | 24 | /* |
24 | * VMX functions: | 25 | * VMX functions: |
@@ -66,4 +67,44 @@ static inline void cpu_emergency_vmxoff(void) | |||
66 | __cpu_emergency_vmxoff(); | 67 | __cpu_emergency_vmxoff(); |
67 | } | 68 | } |
68 | 69 | ||
70 | |||
71 | |||
72 | |||
73 | /* | ||
74 | * SVM functions: | ||
75 | */ | ||
76 | |||
77 | /** Check if the CPU has SVM support | ||
78 | * | ||
79 | * You can use the 'msg' arg to get a message describing the problem, | ||
80 | * if the function returns zero. Simply pass NULL if you are not interested | ||
81 | * on the messages; gcc should take care of not generating code for | ||
82 | * the messages on this case. | ||
83 | */ | ||
84 | static inline int cpu_has_svm(const char **msg) | ||
85 | { | ||
86 | uint32_t eax, ebx, ecx, edx; | ||
87 | |||
88 | if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) { | ||
89 | if (msg) | ||
90 | *msg = "not amd"; | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | cpuid(0x80000000, &eax, &ebx, &ecx, &edx); | ||
95 | if (eax < SVM_CPUID_FUNC) { | ||
96 | if (msg) | ||
97 | *msg = "can't execute cpuid_8000000a"; | ||
98 | return 0; | ||
99 | } | ||
100 | |||
101 | cpuid(0x80000001, &eax, &ebx, &ecx, &edx); | ||
102 | if (!(ecx & (1 << SVM_CPUID_FEATURE_SHIFT))) { | ||
103 | if (msg) | ||
104 | *msg = "svm not available"; | ||
105 | return 0; | ||
106 | } | ||
107 | return 1; | ||
108 | } | ||
109 | |||
69 | #endif /* _ASM_X86_VIRTEX_H */ | 110 | #endif /* _ASM_X86_VIRTEX_H */ |