From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59604C10F1A for ; Thu, 9 May 2024 21:05:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CEA0D6B0087; Thu, 9 May 2024 17:05:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C98A56B0098; Thu, 9 May 2024 17:05:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEB966B0099; Thu, 9 May 2024 17:05:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 8762D6B0087 for ; Thu, 9 May 2024 17:05:55 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1FA081A0320 for ; Thu, 9 May 2024 21:05:55 +0000 (UTC) X-FDA: 82100089470.15.59FED37 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 039E5C0002 for ; Thu, 9 May 2024 21:05:52 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HFLxPhB8; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715288753; h=from:from:sender: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:dkim-signature; bh=7T3LDIhsXGXUAobvNy/zX3cm6DyL69PkcrlNbmolHko=; b=p1sm/scNkpdwZe7EXXOexc3pU5VOh2QuizKjE9/RnAMuZzdcKYCEuEEnTCqHaO2OUup6ml iq6csdLqMpSsViqpur4v4o4QHNqFNvMDFbaZCDL7pQf0Zov/Nd3p0GDWdfeFdUeLN76mJV jVMnuTWBHptprGAoK99gc/cnEKnCA0A= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HFLxPhB8; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715288753; a=rsa-sha256; cv=none; b=WGYKfsqMvtwWo4px8qVqiFBC+pVn9fepp+Zy37saR0NXDwo/woCzIi+TbeQZTYG5kBtJk/ iJjNmMMmijUDmgUJq6loCuuMVTCscXpDso/MjBztJA3a/9/rs69I1oNOXvll1/boFgxJXn 4TOmKPdvki086VDpX88TB21KR/cqCtE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715288752; 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=7T3LDIhsXGXUAobvNy/zX3cm6DyL69PkcrlNbmolHko=; b=HFLxPhB8CWe14xhvyoJw0i/ngXHMYT6SMDjd68T9LVj5nK5qbL5pCMarjtN2lL4cl2R3ug /WIkUvTZLuLIJI8GgwTGhBEjhB+op9h6AlBdredhG1AtVBDqtZXTVPm9EoFMY6fqZE5df3 ixegWxDd7RvX/sAWJvgaFOpb8KNN/AE= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-116-ArmGH14LMwWu_qEkFNn7zA-1; Thu, 09 May 2024 17:05:51 -0400 X-MC-Unique: ArmGH14LMwWu_qEkFNn7zA-1 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-61c3dc525a9so1154967b3.3 for ; Thu, 09 May 2024 14:05:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715288750; x=1715893550; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=7T3LDIhsXGXUAobvNy/zX3cm6DyL69PkcrlNbmolHko=; b=hmTTurLto7AxXP8cfD8Ti9f1vIvGHuQz1BrAujkReDFkQYIkT3B05V9RCjh64s2RGV 8dXDas48XgQZ2HgHE8+BsoK6+ncLrY1nob1wG7EOzRVsjycjmCFIqFq8yQAVHgCAEUtc 58q8wJcgBExYAckhr1CEOVn/ACFkpdv7tVcscF6mVurAVsdRW/Hxm/SDH+w1I/QR/Cfn 949XGS64B0ajCXLZw8FiFmczU7DvsV5stLCRu35LmbAQeD0mQhA1KjwE+d+nrBinF3Tp zzN24s2BUdGMDHytactvnSTHvnDa502o07MkUT+ILI251lbfwFDM5MN8yyTJTxtBoGqc oxjw== X-Forwarded-Encrypted: i=1; AJvYcCX0th6lGjhdELVB97lo4vcaepr1cr9dPPDvcsMNIT0+A2QDts0E/pkBGJfoSgxSV9N3F5d9/Gcdu1gLU5E4BpxivhI= X-Gm-Message-State: AOJu0YweDnpsdemOfVH89395AfgG2TAVyX+dqUZN/Mojas/DNxIxNDy1 FP/1LFB5lRWL+8lsFhJ/GOKT0FD5jjkv4pRkcXkj/6rWc6r97vRIEvKSGVKNKKK1QUrZ6LdzSFH 5KlR+JtZ+WGK0ygowa7DRsGKVsmkCjofO7Y9+na3ddMIZggBY X-Received: by 2002:a05:690c:380e:b0:61a:e298:54bd with SMTP id 00721157ae682-622afffc878mr7230397b3.5.1715288750064; Thu, 09 May 2024 14:05:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHS20oQmRUsuSl8lwz2cOfuBq3VxXVmGt3mp7XGUROKc3y0rvlg28/J2adK4SCZ79ErLFWMGg== X-Received: by 2002:a05:690c:380e:b0:61a:e298:54bd with SMTP id 00721157ae682-622afffc878mr7229957b3.5.1715288749344; Thu, 09 May 2024 14:05:49 -0700 (PDT) Received: from x1n (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6209e2340a3sm4647617b3.4.2024.05.09.14.05.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 14:05:48 -0700 (PDT) Date: Thu, 9 May 2024 17:05:46 -0400 From: Peter Xu To: Axel Rasmussen Cc: Andrew Morton , Andy Lutomirski , "Aneesh Kumar K.V" , Borislav Petkov , Christophe Leroy , Dave Hansen , David Hildenbrand , "H. Peter Anvin" , Helge Deller , Ingo Molnar , "James E.J. Bottomley" , John Hubbard , Liu Shixin , "Matthew Wilcox (Oracle)" , Michael Ellerman , Muchun Song , "Naveen N. Rao" , Nicholas Piggin , Oscar Salvador , Peter Zijlstra , Suren Baghdasaryan , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org Subject: Re: [PATCH 1/1] arch/fault: don't print logs for simulated poison errors Message-ID: References: <20240509203907.504891-1-axelrasmussen@google.com> <20240509203907.504891-2-axelrasmussen@google.com> MIME-Version: 1.0 In-Reply-To: <20240509203907.504891-2-axelrasmussen@google.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 039E5C0002 X-Stat-Signature: cmnckjphjk6czd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gehQ6ho/NG50oP0fg0zSdFwNKDDrSHdTzdIR5G4s5bbtTP6tSz7EAcHcsr/jD1IAly5ju/j0Rq2EB41XT0MXmWXMMZOTMTdI0W2F3bI1IHfBSrJ1+zkOrT0doE2RAQDFzIR29g9UVslOWkStkAitXMH3qrObv0qbbrRaiTV/jJBT2yUPPvSEF2palTRRGANxeJJLoTqX4ShV4krMYyF2Oa1FwhrYGRm484hGCmNayqUVMJtJBRTIxJ2XCMy789HlyUKiaw+rljt7B7WohXEgYo2sJM3h43pQP3AsVv3qH2sUtiPWPLj5dX+FlAjaxRWxPuu67n6I5JZTpbwJmdp6ziUdvaQXPRRDH+YIgc7ZGlRQRJitA8iO4qO+ryj4a5j01Jc5Ghb+zjZkbDfzP+I1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, May 09, 2024 at 01:39:07PM -0700, Axel Rasmussen wrote: > For real MCEs, various architectures print log messages when poisoned > memory is accessed (which results in a SIGBUS). These messages can be > important for users to understand the issue. > > On the other hand, we have the userfaultfd UFFDIO_POISON operation, > which can "simulate" memory poisoning. That particular process will get It also coveres swapin errors as we talked before, so not always SIM. I was thinking we should also do that report for swapin errors, however then I noticed it wasn't reported before the replacement of pte markers, in commit 15520a3f04, since 2022: @@ -3727,8 +3731,6 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) put_page(vmf->page); } else if (is_hwpoison_entry(entry)) { ret = VM_FAULT_HWPOISON; - } else if (is_swapin_error_entry(entry)) { - ret = VM_FAULT_SIGBUS; } else if (is_pte_marker_entry(entry)) { ret = handle_pte_marker(vmf); } else { So I am guessing it could be fine to just turn this report off to syslog. There will be a back-and-forth on this behavior, but hopefully this is even rarer than hwpoison so nobody will notice. With that, the idea looks valid to me, but perhaps a rename is needed. Maybe _QUIESCE or _SILENT? > SIGBUS on access to the memory, but this effect is tied to an MM, rather > than being global like a real poison event. So, we don't want to log > about this case to the global kernel log; instead, let the process > itself log or whatever else it wants to do. This avoids spamming the > kernel log, and avoids e.g. drowning out real events with simulated > ones. > > To identify this situation, add a new VM_FAULT_HWPOISON_SIM flag. This > is expected to be set *in addition to* one of the existing > VM_FAULT_HWPOISON or VM_FAULT_HWPOISON_LARGE flags (which are mutually > exclusive). > > Signed-off-by: Axel Rasmussen > --- > arch/parisc/mm/fault.c | 7 +++++-- > arch/powerpc/mm/fault.c | 6 ++++-- > arch/x86/mm/fault.c | 6 ++++-- > include/linux/mm_types.h | 5 +++++ > mm/hugetlb.c | 3 ++- > mm/memory.c | 2 +- > 6 files changed, 21 insertions(+), 8 deletions(-) > > diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c > index c39de84e98b0..e5370bcadf27 100644 > --- a/arch/parisc/mm/fault.c > +++ b/arch/parisc/mm/fault.c > @@ -400,9 +400,12 @@ void do_page_fault(struct pt_regs *regs, unsigned long code, > #ifdef CONFIG_MEMORY_FAILURE > if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) { > unsigned int lsb = 0; > - printk(KERN_ERR > + > + if (!(fault & VM_FAULT_HWPOISON_SIM)) { > + pr_err( > "MCE: Killing %s:%d due to hardware memory corruption fault at %08lx\n", > - tsk->comm, tsk->pid, address); > + tsk->comm, tsk->pid, address); > + } > /* > * Either small page or large page may be poisoned. > * In other words, VM_FAULT_HWPOISON_LARGE and > diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c > index 53335ae21a40..ac5e8a3c7fba 100644 > --- a/arch/powerpc/mm/fault.c > +++ b/arch/powerpc/mm/fault.c > @@ -140,8 +140,10 @@ static int do_sigbus(struct pt_regs *regs, unsigned long address, > if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) { > unsigned int lsb = 0; /* shutup gcc */ > > - pr_err("MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n", > - current->comm, current->pid, address); > + if (!(fault & VM_FAULT_HWPOISON_SIM)) { > + pr_err("MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n", > + current->comm, current->pid, address); > + } > > if (fault & VM_FAULT_HWPOISON_LARGE) > lsb = hstate_index_to_shift(VM_FAULT_GET_HINDEX(fault)); > diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c > index e4f3c7721f45..16d077a3ad14 100644 > --- a/arch/x86/mm/fault.c > +++ b/arch/x86/mm/fault.c > @@ -928,9 +928,11 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address, > struct task_struct *tsk = current; > unsigned lsb = 0; > > - pr_err_ratelimited( > + if (!(fault & VM_FAULT_HWPOISON_SIM)) { > + pr_err_ratelimited( > "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n", > - tsk->comm, tsk->pid, address); > + tsk->comm, tsk->pid, address); > + } > if (fault & VM_FAULT_HWPOISON_LARGE) > lsb = hstate_index_to_shift(VM_FAULT_GET_HINDEX(fault)); > if (fault & VM_FAULT_HWPOISON) > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > index 5240bd7bca33..7f8fc3efc5b2 100644 > --- a/include/linux/mm_types.h > +++ b/include/linux/mm_types.h > @@ -1226,6 +1226,9 @@ typedef __bitwise unsigned int vm_fault_t; > * @VM_FAULT_HWPOISON_LARGE: Hit poisoned large page. Index encoded > * in upper bits > * @VM_FAULT_SIGSEGV: segmentation fault > + * @VM_FAULT_HWPOISON_SIM Hit poisoned, PTE marker; this indicates a > + * simulated poison (e.g. via usefaultfd's > + * UFFDIO_POISON), not a "real" hwerror. > * @VM_FAULT_NOPAGE: ->fault installed the pte, not return page > * @VM_FAULT_LOCKED: ->fault locked the returned page > * @VM_FAULT_RETRY: ->fault blocked, must retry > @@ -1245,6 +1248,7 @@ enum vm_fault_reason { > VM_FAULT_HWPOISON = (__force vm_fault_t)0x000010, > VM_FAULT_HWPOISON_LARGE = (__force vm_fault_t)0x000020, > VM_FAULT_SIGSEGV = (__force vm_fault_t)0x000040, > + VM_FAULT_HWPOISON_SIM = (__force vm_fault_t)0x000080, > VM_FAULT_NOPAGE = (__force vm_fault_t)0x000100, > VM_FAULT_LOCKED = (__force vm_fault_t)0x000200, > VM_FAULT_RETRY = (__force vm_fault_t)0x000400, > @@ -1270,6 +1274,7 @@ enum vm_fault_reason { > { VM_FAULT_HWPOISON, "HWPOISON" }, \ > { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \ > { VM_FAULT_SIGSEGV, "SIGSEGV" }, \ > + { VM_FAULT_HWPOISON_SIM, "HWPOISON_SIM" }, \ > { VM_FAULT_NOPAGE, "NOPAGE" }, \ > { VM_FAULT_LOCKED, "LOCKED" }, \ > { VM_FAULT_RETRY, "RETRY" }, \ > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 65456230cc71..2b4e0173e806 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -6485,7 +6485,8 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, > pte_marker_get(pte_to_swp_entry(entry)); > > if (marker & PTE_MARKER_POISONED) { > - ret = VM_FAULT_HWPOISON_LARGE | > + ret = VM_FAULT_HWPOISON_SIM | > + VM_FAULT_HWPOISON_LARGE | > VM_FAULT_SET_HINDEX(hstate_index(h)); > goto out_mutex; > } > diff --git a/mm/memory.c b/mm/memory.c > index d2155ced45f8..29a833b996ae 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -3910,7 +3910,7 @@ static vm_fault_t handle_pte_marker(struct vm_fault *vmf) > > /* Higher priority than uffd-wp when data corrupted */ > if (marker & PTE_MARKER_POISONED) > - return VM_FAULT_HWPOISON; > + return VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_SIM; > > if (pte_marker_entry_uffd_wp(entry)) > return pte_marker_handle_uffd_wp(vmf); > -- > 2.45.0.118.g7fe29c98d7-goog > -- Peter Xu