From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3FC5C28CF6 for ; Wed, 1 Aug 2018 11:38:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82B6720894 for ; Wed, 1 Aug 2018 11:38:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82B6720894 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388732AbeHANXj (ORCPT ); Wed, 1 Aug 2018 09:23:39 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58314 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387610AbeHANXj (ORCPT ); Wed, 1 Aug 2018 09:23:39 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 95F0040241C0; Wed, 1 Aug 2018 11:38:15 +0000 (UTC) Received: from prarit.bos.redhat.com (prarit-guest.khw.lab.eng.bos.redhat.com [10.16.186.145]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2BD92026D68; Wed, 1 Aug 2018 11:38:13 +0000 (UTC) Subject: Re: [PATCH v2] arch/x86: Fix boot_cpu_data.microcode version output To: Oleksandr Natalenko Cc: bp@alien8.de, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, sironi@amazon.de, stable@vger.kernel.org, tony.luck@intel.com References: From: Prarit Bhargava Message-ID: Date: Wed, 1 Aug 2018 07:38:13 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 01 Aug 2018 11:38:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 01 Aug 2018 11:38:15 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'prarit@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/01/2018 02:38 AM, Oleksandr Natalenko wrote: > Hi. > >> I tested this on AMD Ryzen & Intel Broadwell system and dumped the >> boot_cpu_data before and after a microcode update.  On the Intel >> system I also did a fatal MCE using mce-inject to confirm the output >> from the mce handling code. >> >> P. >> >> ---8<--- >> >> On systems where a runtime microcode update has occurred the microcode >> version output in a MCE log record is wrong because >> boot_cpu_data.microcode is not updated during runtime. >> >> Update boot_cpu_data.microcode when the BSP's microcode is updated. >> >> Fixes: fa94d0c6e0f3 ("x86/MCE: Save microcode revision in machine check records") >> Suggested-by: Borislav Petkov >> Signed-off-by: Prarit Bhargava >> Cc: stable@vger.kernel.org >> Cc: sironi@amazon.de >> Cc: tony.luck@intel.com >> --- >> Changes in v2: Use mc_amd->hdr.patch_id on AMD >> >>  arch/x86/kernel/cpu/microcode/amd.c   | 4 ++++ >>  arch/x86/kernel/cpu/microcode/intel.c | 4 ++++ >>  2 files changed, 8 insertions(+) >> >> diff --git a/arch/x86/kernel/cpu/microcode/amd.c >> b/arch/x86/kernel/cpu/microcode/amd.c >> index 0624957aa068..63b072377ba4 100644 >> --- a/arch/x86/kernel/cpu/microcode/amd.c >> +++ b/arch/x86/kernel/cpu/microcode/amd.c >> @@ -537,6 +537,10 @@ static enum ucode_state apply_microcode_amd(int cpu) >>      uci->cpu_sig.rev = mc_amd->hdr.patch_id; >>      c->microcode = mc_amd->hdr.patch_id; >> >> +    /* Update boot_cpu_data's revision too, if we're on the BSP: */ >> +    if (c->cpu_index == boot_cpu_data.cpu_index) >> +        boot_cpu_data.microcode =  mc_amd->hdr.patch_id; >> + >>      return UCODE_UPDATED; >>  } >> >> diff --git a/arch/x86/kernel/cpu/microcode/intel.c >> b/arch/x86/kernel/cpu/microcode/intel.c >> index 97ccf4c3b45b..256d336cbc04 100644 >> --- a/arch/x86/kernel/cpu/microcode/intel.c >> +++ b/arch/x86/kernel/cpu/microcode/intel.c >> @@ -851,6 +851,10 @@ static enum ucode_state apply_microcode_intel(int cpu) >>      uci->cpu_sig.rev = rev; >>      c->microcode = rev; >> >> +    /* Update boot_cpu_data's revision too, if we're on the BSP: */ >> +    if (c->cpu_index == boot_cpu_data.cpu_index) >> +        boot_cpu_data.microcode = rev; >> + >>      return UCODE_UPDATED; >>  } >> >> -- >> 2.17.0 > > After this patch, do we preserve an original microcode version somewhere? If no, > why? Sometimes it is useful while debugging another crash because of faulty > microcode. > Interesting, and thanks for bringing this up. Oleksandr, under what circumstances would you want to know what the old version was. AFAICS it is no longer running and should not have an impact on the system? P. > Thanks. >