Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2629528rwd; Fri, 19 May 2023 08:10:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5BssD5W+jwc0VIUb2emnzORGLBdmd5uW5e9CW5EXxNs/jkiWe/8GCv11UDPkaBu9bisB2D X-Received: by 2002:a17:90a:2a42:b0:252:e7db:66df with SMTP id d2-20020a17090a2a4200b00252e7db66dfmr2074727pjg.49.1684509048241; Fri, 19 May 2023 08:10:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684509048; cv=none; d=google.com; s=arc-20160816; b=kMOQf/opDvPzlXNxzbxan/i4DEonc/iIEuHBigoJmnCi021UWISLW7Vq8Xd0rZcS2J Rv/5zeEnRTNwYHkfj/cRvRIJbwblielevRDpqmUECdITPmMFu9CaNJr8Ea2YYojSeE4N 4tGbvYYJGvsNbYWHYk/gpo3nIZzwZbE6TzlS1M8WZyuU4BPxEJyPQjzub9URfJQ/wCII I4xszmu6nntNj5wgAwV3tgLdG3/l+C5RwtYBMeOQJqsGxunt7BChF144XYFBiPXCjAHd nCNJX328Vj7E3ovL5zebdW+yNby82Fa0AogTj4qRrjTAiTqVHy7Cgbh2mdLR2jzXY5HE Bi/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=33LUfnvcBk5FJKdYxdHSvEMGUXklwU9JErgqA7bqDJ8=; b=sqhuxzgCeOT9Ab66cI4p+yfR3as76H+RSnV9S5yo9efwhHBYgl0VXMQ6sjew9HR/iX jtoscbj3fvRwao9SU2f6XzSAQYGOTDjWRUOVyYnC8gVek7iI+zQ7PhdtrBX94Rvht3tG seFFLprHvxZFsSGuZkZv6QZIZ1cplVvVEqC6HPt6eEJmJMup7lvvDwCdotbVgXXyn/PG uUoWZbkKIfVgE83himrbF0R4P4hxGfgBBe6A8ID/XpBYqwz0iBCRcVz/aYty/vh0Xuft Rneem8WRq9GmJZSs52Hu4XiFFeb2H+RW8zLXofv5S8du5BRoYeJ22r/SECMEc03bpnl4 dUkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=BULDGCz+; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j22-20020a633c16000000b0050bf5b9ad11si1928643pga.752.2023.05.19.08.10.32; Fri, 19 May 2023 08:10:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=BULDGCz+; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232059AbjESPD2 (ORCPT + 99 others); Fri, 19 May 2023 11:03:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbjESPD1 (ORCPT ); Fri, 19 May 2023 11:03:27 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 494F6121 for ; Fri, 19 May 2023 08:03:26 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684508604; 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: in-reply-to:in-reply-to:references:references; bh=33LUfnvcBk5FJKdYxdHSvEMGUXklwU9JErgqA7bqDJ8=; b=BULDGCz+pHDYEffJS7qJztU2tfavRGbe3pvfFYMm3MrdqhTqpfs2TOFO38tn6qcymA+p5C 1Ja36SbVAISU5Q+HjRN3EIGwpIwvMroO37uLoUUcEPnWcuKvpVBXravxxVc5hDoFSfc5MK FxVLTA7eSOuXBIQuWqS5KmgFuJfmKSiFritnDKcOab5kmWThqpHCeOsnOPylviJchMZdXm 18u1Vwe/HoCV9Jgd7kUMh1voW9YPZpMe1dUXnwO/3FaSDVmJgT5D857yqj9/517FHBV+E9 GO2m9z9xJmsYkK8x5Tqx61M3VWNqYlHnIT9XU/O/Kb0X22k4c1zvd7GdgBsKBQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684508604; 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: in-reply-to:in-reply-to:references:references; bh=33LUfnvcBk5FJKdYxdHSvEMGUXklwU9JErgqA7bqDJ8=; b=bEJ0YDdfhjKEuNxmuJSTb7dtJlosFCgokxKWlbJE08kxOa98ydSQ6tJ0YqOmxhj1v/U8xB +S9Q5rry41cK+WCg== To: Adamos Ttofari , chang.seok.bae@intel.com Cc: attofari@amazon.de, abusse@amazon.de, Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Kyle Huey , Andrew Cooper , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] x86: fpu: Keep xfd_state always in sync with MSR_IA32_XFD In-Reply-To: <20230519112315.30616-1-attofari@amazon.de> References: <87y1ltbtkh.ffs@tglx> <20230519112315.30616-1-attofari@amazon.de> Date: Fri, 19 May 2023 17:03:23 +0200 Message-ID: <87ilco4b44.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 19 2023 at 11:23, Adamos Ttofari wrote: > Commit 672365477ae8 ("x86/fpu: Update XFD state where required") and > commit 8bf26758ca96 ("x86/fpu: Add XFD state to fpstate") introduced a > per CPU variable xfd_state to keep the MSR_IA32_XFD value cached. In > order to avoid unnecessary writes to the MSR. > > On CPU hotplug MSR_IA32_XFD is reset to the init_fpstate.xfd, which > wipes out any stale state. But the per CPU cached xfd value is not > reset, which brings them out of sync. > > As a consequence a subsequent xfd_update_state() might fail to update > the MSR which in turn can result in XRSTOR raising a #NM in kernel > space, which crashes the kernel. > > To address the issue mentioned, initialize xfd_state together with > MSR_IA32_XFD. > > Fixes: 672365477ae8 ("x86/fpu: Update XFD state where required") > > Signed-off-by: Adamos Ttofari Reviewed-by: Thomas Gleixner