From: Jithu Joseph <jithu.joseph@intel.com>
To: hdegoede@redhat.com, markgross@kernel.org
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
gregkh@linuxfoundation.org, jithu.joseph@intel.com,
ashok.raj@intel.com, tony.luck@intel.com,
linux-kernel@vger.kernel.org,
platform-driver-x86@vger.kernel.org, patches@lists.linux.dev,
ravi.v.shankar@intel.com, thiago.macieira@intel.com,
athenas.jimenez.gonzalez@intel.com, sohil.mehta@intel.com
Subject: [PATCH v2 04/14] x86/microcode/intel: Expose find_matching_signature() for IFS
Date: Mon, 7 Nov 2022 14:53:13 -0800 [thread overview]
Message-ID: <20221107225323.2733518-5-jithu.joseph@intel.com> (raw)
In-Reply-To: <20221107225323.2733518-1-jithu.joseph@intel.com>
IFS uses 'scan test images' provided by Intel that can be regarded as
firmware. IFS test image carries microcode header with extended signature
table.
Expose find_matching_signature() for verifying if the test image
header or the extended signature table indicate whether an IFS test image
is fit to run on a system. Move the function to cpu/intel.c and
add intel_ prefix to the function name.
No functional change
Reviewed-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Ashok Raj <ashok.raj@intel.com>
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
---
arch/x86/include/asm/cpu.h | 1 +
arch/x86/kernel/cpu/intel.c | 29 ++++++++++++++++++
arch/x86/kernel/cpu/microcode/intel.c | 44 +++++----------------------
3 files changed, 38 insertions(+), 36 deletions(-)
diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h
index b472ef76826a..e853440b5c65 100644
--- a/arch/x86/include/asm/cpu.h
+++ b/arch/x86/include/asm/cpu.h
@@ -95,5 +95,6 @@ static inline bool intel_cpu_signatures_match(unsigned int s1, unsigned int p1,
}
extern u64 x86_read_arch_cap_msr(void);
+int intel_find_matching_signature(void *mc, unsigned int csig, int cpf);
#endif /* _ASM_X86_CPU_H */
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 2d7ea5480ec3..b6f9210fb31a 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -216,6 +216,35 @@ int intel_cpu_collect_info(struct ucode_cpu_info *uci)
}
EXPORT_SYMBOL_GPL(intel_cpu_collect_info);
+/*
+ * Returns 1 if update has been found, 0 otherwise.
+ */
+int intel_find_matching_signature(void *mc, unsigned int csig, int cpf)
+{
+ struct microcode_header_intel *mc_hdr = mc;
+ struct extended_sigtable *ext_hdr;
+ struct extended_signature *ext_sig;
+ int i;
+
+ if (intel_cpu_signatures_match(csig, cpf, mc_hdr->sig, mc_hdr->pf))
+ return 1;
+
+ /* Look for ext. headers: */
+ if (get_totalsize(mc_hdr) <= get_datasize(mc_hdr) + MC_HEADER_SIZE)
+ return 0;
+
+ ext_hdr = mc + get_datasize(mc_hdr) + MC_HEADER_SIZE;
+ ext_sig = (void *)ext_hdr + EXT_HEADER_SIZE;
+
+ for (i = 0; i < ext_hdr->count; i++) {
+ if (intel_cpu_signatures_match(csig, cpf, ext_sig->sig, ext_sig->pf))
+ return 1;
+ ext_sig++;
+ }
+ return 0;
+}
+EXPORT_SYMBOL_GPL(intel_find_matching_signature);
+
static void early_init_intel(struct cpuinfo_x86 *c)
{
u64 misc_enable;
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 1fcbd671f1df..4e611a708718 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -45,34 +45,6 @@ static struct microcode_intel *intel_ucode_patch;
/* last level cache size per core */
static int llc_size_per_core;
-/*
- * Returns 1 if update has been found, 0 otherwise.
- */
-static int find_matching_signature(void *mc, unsigned int csig, int cpf)
-{
- struct microcode_header_intel *mc_hdr = mc;
- struct extended_sigtable *ext_hdr;
- struct extended_signature *ext_sig;
- int i;
-
- if (intel_cpu_signatures_match(csig, cpf, mc_hdr->sig, mc_hdr->pf))
- return 1;
-
- /* Look for ext. headers: */
- if (get_totalsize(mc_hdr) <= get_datasize(mc_hdr) + MC_HEADER_SIZE)
- return 0;
-
- ext_hdr = mc + get_datasize(mc_hdr) + MC_HEADER_SIZE;
- ext_sig = (void *)ext_hdr + EXT_HEADER_SIZE;
-
- for (i = 0; i < ext_hdr->count; i++) {
- if (intel_cpu_signatures_match(csig, cpf, ext_sig->sig, ext_sig->pf))
- return 1;
- ext_sig++;
- }
- return 0;
-}
-
/*
* Returns 1 if update has been found, 0 otherwise.
*/
@@ -83,7 +55,7 @@ static int has_newer_microcode(void *mc, unsigned int csig, int cpf, int new_rev
if (mc_hdr->rev <= new_rev)
return 0;
- return find_matching_signature(mc, csig, cpf);
+ return intel_find_matching_signature(mc, csig, cpf);
}
static struct ucode_patch *memdup_patch(void *data, unsigned int size)
@@ -117,7 +89,7 @@ static void save_microcode_patch(struct ucode_cpu_info *uci, void *data, unsigne
sig = mc_saved_hdr->sig;
pf = mc_saved_hdr->pf;
- if (find_matching_signature(data, sig, pf)) {
+ if (intel_find_matching_signature(data, sig, pf)) {
prev_found = true;
if (mc_hdr->rev <= mc_saved_hdr->rev)
@@ -149,7 +121,7 @@ static void save_microcode_patch(struct ucode_cpu_info *uci, void *data, unsigne
if (!p)
return;
- if (!find_matching_signature(p->data, uci->cpu_sig.sig, uci->cpu_sig.pf))
+ if (!intel_find_matching_signature(p->data, uci->cpu_sig.sig, uci->cpu_sig.pf))
return;
/*
@@ -286,8 +258,8 @@ scan_microcode(void *data, size_t size, struct ucode_cpu_info *uci, bool save)
size -= mc_size;
- if (!find_matching_signature(data, uci->cpu_sig.sig,
- uci->cpu_sig.pf)) {
+ if (!intel_find_matching_signature(data, uci->cpu_sig.sig,
+ uci->cpu_sig.pf)) {
data += mc_size;
continue;
}
@@ -652,9 +624,9 @@ static struct microcode_intel *find_patch(struct ucode_cpu_info *uci)
if (phdr->rev <= uci->cpu_sig.rev)
continue;
- if (!find_matching_signature(phdr,
- uci->cpu_sig.sig,
- uci->cpu_sig.pf))
+ if (!intel_find_matching_signature(phdr,
+ uci->cpu_sig.sig,
+ uci->cpu_sig.pf))
continue;
return iter->data;
--
2.25.1
next prev parent reply other threads:[~2022-11-07 22:55 UTC|newest]
Thread overview: 193+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-21 20:33 [PATCH 00/14] IFS multi test image support and misc changes Jithu Joseph
2022-10-21 20:34 ` [PATCH 01/14] platform/x86/intel/ifs: Remove unused selection Jithu Joseph
2022-10-21 20:34 ` [PATCH 02/14] platform/x86/intel/ifs: Propagate load failure error code Jithu Joseph
2022-10-24 22:52 ` Sohil Mehta
2022-10-24 23:17 ` Joseph, Jithu
2022-10-21 20:34 ` [PATCH 03/14] platform/x86/intel/ifs: return a more appropriate Error code Jithu Joseph
2022-10-24 22:57 ` Sohil Mehta
2022-10-24 23:01 ` Luck, Tony
2022-10-21 20:34 ` [PATCH 04/14] platform/x86/intel/ifs: Remove image loading during init Jithu Joseph
2022-10-24 23:50 ` Sohil Mehta
2022-10-25 0:41 ` Joseph, Jithu
2022-10-25 6:06 ` Sohil Mehta
2022-10-26 23:53 ` Joseph, Jithu
2022-11-01 7:00 ` Sohil Mehta
2022-10-21 20:34 ` [PATCH 05/14] x86/microcode/intel: Expose find_matching_signature() for IFS Jithu Joseph
2022-11-02 19:03 ` Borislav Petkov
2022-11-02 21:32 ` Joseph, Jithu
2022-10-21 20:34 ` [PATCH 06/14] x86/microcode/intel: Use appropriate type in microcode_sanity_check() Jithu Joseph
2022-10-21 20:34 ` [PATCH 07/14] x86/microcode/intel: Expose microcode_sanity_check() Jithu Joseph
2022-11-01 7:28 ` Sohil Mehta
2022-11-01 19:06 ` Joseph, Jithu
2022-11-03 11:33 ` Borislav Petkov
2022-11-03 19:25 ` Ashok Raj
2022-11-03 23:32 ` Borislav Petkov
2022-11-04 6:15 ` Joseph, Jithu
2022-11-04 10:50 ` Borislav Petkov
2022-11-04 22:02 ` Joseph, Jithu
2022-11-04 22:14 ` Borislav Petkov
2022-10-21 20:34 ` [PATCH 08/14] x86/microcode/intel: Meta-data support in microcode file Jithu Joseph
2022-11-01 8:51 ` Sohil Mehta
2022-11-01 18:05 ` Joseph, Jithu
2022-11-03 11:35 ` Borislav Petkov
2022-10-21 20:34 ` [PATCH 09/14] platform/x86/intel/ifs: Use generic microcode headers and functions Jithu Joseph
2022-11-01 18:37 ` Sohil Mehta
2022-11-01 21:07 ` Joseph, Jithu
2022-10-21 20:34 ` [PATCH 10/14] platform/x86/intel/ifs: Add metadata validation Jithu Joseph
2022-11-01 20:28 ` Sohil Mehta
2022-11-09 23:10 ` Sohil Mehta
2022-10-21 20:34 ` [PATCH 11/14] platform/x86/intel/ifs: Remove reload sysfs entry Jithu Joseph
2022-10-21 20:34 ` [PATCH 12/14] platform/x86/intel/ifs: Add current_batch " Jithu Joseph
2022-11-01 22:26 ` Sohil Mehta
2022-11-01 23:27 ` Joseph, Jithu
2022-11-03 8:03 ` Sohil Mehta
2022-10-21 20:34 ` [PATCH 13/14] Documentation/ABI: Update IFS ABI doc Jithu Joseph
2022-11-01 22:34 ` Sohil Mehta
2022-11-01 22:48 ` Joseph, Jithu
2022-11-01 22:59 ` Sohil Mehta
2022-11-02 22:10 ` Joseph, Jithu
2022-11-03 7:49 ` Sohil Mehta
2022-10-21 20:34 ` [PATCH 14/14] Revert "platform/x86/intel/ifs: Mark as BROKEN" Jithu Joseph
2022-11-03 8:21 ` [PATCH 00/14] IFS multi test image support and misc changes Sohil Mehta
2022-11-07 9:24 ` Hans de Goede
2022-11-07 23:01 ` Joseph, Jithu
2022-11-07 22:53 ` [PATCH v2 " Jithu Joseph
2022-11-07 22:53 ` [PATCH v2 01/14] platform/x86/intel/ifs: Remove unused selection Jithu Joseph
2022-11-09 1:52 ` Sohil Mehta
2022-11-10 21:03 ` Hans de Goede
2022-11-07 22:53 ` [PATCH v2 02/14] platform/x86/intel/ifs: return a more appropriate Error code Jithu Joseph
2022-11-09 1:57 ` Sohil Mehta
2022-11-10 21:04 ` Hans de Goede
2022-11-07 22:53 ` [PATCH v2 03/14] platform/x86/intel/ifs: Remove image loading during init Jithu Joseph
2022-11-09 1:59 ` Sohil Mehta
2022-11-10 21:06 ` Hans de Goede
2022-11-07 22:53 ` Jithu Joseph [this message]
2022-11-09 2:06 ` [PATCH v2 04/14] x86/microcode/intel: Expose find_matching_signature() for IFS Sohil Mehta
2022-11-11 13:44 ` Borislav Petkov
2022-11-07 22:53 ` [PATCH v2 05/14] x86/microcode/intel: Use appropriate type in microcode_sanity_check() Jithu Joseph
2022-11-09 2:47 ` Sohil Mehta
2022-11-11 13:46 ` Borislav Petkov
2022-11-07 22:53 ` [PATCH v2 06/14] x86/microcode/intel: Expose microcode_sanity_check() Jithu Joseph
2022-11-09 3:03 ` Sohil Mehta
2022-11-09 3:29 ` Joseph, Jithu
2022-11-11 14:33 ` Borislav Petkov
2022-11-11 21:39 ` Joseph, Jithu
2022-11-07 22:53 ` [PATCH v2 07/14] x86/microcode/intel: Use a reserved field for metasize Jithu Joseph
2022-11-09 3:06 ` Sohil Mehta
2022-11-11 14:37 ` Borislav Petkov
2022-11-07 22:53 ` [PATCH v2 08/14] platform/x86/intel/ifs: Add metadata support Jithu Joseph
2022-11-09 3:25 ` Sohil Mehta
2022-11-10 21:08 ` Hans de Goede
2022-11-11 16:16 ` Borislav Petkov
2022-11-07 22:53 ` [PATCH v2 09/14] platform/x86/intel/ifs: Use generic microcode headers and functions Jithu Joseph
2022-11-09 3:29 ` Sohil Mehta
2022-11-10 21:11 ` Hans de Goede
2022-11-11 16:23 ` Borislav Petkov
2022-11-11 20:41 ` Joseph, Jithu
2022-11-16 17:26 ` Tony Luck
2022-11-16 18:53 ` Borislav Petkov
2022-11-16 19:02 ` Luck, Tony
2022-11-07 22:53 ` [PATCH v2 10/14] platform/x86/intel/ifs: Add metadata validation Jithu Joseph
2022-11-09 23:15 ` Sohil Mehta
2022-11-10 1:22 ` Joseph, Jithu
2022-11-10 9:40 ` Sohil Mehta
2022-11-10 21:18 ` Hans de Goede
2022-11-11 18:39 ` Borislav Petkov
2022-11-11 18:48 ` Dave Hansen
2022-11-11 20:30 ` Joseph, Jithu
2022-11-11 21:29 ` Ashok Raj
2022-11-07 22:53 ` [PATCH v2 11/14] platform/x86/intel/ifs: Remove reload sysfs entry Jithu Joseph
2022-11-09 23:16 ` Sohil Mehta
2022-11-10 21:19 ` Hans de Goede
2022-11-07 22:53 ` [PATCH v2 12/14] platform/x86/intel/ifs: Add current_batch " Jithu Joseph
2022-11-09 23:46 ` Sohil Mehta
2022-11-10 21:22 ` Hans de Goede
2022-11-12 16:26 ` Borislav Petkov
2022-11-12 18:21 ` Thiago Macieira
2022-11-12 19:20 ` Borislav Petkov
2022-11-12 19:58 ` Ashok Raj
2022-11-13 2:06 ` Thiago Macieira
2022-11-12 18:33 ` Luck, Tony
2022-11-12 19:28 ` Borislav Petkov
2022-11-12 23:32 ` Luck, Tony
2022-11-13 2:35 ` Thiago Macieira
2022-11-13 7:37 ` gregkh
2022-11-13 11:48 ` Borislav Petkov
2022-11-13 15:15 ` Ashok Raj
2022-11-13 15:58 ` Borislav Petkov
2022-11-13 17:01 ` Ashok Raj
2022-11-13 18:41 ` Borislav Petkov
2022-11-13 21:40 ` Thiago Macieira
2022-11-13 22:59 ` Borislav Petkov
2022-11-14 18:13 ` Dave Hansen
2022-11-14 18:25 ` Luck, Tony
2022-11-14 19:03 ` Borislav Petkov
2022-11-14 19:07 ` Luck, Tony
2022-11-14 19:17 ` Borislav Petkov
2022-11-14 19:38 ` Luck, Tony
2022-11-14 19:51 ` Borislav Petkov
2022-11-13 16:41 ` Joseph, Jithu
2022-11-13 16:58 ` Borislav Petkov
2022-11-13 17:55 ` Joseph, Jithu
2022-11-13 18:27 ` Borislav Petkov
2022-11-13 21:33 ` Tony Luck
2022-11-13 22:55 ` Borislav Petkov
2022-11-13 21:21 ` Thiago Macieira
2022-11-13 22:40 ` Borislav Petkov
2022-11-13 21:51 ` Thiago Macieira
2022-11-13 23:05 ` Borislav Petkov
2022-11-14 8:28 ` Hans de Goede
2022-11-14 7:15 ` gregkh
2022-11-14 15:33 ` Tony Luck
2022-11-14 15:47 ` Borislav Petkov
2022-11-19 16:24 ` [tip: x86/microcode] " tip-bot2 for Jithu Joseph
2022-11-07 22:53 ` [PATCH v2 13/14] Documentation/ABI: Update IFS ABI doc Jithu Joseph
2022-11-09 23:55 ` Sohil Mehta
2022-11-10 1:16 ` Joseph, Jithu
2022-11-10 21:33 ` Hans de Goede
2022-11-07 22:53 ` [PATCH v2 14/14] Revert "platform/x86/intel/ifs: Mark as BROKEN" Jithu Joseph
2022-11-09 23:57 ` Sohil Mehta
2022-11-10 21:34 ` Hans de Goede
2022-11-10 9:59 ` [PATCH v2 00/14] IFS multi test image support and misc changes Borislav Petkov
2022-11-10 21:37 ` Hans de Goede
2022-11-10 21:58 ` Joseph, Jithu
2022-11-17 3:59 ` [PATCH v3 00/16] " Jithu Joseph
2022-11-17 3:59 ` [PATCH v3 01/16] platform/x86/intel/ifs: Remove unused selection Jithu Joseph
2022-11-19 16:24 ` [tip: x86/microcode] " tip-bot2 for Jithu Joseph
2022-11-17 3:59 ` [PATCH v3 02/16] platform/x86/intel/ifs: Return a more appropriate Error code Jithu Joseph
2022-11-19 16:24 ` [tip: x86/microcode] platform/x86/intel/ifs: Return a more appropriate error code tip-bot2 for Jithu Joseph
2022-11-17 3:59 ` [PATCH v3 03/16] platform/x86/intel/ifs: Remove image loading during init Jithu Joseph
2022-11-19 16:24 ` [tip: x86/microcode] " tip-bot2 for Jithu Joseph
2022-11-17 3:59 ` [PATCH v3 04/16] platform/x86/intel/ifs: Remove memory allocation from load path Jithu Joseph
2022-11-17 8:51 ` Hans de Goede
2022-11-17 17:29 ` Jithu Joseph
2022-11-17 18:01 ` Hans de Goede
2022-11-17 19:59 ` Jithu Joseph
2022-11-17 21:13 ` Hans de Goede
2022-11-17 22:44 ` Joseph, Jithu
2022-11-19 16:24 ` [tip: x86/microcode] " tip-bot2 for Jithu Joseph
2022-11-17 3:59 ` [PATCH v3 05/16] x86/microcode/intel: Reuse find_matching_signature() Jithu Joseph
2022-11-19 16:24 ` [tip: x86/microcode] " tip-bot2 for Jithu Joseph
2022-11-17 3:59 ` [PATCH v3 06/16] x86/microcode/intel: Use appropriate type in microcode_sanity_check() Jithu Joseph
2022-11-19 16:24 ` [tip: x86/microcode] " tip-bot2 for Jithu Joseph
2022-11-17 3:59 ` [PATCH v3 07/16] x86/microcode/intel: Reuse microcode_sanity_check() Jithu Joseph
2022-11-19 16:24 ` [tip: x86/microcode] " tip-bot2 for Jithu Joseph
2022-11-17 3:59 ` [PATCH v3 08/16] x86/microcode/intel: Add hdr_type to intel_microcode_sanity_check() Jithu Joseph
2022-11-19 16:24 ` [tip: x86/microcode] " tip-bot2 for Jithu Joseph
2022-11-17 3:59 ` [PATCH v3 09/16] x86/microcode/intel: Use a reserved field for metasize Jithu Joseph
2022-11-19 16:24 ` [tip: x86/microcode] " tip-bot2 for Jithu Joseph
2022-11-17 3:59 ` [PATCH v3 10/16] platform/x86/intel/ifs: Add metadata support Jithu Joseph
2022-11-19 16:24 ` [tip: x86/microcode] " tip-bot2 for Ashok Raj
2022-11-17 3:59 ` [PATCH v3 11/16] platform/x86/intel/ifs: Use generic microcode headers and functions Jithu Joseph
2022-11-17 22:50 ` Jithu Joseph
2022-11-19 16:24 ` [tip: x86/microcode] " tip-bot2 for Jithu Joseph
2022-11-17 3:59 ` [PATCH v3 12/16] platform/x86/intel/ifs: Add metadata validation Jithu Joseph
2022-11-17 23:04 ` Jithu Joseph
2022-11-19 16:24 ` [tip: x86/microcode] " tip-bot2 for Jithu Joseph
2022-11-17 3:59 ` [PATCH v3 13/16] platform/x86/intel/ifs: Remove reload sysfs entry Jithu Joseph
2022-11-19 16:24 ` [tip: x86/microcode] " tip-bot2 for Jithu Joseph
2022-11-17 3:59 ` [PATCH v3 14/16] platform/x86/intel/ifs: Add current_batch " Jithu Joseph
2022-11-17 3:59 ` [PATCH v3 15/16] Documentation/ABI: Update IFS ABI doc Jithu Joseph
2022-11-19 16:23 ` [tip: x86/microcode] " tip-bot2 for Jithu Joseph
2022-11-17 3:59 ` [PATCH v3 16/16] Revert "platform/x86/intel/ifs: Mark as BROKEN" Jithu Joseph
2022-11-19 16:23 ` [tip: x86/microcode] " tip-bot2 for Jithu Joseph
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=20221107225323.2733518-5-jithu.joseph@intel.com \
--to=jithu.joseph@intel.com \
--cc=ashok.raj@intel.com \
--cc=athenas.jimenez.gonzalez@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=mingo@redhat.com \
--cc=patches@lists.linux.dev \
--cc=platform-driver-x86@vger.kernel.org \
--cc=ravi.v.shankar@intel.com \
--cc=sohil.mehta@intel.com \
--cc=tglx@linutronix.de \
--cc=thiago.macieira@intel.com \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).