Skip to content

Add m68k-specific padding to OBJECT related data structures to make it work#566

Merged
stefanberger merged 3 commits intomasterfrom
stefanberger/force_m68k_alignment
Mar 6, 2026
Merged

Add m68k-specific padding to OBJECT related data structures to make it work#566
stefanberger merged 3 commits intomasterfrom
stefanberger/force_m68k_alignment

Conversation

@stefanberger
Copy link
Copy Markdown
Owner

@stefanberger stefanberger commented Mar 5, 2026

Add m68k-specific padding to OBJECT-related data structures to make libtpms work on Linux m68k. Also NV_INDEX needs to be padded since this structure is still being memcpy'ed into NVRAM and should therefore consume the same amount of space on all archs.

There are only 3 lines of changes in TpmTypes.h, so it's not too intrusive. It may also be helpful to fix other data structures to expected sizes, and fields within data structures to expected offset when it comes to BackwardsCompatibilityObject.c, which should not need to be touch anymore.

Before adding padding to the data structures, add asserts for offsets and
sizes of data structures so that none of these will change due to padding.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
On m68k int's only need to be 2-byte aligned and therefore the size of
some data structures or offsets of fields within data structures is not
as expected. Fix this by adding artificial m68k-specific padding where
necessary. If padding was added on any other architecture, it would not
make a difference there. Similarly, if some day m68k gcc was to align int's
as expected, the artifical padding would not have any influence on the
expected sizes and offsets and could be removed.

With the padding applied, swtpm should now be able to read state written
by other architectures. This is for example the case with swtpm test cases.

Link: https://wiki.debian.org/M68k/Alignment
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
@stefanberger stefanberger force-pushed the stefanberger/force_m68k_alignment branch from fd99669 to 578a752 Compare March 5, 2026 22:39
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
@stefanberger stefanberger force-pushed the stefanberger/force_m68k_alignment branch from 578a752 to 32dd082 Compare March 5, 2026 22:48
@stefanberger stefanberger merged commit ec4b1a7 into master Mar 6, 2026
4 checks passed
@stefanberger stefanberger deleted the stefanberger/force_m68k_alignment branch March 6, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant