Deleted Added
full compact
machdep.c (208621) machdep.c (208833)
1/*-
2 * Copyright (c) 1992 Terrence R. Lambert.
3 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * William Jolitz.
8 *

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

33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
38 */
39
40#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1992 Terrence R. Lambert.
3 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * William Jolitz.
8 *

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

33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
38 */
39
40#include <sys/cdefs.h>
41__FBSDID("$FreeBSD: head/sys/i386/i386/machdep.c 208621 2010-05-28 17:50:24Z jhb $");
41__FBSDID("$FreeBSD: head/sys/i386/i386/machdep.c 208833 2010-06-05 15:59:59Z kib $");
42
43#include "opt_apic.h"
44#include "opt_atalk.h"
45#include "opt_compat.h"
46#include "opt_cpu.h"
47#include "opt_ddb.h"
48#include "opt_inet.h"
49#include "opt_ipx.h"

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

3180}
3181#endif /* CPU_ENABLE_SSE */
3182
3183int
3184fill_fpregs(struct thread *td, struct fpreg *fpregs)
3185{
3186#ifdef CPU_ENABLE_SSE
3187 if (cpu_fxsr) {
42
43#include "opt_apic.h"
44#include "opt_atalk.h"
45#include "opt_compat.h"
46#include "opt_cpu.h"
47#include "opt_ddb.h"
48#include "opt_inet.h"
49#include "opt_ipx.h"

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

3180}
3181#endif /* CPU_ENABLE_SSE */
3182
3183int
3184fill_fpregs(struct thread *td, struct fpreg *fpregs)
3185{
3186#ifdef CPU_ENABLE_SSE
3187 if (cpu_fxsr) {
3188 fill_fpregs_xmm(&td->td_pcb->pcb_save.sv_xmm,
3188 fill_fpregs_xmm(&td->td_pcb->pcb_user_save.sv_xmm,
3189 (struct save87 *)fpregs);
3190 return (0);
3191 }
3192#endif /* CPU_ENABLE_SSE */
3189 (struct save87 *)fpregs);
3190 return (0);
3191 }
3192#endif /* CPU_ENABLE_SSE */
3193 bcopy(&td->td_pcb->pcb_save.sv_87, fpregs, sizeof *fpregs);
3193 bcopy(&td->td_pcb->pcb_user_save.sv_87, fpregs, sizeof *fpregs);
3194 return (0);
3195}
3196
3197int
3198set_fpregs(struct thread *td, struct fpreg *fpregs)
3199{
3200#ifdef CPU_ENABLE_SSE
3201 if (cpu_fxsr) {
3202 set_fpregs_xmm((struct save87 *)fpregs,
3194 return (0);
3195}
3196
3197int
3198set_fpregs(struct thread *td, struct fpreg *fpregs)
3199{
3200#ifdef CPU_ENABLE_SSE
3201 if (cpu_fxsr) {
3202 set_fpregs_xmm((struct save87 *)fpregs,
3203 &td->td_pcb->pcb_save.sv_xmm);
3203 &td->td_pcb->pcb_user_save.sv_xmm);
3204 return (0);
3205 }
3206#endif /* CPU_ENABLE_SSE */
3204 return (0);
3205 }
3206#endif /* CPU_ENABLE_SSE */
3207 bcopy(fpregs, &td->td_pcb->pcb_save.sv_87, sizeof *fpregs);
3207 bcopy(fpregs, &td->td_pcb->pcb_user_save.sv_87, sizeof *fpregs);
3208 return (0);
3209}
3210
3211/*
3212 * Get machine context.
3213 */
3214int
3215get_mcontext(struct thread *td, mcontext_t *mcp, int flags)

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

3326#ifdef CPU_ENABLE_SSE
3327 cpu_fxsr &&
3328#endif
3329 ((uintptr_t)(void *)addr & 0xF)) {
3330 do
3331 addr = (void *)((char *)addr + 4);
3332 while ((uintptr_t)(void *)addr & 0xF);
3333 }
3208 return (0);
3209}
3210
3211/*
3212 * Get machine context.
3213 */
3214int
3215get_mcontext(struct thread *td, mcontext_t *mcp, int flags)

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

3326#ifdef CPU_ENABLE_SSE
3327 cpu_fxsr &&
3328#endif
3329 ((uintptr_t)(void *)addr & 0xF)) {
3330 do
3331 addr = (void *)((char *)addr + 4);
3332 while ((uintptr_t)(void *)addr & 0xF);
3333 }
3334 mcp->mc_ownedfp = npxgetregs(td, addr);
3334 mcp->mc_ownedfp = npxgetuserregs(td, addr);
3335 if (addr != (union savefpu *)&mcp->mc_fpstate) {
3336 bcopy(addr, &mcp->mc_fpstate, sizeof(mcp->mc_fpstate));
3337 bzero(&mcp->mc_spare2, sizeof(mcp->mc_spare2));
3338 }
3339 mcp->mc_fpformat = npxformat();
3340#endif
3341}
3342

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

3371#ifdef CPU_ENABLE_SSE
3372 if (cpu_fxsr)
3373 addr->sv_xmm.sv_env.en_mxcsr &= cpu_mxcsr_mask;
3374#endif
3375 /*
3376 * XXX we violate the dubious requirement that npxsetregs()
3377 * be called with interrupts disabled.
3378 */
3335 if (addr != (union savefpu *)&mcp->mc_fpstate) {
3336 bcopy(addr, &mcp->mc_fpstate, sizeof(mcp->mc_fpstate));
3337 bzero(&mcp->mc_spare2, sizeof(mcp->mc_spare2));
3338 }
3339 mcp->mc_fpformat = npxformat();
3340#endif
3341}
3342

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

3371#ifdef CPU_ENABLE_SSE
3372 if (cpu_fxsr)
3373 addr->sv_xmm.sv_env.en_mxcsr &= cpu_mxcsr_mask;
3374#endif
3375 /*
3376 * XXX we violate the dubious requirement that npxsetregs()
3377 * be called with interrupts disabled.
3378 */
3379 npxsetregs(td, addr);
3379 npxsetuserregs(td, addr);
3380#endif
3381 /*
3382 * Don't bother putting things back where they were in the
3383 * misaligned case, since we know that the caller won't use
3384 * them again.
3385 */
3386 } else
3387 return (EINVAL);
3388 return (0);
3389}
3390
3391static void
3392fpstate_drop(struct thread *td)
3393{
3394 register_t s;
3395
3380#endif
3381 /*
3382 * Don't bother putting things back where they were in the
3383 * misaligned case, since we know that the caller won't use
3384 * them again.
3385 */
3386 } else
3387 return (EINVAL);
3388 return (0);
3389}
3390
3391static void
3392fpstate_drop(struct thread *td)
3393{
3394 register_t s;
3395
3396 KASSERT(PCB_USER_FPU(td->td_pcb), ("fpstate_drop: kernel-owned fpu"));
3396 s = intr_disable();
3397#ifdef DEV_NPX
3398 if (PCPU_GET(fpcurthread) == td)
3399 npxdrop();
3400#endif
3401 /*
3402 * XXX force a full drop of the npx. The above only drops it if we
3403 * owned it. npxgetregs() has the same bug in the !cpu_fxsr case.
3404 *
3405 * XXX I don't much like npxgetregs()'s semantics of doing a full
3406 * drop. Dropping only to the pcb matches fnsave's behaviour.
3407 * We only need to drop to !PCB_INITDONE in sendsig(). But
3408 * sendsig() is the only caller of npxgetregs()... perhaps we just
3409 * have too many layers.
3410 */
3397 s = intr_disable();
3398#ifdef DEV_NPX
3399 if (PCPU_GET(fpcurthread) == td)
3400 npxdrop();
3401#endif
3402 /*
3403 * XXX force a full drop of the npx. The above only drops it if we
3404 * owned it. npxgetregs() has the same bug in the !cpu_fxsr case.
3405 *
3406 * XXX I don't much like npxgetregs()'s semantics of doing a full
3407 * drop. Dropping only to the pcb matches fnsave's behaviour.
3408 * We only need to drop to !PCB_INITDONE in sendsig(). But
3409 * sendsig() is the only caller of npxgetregs()... perhaps we just
3410 * have too many layers.
3411 */
3411 curthread->td_pcb->pcb_flags &= ~PCB_NPXINITDONE;
3412 curthread->td_pcb->pcb_flags &= ~(PCB_NPXINITDONE |
3413 PCB_NPXUSERINITDONE);
3412 intr_restore(s);
3413}
3414
3415int
3416fill_dbregs(struct thread *td, struct dbreg *dbregs)
3417{
3418 struct pcb *pcb;
3419

--- 293 unchanged lines hidden ---
3414 intr_restore(s);
3415}
3416
3417int
3418fill_dbregs(struct thread *td, struct dbreg *dbregs)
3419{
3420 struct pcb *pcb;
3421

--- 293 unchanged lines hidden ---