From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S943782AbcJSPBB (ORCPT ); Wed, 19 Oct 2016 11:01:01 -0400 Received: from mail.skyhub.de ([78.46.96.112]:42997 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S943740AbcJSPA6 (ORCPT ); Wed, 19 Oct 2016 11:00:58 -0400 Date: Wed, 19 Oct 2016 17:00:56 +0200 From: Borislav Petkov To: sonofagun@openmailbox.org, Nikos Barkas Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/AMD: Apply erratum 688 on machines without a BIOS fix Message-ID: <20161019150056.sdhp2nilc5oaqyis@pd.tnic> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/ (1.7.0) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 19, 2016 at 04:58:08PM +0300, sonofagun@openmailbox.org wrote: > > AMD F14h machines have an erratum which can cause unpredictable program > behaviour under specific branch conditions. The workaround is to set > MSRC001_1021[14] and MSRC001_1021[3]. Both bits are reserved for this MSR, > so we trust AMD suggestions. Since there is no BIOS update containing that > workaround for some machines, we do it ourselves unconditionally on this > family too. Our Compaq CQ57 laptop which has broken firmware in various > areas does not contain both workarounds(MSRc0011021: 0000000010208000)... ... > +#define MSR_AMD64_IC_CFG 0xC0011021 > + > +static void init_amd_on(struct cpuinfo_x86 *c) > +{ > + /* > + * Apply erratum 688 fix unconditionally so machines without a BIOS > + * fix work. > + */ > + msr_set_bit(MSR_AMD64_IC_CFG, 3); > + msr_set_bit(MSR_AMD64_IC_CFG, 14); > +} You can't force this unconditionally. Look at the suggested workaround: "BIOS should set MSRC001_1021[14] = 1b and MSRC001_1021[3] = 1b. This workaround is required only when bit 2 of Fixed Errata Status Register (D18F4x164[2]) = 0b." So you need to do something like this: if (c->x86_model == 2 && c->x86_mask == 0) { u32 val = pci_read_config(0, 0x18, 0x4, 0x164); if (!(val & BIT(2))) { msr_set_bit(MSR_AMD64_IC_CFG, 3); msr_set_bit(MSR_AMD64_IC_CFG, 14); } } Also, please paste /proc/cpuinfo from that machine. Then, keep that *whole* changelog above when sending v2 of the patch - I like the level of detail of your explanation! ;-) Thanks. -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply.