From: "Sironi, Filippo" <sironi@amazon.de> To: Prarit Bhargava <prarit@redhat.com> Cc: "bp@alien8.de" <bp@alien8.de>, "linux-edac@vger.kernel.org" <linux-edac@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "tony.luck@intel.com" <tony.luck@intel.com>, "stable@vger.kernel.org" <stable@vger.kernel.org> Subject: Re: [PATCH v2] arch/x86: Fix boot_cpu_data.microcode version output Date: Tue, 31 Jul 2018 11:46:09 +0000 [thread overview] Message-ID: <65549531-EA3A-49ED-BECA-D5F85B9F09E4@amazon.de> (raw) In-Reply-To: <20180731112739.32338-1-prarit@redhat.com> > On 31. Jul 2018, at 13:27, Prarit Bhargava <prarit@redhat.com> wrote: > > 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 <bp@alien8.com> > Signed-off-by: Prarit Bhargava <prarit@redhat.com> > 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; > } There may be a chance of skipping this code, I think. If the microcode is loaded on the hyperthread sibling of the boot cpu before being loaded on the boot cpu, the boot cpu will exit earlier from apply_microcode_intel() - in if (rev >= mc->hdr.rev) { ... }. (This seems to be possible in apply_microcode_amd() as well.) In my tree with the aforementioned change - Intel only - I also had the following patch: diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index 97ccf4c3b45b..4bc869e829eb 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -797,6 +797,7 @@ static enum ucode_state apply_microcode_intel(int cpu) struct microcode_intel *mc; static int prev_rev; u32 rev; + enum ucode_state ret; /* We should bind the task to the CPU */ if (WARN_ON(raw_smp_processor_id() != cpu)) @@ -817,9 +818,8 @@ static enum ucode_state apply_microcode_intel(int cpu) */ rev = intel_get_microcode_revision(); if (rev >= mc->hdr.rev) { - uci->cpu_sig.rev = rev; - c->microcode = rev; - return UCODE_OK; + ret = UCODE_OK; + goto out; } /* @@ -848,10 +848,12 @@ static enum ucode_state apply_microcode_intel(int cpu) prev_rev = rev; } + ret = UCODE_UPDATED; +out: uci->cpu_sig.rev = rev; c->microcode = rev; - return UCODE_UPDATED; + return ret; } static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size, which prevents the issue. > -- > 2.17.0 > > Amazon Development Center Germany GmbH Berlin - Dresden - Aachen main office: Krausenstr. 38, 10117 Berlin Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger Ust-ID: DE289237879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B
WARNING: multiple messages have this Message-ID (diff)
From: Filippo Sironi <sironi@amazon.de> To: Prarit Bhargava <prarit@redhat.com> Cc: "bp@alien8.de" <bp@alien8.de>, "linux-edac@vger.kernel.org" <linux-edac@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "tony.luck@intel.com" <tony.luck@intel.com>, "stable@vger.kernel.org" <stable@vger.kernel.org> Subject: [v2] arch/x86: Fix boot_cpu_data.microcode version output Date: Tue, 31 Jul 2018 11:46:09 +0000 [thread overview] Message-ID: <65549531-EA3A-49ED-BECA-D5F85B9F09E4@amazon.de> (raw) > On 31. Jul 2018, at 13:27, Prarit Bhargava <prarit@redhat.com> wrote: > > 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 <bp@alien8.com> > Signed-off-by: Prarit Bhargava <prarit@redhat.com> > 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; > } There may be a chance of skipping this code, I think. If the microcode is loaded on the hyperthread sibling of the boot cpu before being loaded on the boot cpu, the boot cpu will exit earlier from apply_microcode_intel() - in if (rev >= mc->hdr.rev) { ... }. (This seems to be possible in apply_microcode_amd() as well.) In my tree with the aforementioned change - Intel only - I also had the following patch: which prevents the issue. > -- > 2.17.0 > > Amazon Development Center Germany GmbH Berlin - Dresden - Aachen main office: Krausenstr. 38, 10117 Berlin Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger Ust-ID: DE289237879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B --- To unsubscribe from this list: send the line "unsubscribe linux-edac" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index 97ccf4c3b45b..4bc869e829eb 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -797,6 +797,7 @@ static enum ucode_state apply_microcode_intel(int cpu) struct microcode_intel *mc; static int prev_rev; u32 rev; + enum ucode_state ret; /* We should bind the task to the CPU */ if (WARN_ON(raw_smp_processor_id() != cpu)) @@ -817,9 +818,8 @@ static enum ucode_state apply_microcode_intel(int cpu) */ rev = intel_get_microcode_revision(); if (rev >= mc->hdr.rev) { - uci->cpu_sig.rev = rev; - c->microcode = rev; - return UCODE_OK; + ret = UCODE_OK; + goto out; } /* @@ -848,10 +848,12 @@ static enum ucode_state apply_microcode_intel(int cpu) prev_rev = rev; } + ret = UCODE_UPDATED; +out: uci->cpu_sig.rev = rev; c->microcode = rev; - return UCODE_UPDATED; + return ret; } static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size,
next prev parent reply other threads:[~2018-07-31 11:49 UTC|newest] Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-06-01 11:30 [PATCH] x86/MCE: Get microcode revision from cpu_info instead of boot_cpu_data Filippo Sironi 2018-06-01 11:30 ` Filippo Sironi 2018-06-01 12:19 ` [PATCH] " Borislav Petkov 2018-06-01 12:19 ` Borislav Petkov 2018-06-01 12:32 ` [PATCH] " Sironi, Filippo 2018-06-01 12:32 ` Filippo Sironi 2018-06-01 12:40 ` [PATCH] " Borislav Petkov 2018-06-01 12:40 ` Borislav Petkov 2018-07-30 17:49 ` [PATCH] arch/x86: Fix boot_cpu_data.microcode version output Prarit Bhargava 2018-07-30 17:49 ` Prarit Bhargava 2018-07-30 17:53 ` [PATCH] " Prarit Bhargava 2018-07-30 17:53 ` Prarit Bhargava 2018-07-31 4:02 ` [PATCH] " Borislav Petkov 2018-07-31 4:02 ` Borislav Petkov 2018-07-31 11:27 ` [PATCH v2] " Prarit Bhargava 2018-07-31 11:27 ` [v2] " Prarit Bhargava 2018-07-31 11:46 ` Sironi, Filippo [this message] 2018-07-31 11:46 ` Filippo Sironi 2018-07-31 13:00 ` [PATCH v2] " Borislav Petkov 2018-07-31 13:00 ` [v2] " Borislav Petkov 2018-07-31 15:31 ` [PATCH v2] " Sironi, Filippo 2018-07-31 15:31 ` [v2] " Filippo Sironi 2018-08-01 15:43 ` [PATCH v2] " Borislav Petkov 2018-08-01 15:43 ` [v2] " Borislav Petkov 2018-08-01 15:44 ` [PATCH 1/2] x86/microcode: Make sure boot_cpu_data.microcode is up-to-date Borislav Petkov 2018-08-01 15:44 ` [1/2] " Borislav Petkov 2018-08-01 15:45 ` [PATCH 2/2] x86/microcode: Update the new microcode revision unconditionally Borislav Petkov 2018-08-01 15:45 ` [2/2] " Borislav Petkov 2018-08-01 15:55 ` [PATCH v2] arch/x86: Fix boot_cpu_data.microcode version output Prarit Bhargava 2018-08-01 15:55 ` [v2] " Prarit Bhargava 2018-09-02 12:15 ` [tip:x86/urgent] x86/microcode: Make sure boot_cpu_data.microcode is up-to-date tip-bot for Prarit Bhargava [not found] <<20180731112739.32338-1-prarit@redhat.com> 2018-08-01 6:38 ` [PATCH v2] arch/x86: Fix boot_cpu_data.microcode version output Oleksandr Natalenko 2018-08-01 11:38 ` Prarit Bhargava 2018-08-01 14:16 ` Oleksandr Natalenko 2018-08-01 15:29 ` Borislav Petkov 2018-08-01 15:59 ` Luck, Tony 2018-08-01 16:01 ` Oleksandr Natalenko 2018-08-01 16:14 ` Boris Petkov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=65549531-EA3A-49ED-BECA-D5F85B9F09E4@amazon.de \ --to=sironi@amazon.de \ --cc=bp@alien8.de \ --cc=linux-edac@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=prarit@redhat.com \ --cc=stable@vger.kernel.org \ --cc=tony.luck@intel.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.