All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] x86/microcode: always collect_cpu_info() during boot
@ 2019-03-25 11:12 Sergey Dyasli
  2019-03-25 11:40 ` Chao Gao
  2019-03-25 17:08 ` Jan Beulich
  0 siblings, 2 replies; 5+ messages in thread
From: Sergey Dyasli @ 2019-03-25 11:12 UTC (permalink / raw)
  To: xen-devel
  Cc: Sergey Dyasli, Wei Liu, Andrew Cooper, Jan Beulich,
	Roger Pau Monné,
	Chao Gao

Currently cpu_sig struct is not updated during boot when either:

    1. ucode_scan is set to false (e.g. no "ucode=scan" in cmdline)
    2. initrd does not contain a microcode blob

These will result in cpu_sig.rev being 0 which affects APIC's
check_deadline_errata() and retpoline_safe() functions.

Fix this by getting ucode revision early during boot and SMP bring up.
While at it, protect early_microcode_update_cpu() for cases when
microcode_ops is NULL.

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
---
CC: Jan Beulich <jbeulich@suse.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: "Roger Pau Monné" <roger.pau@citrix.com>
CC: Chao Gao <chao.gao@intel.com>
---
 xen/arch/x86/microcode.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/xen/arch/x86/microcode.c b/xen/arch/x86/microcode.c
index 4163f50bb7..421d57e925 100644
--- a/xen/arch/x86/microcode.c
+++ b/xen/arch/x86/microcode.c
@@ -383,10 +383,15 @@ static struct notifier_block microcode_percpu_nfb = {
 
 int __init early_microcode_update_cpu(bool start_update)
 {
+    unsigned int cpu = smp_processor_id();
+    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
     int rc = 0;
     void *data = NULL;
     size_t len;
 
+    if ( !microcode_ops )
+        return -ENOSYS;
+
     if ( ucode_blob.size )
     {
         len = ucode_blob.size;
@@ -397,6 +402,9 @@ int __init early_microcode_update_cpu(bool start_update)
         len = ucode_mod.mod_end;
         data = bootstrap_map(&ucode_mod);
     }
+
+    microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig);
+
     if ( data )
     {
         if ( start_update && microcode_ops->start_update )
@@ -413,6 +421,8 @@ int __init early_microcode_update_cpu(bool start_update)
 
 int __init early_microcode_init(void)
 {
+    unsigned int cpu = smp_processor_id();
+    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
     int rc;
 
     rc = microcode_init_intel();
@@ -425,6 +435,8 @@ int __init early_microcode_init(void)
 
     if ( microcode_ops )
     {
+        microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig);
+
         if ( ucode_mod.mod_end || ucode_blob.size )
             rc = early_microcode_update_cpu(true);
 
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] x86/microcode: always collect_cpu_info() during boot
  2019-03-25 11:12 [PATCH v1] x86/microcode: always collect_cpu_info() during boot Sergey Dyasli
@ 2019-03-25 11:40 ` Chao Gao
  2019-03-25 17:08 ` Jan Beulich
  1 sibling, 0 replies; 5+ messages in thread
From: Chao Gao @ 2019-03-25 11:40 UTC (permalink / raw)
  To: Sergey Dyasli
  Cc: Andrew Cooper, Roger Pau Monné, Wei Liu, Jan Beulich, xen-devel

On Mon, Mar 25, 2019 at 11:12:17AM +0000, Sergey Dyasli wrote:
>Currently cpu_sig struct is not updated during boot when either:
>
>    1. ucode_scan is set to false (e.g. no "ucode=scan" in cmdline)
>    2. initrd does not contain a microcode blob
>
>These will result in cpu_sig.rev being 0 which affects APIC's
>check_deadline_errata() and retpoline_safe() functions.
>
>Fix this by getting ucode revision early during boot and SMP bring up.
>While at it, protect early_microcode_update_cpu() for cases when
>microcode_ops is NULL.
>
>Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>

Reviewed-by: Chao Gao <chao.gao@intel.com>

Thanks
Chao

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] x86/microcode: always collect_cpu_info() during boot
  2019-03-25 11:12 [PATCH v1] x86/microcode: always collect_cpu_info() during boot Sergey Dyasli
  2019-03-25 11:40 ` Chao Gao
@ 2019-03-25 17:08 ` Jan Beulich
  2019-04-01 10:19   ` Sergey Dyasli
  1 sibling, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2019-03-25 17:08 UTC (permalink / raw)
  To: Sergey Dyasli
  Cc: Andrew Cooper, xen-devel, Chao Gao, Wei Liu, Roger Pau Monne

>>> On 25.03.19 at 12:12, <sergey.dyasli@citrix.com> wrote:
> Currently cpu_sig struct is not updated during boot when either:
> 
>     1. ucode_scan is set to false (e.g. no "ucode=scan" in cmdline)
>     2. initrd does not contain a microcode blob

What about "ucode=<number>"?

> These will result in cpu_sig.rev being 0 which affects APIC's
> check_deadline_errata() and retpoline_safe() functions.
> 
> Fix this by getting ucode revision early during boot and SMP bring up.

Can't you then drop the call from microcode_update_cpu()?

> @@ -413,6 +421,8 @@ int __init early_microcode_update_cpu(bool start_update)
>  
>  int __init early_microcode_init(void)
>  {
> +    unsigned int cpu = smp_processor_id();
> +    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);

Would you mind moving these declarations ...

> @@ -425,6 +435,8 @@ int __init early_microcode_init(void)
>  
>      if ( microcode_ops )
>      {
> +        microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig);

... into this scope?

Jan



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] x86/microcode: always collect_cpu_info() during boot
  2019-03-25 17:08 ` Jan Beulich
@ 2019-04-01 10:19   ` Sergey Dyasli
  2019-04-01 13:49     ` Chao Gao
  0 siblings, 1 reply; 5+ messages in thread
From: Sergey Dyasli @ 2019-04-01 10:19 UTC (permalink / raw)
  To: Jan Beulich, Chao Gao
  Cc: Andrew Cooper, xen-devel, Wei Liu,
	sergey.dyasli@citrix.com >> Sergey Dyasli, Roger Pau Monne

On 25/03/2019 17:08, Jan Beulich wrote:
>>>> On 25.03.19 at 12:12, <sergey.dyasli@citrix.com> wrote:
>> Currently cpu_sig struct is not updated during boot when either:
>>
>>     1. ucode_scan is set to false (e.g. no "ucode=scan" in cmdline)
>>     2. initrd does not contain a microcode blob
> 
> What about "ucode=<number>"?

Yes, it's equally affected, I'll update the commit message.

>> These will result in cpu_sig.rev being 0 which affects APIC's
>> check_deadline_errata() and retpoline_safe() functions.
>>
>> Fix this by getting ucode revision early during boot and SMP bring up.
> 
> Can't you then drop the call from microcode_update_cpu()?

I tried this and found that properly handling errors requires
a call to __microcode_fini_cpu(). But instead of doing all this
refactoring now, I'd prefer this patch to go on top of Chao's
series, which greatly simplifies things in "remove struct
ucode_cpu_info". Otherwise, most of my work here would be removed
by the next version of Chao's series.

Chao,
To help me with this decision, when can we expect a v7 of your
series?

Thanks,
Sergey

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] x86/microcode: always collect_cpu_info() during boot
  2019-04-01 10:19   ` Sergey Dyasli
@ 2019-04-01 13:49     ` Chao Gao
  0 siblings, 0 replies; 5+ messages in thread
From: Chao Gao @ 2019-04-01 13:49 UTC (permalink / raw)
  To: Sergey Dyasli
  Cc: Andrew Cooper, xen-devel, Wei Liu, Jan Beulich, Roger Pau Monne

On Mon, Apr 01, 2019 at 11:19:19AM +0100, Sergey Dyasli wrote:
>On 25/03/2019 17:08, Jan Beulich wrote:
>>>>> On 25.03.19 at 12:12, <sergey.dyasli@citrix.com> wrote:
>>> Currently cpu_sig struct is not updated during boot when either:
>>>
>>>     1. ucode_scan is set to false (e.g. no "ucode=scan" in cmdline)
>>>     2. initrd does not contain a microcode blob
>> 
>> What about "ucode=<number>"?
>
>Yes, it's equally affected, I'll update the commit message.
>
>>> These will result in cpu_sig.rev being 0 which affects APIC's
>>> check_deadline_errata() and retpoline_safe() functions.
>>>
>>> Fix this by getting ucode revision early during boot and SMP bring up.
>> 
>> Can't you then drop the call from microcode_update_cpu()?
>
>I tried this and found that properly handling errors requires
>a call to __microcode_fini_cpu(). But instead of doing all this
>refactoring now, I'd prefer this patch to go on top of Chao's
>series, which greatly simplifies things in "remove struct
>ucode_cpu_info". Otherwise, most of my work here would be removed
>by the next version of Chao's series.
>
>Chao,
>To help me with this decision, when can we expect a v7 of your
>series?

Will start to work on v7 from tomorrow. And I hope that it will be finished
in this week.

Thanks
Chao

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-04-01 13:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-25 11:12 [PATCH v1] x86/microcode: always collect_cpu_info() during boot Sergey Dyasli
2019-03-25 11:40 ` Chao Gao
2019-03-25 17:08 ` Jan Beulich
2019-04-01 10:19   ` Sergey Dyasli
2019-04-01 13:49     ` Chao Gao

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.