From patchwork Tue Oct 15 03:07:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1176750 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (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 46sgcw4TcHz9sPF for ; Tue, 15 Oct 2019 14:18:56 +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="s6EXC+on"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46sgcw2sWVzDqRZ for ; Tue, 15 Oct 2019 14:18:56 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.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="s6EXC+on"; dkim-atps=neutral Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (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 46sgTv1z59zDqR5 for ; Tue, 15 Oct 2019 14:12:51 +1100 (AEDT) Received: by mail-pf1-x444.google.com with SMTP id y72so11487790pfb.12 for ; Mon, 14 Oct 2019 20:12:51 -0700 (PDT) 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=mHy+oliLH18Dm3l3Nmhknw3vMHrgJQtghOWSg2ORkNo=; b=s6EXC+onkjA0LrqL60pPz204NpCcWnIocc3pbx+YG0HDEwTLp4fTfIW8aiy439BvNw WSs0YJmdX6MyP9MuQMIp/oL1DfSLaiHhh6+3bjcpb4N7bfqahqBuOW7tklTNUHTYrNgp XcDtTTevo7josGGokmJSIyDTvl8rE+mmYwqVn3/xq7b/O7RO5JJTf4ItG6Re+xaGb9VU 7+zAqLMhwHpykvpg7ItbykTzKf1aVDb7iTYuSL0txjFmfE5GzazLSi+/BA8bO8uxiXL6 O5RKFCd0ObjQ68wKgIgZR8flnv67YkeHMeXhWXCwUWVGvE50oLnR0fUTnPUvX2TZ4w/F v2AQ== 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=mHy+oliLH18Dm3l3Nmhknw3vMHrgJQtghOWSg2ORkNo=; b=t00b1zfKuhePPLFMu8R/GSE3Q560hsGjAnZRtfF+IPOSG/+tyEPdBE1uo6hD7sQUCi 7TI9bE5u/FxN1D3MXYl1S+j2V7XdjrxoLwSVAZ2F/g68cBOFtltg8itxQxjXKlzjlL1b JnNDXZQY7t5awwTzN7ryo1DZMWXXtDtQwfBUifgf1PZ1TpOBYiI46F4VD9ORCGod0pVV ndVYGY8PRQFzikeEKYeCDtsubRtXjwDlLl7OOLl5Qv9BjXk/GmHB0CU2nls/VblPZt/o BWQON2jLrJf4665vQv2hEqMPRQHFNMRuTw1ZAnn4uaGrLEsisrpRykQOX9SdEi36SKM0 jzLQ== X-Gm-Message-State: APjAAAU1+Cnm/kn0ZK99TyQYRBMSc/dfbd8VvqPlVE9J7HBDywKD23Zy MaHFeyPQBvwaVAhoDlmaey+3fH/gcxk= X-Google-Smtp-Source: APXvYqzWvmbn5r+teYTp/b/5Vun+aFnBgDvpbpPW9arFihjD7Qetnf0veJiX2hGJWDCCw8MgDDAPbA== X-Received: by 2002:a17:90a:b304:: with SMTP id d4mr40542368pjr.27.1571109168703; Mon, 14 Oct 2019 20:12:48 -0700 (PDT) Received: from bobo.local0.net (60-240-111-58.tpgi.com.au. [60.240.111.58]) by smtp.gmail.com with ESMTPSA id w6sm23089828pfw.84.2019.10.14.20.12.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 20:12:48 -0700 (PDT) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Tue, 15 Oct 2019 13:07:09 +1000 Message-Id: <20191015030717.15637-20-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191015030717.15637-1-npiggin@gmail.com> References: <20191015030717.15637-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH v5 19/27] fsp: endian conversions 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 --- hw/fsp/fsp-codeupdate.c | 4 +- hw/fsp/fsp-codeupdate.h | 86 ++++++++++++++++++++--------------------- hw/fsp/fsp-sysdump.c | 2 +- hw/fsp/fsp-sysparam.c | 2 +- hw/fsp/fsp.c | 16 ++++---- 5 files changed, 55 insertions(+), 55 deletions(-) diff --git a/hw/fsp/fsp-codeupdate.c b/hw/fsp/fsp-codeupdate.c index 67732a739..7e58cebeb 100644 --- a/hw/fsp/fsp-codeupdate.c +++ b/hw/fsp/fsp-codeupdate.c @@ -783,7 +783,7 @@ static int validate_candidate_image(uint64_t buffer, memcpy(validate_buf, (void *)buffer, VALIDATE_BUF_SIZE); header = (struct update_image_header *)validate_buf; - if (validate_magic_num(be32_to_cpu(header->magic)) != 0) { + if (validate_magic_num(be16_to_cpu(header->magic)) != 0) { *result = VALIDATE_INVALID_IMG; rc = OPAL_SUCCESS; goto out; @@ -1125,7 +1125,7 @@ static int64_t validate_sglist(struct opal_sg_list *list) return OPAL_PARAMETER; /* All non-terminal entries size must be aligned */ - if (prev_entry && (prev_entry->length & 0xfff)) + if (prev_entry && (be64_to_cpu(prev_entry->length) & 0xfff)) return OPAL_PARAMETER; prev_entry = entry; diff --git a/hw/fsp/fsp-codeupdate.h b/hw/fsp/fsp-codeupdate.h index 237043c8e..0262c69ce 100644 --- a/hw/fsp/fsp-codeupdate.h +++ b/hw/fsp/fsp-codeupdate.h @@ -76,17 +76,17 @@ struct fw_image_vpd { struct master_lid_header { char key[3]; /* "MLH" */ uint8_t version; /* 0x02 */ - uint16_t header_size; - uint16_t entry_size; + __be16 header_size; + __be16 entry_size; uint8_t reserved[56]; }; /* LID index entry */ struct lid_index_entry { - uint32_t id; - uint32_t size; - uint32_t offset; - uint32_t crc; + __be32 id; + __be32 size; + __be32 offset; + __be32 crc; }; /* SP flags */ @@ -99,7 +99,7 @@ struct lid_index_entry { * sp_flag addr = header->data + header->ext_fw_id_size */ struct update_image_ga_date { - uint32_t sp_flag; + __be32 sp_flag; char sp_ga_date[8]; /* YYYYMMDD */ }; @@ -108,39 +108,39 @@ struct update_image_ga_date { /* Image header structure */ struct update_image_header { - uint16_t magic; - uint16_t version; - uint32_t package_size; - uint32_t crc; - uint16_t lid_index_offset; - uint16_t number_lids; - uint16_t package_flags; - uint16_t mi_keyword_size; + __be16 magic; + __be16 version; + __be32 package_size; + __be32 crc; + __be16 lid_index_offset; + __be16 number_lids; + __be16 package_flags; + __be16 mi_keyword_size; char mi_keyword_data[40]; - uint16_t ext_fw_id_size; + __be16 ext_fw_id_size; /* Rest of the image data including ext fw id, sp flags */ char data[]; }; /* FipS header */ struct fips_header { - uint16_t magic; - uint16_t version; - uint32_t lid_id; - uint32_t lid_date; /* YYYYMMDD */ - uint16_t lid_time; /* HHMM */ - uint16_t lid_class; - uint32_t crc; - uint32_t lid_size; /* Number of bytes below header */ - uint32_t header_size; + __be16 magic; + __be16 version; + __be32 lid_id; + __be32 lid_date; /* YYYYMMDD */ + __be16 lid_time; /* HHMM */ + __be16 lid_class; + __be32 crc; + __be32 lid_size; /* Number of bytes below header */ + __be32 header_size; uint8_t mtd_number; uint8_t valid; /* 1 = valid, 0 = invalid */ uint8_t reserved; uint8_t lid_info_size; char lid_info[64]; /* code level */ - uint32_t update_date; /* YYYYMMDD */ - uint16_t update_time; /* HHMM */ - uint16_t phylum_len; + __be32 update_date; /* YYYYMMDD */ + __be16 update_time; /* HHMM */ + __be16 phylum_len; uint8_t lid_phylum[]; }; @@ -165,30 +165,30 @@ struct fips_header { * not all ADF sections in common marker LID. */ struct com_marker_header { - uint32_t version; - uint32_t MI_offset; /* Offset to MI section */ - uint32_t iseries_offset; + __be32 version; + __be32 MI_offset; /* Offset to MI section */ + __be32 iseries_offset; }; /* MI Keyword section */ struct com_marker_mi_section { - uint32_t MI_size; + __be32 MI_size; char mi_keyword[40]; /* MI Keyword */ char lst_disrupt_fix_lvl[3]; char skip[21]; /* Skip not interested fields */ - uint32_t adf_offset; /* Offset to ADF section */ + __be32 adf_offset; /* Offset to ADF section */ }; /* Additional Data Fields */ struct com_marker_adf_sec { - uint32_t adf_cnt; /* ADF count */ + __be32 adf_cnt; /* ADF count */ char adf_data[]; /* ADF data */ }; /* ADF common header */ struct com_marker_adf_header { - uint32_t size; /* Section size */ - uint32_t name; /* Section name */ + __be32 size; /* Section size */ + __be32 name; /* Section name */ }; /* @@ -200,9 +200,9 @@ struct com_marker_adf_header { struct com_marker_adf_sp { struct com_marker_adf_header header; - uint32_t sp_name_offset; /* Offset from start of ADF */ - uint32_t sp_name_size; - uint32_t skip[4]; /* Skip rest of fields */ + __be32 sp_name_offset; /* Offset from start of ADF */ + __be32 sp_name_size; + __be32 skip[4]; /* Skip rest of fields */ }; /* @@ -213,10 +213,10 @@ struct com_marker_adf_sp #define ADF_NAME_FW_IP 0x46495050 /* FIPP */ struct com_marker_fw_ip { struct com_marker_adf_header header; - uint32_t sp_flag_offset; /* Offset from start of ADF */ - uint32_t sp_flag_size; - uint32_t sp_ga_offset; /* Offset from start of ADF*/ - uint32_t sp_ga_size; + __be32 sp_flag_offset; /* Offset from start of ADF */ + __be32 sp_flag_size; + __be32 sp_ga_offset; /* Offset from start of ADF*/ + __be32 sp_ga_size; }; #endif /* __CODEUPDATE_H */ diff --git a/hw/fsp/fsp-sysdump.c b/hw/fsp/fsp-sysdump.c index cf4af34d1..1a9b46653 100644 --- a/hw/fsp/fsp-sysdump.c +++ b/hw/fsp/fsp-sysdump.c @@ -237,7 +237,7 @@ static int __dump_region_add_entry(uint32_t id, uint64_t addr, uint32_t size) } /* Add entry to dump memory region table */ - dump_mem_region[cur_mdst_entry].data_region = (u8)cpu_to_be32(id); + dump_mem_region[cur_mdst_entry].data_region = (u8)id; dump_mem_region[cur_mdst_entry].addr = cpu_to_be64(addr); dump_mem_region[cur_mdst_entry].size = cpu_to_be32(size); diff --git a/hw/fsp/fsp-sysparam.c b/hw/fsp/fsp-sysparam.c index 0e1e8181f..e30a686d4 100644 --- a/hw/fsp/fsp-sysparam.c +++ b/hw/fsp/fsp-sysparam.c @@ -422,7 +422,7 @@ static void add_opal_sysparam_node(void) { struct dt_node *sysparams; char *names, *s; - uint32_t *ids, *lens; + __be32 *ids, *lens; uint8_t *perms; unsigned int i, count, size = 0; diff --git a/hw/fsp/fsp.c b/hw/fsp/fsp.c index 7193c6f4c..c11beb00e 100644 --- a/hw/fsp/fsp.c +++ b/hw/fsp/fsp.c @@ -181,8 +181,8 @@ static void fsp_trace_msg(struct fsp_msg *msg, u8 dir __unused) size_t len = offsetof(struct trace_fsp_msg, data[msg->dlen]); fsp.fsp_msg.dlen = msg->dlen; - fsp.fsp_msg.word0 = msg->word0; - fsp.fsp_msg.word1 = msg->word1; + fsp.fsp_msg.word0 = cpu_to_be32(msg->word0); + fsp.fsp_msg.word1 = cpu_to_be32(msg->word1); fsp.fsp_msg.dir = dir; memcpy(fsp.fsp_msg.data, msg->data.bytes, msg->dlen); trace_add(&fsp, TRACE_FSP_MSG, len); @@ -634,12 +634,12 @@ static void fsp_trace_event(struct fsp *fsp, u32 evt, #ifdef FSP_TRACE_EVENT size_t len = sizeof(struct trace_fsp_event); - tfsp.fsp_evt.event = evt; - tfsp.fsp_evt.fsp_state = fsp->state; - tfsp.fsp_evt.data[0] = data0; - tfsp.fsp_evt.data[1] = data1; - tfsp.fsp_evt.data[2] = data2; - tfsp.fsp_evt.data[3] = data3; + tfsp.fsp_evt.event = cpu_to_be16(evt); + tfsp.fsp_evt.fsp_state = cpu_to_be16(fsp->state); + tfsp.fsp_evt.data[0] = cpu_to_be32(data0); + tfsp.fsp_evt.data[1] = cpu_to_be32(data1); + tfsp.fsp_evt.data[2] = cpu_to_be32(data2); + tfsp.fsp_evt.data[3] = cpu_to_be32(data3); trace_add(&tfsp, TRACE_FSP_EVENT, len); #endif /* FSP_TRACE_EVENT */ }