Skip to content

Commit ba3aeb9

Browse files
KAGA-KOKObp3tk0v
authored andcommitted
x86/microcode: Add per CPU control field
Add a per CPU control field to ucode_ctrl and define constants for it which are going to be used to control the loading state machine. In theory this could be a global control field, but a global control does not cover the following case: 15 primary CPUs load microcode successfully 1 primary CPU fails and returns with an error code With global control the sibling of the failed CPU would either try again or the whole operation would be aborted with the consequence that the 15 siblings do not invoke the apply path and end up with inconsistent software state. The result in dmesg would be inconsistent too. There are two additional fields added and initialized: ctrl_cpu and secondaries. ctrl_cpu is the CPU number of the primary thread for now, but with the upcoming uniform loading at package or system scope this will be one CPU per package or just one CPU. Secondaries hands the control CPU a CPU mask which will be required to release the secondary CPUs out of the wait loop. Preparatory change for implementing a properly split control flow for primary and secondary CPUs. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4b75395 commit ba3aeb9

File tree

1 file changed

+18
-2
lines changed
  • arch/x86/kernel/cpu/microcode

1 file changed

+18
-2
lines changed

arch/x86/kernel/cpu/microcode/core.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,19 @@ static struct platform_device *microcode_pdev;
252252
* requirement can be relaxed in the future. Right now, this is conservative
253253
* and good.
254254
*/
255+
enum sibling_ctrl {
256+
/* Spinwait with timeout */
257+
SCTRL_WAIT,
258+
/* Invoke the microcode_apply() callback */
259+
SCTRL_APPLY,
260+
/* Proceed without invoking the microcode_apply() callback */
261+
SCTRL_DONE,
262+
};
263+
255264
struct microcode_ctrl {
265+
enum sibling_ctrl ctrl;
256266
enum ucode_state result;
267+
unsigned int ctrl_cpu;
257268
};
258269

259270
static DEFINE_PER_CPU(struct microcode_ctrl, ucode_ctrl);
@@ -398,7 +409,7 @@ static int load_late_stop_cpus(void)
398409
*/
399410
static bool setup_cpus(void)
400411
{
401-
struct microcode_ctrl ctrl = { .result = -1, };
412+
struct microcode_ctrl ctrl = { .ctrl = SCTRL_WAIT, .result = -1, };
402413
unsigned int cpu;
403414

404415
for_each_cpu_and(cpu, cpu_present_mask, &cpus_booted_once_mask) {
@@ -408,7 +419,12 @@ static bool setup_cpus(void)
408419
return false;
409420
}
410421
}
411-
/* Initialize the per CPU state */
422+
423+
/*
424+
* Initialize the per CPU state. This is core scope for now,
425+
* but prepared to take package or system scope into account.
426+
*/
427+
ctrl.ctrl_cpu = cpumask_first(topology_sibling_cpumask(cpu));
412428
per_cpu(ucode_ctrl, cpu) = ctrl;
413429
}
414430
return true;

0 commit comments

Comments
 (0)