From owner-svn-src-stable@FreeBSD.ORG Wed May 8 10:14:47 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 48E7ED94; Wed, 8 May 2013 10:14:47 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 3B1DA31F; Wed, 8 May 2013 10:14:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r48AElhB050898; Wed, 8 May 2013 10:14:47 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r48AElS3050897; Wed, 8 May 2013 10:14:47 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201305081014.r48AElS3050897@svn.freebsd.org> From: Konstantin Belousov Date: Wed, 8 May 2013 10:14:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250359 - stable/9/sys/amd64/amd64 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 May 2013 10:14:47 -0000 Author: kib Date: Wed May 8 10:14:46 2013 New Revision: 250359 URL: http://svnweb.freebsd.org/changeset/base/250359 Log: MFC r250153: Partially saved extended state must be handled always, i.e. for both fpu-owned context, and for pcb-saved one. More, the XSAVE could do partial save, same as XSAVEOPT, so qualifier for the handler should be use_xsave and not use_xsaveopt. Since xsave_area_desc is now needed regardless of the XSAVEOPT use, remove the write-only use_xsaveopt variable. Modified: stable/9/sys/amd64/amd64/fpu.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/amd64/amd64/fpu.c ============================================================================== --- stable/9/sys/amd64/amd64/fpu.c Wed May 8 10:11:31 2013 (r250358) +++ stable/9/sys/amd64/amd64/fpu.c Wed May 8 10:14:46 2013 (r250359) @@ -132,7 +132,6 @@ static void fpu_clean_state(void); SYSCTL_INT(_hw, HW_FLOATINGPT, floatingpoint, CTLFLAG_RD, NULL, 1, "Floating point instructions executed in hardware"); -static int use_xsaveopt; int use_xsave; /* non-static for cpu_switch.S */ uint64_t xsave_mask; /* the same */ static uma_zone_t fpu_save_area_zone; @@ -198,7 +197,6 @@ fpuinit_bsp1(void) * REX byte, and set the bit 4 of the r/m byte. */ ctx_switch_xsave[3] |= 0x10; - use_xsaveopt = 1; } } @@ -296,7 +294,7 @@ fpuinitstate(void *arg __unused) * Create a table describing the layout of the CPU Extended * Save Area. */ - if (use_xsaveopt) { + if (use_xsave) { max_ext_n = flsl(xsave_mask); xsave_area_desc = malloc(max_ext_n * sizeof(struct xsave_area_elm_descr), M_DEVBUF, M_WAITOK | M_ZERO); @@ -661,7 +659,7 @@ fpugetregs(struct thread *td) struct pcb *pcb; uint64_t *xstate_bv, bit; char *sa; - int max_ext_n, i; + int max_ext_n, i, owned; pcb = td->td_pcb; if ((pcb->pcb_flags & PCB_USERFPUINITDONE) == 0) { @@ -675,31 +673,31 @@ fpugetregs(struct thread *td) critical_enter(); if (td == PCPU_GET(fpcurthread) && PCB_USER_FPU(pcb)) { fpusave(get_pcb_user_save_pcb(pcb)); - critical_exit(); - return (_MC_FPOWNED_FPU); + owned = _MC_FPOWNED_FPU; } else { - critical_exit(); - if (use_xsaveopt) { - /* - * Handle partially saved state. - */ - sa = (char *)get_pcb_user_save_pcb(pcb); - xstate_bv = (uint64_t *)(sa + sizeof(struct savefpu) + - offsetof(struct xstate_hdr, xstate_bv)); - max_ext_n = flsl(xsave_mask); - for (i = 0; i < max_ext_n; i++) { - bit = 1 << i; - if ((*xstate_bv & bit) != 0) - continue; - bcopy((char *)fpu_initialstate + - xsave_area_desc[i].offset, - sa + xsave_area_desc[i].offset, - xsave_area_desc[i].size); - *xstate_bv |= bit; - } + owned = _MC_FPOWNED_PCB; + } + critical_exit(); + if (use_xsave) { + /* + * Handle partially saved state. + */ + sa = (char *)get_pcb_user_save_pcb(pcb); + xstate_bv = (uint64_t *)(sa + sizeof(struct savefpu) + + offsetof(struct xstate_hdr, xstate_bv)); + max_ext_n = flsl(xsave_mask); + for (i = 0; i < max_ext_n; i++) { + bit = 1 << i; + if ((*xstate_bv & bit) != 0) + continue; + bcopy((char *)fpu_initialstate + + xsave_area_desc[i].offset, + sa + xsave_area_desc[i].offset, + xsave_area_desc[i].size); + *xstate_bv |= bit; } - return (_MC_FPOWNED_PCB); } + return (owned); } void