diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index 763c711ad8b3..305caae2e7bc 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -440,7 +440,7 @@ pmap_bootstrap(vm_paddr_t firstaddr) * CMAP1/CMAP2 are used for zeroing and copying pages. * CMAP3 is used for the boot-time memory test. */ - pc = pcpu_find(curcpu); + pc = get_pcpu(); mtx_init(&pc->pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF); SYSMAP(caddr_t, pc->pc_cmap_pte1, pc->pc_cmap_addr1, 1) SYSMAP(caddr_t, pc->pc_cmap_pte2, pc->pc_cmap_addr2, 1) @@ -4206,7 +4206,7 @@ pmap_zero_page(vm_page_t m) struct pcpu *pc; sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap_pte2 = pc->pc_cmap_pte2; mtx_lock(&pc->pc_cmap_lock); if (*cmap_pte2) @@ -4237,7 +4237,7 @@ pmap_zero_page_area(vm_page_t m, int off, int size) struct pcpu *pc; sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap_pte2 = pc->pc_cmap_pte2; mtx_lock(&pc->pc_cmap_lock); if (*cmap_pte2) @@ -4264,7 +4264,7 @@ pmap_copy_page(vm_page_t src, vm_page_t dst) struct pcpu *pc; sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap_pte1 = pc->pc_cmap_pte1; cmap_pte2 = pc->pc_cmap_pte2; mtx_lock(&pc->pc_cmap_lock); @@ -4299,7 +4299,7 @@ pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[], int cnt; sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap_pte1 = pc->pc_cmap_pte1; cmap_pte2 = pc->pc_cmap_pte2; mtx_lock(&pc->pc_cmap_lock); @@ -5288,7 +5288,7 @@ pmap_flush_page(vm_page_t m) useclflushopt = (cpu_stdext_feature & CPUID_STDEXT_CLFLUSHOPT) != 0; if (useclflushopt || (cpu_feature & CPUID_CLFSH) != 0) { sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap_pte2 = pc->pc_cmap_pte2; mtx_lock(&pc->pc_cmap_lock); if (*cmap_pte2) diff --git a/sys/i386/include/pcpu.h b/sys/i386/include/pcpu.h index 3110f9ffe7ab..1ec6f580ea0f 100644 --- a/sys/i386/include/pcpu.h +++ b/sys/i386/include/pcpu.h @@ -76,6 +76,7 @@ extern struct pcpu *pcpup; +#define get_pcpu() (pcpup) #define PCPU_GET(member) (pcpup->pc_ ## member) #define PCPU_ADD(member, val) (pcpup->pc_ ## member += (val)) #define PCPU_INC(member) PCPU_ADD(member, 1) @@ -196,6 +197,15 @@ extern struct pcpu *pcpup; } \ } while (0) +#define get_pcpu() __extension__ ({ \ + struct pcpu *__pc; \ + \ + __asm __volatile("movl %%fs:%1,%0" \ + : "=r" (__pc) \ + : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace)))); \ + __pc; \ +}) + #define PCPU_GET(member) __PCPU_GET(pc_ ## member) #define PCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val) #define PCPU_INC(member) __PCPU_INC(pc_ ## member)