Skip to content

Commit 85fd29d

Browse files
committed
x86/virt: KVM: Open code cpu_has_svm() into kvm_is_svm_supported()
Fold the guts of cpu_has_svm() into kvm_is_svm_supported(), its sole remaining user. No functional change intended. Reviewed-by: Kai Huang <kai.huang@intel.com> Link: https://lore.kernel.org/r/20230721201859.2307736-14-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 5df8ecf commit 85fd29d

2 files changed

Lines changed: 8 additions & 31 deletions

File tree

arch/x86/include/asm/virtext.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,7 @@
2222
/*
2323
* SVM functions:
2424
*/
25-
26-
/** Check if the CPU has SVM support
27-
*
28-
* You can use the 'msg' arg to get a message describing the problem,
29-
* if the function returns zero. Simply pass NULL if you are not interested
30-
* on the messages; gcc should take care of not generating code for
31-
* the messages on this case.
32-
*/
33-
static inline int cpu_has_svm(const char **msg)
34-
{
35-
if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD &&
36-
boot_cpu_data.x86_vendor != X86_VENDOR_HYGON) {
37-
if (msg)
38-
*msg = "not amd or hygon";
39-
return 0;
40-
}
41-
42-
if (!boot_cpu_has(X86_FEATURE_SVM)) {
43-
if (msg)
44-
*msg = "svm not available";
45-
return 0;
46-
}
47-
return 1;
48-
}
49-
50-
5125
/** Disable SVM on the current CPU
52-
*
53-
* You should call this only if cpu_has_svm() returned true.
5426
*/
5527
static inline void cpu_svm_disable(void)
5628
{

arch/x86/kvm/svm/svm.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,16 @@ static void svm_init_osvw(struct kvm_vcpu *vcpu)
521521
static bool kvm_is_svm_supported(void)
522522
{
523523
int cpu = raw_smp_processor_id();
524-
const char *msg;
525524
u64 vm_cr;
526525

527-
if (!cpu_has_svm(&msg)) {
528-
pr_err("SVM not supported by CPU %d, %s\n", cpu, msg);
526+
if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD &&
527+
boot_cpu_data.x86_vendor != X86_VENDOR_HYGON) {
528+
pr_err("CPU %d isn't AMD or Hygon\n", cpu);
529+
return false;
530+
}
531+
532+
if (!boot_cpu_has(X86_FEATURE_SVM)) {
533+
pr_err("SVM not supported by CPU %d\n", cpu);
529534
return false;
530535
}
531536

0 commit comments

Comments
 (0)