Deleted Added
full compact
mp_machdep.c (189509) mp_machdep.c (189903)
1/*-
2 * Copyright (c) 1996, by Steve Passe
3 * Copyright (c) 2003, by Peter Wemm
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1996, by Steve Passe
3 * Copyright (c) 2003, by Peter Wemm
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/amd64/amd64/mp_machdep.c 189509 2009-03-08 05:01:39Z sobomax $");
28__FBSDID("$FreeBSD: head/sys/amd64/amd64/mp_machdep.c 189903 2009-03-17 00:48:11Z jkim $");
29
30#include "opt_cpu.h"
31#include "opt_kstack_pages.h"
32#include "opt_mp_watchdog.h"
33#include "opt_sched.h"
34
35#include <sys/param.h>
36#include <sys/systm.h>

--- 16 unchanged lines hidden (view full) ---

53#include <vm/vm.h>
54#include <vm/vm_param.h>
55#include <vm/pmap.h>
56#include <vm/vm_kern.h>
57#include <vm/vm_extern.h>
58
59#include <machine/apicreg.h>
60#include <machine/cputypes.h>
29
30#include "opt_cpu.h"
31#include "opt_kstack_pages.h"
32#include "opt_mp_watchdog.h"
33#include "opt_sched.h"
34
35#include <sys/param.h>
36#include <sys/systm.h>

--- 16 unchanged lines hidden (view full) ---

53#include <vm/vm.h>
54#include <vm/vm_param.h>
55#include <vm/pmap.h>
56#include <vm/vm_kern.h>
57#include <vm/vm_extern.h>
58
59#include <machine/apicreg.h>
60#include <machine/cputypes.h>
61#include <machine/cpufunc.h>
61#include <machine/md_var.h>
62#include <machine/mp_watchdog.h>
63#include <machine/pcb.h>
64#include <machine/psl.h>
65#include <machine/smp.h>
66#include <machine/specialreg.h>
67#include <machine/tss.h>
68

--- 29 unchanged lines hidden (view full) ---

98extern pt_entry_t *KPTphys;
99
100/* SMP page table page */
101extern pt_entry_t *SMPpt;
102
103extern int _udatasel;
104
105struct pcb stoppcbs[MAXCPU];
62#include <machine/md_var.h>
63#include <machine/mp_watchdog.h>
64#include <machine/pcb.h>
65#include <machine/psl.h>
66#include <machine/smp.h>
67#include <machine/specialreg.h>
68#include <machine/tss.h>
69

--- 29 unchanged lines hidden (view full) ---

99extern pt_entry_t *KPTphys;
100
101/* SMP page table page */
102extern pt_entry_t *SMPpt;
103
104extern int _udatasel;
105
106struct pcb stoppcbs[MAXCPU];
107struct xpcb *stopxpcbs = NULL;
106
107/* Variables needed for SMP tlb shootdown. */
108vm_offset_t smp_tlb_addr1;
109vm_offset_t smp_tlb_addr2;
110volatile int smp_tlb_wait;
111
112extern inthand_t IDTVEC(fast_syscall), IDTVEC(fast_syscall32);
113

--- 225 unchanged lines hidden (view full) ---

339
340 /* Install generic inter-CPU IPI handler */
341 setidt(IPI_BITMAP_VECTOR, IDTVEC(ipi_intr_bitmap_handler),
342 SDT_SYSIGT, SEL_KPL, 0);
343
344 /* Install an inter-CPU IPI for CPU stop/restart */
345 setidt(IPI_STOP, IDTVEC(cpustop), SDT_SYSIGT, SEL_KPL, 0);
346
108
109/* Variables needed for SMP tlb shootdown. */
110vm_offset_t smp_tlb_addr1;
111vm_offset_t smp_tlb_addr2;
112volatile int smp_tlb_wait;
113
114extern inthand_t IDTVEC(fast_syscall), IDTVEC(fast_syscall32);
115

--- 225 unchanged lines hidden (view full) ---

341
342 /* Install generic inter-CPU IPI handler */
343 setidt(IPI_BITMAP_VECTOR, IDTVEC(ipi_intr_bitmap_handler),
344 SDT_SYSIGT, SEL_KPL, 0);
345
346 /* Install an inter-CPU IPI for CPU stop/restart */
347 setidt(IPI_STOP, IDTVEC(cpustop), SDT_SYSIGT, SEL_KPL, 0);
348
349 /* Install an inter-CPU IPI for CPU suspend/resume */
350 setidt(IPI_SUSPEND, IDTVEC(cpususpend), SDT_SYSIGT, SEL_KPL, 0);
351
347 /* Set boot_cpu_id if needed. */
348 if (boot_cpu_id == -1) {
349 boot_cpu_id = PCPU_GET(apic_id);
350 cpu_info[boot_cpu_id].cpu_bsp = 1;
351 } else
352 KASSERT(boot_cpu_id == PCPU_GET(apic_id),
353 ("BSP's APIC ID doesn't match boot_cpu_id"));
354 cpu_apic_ids[0] = boot_cpu_id;

--- 785 unchanged lines hidden (view full) ---

1140
1141 if (cpu == 0 && cpustop_restartfunc != NULL) {
1142 cpustop_restartfunc();
1143 cpustop_restartfunc = NULL;
1144 }
1145}
1146
1147/*
352 /* Set boot_cpu_id if needed. */
353 if (boot_cpu_id == -1) {
354 boot_cpu_id = PCPU_GET(apic_id);
355 cpu_info[boot_cpu_id].cpu_bsp = 1;
356 } else
357 KASSERT(boot_cpu_id == PCPU_GET(apic_id),
358 ("BSP's APIC ID doesn't match boot_cpu_id"));
359 cpu_apic_ids[0] = boot_cpu_id;

--- 785 unchanged lines hidden (view full) ---

1145
1146 if (cpu == 0 && cpustop_restartfunc != NULL) {
1147 cpustop_restartfunc();
1148 cpustop_restartfunc = NULL;
1149 }
1150}
1151
1152/*
1153 * Handle an IPI_SUSPEND by saving our current context and spinning until we
1154 * are resumed.
1155 */
1156void
1157cpususpend_handler(void)
1158{
1159 struct savefpu *stopfpu;
1160 register_t cr3, rf;
1161 int cpu = PCPU_GET(cpuid);
1162 int cpumask = PCPU_GET(cpumask);
1163
1164 rf = intr_disable();
1165 cr3 = rcr3();
1166 stopfpu = &stopxpcbs[cpu].xpcb_pcb.pcb_save;
1167 if (savectx2(&stopxpcbs[cpu])) {
1168 fpugetregs(curthread, stopfpu);
1169 wbinvd();
1170 atomic_set_int(&stopped_cpus, cpumask);
1171 } else
1172 fpusetregs(curthread, stopfpu);
1173
1174 /* Wait for resume */
1175 while (!(started_cpus & cpumask))
1176 ia32_pause();
1177
1178 atomic_clear_int(&started_cpus, cpumask);
1179 atomic_clear_int(&stopped_cpus, cpumask);
1180
1181 /* Restore CR3 and enable interrupts */
1182 load_cr3(cr3);
1183 lapic_setup(0);
1184 intr_restore(rf);
1185}
1186
1187/*
1148 * This is called once the rest of the system is up and running and we're
1149 * ready to let the AP's out of the pen.
1150 */
1151static void
1152release_aps(void *dummy __unused)
1153{
1154
1155 if (mp_ncpus == 1)

--- 154 unchanged lines hidden ---
1188 * This is called once the rest of the system is up and running and we're
1189 * ready to let the AP's out of the pen.
1190 */
1191static void
1192release_aps(void *dummy __unused)
1193{
1194
1195 if (mp_ncpus == 1)

--- 154 unchanged lines hidden ---