linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Zhang Rui <rui.zhang@intel.com>
Cc: David Laight <David.Laight@ACULAB.COM>,
	Xiaofei Tan <tanxiaofei@huawei.com>,
	"rjw@rjwysocki.net" <rjw@rjwysocki.net>,
	"lenb@kernel.org" <lenb@kernel.org>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"linuxarm@openeuler.org" <linuxarm@openeuler.org>
Subject: Re: [PATCH v2 04/15] ACPI: table: replace __attribute__((packed)) by __packed
Date: Wed, 31 Mar 2021 12:22:10 -0500	[thread overview]
Message-ID: <20210331172210.GA1397554@bjorn-Precision-5520> (raw)
In-Reply-To: <e0d626837e577e60f226b8bbf354bd8cbb1fe40a.camel@intel.com>

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 <rui.zhang@intel.com>
> 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 <rui.zhang@intel.com>
> ---
>  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
> 
> 

  parent reply	other threads:[~2021-03-31 17:22 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-27  7:46 [PATCH v2 00/15] acpi: fix some coding style issues Xiaofei Tan
2021-03-27  7:46 ` [PATCH v2 01/15] ACPI: APD: fix a block comment align issue Xiaofei Tan
2021-03-27  7:46 ` [PATCH v2 02/15] ACPI: processor: fix some coding style issues Xiaofei Tan
2021-03-27  7:46 ` [PATCH v2 03/15] ACPI: debug: " Xiaofei Tan
2021-03-27  7:46 ` [PATCH v2 04/15] ACPI: table: replace __attribute__((packed)) by __packed Xiaofei Tan
2021-03-29 10:09   ` David Laight
2021-03-30  2:23     ` Xiaofei Tan
2021-03-30  7:31       ` Zhang Rui
2021-03-30  7:59         ` Zhang Rui
2021-03-30  8:14           ` David Laight
2021-03-30 17:00             ` Rafael J. Wysocki
2021-03-31 15:55             ` Zhang Rui
2021-03-31 16:14               ` David Laight
2021-03-31 17:22               ` Bjorn Helgaas [this message]
2021-04-01  8:59                 ` David Laight
2021-04-01 13:49                   ` Rafael J. Wysocki
2021-04-01 14:23                     ` David Laight
2021-04-01 17:29                       ` Rafael J. Wysocki
2021-03-27  7:46 ` [PATCH v2 05/15] ACPI: ipmi: remove useless return statement for void function Xiaofei Tan
2021-03-27  7:46 ` [PATCH v2 06/15] ACPI: LPSS: fix some coding style issues Xiaofei Tan
     [not found]   ` <CAHp75Vc+0hxLS_Ab7_VZfrG2jiQzvia9S=o+Gc+wg+vVk1Z39w@mail.gmail.com>
2021-03-27  9:55     ` Xiaofei Tan
     [not found]   ` <CAHp75Vd0hVqsfsZK=d1dz98Kbchqz-w4RqQQp6FwisxSGG5BzA@mail.gmail.com>
2021-03-27  9:58     ` Xiaofei Tan
2021-03-27 13:39     ` Joe Perches
2021-03-27 16:39       ` Andy Shevchenko
2021-03-27  7:46 ` [PATCH v2 07/15] ACPI: memhotplug: fix a coding style issue Xiaofei Tan
2021-03-27  7:46 ` [PATCH v2 08/15] ACPI: acpi_pad: " Xiaofei Tan
2021-03-27  7:46 ` [PATCH v2 09/15] ACPI: battery: fix some coding style issues Xiaofei Tan
2021-03-27  7:46 ` [PATCH v2 10/15] ACPI: button: " Xiaofei Tan
2021-03-27  7:46 ` [PATCH v2 11/15] ACPI: CPPC: " Xiaofei Tan
2021-03-27  7:46 ` [PATCH v2 12/15] ACPI: custom_method: fix a coding style issue Xiaofei Tan
2021-03-27  7:46 ` [PATCH v2 13/15] ACPI: PM: fix some coding style issues Xiaofei Tan
2021-03-27  7:46 ` [PATCH v2 14/15] ACPI: sysfs: " Xiaofei Tan
2021-03-27  7:46 ` [PATCH v2 15/15] ACPI: dock: " Xiaofei Tan
     [not found] ` <CAHp75VcwuFYWRYfVPxbqa4TFGgqOhHc_soefmTAZcGGk3bLuhw@mail.gmail.com>
2021-03-27 10:00   ` [PATCH 00/15] acpi: " Xiaofei Tan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210331172210.GA1397554@bjorn-Precision-5520 \
    --to=helgaas@kernel.org \
    --cc=David.Laight@ACULAB.COM \
    --cc=bhelgaas@google.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxarm@openeuler.org \
    --cc=rjw@rjwysocki.net \
    --cc=rui.zhang@intel.com \
    --cc=tanxiaofei@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).