x86: Print amd virtualization features in /proc/cpuinfo
PATCH 1/1 x86: Print amd virtualization features in /proc/cpuinfo
This patch adds code to cpu initialization path to detect the extended virtualization features of AMD cpus and shows them in /proc/cpuinfo.
Signed-off-by Joerg Roedel <[email protected]>
--- arch/x86/include/asm/cpufeature.h | 5 +++++ arch/x86/kernel/cpu/amd.c | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 0 deletions(-)
arch/x86/include/asm/cpufeature.h +5 -0
@@ -165,6 +165,11 @@#define X86_FEATURE_FLEXPRIORITY (8*32+ 2)/* Intel FlexPriority */ #define X86_FEATURE_EPT (8*32+ 3)/* Intel Extended Page Table */ #define X86_FEATURE_VPID (8*32+ 4)/* Intel Virtual Processor ID */ +#define X86_FEATURE_NPT (8*32+5)/* AMD Nested Page Table support */ +#define X86_FEATURE_LBRV (8*32+6)/* LBR Virtualization support */ +#define X86_FEATURE_SVML (8*32+7)/* "svm_lock" SVM locking MSR */ +#define X86_FEATURE_NRIPS (8*32+8)/* "nrip_save" svm next_rip save */ +#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
arch/x86/kernel/cpu/amd.c +25 -0
@@ -367,6 +367,28 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)#endif } +static void __cpuinit detect_amd_virt_flags (struct cpuinfo_x86 *c) +{ + +#define SVM_FEATURE_NPT_MASK 0x00000001 +#define SVM_FEATURE_LBRV_MASK 0x00000002 +#define SVM_FEATURE_SVML_MASK 0x00000004 +#define SVM_FEATURE_NRIPS_MASK 0x00000008 + +u32 virt_flags; + + virt_flags =cpuid_edx (0x8000000A ); + +if (virt_flags &SVM_FEATURE_NPT_MASK ) +set_cpu_cap (c,X86_FEATURE_NPT ); +if (virt_flags &SVM_FEATURE_LBRV_MASK ) +set_cpu_cap (c,X86_FEATURE_LBRV ); +if (virt_flags &SVM_FEATURE_SVML_MASK ) +set_cpu_cap (c,X86_FEATURE_SVML ); +if (virt_flags &SVM_FEATURE_NRIPS_MASK ) +set_cpu_cap (c,X86_FEATURE_NRIPS ); +} +static void __cpuinit init_amd (struct cpuinfo_x86 *c) {#ifdef CONFIG_SMP
@@ -499,6 +521,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c) } }#endif + +if (cpu_has (c,X86_FEATURE_SVM )) +detect_amd_virt_flags (c); }#ifdef CONFIG_X86_32
Signature · 1 line
1.6.3.3
Hi Ingo,
do you have any objections against this patch? Please let me know so I can fix them.
Thanks,
Joerg
Quoted 71 lines · Joerg Roedel
This patch adds code to cpu initialization path to detect the extended virtualization features of AMD cpus and shows them in
/proc/cpuinfo.Signed-off-by Joerg Roedel <[email protected]>--- arch/x86/include/asm/cpufeature.h | 5 +++++ arch/x86/kernel/cpu/amd.c | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 0 deletions(-)arch/x86/include/asm/cpufeature.h +5
-0@@ -165,6 +165,11 @@#define X86_FEATURE_FLEXPRIORITY (8*32+ 2)/* Intel FlexPriority */ #define X86_FEATURE_EPT (8*32+ 3)/* Intel Extended Page Table */ #define X86_FEATURE_VPID (8*32+ 4)/* Intel Virtual Processor ID */ +#define X86_FEATURE_NPT (8*32+5)/* AMD Nested Page Table support */ +#define X86_FEATURE_LBRV (8*32+6)/* LBR Virtualization support */ +#define X86_FEATURE_SVML (8*32+7)/* "svm_lock" SVM locking MSR */ +#define X86_FEATURE_NRIPS (8*32+8)/* "nrip_save" svm next_rip save */ +#if defined(__KERNEL__) && !defined(__ASSEMBLY__)arch/x86/kernel/cpu/amd.c +25
-0@@ -367,6 +367,28 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)#endif } +static void __cpuinit detect_amd_virt_flags (struct cpuinfo_x86 *c) +{ + +#define SVM_FEATURE_NPT_MASK 0x00000001 +#define SVM_FEATURE_LBRV_MASK 0x00000002 +#define SVM_FEATURE_SVML_MASK 0x00000004 +#define SVM_FEATURE_NRIPS_MASK 0x00000008 + +u32 virt_flags; + + virt_flags =cpuid_edx (0x8000000A ); + +if (virt_flags &SVM_FEATURE_NPT_MASK ) +set_cpu_cap (c,X86_FEATURE_NPT ); +if (virt_flags &SVM_FEATURE_LBRV_MASK ) +set_cpu_cap (c,X86_FEATURE_LBRV ); +if (virt_flags &SVM_FEATURE_SVML_MASK ) +set_cpu_cap (c,X86_FEATURE_SVML ); +if (virt_flags &SVM_FEATURE_NRIPS_MASK ) +set_cpu_cap (c,X86_FEATURE_NRIPS ); +} +static void __cpuinit init_amd (struct cpuinfo_x86 *c) {#ifdef CONFIG_SMP @@ -499,6 +521,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c) } }#endif + +if (cpu_has (c,X86_FEATURE_SVM )) +detect_amd_virt_flags (c); }#ifdef CONFIG_X86_32 Signature · 1 line
1.6.3.3
H. Peter Anvin
reviewerQuoted 8 lines · Joerg Roedel
Hi Ingo,
do you have any objections against this patch? Please let me know so I can fix them.
Thanks,
Joerg
These features should be table-driven like the ones already in scattered_cpuid_features() instead of open-coded.
-hpa
Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.