All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] x86: Add in-scope files under cpu/ to MISRA scans
@ 2026-11-19 14:44 Alejandro Vallejo
  2026-11-19 14:44 ` [PATCH v2 1/3] x86/amd: Consider only Fam10h affected by erratum 383 Alejandro Vallejo
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Alejandro Vallejo @ 2026-11-19 14:44 UTC (permalink / raw)
  To: xen-devel
  Cc: Alejandro Vallejo, Jan Beulich, Andrew Cooper,
	Roger Pau Monné, Teddy Astie, Jason Andryuk, Nicola Vetrini,
	Doug Goldstein, Stefano Stabellini, Anthony PERARD, Michal Orzel,
	Julien Grall

Hi,

v1: https://lore.kernel.org/xen-devel/20261118171758.1125066-1-alejandro.garciavallejo@amd.com/
pipeline: https://gitlab.com/xen-project/people/agvallejo/xen/-/pipelines/3089539179
  (slightly different. fpu.c has different macros, but functionally identical)

v2:

I've reworked the cpu_has_amd_erratum() function into small helpers and
brought the 383 erratum in line with Linux. It turns out a mistake was
made when merging it originally. OSVW is gone and bloat-o-meter reports
200 bytes of net code reduction.

Original cover letter:

The files under cpu/ are excluded from MISRA scans due to their Linux
provenance but they aren't kept in close sync. At best they get
semiregular updates (mwait_idle.c), but most often the files grow with
Xen specifics bops that get a free pass on MISRA scans merely due to
colocation with ancient Linux code. Some files just were never part of
Linux (hygon.c) to begin with, which makes the blanket exclusion even
less credible.

This series brings everything under the MISRA scan umbrella, with the
surprisingly few fixes involved.

Alejandro Vallejo (3):
  x86/amd: Consider only Fam10h affected by erratum 383
  x86/amd: Drop cpu_has_amd_erratum()
  eclair/x86: Scan in-scope files inside cpu/

 .../eclair_analysis/ECLAIR/deviations.ecl     |  3 -
 docs/misra/exclude-list.json                  | 36 -----------
 xen/arch/x86/cpu/amd.c                        | 47 +-------------
 xen/arch/x86/domain.c                         |  2 +-
 xen/arch/x86/hvm/svm/asid.c                   |  2 +-
 xen/arch/x86/hvm/svm/svm.c                    |  2 +-
 xen/arch/x86/include/asm/amd.h                | 62 ++++++-------------
 xen/arch/x86/x86_emulate/fpu.c                |  7 +--
 xen/arch/x86/x86_emulate/x86_emulate.c        |  5 --
 9 files changed, 27 insertions(+), 139 deletions(-)


base-commit: 92ddcda17fb00020c6215d51df4c6a25d5eb0b5e
-- 
2.43.0



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/3] x86/amd: Consider only Fam10h affected by erratum 383
  2026-11-19 14:44 [PATCH v2 0/3] x86: Add in-scope files under cpu/ to MISRA scans Alejandro Vallejo
@ 2026-11-19 14:44 ` Alejandro Vallejo
  2026-11-23 16:53   ` Andrew Cooper
  2026-11-19 14:44 ` [PATCH v2 2/3] x86/amd: Drop cpu_has_amd_erratum() Alejandro Vallejo
  2026-11-19 14:44 ` [PATCH v2 3/3] eclair/x86: Scan in-scope files inside cpu/ Alejandro Vallejo
  2 siblings, 1 reply; 8+ messages in thread
From: Alejandro Vallejo @ 2026-11-19 14:44 UTC (permalink / raw)
  To: xen-devel
  Cc: Alejandro Vallejo, Jan Beulich, Andrew Cooper,
	Roger Pau Monné, Teddy Astie

2604adda4f81 introduced the cpu_has_amd_erratum() machinary while adding
erratum 383. The commit message claims it was based on Linux's, but in
addition to cosmetic changes it also added Fam12h as affected. It is not
acknowledged as so the relevant Fam12h revision guide, and Linux itself
never considered it. My best guess is that OSVW always returns early and
doesn't let the "legacy" mechanism ever match Fam12h (the relevant bit
is always 0, according to its Revision Guide).

Seeing how all K10 is affected, and Xen only matches OSVW for this
erratum, drop OSVW altogether while trimming the list to K10.

Fixes: 2604adda4f81 ("AMD OSVW (OS Visible Workaround) for Xen")
Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@amd.com>
---
Fam12h CPUs where firmware wasn't exposing OSVW would change by not
(wrongly) applying the workaround. I'm not sure if there may be any such
machines. I'm also not sure anyone cares. I wouldn't backport this, thus
why I subsumed the Fam12h removal into the OSVW removal.
---
 xen/arch/x86/cpu/amd.c         | 21 +++------------------
 xen/arch/x86/include/asm/amd.h | 21 +++++++--------------
 2 files changed, 10 insertions(+), 32 deletions(-)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index ff9fc0689f..0515a314dc 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..762b1fbf7a 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,7 @@
     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, 0x0, 0x0, 0xff, 0xf))
 
 #define AMD_ERRATUM_573							\
     AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x0f, 0x0, 0x0, 0xff, 0xf),	\
@@ -72,7 +65,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



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/3] x86/amd: Drop cpu_has_amd_erratum()
  2026-11-19 14:44 [PATCH v2 0/3] x86: Add in-scope files under cpu/ to MISRA scans Alejandro Vallejo
  2026-11-19 14:44 ` [PATCH v2 1/3] x86/amd: Consider only Fam10h affected by erratum 383 Alejandro Vallejo
@ 2026-11-19 14:44 ` Alejandro Vallejo
  2026-11-23 17:08   ` Andrew Cooper
  2026-11-19 14:44 ` [PATCH v2 3/3] eclair/x86: Scan in-scope files inside cpu/ Alejandro Vallejo
  2 siblings, 1 reply; 8+ messages in thread
From: Alejandro Vallejo @ 2026-11-19 14:44 UTC (permalink / raw)
  To: xen-devel
  Cc: Alejandro Vallejo, Jan Beulich, Andrew Cooper,
	Roger Pau Monné, Teddy Astie, Jason Andryuk

cpu_has_amd_erratum() takes the family-model-stepping ranges of an
erratum as variadic arguments, which MISRA C Rule 17.1 forbids, and the
ranges themselves are packed into integers by AMD_MODEL_RANGE(), which
makes them hard to read.

Replace it with one static inline predicate per erratum in asm/amd.h,
stating the vendor, family and models it covers.

No functional change.

Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@amd.com>
---
 xen/arch/x86/cpu/amd.c                 | 32 +--------------
 xen/arch/x86/domain.c                  |  2 +-
 xen/arch/x86/hvm/svm/asid.c            |  2 +-
 xen/arch/x86/hvm/svm/svm.c             |  2 +-
 xen/arch/x86/include/asm/amd.h         | 55 ++++++++++----------------
 xen/arch/x86/x86_emulate/fpu.c         |  7 ++--
 xen/arch/x86/x86_emulate/x86_emulate.c |  5 ---
 7 files changed, 27 insertions(+), 78 deletions(-)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index 0515a314dc..a2386cbfa4 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -317,36 +317,6 @@ void amd_set_cpuid_user_dis(bool enable)
 	wrmsrl(MSR_K8_HWCR, val);
 }
 
-/*
- * 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, ...)
-{
-	va_list ap;
-	u32 range;
-	u32 ms;
-	
-	if (cpu->vendor != X86_VENDOR_AMD)
-		return 0;
-
-	/* Match family-model-stepping range */
-	va_start(ap, cpu);
-
-	ms = (cpu->model << 4) | cpu->stepping;
-	while ((range = va_arg(ap, int))) {
-		if ((cpu->family == AMD_MODEL_RANGE_FAMILY(range)) &&
-		    (ms >= AMD_MODEL_RANGE_START(range)) &&
-		    (ms <= AMD_MODEL_RANGE_END(range))) {
-			va_end(ap);
-			return 1;
-		}
-	}
-
-	va_end(ap);
-	return 0;
-}
-
 /*
  * Disable C1-Clock ramping if enabled in PMM7.CpuLowPwrEnh on 8th-generation
  * cores only. Assume BIOS has setup all Northbridges equivalently.
@@ -1208,7 +1178,7 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)
 	if (c->family == 0x10)
 		__clear_bit(X86_FEATURE_MONITOR, c->x86_capability);
 
-	if (!cpu_has_amd_erratum(c, AMD_ERRATUM_121))
+	if (!cpu_has_amd_erratum_121(c))
 		opt_allow_unsafe = 1;
 	else if (opt_allow_unsafe < 0)
 		panic("Xen will not boot on this CPU for security reasons"
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 74513a79a7..031b292b08 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -833,7 +833,7 @@ int arch_domain_create(struct domain *d,
     if ( !is_hvm_domain(d) )
         d->options |= XEN_DOMCTL_CDF_oos_off;
 
-    if ( d->domain_id && cpu_has_amd_erratum(&boot_cpu_data, AMD_ERRATUM_121) )
+    if ( d->domain_id && cpu_has_amd_erratum_121(&boot_cpu_data) )
     {
         if ( !opt_allow_unsafe )
         {
diff --git a/xen/arch/x86/hvm/svm/asid.c b/xen/arch/x86/hvm/svm/asid.c
index c8d86938d1..e070d97ef8 100644
--- a/xen/arch/x86/hvm/svm/asid.c
+++ b/xen/arch/x86/hvm/svm/asid.c
@@ -16,7 +16,7 @@ void svm_asid_init(const struct cpuinfo_x86 *c)
     unsigned int nasids = 0;
 
     /* Check for erratum #170, and leave ASIDs disabled if it's present. */
-    if ( !cpu_has_amd_erratum(c, AMD_ERRATUM_170) )
+    if ( !cpu_has_amd_erratum_170(c) )
         nasids = cpuid_ebx(0x8000000aU);
 
     hvm_asid_init(nasids);
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index bfca1eda4a..fd89b9bd36 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -1439,7 +1439,7 @@ static void svm_init_erratum_383(const struct cpuinfo_x86 *c)
     uint64_t msr_content;
 
     /* check whether CPU is affected */
-    if ( !cpu_has_amd_erratum(c, AMD_ERRATUM_383) )
+    if ( !cpu_has_amd_erratum_383(c) )
         return;
 
     /* use safe methods to be compatible with nested virtualization */
diff --git a/xen/arch/x86/include/asm/amd.h b/xen/arch/x86/include/asm/amd.h
index 762b1fbf7a..3ed133fcd5 100644
--- a/xen/arch/x86/include/asm/amd.h
+++ b/xen/arch/x86/include/asm/amd.h
@@ -6,43 +6,31 @@
 #define __AMD_H__
 
 #include <asm/cpufeature.h>
+#include <asm/x86-vendors.h>
 
-/* AMD errata checking
- *
- * 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:
- * #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))
- *   
+/*
+ * AMD errata Xen works around, each named after its number in the Revision
+ * Guide for the families it affects.
  */
+static inline bool cpu_has_amd_erratum_121(const struct cpuinfo_x86 *c)
+{
+    return c->vendor == X86_VENDOR_AMD && c->family == 0xf && c->model <= 0x3f;
+}
 
-#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))
-#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 inline bool cpu_has_amd_erratum_170(const struct cpuinfo_x86 *c)
+{
+    return c->vendor == X86_VENDOR_AMD && c->family == 0xf && c->model <= 0x67;
+}
 
-#define AMD_ERRATUM_121                                                 \
-    AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x0f, 0x0, 0x0, 0x3f, 0xf))
+static inline bool cpu_has_amd_erratum_383(const struct cpuinfo_x86 *c)
+{
+    return c->vendor == X86_VENDOR_AMD && c->family == 0x10;
+}
 
-#define AMD_ERRATUM_170                                                 \
-    AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x0f, 0x0, 0x0, 0x67, 0xf))
-
-#define AMD_ERRATUM_383                                                 \
-    AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x10, 0x0, 0x0, 0xff, 0xf))
-
-#define AMD_ERRATUM_573							\
-    AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x0f, 0x0, 0x0, 0xff, 0xf),	\
-                       AMD_MODEL_RANGE(0x10, 0x0, 0x0, 0xff, 0xf),	\
-                       AMD_MODEL_RANGE(0x11, 0x0, 0x0, 0xff, 0xf),	\
-                       AMD_MODEL_RANGE(0x12, 0x0, 0x0, 0xff, 0xf))
+static inline bool cpu_has_amd_erratum_573(const struct cpuinfo_x86 *c)
+{
+    return c->vendor == X86_VENDOR_AMD && c->family >= 0xf && c->family <= 0x12;
+}
 
 /*
  * The Zen1 and Zen2 microarchitectures are implemented by AMD (Fam17h) and
@@ -64,9 +52,6 @@
 #define is_zen5_uarch() (!boot_cpu_has(X86_FEATURE_FRED))
 #define is_zen6_uarch()   boot_cpu_has(X86_FEATURE_FRED)
 
-struct cpuinfo_x86;
-int cpu_has_amd_erratum(const struct cpuinfo_x86 *cpu, ...);
-
 extern int8_t opt_allow_unsafe;
 
 void fam10h_check_enable_mmcfg(void);
diff --git a/xen/arch/x86/x86_emulate/fpu.c b/xen/arch/x86/x86_emulate/fpu.c
index 88df238981..c024f3c601 100644
--- a/xen/arch/x86/x86_emulate/fpu.c
+++ b/xen/arch/x86/x86_emulate/fpu.c
@@ -12,10 +12,9 @@
 
 #ifdef __XEN__
 # include <asm/amd.h>
-# define cpu_has_amd_erratum(nr) \
-         cpu_has_amd_erratum(&current_cpu_data, AMD_ERRATUM_##nr)
+# define cpu_has_amd_erratum_573() cpu_has_amd_erratum_573(&current_cpu_data)
 #else
-# define cpu_has_amd_erratum(nr) 0
+# define cpu_has_amd_erratum_573() false
 #endif
 
 /* Floating point status word definitions. */
@@ -133,7 +132,7 @@ int x86emul_fpu(struct x86_emulate_state *s,
         switch ( s->modrm )
         {
         case 0xfb: /* fsincos */
-            fail_if(cpu_has_amd_erratum(573));
+            fail_if(cpu_has_amd_erratum_573());
             /* fall through */
         case 0xc0 ... 0xc7: /* fld %stN */
         case 0xc8 ... 0xcf: /* fxch %stN */
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index 09d43d204b..2027f7ee6a 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -12,7 +12,6 @@
 
 # include <xen/event.h>
 
-# include <asm/amd.h> /* cpu_has_amd_erratum() */
 # include <asm/processor.h> /* current_cpu_info */
 # include <asm/x86_emulate.h>
 # include <asm/xstate.h>
@@ -22,9 +21,6 @@
 # undef cpuid
 # undef wbinvd
 
-# define cpu_has_amd_erratum(nr) \
-         cpu_has_amd_erratum(&current_cpu_data, AMD_ERRATUM_##nr)
-
 #else /* !__XEN__ */
 
 /* See gcc bug 100680, but here don't bother making this version dependent. */
@@ -34,7 +30,6 @@
      (typeof(x))x_;                        \
 })
 
-# define cpu_has_amd_erratum(nr) 0
 # define cpu_has_mpx false
 # define read_bndcfgu() 0
 # define xstate_set_init(what)
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/3] eclair/x86: Scan in-scope files inside cpu/
  2026-11-19 14:44 [PATCH v2 0/3] x86: Add in-scope files under cpu/ to MISRA scans Alejandro Vallejo
  2026-11-19 14:44 ` [PATCH v2 1/3] x86/amd: Consider only Fam10h affected by erratum 383 Alejandro Vallejo
  2026-11-19 14:44 ` [PATCH v2 2/3] x86/amd: Drop cpu_has_amd_erratum() Alejandro Vallejo
@ 2026-11-19 14:44 ` Alejandro Vallejo
  2 siblings, 0 replies; 8+ messages in thread
From: Alejandro Vallejo @ 2026-11-19 14:44 UTC (permalink / raw)
  To: xen-devel
  Cc: Alejandro Vallejo, Nicola Vetrini, Doug Goldstein,
	Stefano Stabellini, Andrew Cooper, Anthony PERARD, Michal Orzel,
	Jan Beulich, Julien Grall, Roger Pau Monné

Remove the exclusions now that all in-scope files inside are clean on
the regression subset.

Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@amd.com>
Acked-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
 .../eclair_analysis/ECLAIR/deviations.ecl     |  3 --
 docs/misra/exclude-list.json                  | 36 -------------------
 2 files changed, 39 deletions(-)

diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl
index 58af4fb5cd..9aa443e8fd 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -189,9 +189,6 @@ context of R7.2."
 -file_tag+={adopted_r7_2,"^xen/include/efi/efiapi\\.h$"}
 -file_tag+={adopted_r7_2,"^xen/include/efi/efidef\\.h$"}
 -file_tag+={adopted_r7_2,"^xen/include/efi/efiprot\\.h$"}
--file_tag+={adopted_r7_2,"^xen/arch/x86/cpu/intel\\.c$"}
--file_tag+={adopted_r7_2,"^xen/arch/x86/cpu/amd\\.c$"}
--file_tag+={adopted_r7_2,"^xen/arch/x86/cpu/common\\.c$"}
 -config=MC3A2.R7.2,reports+={deliberate,"any_area(any_loc(file(adopted_r7_2)))"}
 -doc_end
 
diff --git a/docs/misra/exclude-list.json b/docs/misra/exclude-list.json
index 2b874dfd3b..a52f0d6429 100644
--- a/docs/misra/exclude-list.json
+++ b/docs/misra/exclude-list.json
@@ -33,42 +33,6 @@
             "rel_path": "arch/x86/acpi/lib.c",
             "comment": "Imported from Linux, ignore for now"
         },
-        {
-            "rel_path": "arch/x86/cpu/amd.c",
-            "comment": "Imported from Linux, ignore for now"
-        },
-        {
-            "rel_path": "arch/x86/cpu/centaur.c",
-            "comment": "Imported from Linux, ignore for now"
-        },
-        {
-            "rel_path": "arch/x86/cpu/common.c",
-            "comment": "Imported from Linux, ignore for now"
-        },
-        {
-            "rel_path": "arch/x86/cpu/hygon.c",
-            "comment": "Imported from Linux, ignore for now"
-        },
-        {
-            "rel_path": "arch/x86/cpu/intel.c",
-            "comment": "Imported from Linux, ignore for now"
-        },
-        {
-            "rel_path": "arch/x86/cpu/intel_cacheinfo.c",
-            "comment": "Imported from Linux, ignore for now"
-        },
-        {
-            "rel_path": "arch/x86/cpu/mcheck/non-fatal.c",
-            "comment": "Imported from Linux, ignore for now"
-        },
-        {
-            "rel_path": "arch/x86/cpu/mtrr/*",
-            "comment": "Imported from Linux, ignore for now"
-        },
-        {
-            "rel_path": "arch/x86/cpu/mwait-idle.c",
-            "comment": "Imported from Linux, ignore for now"
-        },
         {
             "rel_path": "arch/x86/delay.c",
             "comment": "Imported from Linux, ignore for now"
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/3] x86/amd: Consider only Fam10h affected by erratum 383
@ 2026-11-20  1:20 Christian Ludloff
  0 siblings, 0 replies; 8+ messages in thread
From: Christian Ludloff @ 2026-11-20  1:20 UTC (permalink / raw)
  To: xen-devel

> [...] added Fam12h as affected. It is not acknowledged
> as so the relevant Fam12h revision guide [...]

That's because the public RG (#44739-3.10) only lists
a subset of what the non-public one (3.11) contains. In
particular, erratum #383 does affect LN-A0 and LN-A1
but not LN-B0. One school of thought foolishly argues
that A0 and A1 were samples, while another school of
thought doesn't argue but just points at silicon which is
out there in the wild.

00300F00h (LN-A0) affected
00300F01h (LN-A1) affected
00300F10h (LN-B0) not affected

--
C.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/3] x86/amd: Consider only Fam10h affected by erratum 383
  2026-11-19 14:44 ` [PATCH v2 1/3] x86/amd: Consider only Fam10h affected by erratum 383 Alejandro Vallejo
@ 2026-11-23 16:53   ` Andrew Cooper
  2026-11-26 15:34     ` Alejandro Vallejo
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Cooper @ 2026-11-23 16:53 UTC (permalink / raw)
  To: Alejandro Vallejo, xen-devel
  Cc: Andrew Cooper, Jan Beulich, Roger Pau Monné, Teddy Astie

On 19/11/2026 2:44 pm, Alejandro Vallejo wrote:
> 2604adda4f81 introduced the cpu_has_amd_erratum() machinary while adding
> erratum 383. The commit message claims it was based on Linux's, but in
> addition to cosmetic changes it also added Fam12h as affected. It is not
> acknowledged as so the relevant Fam12h revision guide, and Linux itself
> never considered it.

You need the NDA revision guide, not the public one.

Fam12h, Model 0 Steppings 0 and 1 are affected.  It was fixed starting
in Model 1.


> My best guess is that OSVW always returns early and
> doesn't let the "legacy" mechanism ever match Fam12h (the relevant bit
> is always 0, according to its Revision Guide).

The OSVW MSRs are fully writeable, with a note saying "OS/VMM should
treat them as read-only".

Getting helpful OSVW information requires a firmware update, which means
OS/VMM software needs the fallback list irrespective.

This is why we have the legacy list as well, but it also means it
suffices to only have the legacy list.  (Yes, technically we could be
levelled and OSVW says vulnerable outside of the range, but for the sake
of one 20-year-old errata, I'm not overly bothered about this corner case).

Anyway, this can be given as the justification for getting rid of OSVW,
with the Fam12 range reinstated.

~Andrew


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/3] x86/amd: Drop cpu_has_amd_erratum()
  2026-11-19 14:44 ` [PATCH v2 2/3] x86/amd: Drop cpu_has_amd_erratum() Alejandro Vallejo
@ 2026-11-23 17:08   ` Andrew Cooper
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Cooper @ 2026-11-23 17:08 UTC (permalink / raw)
  To: Alejandro Vallejo, xen-devel
  Cc: Andrew Cooper, Jan Beulich, Roger Pau Monné, Teddy Astie,
	Jason Andryuk

On 19/11/2026 2:44 pm, Alejandro Vallejo wrote:
> diff --git a/xen/arch/x86/include/asm/amd.h b/xen/arch/x86/include/asm/amd.h
> index 762b1fbf7a..3ed133fcd5 100644
> --- a/xen/arch/x86/include/asm/amd.h
> +++ b/xen/arch/x86/include/asm/amd.h
> @@ -6,43 +6,31 @@
>  #define __AMD_H__
>  
>  #include <asm/cpufeature.h>
> +#include <asm/x86-vendors.h>
>  
> -/* AMD errata checking
> - *
> - * 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:
> - * #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))
> - *   
> +/*
> + * AMD errata Xen works around, each named after its number in the Revision
> + * Guide for the families it affects.
>   */

These could really do with some information about what they are.

/* Sequential execution across the non-canonical boundary causes hang. */

> +static inline bool cpu_has_amd_erratum_121(const struct cpuinfo_x86 *c)
> +{
> +    return c->vendor == X86_VENDOR_AMD && c->family == 0xf && c->model <= 0x3f;
> +}
>  
> -#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))
> -#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)

/* Incorrect code bytes fetched after a world switch. */

> +static inline bool cpu_has_amd_erratum_170(const struct cpuinfo_x86 *c)
> +{
> +    return c->vendor == X86_VENDOR_AMD && c->family == 0xf && c->model <= 0x67;
> +}
>  
> -#define AMD_ERRATUM_121                                                 \
> -    AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x0f, 0x0, 0x0, 0x3f, 0xf))

/* L1 TLB multi-hit causes #MC. */

> +static inline bool cpu_has_amd_erratum_383(const struct cpuinfo_x86 *c)
> +{
> +    return c->vendor == X86_VENDOR_AMD && c->family == 0x10;
> +}
>  
> -#define AMD_ERRATUM_170                                                 \
> -    AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x0f, 0x0, 0x0, 0x67, 0xf))
> -
> -#define AMD_ERRATUM_383                                                 \
> -    AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x10, 0x0, 0x0, 0xff, 0xf))
> -
> -#define AMD_ERRATUM_573							\
> -    AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x0f, 0x0, 0x0, 0xff, 0xf),	\
> -                       AMD_MODEL_RANGE(0x10, 0x0, 0x0, 0xff, 0xf),	\
> -                       AMD_MODEL_RANGE(0x11, 0x0, 0x0, 0xff, 0xf),	\
> -                       AMD_MODEL_RANGE(0x12, 0x0, 0x0, 0xff, 0xf))

/* FSINCOS instruction may corrupt %rip. */

> +static inline bool cpu_has_amd_erratum_573(const struct cpuinfo_x86 *c)
> +{
> +    return c->vendor == X86_VENDOR_AMD && c->family >= 0xf && c->family <= 0x12;
> +}
>  

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>, subject to rebasing
over the correction in patch 1.

~Andrew


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/3] x86/amd: Consider only Fam10h affected by erratum 383
  2026-11-23 16:53   ` Andrew Cooper
@ 2026-11-26 15:34     ` Alejandro Vallejo
  0 siblings, 0 replies; 8+ messages in thread
From: Alejandro Vallejo @ 2026-11-26 15:34 UTC (permalink / raw)
  To: Andrew Cooper, xen-devel; +Cc: Jan Beulich, Roger Pau Monné, Teddy Astie

On Mon Nov 23, 2026 at 5:53 PM CET, Andrew Cooper wrote:
> On 19/11/2026 2:44 pm, Alejandro Vallejo wrote:
> > 2604adda4f81 introduced the cpu_has_amd_erratum() machinary while adding
> > erratum 383. The commit message claims it was based on Linux's, but in
> > addition to cosmetic changes it also added Fam12h as affected. It is not
> > acknowledged as so the relevant Fam12h revision guide, and Linux itself
> > never considered it.
>
> You need the NDA revision guide, not the public one.
>
> Fam12h, Model 0 Steppings 0 and 1 are affected.  It was fixed starting
> in Model 1.

They are 15yo engineering samples...

More interestingly, the fallback list is wrong. It considers
model1/stepping0 affected when it shouldn't. THAT's actual silicon
people could buy.  The range is inclusive, but it was  written as
exclusive.

I'll rewrite the patch keeping Fam12h, even if it's silly to do so. with
the last item being model0/steppingF.

Cheers,
Alejandro

>
>
> > My best guess is that OSVW always returns early and
> > doesn't let the "legacy" mechanism ever match Fam12h (the relevant bit
> > is always 0, according to its Revision Guide).
>
> The OSVW MSRs are fully writeable, with a note saying "OS/VMM should
> treat them as read-only".
>
> Getting helpful OSVW information requires a firmware update, which means
> OS/VMM software needs the fallback list irrespective.
>
> This is why we have the legacy list as well, but it also means it
> suffices to only have the legacy list.  (Yes, technically we could be
> levelled and OSVW says vulnerable outside of the range, but for the sake
> of one 20-year-old errata, I'm not overly bothered about this corner case).
>
> Anyway, this can be given as the justification for getting rid of OSVW,
> with the Fam12 range reinstated.
>
> ~Andrew



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-26 15:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 14:44 [PATCH v2 0/3] x86: Add in-scope files under cpu/ to MISRA scans Alejandro Vallejo
2026-11-19 14:44 ` [PATCH v2 1/3] x86/amd: Consider only Fam10h affected by erratum 383 Alejandro Vallejo
2026-11-23 16:53   ` Andrew Cooper
2026-11-26 15:34     ` Alejandro Vallejo
2026-11-19 14:44 ` [PATCH v2 2/3] x86/amd: Drop cpu_has_amd_erratum() Alejandro Vallejo
2026-11-23 17:08   ` Andrew Cooper
2026-11-19 14:44 ` [PATCH v2 3/3] eclair/x86: Scan in-scope files inside cpu/ Alejandro Vallejo
  -- strict thread matches above, loose matches on Subject: below --
2026-11-20  1:20 [PATCH v2 1/3] x86/amd: Consider only Fam10h affected by erratum 383 Christian Ludloff

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.