Re: [tip:x86/urgent] x86/cpu/AMD: Apply the Erratum 688 fix when the BIOS doesn't

From: Peter Zijlstra
Date: Sun Oct 22 2017 - 09:05:00 EST


On Sun, Oct 22, 2017 at 05:16:29AM -0700, tip-bot for Borislav Petkov wrote:
> +static void __fix_erratum_688(void *info)
> +{
> +#define MSR_AMD64_IC_CFG 0xC0011021
> +
> + msr_set_bit(MSR_AMD64_IC_CFG, 3);
> + msr_set_bit(MSR_AMD64_IC_CFG, 14);

I realize this is an erratum work around, but would it be too much to
ask for a small comment explaining the magic values?

> +}
> +
> +/* Apply erratum 688 fix so machines without a BIOS fix work. */
> +static __init void fix_erratum_688(void)
> +{
> + struct pci_dev *F4;
> + u32 val;
> +
> + if (boot_cpu_data.x86 != 0x14)
> + return;
> +
> + if (!amd_northbridges.num)
> + return;
> +
> + F4 = node_to_amd_nb(0)->link;
> + if (!F4)
> + return;
> +
> + if (pci_read_config_dword(F4, 0x164, &val))
> + return;
> +
> + if (val & BIT(2))
> + return;
> +
> + on_each_cpu(__fix_erratum_688, NULL, 0);
> +
> + pr_info("x86/cpu/AMD: CPU erratum 688 worked around\n");

Except for all CPUs that were not online at this point in time... So
suppose I boot with a limited number of CPUs and then later bring up the
rest, bad things happen.