git: c13e9968db3b - stable/13 - mca: Add sysctl to mute corrected errors.

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Mon, 15 Aug 2022 17:57:23 UTC
The branch stable/13 has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=c13e9968db3bece3d6dd8d17c0a0bce5ef204967

commit c13e9968db3bece3d6dd8d17c0a0bce5ef204967
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2022-08-05 17:40:57 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2022-08-15 17:29:13 +0000

    mca: Add sysctl to mute corrected errors.
    
    Setting hw.mca.log_corrected to 0 will mute corrected errors logging
    except ones marked as reaching Yellow threshold by hardware.
    
    MFC after:      1 week
    
    (cherry picked from commit ac64943ca8514382289e6054e8127726a7c40ea3)
---
 sys/x86/x86/mca.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/sys/x86/x86/mca.c b/sys/x86/x86/mca.c
index e3386b5b7459..58630fae0781 100644
--- a/sys/x86/x86/mca.c
+++ b/sys/x86/x86/mca.c
@@ -109,6 +109,10 @@ static int mca_enabled = 1;
 SYSCTL_INT(_hw_mca, OID_AUTO, enabled, CTLFLAG_RDTUN, &mca_enabled, 0,
     "Administrative toggle for machine check support");
 
+static int log_corrected = 1;
+SYSCTL_INT(_hw_mca, OID_AUTO, log_corrected, CTLFLAG_RWTUN, &log_corrected, 0,
+    "Log corrected errors to the console");
+
 static int amd10h_L1TP = 1;
 SYSCTL_INT(_hw_mca, OID_AUTO, amd10h_L1TP, CTLFLAG_RDTUN, &amd10h_L1TP, 0,
     "Administrative toggle for logging of level one TLB parity (L1TP) errors");
@@ -426,7 +430,12 @@ mca_log(const struct mca_record *rec)
 	uint16_t mca_error;
 
 	if (mca_mute(rec))
-	    	return;
+		return;
+
+	if (!log_corrected && (rec->mr_status & MC_STATUS_UC) == 0 &&
+	    (!tes_supported(rec->mr_mcg_cap) ||
+	    ((rec->mr_status & MC_STATUS_TES_STATUS) >> 53) != 0x2))
+		return;
 
 	printf("MCA: Bank %d, Status 0x%016llx\n", rec->mr_bank,
 	    (long long)rec->mr_status);