From patchwork Fri May 10 18:29:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 13661818 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 09CC0C25B75 for ; Fri, 10 May 2024 18:29:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 786EB6B0082; Fri, 10 May 2024 14:29:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 735E26B00C3; Fri, 10 May 2024 14:29:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53C7B6B00E3; Fri, 10 May 2024 14:29:37 -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 378816B0082 for ; Fri, 10 May 2024 14:29:37 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id CADEB12036B for ; Fri, 10 May 2024 18:29:36 +0000 (UTC) X-FDA: 82103324352.30.097A602 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf07.hostedemail.com (Postfix) with ESMTP id 1329D4000A for ; Fri, 10 May 2024 18:29:34 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=1OirBff+; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf07.hostedemail.com: domain of 3jmc-Zg0KCI8tGx4AtB5DBBx6z77z4x.v75416DG-553Etv3.7Az@flex--axelrasmussen.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3jmc-Zg0KCI8tGx4AtB5DBBx6z77z4x.v75416DG-553Etv3.7Az@flex--axelrasmussen.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715365775; 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=djjgV/EOUSgIiHJsIm8AWGF7ff5q1uXyb7dMjfHKhrI=; b=BriDKeAei/idF4KykvSIBtOqjeyGmoogQ8vQYxfwcraMwx+8QVK+DIwD1nkg2VcQWoaprd sNLjDvzjNsN+2iHxmzaRVahBjwLGVx7I4zxKK9bzThYjroN9qSwJrPaLQbNs3MvI5XdhE7 1Ns9nUMjKPEqdM7xhrLpaMVIbmbzKPI= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=1OirBff+; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf07.hostedemail.com: domain of 3jmc-Zg0KCI8tGx4AtB5DBBx6z77z4x.v75416DG-553Etv3.7Az@flex--axelrasmussen.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3jmc-Zg0KCI8tGx4AtB5DBBx6z77z4x.v75416DG-553Etv3.7Az@flex--axelrasmussen.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715365775; a=rsa-sha256; cv=none; b=7jbKn7b0muM1sQK1SHjuZaEyiyLVW6kfNwB32WYfyD/dNiS50FGYvkL8vYg4DTTGZTLrJs hUS1GDgB0PsVv8e5YMCSSz/BkC7E/42vegEdLsPseXYXhfAW2a+hfY3aNP2DKXvDsOIuX3 qVgk+u7Wzcm1Luu4PkA2SJDUDtQLLdI= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-de60321ce6cso4121238276.1 for ; Fri, 10 May 2024 11:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715365774; x=1715970574; darn=kvack.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=djjgV/EOUSgIiHJsIm8AWGF7ff5q1uXyb7dMjfHKhrI=; b=1OirBff+uAGJg1tXHZaQJ1rf0T/4YBIG86VTFsyRpjIrdE32eimpcTn8WhOwcu4Wa9 K7XBbEi7QrBpYrwNzl2ZiWwYqidzMTsNLTtSpQhCT1i8QvzT9ELh11mkBlOrB/tRLARo teDuLdJWUPBZeXZ4f3LbMV6eqFqEtJaXrvDYJCy4ngqOptvD7j+Nx0WrDE9o4GkqFS3e kaU3sortxmKVyss3xVsnpbGC71yVhGoykjk90NbDdnhZ4uOHBktuPBfpa9TF/FXVugOT j5vK/KpiPEd4zNSQlypzbqMZGMJFTPGjtH6bkVret1EGFweNxjTZtkG9D592I4zUpYB2 pYHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715365774; x=1715970574; 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=djjgV/EOUSgIiHJsIm8AWGF7ff5q1uXyb7dMjfHKhrI=; b=QYJPI+Ti4xnLpQ4n5xd1G0ohDWKjeKHxa2NBjr1Cjzv5PwjsChnqeR1xnUvpik/uAS wCeu1FEQ7eK4ik0jt1kRMyw80kyvUqLB1aotprzhc0x8gPU+BGNMGWB+2U5aH30yb/SZ 9X2mxrzZfJRwjATyi8lxefV4e2/9ujX2oAfHcS2Lbm2Lopy/VWKUOVQYPwvIrwv2zL2/ YxOXJB3u5lH/FkZaUN7yb4Agu6vLa/FlfHPA2gMv86IzgiQ4oifZCmhrOp4M0JwxH/pi hKNVS7HP4lYMjxn++AqM0P9yN7v/NTxWPOSUusyOXKEGbDm8D60k0CxYNlZR59Xb8s0g df8A== X-Forwarded-Encrypted: i=1; AJvYcCWpmhozS+zIKuMw8MW9NRTkEQTF5qHEouBL62pcrjde5ucedIQKClNldwvwDpqGfW3ubP7r0J6U8MCsKAJsKeeT/7I= X-Gm-Message-State: AOJu0Yz+minc7PHrhnbRSLjA6Li+BhOmfjRhljp15utnEYkFVfgenofX 1VC6QG+Oi1GqYNU3cYBlU83ZYhS/GrwpPEN7CjbeJr3K7QEScifPaR5qe5Oo2xg+SOuPF5cJv/C 8p2MJCnbbQ9N+4WQVeti7D5HPMlneIw== X-Google-Smtp-Source: AGHT+IFerzf95SQt68BSPyg+4slciMy+Qp5Bl/3q5GPRPhHSBZLEJUwSa5o+N+XqGo0DxsH3At45CJWu36ItLUenUz2D X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:6f94:7fe7:5ca2:5501]) (user=axelrasmussen job=sendgmr) by 2002:a05:6902:1890:b0:dee:60e9:69f4 with SMTP id 3f1490d57ef6-dee60e96aeemr201789276.10.1715365774181; Fri, 10 May 2024 11:29:34 -0700 (PDT) Date: Fri, 10 May 2024 11:29:26 -0700 In-Reply-To: <20240510182926.763131-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20240510182926.763131-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.45.0.118.g7fe29c98d7-goog Message-ID: <20240510182926.763131-2-axelrasmussen@google.com> Subject: [PATCH v2 1/1] arch/fault: don't print logs for pte marker 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 X-Rspamd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QqxAdpW4veSAlmYu P48+IQdD B6mt0PYY/F8AU6f2FzilCjkMenvV6VXg1bm+vI6wMPtMS4NCMqohWzOnLN2MAGFhIfhBMFECk0ixSBH+fAILO9BRMl93TGw0gHbFiUZOupVUbmlAUQlfUTMty6u1wgM6RKn4vhWJbMrdAp0d0PTqKBuIrczxPmhKnIv2dmzo7Ae2iGUOkG5Z4vZMv57Gh9GQOakTsJRo7UZ4U7aTT/QQc/1TcdwRMFGzAxNHgKMpujdZiUtd6ThwGHhqsZfbdi9o25eBK+1HQ51mL+zFtEEBiF30CNcSp+V6vUHEoXcjmswegIN3ck8r8abq6IolEDYOX3GmbBXlVhXQQQn++/+qAfjBBcKdp1UVCjdizY17uzy/dZ4thnL4Wk2lXtC3vJcuHTF966eqEetORUsLBbEv6C4JzNYsQNykoMz9ucdQDeCGXeEGKNygockNyDMdyEJZSaahXabz83R4+OhCn1qrzfFrqtlz4QQINqO3y6X1K026qJ6XIQTPad2dmJsnQdD3fyWI3IPhz6HIfAfgkxmA9tJHQ8jJ2d8n5LF7iCmVTQpH7mdu9HI6DeRYo36lD5j8yc+80+LuDCQeP7CbevwQglVQ/cxj3spj9Oos7icOl40z/Wbs5bp1bW69hbFbSqgdp110MletxuVr9LuUPK2jcTwtpNePL1pWGnPSeKLh90lsD5IQWSe26YYl2yRlSc78hyCp9 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: 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 two other cases: swapin errors and simulated poisons via UFFDIO_POISON. These cases also result in SIGBUS, but they aren't "real" hardware memory poisoning events, so we want to avoid logging MCE error messages to dmesg for these events. This avoids spamming the kernel log, and possibly drowning out real events with these other cases. To identify this situation, add a new VM_FAULT_HWPOISON_SILENT 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). Reviewed-by: John Hubbard Signed-off-by: Axel Rasmussen Acked-by: Peter Xu --- arch/parisc/mm/fault.c | 7 +++++-- arch/powerpc/mm/fault.c | 6 ++++-- arch/x86/mm/fault.c | 6 ++++-- include/linux/mm_types.h | 34 ++++++++++++++++++++-------------- mm/hugetlb.c | 3 ++- mm/memory.c | 2 +- 6 files changed, 36 insertions(+), 22 deletions(-) diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c index c39de84e98b0..6c5e8d6498bf 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_SILENT)) { + 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 215690452495..c43bb6193a80 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c @@ -147,8 +147,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_SILENT)) { + 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 67b18adc75dd..9ae5cc6bd933 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -964,9 +964,11 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address, struct task_struct *tsk = current; unsigned lsb = 0; - pr_err( + if (!(fault & VM_FAULT_HWPOISON_SILENT)) { + pr_err( "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 24323c7d0bd4..7663a2725341 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -1224,6 +1224,10 @@ 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_SILENT Hit a poisoned pte marker, which should not be + * logged to dmesg since it's something besides a + * real hardware memory error (swapin error, + * simulated poison via UFFDIO_POISON, etc.). * @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 @@ -1237,20 +1241,21 @@ typedef __bitwise unsigned int vm_fault_t; * */ enum vm_fault_reason { - VM_FAULT_OOM = (__force vm_fault_t)0x000001, - VM_FAULT_SIGBUS = (__force vm_fault_t)0x000002, - VM_FAULT_MAJOR = (__force vm_fault_t)0x000004, - 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_NOPAGE = (__force vm_fault_t)0x000100, - VM_FAULT_LOCKED = (__force vm_fault_t)0x000200, - VM_FAULT_RETRY = (__force vm_fault_t)0x000400, - VM_FAULT_FALLBACK = (__force vm_fault_t)0x000800, - VM_FAULT_DONE_COW = (__force vm_fault_t)0x001000, - VM_FAULT_NEEDDSYNC = (__force vm_fault_t)0x002000, - VM_FAULT_COMPLETED = (__force vm_fault_t)0x004000, - VM_FAULT_HINDEX_MASK = (__force vm_fault_t)0x0f0000, + VM_FAULT_OOM = (__force vm_fault_t)0x000001, + VM_FAULT_SIGBUS = (__force vm_fault_t)0x000002, + VM_FAULT_MAJOR = (__force vm_fault_t)0x000004, + 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_SILENT = (__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, + VM_FAULT_FALLBACK = (__force vm_fault_t)0x000800, + VM_FAULT_DONE_COW = (__force vm_fault_t)0x001000, + VM_FAULT_NEEDDSYNC = (__force vm_fault_t)0x002000, + VM_FAULT_COMPLETED = (__force vm_fault_t)0x004000, + VM_FAULT_HINDEX_MASK = (__force vm_fault_t)0x0f0000, }; /* Encode hstate index for a hwpoisoned large page */ @@ -1268,6 +1273,7 @@ enum vm_fault_reason { { VM_FAULT_HWPOISON, "HWPOISON" }, \ { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \ { VM_FAULT_SIGSEGV, "SIGSEGV" }, \ + { VM_FAULT_HWPOISON_SILENT, "HWPOISON_SILENT" }, \ { VM_FAULT_NOPAGE, "NOPAGE" }, \ { VM_FAULT_LOCKED, "LOCKED" }, \ { VM_FAULT_RETRY, "RETRY" }, \ diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 6be78e7d4f6e..91517cd7f44c 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(vmf.orig_pte)); if (marker & PTE_MARKER_POISONED) { - ret = VM_FAULT_HWPOISON_LARGE | + ret = VM_FAULT_HWPOISON_SILENT | + 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 eea6e4984eae..721c0731cef2 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3938,7 +3938,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_SILENT; if (pte_marker_entry_uffd_wp(entry)) return pte_marker_handle_uffd_wp(vmf);