From patchwork Fri Apr 8 15:31:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1614962 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=nf0Tzbn3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4KZj0g0YGtz9sFq for ; Sat, 9 Apr 2022 01:32:03 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KZj0f6HRnz3bbG for ; Sat, 9 Apr 2022 01:32:02 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=nf0Tzbn3; dkim-atps=neutral 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::42c; helo=mail-pf1-x42c.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=nf0Tzbn3; dkim-atps=neutral Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) (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 4KZj0S0NhYz2yJ9 for ; Sat, 9 Apr 2022 01:31:51 +1000 (AEST) Received: by mail-pf1-x42c.google.com with SMTP id p25so1933626pfn.13 for ; Fri, 08 Apr 2022 08:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nI6M+GMjp0jTq9/yCRhfcYqeLcfwqd0q3ZYVq6Jmfjg=; b=nf0Tzbn3ZjhwQruuklyjOVv1j/2j8yhmLP1DKlEUhnEGJ58HeT7LzWtRO9qIoRQIj7 YOSQEtlEHtv0QuyQZqR0o8ILBCteF6MZ90WX3idb+aVpPsBldcQbwSm2EosP7KBmYQ1k wLlaUfmjOf0jzsKyJAFamWVSS6dW+9pbqqfn/wLTl8eaYQ2MhKmZUV4uZDFOLkmX2NBE Fwfp8lSls/zDPUO8ItqmiIuidJ+n2EZ7mcgXoa/xjLj+jQwGiuSZ9mTf4ghqdNJ6ODFw gPZFqKq0W0etzXjeOIWmKOk2QmeGqnrlG/PljjU167IKHFW9wn/sc4Osy/DviPPGPLb4 Eryw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nI6M+GMjp0jTq9/yCRhfcYqeLcfwqd0q3ZYVq6Jmfjg=; b=RLyOdAFcBTALfDtIMB4y0dLlPJIpt/zgyFp7P+hxdysF6gRLMy87M631lC14kRmYNl 2r4JzfrVUTRJ1artbmG/LPXJX4V9eSsO/cYtPCMCEI7f1TgvCKutYHSXaZ/9IBm1tRuU zwViNq6MCduOGujDJr5HfdehBWyOapY3lOfyTNVqcLr14rvg1x4kIjLq8x3vb5Kp7bXH Oa71bFRN+Vqqf7Ed6sBNL4cRrEF4FtPXLgK4Vhy0MWNhKMoIpmnLrNjUioZDIsJwPbvw D4TByrm6eJ8DLWMVrbhCtMOW9AZoObIipnHj92V67qg061yN/ZrAwp90mUpoS4RGsQbs hpOA== X-Gm-Message-State: AOAM530ouzvEi1Y4Na5S56UpEDe7/Y+Ef0Bb3fAV2M1L8rfXx1duWUd8 TgMmdiKbTrNe7i8LDSrTATP9j8Kjn6M= X-Google-Smtp-Source: ABdhPJxhheG38X4CHm4uS02JxadAuJ1OxTwpNZBubfNqDJ2zz10Qdquqen3vgA56vyRiPzyr5oRZqQ== X-Received: by 2002:a63:3e4e:0:b0:398:997f:a442 with SMTP id l75-20020a633e4e000000b00398997fa442mr15767702pga.421.1649431909392; Fri, 08 Apr 2022 08:31:49 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (220-235-208-104.tpgi.com.au. [220.235.208.104]) by smtp.gmail.com with ESMTPSA id y26-20020a056a00181a00b004fe3a6f02cesm14175172pfa.85.2022.04.08.08.31.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 08:31:49 -0700 (PDT) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Sat, 9 Apr 2022 01:31:34 +1000 Message-Id: <20220408153137.996621-2-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220408153137.996621-1-npiggin@gmail.com> References: <20220408153137.996621-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH 1/4] core/hmi: fix endian conversion bug 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" Fix an endian conversion bug in HMI checkstop reporting. Noticed by sparse. Signed-off-by: Nicholas Piggin Acked-by: Mahesh Salgaonkar --- core/hmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/hmi.c b/core/hmi.c index ce5abd7d6..46dc20dbb 100644 --- a/core/hmi.c +++ b/core/hmi.c @@ -915,7 +915,7 @@ static void find_npu_checkstop_reason(int flat_chip_id, hmi_evt->severity = OpalHMI_SEV_WARNING; hmi_evt->type = OpalHMI_ERROR_MALFUNC_ALERT; hmi_evt->u.xstop_error.xstop_type = CHECKSTOP_TYPE_NPU; - hmi_evt->u.xstop_error.xstop_reason = xstop_reason; + hmi_evt->u.xstop_error.xstop_reason = cpu_to_be32(xstop_reason); hmi_evt->u.xstop_error.u.chip_id = cpu_to_be32(flat_chip_id); /* Marking the event as recoverable so that we don't crash */ From patchwork Fri Apr 8 15:31:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1614963 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=MaJL7kDW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KZj0p2hpPz9sFq for ; Sat, 9 Apr 2022 01:32:10 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KZj0m42p6z3bcr for ; Sat, 9 Apr 2022 01:32:08 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=MaJL7kDW; dkim-atps=neutral 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::529; helo=mail-pg1-x529.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=MaJL7kDW; dkim-atps=neutral Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) (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 4KZj0V0XNBz2yJ9 for ; Sat, 9 Apr 2022 01:31:53 +1000 (AEST) Received: by mail-pg1-x529.google.com with SMTP id s137so5347405pgs.5 for ; Fri, 08 Apr 2022 08:31:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nUzCKJIxI0XSs7iak7hfBgSuMSnNThhMgJR9Yed1m0M=; b=MaJL7kDWAbZEKwB5UlcIyoiP0D7pldg1IAMINDkZzYIqzmHboviOooWgg+Rbn63Hyj 6vc0SZiGdyyQCsL19qj8iylfbT/nvuKd8zcghwxijx8PRQwIiZ0mBi2L8W6IDoyro6Ta hyGfl+gZ5OLCkwc3YoMO/QUGBpGTCluXMQ4xgJRKe3ufbHpIg01M6rJJsVckXsjZNZ2P V/yxM7RY8zEe8Wc3OBusOO7fONMOwCzDc095pZhu6LVxyyNJy2cUgBHNLWmBVxFgnLSM VSEAozUNzsDLeg7wKI0RGVHYFpmu5sQa9bruxq1j8YebKuZ2eRuibKqUvAbzSba48c9V tIeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nUzCKJIxI0XSs7iak7hfBgSuMSnNThhMgJR9Yed1m0M=; b=vVKJx43g++uoe+dHnOHHF+eLVTIFruPICWopMv2C6BVqqjwPsB77hhZwJ4vl5FcBE2 Sfg3ELi3Au0bWUx0KMchWDFBxhZ6TjRQYzm5ySCLyb6UxK8fcU4KbL+lYD755gbBD7D2 /zKnh+oiZ39SGB+O9thYfEB1NUT9678n9AAhYfw+F1QkCDzxjWYrZcumAsL2TqsfRvwt ugEfPmQkSH53F3xGAKPgLTvySGEAAIOXmMv1XGJRgIkcDGqFxzmXUsiwaUg7eGgeJll8 zCdRIWdS82xrWVbqFMb5FOKW/kIzClzQJoK4/VoyQJTTGgnB4N5200g2dFFF/ATT9qEd lVkQ== X-Gm-Message-State: AOAM533nWyt++B/vGNdCOPmkoutr0VhO3Ejzx78IJktTYrYVMWdVhMhH oyA9Np5dxj9YZQJ2ke8tr7LmRXV5u+U= X-Google-Smtp-Source: ABdhPJy+5F5UMXXuPGmOeqU7wRvCaKlbmqzPeDsGU338TBYVvcWoY0Afg1rs9ItXuLSBPEvQld5gkA== X-Received: by 2002:a63:6c8a:0:b0:398:5208:220a with SMTP id h132-20020a636c8a000000b003985208220amr16041848pgc.176.1649431911424; Fri, 08 Apr 2022 08:31:51 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (220-235-208-104.tpgi.com.au. [220.235.208.104]) by smtp.gmail.com with ESMTPSA id y26-20020a056a00181a00b004fe3a6f02cesm14175172pfa.85.2022.04.08.08.31.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 08:31:51 -0700 (PDT) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Sat, 9 Apr 2022 01:31:35 +1000 Message-Id: <20220408153137.996621-3-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220408153137.996621-1-npiggin@gmail.com> References: <20220408153137.996621-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH 2/4] npu/pau: endian fixes 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" Add endian annotations to NPU OPAL APIs, and fix warnings and bugs reported by sparse. Signed-off-by: Nicholas Piggin Reviewed-by: Frederic Barrat --- hw/npu-opal.c | 4 ++-- hw/npu2-opencapi.c | 2 +- hw/pau.c | 19 ++++++++++--------- include/npu2.h | 2 +- include/pau.h | 2 +- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/hw/npu-opal.c b/hw/npu-opal.c index 1b66857f4..943ac608c 100644 --- a/hw/npu-opal.c +++ b/hw/npu-opal.c @@ -241,7 +241,7 @@ static int64_t opal_npu_tl_set(uint64_t phb_id, uint32_t bdfn, opal_call(OPAL_NPU_TL_SET, opal_npu_tl_set, 5); static int64_t opal_npu_mem_alloc(uint64_t phb_id, uint32_t bdfn, - uint64_t size, uint64_t *bar) + uint64_t size, __be64 *bar) { struct phb *phb = pci_get_phb(phb_id); @@ -260,7 +260,7 @@ opal_call(OPAL_NPU_MEM_ALLOC, opal_npu_mem_alloc, 4); static int64_t opal_npu_mem_release(uint64_t phb_id, uint32_t bdfn) { - struct phb *phb = pci_get_phb(phb_id);; + struct phb *phb = pci_get_phb(phb_id); if (!phb) return OPAL_PARAMETER; diff --git a/hw/npu2-opencapi.c b/hw/npu2-opencapi.c index 8e7bcca93..8004d85b9 100644 --- a/hw/npu2-opencapi.c +++ b/hw/npu2-opencapi.c @@ -2296,7 +2296,7 @@ out: } int64_t npu2_opencapi_mem_alloc(struct phb *phb, uint32_t __unused bdfn, - uint64_t size, uint64_t *__bar) + uint64_t size, __be64 *__bar) { struct npu2_dev *dev; uint64_t bar; diff --git a/hw/pau.c b/hw/pau.c index 1a3fbfaf7..144e58456 100644 --- a/hw/pau.c +++ b/hw/pau.c @@ -444,7 +444,7 @@ int64_t pau_opencapi_tl_set(struct phb *phb, uint32_t __unused bdfn, static int64_t pau_opencapi_afu_memory_bars(struct pau_dev *dev, uint64_t size, - uint64_t *bar) + __be64 *bar) { struct pau *pau = dev->pau; uint64_t addr, psize; @@ -492,12 +492,13 @@ static int64_t pau_opencapi_afu_memory_bars(struct pau_dev *dev, reg = PAU_XSL_GPU_MEM_BAR(dev->index); pau_write(pau, reg, val); - *bar = addr; + *bar = cpu_to_be64(addr); + return OPAL_SUCCESS; } int64_t pau_opencapi_mem_alloc(struct phb *phb, uint32_t __unused bdfn, - uint64_t size, uint64_t *bar) + uint64_t size, __be64 *bar) { struct pau_dev *dev = pau_phb_to_opencapi_dev(phb); int64_t rc; @@ -1302,7 +1303,7 @@ static int64_t pau_opencapi_pcicfg_read(struct phb *phb, uint32_t bdfn, cfg_addr = SETFIELD(PAU_CTL_MISC_CFG_ADDR_REGISTER_NBR, cfg_addr, offset & ~3u); - out_be64((uint64_t *)genid_base, cfg_addr); + out_be64((__be64 *)genid_base, cfg_addr); sync(); switch (size) { @@ -1312,10 +1313,10 @@ static int64_t pau_opencapi_pcicfg_read(struct phb *phb, uint32_t bdfn, break; case 2: *((uint16_t *)data) = - in_le16((uint16_t *)(genid_base + 128 + (offset & 2))); + in_le16((__le16 *)(genid_base + 128 + (offset & 2))); break; case 4: - *((uint32_t *)data) = in_le32((uint32_t *)(genid_base + 128)); + *((uint32_t *)data) = in_le32((__le32 *)(genid_base + 128)); break; default: return OPAL_PARAMETER; @@ -1358,7 +1359,7 @@ static int64_t pau_opencapi_pcicfg_write(struct phb *phb, uint32_t bdfn, cfg_addr = SETFIELD(PAU_CTL_MISC_CFG_ADDR_REGISTER_NBR, cfg_addr, offset & ~3u); - out_be64((uint64_t *)genid_base, cfg_addr); + out_be64((__be64 *)genid_base, cfg_addr); sync(); switch (size) { @@ -1366,10 +1367,10 @@ static int64_t pau_opencapi_pcicfg_write(struct phb *phb, uint32_t bdfn, out_8((uint8_t *)(genid_base + 128 + (offset & 3)), data); break; case 2: - out_le16((uint16_t *)(genid_base + 128 + (offset & 2)), data); + out_le16((__le16 *)(genid_base + 128 + (offset & 2)), data); break; case 4: - out_le32((uint32_t *)(genid_base + 128), data); + out_le32((__le32 *)(genid_base + 128), data); break; default: return OPAL_PARAMETER; diff --git a/include/npu2.h b/include/npu2.h index b302108b9..bc1a74ea1 100644 --- a/include/npu2.h +++ b/include/npu2.h @@ -278,7 +278,7 @@ int64_t npu2_opencapi_spa_clear_cache(struct phb *phb, uint32_t __unused bdfn, int64_t npu2_opencapi_tl_set(struct phb *phb, uint32_t __unused bdfn, long capabilities, char *rate); int64_t npu2_opencapi_mem_alloc(struct phb *phb, uint32_t __unused bdfn, - uint64_t size, uint64_t *bar); + uint64_t size, __be64 *bar); int64_t npu2_opencapi_mem_release(struct phb *phb, uint32_t __unused bdfn); #endif /* __NPU2_H */ diff --git a/include/pau.h b/include/pau.h index 4a6087cbf..8d5e32071 100644 --- a/include/pau.h +++ b/include/pau.h @@ -211,7 +211,7 @@ int64_t pau_opencapi_spa_clear_cache(struct phb *phb, int64_t pau_opencapi_tl_set(struct phb *phb, uint32_t __unused bdfn, long capabilities, char *rate_buf); int64_t pau_opencapi_mem_alloc(struct phb *phb, uint32_t __unused bdfn, - uint64_t size, uint64_t *bar); + uint64_t size, __be64 *bar); int64_t pau_opencapi_mem_release(struct phb *phb, uint32_t __unused bdfn); /* PHY */ From patchwork Fri Apr 8 15:31:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1614964 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=oC6w4QqV; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4KZj0v0lnHz9sFq for ; Sat, 9 Apr 2022 01:32:15 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KZj0t6WFZz3bfr for ; Sat, 9 Apr 2022 01:32:14 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=oC6w4QqV; dkim-atps=neutral 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::1030; helo=mail-pj1-x1030.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=oC6w4QqV; dkim-atps=neutral Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) (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 4KZj0W5Nczz2xrS for ; Sat, 9 Apr 2022 01:31:55 +1000 (AEST) Received: by mail-pj1-x1030.google.com with SMTP id e8-20020a17090a118800b001cb13402ea2so5534936pja.0 for ; Fri, 08 Apr 2022 08:31:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1lVgq1twGRW6JsLrjcaaximQ7HJkdTq1Aq524j6KbsA=; b=oC6w4QqVEhnDK0HZnoxnSrYAZRv/ovi0SJ3Yxq6xzb2+5S6nL/w0OTveQrEZ44Y/S/ 5XznfO2UpsJJi8WSkkA0EZEqP1rW5yqkdPobua56sy1I1S/ka5kMvVjGADZy6hLrSkdP Jt9Rxxbb13U9sNu7AA6RHpTmZ/u+wI9UMwTrA99mDvRXOT+7bxk6BMmQAxPtk06RKq6c eOjEbMHxpC0pTYZzGNPpL3DK5gPMgIWxUDtjGBrXb+mkLkYDzjJB8onJ6SpucYPetqj3 it96Iw2yGron0UKvDxHkm9fWk8gvc/E/EFORmvTuJ2HTg946Vlhvxe4ImEPimie+IfP6 7KQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1lVgq1twGRW6JsLrjcaaximQ7HJkdTq1Aq524j6KbsA=; b=CAqLy+PPiYXHgeAjBqbDVbYdWUsXY0zg+dLaFKftQN4KNqB0FxUQZq+kViql4EB/OA 74D5r2QlDrA2D4Sc4qbQGm9afnO4EShJ3aMj97yWSUcgjRFPIBBmu6tTJhe9vW5lD8lB avswETZj7G4gj6yAwjE00U87xUodHDmjJDJM+noe/JsJazd3vJ7hQURLJFAe4jYqPmpL jjLp0AgIpkI1MTvtC4UqbiR49RnE3H+CZj9L3BrCpOWChTBTf29SRZ7R8QuNEkid00xJ H7Gt/4ufjw5gjt5+LXYTWs0kk3Y3rLhIppaosEtEvBm0xybL/gfHMwkCRX/gwSXEAzl2 6keA== X-Gm-Message-State: AOAM530A9Wrdg/oHyNb67mM4/ujPP2itnAuPEikaT4FpZUvQk8r+amXz DU/C43hOE92Aix9I940+wLdvesv5MD0= X-Google-Smtp-Source: ABdhPJztABO7bhqSG1HQN8vnI5Q8HayNWN8LckCW6OwYLJRk48RzXpsS6TMOOPe9nV/kn9WLiSXooA== X-Received: by 2002:a17:90b:4f8d:b0:1c6:408b:6b0d with SMTP id qe13-20020a17090b4f8d00b001c6408b6b0dmr22113326pjb.90.1649431913529; Fri, 08 Apr 2022 08:31:53 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (220-235-208-104.tpgi.com.au. [220.235.208.104]) by smtp.gmail.com with ESMTPSA id y26-20020a056a00181a00b004fe3a6f02cesm14175172pfa.85.2022.04.08.08.31.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 08:31:53 -0700 (PDT) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Sat, 9 Apr 2022 01:31:36 +1000 Message-Id: <20220408153137.996621-4-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220408153137.996621-1-npiggin@gmail.com> References: <20220408153137.996621-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH 3/4] libstb: endian annotations 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" Add endian annotations to silence sparse endian warnings in libstb. Signed-off-by: Nicholas Piggin --- libstb/secvar/storage/secboot_tpm.c | 8 ++++---- libstb/tss2/ibmtpm20tss/utils/tssauth20.c | 4 ++-- libstb/tss2/ibmtpm20tss/utils/tssdevskiboot.c | 4 ++-- libstb/tss2/ibmtpm20tss/utils/tssutils.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libstb/secvar/storage/secboot_tpm.c b/libstb/secvar/storage/secboot_tpm.c index ff8ea9e0a..1dce0c711 100644 --- a/libstb/secvar/storage/secboot_tpm.c +++ b/libstb/secvar/storage/secboot_tpm.c @@ -160,9 +160,9 @@ static char *secboot_serialize_secvar(char *target, const struct secvar *var, co + var->key_len + var->data_size) > end) return NULL; - *((uint64_t*) target) = cpu_to_be64(var->key_len); + *((beint64_t*) target) = cpu_to_be64(var->key_len); target += sizeof(var->key_len); - *((uint64_t*) target) = cpu_to_be64(var->data_size); + *((beint64_t*) target) = cpu_to_be64(var->data_size); target += sizeof(var->data_size); memcpy(target, var->key, var->key_len); target += var->key_len; @@ -289,9 +289,9 @@ static int secboot_deserialize_secvar(struct secvar **var, char **src, const cha assert(var); /* Load in the two header values */ - key_len = be64_to_cpu(*((uint64_t *) *src)); + key_len = be64_to_cpu(*((beint64_t *) *src)); *src += sizeof(uint64_t); - data_size = be64_to_cpu(*((uint64_t *) *src)); + data_size = be64_to_cpu(*((beint64_t *) *src)); *src += sizeof(uint64_t); /* Check if we've reached the last var to deserialize */ diff --git a/libstb/tss2/ibmtpm20tss/utils/tssauth20.c b/libstb/tss2/ibmtpm20tss/utils/tssauth20.c index 8489e86d5..a3dafb9d4 100644 --- a/libstb/tss2/ibmtpm20tss/utils/tssauth20.c +++ b/libstb/tss2/ibmtpm20tss/utils/tssauth20.c @@ -1295,7 +1295,7 @@ TPM_RC TSS_GetCommandDecryptParam(TSS_AUTH_CONTEXT *tssAuthContext, } /* extract contents of the first TPM2B */ if (rc == 0) { - *decryptParamSize = ntohs(*(uint16_t *)cpBuffer); + *decryptParamSize = ntohs(*(beint16_t *)cpBuffer); *decryptParamBuffer = cpBuffer + sizeof(uint16_t); } /* sanity range check */ @@ -1491,7 +1491,7 @@ TPM_RC TSS_GetResponseEncryptParam(TSS_AUTH_CONTEXT *tssAuthContext, } /* extract contents of the first TPM2B */ if (rc == 0) { - *encryptParamSize = ntohs(*(uint16_t *)rpBuffer); + *encryptParamSize = ntohs(*(beint16_t *)rpBuffer); *encryptParamBuffer = rpBuffer + sizeof(uint16_t); } /* sanity range check */ diff --git a/libstb/tss2/ibmtpm20tss/utils/tssdevskiboot.c b/libstb/tss2/ibmtpm20tss/utils/tssdevskiboot.c index 24d437985..e4b1b1072 100644 --- a/libstb/tss2/ibmtpm20tss/utils/tssdevskiboot.c +++ b/libstb/tss2/ibmtpm20tss/utils/tssdevskiboot.c @@ -166,7 +166,7 @@ TPM_RC TSS_Dev_Transmit(TSS_CONTEXT *tssContext, * it here. */ if (rc == 0) { - responseSize = ntohl(*(uint32_t *)(responseBuffer + sizeof(TPM_ST))); + responseSize = ntohl(*(beint32_t *)(responseBuffer + sizeof(TPM_ST))); if (responseSize != *length) { if (tssVerbose) printf("TSS_Skiboot_Transmit: Bytes read (%u) and Buffer responseSize field (%lu) don't match\n", @@ -180,7 +180,7 @@ TPM_RC TSS_Dev_Transmit(TSS_CONTEXT *tssContext, * and deliver it to the upper layers */ if (rc == 0) - rc = ntohl(*(uint32_t *)(responseBuffer + sizeof(TPM_ST) + sizeof(uint32_t))); + rc = ntohl(*(beint32_t *)(responseBuffer + sizeof(TPM_ST) + sizeof(uint32_t))); if (tssVverbose) printf("TSS_Skiboot_Transmit: Response Code: %08x", rc); diff --git a/libstb/tss2/ibmtpm20tss/utils/tssutils.c b/libstb/tss2/ibmtpm20tss/utils/tssutils.c index 29124c36e..90c4f568d 100644 --- a/libstb/tss2/ibmtpm20tss/utils/tssutils.c +++ b/libstb/tss2/ibmtpm20tss/utils/tssutils.c @@ -253,7 +253,7 @@ TPM_RC TSS_TPM2B_CreateUint32(TPM2B *target, uint32_t source, uint16_t targetSiz } } if (rc == 0) { - uint32_t sourceNbo = htonl(source); + beint32_t sourceNbo = htonl(source); memmove(target->buffer, (uint8_t *)&sourceNbo, sizeof(uint32_t)); target->size = sizeof(uint32_t); } From patchwork Fri Apr 8 15:31:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1614965 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=cH70JHA3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4KZj115cdqz9sFq for ; Sat, 9 Apr 2022 01:32:21 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KZj114YJQz3bZy for ; Sat, 9 Apr 2022 01:32:21 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=cH70JHA3; dkim-atps=neutral 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::629; helo=mail-pl1-x629.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=cH70JHA3; dkim-atps=neutral Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) (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 4KZj0Z02Zhz3bXB for ; Sat, 9 Apr 2022 01:31:57 +1000 (AEST) Received: by mail-pl1-x629.google.com with SMTP id k13so2959611plk.12 for ; Fri, 08 Apr 2022 08:31:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t6G5bGZNhJdDyL3ruXSq19fhpXC62AYblyVsNJTfRbY=; b=cH70JHA3hm+R6q/iU5bIxO4ykLp8q3Tn0O94WF9NM7uozxqKVhJ1De3rk2PcvWIYi/ a+ml/C1IstLdhDWgyCuY0Q5z70KcGHuxwZE+nMSZHAbgXWILpAgepfU8Op2QBgv0FmPl gUkP7JlCx0YAtOzjd433C31N5MlQywFmxFqfr0cml6PEFm/pM1Yag19ga1EcA5GA/kpg VpkWT6yoGO9/HognD90uvy8HSC9KyuJCix3IeQh1982yVLWm45HezyCNziuVR/nXRTD2 8B3pLSmOK3c/Phnh6RIkvcaKlgTsqIlqgwb40JnJb2VrPCQuN8X7atkhdIv/7bH9Z69C krIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t6G5bGZNhJdDyL3ruXSq19fhpXC62AYblyVsNJTfRbY=; b=MKGKqkvR/jbCp+k3dmVHPJEFByvm6suR0YdNAIgCzVPFoZJUPiUt+Yasg4lC4jHmB2 3GCpAhOuh0E/uHcyumu4rXZ22WM0+Mh+jT6qIK2+9q2SDXuRVmMDeb0ovm3Bsk3Gn242 mGbYCP0mWbK35rML9jvoG2+u2wZqNVB3NIsCNrOeSdsJU8sfkEDNa/+z2X53XH4n6Cfp Hbwb/PFA/SOzRexO78fflTlJ4DAb7N7BRV6iwu9G5DWNxw+dHxQprHGAmcB69VM3HAax dQv8koUuVp1U9R7lR1nkDNxQozVkvBpuEtK8lEy0iVjedo5pHFnwCe4Omb+eX8B0G0Zi +d0g== X-Gm-Message-State: AOAM533T2xsln+gItVilyt4mjrpZq3MLqGKWMm8dmh31Sm4qqh5qTrN9 gqSTmSgUH4In4MrYix35XR+KIm1gSGc= X-Google-Smtp-Source: ABdhPJxXk2IHJFejIRJVp/PYlw6qpNvOWUDy0oIT5tdxCC3Xm7Kt+MwqNKGisGigfu/L4Yt227AxUg== X-Received: by 2002:a17:90b:1d84:b0:1c7:880b:9efc with SMTP id pf4-20020a17090b1d8400b001c7880b9efcmr22097292pjb.90.1649431915509; Fri, 08 Apr 2022 08:31:55 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (220-235-208-104.tpgi.com.au. [220.235.208.104]) by smtp.gmail.com with ESMTPSA id y26-20020a056a00181a00b004fe3a6f02cesm14175172pfa.85.2022.04.08.08.31.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 08:31:55 -0700 (PDT) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Sat, 9 Apr 2022 01:31:37 +1000 Message-Id: <20220408153137.996621-5-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220408153137.996621-1-npiggin@gmail.com> References: <20220408153137.996621-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH 4/4] Build skiboot little-endian by default when FSP=0 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" Little-endian has a simpler calling convention, it's smaller, uses less stack, and is faster. With a new OPAL ABI, it can avoid heavy-weight endian flips when called from an LE OS. FSP code (namely hservice runtime interface calls and host interface callbacks) does not work with LE or ELFv2, so check for conflicting options and abort the build. This reduces skiboot.lid.xz size by 10KiB. Signed-off-by: Nicholas Piggin --- Makefile | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index f3942c442..610f039f3 100644 --- a/Makefile +++ b/Makefile @@ -48,19 +48,35 @@ KERNEL ?= # STACK_CHECK ?= $(DEBUG) +# Try to build without FSP code +CONFIG_FSP?=1 +# Try to build without POWER8 support +CONFIG_P8?=1 + +# FSP (hservices) code does not work with LE at the moment. +BIG_ENDIAN ?= $(CONFIG_FSP) +ifeq ($(BIG_ENDIAN),1) +LITTLE_ENDIAN = 0 +else +LITTLE_ENDIAN ?= 1 +endif + # # Experimental (unsupported) build options # -# Little-endian does not yet build. Include it here to set ELF ABI. -LITTLE_ENDIAN ?= 0 -# ELF v2 ABI is more efficient and compact +# ELF v2 ABI is more efficient and compact. +# This can be set for big-endian builds. Clearing it for LE probably won't work. ELF_ABI_v2 ?= $(LITTLE_ENDIAN) + +# FSP does not work with LE or ELFv2 +ifeq ($(ELF_ABI_v2),1) +ifeq ($(CONFIG_FSP),1) +$(error FSP support is incompatible with little-endian and ELFv2 build options) +endif +endif + # Discard unreferenced code and data at link-time DEAD_CODE_ELIMINATION ?= 0 -# Try to build without FSP code -CONFIG_FSP?=1 -# Try to build without POWER8 support -CONFIG_P8?=1 # # Where is the source directory, must be a full path (no ~)