lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180126103451.16863-1-poros@redhat.com>
Date:   Fri, 26 Jan 2018 11:34:50 +0100
From:   Petr Oros <poros@...hat.com>
To:     bp@...en8.de
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        "H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH] x86/microcode/intel: print previous microcode revision during early update

  When kernel do early microcode update, code printing only
  new microcode version. But in this case we no have chance
  to check which version was in cpu from BIOS vendor.

  Patch add this info into output message.

Signed-off-by: Petr Oros <poros@...hat.com>
---
 arch/x86/kernel/cpu/microcode/intel.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index d9e460fc7a3b..78330d29cd4c 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -515,9 +515,11 @@ static bool load_builtin_intel_microcode(struct cpio_data *cp)
  * Print ucode update info.
  */
 static void
-print_ucode_info(struct ucode_cpu_info *uci, unsigned int date)
+print_ucode_info(struct ucode_cpu_info *uci, unsigned int date,
+			unsigned int prev_rev)
 {
-	pr_info_once("microcode updated early to revision 0x%x, date = %04x-%02x-%02x\n",
+	pr_info_once("microcode updated early from revision 0x%x to 0x%x, date = %04x-%02x-%02x\n",
+		     prev_rev,
 		     uci->cpu_sig.rev,
 		     date & 0xffff,
 		     date >> 24,
@@ -528,6 +530,7 @@ print_ucode_info(struct ucode_cpu_info *uci, unsigned int date)
 
 static int delay_ucode_info;
 static int current_mc_date;
+static int prev_revision;
 
 /*
  * Print early updated ucode info after printk works. This is delayed info dump.
@@ -538,7 +541,7 @@ void show_ucode_info_early(void)
 
 	if (delay_ucode_info) {
 		collect_cpu_info_early(&uci);
-		print_ucode_info(&uci, current_mc_date);
+		print_ucode_info(&uci, current_mc_date, prev_revision);
 		delay_ucode_info = 0;
 	}
 }
@@ -547,11 +550,12 @@ void show_ucode_info_early(void)
  * At this point, we can not call printk() yet. Delay printing microcode info in
  * show_ucode_info_early() until printk() works.
  */
-static void print_ucode(struct ucode_cpu_info *uci)
+static void print_ucode(struct ucode_cpu_info *uci, unsigned int prev_rev)
 {
 	struct microcode_intel *mc;
 	int *delay_ucode_info_p;
 	int *current_mc_date_p;
+	int *prev_revision_p;
 
 	mc = uci->mc;
 	if (!mc)
@@ -559,13 +563,16 @@ static void print_ucode(struct ucode_cpu_info *uci)
 
 	delay_ucode_info_p = (int *)__pa_nodebug(&delay_ucode_info);
 	current_mc_date_p = (int *)__pa_nodebug(&current_mc_date);
+	prev_revision_p = (int *)__pa_nodebug(&prev_revision);
 
 	*delay_ucode_info_p = 1;
 	*current_mc_date_p = mc->hdr.date;
+	*prev_revision_p = prev_rev;
 }
 #else
 
-static inline void print_ucode(struct ucode_cpu_info *uci)
+static inline void print_ucode(struct ucode_cpu_info *uci,
+				unsigned int prev_rev)
 {
 	struct microcode_intel *mc;
 
@@ -573,19 +580,21 @@ static inline void print_ucode(struct ucode_cpu_info *uci)
 	if (!mc)
 		return;
 
-	print_ucode_info(uci, mc->hdr.date);
+	print_ucode_info(uci, mc->hdr.date, prev_rev);
 }
 #endif
 
 static int apply_microcode_early(struct ucode_cpu_info *uci, bool early)
 {
 	struct microcode_intel *mc;
-	u32 rev;
+	u32 rev, prev_rev;
 
 	mc = uci->mc;
 	if (!mc)
 		return 0;
 
+	prev_rev = intel_get_microcode_revision();
+
 	/* write microcode via MSR 0x79 */
 	native_wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits);
 
@@ -596,9 +605,9 @@ static int apply_microcode_early(struct ucode_cpu_info *uci, bool early)
 	uci->cpu_sig.rev = rev;
 
 	if (early)
-		print_ucode(uci);
+		print_ucode(uci, prev_rev);
 	else
-		print_ucode_info(uci, mc->hdr.date);
+		print_ucode_info(uci, mc->hdr.date, prev_rev);
 
 	return 0;
 }
-- 
2.16.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ