Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2222402ybl; Thu, 19 Dec 2019 09:59:45 -0800 (PST) X-Google-Smtp-Source: APXvYqyNGb59xAFRx5FuSdVeHEZXYSoQFpmepcErQG2huETFnus/aVRamRLv9vNP+/ExwRFtMxaT X-Received: by 2002:a9d:68ca:: with SMTP id i10mr9803105oto.178.1576778385158; Thu, 19 Dec 2019 09:59:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576778385; cv=none; d=google.com; s=arc-20160816; b=U+vPYe1QLNIC++oLhyRXGCkzAXzRvFrhuYF0Ztgmn1nbntmvmLHo04hZ3DIJmFtbg9 DruXmseWoNYRgx7c4jO2MvXnGXMRQL9u9YwRqcIH9LHum50VhBmNW6sP2ckJli2IWzbc yRfTreF5wJtlPQXFhid+WOBhMeZa9N0LicUrESXKJgxVXwXCtHbTGLguWcJZA4D01DLb RBXk73ly0PzF0SH3exzWNo9qddISPBjyM9KIQtL4cDwZ+7cnyXX84pYolgKLWFh1MaR2 9una+fhzLwUcQAm+S5kCokN5J4mIb6GeENK8F0Dz5J0SKoAcCDMpbGmrYnjJLBhHo9jg gDEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=2txbqXq/9gt/GFqdkL7B9YrF7JNGBvja+spi3kwfVi0=; b=bEHi4hOLAIn4OJHwoPw9NT614Ka54VR+pn1ALGGjKSqx8FIkjlzZL80se01igpc7VM b/BWA9Y2DkouBgurHufRqqsiAHLR8e3HnDxJPrX5QV7VVAtZuStw6VY5SNLDM/cVUf+q ZnB+uvjcifNSsbPxXpPuOg+rNNhqYgyavbDorLn3LE5LMBu8H2fsSg3KgWJZeFwGoVGo 88omcxB+Nji4mG6XRUk4NqKtXxDWxVDy4+DMzqCldbZU4N+cymfwrLXJVsiqIf1BS9ZS zwpUoSbAqDJiJ+/I1HXamMhpPyKLMI3+IlwsB1q0uUhmQbOi/FtsEPLmfR2uBEsVw69q Emgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si3547684otq.156.2019.12.19.09.59.33; Thu, 19 Dec 2019 09:59:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726943AbfLSR6v (ORCPT + 99 others); Thu, 19 Dec 2019 12:58:51 -0500 Received: from mga17.intel.com ([192.55.52.151]:4392 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726840AbfLSR6v (ORCPT ); Thu, 19 Dec 2019 12:58:51 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Dec 2019 09:58:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,332,1571727600"; d="scan'208";a="213075151" Received: from yyu32-desk.sc.intel.com ([143.183.136.51]) by fmsmga007.fm.intel.com with ESMTP; 19 Dec 2019 09:58:50 -0800 Message-ID: <1607597639a6c6255127fef07704ee9193e33166.camel@intel.com> Subject: Re: [PATCH v2 3/3] x86/fpu/xstate: Invalidate fpregs when __fpu_restore_sig() fails From: Yu-cheng Yu To: Sebastian Andrzej Siewior Cc: linux-kernel@vger.kernel.org, x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , Dave Hansen , Tony Luck , Andy Lutomirski , Borislav Petkov , Rik van Riel , "Ravi V. Shankar" , Fenghua Yu , Peter Zijlstra Date: Thu, 19 Dec 2019 09:40:06 -0800 In-Reply-To: <20191219171635.phdsfkvsyazwaq7s@linutronix.de> References: <20191212210855.19260-1-yu-cheng.yu@intel.com> <20191212210855.19260-4-yu-cheng.yu@intel.com> <20191218155449.sk4gjabtynh67jqb@linutronix.de> <587463c4e5fa82dff8748e5f753890ac390e993e.camel@intel.com> <20191219142217.axgpqlb7zzluoxnf@linutronix.de> <19a94f88f1bc66bb81dbf5dd72083d03ca5090e9.camel@intel.com> <20191219171635.phdsfkvsyazwaq7s@linutronix.de> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.4 (3.32.4-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2019-12-19 at 18:16 +0100, Sebastian Andrzej Siewior wrote: > On 2019-12-19 08:44:08 [-0800], Yu-cheng Yu wrote: > > Yes, this works. But then everywhere that calls copy_*_to_xregs_*() etc. needs to be checked. > > Are there other alternatives? > > I don't like the big hammer approach of your very much. It might make > all it "correct" but then it might lead to more "invalids" then needed. > It also required to export the symbol which I would like to avoid. Copying to registers invalids current fpregs context. It might not cause extra register loading, because registers are in fact already invalidated and any task owning the context needs to reload anyway. Setting fpu_fpregs_owner_ctx is only to let the rest of the kernel know the fact that already happened. But, I agree with you the patch does look biggish. > > So if this patch works for you and you don't find anything else where it > falls apart then I will audit tomorrow all callers which got the > "invalidator" added and check for that angle. Yes, that works for me. Also, most of these call sites are under fpregs_lock(), and we could use __cpu_invalidate_fpregs_state(). I was also thinking maybe add warnings when any new code re-introduces the issue, but not sure where to add that. Do you think that is needed? Thanks, Yu-cheng