Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1784018pxb; Sun, 17 Jan 2021 22:56:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzgnp13CY8t4WsOIq/19NKO4Ko6tDtkrCU8g5XXczfvt38iVWBiJxBVmB3wwmsrk3PlPu7 X-Received: by 2002:a17:906:351a:: with SMTP id r26mr15724849eja.204.1610953015538; Sun, 17 Jan 2021 22:56:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610953015; cv=none; d=google.com; s=arc-20160816; b=lecYgXdIq6+kyv2I3m3gWngygHxcu/2hMwkltIZf0+/vHRZw5iB6YTw4zNiviwq+4g TLdmDh3kDhnSHDxmC+o0V+ZtxtjrFVI9UHEG5kj2Y9N+Ive5mnYQZ5+ipBSmtbxNPW1D Oly91XLuQOmIkUFt46odvxrjm6hnaNh3M2kPIFzcZ3A9Ir6hEBwBwKjIg2orRPJO7nkD 2yvb7rWlyFc72SHWX3zWQrK1kckViAppgPgd5tU/25cgN+FGiSikExxC0DpHRveqSW0g cYI9LMEAFqclPBbvfjHn8noaCRls4RElO+6taN9JVWH4N1HX4BAIzDHiWb2DOx+bcJZE jhew== 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=3rY3DQK8g3+j65ZKWfU8He/OwIYBMwLGllzDOhZvhTk=; b=OTalU/uCwf6bw3JujiNMCSoMVfG0K54ODV5eVAAPES/0IqujGZm7QMBHNZqmMVvxfm Av2vHz4F8QmP1DxCQrC0KVSzEFu+Ucbn8ym0l7QeQJ8rCgcQ6epx2vBAcJ9tiE7dPzLk aNfk5/ercVKHLyIjMj2HkAGJ2+y+LPLWaDrG+FdH0mWjH+8+TuarOYxZCukxeCEMqWQp cL0XRBxZgrMaKnEUQh90cjjadHdAsD0Ep6E3GXbUzmpD2yFwWuZDeNkmPR/H+S6nEMZ8 B1xMgqs6ETjviNh+BWrMYvkF2+DVhtL1+yeeGuS20StLLgxrT8A9qLFqSv+qOBYKCZ+b dU9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="D/G6McLe"; 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 y24si582031edq.211.2021.01.17.22.56.22; Sun, 17 Jan 2021 22:56:55 -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="D/G6McLe"; 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 S1730634AbhARGW2 (ORCPT + 99 others); Mon, 18 Jan 2021 01:22:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:54374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730288AbhARGV0 (ORCPT ); Mon, 18 Jan 2021 01:21:26 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D56A02256F; Mon, 18 Jan 2021 06:20:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610950845; bh=bE6z4vwevMCwIw3AY9V3tR79VELiXPkOI9dQ368YjhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D/G6McLeWplCOSzIwytUBIwrbuX4RPiljho8QlBAftC8E0qis0XrmZwLciqXmAZCr mowwYwkEuPp3JkNN9kpsmC1P/J6/jyBhFk8W7Xo7s9JH56qRD81Y4BZFSOa5hRqPd7 9ccVL9kINnICZxl7TVLWFCv5+Z3MA2B847TD+7y0FOhG32bYZiJIgGM7071c6VspAX DLS4AORIof886KaL2wzg2QvYPH+ZA643ImH8Wd2pcb9XEgx+8VcTMzmUoK86eMulUj d0v1+xnpAPrc2czfAOjT9TW6Oh7Yd2ixAeZ5y3zXzJFzxsJHlXRGm6EUhn7ueEKmq+ z6TB0lb4GWMYg== From: Andy Lutomirski To: x86@kernel.org Cc: LKML , Krzysztof Mazur , =?UTF-8?q?Krzysztof=20Ol=C4=99dzki?= , Arnd Bergmann , Andy Lutomirski Subject: [PATCH 2/4] x86/mmx: Use KFPU_MMX for MMX string operations Date: Sun, 17 Jan 2021 22:20:39 -0800 Message-Id: <233a815f5c34cdefb25628fead19b6789b8bd273.1610950681.git.luto@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The default kernel_fpu_begin() doesn't work on systems that support XMM but haven't yet enabled OSFXSR. This causes crashes when _mmx_memcpy() is called too early. Fix it by using kernel_fpu_begin(KFPU_MMX) explicitly. This should also be faster, since it skips both the reasonably fast LDMXCSR and also the rather slow FNINIT instructions. Fixes: 7ad816762f9b ("x86/fpu: Reset MXCSR to default in kernel_fpu_begin()") Reported-by: Krzysztof Mazur Signed-off-by: Andy Lutomirski --- arch/x86/lib/mmx_32.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c index 4321fa02e18d..daa80fa005fb 100644 --- a/arch/x86/lib/mmx_32.c +++ b/arch/x86/lib/mmx_32.c @@ -37,7 +37,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len) p = to; i = len >> 6; /* len/64 */ - kernel_fpu_begin(); + kernel_fpu_begin_mask(KFPU_MMX); __asm__ __volatile__ ( "1: prefetch (%0)\n" /* This set is 28 bytes */ @@ -127,7 +127,7 @@ static void fast_clear_page(void *page) { int i; - kernel_fpu_begin(); + kernel_fpu_begin_mask(KFPU_MMX); __asm__ __volatile__ ( " pxor %%mm0, %%mm0\n" : : @@ -160,7 +160,7 @@ static void fast_copy_page(void *to, void *from) { int i; - kernel_fpu_begin(); + kernel_fpu_begin_mask(KFPU_MMX); /* * maybe the prefetch stuff can go before the expensive fnsave... @@ -247,7 +247,7 @@ static void fast_clear_page(void *page) { int i; - kernel_fpu_begin(); + kernel_fpu_begin_mask(KFPU_MMX); __asm__ __volatile__ ( " pxor %%mm0, %%mm0\n" : : @@ -282,7 +282,7 @@ static void fast_copy_page(void *to, void *from) { int i; - kernel_fpu_begin(); + kernel_fpu_begin_mask(KFPU_MMX); __asm__ __volatile__ ( "1: prefetch (%0)\n" -- 2.29.2