Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp576441pxf; Wed, 31 Mar 2021 10:25:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB3bjg02hMg+MKMLrMalT8Bwxi32TDq1lRXBqS8yDWFAL/D0HAoCEgjw1lYgxBn0QtLNCq X-Received: by 2002:a50:eb8f:: with SMTP id y15mr5115758edr.115.1617211520326; Wed, 31 Mar 2021 10:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617211520; cv=none; d=google.com; s=arc-20160816; b=iYnGptIDQELeJcqEl4C5Q15TkrnkQ756FWKIhqCLLnlk39EFBrHcIyKeDlOnr5oXtG WlvNa80450zbjX70Yw+Rj6Knhyl+Lw0EAmgWDkUcQB9n8bl3jXvk9q+n6gMLlcd7WlRL 5uHBKz9E9cBannxujMPjsrunp+C+zr28eZIIjCn/NsPoWdSPPno2gEXVCne7uc3F1R5d M0joRcKyy3ZiYQZ3OBePAmbMWiayzI1+kssROAQ6mT4DzUW37+D3+mEIbLwVLeWgLTOa QKUmhlctSf+rWu8q8uEKy5B31saqTP2ij6Y2BqLVypYkXajnVxtwFxIefd9a5C+Eq4y0 geAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=GFpn/hOCe2YOIez71uqLv++3ziQM0okBrbgb0ZADOQc=; b=OqQoFr+fFaBGAIjN3HVqSAslXBAKcVdMtkP5Cg1FAwzbNpEnPjfuiJIIE1VZM0l6o+ KZCo4v07asaNAshMIlCwhRf7nfRaBn0UGxfafzUD5iBL0rrqhRr4ciRaSmQaThVV6H+w 8eYtdwA1HSom6ijF416K0NKwDqBU0PC/mbBs3bKoGt1KAybbcvacQtkn6PawfRQ69epl 9MU2x568v01X11FGBIqLWH8NF/zYeYTHAjH+mOrZ2RqFKylb1zTXV8+YqNcmDXfVkith hWTGuCNgUrRPrgnDrVqXbRzjg4+YyEI3Eaiz0QlYN1//imc8/dCy+GK4Vp2X64PLNCu7 qyEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Y+w6NTt0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si2321324ejr.192.2021.03.31.10.24.56; Wed, 31 Mar 2021 10:25:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Y+w6NTt0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233757AbhCaRWU (ORCPT + 99 others); Wed, 31 Mar 2021 13:22:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:36334 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233900AbhCaRWN (ORCPT ); Wed, 31 Mar 2021 13:22:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B721961041; Wed, 31 Mar 2021 17:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617211332; bh=UNNvx8KRbir/+SlHakk0v0B4spVKeTNYcTv3zPs9JaY=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=Y+w6NTt0eiDQrd/3cvK6U8FxlBYYQDStYl+pTMOrnYv5SRqR9ou5//rEZoXqXa6iA bqZXtWIHoGkR6BCUqOR+xkJxAtrXK6++GFvEVtTQLuuQz8rb/G424ffNkHN3OFDU5j T87XdnLPLslscLynwtM+aQU2UKqpAJyG/rBkXwzmCXyJFkgjalwgzG2a5UVkBb1/bG 0dMtuuEOkTsb1YIEuAQURB9HE++Xu9K14sG2y+EXAGYNlXPGZ8f0qnlI/kFYmSbViT V8qFnLiFWMgqdtxbciYGFSLK1MYyb9yBFezmbQLzjhb+3F292NIj0dXTbiCSJZlm1t DeUVdbnQRnPYw== Date: Wed, 31 Mar 2021 12:22:10 -0500 From: Bjorn Helgaas To: Zhang Rui Cc: David Laight , Xiaofei Tan , "rjw@rjwysocki.net" , "lenb@kernel.org" , "bhelgaas@google.com" , "linux-acpi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linuxarm@openeuler.org" Subject: Re: [PATCH v2 04/15] ACPI: table: replace __attribute__((packed)) by __packed Message-ID: <20210331172210.GA1397554@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 31, 2021 at 11:55:08PM +0800, Zhang Rui wrote: > ... > From e18c942855e2f51e814d057fff4dd951cd0d0907 Mon Sep 17 00:00:00 2001 > From: Zhang Rui > Date: Wed, 31 Mar 2021 20:34:13 +0800 > Subject: [PATCH] ACPI: tables: FPDT: Fix 64bit alignment issue > > Some of the 64bit items in FPDT table may be 32bit aligned. > Using __attribute__((packed)) is not needed in this case, fixing it by > allowing 32bit alignment for these 64bit items. 1) Can you please add a spec reference for this? I think it's ACPI v6.3, sec 5.2.23.5, or something close to that. 2) The exact layout in memory is prescribed by the spec. I think that's basically what "packed" accomplishes. I don't understand why using "aligned" would be preferable. Using "aligned" means things can be at different offsets depending on the starting address of the structure. We always want the identical layout, no matter what the starting address is. > Signed-off-by: Zhang Rui > --- > drivers/acpi/acpi_fpdt.c | 28 +++++++++++++++------------- > 1 file changed, 15 insertions(+), 13 deletions(-) > > diff --git a/drivers/acpi/acpi_fpdt.c b/drivers/acpi/acpi_fpdt.c > index a89a806a7a2a..94e107b9a114 100644 > --- a/drivers/acpi/acpi_fpdt.c > +++ b/drivers/acpi/acpi_fpdt.c > @@ -23,12 +23,14 @@ enum fpdt_subtable_type { > SUBTABLE_S3PT, > }; > > +typedef u64 __attribute__((aligned(4))) u64_align32; > + > struct fpdt_subtable_entry { > u16 type; /* refer to enum fpdt_subtable_type */ > u8 length; > u8 revision; > u32 reserved; > - u64 address; /* physical address of the S3PT/FBPT table */ > + u64_align32 address; /* physical address of the S3PT/FBPT table */ > }; > > struct fpdt_subtable_header { > @@ -51,25 +53,25 @@ struct fpdt_record_header { > struct resume_performance_record { > struct fpdt_record_header header; > u32 resume_count; > - u64 resume_prev; > - u64 resume_avg; > -} __attribute__((packed)); > + u64_align32 resume_prev; > + u64_align32 resume_avg; > +}; > > struct boot_performance_record { > struct fpdt_record_header header; > u32 reserved; > - u64 firmware_start; > - u64 bootloader_load; > - u64 bootloader_launch; > - u64 exitbootservice_start; > - u64 exitbootservice_end; > -} __attribute__((packed)); > + u64_align32 firmware_start; > + u64_align32 bootloader_load; > + u64_align32 bootloader_launch; > + u64_align32 exitbootservice_start; > + u64_align32 exitbootservice_end; > +}; > > struct suspend_performance_record { > struct fpdt_record_header header; > - u64 suspend_start; > - u64 suspend_end; > -} __attribute__((packed)); > + u64_align32 suspend_start; > + u64_align32 suspend_end; > +}; > > > static struct resume_performance_record *record_resume; > -- > 2.17.1 > >