From patchwork Mon Sep 18 12:26:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 1836085 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=COwId9sB; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=COwId9sB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rq3vp2Cffz1ynX for ; Mon, 18 Sep 2023 22:27:18 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=COwId9sB; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=COwId9sB; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Rq3vm59V3z30Jy for ; Mon, 18 Sep 2023 22:27:16 +1000 (AEST) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=COwId9sB; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=COwId9sB; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=thuth@redhat.com; receiver=lists.ozlabs.org) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 4Rq3vZ5rrSz30NP for ; Mon, 18 Sep 2023 22:27:06 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695040023; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qeGsQa+50nR/Q5jevbX/DD3jYQ+WB7/UyM28+bBxzWo=; b=COwId9sBBGiSlR5UM0iArjvy36qQBhXmxuVOjsA3CvlkEho74iLCzOoMoskXwBtjzzbns2 LzFs+FiQI7iKB8qd5DY553/1I2xR50lMcYmaw55BzMFIyRl8Rz8Bj3dGJgJLppvwPL/weD GiU76J5Mxc5jpNdQkQgh3y4Pc/s01h0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695040023; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qeGsQa+50nR/Q5jevbX/DD3jYQ+WB7/UyM28+bBxzWo=; b=COwId9sBBGiSlR5UM0iArjvy36qQBhXmxuVOjsA3CvlkEho74iLCzOoMoskXwBtjzzbns2 LzFs+FiQI7iKB8qd5DY553/1I2xR50lMcYmaw55BzMFIyRl8Rz8Bj3dGJgJLppvwPL/weD GiU76J5Mxc5jpNdQkQgh3y4Pc/s01h0= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-660-gAGMOEwEP42jFqbV-VyabA-1; Mon, 18 Sep 2023 08:27:01 -0400 X-MC-Unique: gAGMOEwEP42jFqbV-VyabA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 73EBC29AA3BA for ; Mon, 18 Sep 2023 12:27:01 +0000 (UTC) Received: from thuth-p1g4.str.redhat.com (dhcp-192-205.str.redhat.com [10.33.192.205]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24130492C37 for ; Mon, 18 Sep 2023 12:27:01 +0000 (UTC) From: Thomas Huth To: slof@lists.ozlabs.org Date: Mon, 18 Sep 2023 14:26:58 +0200 Message-ID: <20230918122659.92014-2-thuth@redhat.com> In-Reply-To: <20230918122659.92014-1-thuth@redhat.com> References: <20230918122659.92014-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [SLOF] [PATCH 1/2] lib/libtpm: Silence compiler warnings about bad zero-length array access 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: , Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" GCC v13.2.1 complains: tcgbios.c: In function ‘tpm20_write_EfiSpecIdEventStruct’: tcgbios.c:708:38: 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 = | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~ Let's use the undefined array length declaration instead to make GCC here happy again. Signed-off-by: Thomas Huth --- lib/libtpm/tcgbios_int.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libtpm/tcgbios_int.h b/lib/libtpm/tcgbios_int.h index 22df31d..cc38455 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]; From patchwork Mon Sep 18 12:26:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 1836086 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=R/NAky8x; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=R/NAky8x; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rq3vq5Plbz1ynX for ; Mon, 18 Sep 2023 22:27:19 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=R/NAky8x; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=R/NAky8x; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Rq3vq4L1Bz30NP for ; Mon, 18 Sep 2023 22:27:19 +1000 (AEST) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=R/NAky8x; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=R/NAky8x; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=thuth@redhat.com; receiver=lists.ozlabs.org) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 4Rq3vb4YHWz30NP for ; Mon, 18 Sep 2023 22:27:07 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695040024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qiFU3BW4Bzn+rcehjGX1kpl8PRWnTj9hvKJwK7d1Kgw=; b=R/NAky8xriVPDmeKEAliUWkyeQBdr7kknSiszE+o3rT/eh1HM81kuvhTc1/DrOQ7BamMVX GX6xK8VOkYImus5RqMnW+oES94eYK8hemoqEUHpdl8csd+2BxviNENzquHh4rAXUHdUCUA AB1GgLRY8824krhorQjqz97vIw6k17g= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695040024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qiFU3BW4Bzn+rcehjGX1kpl8PRWnTj9hvKJwK7d1Kgw=; b=R/NAky8xriVPDmeKEAliUWkyeQBdr7kknSiszE+o3rT/eh1HM81kuvhTc1/DrOQ7BamMVX GX6xK8VOkYImus5RqMnW+oES94eYK8hemoqEUHpdl8csd+2BxviNENzquHh4rAXUHdUCUA AB1GgLRY8824krhorQjqz97vIw6k17g= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-505-aLWzGnimNHCrz1-fa6UTvQ-1; Mon, 18 Sep 2023 08:27:02 -0400 X-MC-Unique: aLWzGnimNHCrz1-fa6UTvQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F1F7429AA386 for ; Mon, 18 Sep 2023 12:27:01 +0000 (UTC) Received: from thuth-p1g4.str.redhat.com (dhcp-192-205.str.redhat.com [10.33.192.205]) by smtp.corp.redhat.com (Postfix) with ESMTP id A212D49BB9A for ; Mon, 18 Sep 2023 12:27:01 +0000 (UTC) From: Thomas Huth To: slof@lists.ozlabs.org Date: Mon, 18 Sep 2023 14:26:59 +0200 Message-ID: <20230918122659.92014-3-thuth@redhat.com> In-Reply-To: <20230918122659.92014-1-thuth@redhat.com> References: <20230918122659.92014-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [SLOF] [PATCH 2/2] lib/libtpm: Silence compiler warning about unaligned pointer value 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: , Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" GCC v13.2.1 complains: tpm_drivers.c: In function ‘spapr_send_crq_and_wait’: tpm_drivers.c:153:9: 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 { | ^~~ Since all members of this struct are naturally aligned, it's indeed better to avoid the "packed" attribute here and use a _Static_assert() to make sure that no padding is added here by accident. Signed-off-by: Thomas Huth --- lib/libtpm/tpm_drivers.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libtpm/tpm_drivers.c b/lib/libtpm/tpm_drivers.c index 85cb309..ac28072 100644 --- a/lib/libtpm/tpm_drivers.c +++ b/lib/libtpm/tpm_drivers.c @@ -37,7 +37,8 @@ struct crq { uint16_t len; uint32_t data; uint64_t reserved; -} __attribute__((packed)); +}; +_Static_assert(sizeof(struct crq) == 16, "padding in struct crq"); #define PAPR_VTPM_INIT_CRQ_COMMAND 0xC0 #define PAPR_VTPM_VALID_COMMAND 0x80