# microcode patch for AMD? [SOLVED]

## dufeu

As I read the ebuild for 'sys-apps/microcode-patch-20101123', there is apparently no support for AMD microcode patches. Am I reading this correctly?

```
# Copyright 1999-2010 Gentoo Foundation

# Distributed under the terms of the GNU General Public License v2

# $Header: /var/cvsroot/gentoo-x86/sys-apps/microcode-data/microcode-data-20101123.ebuild,v 1.1 2010/12/17 09:10:02 flameeyes Exp $

NUM="19611"

DESCRIPTION="Intel IA32 microcode update data"

HOMEPAGE="http://urbanmyth.org/microcode/"

SRC_URI="http://downloadmirror.intel.com/${NUM}/eng/microcode-${PV}.tgz"

LICENSE="as-is"

SLOT="0"

KEYWORDS="~amd64 ~x86"

IUSE=""

RDEPEND="!<sys-apps/microcode-ctl-1.17-r2" #268586

S=${WORKDIR}

src_install() {

        insinto /lib/firmware

        newins microcode-${PV}.dat microcode.dat || die

}

pkg_postinst() {

        einfo "The microcode available for Intel CPUs has been updated.  You'll need"

        einfo "to reload the code into your processor.  If you're using the init.d:"

        einfo "/etc/init.d/microcode_ctl restart"
```

The microcode patches for AMD are available at AMD64.org.

My second question would be to know if 'sys-apps/microcode-ctl' supports AMD micropatches even if said patches are available. I don't know how to check this.

What it looks like to me is that the microcode patch related programs are all for Intel only. If this is the case, then there is no sense to turning on support for AMD micropatches in the kernel. Is my understanding correct?

Thank you.

----------

## roarinelk

Support for AMD microcode updates exists as well, I suppose you just have to

manually run "microcode_ctl -f /path/to/amd-ucode-latest.hex".

EDIT: just tried it on my AMD box, apparently updating microcode via microcode_ctl

isn't supported (dmesg says "microcode: AMD microcode update via /dev/cpu/microcode not supported").

Apparently you need to build "microcode update" as a module, put the microcode_amd file to /lib/firmware/amd-ucode

and the "microcode" module will pick it up when it is loaded.

----------

## dufeu

 *roarinelk wrote:*   

> Apparently you need to build "microcode update" as a module, put the microcode_amd file to /lib/firmware/amd-ucode
> 
> and the "microcode" module will pick it up when it is loaded.

 

If I'm understanding this correctly, then I don't need to emerge 'sys-apps/microcode-ctl' or 'sys-apps/microcode-data'.

Rather, just download the latest tar file the site I have earlier. Put the file in the /lib/firmware directory. Set up the kernel support as a module. modprobe said module to load the microcode. That seems quite reasonable.

To be sure the AMD microcode patch gets loaded at each boot, I would just need to load it at boot time during init.

I'll try this out later today or tomorrow. I'm reviewing, in detail, all my kernel settings for application to the new 2.6.36.2 and 2.6.37 kernels.

I should point out for those whom are interested, the AMD microcode patches only apply to "AMD processor family 0x10 and 0x11, namely AMD Phenom™, AMD Opteron™ and AMD Turion™ 64 Ultra." They apparently don't apply to AMD Athlon64 etc.

----------

## Anon-E-moose

I have microcode support built in vs module and it seems to work fine 

```
Jan  3 12:42:31 don64 kernel: [    0.544003] microcode: CPU0: patch_level=0x10000bf

Jan  3 12:42:31 don64 kernel: [    0.544013] microcode: CPU1: patch_level=0x10000bf

Jan  3 12:42:31 don64 kernel: [    0.544022] microcode: CPU2: patch_level=0x10000bf

Jan  3 12:42:31 don64 kernel: [    0.544032] microcode: CPU3: patch_level=0x10000bf

Jan  3 12:42:31 don64 kernel: [    0.544042] microcode: CPU4: patch_level=0x10000bf

Jan  3 12:42:31 don64 kernel: [    0.544050] microcode: CPU5: patch_level=0x10000bf

Jan  3 12:42:31 don64 kernel: [    0.544078] microcode: Microcode Update Driver: v2.00 <tigran@aivazian.fsnet.co.uk>, Peter Oruba
```

----------

## thumper

Have you had a look at this yet?

AMD Family 10h, 11h and 14h microcode patch data

http://packages.gentoo.org/package/sys-kernel/amd-ucode

George

----------

## floppymaster

Diego (flameeyes) blogged about this today.

http://blog.flameeyes.eu/2011/01/17/microupdates-for-microcodes

----------

## dufeu

As noted above in the prior posts in this thread {thanks people!!}, this issue has answers.

I'd like to re-iterate some points and give some of my own thoughts on the matter.

1) As noted both in the AMD provided documentation and in flameeyes post, AMD provides microcode updates for CPUs '10h' and higher. Important note: This means something different than official statements elsewhere which indicate microcode updates for 'Opterons and Phenoms'. What's left out of the market speak quotes is that only Opterons based on more recent cores need apply. Original Opertons are not part of this group.

2) The microcode loader provided in the kernel does indeed perform sanity checking and will not load microcode for CPUs which are not appropriate. For those people building more or less generic kernels, it doesn't appear to hurt to include microcode support for AMD based CPUs.

3) AMD has approached the problem of loading microcode for it's CPUs with consistency. i.e. The microcode gets stored and loaded from '/lib/firmware'. This is the Linux kernel's standard location for storing firmware blobs. Huzzah! As an end user, I like consistent, standard approaches. Thank you AMD and kernel folks.

4) The microcode load support can be compiled either as a module or as built-in. Regardless of how you build it, the firmware blob is loaded from '/lib/firmware' during boot or at kernel load time. This depends not only on module/builtin but also on whether or not kernel modules are set to autoload at boot.

For my kernels, I chose builtin. I also have kernel module autoload turned on, but that's not actually germane to my setup. The following are snippets from 'dmesg' showing typical microcode load messages during kernel boot: 10h CPU core and higher;

```
[    0.546677] PCI-DMA: using GART IOMMU.

[    0.546718] PCI-DMA: Reserving 64MB of IOMMU area in the AGP aperture

[    0.551998] microcode: CPU0: patch_level=0x1000095

[    0.552049] microcode: CPU1: patch_level=0x1000095

[    0.552097] microcode: CPU2: patch_level=0x1000095

[    0.552148] microcode: CPU3: patch_level=0x1000095

[    0.552226] microcode: Microcode Update Driver: v2.00 <tigran@aivazian.fsnet.co.uk>, Peter Oruba
```

less than 10h CPU core;

```
[    0.242749] PCI-DMA: using GART IOMMU.

[    0.242774] PCI-DMA: Reserving 64MB of IOMMU area in the AGP aperture

[    0.247543] microcode: microcode: CPU0: AMD CPU family 0xf not supported

[    0.247578] microcode: microcode: CPU1: AMD CPU family 0xf not supported

[    0.247646] microcode: Microcode Update Driver: v2.00 <tigran@aivazian.fsnet.co.uk>, Peter Oruba
```

Once again, thanks everyone.

----------

## trippels

dufeu,

The kernel doesn't load any microcode in your case. It just 

prints the ucode patch_level setup by your BIOS.

When the kernel does infact update the microcode it will print the

following message:

```

pr_info("CPU%d: updated (new patch_level=0x%x)\n", cpu, rev);  
```

from arch/x86/kernel/microcode_amd.c

----------

## toralf

 *trippels wrote:*   

> dufeu,
> 
> The kernel doesn't load any microcode in your case. It just 
> 
> prints the ucode patch_level setup by your BIOS.

 Well, similar question for me (however Intel x86 core 2 duo). Does the follwing means, that nothing is updated ? :

```
2011-01-18T21:25:40.000+01:00 n22 sudo: tfoerste : TTY=pts/2 ; PWD=/home/tfoerste ; USER=root ; COMMAND=/etc/init.d/microcode_ctl restart

2011-01-18T21:25:40.000+01:00 n22 sudo: pam_unix(sudo:session): session opened for user root by tfoerste(uid=0)

2011-01-18T21:25:41.172+01:00 n22 kernel: microcode: CPU0 sig=0x10676, pf=0x80, revision=0x60f

2011-01-18T21:25:41.191+01:00 n22 kernel: microcode: CPU1 sig=0x10676, pf=0x80, revision=0x60f

2011-01-18T21:25:41.195+01:00 n22 kernel: microcode: Microcode Update Driver: v2.00 <tigran@aivazian.fsnet.co.uk>, Peter Oruba

2011-01-18T21:25:41.580+01:00 n22 kernel: microcode: Microcode Update Driver: v2.00 removed.

```

----------

## trippels

 *toralf wrote:*   

>  *trippels wrote:*   dufeu,
> 
> The kernel doesn't load any microcode in your case. It just 
> 
> prints the ucode patch_level setup by your BIOS. Well, similar question for me (however Intel x86 core 2 duo). Does the follwing means, that nothing is updated ? :
> ...

 

Yes nothing is updated in your case also.

This would be printed otherwise:

```
pr_info("CPU%d updated to revision 0x%x, date = %04x-%02x-%02x\n"
```

from ./arch/x86/kernel/microcode_intel.c

----------

## dufeu

 *trippels wrote:*   

> dufeu,
> 
> The kernel doesn't load any microcode in your case. It just 
> 
> prints the ucode patch_level setup by your BIOS.
> ...

 

Thank you. I wanted to include an example where the CPU microcode is actually patched, but I don't have any PCs with such CPUs. I do appreciate the clarification. It never occurred to me to look for the actual print statement in the code.

If someone out there does have such an example, a similar real life snippet posting would be appreciated. Just to see it in action.

----------

## trippels

AMD

```
microcode: CPU0: patch_level=0x1000065

microcode: CPU0: updated (new patch_level=0x1000083)

microcode: CPU1: patch_level=0x1000065

microcode: CPU1: updated (new patch_level=0x1000083)

microcode: CPU2: patch_level=0x1000065

microcode: CPU2: updated (new patch_level=0x1000083)

microcode: CPU3: patch_level=0x1000065

microcode: CPU3: updated (new patch_level=0x1000083)

microcode: Microcode Update Driver: v2.00 <tigran@aivazian.fsnet.co.uk>, Peter

Oruba
```

INTEL

```
microcode: CPU0 sig=0x106c2, pf=0x8, revision=0x20d

microcode: CPU1 sig=0x106c2, pf=0x8, revision=0x20d

microcode: CPU2 sig=0x106c2, pf=0x8, revision=0x20d

microcode: CPU3 sig=0x106c2, pf=0x8, revision=0x20d

microcode: Microcode Update Driver: v2.00 <tigran@aivazian.fsnet.co.uk>, Peter Oruba

microcode: CPU0 updated to revision 0x219, date = 2009-04-10

microcode: CPU1 updated to revision 0x219, date = 2009-04-10

microcode: CPU2 updated to revision 0x219, date = 2009-04-10

microcode: CPU3 updated to revision 0x219, date = 2009-04-10
```

----------

## Goverp

 *dufeu wrote:*   

> ...
> 
> 4) The microcode load support can be compiled either as a module or as built-in. Regardless of how you build it, the firmware blob is loaded from '/lib/firmware' during boot or at kernel load time. This depends not only on module/builtin but also on whether or not kernel modules are set to autoload at boot
> 
> ...

 

To clarify, I find that if you compile the load support as a module and don't set it to autoload, the kernel does not attempt to patch the firmware until you "modprobe microcode" as per the ebuild's info messages, which is nice if you want manual control.  Note that once the patch is applied, you don't need to apply it on every boot.

FWIW, when I tried the procedure, it gave the messages showing my microcode was already patched.  That's 'cos I still have the Windows Vista partition my PC came with, and I boot it once a month or so to apply updates.  I suspect the vendor (Acer) shipped CPU microcode updates as part of the BIOS upgrades.

----------

## ConnClark

Ummmmm .... I haven't seen this question asked yet but what exactly cpu bugs does this microcode patch fix?

----------

## trippels

 *ConnClark wrote:*   

> Ummmmm .... I haven't seen this question asked yet but what exactly cpu bugs does this microcode patch fix?

 

amd

intel

----------

## ConnClark

Tripples,

The question still stands. What exact cpu bugs does this microcode patch fix? ( it probably doesn't fix them all )

----------

