首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AMD微码不更新

AMD微码不更新
EN

Unix & Linux用户
提问于 2018-09-07 12:23:47
回答 1查看 1.1K关注 0票数 6

我最近在我的AMD Ryzen 7 1700X上安装了Gentoo Linux。现在我面对重编译过程中的故障分割在空闲状态下随机重新启动

作为第一步,我验证了当前的微码版本:

代码语言:javascript
复制
grep -m 1 microcode /proc/cpuinfo
microcode       : 0x8001126

然而,根据这张桌子,最新的微码应该是0x08001129。因此,更新CPU的微码似乎是个好主意。

所以我出现了=sys-kernel/linux-firmware-20180730 (包含/lib/firmware/amd-ucode/microcode_amd_fam17h.bin)。此外,我在内核中启用了以下选项:

代码语言:javascript
复制
CONFIG_MICROCODE=y
CONFIG_MICROCODE_AMD=y

重新启动后,我尝试手动加载微代码(后期微码更新):

代码语言:javascript
复制
echo 1 > /sys/devices/system/cpu/microcode/reload

但是,当我这样做时,dmesg中不会出现新行:

代码语言:javascript
复制
dmesg | grep microcode
[    0.465121] microcode: CPU0: patch_level=0x08001126
[    0.465514] microcode: CPU1: patch_level=0x08001126
[    0.465932] microcode: CPU2: patch_level=0x08001126
[    0.466394] microcode: CPU3: patch_level=0x08001126
[    0.466772] microcode: CPU4: patch_level=0x08001126
[    0.467159] microcode: CPU5: patch_level=0x08001126
[    0.467537] microcode: CPU6: patch_level=0x08001126
[    0.467908] microcode: CPU7: patch_level=0x08001126
[    0.468268] microcode: CPU8: patch_level=0x08001126
[    0.468653] microcode: CPU9: patch_level=0x08001126
[    0.468999] microcode: CPU10: patch_level=0x08001126
[    0.469409] microcode: CPU11: patch_level=0x08001126
[    0.469744] microcode: CPU12: patch_level=0x08001126
[    0.470136] microcode: CPU13: patch_level=0x08001126
[    0.470455] microcode: CPU14: patch_level=0x08001126
[    0.470757] microcode: CPU15: patch_level=0x08001126
[    0.471092] microcode: Microcode Update Driver: v2.2.

我希望看到类似microcode: CPU0: new patch_level=0x08001129的东西。我在这里错过了什么?内核CONFIG_选项?我可以打开某种调试信息吗?或者更好的是--我如何列出microcode_amd_fam17h.bin中提供的微码版本?

EN

回答 1

Unix & Linux用户

发布于 2018-09-14 01:12:55

你可以试试这样的方法:

代码语言:javascript
复制
CONFIG_PREVENT_FIRMWARE_BUILD=y
CONFIG_FIRMWARE_MEMMAP=y
CONFIG_MICROCODE=y
# CONFIG_MICROCODE_INTEL is not set
CONFIG_MICROCODE_AMD=y
CONFIG_MICROCODE_OLD_INTERFACE=y
CONFIG_FW_LOADER=y
CONFIG_EXTRA_FIRMWARE="amd-ucode/microcode_amd_fam17h.bin"
CONFIG_EXTRA_FIRMWARE_DIR="/lib/firmware"
# CONFIG_FW_LOADER_USER_HELPER is not set

(注意,如果您想在CONFIG_EXTRA_FIRMWARE中列出多个文件,它们应该是分隔的,它们的路径应该相对于CONFIG_EXTRA_FIRMWARE_DIR。)

但这可能行不通(如果我只使用图形和网络固件,还没有尝试过CPU固件),所以,尝试另一种方法:忽略上面CONFIG_EXTRA_FIRMWARE的值(即。不要设置它;但是其他的可能仍然需要,不确定),而是尝试早期微码加载,将CPU微代码文件放在initramfs文件的前面,也许类似于这样(在Gentoo中):

/etc/kernel/postinst.d/25-glue_cpu_microcode_to_kernel

代码语言:javascript
复制
#!/bin/bash

bootdir='/bewt'
initramfsfname="initramfs"
initramfs="$( realpath -- "/${bootdir}/${initramfsfname}" )"
vmlinuz="/${bootdir}/kernel"

prepend_microcode () {
  echo "prepending CPU microcode to ${initramfs}"
  local destfirst="/tmp/initrd/"
  local destmc="${destfirst}/kernel/x86/microcode/"
#  mkdir -p "${destmc}"
    install -dm644 "${destmc}"

  #this will replace the symlink /bewt/initramfs (on gentoo) with the file!
  #but this makes genkernel fail as such: 
  #ln: failed to create symbolic link 'initramfs.old' -> '': No such file or directory
  #even though it doesn't touch the .old file!
  # so to fix this, we'll use realpath above!

  ( cp -f "/lib/firmware/amd-ucode/microcode_amd.bin" "${destmc}/AuthenticAMD.bin" && cd "${destfirst}" && find . | cpio -o -H newc > "../ucode.cpio" 2>/dev/null && cd .. && cat "ucode.cpio" "${initramfs}" > "/tmp/${initramfsfname}" && chmod a-rwx "/tmp/${initramfsfname}" && mv -f "/tmp/${initramfsfname}" "${initramfs}" )
    local ec=$?
    if [[ $ec -eq 0 ]]; then
        echo "success."
    else
        #TODO: make errors be red so it's more obvious
        echo "failed!"
    fi
    return $ec
}

prepend_microcode

然而,genkernel可能(仍然?3年后)忽略/etc/kernel/postinst.d/中的文件(或者直到2015年才被修复,或者出于其他原因),这意味着您必须自己手动运行genkernel (编译内核),然后在/etc/kernel/postinst.d/中手动运行脚本现在时中的所有文件,这样做看起来像

echo "!! Running genkernel..." time genkernel all --bootdir="/bewt" --install --symlink --no-splash --no-mountboot --makeopts="-j4 V=0" --no-keymap --lvm --no-mdadm --no-dmraid --no-zfs --no-multipath --no-iscsi --disklabel --luks --no-gpg --no-netboot --no-unionfs --no-firmware --no-integrated-initramfs --compress-initramfs --compress-initrd --compress-initramfs-type=best --loglevel=5 --color --no-mrproper --no-clean --no-postclear --oldconfig ec="$?" if test "$ec" -ne "0"; then echo "!! genkernel failed $ec" exit "$ec" fi echo "!! Done genkernel" list=( `find /etc/kernel/postinst.d -type f -executable | sort --general-numeric-sort` ) echo "!! Found executables: ${list[@]}" for i in ${list[@]}; do ec="-1" while test "0" -ne "$ec"; do echo "!! Executing: '$i'" time $i ec="$?" echo "!! Exit code: $ec" if test "$ec" -ne "0"; then echo "!! something went wrong, fix it then press Enter to retry executing '$i' or press C-c now." #exit $ec time read -p -s "!! Press Enter to re-execute that or C-c to cancel" fi done done

(注意:上面使用的引导程序是/bewt而不是/boot,所以您可能希望至少更改它;上面的字符串microcode_amd.bin也应该替换为yours:microcode_amd_fam17h.bin),上面的list=for不是正确的方式来处理文件名,除非它们没有空格、换行符等等,这显然是上面假设的。

如果您想看一看早期加载cpu固件的4.1.7内核.config,请参阅这一个

票数 3
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/467528

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档