From: Zhang Rui <rui.zhang@intel.com>
To: Xiaofei Tan <tanxiaofei@huawei.com>,
David Laight <David.Laight@ACULAB.COM>,
"rjw@rjwysocki.net" <rjw@rjwysocki.net>,
"lenb@kernel.org" <lenb@kernel.org>,
"bhelgaas@google.com" <bhelgaas@google.com>
Cc: "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: Tue, 30 Mar 2021 15:59:58 +0800 [thread overview]
Message-ID: <af3fd5adb62dcac93f2ff4ea7b6aff74d0106ac5.camel@intel.com> (raw)
In-Reply-To: <b5ad5909f3fb14b46d6ff0f81c10e42507a60c74.camel@intel.com>
On Tue, 2021-03-30 at 15:31 +0800, Zhang Rui wrote:
> On Tue, 2021-03-30 at 10:23 +0800, Xiaofei Tan wrote:
> > Hi David,
> >
> > On 2021/3/29 18:09, David Laight wrote:
> > > From: Xiaofei Tan
> > > > Sent: 27 March 2021 07:46
> > > >
> > > > Replace __attribute__((packed)) by __packed following the
> > > > advice of checkpatch.pl.
> > > >
> > > > Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
> > > > ---
> > > > drivers/acpi/acpi_fpdt.c | 6 +++---
> > > > 1 file changed, 3 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/drivers/acpi/acpi_fpdt.c
> > > > b/drivers/acpi/acpi_fpdt.c
> > > > index a89a806..690a88a 100644
> > > > --- a/drivers/acpi/acpi_fpdt.c
> > > > +++ b/drivers/acpi/acpi_fpdt.c
> > > > @@ -53,7 +53,7 @@ struct resume_performance_record {
> > > > u32 resume_count;
> > > > u64 resume_prev;
> > > > u64 resume_avg;
> > > > -} __attribute__((packed));
> > > > +} __packed;
> > > >
> > > > struct boot_performance_record {
> > > > struct fpdt_record_header header;
> > > > @@ -63,13 +63,13 @@ struct boot_performance_record {
> > > > u64 bootloader_launch;
> > > > u64 exitbootservice_start;
> > > > u64 exitbootservice_end;
> > > > -} __attribute__((packed));
> > > > +} __packed;
> > > >
> > > > struct suspend_performance_record {
> > > > struct fpdt_record_header header;
> > > > u64 suspend_start;
> > > > u64 suspend_end;
> > > > -} __attribute__((packed));
> > > > +} __packed;
> > >
> > > My standard question about 'packed' is whether it is actually
> > > needed.
> > > It should only be used if the structures might be misaligned in
> > > memory.
> > > If the only problem is that a 64bit item needs to be 32bit
> > > aligned
> > > then a suitable type should be used for those specific fields.
> > >
> > > Those all look very dubious - the standard header isn't packed
> > > so everything must eb assumed to be at least 32bit aligned.
> > >
> > > There are also other sub-structures that contain 64bit values.
> > > These don't contain padding - but that requires 64bit alignement.
> > >
> > > The only problematic structure is the last one - which would have
> > > a 32bit pad after the header.
> > > Is this even right given than there are explicit alignment pads
> > > in some of the other structures.
> > >
> > > If 64bit alignment isn't guaranteed then a '64bit aligned to
> > > 32bit'
> > > type should be used for the u64 fields.
> > >
> >
> > Yes, some of them has been aligned already, then nothing changed
> > when
> > add this "packed ". Maybe the purpose of the original author is
> > for
> > extension, and can tell others that this struct need be packed.
> >
>
> The patch is upstreamed recently but it was made long time ago.
> I think the original problem is that one of the address, probably the
> suspend_performance record, is not 64bit aligned, thus we can not
> read
> the proper content of suspend_start and suspend_end, mapped from
> physical memory.
>
> I will try to find a machine to reproduce the problem with all
> __attribute__((packed)) removed to double confirm this.
>
So here is the problem, without __attribute__((packed))
[ 0.858442] suspend_record: 0xffffaad500175020
/sys/firmware/acpi/fpdt/suspend/suspend_end_ns:addr:
0xffffaad500175030, 15998179292659843072
/sys/firmware/acpi/fpdt/suspend/suspend_start_ns:addr:
0xffffaad500175028, 0
suspend_record is mapped to 0xffffaad500175020, and it is combined with
one 32bit header and two 64bit fields (suspend_start and suspend_end),
this is how it is located in physical memory.
So the addresses of the two 64bit fields are actually not 64bit
aligned.
David,
Is this the "a 64bit item needs to be 32bit aligned" problem you
referred?
If yes, what is the proper fix? should I used two 32bits for each of
the field instead?
thanks,
rui
> thanks,
> rui
> > > David
> > >
> > > -
> > > Registered Address Lakeside, Bramley Road, Mount Farm, Milton
> > > Keynes, MK1 1PT, UK
> > > Registration No: 1397386 (Wales)
> > >
> > >
> > > .
> > >
> >
> >
>
>
next prev parent reply other threads:[~2021-03-30 8:01 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 [this message]
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
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=af3fd5adb62dcac93f2ff4ea7b6aff74d0106ac5.camel@intel.com \
--to=rui.zhang@intel.com \
--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=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