From: "Michael S. Tsirkin" <mst@redhat.com>
To: Laszlo Ersek <lersek@redhat.com>
Cc: Dongjiu Geng <gengdongjiu@huawei.com>,
imammedo@redhat.com, famz@redhat.com, qemu-devel@nongnu.org,
zhaoshenglong@huawei.com, peter.maydell@linaro.org,
qemu-arm@nongnu.org, james.morse@arm.com,
zhengqiang10@huawei.com, huangshaoyu@huawei.com,
wuquanming@huawei.com
Subject: Re: [Qemu-devel] [PATCH v5 2/3] ACPI: Add APEI GHES Table Generation support
Date: Fri, 14 Jul 2017 01:31:31 +0300 [thread overview]
Message-ID: <20170714012613-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <660d600a-107c-e44a-7322-ae4a74bc5565@redhat.com>
On Thu, Jul 13, 2017 at 09:41:03PM +0200, Laszlo Ersek wrote:
> >> +
> >> + error_source++;
> >> + }
> >> +
> >> + for (i = 0; i < GHES_ACPI_HEST_NOTIFY_RESERVED; i++) {
> >> + bios_linker_loader_add_pointer(linker,
> >> + GHES_ERRORS_FW_CFG_FILE, sizeof(uint64_t) * i, sizeof(uint64_t),
> >> + GHES_ERRORS_FW_CFG_FILE, GHES_ACPI_HEST_NOTIFY_RESERVED *
> >> + sizeof(uint64_t) + i * GHES_MAX_RAW_DATA_LENGTH);
> >> + }
>
> So basically all this math exists to set up the pointers that are shown
> in the diagram in the commit message. It is a bit tricky because most of
> those pointer fields (all 8-bytes wide) are individually embedded into
> their own containing structures. In the previous version of this patch
> set, I painstakingly verified the math, and pointed out wherever I
> thought updates were necessary.
>
> I agree the math is hard to read, the code is very "dense". My
> suggestion (supporting yours) would be to calculate the fw_cfg blob
> offsets that should be patched in more fine-grained steps, possibly with
> multiple separate increments, using:
> - structure type names,
> - sizeof operators,
> - offsetof macros,
> - and possibly a separate comment for each offset increment.
>
> Thanks,
> Laszlo
Right. That's not what rest of ACPI does though. What we do there
is one of:
1. Use GArray to gradually build up the structure.
Struct *s = acpi_data_push(table, sizeof (*s));
s->foo = bar;
2. Even simpler: use build_append_int_noprefix:
build_append_int_noprefix(table, 2, bar); /* Foo field */
this removes the need to declare Struct in a header,
just add comments to match the spec exactly.
We might gradually move more code to (2) but (1) is an
OK style too, it makes it obvious the sizes are fine.
--
MST
next prev parent reply other threads:[~2017-07-13 22:31 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-12 2:08 [Qemu-devel] [PATCH v5 0/3] Generate APEI GHES table and dynamically record CPER Dongjiu Geng
2017-07-12 2:08 ` [Qemu-devel] [PATCH v5 1/3] ACPI: Add new ACPI structures and macros Dongjiu Geng
2017-07-13 10:33 ` Laszlo Ersek
2017-07-13 12:00 ` gengdongjiu
2017-07-13 15:33 ` Laszlo Ersek
2017-07-13 17:13 ` Michael S. Tsirkin
2017-07-14 8:25 ` gengdongjiu
2017-07-13 17:35 ` Michael S. Tsirkin
2017-07-13 17:01 ` Michael S. Tsirkin
2017-07-14 5:51 ` gengdongjiu
2017-07-13 17:11 ` Michael S. Tsirkin
2017-07-14 8:22 ` gengdongjiu
2017-07-12 2:08 ` [Qemu-devel] [PATCH v5 2/3] ACPI: Add APEI GHES Table Generation support Dongjiu Geng
2017-07-13 17:32 ` Michael S. Tsirkin
2017-07-13 19:41 ` Laszlo Ersek
2017-07-13 22:31 ` Michael S. Tsirkin [this message]
2017-07-17 4:43 ` gengdongjiu
2017-07-12 2:08 ` [Qemu-devel] [PATCH v5 3/3] ACPI: build and enable APEI GHES in the Makefile and configuration Dongjiu Geng
2017-07-13 17:36 ` [Qemu-devel] [PATCH v5 0/3] Generate APEI GHES table and dynamically record CPER Michael S. Tsirkin
-- strict thread matches above, loose matches on Subject: below --
2017-07-15 15:29 [Qemu-devel] [PATCH v5 2/3] ACPI: Add APEI GHES Table Generation support gengdongjiu
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=20170714012613-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=famz@redhat.com \
--cc=gengdongjiu@huawei.com \
--cc=huangshaoyu@huawei.com \
--cc=imammedo@redhat.com \
--cc=james.morse@arm.com \
--cc=lersek@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=wuquanming@huawei.com \
--cc=zhaoshenglong@huawei.com \
--cc=zhengqiang10@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).