Bug 1476039 - Microcode on AMD family 16h processors not updated early in the boot process
Microcode on AMD family 16h processors not updated early in the boot process
Status: VERIFIED
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: dracut (Show other bugs)
7.3
x86_64 Linux
high Severity urgent
: rc
: 7.5
Assigned To: Lukáš Nykrýn
Jeff Bastian
: ZStream
: 1529311 (view as bug list)
Depends On:
Blocks: CVE-2017-5715 1526943 1527310 1527311
  Show dependency treegraph
 
Reported: 2017-07-27 18:22 EDT by Jonathan Teh
Modified: 2018-01-08 16:26 EST (History)
15 users (show)

See Also:
Fixed In Version: dracut-033-525.el7
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1526943 1527310 1527311 (view as bug list)
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Bugfix for dracut-functions.sh (646 bytes, patch)
2017-07-27 18:22 EDT, Jonathan Teh
no flags Details | Diff

  None (edit)
Description Jonathan Teh 2017-07-27 18:22:36 EDT
Created attachment 1305689 [details]
Bugfix for dracut-functions.sh

Description of problem:
Microcode on AMD family 16h (22) processors (Jaguar microarchitecture) is not updated early in the boot process, only later.

Version-Release number of selected component (if applicable):
dracut-033-463.el7_3.2.x86_64
Bug is also present in current git version.

How reproducible:
Every time.

Steps to Reproduce:
1. Boot RHEL/CentOS 7.3 on a system with AMD family 16h CPU.
2.
3.

Actual results:
$ dmesg | grep microcode
[    1.287156] microcode: CPU0: patch_level=0x0700010b
[    1.287168] microcode: CPU1: patch_level=0x0700010b
[    1.287180] microcode: CPU2: patch_level=0x0700010b
[    1.287192] microcode: CPU3: patch_level=0x0700010b
[    1.287250] microcode: Microcode Update Driver: v2.01 <tigran@aivazian.fsnet.co.uk>, Peter Oruba
[    8.273684] microcode: CPU0: new patch_level=0x0700010f
[    8.274709] microcode: CPU1: new patch_level=0x0700010f
[    8.275741] microcode: CPU2: new patch_level=0x0700010f
[    8.276757] microcode: CPU3: new patch_level=0x0700010f

Expected results:
$ dmesg | grep microcode
[    1.103284] microcode: microcode: updated early to new patch_level=0x0700010f
[    1.302144] microcode: CPU0: patch_level=0x0700010f
[    1.302158] microcode: CPU1: patch_level=0x0700010f
[    1.302170] microcode: CPU2: patch_level=0x0700010f
[    1.302178] microcode: CPU3: patch_level=0x0700010f
[    1.302245] microcode: Microcode Update Driver: v2.01 <tigran@aivazian.fsnet.co.uk>, Peter Oruba

Additional info:
Bug occurs on this CPU:

$ lscpu
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 22
model           : 0
model name      : AMD Athlon(tm) 5350 APU with Radeon(tm) R3
stepping        : 1
microcode       : 0x700010f

dracut has incorrectly copied family 15h microcode into initramfs:

========================================================================
Early CPIO image
========================================================================
drwxr-xr-x   3 root     root            0 Jun 20 19:48 .
-rw-r--r--   1 root     root            2 Jun 20 19:48 early_cpio
drwxr-xr-x   3 root     root            0 Jun 20 19:48 kernel
drwxr-xr-x   3 root     root            0 Jun 20 19:48 kernel/x86
drwxr-xr-x   2 root     root            0 Jun 20 19:48 kernel/x86/microcode
-rw-r--r--   1 root     root         7876 Jun 20 19:48 kernel/x86/microcode/AuthenticAMD.bin
========================================================================
Version: dracut-033-463.el7_3.1

$ ls -l /lib/firmware/amd-ucode/
total 40
-rw-r--r--. 1 root root 12684 Nov  6  2016 microcode_amd.bin
-rw-r--r--. 1 root root   490 Nov  6  2016 microcode_amd.bin.asc
-rw-r--r--. 1 root root  7876 Nov  6  2016 microcode_amd_fam15h.bin
-rw-r--r--. 1 root root   473 Nov  6  2016 microcode_amd_fam15h.bin.asc
-rw-r--r--. 1 root root  3510 Nov  6  2016 microcode_amd_fam16h.bin
-rw-r--r--. 1 root root   473 Nov  6  2016 microcode_amd_fam16h.bin.asc

With the attached patch, it copies the correct family 16h microcode:

========================================================================
Early CPIO image
========================================================================
drwxr-xr-x   3 root     root            0 Jun 28 23:54 .
-rw-r--r--   1 root     root            2 Jun 28 23:54 early_cpio
drwxr-xr-x   3 root     root            0 Jun 28 23:54 kernel
drwxr-xr-x   3 root     root            0 Jun 28 23:54 kernel/x86
drwxr-xr-x   2 root     root            0 Jun 28 23:54 kernel/x86/microcode
-rw-r--r--   1 root     root         3510 Jun 28 23:54 kernel/x86/microcode/AuthenticAMD.bin
========================================================================
Version: dracut-033-463.el7_3.1

Patch will need revising when AMD family 17h (23, Zen microarchitecture) microcode is available.
Comment 2 Lukáš Nykrýn 2017-07-28 08:35:35 EDT
Can I ask you to submit the patch to upstream gtihut, if it is not already there?
https://github.com/dracutdevs/dracut/pulls
Comment 3 Jonathan Teh 2017-07-28 20:36:23 EDT
I've created a pull request https://github.com/dracutdevs/dracut/pull/261.
Comment 5 Jonathan Teh 2017-08-15 18:14:41 EDT
Just noticed this is fixed in dracut-046-2.git20170811 on Fedora 26, on my other box. I guess this just needs cherry-picking for the RHEL branch.
Comment 8 Jeff Bastian 2017-12-11 15:10:52 EST
(In reply to Jonathan Teh from comment #0)
> Patch will need revising when AMD family 17h (23, Zen microarchitecture)
> microcode is available.

Once we're updating dracut, we might as well handle both 16h and 17h at the same time.  Extending the patch for another family is pretty straightforward:

diff --git a/dracut-functions.sh b/dracut-functions.sh
index 4051596b1d18..0b456f5cd2ab 100755
--- a/dracut-functions.sh
+++ b/dracut-functions.sh
@@ -1738,8 +1738,14 @@ get_ucode_file ()
     local stepping=`grep -E "stepping" /proc/cpuinfo | head -1 | sed s/.*:\ //`
 
     if [[ "$(get_cpu_vendor)" == "AMD" ]]; then
+        # If family greater or equal than 0x17
+        if [[ $family -ge 23 ]]; then
+            printf "microcode_amd_fam17h.bin"
         # If family greater or equal than 0x15
-        if [[ $family -ge 21 ]]; then
+        elif [[ $family -ge 22 ]]; then
+            printf "microcode_amd_fam16h.bin"
+        # If family greater or equal than 0x15
+        elif [[ $family -ge 21 ]]; then
             printf "microcode_amd_fam15h.bin"
         else
             printf "microcode_amd.bin"
Comment 9 Jonathan Teh 2017-12-11 17:38:14 EST
Shouldn't that be:

--- dracut-functions.sh.orig    2017-08-05 16:02:47.000000000 +0100
+++ dracut-functions.sh 2017-12-11 22:35:48.601627126 +0000
@@ -1737,8 +1737,12 @@
     local stepping=`grep -E "stepping" /proc/cpuinfo | head -1 | sed s/.*:\ //`
 
     if [[ "$(get_cpu_vendor)" == "AMD" ]]; then
-        # If family greater or equal than 0x15
-        if [[ $family -ge 21 ]]; then
+        # If family greater than or equal to 0x17
+        if [[ $family -ge 23 ]]; then
+            printf "microcode_amd_fam17h.bin"
+        elif [[ $family -eq 22 ]]; then
+            printf "microcode_amd_fam16h.bin"
+        elif [[ $family -eq 21 ]]; then
             printf "microcode_amd_fam15h.bin"
         else
             printf "microcode_amd.bin"
Comment 10 Jeff Bastian 2017-12-12 08:13:52 EST
Oh, you're right!  I updated the code, but I forgot to update the comments.  Thanks!
Comment 13 Lukáš Nykrýn 2017-12-18 03:50:46 EST
I will also backport:
https://github.com/dracutdevs/dracut/commit/19453dc8744e6a59725c43b61b2e3db01cb4c57c
Comment 18 Jan Stodola 2018-01-03 11:11:47 EST
Reproduced on RHEL-7.4 GA.
Verified with dracut-033-526.el7 on systems with AMD CPU, families 21 and 22. In both cases the correct microcode was included in the early CPIO image:

Family 21:
# cat /proc/cpuinfo | grep "cpu family" | head -n1
cpu family      : 22
# ls -l /usr/lib/firmware/amd-ucode/
total 40
-rw-r--r--. 1 root root 12684 Nov 27 07:35 microcode_amd.bin
-rw-r--r--. 1 root root   490 Nov 27 07:35 microcode_amd.bin.asc
-rw-r--r--. 1 root root  7876 Nov 27 07:35 microcode_amd_fam15h.bin
-rw-r--r--. 1 root root   473 Nov 27 07:35 microcode_amd_fam15h.bin.asc
-rw-r--r--. 1 root root  3510 Nov 27 07:35 microcode_amd_fam16h.bin
-rw-r--r--. 1 root root   473 Nov 27 07:35 microcode_amd_fam16h.bin.asc
# lsinitrd | grep AMD
-rw-r--r--   1 root     root         3510 Jan  3 10:58 kernel/x86/microcode/AuthenticAMD.bin
#


Family 22:
# cat /proc/cpuinfo | grep "cpu family" | head -n1
cpu family      : 21
# ls -l /usr/lib/firmware/amd-ucode/
total 40
-rw-r--r--. 1 root root 12684 Nov 27 07:35 microcode_amd.bin
-rw-r--r--. 1 root root   490 Nov 27 07:35 microcode_amd.bin.asc
-rw-r--r--. 1 root root  7876 Nov 27 07:35 microcode_amd_fam15h.bin
-rw-r--r--. 1 root root   473 Nov 27 07:35 microcode_amd_fam15h.bin.asc
-rw-r--r--. 1 root root  3510 Nov 27 07:35 microcode_amd_fam16h.bin
-rw-r--r--. 1 root root   473 Nov 27 07:35 microcode_amd_fam16h.bin.asc
# lsinitrd | grep AMD
-rw-r--r--   1 root     root         7876 Jan  3 10:54 kernel/x86/microcode/AuthenticAMD.bin
#

Moving to VERIFIED.
Comment 19 Lukáš Nykrýn 2018-01-04 05:29:34 EST
*** Bug 1529311 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.