From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BB9C1D6ED09 for ; Thu, 21 Nov 2024 11:25:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tE5Hs-0003Zf-HT; Thu, 21 Nov 2024 06:23:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tE5Ho-0003Yg-OM for qemu-devel@nongnu.org; Thu, 21 Nov 2024 06:23:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tE5Hn-0004K6-65 for qemu-devel@nongnu.org; Thu, 21 Nov 2024 06:23:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732188223; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=t7qMvePr7uUUcsEhtBBE/hzKBTUJZ2vBMpomLtHayJ8=; b=P2P1ddG9HAdDzmFxH570sfZDV39l6nydYjqimzxJK1U6ZI0ts+daozZ87fjPNfLcGXA3db R+G+QonLYmi+koNwljVXA28uFHyuwZbUGuFR6t9txUOukP2RXcrqZLPZP7sDKcuAqJapKK VJALkLrZ5YEgX1vBb1VKKw7bpzEtiVk= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-656-tGKC8KU9M5C3fE9JU_hnlQ-1; Thu, 21 Nov 2024 06:23:41 -0500 X-MC-Unique: tGKC8KU9M5C3fE9JU_hnlQ-1 X-Mimecast-MFC-AGG-ID: tGKC8KU9M5C3fE9JU_hnlQ Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-53a017bc09dso442579e87.0 for ; Thu, 21 Nov 2024 03:23:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732188220; x=1732793020; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=t7qMvePr7uUUcsEhtBBE/hzKBTUJZ2vBMpomLtHayJ8=; b=lbvL3UWMLsj1e7z0fIyjoQbn2Vh/fSiARwAxZjFdp6oEiSqOKW/zZdlj9zHmoJwFZh a+6q5M3bn1yzSxjC2sVvyIMkiMa9wcnpevgKs0yuY9UXR8YrrxgqhxP+oGg+vSvGJD3U i0QZSqP8V++lUfKF+j5yE7Z49fSa6u/wfp3BybIUWv0xTlaOw01GW2Gw6jNmr5UfjFod TTvAfa65iFzmaSaLVslEbNVd1voACAglKPgK8cyyfEij30lq4WZkSa79jeBqFL9e+oAx iRTnJjXTjps9CGPNBOXUZFTxwX2XPz5LxvAKvv5XGIFenvAxdT+h5J/3GrSW5duXIG47 ySHg== X-Gm-Message-State: AOJu0YwMdswEKa2JYgQHLx/xipX0pj604wkzgNDjyoq2YN+YA7RCl6AD 6cu/mjERE4Ka9FwenYhCdUMD8/zlODXH6LX1+sE5oV7Jb9jlifpaHig6RblMMQpGzKW8h2J5qfQ Opt7C9AuP6ueSZubMH+T7trsD1vWiqVYCohVZ8diffILXquwOLMSa X-Received: by 2002:a05:6512:b84:b0:53d:a8d3:aeca with SMTP id 2adb3069b0e04-53dc133ae0dmr3136732e87.28.1732188220328; Thu, 21 Nov 2024 03:23:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IEiqDQw7Vx2btXe7l/Oru39oAyFh+IdSudpcT4GB7SlEM+A2rwI7xi18GFk4/0Inbf7Cl4PHw== X-Received: by 2002:a05:6512:b84:b0:53d:a8d3:aeca with SMTP id 2adb3069b0e04-53dc133ae0dmr3136714e87.28.1732188219905; Thu, 21 Nov 2024 03:23:39 -0800 (PST) Received: from [192.168.10.3] ([151.49.91.173]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3825490c674sm4688174f8f.33.2024.11.21.03.23.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Nov 2024 03:23:39 -0800 (PST) Message-ID: <4549dfdb-f0b3-4a97-a8cf-3501a6051771@redhat.com> Date: Thu, 21 Nov 2024 12:23:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] hw/usb: Use __attribute__((packed)) vs __packed To: Thomas Huth , Michael Tokarev , Roque Arcudia Hernandez , richard.henderson@linaro.org, jansene@google.com Cc: qemu-devel@nongnu.org, Gerd Hoffmann , QEMU Trivial References: <20241101211720.3354111-1-roqueh@google.com> <6f67908f-7ca7-4aa2-86e2-99b79aa6b4e7@redhat.com> <68860810-cb4e-44c6-9466-a117bd4fcd49@redhat.com> From: Paolo Bonzini Content-Language: en-US Autocrypt: addr=pbonzini@redhat.com; keydata= xsEhBFRCcBIBDqDGsz4K0zZun3jh+U6Z9wNGLKQ0kSFyjN38gMqU1SfP+TUNQepFHb/Gc0E2 CxXPkIBTvYY+ZPkoTh5xF9oS1jqI8iRLzouzF8yXs3QjQIZ2SfuCxSVwlV65jotcjD2FTN04 hVopm9llFijNZpVIOGUTqzM4U55sdsCcZUluWM6x4HSOdw5F5Utxfp1wOjD/v92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do4qBrk41+gGQh b906Dudw5YhTJFU3nC6bbF2nrLlB4C/XSiH76ZvqzV0Z/cAMBo5NF/w= In-Reply-To: <68860810-cb4e-44c6-9466-a117bd4fcd49@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On 11/21/24 11:24, Thomas Huth wrote: > On 21/11/2024 11.01, Michael Tokarev wrote: >> 04.11.2024 10:37, Thomas Huth wrote: >>> On 01/11/2024 22.17, Roque Arcudia Hernandez wrote: >>>> __packed is non standard and is not present in clang-cl. >>>> __attribute__((packed)) has the same semantics. >>>> >>>> Signed-off-by: Erwin Jansen >>>> Signed-off-by: Roque Arcudia Hernandez >>>> --- >>>>   include/hw/usb/dwc2-regs.h | 2 +- >>>>   1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/include/hw/usb/dwc2-regs.h b/include/hw/usb/dwc2-regs.h >>>> index 523b112c5e..b8b4266543 100644 >>>> --- a/include/hw/usb/dwc2-regs.h >>>> +++ b/include/hw/usb/dwc2-regs.h >>>> @@ -838,7 +838,7 @@ >>>>   struct dwc2_dma_desc { >>>>           uint32_t status; >>>>           uint32_t buf; >>>> -} __packed; >>>> +} QEMU_PACKED; >>> >>> Reviewed-by: Thomas Huth >>> >>> Actually, the struct only consists of two 32-bit values, so I doubt >>> that the "packed" is needed here at all. Maybe we could even simply >>> remove it? >> To me it is important to mark structures as packed if it is >> important for them to have strict layout like in this case, >> even if de-facto it does not change the actual layout.  It's >> just like an annotation saying this structure can be used >> on wire or somesuch. > > Well, it can have an impact on your binary, too. On architectures that > don't support unaligned memory accesses, the compiler has to generate > code that reads the values of packed structures in a more cumbersome > way. So if you used "packed" though it's not really necessary (i.e. > everything is naturally aligned, and you can be sure that the starting > address is also properly aligned), the compiler generates worse code > than necessary in that case. Well, in this case the struct is downright unused. :) But we can't know if it is naturally aligned or not in guest memory, so it is advisable to keep the QEMU_PACKED. Paolo