]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/amd64/amd64/mp_machdep.c
Update libc++ to 3.7.0 release.
[FreeBSD/FreeBSD.git] / sys / amd64 / amd64 / mp_machdep.c
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:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. The name of the developer may NOT be used to endorse or promote products
12  *    derived from this software without specific prior written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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$");
29
30 #include "opt_cpu.h"
31 #include "opt_ddb.h"
32 #include "opt_kstack_pages.h"
33 #include "opt_sched.h"
34 #include "opt_smp.h"
35
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/bus.h>
39 #include <sys/cpuset.h>
40 #ifdef GPROF 
41 #include <sys/gmon.h>
42 #endif
43 #include <sys/kernel.h>
44 #include <sys/ktr.h>
45 #include <sys/lock.h>
46 #include <sys/malloc.h>
47 #include <sys/memrange.h>
48 #include <sys/mutex.h>
49 #include <sys/pcpu.h>
50 #include <sys/proc.h>
51 #include <sys/sched.h>
52 #include <sys/smp.h>
53 #include <sys/sysctl.h>
54
55 #include <vm/vm.h>
56 #include <vm/vm_param.h>
57 #include <vm/pmap.h>
58 #include <vm/vm_kern.h>
59 #include <vm/vm_extern.h>
60
61 #include <x86/apicreg.h>
62 #include <machine/clock.h>
63 #include <machine/cputypes.h>
64 #include <machine/cpufunc.h>
65 #include <x86/mca.h>
66 #include <machine/md_var.h>
67 #include <machine/pcb.h>
68 #include <machine/psl.h>
69 #include <machine/smp.h>
70 #include <machine/specialreg.h>
71 #include <machine/tss.h>
72 #include <machine/cpu.h>
73 #include <x86/init.h>
74
75 #define WARMBOOT_TARGET         0
76 #define WARMBOOT_OFF            (KERNBASE + 0x0467)
77 #define WARMBOOT_SEG            (KERNBASE + 0x0469)
78
79 #define CMOS_REG                (0x70)
80 #define CMOS_DATA               (0x71)
81 #define BIOS_RESET              (0x0f)
82 #define BIOS_WARM               (0x0a)
83
84 extern  struct pcpu __pcpu[];
85
86 /* Temporary variables for init_secondary()  */
87 char *doublefault_stack;
88 char *nmi_stack;
89
90 /* Variables needed for SMP tlb shootdown. */
91 static vm_offset_t smp_tlb_addr1, smp_tlb_addr2;
92 static pmap_t smp_tlb_pmap;
93 volatile int smp_tlb_wait;
94
95 extern inthand_t IDTVEC(fast_syscall), IDTVEC(fast_syscall32);
96
97 /*
98  * Local data and functions.
99  */
100
101 static int      start_ap(int apic_id);
102
103 static u_int    bootMP_size;
104 static u_int    boot_address;
105
106 /*
107  * Calculate usable address in base memory for AP trampoline code.
108  */
109 u_int
110 mp_bootaddress(u_int basemem)
111 {
112
113         bootMP_size = mptramp_end - mptramp_start;
114         boot_address = trunc_page(basemem * 1024); /* round down to 4k boundary */
115         if (((basemem * 1024) - boot_address) < bootMP_size)
116                 boot_address -= PAGE_SIZE;      /* not enough, lower by 4k */
117         /* 3 levels of page table pages */
118         mptramp_pagetables = boot_address - (PAGE_SIZE * 3);
119
120         return mptramp_pagetables;
121 }
122
123 /*
124  * Initialize the IPI handlers and start up the AP's.
125  */
126 void
127 cpu_mp_start(void)
128 {
129         int i;
130
131         /* Initialize the logical ID to APIC ID table. */
132         for (i = 0; i < MAXCPU; i++) {
133                 cpu_apic_ids[i] = -1;
134                 cpu_ipi_pending[i] = 0;
135         }
136
137         /* Install an inter-CPU IPI for TLB invalidation */
138         if (pmap_pcid_enabled) {
139                 if (invpcid_works) {
140                         setidt(IPI_INVLTLB, IDTVEC(invltlb_invpcid),
141                             SDT_SYSIGT, SEL_KPL, 0);
142                 } else {
143                         setidt(IPI_INVLTLB, IDTVEC(invltlb_pcid), SDT_SYSIGT,
144                             SEL_KPL, 0);
145                 }
146         } else {
147                 setidt(IPI_INVLTLB, IDTVEC(invltlb), SDT_SYSIGT, SEL_KPL, 0);
148         }
149         setidt(IPI_INVLPG, IDTVEC(invlpg), SDT_SYSIGT, SEL_KPL, 0);
150         setidt(IPI_INVLRNG, IDTVEC(invlrng), SDT_SYSIGT, SEL_KPL, 0);
151
152         /* Install an inter-CPU IPI for cache invalidation. */
153         setidt(IPI_INVLCACHE, IDTVEC(invlcache), SDT_SYSIGT, SEL_KPL, 0);
154
155         /* Install an inter-CPU IPI for all-CPU rendezvous */
156         setidt(IPI_RENDEZVOUS, IDTVEC(rendezvous), SDT_SYSIGT, SEL_KPL, 0);
157
158         /* Install generic inter-CPU IPI handler */
159         setidt(IPI_BITMAP_VECTOR, IDTVEC(ipi_intr_bitmap_handler),
160                SDT_SYSIGT, SEL_KPL, 0);
161
162         /* Install an inter-CPU IPI for CPU stop/restart */
163         setidt(IPI_STOP, IDTVEC(cpustop), SDT_SYSIGT, SEL_KPL, 0);
164
165         /* Install an inter-CPU IPI for CPU suspend/resume */
166         setidt(IPI_SUSPEND, IDTVEC(cpususpend), SDT_SYSIGT, SEL_KPL, 0);
167
168         /* Set boot_cpu_id if needed. */
169         if (boot_cpu_id == -1) {
170                 boot_cpu_id = PCPU_GET(apic_id);
171                 cpu_info[boot_cpu_id].cpu_bsp = 1;
172         } else
173                 KASSERT(boot_cpu_id == PCPU_GET(apic_id),
174                     ("BSP's APIC ID doesn't match boot_cpu_id"));
175
176         /* Probe logical/physical core configuration. */
177         topo_probe();
178
179         assign_cpu_ids();
180
181         /* Start each Application Processor */
182         init_ops.start_all_aps();
183
184         set_interrupt_apic_ids();
185 }
186
187
188 /*
189  * AP CPU's call this to initialize themselves.
190  */
191 void
192 init_secondary(void)
193 {
194         struct pcpu *pc;
195         struct nmi_pcpu *np;
196         u_int64_t msr, cr0;
197         int cpu, gsel_tss, x;
198         struct region_descriptor ap_gdt;
199
200         /* Set by the startup code for us to use */
201         cpu = bootAP;
202
203         /* Init tss */
204         common_tss[cpu] = common_tss[0];
205         common_tss[cpu].tss_rsp0 = 0;   /* not used until after switch */
206         common_tss[cpu].tss_iobase = sizeof(struct amd64tss) +
207             IOPERM_BITMAP_SIZE;
208         common_tss[cpu].tss_ist1 = (long)&doublefault_stack[PAGE_SIZE];
209
210         /* The NMI stack runs on IST2. */
211         np = ((struct nmi_pcpu *) &nmi_stack[PAGE_SIZE]) - 1;
212         common_tss[cpu].tss_ist2 = (long) np;
213
214         /* Prepare private GDT */
215         gdt_segs[GPROC0_SEL].ssd_base = (long) &common_tss[cpu];
216         for (x = 0; x < NGDT; x++) {
217                 if (x != GPROC0_SEL && x != (GPROC0_SEL + 1) &&
218                     x != GUSERLDT_SEL && x != (GUSERLDT_SEL + 1))
219                         ssdtosd(&gdt_segs[x], &gdt[NGDT * cpu + x]);
220         }
221         ssdtosyssd(&gdt_segs[GPROC0_SEL],
222             (struct system_segment_descriptor *)&gdt[NGDT * cpu + GPROC0_SEL]);
223         ap_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1;
224         ap_gdt.rd_base =  (long) &gdt[NGDT * cpu];
225         lgdt(&ap_gdt);                  /* does magic intra-segment return */
226
227         /* Get per-cpu data */
228         pc = &__pcpu[cpu];
229
230         /* prime data page for it to use */
231         pcpu_init(pc, cpu, sizeof(struct pcpu));
232         dpcpu_init(dpcpu, cpu);
233         pc->pc_apic_id = cpu_apic_ids[cpu];
234         pc->pc_prvspace = pc;
235         pc->pc_curthread = 0;
236         pc->pc_tssp = &common_tss[cpu];
237         pc->pc_commontssp = &common_tss[cpu];
238         pc->pc_rsp0 = 0;
239         pc->pc_tss = (struct system_segment_descriptor *)&gdt[NGDT * cpu +
240             GPROC0_SEL];
241         pc->pc_fs32p = &gdt[NGDT * cpu + GUFS32_SEL];
242         pc->pc_gs32p = &gdt[NGDT * cpu + GUGS32_SEL];
243         pc->pc_ldt = (struct system_segment_descriptor *)&gdt[NGDT * cpu +
244             GUSERLDT_SEL];
245         pc->pc_curpmap = kernel_pmap;
246         pc->pc_pcid_gen = 1;
247         pc->pc_pcid_next = PMAP_PCID_KERN + 1;
248
249         /* Save the per-cpu pointer for use by the NMI handler. */
250         np->np_pcpu = (register_t) pc;
251
252         wrmsr(MSR_FSBASE, 0);           /* User value */
253         wrmsr(MSR_GSBASE, (u_int64_t)pc);
254         wrmsr(MSR_KGSBASE, (u_int64_t)pc);      /* XXX User value while we're in the kernel */
255         intel_fix_cpuid();
256
257         lidt(&r_idt);
258
259         gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
260         ltr(gsel_tss);
261
262         /*
263          * Set to a known state:
264          * Set by mpboot.s: CR0_PG, CR0_PE
265          * Set by cpu_setregs: CR0_NE, CR0_MP, CR0_TS, CR0_WP, CR0_AM
266          */
267         cr0 = rcr0();
268         cr0 &= ~(CR0_CD | CR0_NW | CR0_EM);
269         load_cr0(cr0);
270
271         /* Set up the fast syscall stuff */
272         msr = rdmsr(MSR_EFER) | EFER_SCE;
273         wrmsr(MSR_EFER, msr);
274         wrmsr(MSR_LSTAR, (u_int64_t)IDTVEC(fast_syscall));
275         wrmsr(MSR_CSTAR, (u_int64_t)IDTVEC(fast_syscall32));
276         msr = ((u_int64_t)GSEL(GCODE_SEL, SEL_KPL) << 32) |
277               ((u_int64_t)GSEL(GUCODE32_SEL, SEL_UPL) << 48);
278         wrmsr(MSR_STAR, msr);
279         wrmsr(MSR_SF_MASK, PSL_NT|PSL_T|PSL_I|PSL_C|PSL_D);
280
281         /* signal our startup to the BSP. */
282         mp_naps++;
283
284         /* Spin until the BSP releases the AP's. */
285         while (atomic_load_acq_int(&aps_ready) == 0)
286                 ia32_pause();
287
288         init_secondary_tail();
289 }
290
291 /*******************************************************************
292  * local functions and data
293  */
294
295 /*
296  * start each AP in our list
297  */
298 int
299 native_start_all_aps(void)
300 {
301         vm_offset_t va = boot_address + KERNBASE;
302         u_int64_t *pt4, *pt3, *pt2;
303         u_int32_t mpbioswarmvec;
304         int apic_id, cpu, i;
305         u_char mpbiosreason;
306
307         mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN);
308
309         /* install the AP 1st level boot code */
310         pmap_kenter(va, boot_address);
311         pmap_invalidate_page(kernel_pmap, va);
312         bcopy(mptramp_start, (void *)va, bootMP_size);
313
314         /* Locate the page tables, they'll be below the trampoline */
315         pt4 = (u_int64_t *)(uintptr_t)(mptramp_pagetables + KERNBASE);
316         pt3 = pt4 + (PAGE_SIZE) / sizeof(u_int64_t);
317         pt2 = pt3 + (PAGE_SIZE) / sizeof(u_int64_t);
318
319         /* Create the initial 1GB replicated page tables */
320         for (i = 0; i < 512; i++) {
321                 /* Each slot of the level 4 pages points to the same level 3 page */
322                 pt4[i] = (u_int64_t)(uintptr_t)(mptramp_pagetables + PAGE_SIZE);
323                 pt4[i] |= PG_V | PG_RW | PG_U;
324
325                 /* Each slot of the level 3 pages points to the same level 2 page */
326                 pt3[i] = (u_int64_t)(uintptr_t)(mptramp_pagetables + (2 * PAGE_SIZE));
327                 pt3[i] |= PG_V | PG_RW | PG_U;
328
329                 /* The level 2 page slots are mapped with 2MB pages for 1GB. */
330                 pt2[i] = i * (2 * 1024 * 1024);
331                 pt2[i] |= PG_V | PG_RW | PG_PS | PG_U;
332         }
333
334         /* save the current value of the warm-start vector */
335         mpbioswarmvec = *((u_int32_t *) WARMBOOT_OFF);
336         outb(CMOS_REG, BIOS_RESET);
337         mpbiosreason = inb(CMOS_DATA);
338
339         /* setup a vector to our boot code */
340         *((volatile u_short *) WARMBOOT_OFF) = WARMBOOT_TARGET;
341         *((volatile u_short *) WARMBOOT_SEG) = (boot_address >> 4);
342         outb(CMOS_REG, BIOS_RESET);
343         outb(CMOS_DATA, BIOS_WARM);     /* 'warm-start' */
344
345         /* start each AP */
346         for (cpu = 1; cpu < mp_ncpus; cpu++) {
347                 apic_id = cpu_apic_ids[cpu];
348
349                 /* allocate and set up an idle stack data page */
350                 bootstacks[cpu] = (void *)kmem_malloc(kernel_arena,
351                     kstack_pages * PAGE_SIZE, M_WAITOK | M_ZERO);
352                 doublefault_stack = (char *)kmem_malloc(kernel_arena,
353                     PAGE_SIZE, M_WAITOK | M_ZERO);
354                 nmi_stack = (char *)kmem_malloc(kernel_arena, PAGE_SIZE,
355                     M_WAITOK | M_ZERO);
356                 dpcpu = (void *)kmem_malloc(kernel_arena, DPCPU_SIZE,
357                     M_WAITOK | M_ZERO);
358
359                 bootSTK = (char *)bootstacks[cpu] + kstack_pages * PAGE_SIZE - 8;
360                 bootAP = cpu;
361
362                 /* attempt to start the Application Processor */
363                 if (!start_ap(apic_id)) {
364                         /* restore the warmstart vector */
365                         *(u_int32_t *) WARMBOOT_OFF = mpbioswarmvec;
366                         panic("AP #%d (PHY# %d) failed!", cpu, apic_id);
367                 }
368
369                 CPU_SET(cpu, &all_cpus);        /* record AP in CPU map */
370         }
371
372         /* restore the warmstart vector */
373         *(u_int32_t *) WARMBOOT_OFF = mpbioswarmvec;
374
375         outb(CMOS_REG, BIOS_RESET);
376         outb(CMOS_DATA, mpbiosreason);
377
378         /* number of APs actually started */
379         return mp_naps;
380 }
381
382
383 /*
384  * This function starts the AP (application processor) identified
385  * by the APIC ID 'physicalCpu'.  It does quite a "song and dance"
386  * to accomplish this.  This is necessary because of the nuances
387  * of the different hardware we might encounter.  It isn't pretty,
388  * but it seems to work.
389  */
390 static int
391 start_ap(int apic_id)
392 {
393         int vector, ms;
394         int cpus;
395
396         /* calculate the vector */
397         vector = (boot_address >> 12) & 0xff;
398
399         /* used as a watchpoint to signal AP startup */
400         cpus = mp_naps;
401
402         ipi_startup(apic_id, vector);
403
404         /* Wait up to 5 seconds for it to start. */
405         for (ms = 0; ms < 5000; ms++) {
406                 if (mp_naps > cpus)
407                         return 1;       /* return SUCCESS */
408                 DELAY(1000);
409         }
410         return 0;               /* return FAILURE */
411 }
412
413 /*
414  * Flush the TLB on other CPU's
415  */
416
417 static void
418 smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector, pmap_t pmap,
419     vm_offset_t addr1, vm_offset_t addr2)
420 {
421         int cpu, ncpu, othercpus;
422
423         othercpus = mp_ncpus - 1;       /* does not shootdown self */
424
425         /*
426          * Check for other cpus.  Return if none.
427          */
428         if (CPU_ISFULLSET(&mask)) {
429                 if (othercpus < 1)
430                         return;
431         } else {
432                 CPU_CLR(PCPU_GET(cpuid), &mask);
433                 if (CPU_EMPTY(&mask))
434                         return;
435         }
436
437         if (!(read_rflags() & PSL_I))
438                 panic("%s: interrupts disabled", __func__);
439         mtx_lock_spin(&smp_ipi_mtx);
440         smp_tlb_addr1 = addr1;
441         smp_tlb_addr2 = addr2;
442         smp_tlb_pmap = pmap;
443         smp_tlb_wait =  0;
444         if (CPU_ISFULLSET(&mask)) {
445                 ncpu = othercpus;
446                 ipi_all_but_self(vector);
447         } else {
448                 ncpu = 0;
449                 while ((cpu = CPU_FFS(&mask)) != 0) {
450                         cpu--;
451                         CPU_CLR(cpu, &mask);
452                         CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__,
453                             cpu, vector);
454                         ipi_send_cpu(cpu, vector);
455                         ncpu++;
456                 }
457         }
458         while (smp_tlb_wait < ncpu)
459                 ia32_pause();
460         mtx_unlock_spin(&smp_ipi_mtx);
461 }
462
463 void
464 smp_masked_invltlb(cpuset_t mask, pmap_t pmap)
465 {
466
467         if (smp_started) {
468                 smp_targeted_tlb_shootdown(mask, IPI_INVLTLB, pmap, 0, 0);
469 #ifdef COUNT_XINVLTLB_HITS
470                 ipi_global++;
471 #endif
472         }
473 }
474
475 void
476 smp_masked_invlpg(cpuset_t mask, vm_offset_t addr)
477 {
478
479         if (smp_started) {
480                 smp_targeted_tlb_shootdown(mask, IPI_INVLPG, NULL, addr, 0);
481 #ifdef COUNT_XINVLTLB_HITS
482                 ipi_page++;
483 #endif
484         }
485 }
486
487 void
488 smp_masked_invlpg_range(cpuset_t mask, vm_offset_t addr1, vm_offset_t addr2)
489 {
490
491         if (smp_started) {
492                 smp_targeted_tlb_shootdown(mask, IPI_INVLRNG, NULL,
493                     addr1, addr2);
494 #ifdef COUNT_XINVLTLB_HITS
495                 ipi_range++;
496                 ipi_range_size += (addr2 - addr1) / PAGE_SIZE;
497 #endif
498         }
499 }
500
501 void
502 smp_cache_flush(void)
503 {
504
505         if (smp_started) {
506                 smp_targeted_tlb_shootdown(all_cpus, IPI_INVLCACHE, NULL,
507                     0, 0);
508         }
509 }
510
511 /*
512  * Handlers for TLB related IPIs
513  */
514 void
515 invltlb_handler(void)
516 {
517 #ifdef COUNT_XINVLTLB_HITS
518         xhits_gbl[PCPU_GET(cpuid)]++;
519 #endif /* COUNT_XINVLTLB_HITS */
520 #ifdef COUNT_IPIS
521         (*ipi_invltlb_counts[PCPU_GET(cpuid)])++;
522 #endif /* COUNT_IPIS */
523
524         invltlb();
525         atomic_add_int(&smp_tlb_wait, 1);
526 }
527
528 void
529 invltlb_invpcid_handler(void)
530 {
531         struct invpcid_descr d;
532
533 #ifdef COUNT_XINVLTLB_HITS
534         xhits_gbl[PCPU_GET(cpuid)]++;
535 #endif /* COUNT_XINVLTLB_HITS */
536 #ifdef COUNT_IPIS
537         (*ipi_invltlb_counts[PCPU_GET(cpuid)])++;
538 #endif /* COUNT_IPIS */
539
540         d.pcid = smp_tlb_pmap->pm_pcids[PCPU_GET(cpuid)].pm_pcid;
541         d.pad = 0;
542         d.addr = 0;
543         invpcid(&d, smp_tlb_pmap == kernel_pmap ? INVPCID_CTXGLOB :
544             INVPCID_CTX);
545         atomic_add_int(&smp_tlb_wait, 1);
546 }
547
548 void
549 invltlb_pcid_handler(void)
550 {
551 #ifdef COUNT_XINVLTLB_HITS
552         xhits_gbl[PCPU_GET(cpuid)]++;
553 #endif /* COUNT_XINVLTLB_HITS */
554 #ifdef COUNT_IPIS
555         (*ipi_invltlb_counts[PCPU_GET(cpuid)])++;
556 #endif /* COUNT_IPIS */
557
558         if (smp_tlb_pmap == kernel_pmap) {
559                 invltlb_globpcid();
560         } else {
561                 /*
562                  * The current pmap might not be equal to
563                  * smp_tlb_pmap.  The clearing of the pm_gen in
564                  * pmap_invalidate_all() takes care of TLB
565                  * invalidation when switching to the pmap on this
566                  * CPU.
567                  */
568                 if (PCPU_GET(curpmap) == smp_tlb_pmap) {
569                         load_cr3(smp_tlb_pmap->pm_cr3 |
570                             smp_tlb_pmap->pm_pcids[PCPU_GET(cpuid)].pm_pcid);
571                 }
572         }
573         atomic_add_int(&smp_tlb_wait, 1);
574 }
575
576 void
577 invlpg_handler(void)
578 {
579 #ifdef COUNT_XINVLTLB_HITS
580         xhits_pg[PCPU_GET(cpuid)]++;
581 #endif /* COUNT_XINVLTLB_HITS */
582 #ifdef COUNT_IPIS
583         (*ipi_invlpg_counts[PCPU_GET(cpuid)])++;
584 #endif /* COUNT_IPIS */
585
586         invlpg(smp_tlb_addr1);
587         atomic_add_int(&smp_tlb_wait, 1);
588 }
589
590 void
591 invlrng_handler(void)
592 {
593         vm_offset_t addr;
594
595 #ifdef COUNT_XINVLTLB_HITS
596         xhits_rng[PCPU_GET(cpuid)]++;
597 #endif /* COUNT_XINVLTLB_HITS */
598 #ifdef COUNT_IPIS
599         (*ipi_invlrng_counts[PCPU_GET(cpuid)])++;
600 #endif /* COUNT_IPIS */
601
602         addr = smp_tlb_addr1;
603         do {
604                 invlpg(addr);
605                 addr += PAGE_SIZE;
606         } while (addr < smp_tlb_addr2);
607
608         atomic_add_int(&smp_tlb_wait, 1);
609 }