refresh patches for current submodule state
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
067446a439
commit
8c992dd41c
@ -55,10 +55,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
2 files changed, 111 insertions(+)
|
||||
|
||||
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
|
||||
index 68e20f4f1ad4..28131c19b1c9 100644
|
||||
index cad8753be8fa..474342bbb4b4 100644
|
||||
--- a/Documentation/admin-guide/kernel-parameters.txt
|
||||
+++ b/Documentation/admin-guide/kernel-parameters.txt
|
||||
@@ -3978,6 +3978,15 @@
|
||||
@@ -4001,6 +4001,15 @@
|
||||
Also, it enforces the PCI Local Bus spec
|
||||
rule that those bits should be 0 in system reset
|
||||
events (useful for kexec/kdump cases).
|
||||
|
@ -267,10 +267,10 @@ index fb09cd22cb7f..0b2bbcce321a 100644
|
||||
#if defined(CONFIG_X86_32)
|
||||
#define X86EMUL_MODE_HOST X86EMUL_MODE_PROT32
|
||||
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
|
||||
index 386b92c2e4aa..1b2f6cd3cc8d 100644
|
||||
index 3b19e0fdc5b0..f57d81400f21 100644
|
||||
--- a/arch/x86/kvm/x86.c
|
||||
+++ b/arch/x86/kvm/x86.c
|
||||
@@ -12642,6 +12642,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_vmgexit_msr_protocol_exit);
|
||||
@@ -12647,6 +12647,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_vmgexit_msr_protocol_exit);
|
||||
static int __init kvm_x86_init(void)
|
||||
{
|
||||
kvm_mmu_x86_module_init();
|
||||
|
@ -17,7 +17,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
6 files changed, 28 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
|
||||
index 1172a201d851..c4e382af1853 100644
|
||||
index 55d791ad4787..e05a22527585 100644
|
||||
--- a/arch/x86/include/asm/kvm_host.h
|
||||
+++ b/arch/x86/include/asm/kvm_host.h
|
||||
@@ -200,6 +200,7 @@ typedef enum exit_fastpath_completion fastpath_t;
|
||||
@ -143,10 +143,10 @@ index b0b87c36be3d..545e321998d3 100644
|
||||
return 0;
|
||||
|
||||
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
|
||||
index 7db4c69ac77b..0e52ddd14c57 100644
|
||||
index c3382549fdf2..68a3b2844aed 100644
|
||||
--- a/arch/x86/kvm/vmx/vmx.c
|
||||
+++ b/arch/x86/kvm/vmx/vmx.c
|
||||
@@ -7615,7 +7615,7 @@ static int vmx_smi_allowed(struct kvm_vcpu *vcpu, bool for_injection)
|
||||
@@ -7630,7 +7630,7 @@ static int vmx_smi_allowed(struct kvm_vcpu *vcpu, bool for_injection)
|
||||
return !is_smm(vcpu);
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ index 7db4c69ac77b..0e52ddd14c57 100644
|
||||
{
|
||||
struct vcpu_vmx *vmx = to_vmx(vcpu);
|
||||
|
||||
@@ -7629,7 +7629,7 @@ static int vmx_enter_smm(struct kvm_vcpu *vcpu, char *smstate)
|
||||
@@ -7644,7 +7644,7 @@ static int vmx_enter_smm(struct kvm_vcpu *vcpu, char *smstate)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -165,10 +165,10 @@ index 7db4c69ac77b..0e52ddd14c57 100644
|
||||
struct vcpu_vmx *vmx = to_vmx(vcpu);
|
||||
int ret;
|
||||
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
|
||||
index 1b2f6cd3cc8d..1b7e08590493 100644
|
||||
index f57d81400f21..87952db52155 100644
|
||||
--- a/arch/x86/kvm/x86.c
|
||||
+++ b/arch/x86/kvm/x86.c
|
||||
@@ -7440,9 +7440,9 @@ static void emulator_exiting_smm(struct x86_emulate_ctxt *ctxt)
|
||||
@@ -7445,9 +7445,9 @@ static void emulator_exiting_smm(struct x86_emulate_ctxt *ctxt)
|
||||
}
|
||||
|
||||
static int emulator_leave_smm(struct x86_emulate_ctxt *ctxt,
|
||||
@ -180,7 +180,7 @@ index 1b2f6cd3cc8d..1b7e08590493 100644
|
||||
}
|
||||
|
||||
static void emulator_triple_fault(struct x86_emulate_ctxt *ctxt)
|
||||
@@ -9321,25 +9321,25 @@ static void enter_smm(struct kvm_vcpu *vcpu)
|
||||
@@ -9326,25 +9326,25 @@ static void enter_smm(struct kvm_vcpu *vcpu)
|
||||
struct kvm_segment cs, ds;
|
||||
struct desc_ptr dt;
|
||||
unsigned long cr0;
|
||||
|
@ -145,10 +145,10 @@ index d3cc1b8e2ea6..0dd18d66f3b7 100644
|
||||
if (ret != X86EMUL_CONTINUE)
|
||||
goto emulate_shutdown;
|
||||
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
|
||||
index 1b7e08590493..678318e5e0b4 100644
|
||||
index 87952db52155..26d6e3c3138f 100644
|
||||
--- a/arch/x86/kvm/x86.c
|
||||
+++ b/arch/x86/kvm/x86.c
|
||||
@@ -9175,22 +9175,18 @@ static u32 enter_smm_get_segment_flags(struct kvm_segment *seg)
|
||||
@@ -9180,22 +9180,18 @@ static u32 enter_smm_get_segment_flags(struct kvm_segment *seg)
|
||||
return flags;
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ index 1b7e08590493..678318e5e0b4 100644
|
||||
}
|
||||
|
||||
#ifdef CONFIG_X86_64
|
||||
@@ -9211,54 +9207,47 @@ static void enter_smm_save_seg_64(struct kvm_vcpu *vcpu, char *buf, int n)
|
||||
@@ -9216,54 +9212,47 @@ static void enter_smm_save_seg_64(struct kvm_vcpu *vcpu, char *buf, int n)
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -257,7 +257,7 @@ index 1b7e08590493..678318e5e0b4 100644
|
||||
}
|
||||
|
||||
#ifdef CONFIG_X86_64
|
||||
@@ -9329,7 +9318,7 @@ static void enter_smm(struct kvm_vcpu *vcpu)
|
||||
@@ -9334,7 +9323,7 @@ static void enter_smm(struct kvm_vcpu *vcpu)
|
||||
enter_smm_save_state_64(vcpu, (char *)&smram);
|
||||
else
|
||||
#endif
|
||||
|
@ -154,10 +154,10 @@ index 0dd18d66f3b7..37c1662b5508 100644
|
||||
#endif
|
||||
ret = rsm_load_state_32(ctxt, &smram.smram32);
|
||||
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
|
||||
index 678318e5e0b4..de1b88836442 100644
|
||||
index 26d6e3c3138f..76f7c78c4629 100644
|
||||
--- a/arch/x86/kvm/x86.c
|
||||
+++ b/arch/x86/kvm/x86.c
|
||||
@@ -9190,20 +9190,17 @@ static void enter_smm_save_seg_32(struct kvm_vcpu *vcpu,
|
||||
@@ -9195,20 +9195,17 @@ static void enter_smm_save_seg_32(struct kvm_vcpu *vcpu,
|
||||
}
|
||||
|
||||
#ifdef CONFIG_X86_64
|
||||
@ -185,7 +185,7 @@ index 678318e5e0b4..de1b88836442 100644
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9251,57 +9248,51 @@ static void enter_smm_save_state_32(struct kvm_vcpu *vcpu, struct kvm_smram_stat
|
||||
@@ -9256,57 +9253,51 @@ static void enter_smm_save_state_32(struct kvm_vcpu *vcpu, struct kvm_smram_stat
|
||||
}
|
||||
|
||||
#ifdef CONFIG_X86_64
|
||||
@ -268,7 +268,7 @@ index 678318e5e0b4..de1b88836442 100644
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9315,7 +9306,7 @@ static void enter_smm(struct kvm_vcpu *vcpu)
|
||||
@@ -9320,7 +9311,7 @@ static void enter_smm(struct kvm_vcpu *vcpu)
|
||||
memset(smram.bytes, 0, sizeof(smram.bytes));
|
||||
#ifdef CONFIG_X86_64
|
||||
if (guest_cpuid_has(vcpu, X86_FEATURE_LM))
|
||||
|
@ -17,10 +17,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
2 files changed, 6 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
|
||||
index c4e382af1853..932c0f659468 100644
|
||||
index e05a22527585..457071be1f76 100644
|
||||
--- a/arch/x86/include/asm/kvm_host.h
|
||||
+++ b/arch/x86/include/asm/kvm_host.h
|
||||
@@ -1937,12 +1937,6 @@ static inline int kvm_cpu_get_apicid(int mps_cpu)
|
||||
@@ -1939,12 +1939,6 @@ static inline int kvm_cpu_get_apicid(int mps_cpu)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -128,10 +128,10 @@ index 3b37b3e17379..a64c190abf28 100644
|
||||
__CHECK_SMRAM64_OFFSET(auto_hlt_restart, 0xFEC9);
|
||||
__CHECK_SMRAM64_OFFSET(reserved2, 0xFECA);
|
||||
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
|
||||
index de1b88836442..e95c254b450f 100644
|
||||
index 76f7c78c4629..e34172783b7f 100644
|
||||
--- a/arch/x86/kvm/x86.c
|
||||
+++ b/arch/x86/kvm/x86.c
|
||||
@@ -7427,6 +7427,11 @@ static void emulator_set_nmi_mask(struct x86_emulate_ctxt *ctxt, bool masked)
|
||||
@@ -7432,6 +7432,11 @@ static void emulator_set_nmi_mask(struct x86_emulate_ctxt *ctxt, bool masked)
|
||||
static_call(kvm_x86_set_nmi_mask)(emul_to_vcpu(ctxt), masked);
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ index de1b88836442..e95c254b450f 100644
|
||||
static unsigned emulator_get_hflags(struct x86_emulate_ctxt *ctxt)
|
||||
{
|
||||
return emul_to_vcpu(ctxt)->arch.hflags;
|
||||
@@ -7496,6 +7501,7 @@ static const struct x86_emulate_ops emulate_ops = {
|
||||
@@ -7501,6 +7506,7 @@ static const struct x86_emulate_ops emulate_ops = {
|
||||
.guest_has_fxsr = emulator_guest_has_fxsr,
|
||||
.guest_has_rdpid = emulator_guest_has_rdpid,
|
||||
.set_nmi_mask = emulator_set_nmi_mask,
|
||||
@ -151,7 +151,7 @@ index de1b88836442..e95c254b450f 100644
|
||||
.get_hflags = emulator_get_hflags,
|
||||
.exiting_smm = emulator_exiting_smm,
|
||||
.leave_smm = emulator_leave_smm,
|
||||
@@ -9245,6 +9251,8 @@ static void enter_smm_save_state_32(struct kvm_vcpu *vcpu, struct kvm_smram_stat
|
||||
@@ -9250,6 +9256,8 @@ static void enter_smm_save_state_32(struct kvm_vcpu *vcpu, struct kvm_smram_stat
|
||||
smram->cr4 = kvm_read_cr4(vcpu);
|
||||
smram->smm_revision = 0x00020000;
|
||||
smram->smbase = vcpu->arch.smbase;
|
||||
@ -160,7 +160,7 @@ index de1b88836442..e95c254b450f 100644
|
||||
}
|
||||
|
||||
#ifdef CONFIG_X86_64
|
||||
@@ -9293,6 +9301,8 @@ static void enter_smm_save_state_64(struct kvm_vcpu *vcpu, struct kvm_smram_stat
|
||||
@@ -9298,6 +9306,8 @@ static void enter_smm_save_state_64(struct kvm_vcpu *vcpu, struct kvm_smram_stat
|
||||
enter_smm_save_seg_64(vcpu, &smram->ds, VCPU_SREG_DS);
|
||||
enter_smm_save_seg_64(vcpu, &smram->fs, VCPU_SREG_FS);
|
||||
enter_smm_save_seg_64(vcpu, &smram->gs, VCPU_SREG_GS);
|
||||
@ -169,7 +169,7 @@ index de1b88836442..e95c254b450f 100644
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9329,6 +9339,8 @@ static void enter_smm(struct kvm_vcpu *vcpu)
|
||||
@@ -9334,6 +9344,8 @@ static void enter_smm(struct kvm_vcpu *vcpu)
|
||||
kvm_set_rflags(vcpu, X86_EFLAGS_FIXED);
|
||||
kvm_rip_write(vcpu, 0x8000);
|
||||
|
||||
|
@ -1,182 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Borislav Petkov (AMD)" <bp@alien8.de>
|
||||
Date: Sat, 15 Jul 2023 13:31:32 +0200
|
||||
Subject: [PATCH] x86/cpu/amd: Move the errata checking functionality up
|
||||
|
||||
Upstream commit: 8b6f687743dacce83dbb0c7cfacf88bab00f808a
|
||||
|
||||
Avoid new and remove old forward declarations.
|
||||
|
||||
No functional changes.
|
||||
|
||||
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
arch/x86/kernel/cpu/amd.c | 139 ++++++++++++++++++--------------------
|
||||
1 file changed, 67 insertions(+), 72 deletions(-)
|
||||
|
||||
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
|
||||
index 962d71bb64a8..7caff84f12ca 100644
|
||||
--- a/arch/x86/kernel/cpu/amd.c
|
||||
+++ b/arch/x86/kernel/cpu/amd.c
|
||||
@@ -27,11 +27,6 @@
|
||||
|
||||
#include "cpu.h"
|
||||
|
||||
-static const int amd_erratum_383[];
|
||||
-static const int amd_erratum_400[];
|
||||
-static const int amd_erratum_1054[];
|
||||
-static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum);
|
||||
-
|
||||
/*
|
||||
* nodes_per_socket: Stores the number of nodes per socket.
|
||||
* Refer to Fam15h Models 00-0fh BKDG - CPUID Fn8000_001E_ECX
|
||||
@@ -39,6 +34,73 @@ static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum);
|
||||
*/
|
||||
static u32 nodes_per_socket = 1;
|
||||
|
||||
+/*
|
||||
+ * AMD errata checking
|
||||
+ *
|
||||
+ * Errata are defined as arrays of ints using the AMD_LEGACY_ERRATUM() or
|
||||
+ * AMD_OSVW_ERRATUM() macros. The latter is intended for newer errata that
|
||||
+ * have an OSVW id assigned, which it takes as first argument. Both take a
|
||||
+ * variable number of family-specific model-stepping ranges created by
|
||||
+ * AMD_MODEL_RANGE().
|
||||
+ *
|
||||
+ * Example:
|
||||
+ *
|
||||
+ * const int amd_erratum_319[] =
|
||||
+ * AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0x4, 0x2),
|
||||
+ * AMD_MODEL_RANGE(0x10, 0x8, 0x0, 0x8, 0x0),
|
||||
+ * AMD_MODEL_RANGE(0x10, 0x9, 0x0, 0x9, 0x0));
|
||||
+ */
|
||||
+
|
||||
+#define AMD_LEGACY_ERRATUM(...) { -1, __VA_ARGS__, 0 }
|
||||
+#define AMD_OSVW_ERRATUM(osvw_id, ...) { osvw_id, __VA_ARGS__, 0 }
|
||||
+#define AMD_MODEL_RANGE(f, m_start, s_start, m_end, s_end) \
|
||||
+ ((f << 24) | (m_start << 16) | (s_start << 12) | (m_end << 4) | (s_end))
|
||||
+#define AMD_MODEL_RANGE_FAMILY(range) (((range) >> 24) & 0xff)
|
||||
+#define AMD_MODEL_RANGE_START(range) (((range) >> 12) & 0xfff)
|
||||
+#define AMD_MODEL_RANGE_END(range) ((range) & 0xfff)
|
||||
+
|
||||
+static const int amd_erratum_400[] =
|
||||
+ AMD_OSVW_ERRATUM(1, AMD_MODEL_RANGE(0xf, 0x41, 0x2, 0xff, 0xf),
|
||||
+ AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0xff, 0xf));
|
||||
+
|
||||
+static const int amd_erratum_383[] =
|
||||
+ AMD_OSVW_ERRATUM(3, AMD_MODEL_RANGE(0x10, 0, 0, 0xff, 0xf));
|
||||
+
|
||||
+/* #1054: Instructions Retired Performance Counter May Be Inaccurate */
|
||||
+static const int amd_erratum_1054[] =
|
||||
+ AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x17, 0, 0, 0x2f, 0xf));
|
||||
+
|
||||
+static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum)
|
||||
+{
|
||||
+ int osvw_id = *erratum++;
|
||||
+ u32 range;
|
||||
+ u32 ms;
|
||||
+
|
||||
+ if (osvw_id >= 0 && osvw_id < 65536 &&
|
||||
+ cpu_has(cpu, X86_FEATURE_OSVW)) {
|
||||
+ u64 osvw_len;
|
||||
+
|
||||
+ rdmsrl(MSR_AMD64_OSVW_ID_LENGTH, osvw_len);
|
||||
+ if (osvw_id < osvw_len) {
|
||||
+ u64 osvw_bits;
|
||||
+
|
||||
+ rdmsrl(MSR_AMD64_OSVW_STATUS + (osvw_id >> 6),
|
||||
+ osvw_bits);
|
||||
+ return osvw_bits & (1ULL << (osvw_id & 0x3f));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* OSVW unavailable or ID unknown, match family-model-stepping range */
|
||||
+ ms = (cpu->x86_model << 4) | cpu->x86_stepping;
|
||||
+ while ((range = *erratum++))
|
||||
+ if ((cpu->x86 == AMD_MODEL_RANGE_FAMILY(range)) &&
|
||||
+ (ms >= AMD_MODEL_RANGE_START(range)) &&
|
||||
+ (ms <= AMD_MODEL_RANGE_END(range)))
|
||||
+ return true;
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p)
|
||||
{
|
||||
u32 gprs[8] = { 0 };
|
||||
@@ -1095,73 +1157,6 @@ static const struct cpu_dev amd_cpu_dev = {
|
||||
|
||||
cpu_dev_register(amd_cpu_dev);
|
||||
|
||||
-/*
|
||||
- * AMD errata checking
|
||||
- *
|
||||
- * Errata are defined as arrays of ints using the AMD_LEGACY_ERRATUM() or
|
||||
- * AMD_OSVW_ERRATUM() macros. The latter is intended for newer errata that
|
||||
- * have an OSVW id assigned, which it takes as first argument. Both take a
|
||||
- * variable number of family-specific model-stepping ranges created by
|
||||
- * AMD_MODEL_RANGE().
|
||||
- *
|
||||
- * Example:
|
||||
- *
|
||||
- * const int amd_erratum_319[] =
|
||||
- * AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0x4, 0x2),
|
||||
- * AMD_MODEL_RANGE(0x10, 0x8, 0x0, 0x8, 0x0),
|
||||
- * AMD_MODEL_RANGE(0x10, 0x9, 0x0, 0x9, 0x0));
|
||||
- */
|
||||
-
|
||||
-#define AMD_LEGACY_ERRATUM(...) { -1, __VA_ARGS__, 0 }
|
||||
-#define AMD_OSVW_ERRATUM(osvw_id, ...) { osvw_id, __VA_ARGS__, 0 }
|
||||
-#define AMD_MODEL_RANGE(f, m_start, s_start, m_end, s_end) \
|
||||
- ((f << 24) | (m_start << 16) | (s_start << 12) | (m_end << 4) | (s_end))
|
||||
-#define AMD_MODEL_RANGE_FAMILY(range) (((range) >> 24) & 0xff)
|
||||
-#define AMD_MODEL_RANGE_START(range) (((range) >> 12) & 0xfff)
|
||||
-#define AMD_MODEL_RANGE_END(range) ((range) & 0xfff)
|
||||
-
|
||||
-static const int amd_erratum_400[] =
|
||||
- AMD_OSVW_ERRATUM(1, AMD_MODEL_RANGE(0xf, 0x41, 0x2, 0xff, 0xf),
|
||||
- AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0xff, 0xf));
|
||||
-
|
||||
-static const int amd_erratum_383[] =
|
||||
- AMD_OSVW_ERRATUM(3, AMD_MODEL_RANGE(0x10, 0, 0, 0xff, 0xf));
|
||||
-
|
||||
-/* #1054: Instructions Retired Performance Counter May Be Inaccurate */
|
||||
-static const int amd_erratum_1054[] =
|
||||
- AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x17, 0, 0, 0x2f, 0xf));
|
||||
-
|
||||
-static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum)
|
||||
-{
|
||||
- int osvw_id = *erratum++;
|
||||
- u32 range;
|
||||
- u32 ms;
|
||||
-
|
||||
- if (osvw_id >= 0 && osvw_id < 65536 &&
|
||||
- cpu_has(cpu, X86_FEATURE_OSVW)) {
|
||||
- u64 osvw_len;
|
||||
-
|
||||
- rdmsrl(MSR_AMD64_OSVW_ID_LENGTH, osvw_len);
|
||||
- if (osvw_id < osvw_len) {
|
||||
- u64 osvw_bits;
|
||||
-
|
||||
- rdmsrl(MSR_AMD64_OSVW_STATUS + (osvw_id >> 6),
|
||||
- osvw_bits);
|
||||
- return osvw_bits & (1ULL << (osvw_id & 0x3f));
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- /* OSVW unavailable or ID unknown, match family-model-stepping range */
|
||||
- ms = (cpu->x86_model << 4) | cpu->x86_stepping;
|
||||
- while ((range = *erratum++))
|
||||
- if ((cpu->x86 == AMD_MODEL_RANGE_FAMILY(range)) &&
|
||||
- (ms >= AMD_MODEL_RANGE_START(range)) &&
|
||||
- (ms <= AMD_MODEL_RANGE_END(range)))
|
||||
- return true;
|
||||
-
|
||||
- return false;
|
||||
-}
|
||||
-
|
||||
void set_dr_addr_mask(unsigned long mask, int dr)
|
||||
{
|
||||
if (!boot_cpu_has(X86_FEATURE_BPEXT))
|
@ -1,170 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Borislav Petkov (AMD)" <bp@alien8.de>
|
||||
Date: Sat, 15 Jul 2023 13:41:28 +0200
|
||||
Subject: [PATCH] x86/cpu/amd: Add a Zenbleed fix
|
||||
|
||||
Upstream commit: 522b1d69219d8f083173819fde04f994aa051a98
|
||||
|
||||
Add a fix for the Zen2 VZEROUPPER data corruption bug where under
|
||||
certain circumstances executing VZEROUPPER can cause register
|
||||
corruption or leak data.
|
||||
|
||||
The optimal fix is through microcode but in the case the proper
|
||||
microcode revision has not been applied, enable a fallback fix using
|
||||
a chicken bit.
|
||||
|
||||
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
arch/x86/include/asm/microcode.h | 1 +
|
||||
arch/x86/include/asm/microcode_amd.h | 2 +
|
||||
arch/x86/include/asm/msr-index.h | 1 +
|
||||
arch/x86/kernel/cpu/amd.c | 60 ++++++++++++++++++++++++++++
|
||||
arch/x86/kernel/cpu/common.c | 2 +
|
||||
5 files changed, 66 insertions(+)
|
||||
|
||||
diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h
|
||||
index 1bf064a14b95..4ca377efc986 100644
|
||||
--- a/arch/x86/include/asm/microcode.h
|
||||
+++ b/arch/x86/include/asm/microcode.h
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <asm/cpu.h>
|
||||
#include <linux/earlycpio.h>
|
||||
#include <linux/initrd.h>
|
||||
+#include <asm/microcode_amd.h>
|
||||
|
||||
struct ucode_patch {
|
||||
struct list_head plist;
|
||||
diff --git a/arch/x86/include/asm/microcode_amd.h b/arch/x86/include/asm/microcode_amd.h
|
||||
index a645b25ee442..403a8e76b310 100644
|
||||
--- a/arch/x86/include/asm/microcode_amd.h
|
||||
+++ b/arch/x86/include/asm/microcode_amd.h
|
||||
@@ -48,11 +48,13 @@ extern void __init load_ucode_amd_bsp(unsigned int family);
|
||||
extern void load_ucode_amd_ap(unsigned int family);
|
||||
extern int __init save_microcode_in_initrd_amd(unsigned int family);
|
||||
void reload_ucode_amd(unsigned int cpu);
|
||||
+extern void amd_check_microcode(void);
|
||||
#else
|
||||
static inline void __init load_ucode_amd_bsp(unsigned int family) {}
|
||||
static inline void load_ucode_amd_ap(unsigned int family) {}
|
||||
static inline int __init
|
||||
save_microcode_in_initrd_amd(unsigned int family) { return -EINVAL; }
|
||||
static inline void reload_ucode_amd(unsigned int cpu) {}
|
||||
+static inline void amd_check_microcode(void) {}
|
||||
#endif
|
||||
#endif /* _ASM_X86_MICROCODE_AMD_H */
|
||||
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
|
||||
index ef52c3d48640..af1320071e18 100644
|
||||
--- a/arch/x86/include/asm/msr-index.h
|
||||
+++ b/arch/x86/include/asm/msr-index.h
|
||||
@@ -503,6 +503,7 @@
|
||||
#define MSR_AMD64_DE_CFG 0xc0011029
|
||||
#define MSR_AMD64_DE_CFG_LFENCE_SERIALIZE_BIT 1
|
||||
#define MSR_AMD64_DE_CFG_LFENCE_SERIALIZE BIT_ULL(MSR_AMD64_DE_CFG_LFENCE_SERIALIZE_BIT)
|
||||
+#define MSR_AMD64_DE_CFG_ZEN2_FP_BACKUP_FIX_BIT 9
|
||||
|
||||
#define MSR_AMD64_BU_CFG2 0xc001102a
|
||||
#define MSR_AMD64_IBSFETCHCTL 0xc0011030
|
||||
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
|
||||
index 7caff84f12ca..a2f7311df71e 100644
|
||||
--- a/arch/x86/kernel/cpu/amd.c
|
||||
+++ b/arch/x86/kernel/cpu/amd.c
|
||||
@@ -70,6 +70,11 @@ static const int amd_erratum_383[] =
|
||||
static const int amd_erratum_1054[] =
|
||||
AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x17, 0, 0, 0x2f, 0xf));
|
||||
|
||||
+static const int amd_zenbleed[] =
|
||||
+ AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x17, 0x30, 0x0, 0x4f, 0xf),
|
||||
+ AMD_MODEL_RANGE(0x17, 0x60, 0x0, 0x7f, 0xf),
|
||||
+ AMD_MODEL_RANGE(0x17, 0xa0, 0x0, 0xaf, 0xf));
|
||||
+
|
||||
static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum)
|
||||
{
|
||||
int osvw_id = *erratum++;
|
||||
@@ -973,6 +978,47 @@ static void init_amd_zn(struct cpuinfo_x86 *c)
|
||||
}
|
||||
}
|
||||
|
||||
+static bool cpu_has_zenbleed_microcode(void)
|
||||
+{
|
||||
+ u32 good_rev = 0;
|
||||
+
|
||||
+ switch (boot_cpu_data.x86_model) {
|
||||
+ case 0x30 ... 0x3f: good_rev = 0x0830107a; break;
|
||||
+ case 0x60 ... 0x67: good_rev = 0x0860010b; break;
|
||||
+ case 0x68 ... 0x6f: good_rev = 0x08608105; break;
|
||||
+ case 0x70 ... 0x7f: good_rev = 0x08701032; break;
|
||||
+ case 0xa0 ... 0xaf: good_rev = 0x08a00008; break;
|
||||
+
|
||||
+ default:
|
||||
+ return false;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (boot_cpu_data.microcode < good_rev)
|
||||
+ return false;
|
||||
+
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+static void zenbleed_check(struct cpuinfo_x86 *c)
|
||||
+{
|
||||
+ if (!cpu_has_amd_erratum(c, amd_zenbleed))
|
||||
+ return;
|
||||
+
|
||||
+ if (cpu_has(c, X86_FEATURE_HYPERVISOR))
|
||||
+ return;
|
||||
+
|
||||
+ if (!cpu_has(c, X86_FEATURE_AVX))
|
||||
+ return;
|
||||
+
|
||||
+ if (!cpu_has_zenbleed_microcode()) {
|
||||
+ pr_notice_once("Zenbleed: please update your microcode for the most optimal fix\n");
|
||||
+ msr_set_bit(MSR_AMD64_DE_CFG, MSR_AMD64_DE_CFG_ZEN2_FP_BACKUP_FIX_BIT);
|
||||
+ } else {
|
||||
+ msr_clear_bit(MSR_AMD64_DE_CFG, MSR_AMD64_DE_CFG_ZEN2_FP_BACKUP_FIX_BIT);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void init_amd(struct cpuinfo_x86 *c)
|
||||
{
|
||||
early_init_amd(c);
|
||||
@@ -1062,6 +1108,8 @@ static void init_amd(struct cpuinfo_x86 *c)
|
||||
msr_set_bit(MSR_K7_HWCR, MSR_K7_HWCR_IRPERF_EN_BIT);
|
||||
|
||||
check_null_seg_clears_base(c);
|
||||
+
|
||||
+ zenbleed_check(c);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_X86_32
|
||||
@@ -1191,3 +1239,15 @@ u32 amd_get_highest_perf(void)
|
||||
return 255;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(amd_get_highest_perf);
|
||||
+
|
||||
+static void zenbleed_check_cpu(void *unused)
|
||||
+{
|
||||
+ struct cpuinfo_x86 *c = &cpu_data(smp_processor_id());
|
||||
+
|
||||
+ zenbleed_check(c);
|
||||
+}
|
||||
+
|
||||
+void amd_check_microcode(void)
|
||||
+{
|
||||
+ on_each_cpu(zenbleed_check_cpu, NULL, 1);
|
||||
+}
|
||||
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
|
||||
index 40f48b8cafc7..82e3756260ea 100644
|
||||
--- a/arch/x86/kernel/cpu/common.c
|
||||
+++ b/arch/x86/kernel/cpu/common.c
|
||||
@@ -2260,6 +2260,8 @@ void microcode_check(struct cpuinfo_x86 *prev_info)
|
||||
|
||||
perf_check_microcode();
|
||||
|
||||
+ amd_check_microcode();
|
||||
+
|
||||
store_cpu_caps(&curr_info);
|
||||
|
||||
if (!memcmp(&prev_info->x86_capability, &curr_info.x86_capability,
|
Loading…
Reference in New Issue
Block a user