aboutsummaryrefslogtreecommitdiff
path: root/arch/x86/kernel/microcode_amd.c
AgeCommit message (Collapse)AuthorFilesLines
2012-04-13x86, microcode: Ensure that module is only loaded on supported AMD CPUsAndreas Herrmann1-5/+7
Exit early when there's no support for a particular CPU family. Also, fixup the "no support for this CPU vendor" to be issued only when the driver is attempted to be loaded on an unsupported vendor. Cc: [email protected] Cc: Tigran Aivazian <[email protected]> Signed-off-by: Andreas Herrmann <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Link: http://lkml.kernel.org/r/[email protected] [Boris: add a commit msg because Andreas is lazy] Signed-off-by: Borislav Petkov <[email protected]>
2012-02-07x86/microcode: Remove noisy AMD microcode warningPrarit Bhargava1-1/+0
AMD processors will never support /dev/cpu/microcode updating so just silently fail instead of printing out a warning for every cpu. Signed-off-by: Prarit Bhargava <[email protected]> Cc: Borislav Petkov <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
2012-01-26x86/microcode_amd: Add support for CPU family specific container filesAndreas Herrmann1-2/+22
We've decided to provide CPU family specific container files (starting with CPU family 15h). E.g. for family 15h we have to load microcode_amd_fam15h.bin instead of microcode_amd.bin Rationale is that starting with family 15h patch size is larger than 2KB which was hard coded as maximum patch size in various microcode loaders (not just Linux). Container files which include patches larger than 2KB cause different kinds of trouble with such old patch loaders. Thus we have to ensure that the default container file provides only patches with size less than 2KB. Signed-off-by: Andreas Herrmann <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: <[email protected]> Link: http://lkml.kernel.org/r/[email protected] [ documented the naming convention and tidied the code a bit. ] Signed-off-by: Ingo Molnar <[email protected]>
2011-12-14x86, microcode, AMD: Update copyrightsBorislav Petkov1-3/+7
Add Andreas and me as current maintainers. Signed-off-by: Borislav Petkov <[email protected]>
2011-12-14x86, microcode, AMD: Exit early on successBorislav Petkov1-13/+9
Once we've found and validated the ucode patch for the current CPU, there's no need to iterate over the remaining patches in the binary image. Exit then and save us a bunch of cycles. Signed-off-by: Borislav Petkov <[email protected]>
2011-12-14x86, microcode, AMD: Simplify ucode verificationBorislav Petkov1-86/+93
Basically, what we did until now is take out a chunk of the firmware image, vmalloc space for it and inspect it before application. And repeat. This patch changes all that so that we look at each ucode patch from the firmware image, check it for sanity and copy it to local buffer for application only once and if it passes all checks. Thus, vmalloc-ing for each piece is gone, we can do proper size checking only of the patch which is destined for the CPU of the current machine instead of each single patch, which is clearly wrong. Oh yeah, simplify and cleanup the code while at it, along with adding comments as to what actually happens. Signed-off-by: Borislav Petkov <[email protected]>
2011-12-14x86, microcode, AMD: Add a reusable bufferBorislav Petkov1-0/+8
Add a simple 4K page which gets allocated on driver init and freed on driver exit instead of vmalloc'ing small buffers for each ucode patch. Signed-off-by: Borislav Petkov <[email protected]>
2011-12-14x86, microcode, AMD: Add a vendor-specific exit functionBorislav Petkov1-0/+4
This will be used to do cleanup work before the driver exits. Signed-off-by: Borislav Petkov <[email protected]>
2011-10-19x86, microcode, AMD: Add microcode revision to /proc/cpuinfoBorislav Petkov1-2/+3
Enable microcode revision output for AMD after 506ed6b53e00 ("x86, intel: Output microcode revision in /proc/cpuinfo") did it for Intel. Signed-off-by: Borislav Petkov <[email protected]>
2011-06-16x86, microcode, AMD: Fix section header size checkBorislav Petkov1-7/+8
The ucode size check has to take the section header size into account too when sanity checking the section length. Shorten and clarify define names, while at it. Caught-by: Ben Hutchings <[email protected]> Link: http://lkml.kernel.org/r/1302752223.5282.674.camel@localhost Signed-off-by: Borislav Petkov <[email protected]>
2011-06-15x86, microcode, AMD: Correct buf referencesBorislav Petkov1-3/+3
Both the equivalence table and the microcode patch types are u32. Access them properly through the buf-ptr. Signed-off-by: Borislav Petkov <[email protected]>
2011-02-20x86, microcode, AMD: Fix signedness bug in generic_load_microcode()Dan Carpenter1-1/+1
install_equiv_cpu_table() returns type int. It uses negative error codes so using an unsigned type breaks the error handling. Signed-off-by: Dan Carpenter <[email protected]> Acked-by: Borislav Petkov <[email protected]> Cc: open list:AMD MICROCODE UPD... <[email protected]> Cc: Andreas Herrmann <[email protected]> LKML-Reference: <20110218091716.GA4384@bicker> Signed-off-by: Ingo Molnar <[email protected]>
2011-02-10x86, microcode, AMD: Extend ucode size verificationBorislav Petkov1-16/+44
The different families have a different max size for the ucode patch, adjust size checking to the family we're running on. Also, do not vzalloc the max size of the ucode but only the actual size that is passed on from the firmware loader. Signed-off-by: Borislav Petkov <[email protected]>
2011-02-09x86, microcode, AMD: Cleanup dmesg outputBorislav Petkov1-14/+16
Unify pr_* to use pr_fmt, shorten messages, correct type formatting. Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Andreas Herrmann <[email protected]>
2011-02-09x86, microcode, AMD: Remove unneeded memset callBorislav Petkov1-1/+0
collect_cpu_info_amd() clears its csig arg but this is done in the microcode_core's collect_cpu_info() by clearing the embedding struct ucode_cpu_info. Drop it. Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Andreas Herrmann <[email protected]>
2011-02-09x86, microcode, AMD: Simplify get_next_ucodeBorislav Petkov1-36/+32
Do not copy the section header but look at it directly through the pointer. Also, make it return a ptr to a ucode header directly thus dropping a bunch of unneeded casts. Finally, simplify generic_load_microcode(), while at it. Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Andreas Herrmann <[email protected]>
2011-02-09x86, microcode, AMD: Simplify install_equiv_cpu_tableBorislav Petkov1-13/+8
There's no need to memcpy the ucode header in order to look at it only in this function - use the original buffer instead. Also, fix return type semantics by returning a negative value on error and a positive otherwise. Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Andreas Herrmann <[email protected]>
2011-02-09x86, microcode, AMD: Release firmware on errorBorislav Petkov1-12/+14
When the ucode magic is wrong, for whatever reason, we don't release the loaded firmware binary and its related resources. Make sure we do. Also, fix function naming to fit this driver's convention and shorten variable names. Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Andreas Herrmann <[email protected]>
2011-01-06Merge branch 'x86-microcode-for-linus' of ↵Linus Torvalds1-24/+10
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip * 'x86-microcode-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: x86, microcode, AMD: Cleanup code a bit x86, microcode, AMD: Replace vmalloc+memset with vzalloc
2010-11-10x86, microcode, AMD: Cleanup code a bitBorislav Petkov1-20/+5
get_ucode_data is a memcpy() wrapper which always returns 0. Move it into the header and make it an inline. Remove all code checking its return value and turn it into a void. There should be no functionality change resulting from this patch. Signed-off-by: Borislav Petkov <[email protected]>
2010-11-10x86, microcode, AMD: Replace vmalloc+memset with vzallocJesper Juhl1-9/+10
We don't have to do memset() ourselves after vmalloc() when we have vzalloc(), so change that in arch/x86/kernel/microcode_amd.c::get_next_ucode(). Signed-off-by: Jesper Juhl <[email protected]> Signed-off-by: Borislav Petkov <[email protected]>
2010-11-10x86: Remove unnecessary casts of void ptr returning alloc function return valuesJesper Juhl1-1/+1
The [vk][cmz]alloc(_node) family of functions return void pointers which it's completely unnecessary/pointless to cast to other pointer types since that happens implicitly. This patch removes such casts from arch/x86. Signed-off-by: Jesper Juhl <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Andreas Herrmann <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2010-01-23Revert "x86: ucode-amd: Load ucode-patches once ..."Andreas Herrmann1-31/+13
Commit d1c84f79a6ba992dc01e312c44a21496303874d6 leads to a regression when microcode_amd.c is compiled into the kernel. It causes a big boot delay because the firmware is not available. See http://marc.info/?l=linux-kernel&m=126267290920060 It also renders the reload sysfs attribute useless. Fixing this is too intrusive for an -rc5 kernel. Thus I'd like to restore the microcode loading behaviour of kernel 2.6.32. CC: Gene Heskett <[email protected]> Signed-off-by: Andreas Herrmann <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
2009-12-09arch/x86/kernel/microcode*: Use pr_fmt() and remove duplicated KERN_ERR prefixJoe Perches1-21/+19
- Use #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - Remove "microcode: " prefix from each pr_<level> - Fix duplicated KERN_ERR prefix - Coalesce pr_<level> format strings - Add a space after an exclamation point No other change in output. Signed-off-by: Joe Perches <[email protected]> Cc: Andy Whitcroft <[email protected]> Cc: Andreas Herrmann <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2009-11-17x86: ucode-amd: Move family check to microcde_amd.c's init functionAndreas Herrmann1-6/+15
... to avoid useless trial to load firmware on systems with unsupported AMD CPUs. Signed-off-by: Andreas Herrmann <[email protected]> Cc: Dmitry Adamushko <[email protected]> Cc: Mike Travis <[email protected]> Cc: Tigran Aivazian <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Andreas Mohr <[email protected]> Cc: Jack Steiner <[email protected]> LKML-Reference: <[email protected]> [ v2: changed BUG_ON() to WARN_ON() ] Signed-off-by: Ingo Molnar <[email protected]>
2009-11-10x86: ucode-amd: Convert printk(KERN_*...) to pr_*(...)Andreas Herrmann1-19/+15
Signed-off-by: Andreas Herrmann <[email protected]> Cc: dimm <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2009-11-10x86: ucode-amd: Don't warn when no ucode is available for a CPU revisionAndreas Herrmann1-4/+1
There is no point in warning when there is no ucode available for a specific CPU revision. Currently the container-file, which provides the AMD ucode patches for OS load, contains only a few ucode patches. It's already clearly indicated by the printed patch_level whenever new ucode was available and an update happened. So the warning message is of no help but rather annoying on systems with many CPUs. Signed-off-by: Andreas Herrmann <[email protected]> Cc: dimm <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2009-11-10x86: ucode-amd: Load ucode-patches once and not separately of each CPUAndreas Herrmann1-7/+17
This also implies that corresponding log messages, e.g. platform microcode: firmware: requesting amd-ucode/microcode_amd.bin show up only once on module load and not when ucode is updated for each CPU. Signed-off-by: Andreas Herrmann <[email protected]> Cc: dimm <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2009-11-10x86, amd-ucode: Remove needless log messagesAndreas Herrmann1-8/+1
Signed-off-by: Andreas Herrmann <[email protected]> Cc: Borislav Petkov <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2009-11-10x86, amd-ucode: Check UCODE_MAGIC before loading the container fileBorislav Petkov1-0/+6
Signed-off-by: Borislav Petkov <[email protected]> Signed-off-by: Andreas Herrmann <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2009-06-07x86, microcode: Simplify vfree() useFigo.zhang1-8/+4
vfree() does its own 'NULL' check, so no need for check before calling it. In v2, remove the stray newline. [ Impact: cleanup ] Signed-off-by: Figo.zhang <[email protected]> Cc: Dmitry Adamushko <[email protected]> LKML-Reference: <1244385036.3402.11.camel@myhost> Signed-off-by: Ingo Molnar <[email protected]>
2009-05-12x86: microcode: use smp_call_function_single instead of set_cpus_allowed, ↵Dmitry Adamushko1-36/+22
cleanup of synchronization logic * Solve issues described in 6f66cbc63081fd70e3191b4dbb796746780e5ae1 in a way that doesn't resort to set_cpus_allowed(); * in fact, only collect_cpu_info and apply_microcode callbacks must run on a target cpu, others will do just fine on any other. smp_call_function_single() (as suggested by Ingo) is used to run these callbacks on a target cpu. * cleanup of synchronization logic of the 'microcode_core' part The generic 'microcode_core' part guarantees that only a single cpu (be it a full-fledged cpu, one of the cores or HT) is being updated at any particular moment of time. In general, there is no need for any additional sync. mechanism in arch-specific parts (the patch removes existing spinlocks). See also the "Synchronization" section in microcode_core.c. * return -EINVAL instead of -1 (which is translated into -EPERM) in microcode_write(), reload_cpu() and mc_sysdev_add(). Other suggestions for an error code? * use 'enum ucode_state' as return value of request_microcode_{fw, user} to gain more flexibility by distinguishing between real error cases and situations when an appropriate ucode was not found (which is not an error per-se). * some minor cleanups Thanks a lot to Hugh Dickins for review/suggestions/testing! Reference: http://marc.info/?l=linux-kernel&m=124025889012541&w=2 [ Impact: refactor and clean up microcode driver locking code ] Signed-off-by: Dmitry Adamushko <[email protected]> Acked-by: Hugh Dickins <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Rusty Russell <[email protected]> Cc: Andreas Herrmann <[email protected]> Cc: Peter Oruba <[email protected]> Cc: Arjan van de Ven <[email protected]> LKML-Reference: <1242078507.5560.9.camel@earth> [ did some more cleanups ] Signed-off-by: Ingo Molnar <[email protected]> arch/x86/include/asm/microcode.h | 25 ++ arch/x86/kernel/microcode_amd.c | 58 ++---- arch/x86/kernel/microcode_core.c | 326 +++++++++++++++++++++----------------- arch/x86/kernel/microcode_intel.c | 92 +++------- 4 files changed, 261 insertions(+), 240 deletions(-) (~20 new comment lines)
2009-03-18x86: microcode: cleanupIngo Molnar1-23/+20
Impact: cleanup Cc: Rusty Russell <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Dmitry Adamushko <[email protected]> Cc: Peter Oruba <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-12-19x86: fix warning in arch/x86/kernel/microcode_amd.cIngo Molnar1-1/+2
this warning: arch/x86/kernel/microcode_amd.c: In function ‘apply_microcode_amd’: arch/x86/kernel/microcode_amd.c:163: warning: cast from pointer to integer of different size arch/x86/kernel/microcode_amd.c:163: warning: cast from pointer to integer of different size triggers because we want to pass the address to the microcode MSR, which is 64-bit even on 32-bit. Cast it explicitly to express this. Signed-off-by: Ingo Molnar <[email protected]>
2008-12-16x86: microcode_amd: modify log messagesAndreas Herrmann1-32/+26
Impact: change microcode printk content Change log level and provide (at least I tried to;-) consistent, short, meaningful content. Signed-off-by: Andreas Herrmann <[email protected]> Cc: Dmitry Adamushko <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-12-16x86: microcode_amd: use 'packed' attribute for structsAndreas Herrmann1-22/+23
Impact: cleanup Signed-off-by: Andreas Herrmann <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-12-16x86: microcode_amd: remove (wrong) chipset deivce ID checksAndreas Herrmann1-27/+5
Impact: remove dead/incorrect code Currently there is no chipset specific ucode. The checks are incorrect anyway (e.g. pci device IDs are 16 bit and not 8 bit). Thus I remove the stuff for the time being and will reintroduce it if it's foreseeable that it is really needed. Signed-off-by: Andreas Herrmann <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-12-16x86: microcode_amd: consolidate macro definitionsAndreas Herrmann1-13/+3
Impact: cleanup Signed-off-by: Andreas Herrmann <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-12-16x86: microcode_amd: replace inline asm by common rdmsr/wrmsr functionsAndreas Herrmann1-18/+5
Impact: cleanup Signed-off-by: Andreas Herrmann <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-12-16x86: microcode_amd: don't pass superfluous function pointer for get_ucode_dataAndreas Herrmann1-17/+12
Impact: cleanup Signed-off-by: Andreas Herrmann <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-12-16x86: microcode_amd: fix compile warningAndreas Herrmann1-9/+11
Impact: fix build warning CC arch/x86/kernel/microcode_amd.o arch/x86/kernel/microcode_amd.c: In function ‘request_microcode_fw’: arch/x86/kernel/microcode_amd.c:393: warning: passing argument 2 of ‘generic_load_microcode’ discards qualifiers from pointer target type (Respect "const" qualifier of firmware->data.) Signed-off-by: Andreas Herrmann <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-12-16x86: microcode_amd: fix checkpatch warnings/errorsAndreas Herrmann1-11/+14
Impact: cleanup Signed-off-by: Andreas Herrmann <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-12-16x86: microcode_amd: fix typos and trailing whitespaces in log messagesAndreas Herrmann1-6/+6
Impact: fix printk typos Signed-off-by: Andreas Herrmann <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-12-16x86: microcode_amd: fix wrong handling of equivalent CPU idAndreas Herrmann1-17/+6
Impact: fix bug resulting in non-loaded AMD microcode mc_header->processor_rev_id is a 2 byte value. Similar is true for equiv_cpu in an equiv_cpu_entry -- only 2 bytes are of interest. Signed-off-by: Andreas Herrmann <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-10-28x86: AMD microcode patch loader author updatePeter Oruba1-1/+1
Removed author's email address from MODULE_AUTHOR. Signed-off-by: Peter Oruba <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-09-24x86, microcode_amd: cleanup, mark request_microcode_user() as unsupportedDmitry Adamushko1-32/+4
(1) mark mc_size in generic_load_microcode() as unitialized_var to avoid gcc's (false) warning; (2) mark request_microcode_user() as unsupported. The required changes can be added later. Note, we don't break any user-space interfaces here, as there were no kernels with support for AMD-specific ucode update yet. The ucode has to be updated via 'firmware'. Signed-off-by: Dmitry Adamushko <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-09-23x86, microcode rework, v2, renaming cont.Peter Oruba1-9/+8
Renaming based on patch from Dmitry Adamushko. Further clarification by renaming define and variable related to microcode container file. Signed-off-by: Peter Oruba <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-09-23x86, microcode rework, v2, renamingPeter Oruba1-7/+7
Renaming based on patch from Dmitry Adamushko. Made code more readable by renaming define and variables related to microcode _container_file_ header to make it distinguishable from microcode _patch_ header. Signed-off-by: Peter Oruba <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-09-23x86: moved microcode.c to microcode_intel.cDmitry Adamushko1-29/+43
Combine both generic and arch-specific parts of microcode into a single module (arch-specific parts are config-dependent). Also while we are at it, move arch-specific parts from microcode.h into their respective arch-specific .c files. Signed-off-by: Dmitry Adamushko <[email protected]> Cc: "Peter Oruba" <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2008-09-14x86, microcode rework, v2, fixIngo Molnar1-2/+4
based on patch from Dmitry Adamushko. - add missing vfree() - update debug printks Signed-off-by: Ingo Molnar <[email protected]>