Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3985449ybz; Mon, 4 May 2020 13:30:23 -0700 (PDT) X-Google-Smtp-Source: APiQypIhweyg/1ONnbTQCL0uuT4K6f0iz267v2m3csNsScZrAZyq3pkbJK3TI+72QnRZBI2PGGUG X-Received: by 2002:a17:906:b28f:: with SMTP id q15mr16001641ejz.188.1588624223344; Mon, 04 May 2020 13:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588624223; cv=none; d=google.com; s=arc-20160816; b=D3+s/52QPq9UspG89baYjkcVR56BDnyOFmXUoL+BBynHFvKEcpQtSX+EM+8fcpv9EM WT5kobVqmvaB+DY+46dMtRgxfV7BUwq0FI7oPr0eZnWtCLdDBmHrWLPm6XGrH2ElQuJs HmKlcRzVUp9PAvqnQkwRuj2DaDpyxDvYBaWbiAN7RczmiAhi4NQYTc72ZJgNvYolstIf dUxSd7WfEUeqisRZHopIzOjuD61mRqFWixsIPpslLKzz2gc9CGbsxO7W/5H0IuGU8rJl oADS8zvpV+727LRIuNRUNOr7ahjv5/zJKiJNOdrUuUGRjgLqJ9RPsXXmZWPrnTEVwnFK WnWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=kfSSlsP8rPKiF8xNihjNo1jkgJmJ+TJ6ZXFFiKJty8M=; b=lLw09UX6hjIRdn/v3Emp3+BOg4LJOB5ojUV3rcdk2XzXOKMKg65YOleWnozCfuoRrb fJUMfHosrZMZ7WADTQM8Q7Ue4V+mzt1+S+zLLcITwelBaPumPj17dfSNGIFjCSY/2J5a 6iDZmlmSVRgN8beOlptnYLyWzSWLEQdY9gc61L8uPThZKSamirqxj5H9PfSX8nscQmn9 1Vx/AudrzNfD31QCTYuXz54iAJdJaaoqW9W/ZZX2RnR/tCrbF1ucAAxKcTP6N9sk0LAC svoRz7NZcEbBcDgYSWWbdfVBJwhgpShESb3+yzRGyBfU74fQ60BFUlWejGOEItZ3eDgN 8SYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NegKgKRy; 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 j19si6963499ejx.382.2020.05.04.13.29.59; Mon, 04 May 2020 13:30:23 -0700 (PDT) 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=default header.b=NegKgKRy; 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 S1727917AbgEDU0T (ORCPT + 99 others); Mon, 4 May 2020 16:26:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:41582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726410AbgEDU0T (ORCPT ); Mon, 4 May 2020 16:26:19 -0400 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9E2E02075A for ; Mon, 4 May 2020 20:26:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588623978; bh=DUmpNCt7sNyutHVhULaA6d0vAPjjPhpTraWgkmnZdyY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=NegKgKRyNaBnuN1TsEeybVyUpLpVAhemIuLm9j/zLlEB3qOt+cLqmOs0ponzzNQza RVlNbSAfJLTkubAHt/TYjR+dWgCr9hhLfxw9jLQyoh04MDTj5pxeTsfjOZTAodh7c2 T41uMj5P2AlxGzwIoma3qeOBFrZQfayEHF9uRg4I= Received: by mail-wr1-f45.google.com with SMTP id k1so26256wro.12 for ; Mon, 04 May 2020 13:26:18 -0700 (PDT) X-Gm-Message-State: AGi0PuZtIk9+BvsyNW6Q1KnFH5WQ8TC4bOeQzrd6qmPXOl4C9bvh+fMA tEboPCI78sLkz9la+jC5b0hMrPreUx19rwWBrhZ8VA== X-Received: by 2002:a5d:42c8:: with SMTP id t8mr1151633wrr.70.1588623976949; Mon, 04 May 2020 13:26:16 -0700 (PDT) MIME-Version: 1.0 References: <1962EE67-8AD1-409D-963A-4F1E1AB3B865@amacapital.net> <3908561D78D1C84285E8C5FCA982C28F7F60EBB6@ORSMSX115.amr.corp.intel.com> <3908561D78D1C84285E8C5FCA982C28F7F612DF4@ORSMSX115.amr.corp.intel.com> In-Reply-To: <3908561D78D1C84285E8C5FCA982C28F7F612DF4@ORSMSX115.amr.corp.intel.com> From: Andy Lutomirski Date: Mon, 4 May 2020 13:26:05 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 0/2] Replace and improve "mcsafe" with copy_safe() To: "Luck, Tony" Cc: Linus Torvalds , "Williams, Dan J" , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Borislav Petkov , stable , "the arch/x86 maintainers" , "H. Peter Anvin" , Paul Mackerras , Benjamin Herrenschmidt , "Tsaur, Erwin" , Michael Ellerman , Arnaldo Carvalho de Melo , linux-nvdimm , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 4, 2020 at 1:05 PM Luck, Tony wrote: > > > When a copy function hits a bad page and the page is not yet known to > > be bad, what does it do? (I.e. the page was believed to be fine but > > the copy function gets #MC.) Does it unmap it right away? What does > > it return? > > I suspect that we will only ever find a handful of situations where the > kernel can recover from memory that has gone bad that are worth fixing > (got to be some code path that touches a meaningful fraction of memory, > otherwise we get code complexity without any meaningful payoff). > > I don't think we'd want different actions for the cases of "we just found out > now that this page is bad" and "we got a notification an hour ago that this > page had gone bad". Currently we treat those the same for application > errors ... SIGBUS either way[1]. Oh, I agree that the end result should be the same. I'm thinking more about the mechanism and the internal API. As a somewhat silly example of why there's a difference, the first time we try to read from bad memory, we can expect #MC (I assume, on a sensibly functioning platform). But, once we get the #MC, I imagine that the #MC handler will want to unmap the page to prevent a storm of additional #MC events on the same page -- given the awful x86 #MC design, too many all at once is fatal. So the next time we copy_mc_to_user() or whatever from the memory, we'll get #PF instead. Or maybe that #MC will defer the unmap? So the point of my questions is that the overall design should be at least somewhat settled before anyone tries to review just the copy functions.