From patchwork Wed Jun 30 03:16:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 1498720 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=slof-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 ozlabs.org (Postfix) with ESMTPS id 4GF6Dh5d2lz9sVt for ; Wed, 30 Jun 2021 13:25:40 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GF6Dh2Mkjz2ykP for ; Wed, 30 Jun 2021 13:25:40 +1000 (AEST) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.ru (client-ip=107.174.27.60; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) X-Greylist: delayed 521 seconds by postgrey-1.36 at boromir; Wed, 30 Jun 2021 13:25:34 AEST Received: from ozlabs.ru (ozlabs.ru [107.174.27.60]) by lists.ozlabs.org (Postfix) with ESMTP id 4GF6DZ3hq1z2yMM for ; Wed, 30 Jun 2021 13:25:33 +1000 (AEST) Received: from fstn1-p1.ozlabs.ibm.com. (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 738A8AE80013; Tue, 29 Jun 2021 23:16:16 -0400 (EDT) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Wed, 30 Jun 2021 13:16:14 +1000 Message-Id: <20210630031614.2906767-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [SLOF] [PATCH slof] tcgbios: Fix warnings X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Berger Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" This fixes gcc warnings from -Waddress-of-packed-member and -Wzero-length-bounds. Signed-off-by: Alexey Kardashevskiy Reviewed-by: Thomas Huth Tested-by: Stefan Berger --- tpm_drivers.c: In function ‘spapr_send_crq_and_wait’: tpm_drivers.c:153:2: warning: converting a packed ‘struct crq’ pointer (alignment 1) to a ‘uint64_t’ {aka ‘long long unsigned int’} pointer alignment 8) may result in an unaligned pointer value [-Waddress-of-packed-member] 153 | rc = hv_send_crq(unit, (uint64_t *)crq); | ^~ tpm_drivers.c:34:8: note: defined here 34 | struct crq { | ^~~ tpm_drivers.c: In function ‘spapr_vtpm_senddata’: tpm_drivers.c:346:2: warning: converting a packed ‘struct crq’ pointer (alignment 1) to a ‘uint64_t’ {aka ‘long long unsigned int’} pointer (alignment 8) may result in an unaligned pointer value [-Waddress-of-packed-member] 346 | rc = hv_send_crq(spapr_vtpm.unit, (uint64_t *)&crq); | ^~ tpm_drivers.c:34:8: note: defined here 34 | struct crq { | ^~~ [CC] common-libs [CC] common-libs tcgbios.c: In function ‘tpm20_write_EfiSpecIdEventStruct’: tcgbios.c:708:24: warning: array subscript ‘numAlgs’ is outside the bounds of an interior zero-length array ‘struct TCG_EfiSpecIdEventAlgorithmSize[0]’ [-Wzero-length-bounds] 708 | event.hdr.digestSizes[numAlgs].algorithmId = | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~ In file included from tpm_drivers.h:20, from tcgbios.c:27: tcgbios_int.h:92:4: note: while referencing ‘digestSizes’ 92 | } digestSizes[0]; | ^~~~~~~~~~~ tcgbios.c:710:24: warning: array subscript ‘numAlgs’ is outside the bounds of an interior zero-length array ‘struct TCG_EfiSpecIdEventAlgorithmSize[0]’ [-Wzero-length-bounds] 710 | event.hdr.digestSizes[numAlgs].digestSize = cpu_to_log16(hsize); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~ In file included from tpm_drivers.h:20, from tcgbios.c:27: tcgbios_int.h:92:4: note: while referencing ‘digestSizes’ 92 | } digestSizes[0]; | ^~~~~~~~~~~ --- lib/libtpm/tcgbios_int.h | 2 +- lib/libtpm/tpm_drivers.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libtpm/tcgbios_int.h b/lib/libtpm/tcgbios_int.h index 22df31dd504f..cc38455850f2 100644 --- a/lib/libtpm/tcgbios_int.h +++ b/lib/libtpm/tcgbios_int.h @@ -89,7 +89,7 @@ struct TCG_EfiSpecIdEventStruct { struct TCG_EfiSpecIdEventAlgorithmSize { uint16_t algorithmId; uint16_t digestSize; - } digestSizes[0]; + } digestSizes[]; /* uint8_t vendorInfoSize; uint8_t vendorInfo[0]; diff --git a/lib/libtpm/tpm_drivers.c b/lib/libtpm/tpm_drivers.c index 85cb3098712d..4a4fde89ade8 100644 --- a/lib/libtpm/tpm_drivers.c +++ b/lib/libtpm/tpm_drivers.c @@ -150,7 +150,7 @@ static bool spapr_send_crq_and_wait(unsigned long unit, vtpm_drv_state_set(state1, VTPM_DRV_ERROR_NO_FAILURE); - rc = hv_send_crq(unit, (uint64_t *)crq); + rc = hv_send_crq(unit, (uint64_t *)&crq->valid); if (rc != H_SUCCESS) { vtpm_drv_state_set(VTPM_DRV_STATE_WAIT_INIT, VTPM_DRV_ERROR_TPM_CRQ_ERROR); @@ -343,7 +343,7 @@ static bool spapr_vtpm_senddata(const uint8_t *const data, uint32_t len) vtpm_drv_state_set(VTPM_DRV_STATE_SEND_TPM_CMD, VTPM_DRV_ERROR_NO_FAILURE); - rc = hv_send_crq(spapr_vtpm.unit, (uint64_t *)&crq); + rc = hv_send_crq(spapr_vtpm.unit, (uint64_t *)&crq.valid); if (rc == H_SUCCESS) vtpm_drv_state_set(VTPM_DRV_STATE_WAIT_TPM_RSP,