From owner-svn-src-head@freebsd.org Fri Jan 17 19:02:00 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B0E661F79D4; Fri, 17 Jan 2020 19:02:00 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47zr5h1dL1z3xMH; Fri, 17 Jan 2020 19:02:00 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 334D4D947; Fri, 17 Jan 2020 19:02:00 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00HJ20Gr027302; Fri, 17 Jan 2020 19:02:00 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00HJ1xeg027296; Fri, 17 Jan 2020 19:01:59 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202001171901.00HJ1xeg027296@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 17 Jan 2020 19:01:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356839 - in head/sys: arm64/arm64 riscv/riscv X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in head/sys: arm64/arm64 riscv/riscv X-SVN-Commit-Revision: 356839 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jan 2020 19:02:00 -0000 Author: jhb Date: Fri Jan 17 19:01:59 2020 New Revision: 356839 URL: https://svnweb.freebsd.org/changeset/base/356839 Log: Save and restore floating point registers in get/set_mcontext(). arm64 and riscv were only saving and restoring floating point registers for sendsig() and sys_sigreturn(), but not for getcontext(), setcontext(), and swapcontext(). While here, remove an always-false check for uap being NULL from sys_sigreturn(). Reviewed by: br, mhorne Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D23218 Modified: head/sys/arm64/arm64/machdep.c head/sys/riscv/riscv/machdep.c Modified: head/sys/arm64/arm64/machdep.c ============================================================================== --- head/sys/arm64/arm64/machdep.c Fri Jan 17 17:57:34 2020 (r356838) +++ head/sys/arm64/arm64/machdep.c Fri Jan 17 19:01:59 2020 (r356839) @@ -98,6 +98,8 @@ __FBSDID("$FreeBSD$"); #include #endif +static void get_fpcontext(struct thread *td, mcontext_t *mcp); +static void set_fpcontext(struct thread *td, mcontext_t *mcp); enum arm64_bus arm64_bus_method = ARM64_BUS_NONE; @@ -473,6 +475,7 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int c mcp->mc_gpregs.gp_sp = tf->tf_sp; mcp->mc_gpregs.gp_lr = tf->tf_lr; mcp->mc_gpregs.gp_elr = tf->tf_elr; + get_fpcontext(td, mcp); return (0); } @@ -495,6 +498,7 @@ set_mcontext(struct thread *td, mcontext_t *mcp) tf->tf_lr = mcp->mc_gpregs.gp_lr; tf->tf_elr = mcp->mc_gpregs.gp_elr; tf->tf_spsr = mcp->mc_gpregs.gp_spsr; + set_fpcontext(td, mcp); return (0); } @@ -667,15 +671,12 @@ sys_sigreturn(struct thread *td, struct sigreturn_args ucontext_t uc; int error; - if (uap == NULL) - return (EFAULT); if (copyin(uap->sigcntxp, &uc, sizeof(uc))) return (EFAULT); error = set_mcontext(td, &uc.uc_mcontext); if (error != 0) return (error); - set_fpcontext(td, &uc.uc_mcontext); /* Restore signal mask. */ kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0); @@ -747,7 +748,6 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask /* Fill in the frame to copy out */ bzero(&frame, sizeof(frame)); get_mcontext(td, &frame.sf_uc.uc_mcontext, 0); - get_fpcontext(td, &frame.sf_uc.uc_mcontext); frame.sf_si = ksi->ksi_info; frame.sf_uc.uc_sigmask = *mask; frame.sf_uc.uc_stack = td->td_sigstk; Modified: head/sys/riscv/riscv/machdep.c ============================================================================== --- head/sys/riscv/riscv/machdep.c Fri Jan 17 17:57:34 2020 (r356838) +++ head/sys/riscv/riscv/machdep.c Fri Jan 17 19:01:59 2020 (r356839) @@ -99,6 +99,9 @@ __FBSDID("$FreeBSD$"); #include #endif +static void get_fpcontext(struct thread *td, mcontext_t *mcp); +static void set_fpcontext(struct thread *td, mcontext_t *mcp); + struct pcpu __pcpu[MAXCPU]; static struct trapframe proc0_tf; @@ -352,6 +355,7 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int c mcp->mc_gpregs.gp_tp = tf->tf_tp; mcp->mc_gpregs.gp_sepc = tf->tf_sepc; mcp->mc_gpregs.gp_sstatus = tf->tf_sstatus; + get_fpcontext(td, mcp); return (0); } @@ -372,6 +376,7 @@ set_mcontext(struct thread *td, mcontext_t *mcp) tf->tf_gp = mcp->mc_gpregs.gp_gp; tf->tf_sepc = mcp->mc_gpregs.gp_sepc; tf->tf_sstatus = mcp->mc_gpregs.gp_sstatus; + set_fpcontext(td, mcp); return (0); } @@ -522,8 +527,6 @@ sys_sigreturn(struct thread *td, struct sigreturn_args ucontext_t uc; int error; - if (uap == NULL) - return (EFAULT); if (copyin(uap->sigcntxp, &uc, sizeof(uc))) return (EFAULT); @@ -540,8 +543,6 @@ sys_sigreturn(struct thread *td, struct sigreturn_args if (error != 0) return (error); - set_fpcontext(td, &uc.uc_mcontext); - /* Restore signal mask. */ kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0); @@ -612,7 +613,6 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask /* Fill in the frame to copy out */ bzero(&frame, sizeof(frame)); get_mcontext(td, &frame.sf_uc.uc_mcontext, 0); - get_fpcontext(td, &frame.sf_uc.uc_mcontext); frame.sf_si = ksi->ksi_info; frame.sf_uc.uc_sigmask = *mask; frame.sf_uc.uc_stack = td->td_sigstk;