linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mihai Carabas <mihai.carabas@oracle.com>
To: linux-kernel@vger.kernel.org
Cc: Mihai Carabas <mihai.carabas@oracle.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Jonathan Corbet <corbet@lwn.net>,
	linux-doc@vger.kernel.org
Subject: [PATCH RFC 1/3] x86: microcode: intel: read microcode metadata file
Date: Mon, 27 Apr 2020 10:27:57 +0300	[thread overview]
Message-ID: <1587972479-10971-2-git-send-email-mihai.carabas@oracle.com> (raw)
In-Reply-To: <1587972479-10971-1-git-send-email-mihai.carabas@oracle.com>

Try to read the microcode metadata file in order to see what features
are added or remove by the new microcode blob. If the metadata file
does not exists passthrough normal loading with a warning message.

Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
---
 arch/x86/kernel/cpu/microcode/intel.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 6a99535..a54d5e6 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -970,10 +970,12 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
 					     bool refresh_fw)
 {
 	struct cpuinfo_x86 *c = &cpu_data(cpu);
+	const struct firmware *meta_firmware;
 	const struct firmware *firmware;
 	struct iov_iter iter;
 	enum ucode_state ret;
 	struct kvec kvec;
+	char meta_name[40];
 	char name[30];
 
 	if (is_blacklisted(cpu))
@@ -982,11 +984,21 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
 	sprintf(name, "intel-ucode/%02x-%02x-%02x",
 		c->x86, c->x86_model, c->x86_stepping);
 
+	sprintf(meta_name, "intel-ucode/%02x-%02x-%02x.metadata",
+		c->x86, c->x86_model, c->x86_stepping);
+
 	if (request_firmware_direct(&firmware, name, device)) {
 		pr_debug("data file %s load failed\n", name);
 		return UCODE_NFOUND;
 	}
 
+	if (request_firmware_direct(&meta_firmware, meta_name, device)) {
+		pr_debug("metadata file %s load failed\n", name);
+		pr_debug("no feature check will be done pre-loading the microcode\n");
+	} else {
+		release_firmware(meta_firmware);
+	}
+
 	kvec.iov_base = (void *)firmware->data;
 	kvec.iov_len = firmware->size;
 	iov_iter_kvec(&iter, WRITE, &kvec, 1, firmware->size);
-- 
1.8.3.1


  reply	other threads:[~2020-04-27  8:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-27  7:27 [PATCH RFC] Microcode late loading feature identification Mihai Carabas
2020-04-27  7:27 ` Mihai Carabas [this message]
2020-05-04 14:12   ` [PATCH RFC 1/3] x86: microcode: intel: read microcode metadata file Borislav Petkov
2020-04-27  7:27 ` [PATCH RFC 2/3] x86: microcode: intel: process microcode metadata Mihai Carabas
2020-04-27  7:27 ` [PATCH RFC 3/3] Documentation: x86: microcode: add description for metadata file Mihai Carabas
2020-05-04 14:09   ` Borislav Petkov
2020-05-11 14:11 ` [PATCH RFC] Microcode late loading feature identification Mihai Carabas
2020-05-11 15:23   ` Raj, Ashok

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=1587972479-10971-2-git-send-email-mihai.carabas@oracle.com \
    --to=mihai.carabas@oracle.com \
    --cc=bp@alien8.de \
    --cc=corbet@lwn.net \
    --cc=hpa@zytor.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --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).