Skip to content

Commit ae6a8a2

Browse files
Richard CochranIngo Molnar
authored andcommitted
x86/tboot: Convert to hotplug state machine
Install the callbacks via the state machine and let the core invoke the callbacks on the already online CPUs. Signed-off-by: Richard Cochran <rcochran@linutronix.de> Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de> Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Gang Wei <gang.wei@intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Ning Sun <ning.sun@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Richard L Maliszewski <richard.l.maliszewski@intel.com> Cc: Shane Wang <shane.wang@intel.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: rt@linutronix.de Cc: tboot-devel@lists.sourceforge.net Link: http://lkml.kernel.org/r/20160713153337.400227322@linutronix.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 27c01a8 commit ae6a8a2

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

arch/x86/kernel/tboot.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -323,25 +323,16 @@ static int tboot_wait_for_aps(int num_aps)
323323
return !(atomic_read((atomic_t *)&tboot->num_in_wfs) == num_aps);
324324
}
325325

326-
static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
327-
void *hcpu)
326+
static int tboot_dying_cpu(unsigned int cpu)
328327
{
329-
switch (action) {
330-
case CPU_DYING:
331-
atomic_inc(&ap_wfs_count);
332-
if (num_online_cpus() == 1)
333-
if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
334-
return NOTIFY_BAD;
335-
break;
328+
atomic_inc(&ap_wfs_count);
329+
if (num_online_cpus() == 1) {
330+
if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
331+
return -EBUSY;
336332
}
337-
return NOTIFY_OK;
333+
return 0;
338334
}
339335

340-
static struct notifier_block tboot_cpu_notifier =
341-
{
342-
.notifier_call = tboot_cpu_callback,
343-
};
344-
345336
#ifdef CONFIG_DEBUG_FS
346337

347338
#define TBOOT_LOG_UUID { 0x26, 0x25, 0x19, 0xc0, 0x30, 0x6b, 0xb4, 0x4d, \
@@ -417,8 +408,8 @@ static __init int tboot_late_init(void)
417408
tboot_create_trampoline();
418409

419410
atomic_set(&ap_wfs_count, 0);
420-
register_hotcpu_notifier(&tboot_cpu_notifier);
421-
411+
cpuhp_setup_state(CPUHP_AP_X86_TBOOT_DYING, "AP_X86_TBOOT_DYING", NULL,
412+
tboot_dying_cpu);
422413
#ifdef CONFIG_DEBUG_FS
423414
debugfs_create_file("tboot_log", S_IRUSR,
424415
arch_debugfs_dir, NULL, &tboot_log_fops);

include/linux/cpuhotplug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ enum cpuhp_state {
5353
CPUHP_AP_ARM_CORESIGHT4_STARTING,
5454
CPUHP_AP_ARM64_ISNDEP_STARTING,
5555
CPUHP_AP_LEDTRIG_STARTING,
56+
CPUHP_AP_X86_TBOOT_DYING,
5657
CPUHP_AP_NOTIFY_STARTING,
5758
CPUHP_AP_ONLINE,
5859
CPUHP_TEARDOWN_CPU,

0 commit comments

Comments
 (0)