Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp657222pxb; Fri, 8 Jan 2021 14:52:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrAV5oNK+f0B5qYvdmxX2lHxsRNYaeJ/ufE+NtMyBYDfs6yUI4KliCZWW79dggwqecchjq X-Received: by 2002:a17:907:204b:: with SMTP id pg11mr4267450ejb.192.1610146323596; Fri, 08 Jan 2021 14:52:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610146323; cv=none; d=google.com; s=arc-20160816; b=A4vc3QtWZ4os6pcIvNPH/j9TDw+SPuxrKk2l1QeYlqi5yFg5DfGoyPu1ByxkP4dBXe h3HI5JJho6HiTdo2R1kHQCpqlQi+jRhKQb/EOWKsL8HvIRQyvRSI6RP1U97+a2YsYh8M soAzVcaR4CQHYFdd5cnAZfOgz39s4ZEJdoG2EdYhc3LxhTqCCj44RBlQ453kuj2T0CSn lWzFvb4RPff8xWLsEnYD2Tk+05GmjzM9XyY+HMmZibRg49qkQ8ZY0Bnva1KDMW1AtNzH EY4E8y4HAMR1ODTE3oM8Ux3FtkO8D5P8J5acI5LlKgT/E1LLlMbNN45JFnTPLr5ljzDq 1M5g== 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=y6utkV8+rnLd3kCaXRS1gntJ/Qt+RxB06NgyDB05tsQ=; b=Bb6AnBCXLj8nlH1oQwMd5fofghR6iQc4sT2hdRm9dkfJrm6IkhcG13Iwg5Mc7xyFx+ M/cvqvbCzL7+bXqowfclqbIHJ07p8xH6sPtSuqt5bYkCcEiEljeah7YAjj/vSmTrnTra itwSuWIohTAkyCXBLwUVIqY+3H6uq44EouDDMcaZFaXothG/pc1PCfMr8tGL33UtiVuO bDIMGQIj6dd0xGTmV2sI28nBgXbHScYvOA1rSDgqOe0uVGO57uQMIubdZJt2AHepBDH2 FRRNsVGFtaoUPnEJKnmaoQxAkDJRHvzbrJDyBD46xmYRzC3e+gl1DaKd5xmcV4JL3Kd/ 6Wog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=cWZ2NApO; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lu18si3968926ejb.272.2021.01.08.14.51.39; Fri, 08 Jan 2021 14:52: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=@infradead.org header.s=merlin.20170209 header.b=cWZ2NApO; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726245AbhAHWsR (ORCPT + 99 others); Fri, 8 Jan 2021 17:48:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725763AbhAHWsR (ORCPT ); Fri, 8 Jan 2021 17:48:17 -0500 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36A59C061757; Fri, 8 Jan 2021 14:47:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=y6utkV8+rnLd3kCaXRS1gntJ/Qt+RxB06NgyDB05tsQ=; b=cWZ2NApOkgotnnOjxHpSpSy41f QBDtpEdN6cXwaoS+nil5TbeOvdq7tGHv0fAA5n+xeWL4divsAEgYZuT9I3hjz7AsLMYZKv2VuwTdu EdtYBgK0jHYipoTeq3UvKbLlStfuTVu+b4OgnnmDI2ika+Ee7+a2dZg6Gfij4xdofckqeD5EOxjOb 93vnwdD/6UnmcHpBPnSKgDcX3f9vpqqtDT4/iE5sBWH+Jkyney2V7HACZeK7VWa4A5BqdoYMnXsGN eWto8aD02c5iegGv1szt7ghMaD7SmGYctTFWTc3u83YnlcU2xu/EoFN1rjM85EUrEVohihkEfjMk0 mpzXX7kw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1ky0XR-0003Uq-KF; Fri, 08 Jan 2021 22:47:21 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 05F819866B1; Fri, 8 Jan 2021 23:47:15 +0100 (CET) Date: Fri, 8 Jan 2021 23:47:15 +0100 From: Peter Zijlstra To: Tony Luck Cc: Borislav Petkov , x86@kernel.org, Andrew Morton , Darren Hart , Andy Lutomirski , linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 2/2] futex, x86/mce: Avoid double machine checks Message-ID: <20210108224715.GB2453@worktop.programming.kicks-ass.net> References: <20210108222251.14391-1-tony.luck@intel.com> <20210108222251.14391-3-tony.luck@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210108222251.14391-3-tony.luck@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 08, 2021 at 02:22:51PM -0800, Tony Luck wrote: > futex_wait_setup() first tries to read the user value with page faults > disabled (because it holds a lock, and so cannot sleep). If that read > fails it drops the lock and tries again. > > But there are now two reasons why the user space read can fail. Either: > 1) legacy case of a page fault, in which case it is reasonable to retry > 2) machine check on the user address, bad idea to re-read > > Add some infrastructure to differentiate these cases. > --- a/kernel/futex.c > +++ b/kernel/futex.c > @@ -2658,6 +2658,9 @@ static int futex_wait_setup(u32 __user *uaddr, u32 val, unsigned int flags, > if (ret) { > queue_unlock(*hb); > > + if (arch_memory_failure(uaddr)) > + return ret; > + > ret = get_user(uval, uaddr); > if (ret) > return ret; I think this is horrid; why can't we have it return something different then -EFAULT instead?