[kvm-unit-tests PATCH v4 13/13] x86: Add ap_online() to consolidate final "AP is alive!" code

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

 



Add ap_online() to consolidate the last stage of onlining an AP CPU.

Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
 lib/x86/setup.c |  9 +--------
 lib/x86/smp.c   | 12 ++++++++++++
 lib/x86/smp.h   |  1 +
 x86/cstart.S    |  8 +++-----
 4 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/lib/x86/setup.c b/lib/x86/setup.c
index d9fd9e7..65c0fbf 100644
--- a/lib/x86/setup.c
+++ b/lib/x86/setup.c
@@ -393,12 +393,5 @@ void ap_start64(void)
 	save_id();
 	enable_apic();
 	enable_x2apic();
-	sti();
-	asm volatile ("nop");
-	printf("setup: AP %d online\n", apic_id());
-	atomic_inc(&cpu_online_count);
-
-	/* Only the BSP runs the test's main(), APs are given work via IPIs. */
-	for (;;)
-		asm volatile("hlt");
+	ap_online();
 }
diff --git a/lib/x86/smp.c b/lib/x86/smp.c
index dd4eb8c..feaab7a 100644
--- a/lib/x86/smp.c
+++ b/lib/x86/smp.c
@@ -82,6 +82,18 @@ static void setup_smp_id(void *data)
 	this_cpu_write_smp_id(apic_id());
 }
 
+void ap_online(void)
+{
+	irq_enable();
+
+	printf("setup: CPU %d online\n", apic_id());
+	atomic_inc(&cpu_online_count);
+
+	/* Only the BSP runs the test's main(), APs are given work via IPIs. */
+	for (;;)
+		asm volatile("hlt");
+}
+
 static void __on_cpu(int cpu, void (*function)(void *data), void *data, int wait)
 {
 	const u32 ipi_icr = APIC_INT_ASSERT | APIC_DEST_PHYSICAL | APIC_DM_FIXED | IPI_VECTOR;
diff --git a/lib/x86/smp.h b/lib/x86/smp.h
index 3ddc39e..08a440b 100644
--- a/lib/x86/smp.h
+++ b/lib/x86/smp.h
@@ -85,6 +85,7 @@ void on_cpu_async(int cpu, void (*function)(void *data), void *data);
 void on_cpus(void (*function)(void *data), void *data);
 void smp_reset_apic(void);
 void bringup_aps(void);
+void ap_online(void);
 
 extern atomic_t cpu_online_count;
 extern unsigned char online_cpus[(MAX_TEST_CPUS + 7) / 8];
diff --git a/x86/cstart.S b/x86/cstart.S
index fdbe343..e82bed7 100644
--- a/x86/cstart.S
+++ b/x86/cstart.S
@@ -101,12 +101,10 @@ ap_start32:
 	call save_id
 	call enable_apic
 	call enable_x2apic
-	sti
-	nop
-	lock incw cpu_online_count
+	call ap_online
 
-1:	hlt
-	jmp 1b
+	/* ap_online() should never return */
+	ud2
 
 start32:
 	setup_tr_and_percpu
-- 
2.36.1.476.g0c4daa206d-goog




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux