Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1783747pxb; Sun, 17 Jan 2021 22:56:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJyGIQVJR8yv35U3pOH+FIgUGnuunqr6Xq4nKyGusK6rsSo+PL2inOuTBE9oy2SY3xp8/+7Z X-Received: by 2002:aa7:ca51:: with SMTP id j17mr6564767edt.124.1610952972089; Sun, 17 Jan 2021 22:56:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610952972; cv=none; d=google.com; s=arc-20160816; b=E5AeAEwNCBtBsBbECEdm16H3UPHwzZu2IJsZK1balILH3m+BhODatWXmMdIQgriEXc G1eBj3fxs/weKYZEE+nrpcxZf24BKTjCs9hlw/fhh2/tgtG0rxnHxBrmrVvvHxildWvV xenj+KVAeF6kZe9ezLqnXm202jSdO9XDeEb+8Sj20V2myO/wJjnDptRjUXQfl1tQkc2x wkW1MumgQA6w03M7OUkb4neDcVk1tIFIUvsQJvmwzD0pa2sF7thHk0P59LX/YQLxMcAy s65dBsB0uTsvT8toakonIA9qY+GcP1DKNlIVy2jFZivtZv8TUw/CWc7vVo4Nm/emWeML EKvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X1Nbfx/93I1m6QaY5bKTvpHvHYnj3VFDZqNHf2RRiOs=; b=Pa89lmvtE+q4+odogCeGdmiYjuvF5LrVPY4knePcj1S/VecbWTJmiCI13eX5Y/3bbg yCxihIc1UkJtDOSGlP9S3aJAu6Brl0jyI/VHH7+5yQH1lCYR4wiY/Gb/jOlM5Bkhi7hl u/+LdgNdusLZig5SRKKx42MRnwohyuzFCWzRBnrIGCuwGIQrqb8brFGbK2jqAYok5c6x cKNL1fgi6IhF1iC5sry2S+3YZpzk/zexyxTzO8SwLXYkxXAkdlIO3eneYSpfstGnJwyd 64YDOs2aWpgHbk41piXT8wNAS2RY+1OQFNH7w/sBqzx3h1CpZQzddXUKwA6lXUQFeUy5 P+zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J65M9sE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i12si7111595edk.461.2021.01.17.22.55.49; Sun, 17 Jan 2021 22:56:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J65M9sE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732019AbhARGV7 (ORCPT + 99 others); Mon, 18 Jan 2021 01:21:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:54466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730634AbhARGV0 (ORCPT ); Mon, 18 Jan 2021 01:21:26 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 361DC22583; Mon, 18 Jan 2021 06:20:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610950846; bh=/Y8ouPlqMWUZR7Fcd1lZA6ZxI0V0/5/SN2MiDQxmA8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J65M9sE1dMcL2dVpMxCmhu2TOg1q5jhYP1XaTHLWm4+tVJ1ad2hMDJGQQ9dUeEhpM rFMrZUW+vo29DJyyTOtlfVBpvcQRUgMLPvJuNP4Uu/UoQvxKTwEjIauMasnrMezU0T goG7MeibRwjSrZsm0c54R+3UOjxs47MBDYtme5jNwHMOOFx+hki1XdiOz1oFr0gAkf r4WdYbzeVowFeBinkCuY1/5hvNpxvXETioYjCVliCkw9D/gnfzLC1L5S1gowvtOAEe +TmrJwFWGRzJ9Pxq9frtqgXsSkUXG6lglStW59NkznbhS3WAfrCfQkLfa1+yhRy0/a LPK5Phgh8A5nQ== From: Andy Lutomirski To: x86@kernel.org Cc: LKML , Krzysztof Mazur , =?UTF-8?q?Krzysztof=20Ol=C4=99dzki?= , Arnd Bergmann , Andy Lutomirski Subject: [PATCH 4/4] x86/fpu/64: Don't FNINIT in kernel_fpu_begin() Date: Sun, 17 Jan 2021 22:20:41 -0800 Message-Id: <7f668aa760d847f8777371e03a39c4d6373f88ee.1610950681.git.luto@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The remaining callers of kernel_fpu_begin() in 64-bit kernels don't use 387 instructions, so there's no need to sanitize FCW. Skip it to get the performance we lost back. Reported-by: Krzysztof Olędzki Signed-off-by: Andy Lutomirski --- arch/x86/include/asm/fpu/api.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h index e95a06845443..6e826796a734 100644 --- a/arch/x86/include/asm/fpu/api.h +++ b/arch/x86/include/asm/fpu/api.h @@ -40,7 +40,19 @@ extern void fpregs_mark_activate(void); /* Code that is unaware of kernel_fpu_begin_mask() can use this */ static inline void kernel_fpu_begin(void) { +#ifdef CONFIG_X86_64 + /* + * Any 64-bit code that uses 387 instructions must explicitly request + * KFPU_387. + */ + kernel_fpu_begin_mask(KFPU_XYZMM); +#else + /* + * 32-bit kernel code may use 387 operations as well as SSE2, etc, + * as long as it checks that the CPU has the required capability. + */ kernel_fpu_begin_mask(KFPU_387 | KFPU_XYZMM); +#endif } /* -- 2.29.2