From: Petr Pavlu <petr.pavlu@suse.com>
To: Sami Tolvanen <samitolvanen@google.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>,
Luis Chamberlain <mcgrof@kernel.org>,
Daniel Gomez <da.gomez@samsung.com>,
linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] gendwarfksyms: Add a kABI rule to override byte_size attributes
Date: Mon, 5 May 2025 13:57:27 +0200 [thread overview]
Message-ID: <0aa0c9b8-2d6a-48e8-9a57-df2583f26d14@suse.com> (raw)
In-Reply-To: <20250430214049.2658716-8-samitolvanen@google.com>
On 4/30/25 23:40, Sami Tolvanen wrote:
> A data structure can be partially opaque to modules if its
> allocation is handled by the core kernel, and modules only need
> to access some of its members. In this situation, it's possible
> to append new members to the structure without breaking the ABI,
> as long as the layout for the original members remains unchanged.
> For example, consider the following struct:
>
> struct s {
> unsigned long a;
> void *p;
> };
>
> gendwarfksyms --stable --dump-dies produces the following type
> expansion:
>
> variable structure_type s {
> member base_type long unsigned int byte_size(8) encoding(7) a
> data_member_location(0) ,
> member pointer_type {
> base_type void
> } byte_size(8) p data_member_location(8)
> } byte_size(16)
>
> To append new members, we can use the KABI_IGNORE() macro to
> hide them from gendwarfksyms --stable:
>
> struct s {
> /* old members with unchanged layout */
> unsigned long a;
> void *p;
>
> /* new members not accessed by modules */
> KABI_IGNORE(0, unsigned long n);
> };
>
> However, we can't hide the fact that adding new members changes
> the struct size, as seen in the updated type string:
>
> variable structure_type s {
> member base_type long unsigned int byte_size(8) encoding(7) a
> data_member_location(0) ,
> member pointer_type {
> base_type void
> } byte_size(8) p data_member_location(8)
> } byte_size(24)
>
> In order to support this use case, add a kABI rule that makes it
> possible to override the byte_size attribute for types:
>
> /*
> * struct s allocation is handled by the kernel, so
> * appending new members without changing the original
> * layout won't break the ABI.
> */
> KABI_BYTE_SIZE(s, 16);
>
> This results in a type string that's unchanged from the original
> and therefore, won't change versions for symbols that reference
> the changed structure.
>
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
-- Petr
next prev parent reply other threads:[~2025-05-05 11:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-30 21:40 [PATCH 0/4] gendwarfksyms: Add more kABI rules Sami Tolvanen
2025-04-30 21:40 ` [PATCH 1/4] gendwarfksyms: Clean up kABI rule look-ups Sami Tolvanen
2025-05-05 11:56 ` Petr Pavlu
2025-04-30 21:40 ` [PATCH 2/4] gendwarfksyms: Add a kABI rule to override byte_size attributes Sami Tolvanen
2025-05-05 11:57 ` Petr Pavlu [this message]
2025-04-30 21:40 ` [PATCH 3/4] gendwarfksyms: Add a kABI rule to override type strings Sami Tolvanen
2025-05-05 12:17 ` Petr Pavlu
2025-05-05 19:15 ` Sami Tolvanen
2025-04-30 21:40 ` [PATCH 4/4] Documentation/kbuild: Add new gendwarfksyms kABI rules Sami Tolvanen
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=0aa0c9b8-2d6a-48e8-9a57-df2583f26d14@suse.com \
--to=petr.pavlu@suse.com \
--cc=da.gomez@samsung.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=mcgrof@kernel.org \
--cc=samitolvanen@google.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
all inboxes | Powered by JetHome®