Skip to content

Commit

Permalink
icp: fix rodata being marked as text in x86 Asm code
Browse files Browse the repository at this point in the history
objtool properly complains that it can't decode some of the
instructions from ICP x86 Asm code. As mentioned in the Makefile,
where those object files were excluded from objtool check (but they
can still be visible under IBT and LTO), those are just constants,
not code.
In that case, they must be placed in .rodata, so they won't be
marked as "allocatable, executable" (ax) in EFL headers and this
effectively prevents objtool from trying to decode this data. That
reveals a whole bunch of other issues in ICP Asm code, as previously
objtool was bailing out after that warning message.

Reviewed-by: Attila Fülöp <attila@fueloep.org>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Closes openzfs#14035
  • Loading branch information
solbjorn authored and andrewc12 committed Nov 11, 2022
1 parent 22ced67 commit 778f55f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 1 addition & 5 deletions module/Kbuild.in
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,8 @@ $(addprefix $(obj)/icp/,$(ICP_OBJS) $(ICP_OBJS_X86) $(ICP_OBJS_X86_64) \
$(addprefix $(obj)/icp/,$(ICP_OBJS) $(ICP_OBJS_X86) $(ICP_OBJS_X86_64) \
$(ICP_OBJS_ARM64) $(ICP_OBJS_PPC_PPC64)) : ccflags-y += -I$(icp_include)

# Suppress objtool "can't find jump dest instruction at" warnings. They
# are caused by the constants which are defined in the text section of the
# assembly file using .byte instructions (e.g. bswap_mask). The objtool
# utility tries to interpret them as opcodes and obviously fails doing so.
# Suppress objtool "return with modified stack frame" warnings.
OBJECT_FILES_NON_STANDARD_aesni-gcm-x86_64.o := y
OBJECT_FILES_NON_STANDARD_ghash-x86_64.o := y

# Suppress objtool "unsupported stack pointer realignment" warnings. We are
# not using a DRAP register while aligning the stack to a 64 byte boundary.
Expand Down
2 changes: 2 additions & 0 deletions module/icp/asm-x86_64/modes/aesni-gcm-x86_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,7 @@ atomic_toggle_boolean_nv:
RET
.size atomic_toggle_boolean_nv,.-atomic_toggle_boolean_nv

.pushsection .rodata
.align 64
.Lbswap_mask:
.byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
Expand All @@ -1255,6 +1256,7 @@ atomic_toggle_boolean_nv:
.byte 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 65,69,83,45,78,73,32,71,67,77,32,109,111,100,117,108,101,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
.align 64
.popsection

/* Mark the stack non-executable. */
#if defined(__linux__) && defined(__ELF__)
Expand Down
3 changes: 3 additions & 0 deletions module/icp/asm-x86_64/modes/ghash-x86_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,8 @@ gcm_ghash_avx:
RET
.cfi_endproc
.size gcm_ghash_avx,.-gcm_ghash_avx

.pushsection .rodata
.align 64
.Lbswap_mask:
.byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
Expand Down Expand Up @@ -708,6 +710,7 @@ gcm_ghash_avx:

.byte 71,72,65,83,72,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
.align 64
.popsection

/* Mark the stack non-executable. */
#if defined(__linux__) && defined(__ELF__)
Expand Down

0 comments on commit 778f55f

Please sign in to comment.