Skip to contentSkip to conversation

x86/cstart: Delete "local" version of save_id() to fix x2APIC SMP bug

PATCH Applied Sean Christopherson 2 participants 3 messages Dec 18, 2025 – May 19 KVM

lore
Share & tools
lore

Sean Christopherson

author reviewer
#0 lore raw

PATCH 1/1 x86/cstart: Delete "local" version of save_id() to fix x2APIC SMP bug

Delete cstart.S's version of save_id() to play nice with 32-bit SMP tests on CPUs that support x2APIC. The local version assumes xAPIC mode and so depending on the underlying "hardware" (e.g. AVIC vs. APICv vs. emulated, and with or without KVM_X86_QUIRK_LAPIC_MMIO_HOLE), may mark the wrong CPU as being online.

Fixes 0991c0ea ("x86: fix APs with APIC ID more that 255 not showing in id_map")
Cc Igor Mammedov <[email protected]>
Cc Peter Xu <[email protected]>
---
 x86/cstart.S | 7 -------
 1 file changed, 7 deletions(-)
x86/cstart.S +0 -7
index dafb330d..49ba4818 100644
@@ -84,13 +84,6 @@ prepare_32:
 
 smp_stacktop:	.long stacktop - per_cpu_size
 
-save_id:
-	movl $(APIC_DEFAULT_PHYS_BASE + APIC_ID), %eax
-	movl (%eax), %eax
-	shrl $24, %eax
-	lock btsl %eax, online_cpus
-	retl
-
 ap_start32:
 	setup_segments
 	mov $-per_cpu_size, %esp

base-commit: 31d91f5c9b7546471b729491664b05c933d64a7a

Signature · 1 line
2.52.0.322.g1dd061c0dc-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Thu, 18 Dec 2025 15:26:18 -0800 Sean Christopherson <[email protected]>…

Delete cstart.S's version of save_id() to play nice with 32-bit SMP tests on CPUs that support x2APIC. The local version assumes xAPIC mode and so depending on the underlying "hardware" (e.g. AVIC vs. APICv vs. emulated, and with or without KVM_X86_QUIRK_LAPIC_MMIO_HOLE), may mark the wrong CPU as being online.

Fixes 0991c0ea ("x86: fix APs with APIC ID more that 255 not showing in id_map")
Cc Igor Mammedov <[email protected]>
Cc Peter Xu <[email protected]>
Quoted 24 lines
---
 x86/cstart.S | 7 -------
 1 file changed, 7 deletions(-)
x86/cstart.S +0 -7
index dafb330d..49ba4818 100644
@@ -84,13 +84,6 @@ prepare_32:
 
 smp_stacktop:	.long stacktop - per_cpu_size
 
-save_id:
-	movl $(APIC_DEFAULT_PHYS_BASE + APIC_ID), %eax
-	movl (%eax), %eax
-	shrl $24, %eax
-	lock btsl %eax, online_cpus
-	retl
-
 ap_start32:
 	setup_segments
 	mov $-per_cpu_size, %esp

base-commit: 31d91f5c9b7546471b729491664b05c933d64a7a

author reviewer Applied
#2 lore raw
In reply to Sean Christopherson
Quoted 8 lines · Sean Christopherson

Delete cstart.S's version of save_id() to play nice with 32-bit SMP tests on CPUs that support x2APIC. The local version assumes xAPIC mode and so depending on the underlying "hardware" (e.g. AVIC vs. APICv vs. emulated, and with or without KVM_X86_QUIRK_LAPIC_MMIO_HOLE), may mark the wrong CPU as being online.

[...]

Applied to kvm-x86 next, thanks!

[1/1] x86/cstart: Delete "local" version of save_id() to fix x2APIC SMP bug

      https://github.com/kvm-x86/kvm-unit-tests/commit/d0052ffe48da

--
https://github.com/kvm-x86/kvm-unit-tests/tree/next