iPXE
|
Microcode updates. More...
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include <ipxe/uaccess.h>
#include <ipxe/umalloc.h>
#include <ipxe/image.h>
#include <ipxe/cpuid.h>
#include <ipxe/msr.h>
#include <ipxe/mp.h>
#include <ipxe/timer.h>
#include <ipxe/ucode.h>
Go to the source code of this file.
Data Structures | |
union | ucode_vendor_id |
A CPU vendor string. More... | |
struct | ucode_vendor |
A CPU vendor. More... | |
struct | ucode_update |
A microcode update. More... | |
struct | ucode_summary |
A microcode update summary. More... | |
Macros | |
#define | UCODE_MAX_HT 8 |
Maximum number of hyperthread siblings. More... | |
#define | UCODE_WAIT_MS 10 |
Time to wait for a microcode update to complete. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static const char * | ucode_vendor_name (const union ucode_vendor_id *vendor) |
Get CPU vendor name (for debugging) More... | |
static int | ucode_status (struct ucode_update *update, struct ucode_control *control, struct ucode_summary *summary, unsigned int id, int optional) |
Check status report. More... | |
static int | ucode_update_all (struct image *image, struct ucode_update *update, struct ucode_summary *summary) |
Update microcode on all CPUs. More... | |
static void | ucode_describe (struct image *image, size_t start, const struct ucode_vendor *vendor, const struct ucode_descriptor *desc, uint32_t platforms, struct ucode_update *update) |
Add descriptor to list (if applicable) More... | |
static int | ucode_verify (struct image *image, size_t start, size_t len) |
Verify checksum. More... | |
static int | ucode_parse_intel (struct image *image, size_t start, struct ucode_update *update) |
Parse Intel microcode image. More... | |
static int | ucode_parse_amd (struct image *image, size_t start, struct ucode_update *update) |
Parse AMD microcode image. More... | |
static int | ucode_parse (struct image *image, struct ucode_update *update) |
Parse microcode image. More... | |
static int | ucode_exec (struct image *image) |
Execute microcode update. More... | |
static int | ucode_probe (struct image *image) |
Probe microcode update image. More... | |
struct image_type ucode_image_type | __image_type (PROBE_NORMAL) |
Microcode update image type. More... | |
Variables | |
static struct ucode_vendor | ucode_intel |
Intel CPU vendor. More... | |
static struct ucode_vendor | ucode_amd |
AMD CPU vendor. More... | |
static struct ucode_vendor * | ucode_vendors [] |
List of known CPU vendors. More... | |
Microcode updates.
Definition in file ucode.c.
#define UCODE_MAX_HT 8 |
Maximum number of hyperthread siblings.
Microcode updates must not be performed on hyperthread siblings at the same time, since they share microcode storage.
Hyperthread siblings are always the lowest level of the CPU topology and correspond to the least significant bits of the APIC ID. We may therefore avoid collisions by performing the microcode updates in batches, with each batch targeting just one value for the least significant N bits of the APIC ID.
We assume that no CPUs exist with more than this number of hyperthread siblings. (This must be a power of two.)
#define UCODE_WAIT_MS 10 |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Get CPU vendor name (for debugging)
vendor | CPU vendor |
name | Name |
Definition at line 135 of file ucode.c.
References memcpy(), u, and vendor.
Referenced by ucode_describe(), and ucode_exec().
|
static |
Check status report.
update | Microcode update |
control | Microcode update control |
summary | Microcode update summary |
id | APIC ID |
optional | Status report is optional |
rc | Return status code |
Definition at line 157 of file ucode.c.
References apic_max, assert(), control, copy_from_user(), ucode_summary::count, DBGC, DBGC2, desc, ucode_update::desc, EINVAL, EIO, ENOENT, ENOTTY, ERANGE, ucode_summary::high, ucode_summary::low, phys_to_user(), and status.
|
static |
Update microcode on all CPUs.
image | Microcode image |
update | Microcode update |
summary | Microcode update summary to fill in |
rc | Return status code |
Definition at line 233 of file ucode.c.
References assert(), build_assert, control, ucode_update::count, ucode_summary::count, DBGC, ucode_update::desc, ENOMEM, ucode_summary::high, len, ucode_summary::low, max, mdelay(), memset(), memset_user(), mp_boot_cpuid(), mp_exec_boot(), mp_max_cpuid(), mp_start_all(), image::name, rc, status, strerror(), UCODE_MAX_HT, UCODE_VERSION_MAX, UCODE_VERSION_MIN, UCODE_WAIT_MS, ufree(), umalloc(), user_to_phys(), ucode_update::vendor, vendor, and virt_to_phys().
Referenced by ucode_exec().
|
static |
Add descriptor to list (if applicable)
image | Microcode image |
start | Starting offset within image |
vendor | CPU vendor |
desc | Microcode descriptor |
platforms | Supported platforms, or 0 for all platforms |
update | Microcode update |
Definition at line 323 of file ucode.c.
References ucode_update::count, DBGC, DBGC2, desc, ucode_update::desc, memcpy(), image::name, ucode_update::platform, platforms, ucode_update::signature, start, UCODE_SIGNATURE_MASK, ucode_vendor_name(), ucode_update::vendor, and vendor.
Referenced by ucode_parse_amd(), and ucode_parse_intel().
Verify checksum.
image | Microcode image |
start | Starting offset |
len | Length |
rc | Return status code |
Definition at line 361 of file ucode.c.
References checksum, copy_from_user(), image::data, DBGC, EINVAL, len, image::name, offset, and start.
Referenced by ucode_parse_intel().
|
static |
Parse Intel microcode image.
image | Microcode image |
start | Starting offset within image |
update | Microcode update |
len | Length consumed, or negative error |
Definition at line 397 of file ucode.c.
References copy_from_user(), intel_ucode_ext_header::count, image::data, data_len, DBGC, DBGC2, desc, EINVAL, ENOEXEC, ext, hdr, INTEL_UCODE_ALIGN, INTEL_UCODE_DATA_LEN, INTEL_UCODE_HVER, INTEL_UCODE_LVER, len, image::len, image::name, offset, rc, start, ucode_describe(), ucode_intel, ucode_verify(), and user_to_phys().
Referenced by ucode_parse().
|
static |
Parse AMD microcode image.
image | Microcode image |
start | Starting offset within image |
update | Microcode update |
len | Length consumed, or negative error |
Definition at line 503 of file ucode.c.
References AMD_UCODE_EQUIV_TYPE, AMD_UCODE_MAGIC, AMD_UCODE_PATCH_TYPE, copy_from_user(), count, image::data, DBGC, DBGC2, desc, EINVAL, ENOEXEC, ENOTSUP, hdr, amd_ucode_equivalence::id, amd_ucode_patch::id, image::len, amd_ucode_patch_header::len, image::name, offset, amd_ucode_equivalence::signature, start, amd_ucode_patch_header::type, ucode_amd, ucode_describe(), user_to_phys(), and amd_ucode_patch::version.
Referenced by ucode_parse().
|
static |
Parse microcode image.
image | Microcode image |
update | Microcode update |
rc | Return status code |
Definition at line 620 of file ucode.c.
References DBGC, ENOEXEC, len, image::len, image::name, start, ucode_parse_amd(), and ucode_parse_intel().
Referenced by ucode_exec().
|
static |
Execute microcode update.
image | Microcode image |
rc | Return status code |
Definition at line 652 of file ucode.c.
References assert(), image::cmdline, ucode_update::count, ucode_summary::count, CPUID_FEATURES, CPUID_VENDOR_ID, DBGC, ucode_update::desc, discard_c, ENOMEM, free, ucode_summary::high, id, len, ucode_summary::low, memcmp(), memset(), MSR_PLATFORM_ID, MSR_PLATFORM_ID_VALUE, image::name, ucode_update::platform, platform_id, printf(), rc, ucode_update::signature, strstr(), ucode_intel, ucode_parse(), ucode_update_all(), ucode_vendor_name(), ucode_vendors, ucode_update::vendor, vendor, and zalloc().
|
static |
Probe microcode update image.
image | Microcode image |
rc | Return status code |
Definition at line 746 of file ucode.c.
References AMD_UCODE_EQUIV_TYPE, AMD_UCODE_MAGIC, copy_from_user(), image::data, DBGC, ENOEXEC, header, INTEL_UCODE_HVER, INTEL_UCODE_LVER, image::len, and image::name.
struct image_type ucode_image_type __image_type | ( | PROBE_NORMAL | ) |
Microcode update image type.
|
static |
Intel CPU vendor.
Definition at line 110 of file ucode.c.
Referenced by ucode_exec(), and ucode_parse_intel().
|
static |
AMD CPU vendor.
Definition at line 118 of file ucode.c.
Referenced by ucode_parse_amd().
|
static |
List of known CPU vendors.
Definition at line 124 of file ucode.c.
Referenced by ucode_exec().