svn commit: r307565 - in head/sys/arm64: arm64 include

Andrew Turner andrew at FreeBSD.org
Tue Oct 18 13:39:57 UTC 2016


Author: andrew
Date: Tue Oct 18 13:39:55 2016
New Revision: 307565
URL: https://svnweb.freebsd.org/changeset/base/307565

Log:
  Add PCB_FP_USERMASK so we can mask off floating point flags that should
  not be sent to userspace, for example the future flag to tell when we are
  using floating point in the kernel.
  
  Obtained from:	ABT Systems Ltd
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/machdep.c
  head/sys/arm64/arm64/trap.c
  head/sys/arm64/include/pcb.h

Modified: head/sys/arm64/arm64/machdep.c
==============================================================================
--- head/sys/arm64/arm64/machdep.c	Tue Oct 18 13:37:59 2016	(r307564)
+++ head/sys/arm64/arm64/machdep.c	Tue Oct 18 13:39:55 2016	(r307565)
@@ -341,6 +341,8 @@ get_fpcontext(struct thread *td, mcontex
 
 		KASSERT(curpcb->pcb_fpusaved == &curpcb->pcb_fpustate,
 		    ("Called get_fpcontext while the kernel is using the VFP"));
+		KASSERT((curpcb->pcb_fpflags & ~PCB_FP_USERMASK) == 0,
+		    ("Non-userspace FPU flags set in get_fpcontext"));
 		memcpy(mcp->mc_fpregs.fp_q, curpcb->pcb_fpustate.vfp_regs,
 		    sizeof(mcp->mc_fpregs));
 		mcp->mc_fpregs.fp_cr = curpcb->pcb_fpustate.vfp_fpcr;
@@ -376,7 +378,7 @@ set_fpcontext(struct thread *td, mcontex
 		    sizeof(mcp->mc_fpregs));
 		curpcb->pcb_fpustate.vfp_fpcr = mcp->mc_fpregs.fp_cr;
 		curpcb->pcb_fpustate.vfp_fpsr = mcp->mc_fpregs.fp_sr;
-		curpcb->pcb_fpflags = mcp->mc_fpregs.fp_flags;
+		curpcb->pcb_fpflags = mcp->mc_fpregs.fp_flags & PCB_FP_USERMASK;
 	}
 
 	critical_exit();

Modified: head/sys/arm64/arm64/trap.c
==============================================================================
--- head/sys/arm64/arm64/trap.c	Tue Oct 18 13:37:59 2016	(r307564)
+++ head/sys/arm64/arm64/trap.c	Tue Oct 18 13:39:55 2016	(r307565)
@@ -409,6 +409,9 @@ do_el0_sync(struct trapframe *frame)
 		userret(td, frame);
 		break;
 	}
+
+	KASSERT((curthread->td_pcb->pcb_fpflags & ~PCB_FP_USERMASK) == 0,
+	    ("Kernel VFP flags set while entering userspace"));
 }
 
 void

Modified: head/sys/arm64/include/pcb.h
==============================================================================
--- head/sys/arm64/include/pcb.h	Tue Oct 18 13:37:59 2016	(r307564)
+++ head/sys/arm64/include/pcb.h	Tue Oct 18 13:39:55 2016	(r307565)
@@ -54,6 +54,8 @@ struct pcb {
 	struct vfpstate	*pcb_fpusaved;
 	int		pcb_fpflags;
 #define	PCB_FP_STARTED	0x01
+/* The bits passed to userspace in get_fpcontext */
+#define	PCB_FP_USERMASK	(PCB_FP_STARTED)
 	u_int		pcb_vfpcpu;	/* Last cpu this thread ran VFP code */
 
 	/*


More information about the svn-src-all mailing list