History

Merge tag 'x86_cpu_for_6.7_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 cpuid updates from Borislav Petkov: - Make sure the "svm" feature flag is cleared from /proc/cpuinfo when virtualization support is disabled in the BIOS on AMD and Hygon platforms - A minor cleanup * tag 'x86_cpu_for_6.7_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/cpu/amd: Remove redundant 'break' statement x86/cpu: Clear SVM feature if disabled by BIOS

Linus Torvalds committed 3 years ago

Commit ca2e9c32 parents 9ab021a b5034c65 files · +25 −16Browse files

Unified · Split

5 files
  1. arch/x86/include/asm/msr-index.h +5 −1
  2. arch/x86/include/asm/svm.h +0 −6
  3. arch/x86/kernel/cpu/amd.c +10 −1
  4. arch/x86/kernel/cpu/hygon.c +10 −0
  5. arch/x86/kvm/svm/svm.c +0 −8
arch/x86/include/asm/msr-index.h+5−1
@@ -1117,12 +1117,16 @@ · 1116 unmodified lines
11171117 #define MSR_IA32_VMX_MISC_INTEL_PT (1ULL << 14)
11181118 #define MSR_IA32_VMX_MISC_VMWRITE_SHADOW_RO_FIELDS (1ULL << 29)
11191119 #define MSR_IA32_VMX_MISC_PREEMPTION_TIMER_SCALE 0x1F
1120−/* AMD-V MSRs */
11211120
1121+/* AMD-V MSRs */
11221122 #define MSR_VM_CR 0xc0010114
11231123 #define MSR_VM_IGNNE 0xc0010115
11241124 #define MSR_VM_HSAVE_PA 0xc0010117
11251125
1126+#define SVM_VM_CR_VALID_MASK 0x001fULL
1127+#define SVM_VM_CR_SVM_LOCK_MASK 0x0008ULL
1128+#define SVM_VM_CR_SVM_DIS_MASK 0x0010ULL
1129+
11261130 /* Hardware Feedback Interface */
11271131 #define MSR_IA32_HW_FEEDBACK_PTR 0x17d0
11281132 #define MSR_IA32_HW_FEEDBACK_CONFIG 0x17d1
arch/x86/include/asm/svm.h+0−6
@@ -229,10 +229,6 @@ struct __attribute__ ((__packed__)) vmcb_control_area { · 228 unmodified lines
229229 #define SVM_IOIO_SIZE_MASK (7 << SVM_IOIO_SIZE_SHIFT)
230230 #define SVM_IOIO_ASIZE_MASK (7 << SVM_IOIO_ASIZE_SHIFT)
231231
232−#define SVM_VM_CR_VALID_MASK 0x001fULL
233−#define SVM_VM_CR_SVM_LOCK_MASK 0x0008ULL
234−#define SVM_VM_CR_SVM_DIS_MASK 0x0010ULL
235−
236232 #define SVM_NESTED_CTL_NP_ENABLE BIT(0)
237233 #define SVM_NESTED_CTL_SEV_ENABLE BIT(1)
238234 #define SVM_NESTED_CTL_SEV_ES_ENABLE BIT(2)
@@ -572,8 +568,6 @@ struct vmcb { · 333 unmodified lines
572568
573569 #define SVM_CPUID_FUNC 0x8000000a
574570
575−#define SVM_VM_CR_SVM_DISABLE 4
576−
577571 #define SVM_SELECTOR_S_SHIFT 4
578572 #define SVM_SELECTOR_DPL_SHIFT 5
579573 #define SVM_SELECTOR_P_SHIFT 7
arch/x86/kernel/cpu/amd.c+10−1
@@ -1014,7 +1014,6 @@ static bool cpu_has_zenbleed_microcode(void) · 1013 unmodified lines
10141014
10151015 default:
10161016 return false;
1017− break;
10181017 }
10191018
10201019 if (boot_cpu_data.microcode < good_rev)
@@ -1044,6 +1043,8 @@ static void zenbleed_check(struct cpuinfo_x86 *c) · 23 unmodified lines
10441043
10451044 static void init_amd(struct cpuinfo_x86 *c)
10461045 {
1046+ u64 vm_cr;
1047+
10471048 early_init_amd(c);
10481049
10491050 /*
@@ -1095,6 +1096,14 @@ static void init_amd(struct cpuinfo_x86 *c) · 45 unmodified lines
10951096
10961097 init_amd_cacheinfo(c);
10971098
1099+ if (cpu_has(c, X86_FEATURE_SVM)) {
1100+ rdmsrl(MSR_VM_CR, vm_cr);
1101+ if (vm_cr & SVM_VM_CR_SVM_DIS_MASK) {
1102+ pr_notice_once("SVM disabled (by BIOS) in MSR_VM_CR\n");
1103+ clear_cpu_cap(c, X86_FEATURE_SVM);
1104+ }
1105+ }
1106+
10981107 if (!cpu_has(c, X86_FEATURE_LFENCE_RDTSC) && cpu_has(c, X86_FEATURE_XMM2)) {
10991108 /*
11001109 * Use LFENCE for execution serialization. On families which
arch/x86/kernel/cpu/hygon.c+10−0
@@ -290,6 +290,8 @@ static void early_init_hygon(struct cpuinfo_x86 *c) · 289 unmodified lines
290290
291291 static void init_hygon(struct cpuinfo_x86 *c)
292292 {
293+ u64 vm_cr;
294+
293295 early_init_hygon(c);
294296
295297 /*
@@ -320,6 +322,14 @@ static void init_hygon(struct cpuinfo_x86 *c) · 24 unmodified lines
320322
321323 init_hygon_cacheinfo(c);
322324
325+ if (cpu_has(c, X86_FEATURE_SVM)) {
326+ rdmsrl(MSR_VM_CR, vm_cr);
327+ if (vm_cr & SVM_VM_CR_SVM_DIS_MASK) {
328+ pr_notice_once("SVM disabled (by BIOS) in MSR_VM_CR\n");
329+ clear_cpu_cap(c, X86_FEATURE_SVM);
330+ }
331+ }
332+
323333 if (cpu_has(c, X86_FEATURE_XMM2)) {
324334 /*
325335 * Use LFENCE for execution serialization. On families which
arch/x86/kvm/svm/svm.c+0−8
@@ -531,8 +531,6 @@ static bool __kvm_is_svm_supported(void) · 530 unmodified lines
531531 int cpu = smp_processor_id();
532532 struct cpuinfo_x86 *c = &cpu_data(cpu);
533533
534− u64 vm_cr;
535−
536534 if (c->x86_vendor != X86_VENDOR_AMD &&
537535 c->x86_vendor != X86_VENDOR_HYGON) {
538536 pr_err("CPU %d isn't AMD or Hygon\n", cpu);
@@ -549,12 +547,6 @@ static bool __kvm_is_svm_supported(void) · 10 unmodified lines
549547 return false;
550548 }
551549
552− rdmsrl(MSR_VM_CR, vm_cr);
553− if (vm_cr & (1 << SVM_VM_CR_SVM_DISABLE)) {
554− pr_err("SVM disabled (by BIOS) in MSR_VM_CR on CPU %d\n", cpu);
555− return false;
556− }
557−
558550 return true;
559551 }
560552

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t