Stream: git-wasmtime

Topic: wasmtime / PR #4702 Fix mis-aligned access issues with s390x


view this post on Zulip Wasmtime GitHub notifications bot (Aug 12 2022 at 10:31):

uweigand opened PR #4702 from s390x-align-fixes to main:

This fixes two problems: minimum symbol alignment for the LARL
instruction, and alignment requirements for LRL/LGRL etc.

The first problem is that the LARL instruction used to load a
symbol address (PC relative) requires that the target symbol
is at least 2-byte aligned. This is always guaranteed for code
symbols (all instructions must be 2-aligned anyway), but not
necessarily for data symbols.

Other s390x compilers fix this problem by ensuring that all
global symbols are always emitted with a minimum 2-byte
alignment. This patch introduces an equivalent mechanism
for cranelift:

The second problem is that PC-relative instructions that
directly access data (like LRL/LGRL, STRL/STGRL etc.)
not only have the 2-byte requirement like LARL, but actually
require that their memory operand is naturally aligned
(i.e. alignment is at least the size of the access).

This property (natural alignment for memory accesses) is
supposed to be provided by the "aligned" flag in MemFlags;
however, this is not implemented correctly at the moment.

To fix this, this patch:

Tested with wasmtime and cg_clif.

FYI @cfallin @bjorn3 - this is the last missing cranelift patch to make cg_clif work on s390x.

<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

Please ensure all communication adheres to the code of conduct.
-->

view this post on Zulip Wasmtime GitHub notifications bot (Aug 12 2022 at 10:43):

bjorn3 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 12 2022 at 10:43):

bjorn3 created PR review comment:

I think you should default function_alignment to isa.symbol_alignment().

view this post on Zulip Wasmtime GitHub notifications bot (Aug 12 2022 at 10:44):

uweigand created PR review comment:

I didn't do that because it seemed that would allow a caller to override the function alignment to smaller than isa.symbol_alignment(), and that simply doesn't work on s390x.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 12 2022 at 10:44):

uweigand submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 15 2022 at 17:38):

cfallin created PR review comment:

This list of flags is long enough now that it's starting to feel a bit error-prone; and e.g. the diff adding false in the right places is hard to review carefully. Could we turn this into a struct of flags?

view this post on Zulip Wasmtime GitHub notifications bot (Aug 15 2022 at 17:38):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 15 2022 at 17:38):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 16 2022 at 15:18):

uweigand updated PR #4702 from s390x-align-fixes to main.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 16 2022 at 15:18):

uweigand submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 16 2022 at 15:18):

uweigand created PR review comment:

Agreed, that makes sense. Like this?

view this post on Zulip Wasmtime GitHub notifications bot (Aug 16 2022 at 19:39):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 16 2022 at 19:39):

cfallin merged PR #4702.


Last updated: Nov 22 2024 at 17:03 UTC