From 95d84e5461140ffbf1ec9e22daac7d5d2a2544dc Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Mon, 24 Oct 2005 20:52:26 +0000 Subject: [PATCH] Use xchg in Xcpustop to close a race and make cpustop_restartfunc truly one-shot in the SMP case (before using the simple mov / cmp / mov sequence could allow multiple CPUs to execute the restart function on resume). --- sys/amd64/amd64/apic_vector.S | 5 +++-- sys/i386/i386/apic_vector.s | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/amd64/amd64/apic_vector.S b/sys/amd64/amd64/apic_vector.S index 5d7685b1d6a0..2e7e445348d3 100644 --- a/sys/amd64/amd64/apic_vector.S +++ b/sys/amd64/amd64/apic_vector.S @@ -297,10 +297,11 @@ IDTVEC(cpustop) test %eax, %eax jnz 2f - movq cpustop_restartfunc, %rax + xorq %rax, %rax + lock + xchgq cpustop_restartfunc, %rax testq %rax, %rax jz 2f - movq $0, cpustop_restartfunc /* One-shot */ call *%rax 2: diff --git a/sys/i386/i386/apic_vector.s b/sys/i386/i386/apic_vector.s index 99b765f1519c..e8f6f9d73887 100644 --- a/sys/i386/i386/apic_vector.s +++ b/sys/i386/i386/apic_vector.s @@ -340,10 +340,11 @@ IDTVEC(cpustop) test %eax, %eax jnz 2f - movl CNAME(cpustop_restartfunc), %eax + xorl %eax, %eax + lock + xchgl CNAME(cpustop_restartfunc), %eax test %eax, %eax jz 2f - movl $0, CNAME(cpustop_restartfunc) /* One-shot */ call *%eax 2: