[tip: x86/microcode] x86/microcode/intel: Rename get_datasize() since its used externally

From: tip-bot2 for Ashok Raj
Date: Sun Aug 13 2023 - 13:26:43 EST


The following commit has been merged into the x86/microcode branch of tip:

Commit-ID: b0e67db12d769cc308a50c1c0ac3721c4f6aead7
Gitweb: https://git.kernel.org/tip/b0e67db12d769cc308a50c1c0ac3721c4f6aead7
Author: Ashok Raj <ashok.raj@xxxxxxxxx>
AuthorDate: Sat, 12 Aug 2023 21:58:45 +02:00
Committer: Borislav Petkov (AMD) <bp@xxxxxxxxx>
CommitterDate: Sun, 13 Aug 2023 18:42:55 +02:00

x86/microcode/intel: Rename get_datasize() since its used externally

Rename get_datasize() to intel_microcode_get_datasize() and make it an inline.

[ tglx: Make the argument typed and fix up the IFS code ]

Suggested-by: Boris Petkov <bp@xxxxxxxxx>
Signed-off-by: Ashok Raj <ashok.raj@xxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Link: https://lore.kernel.org/r/20230812195727.894165745@xxxxxxxxxxxxx
---
arch/x86/include/asm/microcode_intel.h | 7 ++++---
arch/x86/kernel/cpu/microcode/intel.c | 8 ++++----
drivers/platform/x86/intel/ifs/load.c | 5 +++--
3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/arch/x86/include/asm/microcode_intel.h b/arch/x86/include/asm/microcode_intel.h
index 9951a4b..7bd4c29 100644
--- a/arch/x86/include/asm/microcode_intel.h
+++ b/arch/x86/include/asm/microcode_intel.h
@@ -26,9 +26,10 @@ struct microcode_intel {
#define MC_HEADER_TYPE_IFS 2
#define DEFAULT_UCODE_DATASIZE (2000)

-#define get_datasize(mc) \
- (((struct microcode_intel *)mc)->hdr.datasize ? \
- ((struct microcode_intel *)mc)->hdr.datasize : DEFAULT_UCODE_DATASIZE)
+static inline int intel_microcode_get_datasize(struct microcode_header_intel *hdr)
+{
+ return hdr->datasize ? : DEFAULT_UCODE_DATASIZE;
+}

static inline u32 intel_get_microcode_revision(void)
{
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 171d96b..9866672 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -118,10 +118,10 @@ int intel_find_matching_signature(void *mc, unsigned int csig, int cpf)
return 1;

/* Look for ext. headers: */
- if (get_totalsize(mc_hdr) <= get_datasize(mc_hdr) + MC_HEADER_SIZE)
+ if (get_totalsize(mc_hdr) <= intel_microcode_get_datasize(mc_hdr) + MC_HEADER_SIZE)
return 0;

- ext_hdr = mc + get_datasize(mc_hdr) + MC_HEADER_SIZE;
+ ext_hdr = mc + intel_microcode_get_datasize(mc_hdr) + MC_HEADER_SIZE;
ext_sig = (void *)ext_hdr + EXT_HEADER_SIZE;

for (i = 0; i < ext_hdr->count; i++) {
@@ -156,7 +156,7 @@ int intel_microcode_sanity_check(void *mc, bool print_err, int hdr_type)
struct extended_signature *ext_sig;

total_size = get_totalsize(mc_header);
- data_size = get_datasize(mc_header);
+ data_size = intel_microcode_get_datasize(mc_header);

if (data_size + MC_HEADER_SIZE > total_size) {
if (print_err)
@@ -438,7 +438,7 @@ static void show_saved_mc(void)
date = mc_saved_header->date;

total_size = get_totalsize(mc_saved_header);
- data_size = get_datasize(mc_saved_header);
+ data_size = intel_microcode_get_datasize(mc_saved_header);

pr_debug("mc_saved[%d]: sig=0x%x, pf=0x%x, rev=0x%x, total size=0x%x, date = %04x-%02x-%02x\n",
i++, sig, pf, rev, total_size,
diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c
index 390862a..cefd0d8 100644
--- a/drivers/platform/x86/intel/ifs/load.c
+++ b/drivers/platform/x86/intel/ifs/load.c
@@ -56,12 +56,13 @@ struct metadata_header {

static struct metadata_header *find_meta_data(void *ucode, unsigned int meta_type)
{
+ struct microcode_header_intel *hdr = &((struct microcode_intel *)ucode)->hdr;
struct metadata_header *meta_header;
unsigned long data_size, total_meta;
unsigned long meta_size = 0;

- data_size = get_datasize(ucode);
- total_meta = ((struct microcode_intel *)ucode)->hdr.metasize;
+ data_size = intel_microcode_get_datasize(hdr);
+ total_meta = hdr->metasize;
if (!total_meta)
return NULL;