mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: hans.rosenfeld@amd.com, ak@linux.intel.com, hpa@linux.intel.com,
	gregkh@suse.de, linux-kernel@vger.kernel.org, stable@kernel.org,
	tim.bird@am.sony.com
Subject: [PATCH] [63/106] x86, cpu: AMD errata checking framework
Date: Tue, 26 Apr 2011 14:13:44 -0700 (PDT)	[thread overview]
Message-ID: <20110426211344.0E4083E1886@tassilo.jf.intel.com> (raw)
In-Reply-To: <20110426212.641772347@firstfloor.org>

2.6.35-longterm review patch.  If anyone has any objections, please let me know.

------------------
From: Hans Rosenfeld <hans.rosenfeld@amd.com>

commit d78d671db478eb8b14c78501c0cee1cc7baf6967 upstream.

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().

Iff an erratum has an OSVW id, OSVW is available on the CPU, and the
OSVW id is known to the hardware, it is used to determine whether an
erratum is present. Otherwise, the model-stepping ranges are matched
against the current CPU to find out whether the erratum applies.

For certain special errata, the code using this framework might have to
conduct further checks to make sure an erratum is really (not) present.

Signed-off-by: Hans Rosenfeld <hans.rosenfeld@amd.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
LKML-Reference: <1280336972-865982-1-git-send-email-hans.rosenfeld@amd.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 arch/x86/include/asm/processor.h |   18 +++++++++++
 arch/x86/kernel/cpu/amd.c        |   60 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)

Index: linux-2.6.35.y/arch/x86/include/asm/processor.h
===================================================================
--- linux-2.6.35.y.orig/arch/x86/include/asm/processor.h
+++ linux-2.6.35.y/arch/x86/include/asm/processor.h
@@ -1002,4 +1002,22 @@ unsigned long calc_aperfmperf_ratio(stru
 	return ratio;
 }
 
+/*
+ * AMD errata checking
+ */
+#ifdef CONFIG_CPU_SUP_AMD
+extern bool cpu_has_amd_erratum(const int *);
+
+#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)
+
+#else
+#define cpu_has_amd_erratum(x)	(false)
+#endif /* CONFIG_CPU_SUP_AMD */
+
 #endif /* _ASM_X86_PROCESSOR_H */
Index: linux-2.6.35.y/arch/x86/kernel/cpu/amd.c
===================================================================
--- linux-2.6.35.y.orig/arch/x86/kernel/cpu/amd.c
+++ linux-2.6.35.y/arch/x86/kernel/cpu/amd.c
@@ -608,3 +608,63 @@ static const struct cpu_dev __cpuinitcon
 };
 
 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(). Each erratum also has to be declared as extern const
+ * int[] in arch/x86/include/asm/processor.h.
+ *
+ * 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));
+ */
+
+bool cpu_has_amd_erratum(const int *erratum)
+{
+	struct cpuinfo_x86 *cpu = &current_cpu_data;
+	int osvw_id = *erratum++;
+	u32 range;
+	u32 ms;
+
+	/*
+	 * If called early enough that current_cpu_data hasn't been initialized
+	 * yet, fall back to boot_cpu_data.
+	 */
+	if (cpu->x86 == 0)
+		cpu = &boot_cpu_data;
+
+	if (cpu->x86_vendor != X86_VENDOR_AMD)
+		return false;
+
+	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 << 8) | cpu->x86_mask;
+	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;
+}

  parent reply	other threads:[~2011-04-26 21:14 UTC|newest]

Thread overview: 125+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-26 21:12 [PATCH] [0/106] 2.6.35.13 longterm review Andi Kleen
2011-04-26 21:12 ` [PATCH] [1/106] mm: page allocator: adjust the per-cpu counter threshold when memory is low Andi Kleen
2011-04-26 21:12 ` [PATCH] [2/106] qla2xxx: Make the FC port capability mutual exclusive Andi Kleen
2011-04-26 21:12 ` [PATCH] [3/106] staging: usbip: bugfixes related to kthread conversion Andi Kleen
2011-04-26 21:12 ` [PATCH] [4/106] staging: usbip: bugfix add number of packets for isochronous frames Andi Kleen
2011-04-26 21:12 ` [PATCH] [5/106] staging: usbip: bugfix for isochronous packets and optimization Andi Kleen
2011-04-26 21:12 ` [PATCH] [6/106] staging: hv: Fix GARP not sent after Quick Migration Andi Kleen
2011-04-26 21:12 ` [PATCH] [7/106] staging: hv: use sync_bitops when interacting with the hypervisor Andi Kleen
2011-04-26 21:12 ` [PATCH] [8/106] xfs: prevent leaking uninitialized stack memory in FSGEOMETRY_V1 Andi Kleen
2011-04-27  5:26   ` Dave Chinner
2011-04-27 15:00     ` Andi Kleen
2011-04-28  0:04       ` Dave Chinner
2011-04-26 21:12 ` [PATCH] [9/106] irda: validate peer name and attribute lengths Andi Kleen
2011-04-26 21:12 ` [PATCH] [10/106] irda: prevent heap corruption on invalid nickname Andi Kleen
2011-04-26 21:12 ` [PATCH] [11/106] nilfs2: fix data loss in mmap page write for hole blocks Andi Kleen
2011-04-26 21:12 ` [PATCH] [12/106] ASoC: Explicitly say registerless widgets have no register Andi Kleen
2011-04-26 21:12 ` [PATCH] [13/106] ALSA: ens1371: fix Creative Ectiva support Andi Kleen
2011-04-26 21:12 ` [PATCH] [14/106] ROSE: prevent heap corruption with bad facilities Andi Kleen
2011-04-26 21:12 ` [PATCH] [15/106] Btrfs: Fix uninitialized root flags for subvolumes Andi Kleen
2011-04-26 21:12 ` [PATCH] [16/106] x86, mtrr, pat: Fix one cpu getting out of sync during resume Andi Kleen
2011-04-26 21:12 ` [PATCH] [17/106] UBIFS: do not read flash unnecessarily Andi Kleen
2011-04-26 21:12 ` [PATCH] [18/106] UBIFS: fix oops on error path in read_pnode Andi Kleen
2011-04-26 21:12 ` [PATCH] [19/106] UBIFS: fix debugging failure in dbg_check_space_info Andi Kleen
2011-04-26 21:12 ` [PATCH] [20/106] quota: Don't write quota info in dquot_commit() Andi Kleen
2011-04-26 21:12 ` [PATCH] [21/106] mm: avoid wrapping vm_pgoff in mremap() Andi Kleen
2011-04-26 21:13 ` [PATCH] [22/106] p54usb: IDs for two new devices Andi Kleen
2011-04-26 21:13 ` [PATCH] [23/106] b43: allocate receive buffers big enough for max frame len + offset Andi Kleen
2011-04-26 21:13 ` [PATCH] [24/106] Bluetooth: sco: fix information leak to userspace Andi Kleen
2011-04-26 21:13 ` [PATCH] [25/106] bridge: netfilter: fix information leak Andi Kleen
2011-04-26 21:13 ` [PATCH] [26/106] Bluetooth: bnep: fix buffer overflow Andi Kleen
2011-04-26 21:13 ` [PATCH] [27/106] Bluetooth: add support for Apple MacBook Pro 8,2 Andi Kleen
2011-04-26 21:13 ` [PATCH] [28/106] Treat writes as new when holes span across page boundaries Andi Kleen
2011-04-26 21:13 ` [PATCH] [29/106] char/tpm: Fix unitialized usage of data buffer Andi Kleen
2011-04-26 21:13 ` [PATCH] [30/106] netfilter: ip_tables: fix infoleak to userspace Andi Kleen
2011-04-26 21:13 ` [PATCH] [31/106] netfilter: arp_tables: " Andi Kleen
2011-04-26 21:13 ` [PATCH] [32/106] netfilter: ipt_CLUSTERIP: fix buffer overflow Andi Kleen
2011-04-26 21:13 ` [PATCH] [33/106] ipv6: netfilter: ip6_tables: fix infoleak to userspace Andi Kleen
2011-04-26 21:13 ` [PATCH] [34/106] mfd: ab3100: world-writable debugfs *_priv files Andi Kleen
2011-04-26 21:13 ` [PATCH] [35/106] drivers/rtc/rtc-ds1511.c: world-writable sysfs nvram file Andi Kleen
2011-04-26 21:13 ` [PATCH] [36/106] drivers/misc/ep93xx_pwm.c: world-writable sysfs files Andi Kleen
2011-04-26 21:13 ` [PATCH] [37/106] econet: 4 byte infoleak to the network Andi Kleen
2011-04-26 21:13 ` [PATCH] [38/106] sound/oss: remove offset from load_patch callbacks Andi Kleen
2011-04-26 21:13 ` [PATCH] [39/106] sound: oss: midi_synth: check get_user() return value Andi Kleen
2011-04-26 21:13 ` [PATCH] [40/106] gro: Reset dev pointer on reuse Andi Kleen
2011-04-26 21:13 ` [PATCH] [41/106] gro: reset skb_iif " Andi Kleen
2011-04-26 21:13 ` [PATCH] [42/106] x86, microcode, AMD: Extend ucode size verification Andi Kleen
2011-04-26 22:44   ` Paul Gortmaker
2011-04-26 23:03     ` Andi Kleen
2011-04-26 21:13 ` [PATCH] [43/106] Squashfs: handle corruption of directory structure Andi Kleen
2011-04-26 21:13 ` [PATCH] [44/106] atm/solos-pci: Don't include frame pseudo-header on transmit hex-dump Andi Kleen
2011-04-26 21:13 ` [PATCH] [45/106] ext4: fix credits computing for indirect mapped files Andi Kleen
2011-04-26 21:13 ` [PATCH] [46/106] nfsd: fix auth_domain reference leak on nlm operations Andi Kleen
2011-04-26 21:13 ` [PATCH] [47/106] net: tipc: fix information leak to userland Andi Kleen
2011-04-26 21:13 ` [PATCH] [48/106] inet_diag: Make sure we actually run the same bytecode we audited Andi Kleen
2011-04-26 21:13 ` [PATCH] [49/106] irda: prevent integer underflow in IRLMP_ENUMDEVICES Andi Kleen
2011-04-26 21:13 ` [PATCH] [50/106] CAN: Use inode instead of kernel address for /proc file Andi Kleen
2011-04-26 21:13 ` [PATCH] [51/106] net: fix rds_iovec page count overflow Andi Kleen
2011-04-26 21:13 ` [PATCH] [52/106] xfs: zero proper structure size for geometry calls Andi Kleen
2011-04-26 21:13 ` [PATCH] [53/106] cifs: always do is_path_accessible check in cifs_mount Andi Kleen
2011-04-26 21:13 ` [PATCH] [54/106] video: sn9c102: world-wirtable sysfs files Andi Kleen
2011-04-26 21:13 ` [PATCH] [55/106] UBIFS: restrict world-writable debugfs files Andi Kleen
2011-04-26 21:13 ` [PATCH] [56/106] NET: cdc-phonet, handle empty phonet header Andi Kleen
2011-04-26 21:13 ` [PATCH] [57/106] x86: Fix a bogus unwind annotation in lib/semaphore_32.S Andi Kleen
2011-04-26 21:13 ` [PATCH] [58/106] tioca: Fix assignment from incompatible pointer warnings Andi Kleen
2011-04-26 21:13 ` [PATCH] [59/106] mca.c: Fix cast from integer to pointer warning Andi Kleen
2011-04-26 21:13 ` [PATCH] [60/106] ramfs: fix memleak on no-mmu arch Andi Kleen
2011-04-26 21:13 ` [PATCH] [61/106] MAINTAINERS: update STABLE BRANCH info Andi Kleen
2011-04-26 21:13 ` [PATCH] [62/106] UBIFS: fix oops when R/O file-system is fsync'ed Andi Kleen
2011-04-26 21:13 ` Andi Kleen [this message]
2011-04-26 21:13 ` [PATCH] [64/106] x86, cpu: Clean up AMD erratum 400 workaround Andi Kleen
2011-04-26 21:13 ` [PATCH] [65/106] x86, AMD: Set ARAT feature on AMD processors Andi Kleen
2011-04-26 21:13 ` [PATCH] [66/106] x86, amd: Disable GartTlbWlkErr when BIOS forgets it Andi Kleen
2011-04-26 21:13 ` [PATCH] [67/106] USB: ftdi_sio: Added IDs for CTI USB Serial Devices Andi Kleen
2011-04-26 21:13 ` [PATCH] [68/106] USB: ftdi_sio: add PID for OCT DK201 docking station Andi Kleen
2011-04-26 21:13 ` [PATCH] [69/106] USB: ftdi_sio: add ids for Hameg HO720 and HO730 Andi Kleen
2011-04-26 21:13 ` [PATCH] [70/106] USB: option: Add new ONDA vendor id and product id for ONDA MT825UP Andi Kleen
2011-04-26 21:13 ` [PATCH] [71/106] USB: option: Added support for Samsung GT-B3730/GT-B3710 LTE USB modem Andi Kleen
2011-04-26 21:13 ` [PATCH] [72/106] next_pidmap: fix overflow condition Andi Kleen
2011-04-26 21:13 ` [PATCH] [73/106] proc: do proper range check on readdir offset Andi Kleen
2011-04-26 21:13 ` [PATCH] [74/106] USB: EHCI: unlink unused QHs when the controller is stopped Andi Kleen
2011-04-26 21:13 ` [PATCH] [75/106] USB: fix formatting of SuperSpeed endpoints in /proc/bus/usb/devices Andi Kleen
2011-04-26 21:13 ` [PATCH] [76/106] USB: xhci - fix unsafe macro definitions Andi Kleen
2011-04-26 21:13 ` [PATCH] [77/106] USB: xhci - fix math in xhci_get_endpoint_interval() Andi Kleen
2011-04-26 21:13 ` [PATCH] [78/106] x86, cpu: Fix regression in AMD errata checking code Andi Kleen
2011-04-26 21:14 ` [PATCH] [79/106] net: ax25: fix information leak to userland harder Andi Kleen
2011-04-26 21:14 ` [PATCH] [80/106] Input: synaptics - fix crash in synaptics_module_init() Andi Kleen
2011-04-26 21:14 ` [PATCH] [81/106] ath9k: fix a chip wakeup related crash in ath9k_start Andi Kleen
2011-04-26 21:14 ` [PATCH] [82/106] ath: add missing regdomain pair 0x5c mapping Andi Kleen
2011-04-26 21:14 ` [PATCH] [83/106] block, blk-sysfs: Fix an err return path in blk_register_queue() Andi Kleen
2011-04-26 21:14 ` [PATCH] [84/106] p54: Initialize extra_len in p54_tx_80211 Andi Kleen
2011-04-26 21:14 ` [PATCH] [85/106] x86, gart: Make sure GART does not map physmem above 1TB Andi Kleen
2011-04-26 21:14 ` [PATCH] [86/106] intel-iommu: Unlink domain from iommu Andi Kleen
2011-04-26 21:14 ` [PATCH] [87/106] intel-iommu: Fix get_domain_for_dev() error path Andi Kleen
2011-04-26 21:14 ` [PATCH] [88/106] drm/radeon/kms: fix bad shift in atom iio table parser Andi Kleen
2011-04-26 21:14 ` [PATCH] [89/106] NFS: nfs_wcc_update_inode() should set nfsi->attr_gencount Andi Kleen
2011-04-26 21:14 ` [PATCH] [90/106] serial/imx: read cts state only after acking cts change irq Andi Kleen
2011-04-26 21:14 ` [PATCH] [91/106] ASoC: Fix output PGA enabling in wm_hubs CODECs Andi Kleen
2011-04-26 21:14 ` [PATCH] [92/106] kconfig: Avoid buffer underrun in choice input Andi Kleen
2011-04-26 21:14 ` [PATCH] [93/106] UBIFS: fix master node recovery Andi Kleen
2011-04-26 21:14 ` [PATCH] [94/106] Remove extra struct page member from the buffer info structure Andi Kleen
2011-04-26 21:14 ` [PATCH] [95/106] dasd: correct device table Andi Kleen
2011-04-26 21:14 ` [PATCH] [96/106] iwlagn: Support new 5000 microcode Andi Kleen
2011-04-27 17:42   ` Tim Gardner
2011-04-27 20:47     ` Valdis.Kletnieks
2011-04-27 22:20       ` Andi Kleen
2011-04-27 22:32         ` wwguy
2011-04-27 22:41           ` Andi Kleen
2011-04-27 22:42             ` wwguy
2011-04-27 22:46               ` Andi Kleen
2011-04-28  2:42                 ` Tim Gardner
2011-04-26 21:14 ` [PATCH] [97/106] uvcvideo: Fix descriptor parsing for video output devices Andi Kleen
2011-04-26 21:14 ` [PATCH] [98/106] Revert "intel_idle: PCI quirk to prevent Lenovo Ideapad s10-3 boot hang" Andi Kleen
2011-04-26 21:14 ` [PATCH] [99/106] ALSA: hda - VIA: Add missing support for VT1718S in A-A path Andi Kleen
2011-04-26 21:14 ` [PATCH] [100/106] ALSA: hda - VIA: Fix stereo mixer recording no sound issue Andi Kleen
2011-04-26 21:14 ` [PATCH] [101/106] From: iwlwifi: fix skb usage after free Andi Kleen
2011-04-26 21:14 ` [PATCH] [102/106] From: intel-iommu: Fix use after release during device attach Andi Kleen
2011-04-26 21:14 ` [PATCH] [103/106] From: USB: Fix unplug of device with active streams Andi Kleen
2011-04-26 21:14 ` [PATCH] [104/106] From: USB: xhci - also free streams when resetting devices Andi Kleen
2011-04-26 21:14 ` [PATCH] [105/106] From: 2.6.35.y: Revert "SH: Add missing consts to sys_execve() declaration" Andi Kleen
2011-04-26 21:14 ` [PATCH] [106/106] Release 2.6.35.13 Andi Kleen
2011-04-27  0:08 ` [stable] [PATCH] [0/106] 2.6.35.13 longterm review Chuck Ebbert
2011-04-27  2:58   ` Andi Kleen
2011-04-27  0:17 ` Tim Bird
2011-04-27  0:21 ` [stable] " Chuck Ebbert
2011-04-27  3:08   ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110426211344.0E4083E1886@tassilo.jf.intel.com \
    --to=andi@firstfloor.org \
    --cc=ak@linux.intel.com \
    --cc=gregkh@suse.de \
    --cc=hans.rosenfeld@amd.com \
    --cc=hpa@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@kernel.org \
    --cc=tim.bird@am.sony.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®