diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 48d716a1f4ad..ca8cfd2714b0 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -1155,7 +1155,7 @@ static int processor_entry(proc_entry_ptr entry, int cpu) { /* check for usability */ - if ((cpu >= NCPU) || !(entry->cpu_flags & PROCENTRY_FLAG_EN)) + if (!(entry->cpu_flags & PROCENTRY_FLAG_EN)) return 0; /* check for BSP flag */ @@ -1167,11 +1167,13 @@ processor_entry(proc_entry_ptr entry, int cpu) } /* add another AP to list, if less than max number of CPUs */ - else { + else if (cpu < NCPU) { CPU_TO_ID(cpu) = entry->apic_id; ID_TO_CPU(entry->apic_id) = cpu; return 1; } + + return 0; } diff --git a/sys/amd64/amd64/mptable.c b/sys/amd64/amd64/mptable.c index 48d716a1f4ad..ca8cfd2714b0 100644 --- a/sys/amd64/amd64/mptable.c +++ b/sys/amd64/amd64/mptable.c @@ -1155,7 +1155,7 @@ static int processor_entry(proc_entry_ptr entry, int cpu) { /* check for usability */ - if ((cpu >= NCPU) || !(entry->cpu_flags & PROCENTRY_FLAG_EN)) + if (!(entry->cpu_flags & PROCENTRY_FLAG_EN)) return 0; /* check for BSP flag */ @@ -1167,11 +1167,13 @@ processor_entry(proc_entry_ptr entry, int cpu) } /* add another AP to list, if less than max number of CPUs */ - else { + else if (cpu < NCPU) { CPU_TO_ID(cpu) = entry->apic_id; ID_TO_CPU(entry->apic_id) = cpu; return 1; } + + return 0; } diff --git a/sys/amd64/include/mptable.h b/sys/amd64/include/mptable.h index 48d716a1f4ad..ca8cfd2714b0 100644 --- a/sys/amd64/include/mptable.h +++ b/sys/amd64/include/mptable.h @@ -1155,7 +1155,7 @@ static int processor_entry(proc_entry_ptr entry, int cpu) { /* check for usability */ - if ((cpu >= NCPU) || !(entry->cpu_flags & PROCENTRY_FLAG_EN)) + if (!(entry->cpu_flags & PROCENTRY_FLAG_EN)) return 0; /* check for BSP flag */ @@ -1167,11 +1167,13 @@ processor_entry(proc_entry_ptr entry, int cpu) } /* add another AP to list, if less than max number of CPUs */ - else { + else if (cpu < NCPU) { CPU_TO_ID(cpu) = entry->apic_id; ID_TO_CPU(entry->apic_id) = cpu; return 1; } + + return 0; } diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index 48d716a1f4ad..ca8cfd2714b0 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -1155,7 +1155,7 @@ static int processor_entry(proc_entry_ptr entry, int cpu) { /* check for usability */ - if ((cpu >= NCPU) || !(entry->cpu_flags & PROCENTRY_FLAG_EN)) + if (!(entry->cpu_flags & PROCENTRY_FLAG_EN)) return 0; /* check for BSP flag */ @@ -1167,11 +1167,13 @@ processor_entry(proc_entry_ptr entry, int cpu) } /* add another AP to list, if less than max number of CPUs */ - else { + else if (cpu < NCPU) { CPU_TO_ID(cpu) = entry->apic_id; ID_TO_CPU(entry->apic_id) = cpu; return 1; } + + return 0; } diff --git a/sys/i386/i386/mptable.c b/sys/i386/i386/mptable.c index 48d716a1f4ad..ca8cfd2714b0 100644 --- a/sys/i386/i386/mptable.c +++ b/sys/i386/i386/mptable.c @@ -1155,7 +1155,7 @@ static int processor_entry(proc_entry_ptr entry, int cpu) { /* check for usability */ - if ((cpu >= NCPU) || !(entry->cpu_flags & PROCENTRY_FLAG_EN)) + if (!(entry->cpu_flags & PROCENTRY_FLAG_EN)) return 0; /* check for BSP flag */ @@ -1167,11 +1167,13 @@ processor_entry(proc_entry_ptr entry, int cpu) } /* add another AP to list, if less than max number of CPUs */ - else { + else if (cpu < NCPU) { CPU_TO_ID(cpu) = entry->apic_id; ID_TO_CPU(entry->apic_id) = cpu; return 1; } + + return 0; } diff --git a/sys/i386/include/mpapic.h b/sys/i386/include/mpapic.h index a0099364a99f..4a387199381e 100644 --- a/sys/i386/include/mpapic.h +++ b/sys/i386/include/mpapic.h @@ -98,6 +98,8 @@ all_procs_ipi(int vector) static __inline int all_but_self_ipi(int vector) { + if (mp_ncpus <= 1) + return 0; return apic_ipi(APIC_DEST_ALLESELF, vector, APIC_DELMODE_FIXED); } diff --git a/sys/i386/include/mptable.h b/sys/i386/include/mptable.h index 48d716a1f4ad..ca8cfd2714b0 100644 --- a/sys/i386/include/mptable.h +++ b/sys/i386/include/mptable.h @@ -1155,7 +1155,7 @@ static int processor_entry(proc_entry_ptr entry, int cpu) { /* check for usability */ - if ((cpu >= NCPU) || !(entry->cpu_flags & PROCENTRY_FLAG_EN)) + if (!(entry->cpu_flags & PROCENTRY_FLAG_EN)) return 0; /* check for BSP flag */ @@ -1167,11 +1167,13 @@ processor_entry(proc_entry_ptr entry, int cpu) } /* add another AP to list, if less than max number of CPUs */ - else { + else if (cpu < NCPU) { CPU_TO_ID(cpu) = entry->apic_id; ID_TO_CPU(entry->apic_id) = cpu; return 1; } + + return 0; } diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 48d716a1f4ad..ca8cfd2714b0 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -1155,7 +1155,7 @@ static int processor_entry(proc_entry_ptr entry, int cpu) { /* check for usability */ - if ((cpu >= NCPU) || !(entry->cpu_flags & PROCENTRY_FLAG_EN)) + if (!(entry->cpu_flags & PROCENTRY_FLAG_EN)) return 0; /* check for BSP flag */ @@ -1167,11 +1167,13 @@ processor_entry(proc_entry_ptr entry, int cpu) } /* add another AP to list, if less than max number of CPUs */ - else { + else if (cpu < NCPU) { CPU_TO_ID(cpu) = entry->apic_id; ID_TO_CPU(entry->apic_id) = cpu; return 1; } + + return 0; }