Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp146940lqo; Thu, 9 May 2024 15:48:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU5DoFWi8aMaha+GoKpn9evojQ7Lmnz0827xIDyccnd1bd7rvAIpkgxcCrdteoTHW4PsDSsoP6gRIyzx+/elFJlaW0hnxpx2gZeEr2ziQ== X-Google-Smtp-Source: AGHT+IFqzkxswVfm9jHbEo/GuvTUwU4Qd3Th9fIdHf46GWH9mHcl3qZzCl4mwDBVx58vXEFpmQP1 X-Received: by 2002:a05:6a00:2e8f:b0:6f3:876a:c022 with SMTP id d2e1a72fcca58-6f4e0298553mr1017852b3a.1.1715294898914; Thu, 09 May 2024 15:48:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715294898; cv=pass; d=google.com; s=arc-20160816; b=N75nfxhni5J02W8HXYePVmk5PyImT+LkjXupVk0503SZFqrfG/9nGKANzi0p3zTkDh wb9t7GQyefqJmBMOo95fgzoZgoKdfFm+CR13bHd9TIFoqW9zY+aU8mSAdAESKNJ1iYyD bur3ZanH3C/Nj95/PyGwTjGpJc1fQqY7LGUc0r2VGo/BGlEBr0Lw8bJ8p7wGgcuCc0Wy VeqiBjz/E/CGev5kYZr1RkpHRT7qy3F73BU7fMO9gLOaDTx0Ys1jqTPh09Y87WeJ9Az0 IKGuCUSByYd9s/DDwiVNVRIRiNBLoyNX8t1Dh7cg0PzkeXYt9YuWLFxYH4DUzDwfzqv/ l0Fw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=YIWDSYU6OuwVNwMdVt3NyqDL4ZMH/MF1rCPe+F0j3bE=; fh=YjK6ApGzwfPq3w+yFGB+9AvcUFy7vyO0Jmh15EL2XFI=; b=gNZODB+BSpcG5/ks3Av2WA7U4s/oI4NNVRUYyAnI6dILFYXCLCUSzSnFMDQ+U2ZLOf JdwMrrfGbHJ81ND7cnrCZILOU6TbILe03tjEOsWi9Q5xBVO3151iz4O25ADdlLo1d15C f5RwddsQ+TOBPfZq/AeZp0ojSvUioYAFVO2tyaX1hvBtb/sXtIdakELRJZGEEEooR3Yq 6NdAGa2S3QWjcWk6kjU/CPoQW32Qs+/7GdeLqZuI3BE7Spj3cw9L//7qrltuoxqc+0Fg SMxNzGroxK7bV6y/cpJWxJBU5B1LvgGJKJCAkwsTMP4BUV4FnVzgki3oyGX2BNwWSLky gvcw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=AQ+rQdz7; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-175050-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175050-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-63412a4dfddsi2145055a12.711.2024.05.09.15.48.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 15:48:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175050-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=AQ+rQdz7; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-175050-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175050-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 787822835EE for ; Thu, 9 May 2024 22:48:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77AE012D209; Thu, 9 May 2024 22:48:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AQ+rQdz7" Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4493912DD94 for ; Thu, 9 May 2024 22:48:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715294890; cv=none; b=BZaWKi54/O6WzSMcdLmzW7Ci2eJmesc7V7M/k12+mOCzTJoC7WPD7C6r8FGu5O1UQULVBHOTdYgAVtkjkkU0eBiGVMIWEFRladCT04hL0q4cNB4QFw/95yHFePs85n2W/eJiNiDnHfKrKgOjQ7jCDw1KGne4U0sbb678WYMHuHY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715294890; c=relaxed/simple; bh=3pQ2pM0pNtObEYnZAZ2vpgXGO/JvkW+6q5AWn6pdmPU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=GHrxTPm30p0Bg0LtyHnSXLLWxrzP5hsU1wTNzfsohQ7+kGG2BNjWOjommraiBs/orF1eCQhDXANkV+9R0UZfjVmlCIiJgkZlXeiArD1Ye0GUAIOTBwQnHM85DslOC4DhWUca6YEFQeEmWib9z1POIAtt4KaCd9rpfCIKtM1ylsM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=AQ+rQdz7; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-41dc9c83e57so13885055e9.0 for ; Thu, 09 May 2024 15:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715294886; x=1715899686; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=YIWDSYU6OuwVNwMdVt3NyqDL4ZMH/MF1rCPe+F0j3bE=; b=AQ+rQdz7blSFCviCN7OMSRrL/kuEMFX8gKxUdd1G0Wo4RwuH2950mOhgddCaClrvKO 2zx6dggk+zGsqZz357yd9cqtCfuk5WAZV8vdrvim5dv0TUw6u5CnLPS/R1tA5eLE5sEP Fj4TYbUb+nNX2ntkcLrhhjW/LHH+c+eC6vAD08ZOMUKK5wtM5K2XXAQa0dgBnqF8FInl L/FPHtANzfU1NvjNwGowsgby5eHPmd51Gy/kVklAci4Mws24esDQh5DtUJ3wse3/bFXw DhvfJ5S3pwofuEWoPKSIUdGrkruEMqGs/2hSxg6hQsLgoYlQRAWCJ8nh51Ymavg9YYEh Fi2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715294886; x=1715899686; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YIWDSYU6OuwVNwMdVt3NyqDL4ZMH/MF1rCPe+F0j3bE=; b=bbFCyGE4R65y6/UNpN7yse8Qc9HL/Ad60ckCBuLorz81IHK/wuWdzAM+0o4n65HvlT qmMMcMgxabf0R7BfFfBhOjM6s2TkGg7FDiN54YhHBQtaF3OvOYpDfK7h50AH0Fb1EL/i dbFJNAfHeZija8t4NJ+SN8X41xDH0WrfiyjROygogBEpOaQiFfKNN1ooGn2DFzs9K/q8 5OIg5Wy4q9Wl+movh71S0QJxyZUcWXitzr7O6UaiTa0yYenmL3XN+CiD8BiosFcCX2Ty a64ksZx8PoFkTVWTuytPpm6DB7G0Q6SQXdl/Mmmw/sWpXtM6Tn9gzeMhVokYwKRx03ts Q8/g== X-Forwarded-Encrypted: i=1; AJvYcCW4Jr2cmUoPQIXen0yZYqIUm1Ndy8JZ2Fsfk4v6g3xvM8Op+pMT+cfsoFn5uh8k1vk+BPThhf3eR332YPl4vIJk8Ul7Fzm9FrHrY1d/ X-Gm-Message-State: AOJu0Yx2I6SgEAWZfevVaInMQAdItpMLZu1RDbWgor9lm1PgdPu7EywA tNgoVINeNfXgSqgDazIT6FMn/PP2D0OJ990YlviaRnZ7HZl8siWrooK4/+sLjZJZUhl/WviZs6X 08K2fmlGj70QVsdjGJWX+jT98mAPyR999KOk5 X-Received: by 2002:a5d:5f4e:0:b0:350:4da3:db43 with SMTP id ffacd0b85a97d-3504da3dde7mr436361f8f.35.1715294886227; Thu, 09 May 2024 15:48:06 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240509203907.504891-1-axelrasmussen@google.com> <20240509203907.504891-2-axelrasmussen@google.com> In-Reply-To: From: Axel Rasmussen Date: Thu, 9 May 2024 15:47:29 -0700 Message-ID: Subject: Re: [PATCH 1/1] arch/fault: don't print logs for simulated poison errors To: John Hubbard 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" , Liu Shixin , "Matthew Wilcox (Oracle)" , Michael Ellerman , Muchun Song , "Naveen N. Rao" , Nicholas Piggin , Oscar Salvador , Peter Xu , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 9, 2024 at 2:30=E2=80=AFPM John Hubbard w= rote: > > On 5/9/24 1:39 PM, 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 > > SIGBUS on access to the memory, but this effect is tied to an MM, rathe= r > > 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(-) > > > > This completely fixes the uffd-unit-test behavior, I just did a quick > test run to be sure as well. > > Reviewed-by: John Hubbard Thanks John! And, no problem about the other patch, they aren't functionally dependent, I just hoped to save Andrew dealing with the small merge conflict. :) I'll base a v2 on mm-unstable directly and that should clear everything up. > > thanks, > -- > John Hubbard > NVIDIA > > > > 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 =3D 0; > > - printk(KERN_ERR > > + > > + if (!(fault & VM_FAULT_HWPOISON_SIM)) { > > + pr_err( > > "MCE: Killing %s:%d due to hardware memory corruption fault at %0= 8lx\n", > > - tsk->comm, tsk->pid, address); > > + tsk->comm, tsk->pid, address); > > + } > > /* > > * Either small page or large page may be poisone= d. > > * 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, unsigne= d long address, > > if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) { > > unsigned int lsb =3D 0; /* shutup gcc */ > > > > - pr_err("MCE: Killing %s:%d due to hardware memory corrupt= ion 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 =3D 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 erro= r_code, unsigned long address, > > struct task_struct *tsk =3D current; > > unsigned lsb =3D 0; > > > > - pr_err_ratelimited( > > + if (!(fault & VM_FAULT_HWPOISON_SIM)) { > > + pr_err_ratelimited( > > "MCE: Killing %s:%d due to hardware memory corruption fault at %l= x\n", > > - tsk->comm, tsk->pid, address); > > + tsk->comm, tsk->pid, address); > > + } > > if (fault & VM_FAULT_HWPOISON_LARGE) > > lsb =3D 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 en= coded > > * 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 I'll also fix this small typo in a v2. :P > > + * UFFDIO_POISON), not a "real" hwerror. > > * @VM_FAULT_NOPAGE: ->fault installed the pte, not re= turn 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 =3D (__force vm_fault_t)0x000010, > > VM_FAULT_HWPOISON_LARGE =3D (__force vm_fault_t)0x000020, > > VM_FAULT_SIGSEGV =3D (__force vm_fault_t)0x000040, > > + VM_FAULT_HWPOISON_SIM =3D (__force vm_fault_t)0x000080, > > VM_FAULT_NOPAGE =3D (__force vm_fault_t)0x000100, > > VM_FAULT_LOCKED =3D (__force vm_fault_t)0x000200, > > VM_FAULT_RETRY =3D (__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, st= ruct vm_area_struct *vma, > > pte_marker_get(pte_to_swp_entry(entry)); > > > > if (marker & PTE_MARKER_POISONED) { > > - ret =3D VM_FAULT_HWPOISON_LARGE | > > + ret =3D 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_fau= lt *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); > >