Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp435463pxb; Wed, 20 Jan 2021 10:31:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYeuNzSIQeOU1BkTWH9c5GUcDZ1LJd9aONLktQlDOEtNyspjaMY9osW12Kiu1sA7cIe2SI X-Received: by 2002:a05:6402:278a:: with SMTP id b10mr6244727ede.347.1611167463261; Wed, 20 Jan 2021 10:31:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611167463; cv=none; d=google.com; s=arc-20160816; b=oiIvRjVgRDzKfxqw+5i6bSt2cK/iegcaclTnvCPvlr5jHaLFLev5cVKKV/O5rDIwAi N9au07OHNsp032GxdUw6rXFv0U5umvmTU1v02mHgXwHmi0YlZK59Q8NhScKg3P4TGzjG t/faCdRZkkUCDA+TEPENM7UGUwTk0CxG6EPjR3ayfHZ6lkWRgJAOfTmYgckLMTm7R00S wcZYXeTYuetxBPTW1K4QpEUPs9tV1F38RAgsXJI9ijAoKoAv+gH0CBjqYo9z6in7H4NO suOyLMLmLb251/PrPvbN5Ah9Ip49D2nIG3LZWGzKOUrj4zo4yY247K2di278qD+y9uST HhvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YdsY64auz+N4Ke+6Uorfvs1e0o4cdCe8WQpfT5eDLSU=; b=vEfHGCjN3MPhSxpbKi7Bs/r7WmWb9Y/nJ/9V8t0peasSS8+mgJi5FcV/4LGFqFow/A y1YBX9QbXZDD9k5EOnhNtyW/4dtCwEGs6lZfEbZaryj8/AonAsXNaXuQKz5ja7sK/Dz6 1VNwaxcQBvyO65InLYWeUBmoVoL1wJFm+pgb/Vk8k8XHLiboS8qEFLCWX7gRXra5aIPN w9OnzvcH0YEmNBrLOvJ/iUqkAe9mlOhJkVOKMJiNV9vbTdGhK1xVjTyEeVfgu2lw8ZeS KXzQVVOjf0ZpWBMa1de3kLjqPCcjIDYnunF2PmVCDCIZEFOYXrRMgqgZvI9zEIoreBkx fOiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=YTPOvvCT; 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=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m10si1188011edi.26.2021.01.20.10.30.37; Wed, 20 Jan 2021 10:31:03 -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=@alien8.de header.s=dkim header.b=YTPOvvCT; 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=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404667AbhATS02 (ORCPT + 99 others); Wed, 20 Jan 2021 13:26:28 -0500 Received: from mail.skyhub.de ([5.9.137.197]:51760 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391967AbhATSSv (ORCPT ); Wed, 20 Jan 2021 13:18:51 -0500 Received: from zn.tnic (p200300ec2f0bb000f815c9e084808a0b.dip0.t-ipconnect.de [IPv6:2003:ec:2f0b:b000:f815:c9e0:8480:8a0b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id C699F1EC04D1; Wed, 20 Jan 2021 19:18:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1611166688; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=YdsY64auz+N4Ke+6Uorfvs1e0o4cdCe8WQpfT5eDLSU=; b=YTPOvvCTWi8wDa1Njffe848Yoloadu1DGr7T9DL9MlfpgGosH3d+CmaJZ2Fl75fq0/Tg67 E730Gx0BIyHJ6i6Mq123KgAPnIFqxMSIXI2/8F3aMDkYlURkZK1yqtVNXlqw/BVIivos/H iUylhhYiM3xcUzkEUXBjecppuqDzjPI= Date: Wed, 20 Jan 2021 19:18:02 +0100 From: Borislav Petkov To: Andy Lutomirski Cc: x86@kernel.org, LKML , Krzysztof Mazur , Krzysztof =?utf-8?Q?Ol=C4=99dzki?= , Arnd Bergmann Subject: Re: [PATCH v2 2/4] x86/mmx: Use KFPU_387 for MMX string operations Message-ID: <20210120181802.GH825@zn.tnic> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 19, 2021 at 09:39:00AM -0800, Andy Lutomirski wrote: > The default kernel_fpu_begin() doesn't work on systems that support XMM but > haven't yet enabled CR4.OSFXSR. This causes crashes when _mmx_memcpy() is > called too early because LDMXCSR generates #UD when the aforementioned bit > is clear. > > Fix it by using kernel_fpu_begin_mask(KFPU_387) explicitly. > > Fixes: 7ad816762f9b ("x86/fpu: Reset MXCSR to default in kernel_fpu_begin()") > Reported-by: Krzysztof Mazur > Signed-off-by: Andy Lutomirski Cc: I guess. > --- > arch/x86/lib/mmx_32.c | 20 +++++++++++++++----- > 1 file changed, 15 insertions(+), 5 deletions(-) > > diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c > index 4321fa02e18d..2a6ad7aa148a 100644 > --- a/arch/x86/lib/mmx_32.c > +++ b/arch/x86/lib/mmx_32.c > @@ -26,6 +26,16 @@ > #include > #include > > +/* > + * For MMX, we use KFPU_387. MMX instructions are not affected by MXCSR, > + * but both AMD and Intel documentation states that even integer MMX > + * operations will result in #MF if an exception is pending in FCW. > + * > + * We don't need EMMS afterwards because, after we call kernel_fpu_end(), > + * any subsequent user of the 387 stack will reinitialize it using > + * KFPU_387. Please use passive voice and convert the "we" to something impersonal. For example: "Use KFPU_387 for MMX. MMX instructions are not affected by MXCSR, but both AMD and Intel documentation states that even integer MMX operations will result in #MF if an exception is pending in FCW. EMMS afterwards is not needed because, after kernel_fpu_end(), any subsequent user of the 387 stack will reinitialize it using KFPU_387." Voila, de-we-fied! :-) -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette