Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp91808lqo; Thu, 9 May 2024 13:39:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXhZ3UmTb2D9LgXO5CUjencA13Fxe05My+uz9urRBvOWhXkQB/GrLPv3sW8iIgGD/myu0GepOk+KdOks4nv9tvY8ZO208e+X7U+EepWgQ== X-Google-Smtp-Source: AGHT+IH56oOBSH9IYIAK4fnHtKmfJxh/KNqzRxUZl/gPMx6RBvYaIue6u8C27vRY3WNpCPKmMitc X-Received: by 2002:a17:90b:695:b0:2ae:c8fe:a4a4 with SMTP id 98e67ed59e1d1-2b6ccd8e060mr527758a91.46.1715287182879; Thu, 09 May 2024 13:39:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715287182; cv=pass; d=google.com; s=arc-20160816; b=cgU7cs6mLi3oaWT51D0Lps9k/cyW00JE1NvFM2f5yoLurxJ9dFRR6YiRHSfFZj4vw3 guMzE9yWxs1aAeBWYQdCNBPBstV9eqcBM6W+YFPPEfeyv9TCFEbY4WJccAONTuwWr8zP l7XSfRL4PM9h6arLaBwa+1e53JP07yLbbhHO/c230q4h9kg1CzYiL8PogY44A02u4oJ4 l/kW3eJkXckMcE8eiU65MmReXZzDQ6/vTmQSt76qwlnX8ycp+HXGhsfyIplFQSIH+i85 i1BNhKN87ayRcTzaVRDDm2QM961oiVZHGrz8AaRq2d+zN0HPhR1imo13PvxItgxeQzlt rg5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=72EB+jPmMFAxQhDugLcn3MtcnlhS5/KVvKJQ1v/oDoM=; fh=iMESCro4s+VaRiW4NkWIzUFVD5+04CngtnyuB8L2EhU=; b=aKV8BJ0RC96XH8nndfPKildPrpoI6IgPftvt3ZJnbQDJZvmvIRQ87BSb8AmqXPLuYi lYEgz1dP/HbaFo9zsVq0Y+h9Q5o8tKoebDKKdhDLMCVKtpAbBL3AzadXj1ew+ZeANxhl F17OAsfY7EUfIbN040RWfplnwaG+MIg/3A8snf/Bxpt4QAL5JSBbjSY1+iQxS7jcO9nD XRcqHM+vJ7MIO8lL1Hf1QB4R3b8hAdIyCWqZGm7D3fJAcS2DjqtyW1MGVrI/3FMZdI0I APAx02e6Mn0SSMtzYKhs3k6JtwXvnJaKlZo2iCkLs5wtyb3k76+yNL2Mjtcy8LqoWs1O hLaw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=FZQNA1aq; arc=pass (i=1 spf=pass spfdomain=flex--axelrasmussen.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-174938-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174938-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b628868bcdsi2624753a91.11.2024.05.09.13.39.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 13:39:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174938-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=FZQNA1aq; arc=pass (i=1 spf=pass spfdomain=flex--axelrasmussen.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-174938-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174938-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 4A98C282825 for ; Thu, 9 May 2024 20:39:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6771782C7E; Thu, 9 May 2024 20:39:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FZQNA1aq" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 9905D7FBBE for ; Thu, 9 May 2024 20:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715287156; cv=none; b=TIBcKthtHvdSXuSbaZSX8z/peL/znZp2zW+HbbaxdnvT6x+ObRyorPLzmby6nGK5w0wxMtn96duAScTGcRXNZvW0VZturzDZbcnT4ZfZl3CvxumawcZZ3YyqPdZKvGsXSP7SnYCzoleWDo6pM0UGq8Ec2i1+Y+Sa0/gXeEEjaT4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715287156; c=relaxed/simple; bh=OgELSVNmqwbZweBAv9t8WIscVMIPvXW0Q9emR5MQyYk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bvpxy+uVT8wwov0Ql6lqcIyPuigUdUU3Pp3TcLIfoc7QqEn0LR0+bY0ntBwwLvUS1gqIREG19vGPExWIMvKTdUB3z6a3uQOuqr/NU0X9VZinLn7XPfrRCjiZ4N0kaNuiRrVBWjq2x7stY7XyFt9AWqeXAoxXp3OzMW21dmCmVcc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--axelrasmussen.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=FZQNA1aq; arc=none smtp.client-ip=209.85.219.202 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=flex--axelrasmussen.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-deb45f85880so2031352276.2 for ; Thu, 09 May 2024 13:39:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715287154; x=1715891954; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=72EB+jPmMFAxQhDugLcn3MtcnlhS5/KVvKJQ1v/oDoM=; b=FZQNA1aqucPBciveBgbDZB2RAKL0C/HkhdldlvyPYtbEVn/lLnbweZvrtsjlajMeWA XtuPrG1hWmR1Y31Tv78QClEL0Y5JQAXPM4cGlNJqBGut9Xkj5/pxU6DT0JIRK7qyaZba RI/LpXG2bc9wXGjIz73Uhmtrl4Zd2VqIhlq63PqpoSkPL2PbAkzKyhO718ceQzsPlCIT U1eILyspkPphTG/niqwVfHlezmESnUGJ+Dqb1kiRJcvAyBybY3M3P6PkZJ11JB/SsWpp 6FN07FjzS+LM3g2PWa1PwkZgpKyHUpYxtgCVz6558dTPmCaALNYevVtzjnJ3qfddiYmC JmnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715287154; x=1715891954; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=72EB+jPmMFAxQhDugLcn3MtcnlhS5/KVvKJQ1v/oDoM=; b=LMBhdhXIJEzvjNEFOX7hGFGt+ETiaotCdjI6yP6N5QU7SKpDV1PImCMwRry758FoLL nXcJRq3+zlQpB2ny+UxrmyChByewCLW70mQf9AK00pl5E9yJK85BHObqJURV+fbHI0cj uPslrzMOWQ3ooNIaxCkmnHVfCi7I/QfXWplntaXjBt5MfTLOkw5nOliH2aDqPJ1hB70N Ttr7UjkFwHU4rQ58dT+S/+kCJHsLa7QfpzOMqCMmNgHtWaTug7MnzW0YrpxlwbyH3F9i mQjUpAFgiZfoiZf7tT45wpZYo0niTeut0E9TaT+2d1TLLNwL87ky0eZM1i3qu+rcvmEq g06Q== X-Forwarded-Encrypted: i=1; AJvYcCV5HDJu/h5uhKgkfRuKPOjwXLk4rGQie4P+Q0zlPWBPcztIIxAn5szEgSHO3MyzFknV6O2maf6JyJmurjP7tTb4m5zNnfxDAgYh9SJa X-Gm-Message-State: AOJu0YwQTbADPb2MKHf+f3rEuy87cXreYk2KWpOj3NzR9f2tZlbvnPSg gsz7Wlmr7UoMikT8xtTmnwJ6wv+mn6jkiEc6gNlpQfQ3p/B8fvd6hqYIA2TbwpouTFr5hIaXiPM koXgSewROcO/sF2BpHs05ofvnDLMQDw== X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:22b1:9c9e:3544:83b8]) (user=axelrasmussen job=sendgmr) by 2002:a05:6902:c09:b0:de5:5304:3206 with SMTP id 3f1490d57ef6-dee4f52d715mr74188276.11.1715287153666; Thu, 09 May 2024 13:39:13 -0700 (PDT) Date: Thu, 9 May 2024 13:39:07 -0700 In-Reply-To: <20240509203907.504891-1-axelrasmussen@google.com> 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> X-Mailer: git-send-email 2.45.0.118.g7fe29c98d7-goog Message-ID: <20240509203907.504891-2-axelrasmussen@google.com> Subject: [PATCH 1/1] arch/fault: don't print logs for simulated poison errors From: Axel Rasmussen To: 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 Xu , Peter Zijlstra , Suren Baghdasaryan , Thomas Gleixner Cc: Axel Rasmussen , 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" 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, 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