Commit 164aa1ca authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Borislav Petkov (AMD)

x86/microcode/intel: Rework intel_cpu_collect_info()

Nothing needs struct ucode_cpu_info. Make it take struct cpu_signature,
let it return a boolean and simplify the implementation. Rename it now
that the silly name clash with collect_cpu_info() is gone.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20231017211722.851573238@linutronix.de
parent 3973718c
...@@ -71,9 +71,9 @@ static inline void init_ia32_feat_ctl(struct cpuinfo_x86 *c) {} ...@@ -71,9 +71,9 @@ static inline void init_ia32_feat_ctl(struct cpuinfo_x86 *c) {}
extern __noendbr void cet_disable(void); extern __noendbr void cet_disable(void);
struct ucode_cpu_info; struct cpu_signature;
int intel_cpu_collect_info(struct ucode_cpu_info *uci); void intel_collect_cpu_info(struct cpu_signature *sig);
static inline bool intel_cpu_signatures_match(unsigned int s1, unsigned int p1, static inline bool intel_cpu_signatures_match(unsigned int s1, unsigned int p1,
unsigned int s2, unsigned int p2) unsigned int s2, unsigned int p2)
......
...@@ -68,36 +68,21 @@ static inline unsigned int exttable_size(struct extended_sigtable *et) ...@@ -68,36 +68,21 @@ static inline unsigned int exttable_size(struct extended_sigtable *et)
return et->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE; return et->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE;
} }
int intel_cpu_collect_info(struct ucode_cpu_info *uci) void intel_collect_cpu_info(struct cpu_signature *sig)
{ {
unsigned int val[2]; sig->sig = cpuid_eax(1);
unsigned int family, model; sig->pf = 0;
struct cpu_signature csig = { 0 }; sig->rev = intel_get_microcode_revision();
unsigned int eax, ebx, ecx, edx;
memset(uci, 0, sizeof(*uci));
eax = 0x00000001;
ecx = 0;
native_cpuid(&eax, &ebx, &ecx, &edx);
csig.sig = eax;
family = x86_family(eax); if (x86_model(sig->sig) >= 5 || x86_family(sig->sig) > 6) {
model = x86_model(eax); unsigned int val[2];
if (model >= 5 || family > 6) {
/* get processor flags from MSR 0x17 */ /* get processor flags from MSR 0x17 */
native_rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]); native_rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]);
csig.pf = 1 << ((val[1] >> 18) & 7); sig->pf = 1 << ((val[1] >> 18) & 7);
} }
csig.rev = intel_get_microcode_revision();
uci->cpu_sig = csig;
return 0;
} }
EXPORT_SYMBOL_GPL(intel_cpu_collect_info); EXPORT_SYMBOL_GPL(intel_collect_cpu_info);
/* /*
* Returns 1 if update has been found, 0 otherwise. * Returns 1 if update has been found, 0 otherwise.
...@@ -391,7 +376,7 @@ static __init struct microcode_intel *get_microcode_blob(struct ucode_cpu_info * ...@@ -391,7 +376,7 @@ static __init struct microcode_intel *get_microcode_blob(struct ucode_cpu_info *
if (!(cp.data && cp.size)) if (!(cp.data && cp.size))
return NULL; return NULL;
intel_cpu_collect_info(uci); intel_collect_cpu_info(&uci->cpu_sig);
return scan_microcode(cp.data, cp.size, uci, save); return scan_microcode(cp.data, cp.size, uci, save);
} }
......
...@@ -227,7 +227,7 @@ static int scan_chunks_sanity_check(struct device *dev) ...@@ -227,7 +227,7 @@ static int scan_chunks_sanity_check(struct device *dev)
static int image_sanity_check(struct device *dev, const struct microcode_header_intel *data) static int image_sanity_check(struct device *dev, const struct microcode_header_intel *data)
{ {
struct ucode_cpu_info uci; struct cpu_signature sig;
/* Provide a specific error message when loading an older/unsupported image */ /* Provide a specific error message when loading an older/unsupported image */
if (data->hdrver != MC_HEADER_TYPE_IFS) { if (data->hdrver != MC_HEADER_TYPE_IFS) {
...@@ -240,11 +240,9 @@ static int image_sanity_check(struct device *dev, const struct microcode_header_ ...@@ -240,11 +240,9 @@ static int image_sanity_check(struct device *dev, const struct microcode_header_
return -EINVAL; return -EINVAL;
} }
intel_cpu_collect_info(&uci); intel_collect_cpu_info(&sig);
if (!intel_find_matching_signature((void *)data, if (!intel_find_matching_signature((void *)data, sig.sig, sig.pf)) {
uci.cpu_sig.sig,
uci.cpu_sig.pf)) {
dev_err(dev, "cpu signature, processor flags not matching\n"); dev_err(dev, "cpu signature, processor flags not matching\n");
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment