From patchwork Sun Dec 8 12:23:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1205642 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W5MW6nLKz9sPK for ; Sun, 8 Dec 2019 23:33:11 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DERID4v+"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47W5MW4hnKzDqGY for ; Sun, 8 Dec 2019 23:33:11 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::442; helo=mail-pf1-x442.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DERID4v+"; dkim-atps=neutral Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47W59K6cWBzDqP1 for ; Sun, 8 Dec 2019 23:24:21 +1100 (AEDT) Received: by mail-pf1-x442.google.com with SMTP id x185so5752609pfc.5 for ; Sun, 08 Dec 2019 04:24:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KrbMQtDFnDlRvIopRyMEXvQlNmLsdFtST1djkIWUBcE=; b=DERID4v+qOA+76tUuRVljpKWWfejIAa/dp0KqEFKPXtC2j4vxq2w7Tt+/qHHtn9XVk 5xpaE1v9EyytkH8wwjEv7Fp8EDScUIcvW9VH3FAj4Z1IPX67t81uJukkMQxJ48RmSnJU 4XEu9LRJKVTD6gLYA2dvolqAUUOHAuEEr5saolYQP8BUZ70i6dOiEUVEvjoZNX+LQWdx k46h29KWtG8zjLjwK1rWt32XoQ/W4qnjB+4zihQN136H/7u5hQkXPH3+Cc7to2Gl1mGD Lvvi9FeSo7IUeK8SDnoiOiumsHhnt+MN2AwVHFulb7tExj1xHWJxZzc3URi16EuM71Z0 p/BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KrbMQtDFnDlRvIopRyMEXvQlNmLsdFtST1djkIWUBcE=; b=rvI5RiQ8hUaxsaa/HGu5D28u3WbvTFBLKysrpUSq+yDQTPa+UIIr98I3h4kJZ93gUd jrhicBERh1t4htU26RoMVLbBDo2P03awAG+ZawrfiytZ6B4KCxcozpHowOsqXtXJ6sVR 4u6q9wTFSWMAZzhd09gkTekQXuiSM8ZlaPQ9M7jFBK01Znw6OM8G6pP7IIqCPQ1nEYeS SDbXUeCV/L2TrZERJG2EefPvDzcvgf9RgcQTDdPl+S1BDXxsgO7STywqeupbOfQXQOdp K8/ii1TUAcFh6JWzbXHtoUZIuRo/okvgWkmR7aILLTtiRbXzHQ+NxwUYabn/5hVykQXk iTAg== X-Gm-Message-State: APjAAAXNXLOBe5DmYSEgFilRQKDkXV6i02S2WgJB6XpF71+ZM6TSRRIE ML+RRafGpoUDVD3sU//fbJz9/muI X-Google-Smtp-Source: APXvYqzMjPqXqWhwmEs7n/tUqsWiH9DYYaU0AQpOwqZDMIg2D2x5MHRwC8Qo7AgtrXTLwlogl2ekLA== X-Received: by 2002:a63:d802:: with SMTP id b2mr6131176pgh.414.1575807859970; Sun, 08 Dec 2019 04:24:19 -0800 (PST) Received: from bobo.local0.net ([202.21.15.182]) by smtp.gmail.com with ESMTPSA id i9sm23741866pfk.24.2019.12.08.04.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2019 04:24:19 -0800 (PST) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Sun, 8 Dec 2019 22:23:02 +1000 Message-Id: <20191208122312.12837-22-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191208122312.12837-1-npiggin@gmail.com> References: <20191208122312.12837-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH v10 21/31] errorlog: endian conversion X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Signed-off-by: Nicholas Piggin --- core/errorlog.c | 14 ++++++++------ core/pel.c | 15 ++++++++++----- include/errorlog.h | 12 ++++++------ 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/core/errorlog.c b/core/errorlog.c index 01e296999..fd316836f 100644 --- a/core/errorlog.c +++ b/core/errorlog.c @@ -93,10 +93,10 @@ void log_add_section(struct errorlog *buf, uint32_t tag) tmp = (struct elog_user_data_section *)(buf->user_data_dump + buf->user_section_size); /* Use DESC if no other tag provided */ - tmp->tag = tag ? tag : 0x44455343; - tmp->size = size; + tmp->tag = tag ? cpu_to_be32(tag) : cpu_to_be32(0x44455343); + tmp->size = cpu_to_be16(size); - buf->user_section_size += tmp->size; + buf->user_section_size += size; buf->user_section_count++; } @@ -133,6 +133,7 @@ void log_append_data(struct errorlog *buf, unsigned char *data, uint16_t size) struct elog_user_data_section *section; uint8_t n_sections; char *buffer; + uint16_t ssize; if (!buf) { prerror("ELOG: Cannot update user data. Buffer is invalid\n"); @@ -154,13 +155,14 @@ void log_append_data(struct errorlog *buf, unsigned char *data, uint16_t size) while (--n_sections) { section = (struct elog_user_data_section *)buffer; - buffer += section->size; + buffer += be16_to_cpu(section->size); } section = (struct elog_user_data_section *)buffer; - buffer += section->size; + ssize = be16_to_cpu(section->size); + buffer += ssize; memcpy(buffer, data, size); - section->size += size; + section->size = cpu_to_be16(ssize + size); buf->user_section_size += size; } diff --git a/core/pel.c b/core/pel.c index b07ba0efc..7f9abb8f3 100644 --- a/core/pel.c +++ b/core/pel.c @@ -211,16 +211,19 @@ static void create_user_defined_section(struct errorlog *elog_data, opal_usr_data = (struct elog_user_data_section *)opal_buf; usrhdr->v6header.id = ELOG_SID_USER_DEFINED; + usrhdr->v6header.length = cpu_to_be16( + sizeof(struct opal_v6_header) + + be16_to_cpu(opal_usr_data->size)); usrhdr->v6header.version = OPAL_ELOG_VERSION; usrhdr->v6header.length = sizeof(struct opal_v6_header) + opal_usr_data->size; usrhdr->v6header.subtype = OPAL_ELOG_SST; usrhdr->v6header.component_id = elog_data->component_id; - memcpy(usrhdr->dump, opal_buf, opal_usr_data->size); + memcpy(usrhdr->dump, opal_buf, be16_to_cpu(opal_usr_data->size)); *pel_offset += usrhdr->v6header.length; dump += usrhdr->v6header.length; - opal_buf += opal_usr_data->size; + opal_buf += be16_to_cpu(opal_usr_data->size); privhdr->section_count++; } } @@ -233,10 +236,12 @@ static size_t pel_user_section_size(struct errorlog *elog_data) struct elog_user_data_section *opal_usr_data; for (i = 0; i < elog_data->user_section_count; i++) { + u16 s; + opal_usr_data = (struct elog_user_data_section *)opal_buf; - total += sizeof(struct opal_v6_header) + - opal_usr_data->size; - opal_buf += opal_usr_data->size; + s = be16_to_cpu(opal_usr_data->size); + total += sizeof(struct opal_v6_header) + s; + opal_buf += s; } return total; diff --git a/include/errorlog.h b/include/errorlog.h index 3fd475c07..a01ab97be 100644 --- a/include/errorlog.h +++ b/include/errorlog.h @@ -94,19 +94,19 @@ #define ORG_POWERNV 2 /* Multiple user data sections */ -struct __attribute__((__packed__))elog_user_data_section { - uint32_t tag; - uint16_t size; - uint16_t component_id; +struct elog_user_data_section { + __be32 tag; + __be16 size; + __be16 component_id; char data_dump[1]; -}; +} __packed; /* * All the information regarding an error/event to be reported * needs to populate this structure using pre-defined interfaces * only */ -struct __attribute__((__packed__)) __attribute__ ((aligned (8))) errorlog { +struct errorlog { uint16_t component_id; uint8_t error_event_type;