From owner-svn-src-all@freebsd.org Thu May 10 15:01:45 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D1D91FCC6F7; Thu, 10 May 2018 15:01:44 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 840DC6B93F; Thu, 10 May 2018 15:01:44 +0000 (UTC) (envelope-from kib@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 65FE521FDC; Thu, 10 May 2018 15:01:44 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4AF1iFm039083; Thu, 10 May 2018 15:01:44 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4AF1iI0039082; Thu, 10 May 2018 15:01:44 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201805101501.w4AF1iI0039082@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 10 May 2018 15:01:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333461 - head/sys/amd64/amd64 X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/amd64/amd64 X-SVN-Commit-Revision: 333461 X-SVN-Commit-Repository: base 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.25 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: Thu, 10 May 2018 15:01:45 -0000 Author: kib Date: Thu May 10 15:01:43 2018 New Revision: 333461 URL: https://svnweb.freebsd.org/changeset/base/333461 Log: Make fpusave() and fpurestore() on amd64 ifuncs. From now on, linking amd64 kernel requires either lld or newer ld.bfd. Reviewed by: jhb (as part of the large patch) Discussed with: emaste Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D13838 Modified: head/sys/amd64/amd64/fpu.c Modified: head/sys/amd64/amd64/fpu.c ============================================================================== --- head/sys/amd64/amd64/fpu.c Thu May 10 13:52:52 2018 (r333460) +++ head/sys/amd64/amd64/fpu.c Thu May 10 15:01:43 2018 (r333461) @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include /* * Floating point support. @@ -151,26 +152,60 @@ struct xsave_area_elm_descr { u_int size; } *xsave_area_desc; -void -fpusave(void *addr) +static void +fpusave_xsave(void *addr) { - if (use_xsave) - xsave((char *)addr, xsave_mask); - else - fxsave((char *)addr); + xsave((char *)addr, xsave_mask); } -void -fpurestore(void *addr) +static void +fpurestore_xrstor(void *addr) { + xrstor((char *)addr, xsave_mask); +} + +static void +fpusave_fxsave(void *addr) +{ + + fxsave((char *)addr); +} + +static void +fpurestore_fxrstor(void *addr) +{ + + fxrstor((char *)addr); +} + +static void +init_xsave(void) +{ + if (use_xsave) - xrstor((char *)addr, xsave_mask); - else - fxrstor((char *)addr); + return; + if ((cpu_feature2 & CPUID2_XSAVE) == 0) + return; + use_xsave = 1; + TUNABLE_INT_FETCH("hw.use_xsave", &use_xsave); } +DEFINE_IFUNC(, void, fpusave, (void *), static) +{ + + init_xsave(); + return (use_xsave ? fpusave_xsave : fpusave_fxsave); +} + +DEFINE_IFUNC(, void, fpurestore, (void *), static) +{ + + init_xsave(); + return (use_xsave ? fpurestore_xrstor : fpurestore_fxrstor); +} + void fpususpend(void *addr) { @@ -207,13 +242,8 @@ fpuinit_bsp1(void) uint64_t xsave_mask_user; bool old_wp; - if ((cpu_feature2 & CPUID2_XSAVE) != 0) { - use_xsave = 1; - TUNABLE_INT_FETCH("hw.use_xsave", &use_xsave); - } if (!use_xsave) return; - cpuid_count(0xd, 0x0, cp); xsave_mask = XFEATURE_ENABLED_X87 | XFEATURE_ENABLED_SSE; if ((cp[0] & xsave_mask) != xsave_mask)