函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:arch\x86\include\asm\virtext.h Create Date:2022-07-27 09:18:13
首页 Copyright©Brick

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
 * SVM functions:
 */
 
/** Check if the CPU has SVM support
 *
 * You can use the 'msg' arg to get a message describing the problem,
 * if the function returns zero. Simply pass NULL if you are not interested
 * on the messages; gcc should take care of not generating code for
 * the messages on this case.
 */
static inline int cpu_has_svm(const char **msg)
{
    if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD &&
        boot_cpu_data.x86_vendor != X86_VENDOR_HYGON) {
        if (msg)
            *msg = "not amd or hygon";
        return 0;
    }
 
    if (boot_cpu_data.extended_cpuid_level < SVM_CPUID_FUNC) {
        if (msg)
            *msg = "can't execute cpuid_8000000a";
        return 0;
    }
 
    if (!boot_cpu_has(X86_FEATURE_SVM)) {
        if (msg)
            *msg = "svm not available";
        return 0;
    }
    return 1;
}