From owner-svn-src-all@FreeBSD.ORG Sat Jan 31 21:43:49 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DA008E30; Sat, 31 Jan 2015 21:43:49 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BA603E6A; Sat, 31 Jan 2015 21:43:49 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t0VLhnf4020794; Sat, 31 Jan 2015 21:43:49 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t0VLhlSq020782; Sat, 31 Jan 2015 21:43:47 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201501312143.t0VLhlSq020782@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 31 Jan 2015 21:43:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278001 - in head/sys: amd64/amd64 amd64/ia32 arm/arm i386/i386 mips/mips powerpc/powerpc sparc64/sparc64 sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Jan 2015 21:43:50 -0000 Author: kib Date: Sat Jan 31 21:43:46 2015 New Revision: 278001 URL: https://svnweb.freebsd.org/changeset/base/278001 Log: Do not qualify the mcontext_t *mcp argument for set_mcontext(9) as const. On x86, even after the machine context is supposedly read into the struct ucontext, lazy FPU state save code might only mark the FPU data as hardware-owned. Later, set_fpcontext() needs to fetch the state from hardware, modifying the *mcp. The set_mcontext(9) is called from sigreturn(2) and setcontext(2) implementations and old create_thread(2) interface, which throw the *mcp out after the set_mcontext() call. Reported by: dim Discussed with: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/amd64/amd64/machdep.c head/sys/amd64/ia32/ia32_signal.c head/sys/arm/arm/machdep.c head/sys/i386/i386/machdep.c head/sys/mips/mips/freebsd32_machdep.c head/sys/mips/mips/pm_machdep.c head/sys/powerpc/powerpc/exec_machdep.c head/sys/sparc64/sparc64/machdep.c head/sys/sys/ucontext.h Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Sat Jan 31 21:31:53 2015 (r278000) +++ head/sys/amd64/amd64/machdep.c Sat Jan 31 21:43:46 2015 (r278001) @@ -157,7 +157,7 @@ extern u_int64_t hammer_time(u_int64_t, static void cpu_startup(void *); static void get_fpcontext(struct thread *td, mcontext_t *mcp, char *xfpusave, size_t xfpusave_len); -static int set_fpcontext(struct thread *td, const mcontext_t *mcp, +static int set_fpcontext(struct thread *td, mcontext_t *mcp, char *xfpustate, size_t xfpustate_len); SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL); @@ -2480,7 +2480,7 @@ get_mcontext(struct thread *td, mcontext * touch the cs selector. */ int -set_mcontext(struct thread *td, const mcontext_t *mcp) +set_mcontext(struct thread *td, mcontext_t *mcp) { struct pcb *pcb; struct trapframe *tp; @@ -2567,7 +2567,7 @@ get_fpcontext(struct thread *td, mcontex } static int -set_fpcontext(struct thread *td, const mcontext_t *mcp, char *xfpustate, +set_fpcontext(struct thread *td, mcontext_t *mcp, char *xfpustate, size_t xfpustate_len) { struct savefpu *fpstate; Modified: head/sys/amd64/ia32/ia32_signal.c ============================================================================== --- head/sys/amd64/ia32/ia32_signal.c Sat Jan 31 21:31:53 2015 (r278000) +++ head/sys/amd64/ia32/ia32_signal.c Sat Jan 31 21:43:46 2015 (r278001) @@ -118,7 +118,7 @@ ia32_get_fpcontext(struct thread *td, st } static int -ia32_set_fpcontext(struct thread *td, const struct ia32_mcontext *mcp, +ia32_set_fpcontext(struct thread *td, struct ia32_mcontext *mcp, char *xfpustate, size_t xfpustate_len) { int error; @@ -197,7 +197,7 @@ ia32_get_mcontext(struct thread *td, str * touch the cs selector. */ static int -ia32_set_mcontext(struct thread *td, const struct ia32_mcontext *mcp) +ia32_set_mcontext(struct thread *td, struct ia32_mcontext *mcp) { struct trapframe *tp; char *xfpustate; Modified: head/sys/arm/arm/machdep.c ============================================================================== --- head/sys/arm/arm/machdep.c Sat Jan 31 21:31:53 2015 (r278000) +++ head/sys/arm/arm/machdep.c Sat Jan 31 21:43:46 2015 (r278001) @@ -700,7 +700,7 @@ get_mcontext(struct thread *td, mcontext * touch the cs selector. */ int -set_mcontext(struct thread *td, const mcontext_t *mcp) +set_mcontext(struct thread *td, mcontext_t *mcp) { struct trapframe *tf = td->td_frame; const __greg_t *gr = mcp->__gregs; Modified: head/sys/i386/i386/machdep.c ============================================================================== --- head/sys/i386/i386/machdep.c Sat Jan 31 21:31:53 2015 (r278000) +++ head/sys/i386/i386/machdep.c Sat Jan 31 21:43:46 2015 (r278001) @@ -195,7 +195,7 @@ static void cpu_startup(void *); static void fpstate_drop(struct thread *td); static void get_fpcontext(struct thread *td, mcontext_t *mcp, char *xfpusave, size_t xfpusave_len); -static int set_fpcontext(struct thread *td, const mcontext_t *mcp, +static int set_fpcontext(struct thread *td, mcontext_t *mcp, char *xfpustate, size_t xfpustate_len); #ifdef CPU_ENABLE_SSE static void set_fpregs_xmm(struct save87 *, struct savexmm *); @@ -3856,7 +3856,7 @@ get_mcontext(struct thread *td, mcontext * touch the cs selector. */ int -set_mcontext(struct thread *td, const mcontext_t *mcp) +set_mcontext(struct thread *td, mcontext_t *mcp) { struct trapframe *tp; char *xfpustate; @@ -3934,7 +3934,7 @@ get_fpcontext(struct thread *td, mcontex } static int -set_fpcontext(struct thread *td, const mcontext_t *mcp, char *xfpustate, +set_fpcontext(struct thread *td, mcontext_t *mcp, char *xfpustate, size_t xfpustate_len) { union savefpu *fpstate; Modified: head/sys/mips/mips/freebsd32_machdep.c ============================================================================== --- head/sys/mips/mips/freebsd32_machdep.c Sat Jan 31 21:31:53 2015 (r278000) +++ head/sys/mips/mips/freebsd32_machdep.c Sat Jan 31 21:43:46 2015 (r278001) @@ -68,7 +68,7 @@ static void freebsd32_exec_setregs(struct thread *, struct image_params *, u_long); static int get_mcontext32(struct thread *, mcontext32_t *, int); -static int set_mcontext32(struct thread *, const mcontext32_t *); +static int set_mcontext32(struct thread *, mcontext32_t *); static void freebsd32_sendsig(sig_t, ksiginfo_t *, sigset_t *); extern const char *freebsd32_syscallnames[]; @@ -227,7 +227,7 @@ get_mcontext32(struct thread *td, mconte } static int -set_mcontext32(struct thread *td, const mcontext32_t *mcp) +set_mcontext32(struct thread *td, mcontext32_t *mcp) { mcontext_t mcp64; unsigned i; Modified: head/sys/mips/mips/pm_machdep.c ============================================================================== --- head/sys/mips/mips/pm_machdep.c Sat Jan 31 21:31:53 2015 (r278000) +++ head/sys/mips/mips/pm_machdep.c Sat Jan 31 21:43:46 2015 (r278001) @@ -375,7 +375,7 @@ get_mcontext(struct thread *td, mcontext } int -set_mcontext(struct thread *td, const mcontext_t *mcp) +set_mcontext(struct thread *td, mcontext_t *mcp) { struct trapframe *tp; Modified: head/sys/powerpc/powerpc/exec_machdep.c ============================================================================== --- head/sys/powerpc/powerpc/exec_machdep.c Sat Jan 31 21:31:53 2015 (r278000) +++ head/sys/powerpc/powerpc/exec_machdep.c Sat Jan 31 21:43:46 2015 (r278001) @@ -442,7 +442,7 @@ get_mcontext(struct thread *td, mcontext } int -set_mcontext(struct thread *td, const mcontext_t *mcp) +set_mcontext(struct thread *td, mcontext_t *mcp) { struct pcb *pcb; struct trapframe *tf; @@ -739,7 +739,7 @@ get_mcontext32(struct thread *td, mconte } static int -set_mcontext32(struct thread *td, const mcontext32_t *mcp) +set_mcontext32(struct thread *td, mcontext32_t *mcp) { mcontext_t mcp64; int i, error; Modified: head/sys/sparc64/sparc64/machdep.c ============================================================================== --- head/sys/sparc64/sparc64/machdep.c Sat Jan 31 21:31:53 2015 (r278000) +++ head/sys/sparc64/sparc64/machdep.c Sat Jan 31 21:43:46 2015 (r278001) @@ -811,7 +811,7 @@ get_mcontext(struct thread *td, mcontext } int -set_mcontext(struct thread *td, const mcontext_t *mc) +set_mcontext(struct thread *td, mcontext_t *mc) { struct trapframe *tf; struct pcb *pcb; Modified: head/sys/sys/ucontext.h ============================================================================== --- head/sys/sys/ucontext.h Sat Jan 31 21:31:53 2015 (r278000) +++ head/sys/sys/ucontext.h Sat Jan 31 21:43:46 2015 (r278001) @@ -99,7 +99,7 @@ struct thread; /* Machine-dependent functions: */ int get_mcontext(struct thread *, mcontext_t *, int); -int set_mcontext(struct thread *, const mcontext_t *); +int set_mcontext(struct thread *, mcontext_t *); #endif /* !_KERNEL */