|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v3 1/3] x86/amd: Fix off by one error in Fam12h range of erratum 383
Model 1 isn't affected, but the macro says it is (end is inclusive).
Mark the limit as model0/steppingF.
While at it, note that OSVW is purely redundant with the fallback list.
We only use it for errata 383, but that has a well known set of
processors it affects so we can rely on the exhaustive list.
Fixes: 2604adda4f81 ("AMD OSVW (OS Visible Workaround) for Xen")
Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
---
v3:
* Kept Fam12h on errata 383, because there might be someone hoarding a
15yo engineering sample and expecting a 2026 Xen to work well on it.
---
xen/arch/x86/cpu/amd.c | 21 +++------------------
xen/arch/x86/include/asm/amd.h | 22 ++++++++--------------
2 files changed, 11 insertions(+), 32 deletions(-)
diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index 8fd0b67516..c6d6913cfa 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -321,7 +321,7 @@ void amd_set_cpuid_user_dis(bool enable)
* Check for the presence of an AMD erratum. Arguments are defined in amd.h
* for each known erratum. Return 1 if erratum is found.
*/
-int cpu_has_amd_erratum(const struct cpuinfo_x86 *cpu, int osvw_id, ...)
+int cpu_has_amd_erratum(const struct cpuinfo_x86 *cpu, ...)
{
va_list ap;
u32 range;
@@ -330,23 +330,8 @@ int cpu_has_amd_erratum(const struct cpuinfo_x86 *cpu, int
osvw_id, ...)
if (cpu->vendor != X86_VENDOR_AMD)
return 0;
- if (osvw_id >= 0 && cpu_has(cpu, X86_FEATURE_OSVW)) {
- u64 osvw_len;
-
- rdmsrl(MSR_AMD_OSVW_ID_LENGTH, osvw_len);
-
- if (osvw_id < osvw_len) {
- u64 osvw_bits;
-
- rdmsrl(MSR_AMD_OSVW_STATUS + (osvw_id >> 6),
- osvw_bits);
-
- return (osvw_bits >> (osvw_id & 0x3f)) & 1;
- }
- }
-
- /* OSVW unavailable or ID unknown, match family-model-stepping range */
- va_start(ap, osvw_id);
+ /* Match family-model-stepping range */
+ va_start(ap, cpu);
ms = (cpu->model << 4) | cpu->stepping;
while ((range = va_arg(ap, int))) {
diff --git a/xen/arch/x86/include/asm/amd.h b/xen/arch/x86/include/asm/amd.h
index d21df0741a..d87a57f7a5 100644
--- a/xen/arch/x86/include/asm/amd.h
+++ b/xen/arch/x86/include/asm/amd.h
@@ -9,25 +9,19 @@
/* AMD errata checking
*
- * Errata are defined 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().
+ * Errata are defined using the AMD_LEGACY_ERRATUM() macro, which takes a
+ * variable number of family-specific model-stepping ranges created by
+ * AMD_MODEL_RANGE().
*
- * Example 1:
+ * Example:
* #define 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))
- * Example 2:
- * #define AMD_ERRATUM_400 \
- * AMD_OSVW_ERRATUM(1, AMD_MODEL_RANGE(0xf, 0x41, 0x2, 0xff, 0xf), \
- * AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0xff, 0xf))
*
*/
-#define AMD_LEGACY_ERRATUM(...) -1 /* legacy */, __VA_ARGS__, 0
-#define AMD_OSVW_ERRATUM(osvw_id, ...) osvw_id, __VA_ARGS__, 0
+#define AMD_LEGACY_ERRATUM(...) __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))
@@ -42,8 +36,8 @@
AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x0f, 0x0, 0x0, 0x67, 0xf))
#define AMD_ERRATUM_383 \
- AMD_OSVW_ERRATUM(3, AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0xff, 0xf), \
- AMD_MODEL_RANGE(0x12, 0x0, 0x0, 0x1, 0x0))
+ AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0xff, 0xf), \
+ AMD_MODEL_RANGE(0x12, 0x0, 0x0, 0x00, 0xf))
#define AMD_ERRATUM_573
\
AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x0f, 0x0, 0x0, 0xff, 0xf), \
@@ -72,7 +66,7 @@
#define is_zen6_uarch() boot_cpu_has(X86_FEATURE_FRED)
struct cpuinfo_x86;
-int cpu_has_amd_erratum(const struct cpuinfo_x86 *cpu, int osvw_id, ...);
+int cpu_has_amd_erratum(const struct cpuinfo_x86 *cpu, ...);
extern int8_t opt_allow_unsafe;
--
2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |