From patchwork Mon Jun 24 09:19:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 807332 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5ABDA2C95; Mon, 24 Jun 2024 09:19:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719220790; cv=none; b=bjirFwS+tigke7ugxTlyuM28ROM48L7e8GNZ1jOxXQ0Jc4lds6v392S4fOn0FUbEzwkftDDvz0GUyg8vjEwUiY9zRVWKhh35/WyfbzFrXh7ZjQ3Cg+uNmQ34FN2j9TtWscmQ/NgxCi0DMjmbKiyaJosiD8T1+ZQqdmTaUU7lDvY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719220790; c=relaxed/simple; bh=LayJjNlHt7RdDKs2eSpJizuqfyzjoPSkSmmLznNH6CU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aG9kZcpI12kkFV4EG8g2apUx3HcZDzdeH2ybDsp8CPuUnCZDCRJMK4kDR4YKX9uq4RdbvvjQFRN/LFzgS8h2Fb8eKKt+EXNfbBL6e3/txaIltEYsDGMr3FgZnoyFvgq0jImc9o5cm/0oRhw29chHMtMb1Nv40UhRwjzckGHkJO0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pSOfEdae; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pSOfEdae" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 060F8C32781; Mon, 24 Jun 2024 09:19:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719220790; bh=LayJjNlHt7RdDKs2eSpJizuqfyzjoPSkSmmLznNH6CU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pSOfEdaeKFIRCtOcdsfBo0VpFuDm9gEnDpyYbJbvxYqEsZOshyZwigQbbgx7fkDyo R15v3iGvG2UY8qSObyAJFfabsuSv47Hc8VKPSVQlL9LAxuG0gQr5Gu15h09vmIEJqT ehbqkKCy3EluS20YRYIWsZTF+h59YrGBzR5pjPkd2YIdl/C2meL9fEW85CnB4EBTY1 jVLSCrgP1drLQKynDf+1UPZ4Ah/WAsEWbKcy6Jq0lXpn81py2ENpCgywt5zLglGTZY zrEr5Dw1CiQMAVbw8e+JsyUT36QxJF2NvppmGEbQj5INFACjDIzDh3cQqOBekt0ZBi gGNpyPEw+f6XA== Received: from mchehab by mail.kernel.org with local (Exim 4.97.1) (envelope-from ) id 1sLfrX-000000085bf-1gZ6; Mon, 24 Jun 2024 11:19:47 +0200 From: Mauro Carvalho Chehab To: Cc: Mauro Carvalho Chehab , "Borislav Petkov" , "James Morse" , "Jonathan Cameron" , "Shiju Jose" , "Tony Luck" , Ard Biesheuvel , linux-edac@vger.kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/4] efi/cper: Adjust infopfx size to accept an extra space Date: Mon, 24 Jun 2024 11:19:18 +0200 Message-ID: <665a5626bea1c13538fef09d2120343eeae04553.1719219886.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab Compiling with W=1 with werror enabled produces an error: drivers/firmware/efi/cper-arm.c: In function ‘cper_print_proc_arm’: drivers/firmware/efi/cper-arm.c:298:64: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] 298 | snprintf(infopfx, sizeof(infopfx), "%s ", newpfx); | ^ drivers/firmware/efi/cper-arm.c:298:25: note: ‘snprintf’ output between 2 and 65 bytes into a destination of size 64 298 | snprintf(infopfx, sizeof(infopfx), "%s ", newpfx); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ As the logic there adds an space at the end of infopx buffer. Add an extra space to avoid such warning. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron --- drivers/firmware/efi/cper-arm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/efi/cper-arm.c b/drivers/firmware/efi/cper-arm.c index fa9c1c3bf168..eb7ee6af55f2 100644 --- a/drivers/firmware/efi/cper-arm.c +++ b/drivers/firmware/efi/cper-arm.c @@ -240,7 +240,7 @@ void cper_print_proc_arm(const char *pfx, int i, len, max_ctx_type; struct cper_arm_err_info *err_info; struct cper_arm_ctx_info *ctx_info; - char newpfx[64], infopfx[64]; + char newpfx[64], infopfx[ARRAY_SIZE(newpfx) + 1]; printk("%sMIDR: 0x%016llx\n", pfx, proc->midr); From patchwork Mon Jun 24 09:19:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 807088 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AC9412FF8C; Mon, 24 Jun 2024 09:19:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719220790; cv=none; b=kRJ4qnp4/4FOzYfMu1ufGjbpMIHJuNODkKwpoTXttPKkes4J4TnR1PfacDEiE9gcJEp5HTGzAKxHrLjd8PDAtkffcD3RocgyW4pdVQvTxyIwu4B8b4lYdFgoN5YQhx5+8HMiSOgnKO9YUHWCUSapGuH29ln90H+CmnK+FPxLn3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719220790; c=relaxed/simple; bh=MiJu506E02sUqMejKu5a4CpTEW7a3bv6SgfhjAqtNZM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pnS/Xj03BY+9+n3wFp2MGxfpWdNnqBSzFz/hUEj1FqMjRTZbU7inGD5fQZ2EipGCxFJ7Q43bKhJN8IN0fwuHeY0FLCGqVUeAP6fLYFMdP24XTEeKWwVcwpVtVi2UWQVs8jvaN/MrmAYNVp9b5M979nLZKXe+Y8TsTwu/geqpMFo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tGYP9MFX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tGYP9MFX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0936CC32782; Mon, 24 Jun 2024 09:19:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719220790; bh=MiJu506E02sUqMejKu5a4CpTEW7a3bv6SgfhjAqtNZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tGYP9MFXOpjlu+0DM1dR1AdDd1EIvzeJ4btWbao7hqc2LxltXn0sLcJYhNUEr6Mwq 548Ptdnx09TP1zDcwf8ot2vLOXmzc+XsfW87qDZJ9XyTfh2Y+CqgWAReyjT7jtnD+j HTUEwLg8PQKYOGXUyn3xcDmJc/VSJ4wxSuhjCf35pRr4TP/yGMaphDlcvhlV9FHxl6 Z7H+J5xaMFEcDtN9+hk+Z7TEU7KdBdGcIASdwOIoYX6vfg7D9s98IIYgDG0FmlX1WV EAdlaemWJCagRjpA3E0UTHCzHWTqWVuk2PozvT1zROqQHnZmdwdrQfKCgD+1NOvOzd CFz0N1MZ5YWUw== Received: from mchehab by mail.kernel.org with local (Exim 4.97.1) (envelope-from ) id 1sLfrX-000000085bi-1s15; Mon, 24 Jun 2024 11:19:47 +0200 From: Mauro Carvalho Chehab To: Cc: Mauro Carvalho Chehab , "Borislav Petkov" , "James Morse" , "Jonathan Cameron" , "Shiju Jose" , "Tony Luck" , Alison Schofield , Ard Biesheuvel , Dave Jiang , Ira Weiny , linux-edac@vger.kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 2/4] efi/cper: Add a new helper function to print bitmasks Date: Mon, 24 Jun 2024 11:19:19 +0200 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab Sometimes it is desired to produce a single log line for errors. Add a new helper function for such purpose. Signed-off-by: Mauro Carvalho Chehab --- drivers/firmware/efi/cper.c | 41 +++++++++++++++++++++++++++++++++++++ include/linux/cper.h | 2 ++ 2 files changed, 43 insertions(+) diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c index 7d2cdd9e2227..4cf56657afde 100644 --- a/drivers/firmware/efi/cper.c +++ b/drivers/firmware/efi/cper.c @@ -106,6 +106,47 @@ void cper_print_bits(const char *pfx, unsigned int bits, printk("%s\n", buf); } +/* + * cper_bits_to_str - return a string for set bits + * @buf: buffer to store the output string + * @buf_size: size of the output string buffer + * @bits: bit mask + * @strs: string array, indexed by bit position + * @strs_size: size of the string array: @strs + * @mask: a continuous bitmask used to detect the first valid bit of the + * bitmap. + * + * Add to @buf the bitmask in hexadecimal. Then, for each set bit in @bits + * mask, add the corresponding string describing the bit in @strs to @buf. + */ +char *cper_bits_to_str(char *buf, int buf_size, unsigned long bits, + const char * const strs[], unsigned int strs_size) +{ + int len = buf_size; + char *str = buf; + int i, size; + + for_each_set_bit(i, &bits, strs_size) { + if (!(bits & (1U << (i)))) + continue; + + if (*buf && len > 0) { + *str = '|'; + len--; + str++; + } + + size = strscpy(str, strs[i], len); + if (size < 0) + break; + + len -= size; + str += size; + } + return buf; +} +EXPORT_SYMBOL_GPL(cper_bits_to_str); + static const char * const proc_type_strs[] = { "IA32/X64", "IA64", diff --git a/include/linux/cper.h b/include/linux/cper.h index 265b0f8fc0b3..c2f14b916bfb 100644 --- a/include/linux/cper.h +++ b/include/linux/cper.h @@ -584,6 +584,8 @@ const char *cper_mem_err_type_str(unsigned int); const char *cper_mem_err_status_str(u64 status); void cper_print_bits(const char *prefix, unsigned int bits, const char * const strs[], unsigned int strs_size); +char *cper_bits_to_str(char *buf, int buf_size, unsigned long bits, + const char * const strs[], unsigned int strs_size); void cper_mem_err_pack(const struct cper_sec_mem_err *, struct cper_mem_err_compact *); const char *cper_mem_err_unpack(struct trace_seq *, From patchwork Mon Jun 24 09:19:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 807330 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F77F130A66; Mon, 24 Jun 2024 09:19:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719220790; cv=none; b=fG9qXT5RPI/oe24k9ysD0etj3DRclrRRIPhyXk5pP7uxcT0NOq2IEcLdubMa43NNt8t1Qfk+Lp7m+i1tScZL+5Pw2eBiBtJWmscc7kVNPFF3UK6bqHO4gZe7/RfyY4pBkaM4JQ4zLepK01lNdExobuOB7DgIdl0udrB29AdZCO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719220790; c=relaxed/simple; bh=BoVXMC3yh8YzrLfCFEPWdFRffhONX8GKgR3QpZgFYXQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bR1CrDNv1itTjTzqkTVnYnx/MmDTyP3aaUn613bCvXJgYFE5S3oFNg5Fn7Lmv/tZj+iDwVcaWf8ybiw8ePNfhD6gh/9hvOL/XxN4lSE3isKC52NcCvVfas/RuhW52Df+61yYLw6JWfQa9EopqRxokNSEat32jt5TRTyPBZIa0oQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=szwcnY/S; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="szwcnY/S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10310C4AF0B; Mon, 24 Jun 2024 09:19:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719220790; bh=BoVXMC3yh8YzrLfCFEPWdFRffhONX8GKgR3QpZgFYXQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=szwcnY/SdZuOH/Ll6AVMKeBWITTGhwZ4/ZRvGPaHCLXQwFHXEvMG7jaKhVgeAX92r /hgcdsTVB4BUpxFnbHPV5GctE0NBrTf4rSZybxjfgon+4UquT0uGsjHQ7VTH9qAA4c ntvUllTYTHHQw7f6DqjesyqNSApspSDP0ZsgtH6D4iZ1KbHSfFACgUkkQWFr56WMFp qgyCMgKSqavDXBWogc5Aw7fcuTLVgEIrTiW34bNPLPlMFGrhme9ANvyoINE9weJycx iNYiVJAi9mqSS2gYYcN2YjNtvO/kVjoIX5NCZDnbNz4mCuYrSAsTU2W8zEq58QFbnw bYqe14lzwHSxw== Received: from mchehab by mail.kernel.org with local (Exim 4.97.1) (envelope-from ) id 1sLfrX-000000085bn-24kM; Mon, 24 Jun 2024 11:19:47 +0200 From: Mauro Carvalho Chehab To: Cc: Mauro Carvalho Chehab , "Borislav Petkov" , "James Morse" , "Jonathan Cameron" , "Rafael J. Wysocki" , "Shiju Jose" , "Tony Luck" , Alison Schofield , Ard Biesheuvel , Dan Williams , Dave Jiang , Ira Weiny , Len Brown , Shuai Xue , linux-acpi@vger.kernel.org, linux-edac@vger.kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 3/4] efi/cper: align ARM CPER type with UEFI 2.9A/2.10 specs Date: Mon, 24 Jun 2024 11:19:20 +0200 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab Up to UEFI spec, the type byte of CPER struct for ARM processor was defined simply as: Type at byte offset 4: - Cache error - TLB Error - Bus Error - Micro-architectural Error All other values are reserved Yet, there was no information about how this would be encoded. Spec 2.9A errata corrected it by defining: - Bit 1 - Cache Error - Bit 2 - TLB Error - Bit 3 - Bus Error - Bit 4 - Micro-architectural Error All other values are reserved That actually aligns with the values already defined on older versions at N.2.4.1. Generic Processor Error Section. Spec 2.10 also preserve the same encoding as 2.9A Adjust CPER and GHES handling code for both generic and ARM processors to properly handle UEFI 2.9A and 2.10 encoding. Link: https://uefi.org/specs/UEFI/2.10/Apx_N_Common_Platform_Error_Record.html#arm-processor-error-information Signed-off-by: Mauro Carvalho Chehab --- drivers/acpi/apei/ghes.c | 15 ++++++---- drivers/firmware/efi/cper-arm.c | 50 ++++++++++++++++----------------- include/linux/cper.h | 10 +++---- 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 623cc0cb4a65..de79cc0a0f1d 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -533,6 +533,7 @@ static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata, { struct cper_sec_proc_arm *err = acpi_hest_get_payload(gdata); int flags = sync ? MF_ACTION_REQUIRED : 0; + char error_type[120]; bool queued = false; int sec_sev, i; char *p; @@ -546,9 +547,8 @@ static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata, p = (char *)(err + 1); for (i = 0; i < err->err_info_num; i++) { struct cper_arm_err_info *err_info = (struct cper_arm_err_info *)p; - bool is_cache = (err_info->type == CPER_ARM_CACHE_ERROR); + bool is_cache = err_info->type & CPER_ARM_CACHE_ERROR; bool has_pa = (err_info->validation_bits & CPER_ARM_INFO_VALID_PHYSICAL_ADDR); - const char *error_type = "unknown error"; /* * The field (err_info->error_info & BIT(26)) is fixed to set to @@ -562,12 +562,15 @@ static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata, continue; } - if (err_info->type < ARRAY_SIZE(cper_proc_error_type_strs)) - error_type = cper_proc_error_type_strs[err_info->type]; + cper_bits_to_str(error_type, sizeof(error_type), + FIELD_GET(CPER_ARM_ERR_TYPE_MASK, err_info->type), + cper_proc_error_type_strs, + ARRAY_SIZE(cper_proc_error_type_strs)); pr_warn_ratelimited(FW_WARN GHES_PFX - "Unhandled processor error type: %s\n", - error_type); + "Unhandled processor error type 0x%02x: %s%s\n", + err_info->type, error_type, + (err_info->type & ~CPER_ARM_ERR_TYPE_MASK) ? " with reserved bit(s)" : ""); p += err_info->length; } diff --git a/drivers/firmware/efi/cper-arm.c b/drivers/firmware/efi/cper-arm.c index eb7ee6af55f2..52d18490b59e 100644 --- a/drivers/firmware/efi/cper-arm.c +++ b/drivers/firmware/efi/cper-arm.c @@ -93,15 +93,11 @@ static void cper_print_arm_err_info(const char *pfx, u32 type, bool proc_context_corrupt, corrected, precise_pc, restartable_pc; bool time_out, access_mode; - /* If the type is unknown, bail. */ - if (type > CPER_ARM_MAX_TYPE) - return; - /* * Vendor type errors have error information values that are vendor * specific. */ - if (type == CPER_ARM_VENDOR_ERROR) + if (type & CPER_ARM_VENDOR_ERROR) return; if (error_info & CPER_ARM_ERR_VALID_TRANSACTION_TYPE) { @@ -116,43 +112,38 @@ static void cper_print_arm_err_info(const char *pfx, u32 type, if (error_info & CPER_ARM_ERR_VALID_OPERATION_TYPE) { op_type = ((error_info >> CPER_ARM_ERR_OPERATION_SHIFT) & CPER_ARM_ERR_OPERATION_MASK); - switch (type) { - case CPER_ARM_CACHE_ERROR: + if (type & CPER_ARM_CACHE_ERROR) { if (op_type < ARRAY_SIZE(arm_cache_err_op_strs)) { - printk("%soperation type: %s\n", pfx, + printk("%scache error, operation type: %s\n", pfx, arm_cache_err_op_strs[op_type]); } - break; - case CPER_ARM_TLB_ERROR: + } + if (type & CPER_ARM_TLB_ERROR) { if (op_type < ARRAY_SIZE(arm_tlb_err_op_strs)) { - printk("%soperation type: %s\n", pfx, + printk("%sTLB error, operation type: %s\n", pfx, arm_tlb_err_op_strs[op_type]); } - break; - case CPER_ARM_BUS_ERROR: + } + if (type & CPER_ARM_BUS_ERROR) { if (op_type < ARRAY_SIZE(arm_bus_err_op_strs)) { - printk("%soperation type: %s\n", pfx, + printk("%sbus error, operation type: %s\n", pfx, arm_bus_err_op_strs[op_type]); } - break; } } if (error_info & CPER_ARM_ERR_VALID_LEVEL) { level = ((error_info >> CPER_ARM_ERR_LEVEL_SHIFT) & CPER_ARM_ERR_LEVEL_MASK); - switch (type) { - case CPER_ARM_CACHE_ERROR: + if (type & CPER_ARM_CACHE_ERROR) printk("%scache level: %d\n", pfx, level); - break; - case CPER_ARM_TLB_ERROR: + + if (type & CPER_ARM_TLB_ERROR) printk("%sTLB level: %d\n", pfx, level); - break; - case CPER_ARM_BUS_ERROR: + + if (type & CPER_ARM_BUS_ERROR) printk("%saffinity level at which the bus error occurred: %d\n", pfx, level); - break; - } } if (error_info & CPER_ARM_ERR_VALID_PROC_CONTEXT_CORRUPT) { @@ -241,6 +232,7 @@ void cper_print_proc_arm(const char *pfx, struct cper_arm_err_info *err_info; struct cper_arm_ctx_info *ctx_info; char newpfx[64], infopfx[ARRAY_SIZE(newpfx) + 1]; + char error_type[120]; printk("%sMIDR: 0x%016llx\n", pfx, proc->midr); @@ -289,9 +281,15 @@ void cper_print_proc_arm(const char *pfx, newpfx); } - printk("%serror_type: %d, %s\n", newpfx, err_info->type, - err_info->type < ARRAY_SIZE(cper_proc_error_type_strs) ? - cper_proc_error_type_strs[err_info->type] : "unknown"); + cper_bits_to_str(error_type, sizeof(error_type), + FIELD_GET(CPER_ARM_ERR_TYPE_MASK, err_info->type), + cper_proc_error_type_strs, + ARRAY_SIZE(cper_proc_error_type_strs)); + + printk("%serror_type: 0x%02x: %s%s\n", newpfx, err_info->type, + error_type, + (err_info->type & ~CPER_ARM_ERR_TYPE_MASK) ? " with reserved bit(s)" : ""); + if (err_info->validation_bits & CPER_ARM_INFO_VALID_ERR_INFO) { printk("%serror_info: 0x%016llx\n", newpfx, err_info->error_info); diff --git a/include/linux/cper.h b/include/linux/cper.h index c2f14b916bfb..fc62a80575e8 100644 --- a/include/linux/cper.h +++ b/include/linux/cper.h @@ -293,11 +293,11 @@ enum { #define CPER_ARM_INFO_FLAGS_PROPAGATED BIT(2) #define CPER_ARM_INFO_FLAGS_OVERFLOW BIT(3) -#define CPER_ARM_CACHE_ERROR 0 -#define CPER_ARM_TLB_ERROR 1 -#define CPER_ARM_BUS_ERROR 2 -#define CPER_ARM_VENDOR_ERROR 3 -#define CPER_ARM_MAX_TYPE CPER_ARM_VENDOR_ERROR +#define CPER_ARM_ERR_TYPE_MASK GENMASK(4,1) +#define CPER_ARM_CACHE_ERROR BIT(1) +#define CPER_ARM_TLB_ERROR BIT(2) +#define CPER_ARM_BUS_ERROR BIT(3) +#define CPER_ARM_VENDOR_ERROR BIT(4) #define CPER_ARM_ERR_VALID_TRANSACTION_TYPE BIT(0) #define CPER_ARM_ERR_VALID_OPERATION_TYPE BIT(1) From patchwork Mon Jun 24 09:19:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 807331 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AC1C4962B; Mon, 24 Jun 2024 09:19:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719220790; cv=none; b=R2qPvwiTkBHgWWIUD/5h/lCLsayvfk3tNGbcDlj549inPGEs/TI9j6b/Jpz6Vlyaw58IUqqaay7h9c1iMvo0N8jipsXGWUTZmV29QyzXzLJlK8PFll1cCt9Ad/7E/eSwG89qmX3GkpZX8bdbR7ZN6frLJVv1xnaNOTvqWXk2H0Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719220790; c=relaxed/simple; bh=ueKAZu/ar61RH+7+SVha6r9QoHpXIuCXEquxTHmjDy8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cw4bR03qMI1GnjgBcbRcQpb1sc6t0/BiDgSzF3DUIjRcY0j1FUcBV4o0nROh1x1gLRV5dMWeXDcEvb2BSiPG21i7etd7cYLuIZK1ICewcq77zZYYB54HhDK91Z6w7ohrruU6xW5OkPfBrAC6GRKZ7MlTeAFPXkHL7MX+vZ6kdbQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DQl9hJ1f; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DQl9hJ1f" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B65FC4AF0A; Mon, 24 Jun 2024 09:19:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719220790; bh=ueKAZu/ar61RH+7+SVha6r9QoHpXIuCXEquxTHmjDy8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DQl9hJ1fKghiq9MwhsYzEd3OPju43qMtQZqFVba1+dc/YYg3vbhEJGQ0M2Vnc+RHS bSvzLEeiz6v3VQO970GB0JMALPfNe/5CBQn6rLji3tfKa7b7aCbP3kHP1glYN+nM+n c6si/OcXorTEL68dH4eK/czp2WUx0hF11HjLBkHdJzLf6FftFTPc35Ii+q57RtS6Jf 7cBsl3l33TIvowngFXwOUeUaBKpXMXs/qHE7W27n0FwcwJDAjbxkR9kda7LHWZo4C6 3KttKQqA7Xpfrq3WytiVd3ImILwnATwJk0SjEYlkyNHWzNN9xDfA2qgVvGNpqhVCK3 KAss1erx/qE6Q== Received: from mchehab by mail.kernel.org with local (Exim 4.97.1) (envelope-from ) id 1sLfrX-000000085br-2FWa; Mon, 24 Jun 2024 11:19:47 +0200 From: Mauro Carvalho Chehab To: Cc: Mauro Carvalho Chehab , "Borislav Petkov" , "James Morse" , "Jonathan Cameron" , "Shiju Jose" , "Tony Luck" , Ard Biesheuvel , Jonathan Corbet , linux-doc@vger.kernel.org, linux-edac@vger.kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 4/4] docs: efi: add CPER functions to driver-api Date: Mon, 24 Jun 2024 11:19:21 +0200 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab There are two kernel-doc like descriptions at cper, which is used by other parts of cper and on ghes driver. They both have kernel-doc like descriptions. Change the tags for them to be actual kernel-doc tags and add them to the driver-api documentaion at the UEFI section. Signed-off-by: Mauro Carvalho Chehab --- Documentation/driver-api/firmware/efi/index.rst | 11 ++++++++--- drivers/firmware/efi/cper.c | 10 ++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Documentation/driver-api/firmware/efi/index.rst b/Documentation/driver-api/firmware/efi/index.rst index 4fe8abba9fc6..5a6b6229592c 100644 --- a/Documentation/driver-api/firmware/efi/index.rst +++ b/Documentation/driver-api/firmware/efi/index.rst @@ -1,11 +1,16 @@ .. SPDX-License-Identifier: GPL-2.0 -============ -UEFI Support -============ +==================================================== +Unified Extensible Firmware Interface (UEFI) Support +==================================================== UEFI stub library functions =========================== .. kernel-doc:: drivers/firmware/efi/libstub/mem.c :internal: + +UEFI Common Platform Error Record (CPER) functions +================================================== + +.. kernel-doc:: drivers/firmware/efi/cper.c diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c index 4cf56657afde..c8a432c5cb5d 100644 --- a/drivers/firmware/efi/cper.c +++ b/drivers/firmware/efi/cper.c @@ -69,7 +69,7 @@ const char *cper_severity_str(unsigned int severity) } EXPORT_SYMBOL_GPL(cper_severity_str); -/* +/** * cper_print_bits - print strings for set bits * @pfx: prefix for each line, including log level and prefix string * @bits: bit mask @@ -106,18 +106,16 @@ void cper_print_bits(const char *pfx, unsigned int bits, printk("%s\n", buf); } -/* +/** * cper_bits_to_str - return a string for set bits * @buf: buffer to store the output string * @buf_size: size of the output string buffer * @bits: bit mask * @strs: string array, indexed by bit position * @strs_size: size of the string array: @strs - * @mask: a continuous bitmask used to detect the first valid bit of the - * bitmap. * - * Add to @buf the bitmask in hexadecimal. Then, for each set bit in @bits - * mask, add the corresponding string describing the bit in @strs to @buf. + * Add to @buf the bitmask in hexadecimal. Then, for each set bit in @bits, + * add the corresponding string describing the bit in @strs to @buf. */ char *cper_bits_to_str(char *buf, int buf_size, unsigned long bits, const char * const strs[], unsigned int strs_size)