Re: [PATCH v2 2/3] Mutually exclude cpu online and suspend/hibernate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/13/2011 10:59 PM, Srivatsa S. Bhat wrote:
> On 10/13/2011 10:31 PM, Borislav Petkov wrote:
>> On Thu, Oct 13, 2011 at 12:06:02PM -0400, Tejun Heo wrote:
>>> I hate to sound like a broken recorder but the above patch isn't
>>> strictly correct for hot-swap cases, right?
>>
>> hpa is working on a ucode loading solution which will take care of your
>> hotswap case too.
>>
> 
> Tejun, I have written a patch below (untested) that does what you said.
> So Boris, hpa's work would make such a patch unnecessary is it?
> 

I have posted this patch (tested/corrected and with changelog), in case
it is useful/necessary. Link: https://lkml.org/lkml/2011/10/19/295

> ---
> 
>  arch/x86/kernel/microcode_core.c |   33 +++++++++++++++++++++++++++++++++
>  1 files changed, 33 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
> index f924280..849ae2d 100644
> --- a/arch/x86/kernel/microcode_core.c
> +++ b/arch/x86/kernel/microcode_core.c
> @@ -155,6 +155,27 @@ static int collect_cpu_info(int cpu)
>  	return ret;
>  }
>  
> +/*
> + * Compare the microcode revision that the kernel has in memory
> + * for this cpu and the microcode revision that we need to apply
> + * on this cpu. If they match, return 0, else return -1.
> + */
> +static int compare_cpu_with_microcode(int cpu)
> +{
> +	struct ucode_cpu_info *uci_mem = ucode_cpu_info + cpu;
> +	struct ucode_cpu_info uci_cpu;
> +	int ret;
> +
> +	ret = collect_cpu_info_on_target(cpu, &uci_cpu->cpu_sig);
> +	if(!ret) {
> +		if (!(uci_mem->cpu_sig->sig == uci_cpu->cpu_sig->sig &&
> +		      uci_mem->cpu_sig->pf == uci_cpu->cpu_sig->pf &&
> +		      uci_mem->cpu_sig->rev == uci_cpu->cpu_sig->rev))
> +			ret = -1;
> +	}
> +	return ret;
> +}
> +
>  struct apply_microcode_ctx {
>  	int err;
>  };
> @@ -397,6 +418,18 @@ static enum ucode_state microcode_update_cpu(int cpu)
>  	struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
>  	enum ucode_state ustate;
>  
> +	/*
> +	 * If the CPU on which we are going to update the
> +	 * microcode and the microcode which we currently
> +	 * have in kernel memory are incompatible, then
> +	 * invalidate the microcode that we have (and also
> +	 * free its memory), so that we can get the required
> +	 * microcode afresh.
> +	 */
> +	if (compare_cpu_with_microcode(cpu)) {
> +		microcode_fini_cpu(cpu);
> +	}
> +
>  	if (uci->valid)
>  		ustate = microcode_resume_cpu(cpu);
>  	else
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux