From nobody Thu Dec 09 01:35:36 2021 X-Original-To: dev-commits-src-branches@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 B643218D2407; Thu, 9 Dec 2021 01:35:36 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J8c6w3SSbz3KrS; Thu, 9 Dec 2021 01:35:36 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4D09B1DDCC; Thu, 9 Dec 2021 01:35:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1B91ZafT058981; Thu, 9 Dec 2021 01:35:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B91ZamZ058980; Thu, 9 Dec 2021 01:35:36 GMT (envelope-from git) Date: Thu, 9 Dec 2021 01:35:36 GMT Message-Id: <202112090135.1B91ZamZ058980@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 447d2569d69f - stable/13 - APEI: Fix Generic Error Data Entry revision 3.0 handling. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 447d2569d69f5ae698f990984bc36af0818e4cf3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639013736; 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=s4ecDbkedX3gB9AksQU0KjWeYkvXE35qPCAvKf/PCWE=; b=i2jFzyjd1TNWrLRwJkZfNKUU8zwBLTr7iFEM0lFQjzUxffPixlrU2zSavjnOe7zIlNk377 qMPibVHnd5uBZgVSRR/K3o6f+K+bcNe1ziVLAeuVKafibRmYQ8Xg5XW6qtFHn1bLz9++0C RPBh2nWx0H5RrlnKKzEjH0RfuZ5dDTFgaK5zeRm3793oNHnvKcQ0wtL1tcdB8W3ugRtT8Z +YiJWouJSX/qI4orSVyva+a8tvlUu5kxiPVqmW+RjktB5eNZbPxjr088ldbIe30Sd8a497 pr8m3kBXkBldXpE3ZFJXfmVY7Ncb7zg+wXT/q4KYolszGg/V5ZItz2l1+A+Yyg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639013736; a=rsa-sha256; cv=none; b=SdWWFQLoCuZSVsEyEulp+2q58SwydGdnUBDUzq4TvoAACoHKtvO3i4P/00Vmyo9U+7IpKM fXBU+CTHd9A6YndUNSslrAEjG0TOwh8jx4PFJCUnNeI2+WBGgL5FEDyCmHxwtNCPgaPap0 4MsOTmolXzIJ73fiTh63/2jeS/NzgvvzcoT3U0ZzdjOWVG/p0jvWKRS9tu4Pg5QKn/yVHl 5DY8Nj2L1BCua+D3Ir6bZxEPAalHuIK7ZLKEe08IMUbgX0vOVD4pw4PI7Z+pEnS6HkChfn 1K2yW41juQJaiKifEOtmcdwan9c0PzbMWnSvY59BgZP09e+0OIrihQ2hDMUuqA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=447d2569d69f5ae698f990984bc36af0818e4cf3 commit 447d2569d69f5ae698f990984bc36af0818e4cf3 Author: Alexander Motin AuthorDate: 2021-11-25 04:03:20 +0000 Commit: Alexander Motin CommitDate: 2021-12-09 01:35:21 +0000 APEI: Fix Generic Error Data Entry revision 3.0 handling. Since revision 3.0 this structure grown another field, breaking access to the following data structures. This change fixes the PCIe errors decoding on newer systems. MFC after: 2 weeks (cherry picked from commit ba83762a623033576bab5942312365d2d738f437) --- sys/dev/acpica/acpi_apei.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sys/dev/acpica/acpi_apei.c b/sys/dev/acpica/acpi_apei.c index bc1f38f2fc8f..d4bc38887d9e 100644 --- a/sys/dev/acpica/acpi_apei.c +++ b/sys/dev/acpica/acpi_apei.c @@ -131,6 +131,10 @@ apei_bus_write_8(struct resource *res, bus_size_t offset, uint64_t val) #define WRITE8(r, o, v) bus_write_8((r), (o), (v)) #endif +#define GED_SIZE(ged) ((ged)->Revision >= 0x300 ? \ + sizeof(ACPI_HEST_GENERIC_DATA_V300) : sizeof(ACPI_HEST_GENERIC_DATA)) +#define GED_DATA(ged) ((uint8_t *)(ged) + GED_SIZE(ged)) + int apei_nmi_handler(void); static const char * @@ -152,7 +156,7 @@ apei_severity(uint32_t s) static int apei_mem_handler(ACPI_HEST_GENERIC_DATA *ged) { - struct apei_mem_error *p = (struct apei_mem_error *)(ged + 1); + struct apei_mem_error *p = (struct apei_mem_error *)GED_DATA(ged); printf("APEI %s Memory Error:\n", apei_severity(ged->ErrorSeverity)); if (p->ValidationBits & 0x01) @@ -207,7 +211,7 @@ apei_mem_handler(ACPI_HEST_GENERIC_DATA *ged) static int apei_pcie_handler(ACPI_HEST_GENERIC_DATA *ged) { - struct apei_pcie_error *p = (struct apei_pcie_error *)(ged + 1); + struct apei_pcie_error *p = (struct apei_pcie_error *)GED_DATA(ged); int h = 0, off; #ifdef DEV_PCI device_t dev; @@ -314,7 +318,7 @@ apei_ged_handler(ACPI_HEST_GENERIC_DATA *ged) t[3], t[2], t[1], t[0], t[5], t[4], t[7], t[6], t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15]); printf(" Error Data:\n"); - t = (uint8_t *)(ged + 1); + t = (uint8_t *)GED_DATA(ged); for (off = 0; off < ged->ErrorDataLength; off++) { printf(" %02x", t[off]); if ((off % 16) == 15 || off + 1 == ged->ErrorDataLength) @@ -334,7 +338,7 @@ apei_ged_handler(ACPI_HEST_GENERIC_DATA *ged) } if (ged->ValidationBits & ACPI_HEST_GEN_VALID_FRU_STRING) printf(" FRU Text: %.20s\n", ged->FruText); - if (ged->Revision == 0x300 && + if (ged->Revision >= 0x300 && ged->ValidationBits & ACPI_HEST_GEN_VALID_TIMESTAMP) printf(" Timestamp: %016jx\n", ged3->TimeStamp); } @@ -358,7 +362,7 @@ apei_ge_handler(struct apei_ge *ge, bool copy) for (off = i = 0; i < c && off + sizeof(*ged) <= ges->DataLength; i++) { ged = (ACPI_HEST_GENERIC_DATA *)&buf[sizeof(*ges) + off]; apei_ged_handler(ged); - off += sizeof(*ged) + ged->ErrorDataLength; + off += GED_SIZE(ged) + ged->ErrorDataLength; } /* Acknowledge the error has been processed. */