From nobody Wed Sep 18 14:37:24 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4X81T02L9tz5WWX7; Wed, 18 Sep 2024 14:37:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4X81T01sl7z4DjY; Wed, 18 Sep 2024 14:37:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726670244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9zQyQYyNhWXbBw8xJxVsFHwPSra1cWaCxulmBXkJ/ok=; b=gwOqSzO5kH9zbxmkxGHxTlM1ZRdZwnd+ukf7xurWLWxgNHtdyTzHSIf1IWXGJSoo3g6bSf LxGZvwrlSLq4kEIa3BfyAF4MXpDJb7457V3XXnd+LoCrFnxp/Cxsh222Nbvx776WGY6ZX+ b3EVZeb1pgdmm7JGUDwLPkD0VgPMWC4dtmhC5WnheM5EU4RyWKeQDfFEh0FlOGJD9S91Aj Yw0VMv5M0wiHiJzSAd1j9g+2UNXYwJ+7uEVINwqEj/18UjuVkdH5jLwOv/n6iZxvUxcGQ3 mLgo2w1wkT+MYAL5Y2x0nxqNNGstIa012ItsWV09UUZm/3rTxJ8DgrY4qsD+zw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1726670244; a=rsa-sha256; cv=none; b=s6KqAC8fWJSrSk1EIfJwBJMfKqph1XGlzjDLkFbjJGIQCtDAZQBeqrow+egUttq307BjgE T4TucxsK3rTUI6flhhnNWPob3TBSielqWEnRE3deEdX1/EcxmUk+XMaST/OS/Hyb/czear O6vCDzykOkEcBvvAth6OQJfnV5bEdiROvGEG9V98kpqHZ004ecsTuPdltkzmo8HGxxWgZi 9mBJW4bT7fvnJHTI0gCwoYe0EHir9scNL1m5sCPNLzjX73Cc1XhUT62xwnJzlnbuh9oVgw H5NHKUR4Xea7Tw0gjaTe7mSp2kS7q2bXWUCqeG8jVqQVnmITTszj5OP7Hc26gw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726670244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9zQyQYyNhWXbBw8xJxVsFHwPSra1cWaCxulmBXkJ/ok=; b=D/RJUS0oqggj2XWgT11Qjz7w+Ue/kJdzlqpnVtgSHisa0AjzIlNi5+v9t8EJ6QK32xbHt0 250NQPYQUsxaFgx8z/2b0YFQMsndLJwXB+uRoPN0Tvtou21gsFZk98zznKdhIOjWNdvGIF Sqo4OFTWTLJmDLBN9J/sRlmjVone19BBRuSB2qIbwo19Lux7Qnxj6UBHIreo6mfnGpYawL ut0IS9AGhcdSMthgLCasGN5j05D7UCAkseFBdVzhqkoH2C+R5/fgP45aRyJ4wJU2vUaLdP bNn43yxYj/8xTsEOuSoYd6+i78XkOq0t/Vq8zbe3z01nzAU/0WEnqRBeMBHZoQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4X81T018nNzQkf; Wed, 18 Sep 2024 14:37:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48IEbONd003811; Wed, 18 Sep 2024 14:37:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48IEbOC2003808; Wed, 18 Sep 2024 14:37:24 GMT (envelope-from git) Date: Wed, 18 Sep 2024 14:37:24 GMT Message-Id: <202409181437.48IEbOC2003808@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Stephen J. Kiernan" Subject: git: 996a832d2e01 - main - mca: Allow for passing ECC error record to memory controller driver List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: stevek X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 996a832d2e01fceb5a3bbfd33df585bd778e6288 Auto-Submitted: auto-generated The branch main has been updated by stevek: URL: https://cgit.FreeBSD.org/src/commit/?id=996a832d2e01fceb5a3bbfd33df585bd778e6288 commit 996a832d2e01fceb5a3bbfd33df585bd778e6288 Author: Stephen J. Kiernan AuthorDate: 2024-09-18 14:37:14 +0000 Commit: Stephen J. Kiernan CommitDate: 2024-09-18 14:37:14 +0000 mca: Allow for passing ECC error record to memory controller driver Added (de)registration functions for memory controller driver to be notified when ECC errors occur. This allows for decoding of the specific error by the driver. Submitted by: Lakshman Likith Nudurupati Sponsored by: Juniper Networks, Inc. Obtained from: Semihalf --- sys/x86/include/mca.h | 5 +++++ sys/x86/x86/mca.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/sys/x86/include/mca.h b/sys/x86/include/mca.h index 183480625f6d..d8b8da86523d 100644 --- a/sys/x86/include/mca.h +++ b/sys/x86/include/mca.h @@ -46,6 +46,11 @@ struct mca_record { #ifdef _KERNEL +typedef void (*mca_decode_func)(void *, const struct mca_record *); + +int mca_register_decode_func(mca_decode_func func, void *aux); +int mca_deregister_decode_func(mca_decode_func func); + void cmc_intr(void); void mca_init(void); void mca_intr(void); diff --git a/sys/x86/x86/mca.c b/sys/x86/x86/mca.c index b293fcedbd84..89ab59639882 100644 --- a/sys/x86/x86/mca.c +++ b/sys/x86/x86/mca.c @@ -99,6 +99,8 @@ static MALLOC_DEFINE(M_MCA, "MCA", "Machine Check Architecture"); static volatile int mca_count; /* Number of records stored. */ static int mca_banks; /* Number of per-CPU register banks. */ static int mca_maxcount = -1; /* Limit on records stored. (-1 = unlimited) */ +static mca_decode_func mca_func; +static void *mca_decode_arg; static SYSCTL_NODE(_hw, OID_AUTO, mca, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Machine Check Architecture"); @@ -421,6 +423,50 @@ mca_mute(const struct mca_record *rec) return (0); } +/* + * Pass mca_record to a memory controller driver so that it can decode + * the address and possibly do some more work. + */ +static void +mca_decode_record(const struct mca_record *rec) +{ + + if (mca_func != NULL) + mca_func(mca_decode_arg, rec); +} + +int +mca_register_decode_func(mca_decode_func func, void *aux) +{ + int error; + + if (func == NULL) + return (EINVAL); + + error = 0; + mtx_lock_spin(&mca_lock); + if (mca_func != NULL) + error = EEXIST; + + if (error == 0) { + mca_func = func; + mca_decode_arg = aux; + } + + mtx_unlock_spin(&mca_lock); + return (error); +} + +int +mca_deregister_decode_func(mca_decode_func func) +{ + if (func == NULL || func != mca_func) + return (EINVAL); + + mca_func = NULL; + return (0); +} + /* Dump details about a single machine check. */ static void mca_log(const struct mca_record *rec) @@ -613,6 +659,8 @@ mca_log(const struct mca_record *rec) } if (rec->mr_status & MC_STATUS_MISCV) printf("MCA: Misc 0x%llx\n", (long long)rec->mr_misc); + + mca_decode_record(rec); } static bool