Date: Thu, 10 Jun 2010 20:55:07 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 179438 for review Message-ID: <201006102055.o5AKt7bp077213@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@179438?ac=10 Change 179438 by jhb@jhb_jhbbsd on 2010/06/10 20:54:07 IFC @179436 Affected files ... .. //depot/projects/smpng/share/man/man9/make_dev.9#4 integrate .. //depot/projects/smpng/sys/amd64/acpica/acpi_wakeup.c#11 integrate .. //depot/projects/smpng/sys/amd64/amd64/cpu_switch.S#27 integrate .. //depot/projects/smpng/sys/amd64/amd64/fpu.c#15 integrate .. //depot/projects/smpng/sys/amd64/amd64/io_apic.c#27 delete .. //depot/projects/smpng/sys/amd64/amd64/machdep.c#92 integrate .. //depot/projects/smpng/sys/amd64/amd64/mca.c#7 delete .. //depot/projects/smpng/sys/amd64/amd64/mp_machdep.c#62 integrate .. //depot/projects/smpng/sys/amd64/amd64/msi.c#17 delete .. //depot/projects/smpng/sys/amd64/amd64/pmap.c#106 integrate .. //depot/projects/smpng/sys/amd64/amd64/trap.c#74 integrate .. //depot/projects/smpng/sys/amd64/amd64/vm_machdep.c#47 integrate .. //depot/projects/smpng/sys/amd64/ia32/ia32_reg.c#7 integrate .. //depot/projects/smpng/sys/amd64/include/fpu.h#6 integrate .. //depot/projects/smpng/sys/amd64/include/pcb.h#19 integrate .. //depot/projects/smpng/sys/amd64/linux32/linux32_machdep.c#34 integrate .. //depot/projects/smpng/sys/arm/arm/pmap.c#59 integrate .. //depot/projects/smpng/sys/boot/i386/boot0/Makefile#15 integrate .. //depot/projects/smpng/sys/boot/i386/btx/btx/Makefile#9 integrate .. //depot/projects/smpng/sys/boot/i386/btx/btxldr/Makefile#8 integrate .. //depot/projects/smpng/sys/boot/i386/cdboot/Makefile#7 integrate .. //depot/projects/smpng/sys/boot/i386/mbr/Makefile#9 integrate .. //depot/projects/smpng/sys/boot/i386/pmbr/Makefile#2 integrate .. //depot/projects/smpng/sys/boot/pc98/boot0.5/Makefile#5 integrate .. //depot/projects/smpng/sys/boot/pc98/boot0/Makefile#4 integrate .. //depot/projects/smpng/sys/boot/pc98/btx/btx/Makefile#10 integrate .. //depot/projects/smpng/sys/boot/pc98/btx/btxldr/Makefile#8 integrate .. //depot/projects/smpng/sys/boot/pc98/cdboot/Makefile#2 integrate .. //depot/projects/smpng/sys/boot/sparc64/boot1/Makefile#9 integrate .. //depot/projects/smpng/sys/cam/ata/ata_pmp.c#4 integrate .. //depot/projects/smpng/sys/cam/ata/ata_xpt.c#8 integrate .. //depot/projects/smpng/sys/cam/cam_debug.h#4 integrate .. //depot/projects/smpng/sys/cam/cam_periph.c#37 integrate .. //depot/projects/smpng/sys/cam/cam_xpt.c#67 integrate .. //depot/projects/smpng/sys/cam/cam_xpt_internal.h#5 integrate .. //depot/projects/smpng/sys/cam/scsi/scsi_all.c#31 integrate .. //depot/projects/smpng/sys/cam/scsi/scsi_all.h#16 integrate .. //depot/projects/smpng/sys/cam/scsi/scsi_cd.c#44 integrate .. //depot/projects/smpng/sys/cam/scsi/scsi_ch.h#4 integrate .. //depot/projects/smpng/sys/cam/scsi/scsi_da.c#91 integrate .. //depot/projects/smpng/sys/cam/scsi/scsi_xpt.c#6 integrate .. //depot/projects/smpng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c#8 integrate .. //depot/projects/smpng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c#6 integrate .. //depot/projects/smpng/sys/conf/NOTES#185 integrate .. //depot/projects/smpng/sys/conf/files#260 integrate .. //depot/projects/smpng/sys/conf/files.amd64#76 integrate .. //depot/projects/smpng/sys/conf/files.i386#134 integrate .. //depot/projects/smpng/sys/conf/files.pc98#104 integrate .. //depot/projects/smpng/sys/conf/files.powerpc#58 integrate .. //depot/projects/smpng/sys/conf/options#183 integrate .. //depot/projects/smpng/sys/contrib/libfdt/libfdt_env.h#2 integrate .. //depot/projects/smpng/sys/crypto/via/padlock.c#15 integrate .. //depot/projects/smpng/sys/crypto/via/padlock.h#3 integrate .. //depot/projects/smpng/sys/crypto/via/padlock_cipher.c#3 integrate .. //depot/projects/smpng/sys/crypto/via/padlock_hash.c#4 integrate .. //depot/projects/smpng/sys/dev/acpica/acpi.c#122 integrate .. //depot/projects/smpng/sys/dev/acpica/acpi_ec.c#51 integrate .. //depot/projects/smpng/sys/dev/ahci/ahci.c#9 integrate .. //depot/projects/smpng/sys/dev/ata/ata-all.h#69 integrate .. //depot/projects/smpng/sys/dev/ata/ata-lowlevel.c#41 integrate .. //depot/projects/smpng/sys/dev/ata/atapi-cam.c#44 integrate .. //depot/projects/smpng/sys/dev/ata/chipsets/ata-acerlabs.c#10 integrate .. //depot/projects/smpng/sys/dev/ata/chipsets/ata-intel.c#10 integrate .. //depot/projects/smpng/sys/dev/ata/chipsets/ata-serverworks.c#8 integrate .. //depot/projects/smpng/sys/dev/bge/if_bge.c#115 integrate .. //depot/projects/smpng/sys/dev/bge/if_bgereg.h#64 integrate .. //depot/projects/smpng/sys/dev/cas/if_cas.c#6 integrate .. //depot/projects/smpng/sys/dev/cxgb/cxgb_main.c#31 integrate .. //depot/projects/smpng/sys/dev/fdt/fdt_common.c#1 branch .. //depot/projects/smpng/sys/dev/fdt/fdt_common.h#1 branch .. //depot/projects/smpng/sys/dev/fdt/fdt_pci.c#1 branch .. //depot/projects/smpng/sys/dev/fdt/fdt_static_dtb.S#1 branch .. //depot/projects/smpng/sys/dev/fdt/fdtbus.c#1 branch .. //depot/projects/smpng/sys/dev/fdt/simplebus.c#1 branch .. //depot/projects/smpng/sys/dev/hwpmc/hwpmc_mod.c#36 integrate .. //depot/projects/smpng/sys/dev/iicbus/iic.h#5 integrate .. //depot/projects/smpng/sys/dev/isp/isp.c#64 integrate .. //depot/projects/smpng/sys/dev/isp/isp_freebsd.c#67 integrate .. //depot/projects/smpng/sys/dev/isp/isp_library.c#16 integrate .. //depot/projects/smpng/sys/dev/isp/isp_pci.c#62 integrate .. //depot/projects/smpng/sys/dev/ixgbe/ixgbe.c#17 integrate .. //depot/projects/smpng/sys/dev/ixgbe/ixgbe.h#10 integrate .. //depot/projects/smpng/sys/dev/mvs/mvs.c#2 integrate .. //depot/projects/smpng/sys/dev/random/nehemiah.c#6 integrate .. //depot/projects/smpng/sys/dev/sge/if_sge.c#3 integrate .. //depot/projects/smpng/sys/dev/siis/siis.c#9 integrate .. //depot/projects/smpng/sys/dev/sound/pci/hda/hdac.c#44 integrate .. //depot/projects/smpng/sys/dev/twa/tw_cl.h#4 integrate .. //depot/projects/smpng/sys/dev/twa/tw_cl_fwif.h#4 integrate .. //depot/projects/smpng/sys/dev/twa/tw_cl_init.c#6 integrate .. //depot/projects/smpng/sys/dev/twa/tw_cl_intr.c#5 integrate .. //depot/projects/smpng/sys/dev/twa/tw_cl_io.c#6 integrate .. //depot/projects/smpng/sys/dev/twa/tw_cl_misc.c#5 integrate .. //depot/projects/smpng/sys/dev/twa/tw_cl_share.h#6 integrate .. //depot/projects/smpng/sys/dev/twa/tw_osl.h#7 integrate .. //depot/projects/smpng/sys/dev/twa/tw_osl_cam.c#13 integrate .. //depot/projects/smpng/sys/dev/twa/tw_osl_externs.h#3 integrate .. //depot/projects/smpng/sys/dev/twa/tw_osl_freebsd.c#14 integrate .. //depot/projects/smpng/sys/dev/twa/tw_osl_inline.h#4 integrate .. //depot/projects/smpng/sys/dev/twa/tw_osl_share.h#9 integrate .. //depot/projects/smpng/sys/dev/uart/uart_bus_fdt.c#1 branch .. //depot/projects/smpng/sys/dev/xen/netfront/netfront.c#15 integrate .. //depot/projects/smpng/sys/fs/devfs/devfs.h#22 integrate .. //depot/projects/smpng/sys/fs/devfs/devfs_devs.c#35 integrate .. //depot/projects/smpng/sys/fs/devfs/devfs_vnops.c#86 integrate .. //depot/projects/smpng/sys/geom/geom_event.c#35 integrate .. //depot/projects/smpng/sys/geom/geom_io.c#56 integrate .. //depot/projects/smpng/sys/geom/mountver/g_mountver.c#2 integrate .. //depot/projects/smpng/sys/geom/part/g_part_bsd.c#15 integrate .. //depot/projects/smpng/sys/geom/part/g_part_gpt.c#16 integrate .. //depot/projects/smpng/sys/i386/i386/io_apic.c#29 delete .. //depot/projects/smpng/sys/i386/i386/machdep.c#153 integrate .. //depot/projects/smpng/sys/i386/i386/mca.c#7 delete .. //depot/projects/smpng/sys/i386/i386/msi.c#17 delete .. //depot/projects/smpng/sys/i386/i386/pmap.c#145 integrate .. //depot/projects/smpng/sys/i386/i386/ptrace_machdep.c#5 integrate .. //depot/projects/smpng/sys/i386/i386/swtch.s#33 integrate .. //depot/projects/smpng/sys/i386/i386/trap.c#124 integrate .. //depot/projects/smpng/sys/i386/i386/vm_machdep.c#96 integrate .. //depot/projects/smpng/sys/i386/include/npx.h#11 integrate .. //depot/projects/smpng/sys/i386/include/pcb.h#16 integrate .. //depot/projects/smpng/sys/i386/include/pcpu.h#24 integrate .. //depot/projects/smpng/sys/i386/isa/npx.c#67 integrate .. //depot/projects/smpng/sys/i386/linux/linux_machdep.c#53 integrate .. //depot/projects/smpng/sys/i386/linux/linux_ptrace.c#16 integrate .. //depot/projects/smpng/sys/i386/xen/pmap.c#15 integrate .. //depot/projects/smpng/sys/ia64/ia64/pmap.c#99 integrate .. //depot/projects/smpng/sys/kern/kern_intr.c#104 integrate .. //depot/projects/smpng/sys/kern/kern_jail.c#82 integrate .. //depot/projects/smpng/sys/kern/kern_sx.c#63 integrate .. //depot/projects/smpng/sys/kern/posix4_mib.c#2 integrate .. //depot/projects/smpng/sys/kern/sched_4bsd.c#93 integrate .. //depot/projects/smpng/sys/kern/sched_ule.c#101 integrate .. //depot/projects/smpng/sys/kern/subr_acl_nfs4.c#5 integrate .. //depot/projects/smpng/sys/kern/subr_acl_posix1e.c#10 integrate .. //depot/projects/smpng/sys/kern/subr_bus.c#90 integrate .. //depot/projects/smpng/sys/kern/uipc_sem.c#32 integrate .. //depot/projects/smpng/sys/kern/uipc_shm.c#9 integrate .. //depot/projects/smpng/sys/kern/vfs_acl.c#12 integrate .. //depot/projects/smpng/sys/kern/vfs_bio.c#128 integrate .. //depot/projects/smpng/sys/kern/vfs_subr.c#178 integrate .. //depot/projects/smpng/sys/libkern/memchr.c#1 branch .. //depot/projects/smpng/sys/mips/mips/pmap.c#18 integrate .. //depot/projects/smpng/sys/modules/netgraph/Makefile#31 integrate .. //depot/projects/smpng/sys/modules/netgraph/patch/Makefile#1 branch .. //depot/projects/smpng/sys/modules/zfs/Makefile#14 integrate .. //depot/projects/smpng/sys/net/vnet.h#20 integrate .. //depot/projects/smpng/sys/netgraph/ng_patch.c#1 branch .. //depot/projects/smpng/sys/netgraph/ng_patch.h#1 branch .. //depot/projects/smpng/sys/netgraph/ng_pppoe.c#35 integrate .. //depot/projects/smpng/sys/netinet/ip_mroute.c#73 integrate .. //depot/projects/smpng/sys/netinet/ip_mroute.h#17 integrate .. //depot/projects/smpng/sys/netinet/pim_var.h#5 integrate .. //depot/projects/smpng/sys/netinet/sctp_auth.c#19 integrate .. //depot/projects/smpng/sys/netinet/sctp_bsd_addr.c#17 integrate .. //depot/projects/smpng/sys/netinet/sctp_constants.h#26 integrate .. //depot/projects/smpng/sys/netinet/sctp_indata.c#32 integrate .. //depot/projects/smpng/sys/netinet/sctp_input.c#34 integrate .. //depot/projects/smpng/sys/netinet/sctp_lock_bsd.h#10 integrate .. //depot/projects/smpng/sys/netinet/sctp_output.c#39 integrate .. //depot/projects/smpng/sys/netinet/sctp_pcb.c#38 integrate .. //depot/projects/smpng/sys/netinet/sctp_pcb.h#22 integrate .. //depot/projects/smpng/sys/netinet/sctp_sysctl.c#19 integrate .. //depot/projects/smpng/sys/netinet/sctp_usrreq.c#32 integrate .. //depot/projects/smpng/sys/netinet/sctputil.c#39 integrate .. //depot/projects/smpng/sys/opencrypto/crypto.c#19 integrate .. //depot/projects/smpng/sys/pc98/pc98/machdep.c#38 integrate .. //depot/projects/smpng/sys/powerpc/aim/mmu_oea.c#12 integrate .. //depot/projects/smpng/sys/powerpc/aim/mmu_oea64.c#9 integrate .. //depot/projects/smpng/sys/powerpc/booke/pmap.c#18 integrate .. //depot/projects/smpng/sys/powerpc/powermac/kiic.c#3 integrate .. //depot/projects/smpng/sys/powerpc/powermac/macgpio.c#4 integrate .. //depot/projects/smpng/sys/powerpc/powermac/smu.c#5 integrate .. //depot/projects/smpng/sys/powerpc/powermac/smusat.c#1 branch .. //depot/projects/smpng/sys/powerpc/powermac/uninorth.c#20 integrate .. //depot/projects/smpng/sys/powerpc/powerpc/intr_machdep.c#20 integrate .. //depot/projects/smpng/sys/sparc64/sparc64/pmap.c#86 integrate .. //depot/projects/smpng/sys/sun4v/sun4v/pmap.c#20 integrate .. //depot/projects/smpng/sys/sys/libkern.h#29 integrate .. //depot/projects/smpng/sys/sys/nlist_aout.h#4 integrate .. //depot/projects/smpng/sys/sys/param.h#162 integrate .. //depot/projects/smpng/sys/sys/pmc.h#21 integrate .. //depot/projects/smpng/sys/sys/posix4.h#2 integrate .. //depot/projects/smpng/sys/sys/proc.h#207 integrate .. //depot/projects/smpng/sys/sys/vtoc.h#4 integrate .. //depot/projects/smpng/sys/tools/fdt/embed_dtb.sh#1 branch .. //depot/projects/smpng/sys/tools/fdt/make_dtbh.sh#1 branch .. //depot/projects/smpng/sys/ufs/ufs/ufs_quota.c#44 integrate .. //depot/projects/smpng/sys/vm/vm_contig.c#54 integrate .. //depot/projects/smpng/sys/vm/vm_page.c#112 integrate .. //depot/projects/smpng/sys/vm/vm_page.h#49 integrate .. //depot/projects/smpng/sys/vm/vm_pageout.c#78 integrate .. //depot/projects/smpng/sys/vm/vm_pageout.h#19 integrate .. //depot/projects/smpng/sys/vm/vnode_pager.c#78 integrate .. //depot/projects/smpng/sys/x86/x86/io_apic.c#1 branch .. //depot/projects/smpng/sys/x86/x86/mca.c#1 branch .. //depot/projects/smpng/sys/x86/x86/msi.c#1 branch Differences ... ==== //depot/projects/smpng/share/man/man9/make_dev.9#4 (text+ko) ==== @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/share/man/man9/make_dev.9,v 1.28 2010/05/06 19:23:49 kib Exp $ +.\" $FreeBSD: src/share/man/man9/make_dev.9,v 1.29 2010/06/02 10:20:23 uqs Exp $ .\" .Dd May 6, 2010 .Dt MAKE_DEV 9 @@ -158,14 +158,14 @@ function is equivalent to the call .Bd -literal -offset indent make_dev_credf(0, cdevsw, unit, cr, uid, gid, perms, fmt, ...); -.Ed . +.Ed .Pp The .Fn make_dev function call is the same as .Bd -literal -offset indent make_dev_credf(0, cdevsw, unit, NULL, uid, gid, perms, fmt, ...); -.Ed . +.Ed .Pp The .Fn make_dev_alias @@ -245,7 +245,7 @@ function is the same as .Bd -literal -offset indent destroy_dev_sched(cdev, NULL, NULL); -.Ed . +.Ed .Pp The .Fn d_close ==== //depot/projects/smpng/sys/amd64/acpica/acpi_wakeup.c#11 (text+ko) ==== @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/acpica/acpi_wakeup.c,v 1.28 2009/11/04 22:39:18 jkim Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/acpica/acpi_wakeup.c,v 1.29 2010/06/05 15:59:59 kib Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -245,7 +245,7 @@ cr3 = rcr3(); load_cr3(KPML4phys); - stopfpu = &stopxpcbs[0]->xpcb_pcb.pcb_save; + stopfpu = stopxpcbs[0]->xpcb_pcb.pcb_save; if (acpi_savecpu(stopxpcbs[0])) { fpugetregs(curthread, stopfpu); ==== //depot/projects/smpng/sys/amd64/amd64/cpu_switch.S#27 (text+ko) ==== @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/amd64/amd64/cpu_switch.S,v 1.169 2009/07/09 09:34:11 kib Exp $ + * $FreeBSD: src/sys/amd64/amd64/cpu_switch.S,v 1.170 2010/06/05 15:59:59 kib Exp $ */ #include <machine/asmacros.h> @@ -116,7 +116,7 @@ /* have we used fp, and need a save? */ cmpq %rdi,PCPU(FPCURTHREAD) jne 1f - addq $PCB_SAVEFPU,%r8 + movq PCB_SAVEFPU(%r8),%r8 clts fxsave (%r8) smsw %ax @@ -341,7 +341,7 @@ je 1f movq TD_PCB(%rax),%rdi - leaq PCB_SAVEFPU(%rdi),%rdi + movq PCB_SAVEFPU(%rdi),%rdi clts fxsave (%rdi) smsw %ax @@ -349,7 +349,7 @@ lmsw %ax movq $PCB_SAVEFPU_SIZE,%rdx /* arg 3 */ - leaq PCB_SAVEFPU(%rcx),%rsi /* arg 2 */ + movq PCB_SAVEFPU(%rcx),%rsi /* arg 2 */ /* arg 1 (%rdi) already loaded */ call bcopy 1: ==== //depot/projects/smpng/sys/amd64/amd64/fpu.c#15 (text+ko) ==== @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/amd64/fpu.c,v 1.165 2009/03/25 22:08:30 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/amd64/fpu.c,v 1.167 2010/06/06 16:13:50 kib Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -91,8 +91,8 @@ #endif /* __GNUCLIKE_ASM && !lint */ -#define GET_FPU_CW(thread) ((thread)->td_pcb->pcb_save.sv_env.en_cw) -#define GET_FPU_SW(thread) ((thread)->td_pcb->pcb_save.sv_env.en_sw) +#define GET_FPU_CW(thread) ((thread)->td_pcb->pcb_save->sv_env.en_cw) +#define GET_FPU_SW(thread) ((thread)->td_pcb->pcb_save->sv_env.en_sw) typedef u_char bool_t; @@ -146,7 +146,7 @@ savecrit = intr_disable(); if (curthread == PCPU_GET(fpcurthread)) { stop_emulating(); - fxsave(&PCPU_GET(curpcb)->pcb_save); + fxsave(PCPU_GET(curpcb)->pcb_save); start_emulating(); PCPU_SET(fpcurthread, 0); } @@ -424,8 +424,10 @@ if (pcb->pcb_initial_fpucw != __INITIAL_FPUCW__) fldcw(&pcb->pcb_initial_fpucw); pcb->pcb_flags |= PCB_FPUINITDONE; + if (PCB_USER_FPU(pcb)) + pcb->pcb_flags |= PCB_USERFPUINITDONE; } else - fxrstor(&pcb->pcb_save); + fxrstor(pcb->pcb_save); intr_restore(s); } @@ -449,13 +451,39 @@ * It returns the FPU ownership status. */ int +fpugetuserregs(struct thread *td, struct savefpu *addr) +{ + struct pcb *pcb; + register_t s; + + pcb = td->td_pcb; + if ((pcb->pcb_flags & PCB_USERFPUINITDONE) == 0) { + bcopy(&fpu_initialstate, addr, sizeof(fpu_initialstate)); + addr->sv_env.en_cw = pcb->pcb_initial_fpucw; + return (_MC_FPOWNED_NONE); + } + s = intr_disable(); + if (td == PCPU_GET(fpcurthread) && PCB_USER_FPU(pcb)) { + fxsave(addr); + intr_restore(s); + return (_MC_FPOWNED_FPU); + } else { + intr_restore(s); + bcopy(&pcb->pcb_user_save, addr, sizeof(*addr)); + return (_MC_FPOWNED_PCB); + } +} + +int fpugetregs(struct thread *td, struct savefpu *addr) { + struct pcb *pcb; register_t s; - if ((td->td_pcb->pcb_flags & PCB_FPUINITDONE) == 0) { + pcb = td->td_pcb; + if ((pcb->pcb_flags & PCB_FPUINITDONE) == 0) { bcopy(&fpu_initialstate, addr, sizeof(fpu_initialstate)); - addr->sv_env.en_cw = td->td_pcb->pcb_initial_fpucw; + addr->sv_env.en_cw = pcb->pcb_initial_fpucw; return (_MC_FPOWNED_NONE); } s = intr_disable(); @@ -465,7 +493,7 @@ return (_MC_FPOWNED_FPU); } else { intr_restore(s); - bcopy(&td->td_pcb->pcb_save, addr, sizeof(*addr)); + bcopy(pcb->pcb_save, addr, sizeof(*addr)); return (_MC_FPOWNED_PCB); } } @@ -474,19 +502,44 @@ * Set the state of the FPU. */ void +fpusetuserregs(struct thread *td, struct savefpu *addr) +{ + struct pcb *pcb; + register_t s; + + pcb = td->td_pcb; + s = intr_disable(); + if (td == PCPU_GET(fpcurthread) && PCB_USER_FPU(pcb)) { + fxrstor(addr); + intr_restore(s); + pcb->pcb_flags |= PCB_FPUINITDONE | PCB_USERFPUINITDONE; + } else { + intr_restore(s); + bcopy(addr, &td->td_pcb->pcb_user_save, sizeof(*addr)); + if (PCB_USER_FPU(pcb)) + pcb->pcb_flags |= PCB_FPUINITDONE; + pcb->pcb_flags |= PCB_USERFPUINITDONE; + } +} + +void fpusetregs(struct thread *td, struct savefpu *addr) { + struct pcb *pcb; register_t s; + pcb = td->td_pcb; s = intr_disable(); if (td == PCPU_GET(fpcurthread)) { fxrstor(addr); intr_restore(s); } else { intr_restore(s); - bcopy(addr, &td->td_pcb->pcb_save, sizeof(*addr)); + bcopy(addr, td->td_pcb->pcb_save, sizeof(*addr)); } - curthread->td_pcb->pcb_flags |= PCB_FPUINITDONE; + if (PCB_USER_FPU(pcb)) + pcb->pcb_flags |= PCB_USERFPUINITDONE; + pcb->pcb_flags |= PCB_FPUINITDONE; } /* @@ -575,3 +628,74 @@ DRIVER_MODULE(fpupnp, acpi, fpupnp_driver, fpupnp_devclass, 0, 0); #endif /* DEV_ISA */ + +int +fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags) +{ + struct pcb *pcb; + + pcb = td->td_pcb; + KASSERT(!PCB_USER_FPU(pcb) || pcb->pcb_save == &pcb->pcb_user_save, + ("mangled pcb_save")); + ctx->flags = 0; + if ((pcb->pcb_flags & PCB_FPUINITDONE) != 0) + ctx->flags |= FPU_KERN_CTX_FPUINITDONE; + fpuexit(td); + ctx->prev = pcb->pcb_save; + pcb->pcb_save = &ctx->hwstate; + pcb->pcb_flags |= PCB_KERNFPU; + pcb->pcb_flags &= ~PCB_FPUINITDONE; + return (0); +} + +int +fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx) +{ + struct pcb *pcb; + register_t savecrit; + + pcb = td->td_pcb; + savecrit = intr_disable(); + if (curthread == PCPU_GET(fpcurthread)) + fpudrop(); + intr_restore(savecrit); + pcb->pcb_save = ctx->prev; + if (pcb->pcb_save == &pcb->pcb_user_save) { + if ((pcb->pcb_flags & PCB_USERFPUINITDONE) != 0) + pcb->pcb_flags |= PCB_FPUINITDONE; + else + pcb->pcb_flags &= ~PCB_FPUINITDONE; + pcb->pcb_flags &= ~PCB_KERNFPU; + } else { + if ((ctx->flags & FPU_KERN_CTX_FPUINITDONE) != 0) + pcb->pcb_flags |= PCB_FPUINITDONE; + else + pcb->pcb_flags &= ~PCB_FPUINITDONE; + KASSERT(!PCB_USER_FPU(pcb), ("unpaired fpu_kern_leave")); + } + return (0); +} + +int +fpu_kern_thread(u_int flags) +{ + struct pcb *pcb; + + pcb = PCPU_GET(curpcb); + KASSERT((curthread->td_pflags & TDP_KTHREAD) != 0, + ("Only kthread may use fpu_kern_thread")); + KASSERT(pcb->pcb_save == &pcb->pcb_user_save, ("mangled pcb_save")); + KASSERT(PCB_USER_FPU(pcb), ("recursive call")); + + pcb->pcb_flags |= PCB_KERNFPU; + return (0); +} + +int +is_fpu_kern_thread(u_int flags) +{ + + if ((curthread->td_pflags & TDP_KTHREAD) == 0) + return (0); + return ((PCPU_GET(curpcb)->pcb_flags & PCB_KERNFPU) != 0); +} ==== //depot/projects/smpng/sys/amd64/amd64/machdep.c#92 (text+ko) ==== @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/amd64/machdep.c,v 1.717 2010/05/28 17:50:24 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/amd64/machdep.c,v 1.718 2010/06/05 15:59:59 kib Exp $"); #include "opt_atalk.h" #include "opt_atpic.h" @@ -1960,7 +1960,7 @@ fill_fpregs(struct thread *td, struct fpreg *fpregs) { - fill_fpregs_xmm(&td->td_pcb->pcb_save, fpregs); + fill_fpregs_xmm(&td->td_pcb->pcb_user_save, fpregs); return (0); } @@ -1969,7 +1969,7 @@ set_fpregs(struct thread *td, struct fpreg *fpregs) { - set_fpregs_xmm(fpregs, &td->td_pcb->pcb_save); + set_fpregs_xmm(fpregs, &td->td_pcb->pcb_user_save); return (0); } @@ -2084,7 +2084,8 @@ get_fpcontext(struct thread *td, mcontext_t *mcp) { - mcp->mc_ownedfp = fpugetregs(td, (struct savefpu *)&mcp->mc_fpstate); + mcp->mc_ownedfp = fpugetuserregs(td, + (struct savefpu *)&mcp->mc_fpstate); mcp->mc_fpformat = fpuformat(); } @@ -2109,7 +2110,7 @@ */ fpstate = (struct savefpu *)&mcp->mc_fpstate; fpstate->sv_env.en_mxcsr &= cpu_mxcsr_mask; - fpusetregs(td, fpstate); + fpusetuserregs(td, fpstate); } else return (EINVAL); return (0); @@ -2120,6 +2121,7 @@ { register_t s; + KASSERT(PCB_USER_FPU(td->td_pcb), ("fpstate_drop: kernel-owned fpu")); s = intr_disable(); if (PCPU_GET(fpcurthread) == td) fpudrop(); @@ -2133,7 +2135,8 @@ * sendsig() is the only caller of fpugetregs()... perhaps we just * have too many layers. */ - curthread->td_pcb->pcb_flags &= ~PCB_FPUINITDONE; + curthread->td_pcb->pcb_flags &= ~(PCB_FPUINITDONE | + PCB_USERFPUINITDONE); intr_restore(s); } ==== //depot/projects/smpng/sys/amd64/amd64/mp_machdep.c#62 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/amd64/mp_machdep.c,v 1.313 2010/05/24 11:40:49 mav Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/amd64/mp_machdep.c,v 1.314 2010/06/05 15:59:59 kib Exp $"); #include "opt_cpu.h" #include "opt_kstack_pages.h" @@ -1247,7 +1247,7 @@ rf = intr_disable(); cr3 = rcr3(); - stopfpu = &stopxpcbs[cpu]->xpcb_pcb.pcb_save; + stopfpu = stopxpcbs[cpu]->xpcb_pcb.pcb_save; if (savectx2(stopxpcbs[cpu])) { fpugetregs(curthread, stopfpu); wbinvd(); ==== //depot/projects/smpng/sys/amd64/amd64/pmap.c#106 (text+ko) ==== @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/amd64/pmap.c,v 1.703 2010/05/31 06:06:10 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/amd64/pmap.c,v 1.704 2010/06/10 16:56:35 alc Exp $"); /* * Manages physical address maps. @@ -3899,30 +3899,35 @@ struct md_page *pvh; pv_entry_t pv; int loops = 0; + boolean_t rv; - if (m->flags & PG_FICTITIOUS) - return (FALSE); - - mtx_assert(&vm_page_queue_mtx, MA_OWNED); + KASSERT((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) == 0, + ("pmap_page_exists_quick: page %p is not managed", m)); + rv = FALSE; + vm_page_lock_queues(); TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) { if (PV_PMAP(pv) == pmap) { - return (TRUE); + rv = TRUE; + break; } loops++; if (loops >= 16) break; } - if (loops < 16) { + if (!rv && loops < 16) { pvh = pa_to_pvh(VM_PAGE_TO_PHYS(m)); TAILQ_FOREACH(pv, &pvh->pv_list, pv_list) { - if (PV_PMAP(pv) == pmap) - return (TRUE); + if (PV_PMAP(pv) == pmap) { + rv = TRUE; + break; + } loops++; if (loops >= 16) break; } } - return (FALSE); + vm_page_unlock_queues(); + return (rv); } /* @@ -4335,10 +4340,10 @@ vm_offset_t va; int rtval = 0; - if (m->flags & PG_FICTITIOUS) - return (rtval); - mtx_assert(&vm_page_queue_mtx, MA_OWNED); + KASSERT((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) == 0, + ("pmap_ts_referenced: page %p is not managed", m)); pvh = pa_to_pvh(VM_PAGE_TO_PHYS(m)); + vm_page_lock_queues(); TAILQ_FOREACH_SAFE(pv, &pvh->pv_list, pv_list, pvn) { pmap = PV_PMAP(pv); PMAP_LOCK(pmap); @@ -4362,7 +4367,7 @@ rtval++; if (rtval > 4) { PMAP_UNLOCK(pmap); - return (rtval); + goto out; } } } @@ -4391,6 +4396,8 @@ PMAP_UNLOCK(pmap); } while ((pv = pvn) != NULL && pv != pvf); } +out: + vm_page_unlock_queues(); return (rtval); } ==== //depot/projects/smpng/sys/amd64/amd64/trap.c#74 (text+ko) ==== @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/amd64/trap.c,v 1.344 2010/05/23 18:32:02 kib Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/amd64/trap.c,v 1.345 2010/06/05 15:59:59 kib Exp $"); /* * AMD64 Trap and System call handling @@ -425,6 +425,8 @@ case T_DNA: /* transparent fault (due to context switch "late") */ + KASSERT(PCB_USER_FPU(td->td_pcb), + ("kernel FPU ctx has leaked")); fpudna(); goto userout; @@ -449,16 +451,19 @@ goto out; case T_DNA: + KASSERT(!PCB_USER_FPU(td->td_pcb), + ("Unregistered use of FPU in kernel")); + fpudna(); + goto out; + + case T_ARITHTRAP: /* arithmetic trap */ + case T_XMMFLT: /* SIMD floating-point exception */ + case T_FPOPFLT: /* FPU operand fetch fault */ /* - * The kernel is apparently using fpu for copying. - * XXX this should be fatal unless the kernel has - * registered such use. + * XXXKIB for now disable any FPU traps in kernel + * handler registration seems to be overkill */ - printf("fpudna in kernel mode!\n"); -#ifdef KDB - kdb_backtrace(); -#endif - fpudna(); + trap_fatal(frame, 0); goto out; case T_STKFLT: /* stack fault */ @@ -603,6 +608,8 @@ user: userret(td, frame); mtx_assert(&Giant, MA_NOTOWNED); + KASSERT(PCB_USER_FPU(td->td_pcb), + ("Return from trap with kernel FPU ctx leaked")); userout: out: return; @@ -891,5 +898,12 @@ trapsignal(td, &ksi); } + KASSERT(PCB_USER_FPU(td->td_pcb), + ("System call %s returing with kernel FPU ctx leaked", + syscallname(td->td_proc, sa.code))); + KASSERT(td->td_pcb->pcb_save == &td->td_pcb->pcb_user_save, + ("System call %s returning with mangled pcb_save", + syscallname(td->td_proc, sa.code))); + syscallret(td, error, &sa); } ==== //depot/projects/smpng/sys/amd64/amd64/vm_machdep.c#47 (text+ko) ==== @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/amd64/vm_machdep.c,v 1.268 2010/03/11 14:49:06 nwhitehorn Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/amd64/vm_machdep.c,v 1.269 2010/06/05 15:59:59 kib Exp $"); #include "opt_isa.h" #include "opt_cpu.h" @@ -122,7 +122,7 @@ return; } - /* Ensure that p1's pcb is up to date. */ + /* Ensure that td1's pcb is up to date. */ fpuexit(td1); /* Point the pcb to the top of the stack */ @@ -130,9 +130,12 @@ td2->td_kstack_pages * PAGE_SIZE) - 1; td2->td_pcb = pcb2; - /* Copy p1's pcb */ + /* Copy td1's pcb */ bcopy(td1->td_pcb, pcb2, sizeof(*pcb2)); + /* Properly initialize pcb_save */ + pcb2->pcb_save = &pcb2->pcb_user_save; + /* Point mdproc and then copy over td1's contents */ mdp2 = &p2->p_md; bcopy(&p1->p_md, mdp2, sizeof(*mdp2)); @@ -308,6 +311,7 @@ td->td_pcb = (struct pcb *)(td->td_kstack + td->td_kstack_pages * PAGE_SIZE) - 1; td->td_frame = (struct trapframe *)td->td_pcb - 1; + td->td_pcb->pcb_save = &td->td_pcb->pcb_user_save; } void @@ -381,7 +385,8 @@ * values here. */ bcopy(td0->td_pcb, pcb2, sizeof(*pcb2)); - pcb2->pcb_flags &= ~PCB_FPUINITDONE; + pcb2->pcb_flags &= ~(PCB_FPUINITDONE | PCB_USERFPUINITDONE); + pcb2->pcb_save = &pcb2->pcb_user_save; pcb2->pcb_full_iret = 1; /* ==== //depot/projects/smpng/sys/amd64/ia32/ia32_reg.c#7 (text+ko) ==== @@ -23,11 +23,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/amd64/ia32/ia32_reg.c,v 1.6 2010/01/24 12:13:38 trasz Exp $ + * $FreeBSD: src/sys/amd64/ia32/ia32_reg.c,v 1.7 2010/06/05 15:59:59 kib Exp $ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/ia32/ia32_reg.c,v 1.6 2010/01/24 12:13:38 trasz Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/ia32/ia32_reg.c,v 1.7 2010/06/05 15:59:59 kib Exp $"); #include "opt_compat.h" @@ -147,7 +147,7 @@ { struct save87 *sv_87 = (struct save87 *)regs; struct env87 *penv_87 = &sv_87->sv_env; - struct savefpu *sv_fpu = &td->td_pcb->pcb_save; + struct savefpu *sv_fpu = &td->td_pcb->pcb_user_save; struct envxmm *penv_xmm = &sv_fpu->sv_env; int i; @@ -182,7 +182,7 @@ { struct save87 *sv_87 = (struct save87 *)regs; struct env87 *penv_87 = &sv_87->sv_env; - struct savefpu *sv_fpu = &td->td_pcb->pcb_save; + struct savefpu *sv_fpu = &td->td_pcb->pcb_user_save; struct envxmm *penv_xmm = &sv_fpu->sv_env; int i; ==== //depot/projects/smpng/sys/amd64/include/fpu.h#6 (text+ko) ==== @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 - * $FreeBSD: src/sys/amd64/include/fpu.h,v 1.35 2009/03/05 16:56:16 jhb Exp $ + * $FreeBSD: src/sys/amd64/include/fpu.h,v 1.36 2010/06/05 15:59:59 kib Exp $ */ /* @@ -73,6 +73,17 @@ u_char sv_pad[96]; } __aligned(16); +#ifdef _KERNEL +struct fpu_kern_ctx { + struct savefpu hwstate; + struct savefpu *prev; + uint32_t flags; +}; +#define FPU_KERN_CTX_FPUINITDONE 0x01 + +#define PCB_USER_FPU(pcb) (((pcb)->pcb_flags & PCB_KERNFPU) == 0) +#endif + /* * The hardware default control word for i387's and later coprocessors is * 0x37F, giving: @@ -102,9 +113,22 @@ void fpuexit(struct thread *td); int fpuformat(void); int fpugetregs(struct thread *td, struct savefpu *addr); +int fpugetuserregs(struct thread *td, struct savefpu *addr); void fpuinit(void); void fpusetregs(struct thread *td, struct savefpu *addr); +void fpusetuserregs(struct thread *td, struct savefpu *addr); int fputrap(void); +int fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, + u_int flags); +int fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx); +int fpu_kern_thread(u_int flags); +int is_fpu_kern_thread(u_int flags); + +/* + * Flags for fpu_kern_enter() and fpu_kern_thread(). + */ +#define FPU_KERN_NORMAL 0x0000 + #endif #endif /* !_MACHINE_FPU_H_ */ ==== //depot/projects/smpng/sys/amd64/include/pcb.h#19 (text+ko) ==== @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)pcb.h 5.10 (Berkeley) 5/12/91 - * $FreeBSD: src/sys/amd64/include/pcb.h,v 1.72 2009/07/09 09:34:11 kib Exp $ + * $FreeBSD: src/sys/amd64/include/pcb.h,v 1.73 2010/06/05 15:59:59 kib Exp $ */ #ifndef _AMD64_PCB_H_ @@ -57,7 +57,9 @@ register_t pcb_gsbase; u_long pcb_flags; #define PCB_DBREGS 0x02 /* process using debug registers */ +#define PCB_KERNFPU 0x04 /* kernel uses fpu */ #define PCB_FPUINITDONE 0x08 /* fpu state is initialized */ +#define PCB_USERFPUINITDONE 0x10 /* fpu user state is initialized */ #define PCB_GS32BIT 0x20 /* linux gs switch */ #define PCB_32BIT 0x40 /* process has 32 bit context (segs etc) */ #define PCB_FULLCTX 0x80 /* full context restore on sysret */ @@ -69,7 +71,7 @@ u_int64_t pcb_dr6; u_int64_t pcb_dr7; - struct savefpu pcb_save; + struct savefpu pcb_user_save; uint16_t pcb_initial_fpucw; caddr_t pcb_onfault; /* copyin/out fault recovery */ @@ -78,6 +80,7 @@ struct user_segment_descriptor pcb_gs32sd; /* local tss, with i/o bitmap; NULL for common */ struct amd64tss *pcb_tssp; + struct savefpu *pcb_save; char pcb_full_iret; }; ==== //depot/projects/smpng/sys/amd64/linux32/linux32_machdep.c#34 (text+ko) ==== @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/linux32/linux32_machdep.c,v 1.54 2009/10/28 20:17:54 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/linux32/linux32_machdep.c,v 1.55 2010/06/10 17:59:47 kan Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -835,9 +835,13 @@ bsd_args.flags |= MAP_PRIVATE; if (flags & LINUX_MAP_FIXED) bsd_args.flags |= MAP_FIXED; - if (flags & LINUX_MAP_ANON) + if (flags & LINUX_MAP_ANON) { + /* Enforce pos to be on page boundary, then ignore. */ + if ((pos & PAGE_MASK) != 0) + return (EINVAL); + pos = 0; bsd_args.flags |= MAP_ANON; - else + } else bsd_args.flags |= MAP_NOSYNC; if (flags & LINUX_MAP_GROWSDOWN) bsd_args.flags |= MAP_STACK; ==== //depot/projects/smpng/sys/arm/arm/pmap.c#59 (text+ko) ==== @@ -140,7 +140,7 @@ #include "opt_vm.h" #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/arm/arm/pmap.c,v 1.126 2010/06/01 05:32:59 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/arm/arm/pmap.c,v 1.128 2010/06/10 16:56:35 alc Exp $"); #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> @@ -1423,7 +1423,7 @@ u_int oflags; int count = 0; - mtx_assert(&vm_page_queue_mtx, MA_OWNED); + vm_page_lock_queues(); if (maskbits & PVF_WRITE) maskbits |= PVF_MOD; @@ -1433,6 +1433,7 @@ pg->md.pvh_attrs &= ~(maskbits & (PVF_MOD | PVF_REF)); >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006102055.o5AKt7bp077213>