Skip to content

Commit

Permalink
x86/asm: Ensure function alignment
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
KAGA-KOKO committed Jul 20, 2022
1 parent 4e3d90f commit 0f16b39
Show file tree
Hide file tree
Showing 19 changed files with 18 additions and 38 deletions.
2 changes: 0 additions & 2 deletions arch/x86/crypto/camellia-aesni-avx-asm_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,6 @@ SYM_FUNC_END(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)

.text

.align 8
SYM_FUNC_START_LOCAL(__camellia_enc_blk16)
/* input:
* %rdi: ctx, CTX
Expand Down Expand Up @@ -799,7 +798,6 @@ SYM_FUNC_START_LOCAL(__camellia_enc_blk16)
jmp .Lenc_done;
SYM_FUNC_END(__camellia_enc_blk16)

.align 8
SYM_FUNC_START_LOCAL(__camellia_dec_blk16)
/* input:
* %rdi: ctx, CTX
Expand Down
4 changes: 0 additions & 4 deletions arch/x86/crypto/camellia-aesni-avx2-asm_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,13 @@
* Size optimization... with inlined roundsm32 binary would be over 5 times
* larger and would only marginally faster.
*/
.align 8
SYM_FUNC_START_LOCAL(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
%ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
%rcx, (%r9));
RET;
SYM_FUNC_END(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)

.align 8
SYM_FUNC_START_LOCAL(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
%ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
Expand Down Expand Up @@ -748,7 +746,6 @@ SYM_FUNC_END(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)

.text

.align 8
SYM_FUNC_START_LOCAL(__camellia_enc_blk32)
/* input:
* %rdi: ctx, CTX
Expand Down Expand Up @@ -835,7 +832,6 @@ SYM_FUNC_START_LOCAL(__camellia_enc_blk32)
jmp .Lenc_done;
SYM_FUNC_END(__camellia_enc_blk32)

.align 8
SYM_FUNC_START_LOCAL(__camellia_dec_blk32)
/* input:
* %rdi: ctx, CTX
Expand Down
2 changes: 0 additions & 2 deletions arch/x86/crypto/cast5-avx-x86_64-asm_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@

.text

.align 16
SYM_FUNC_START_LOCAL(__cast5_enc_blk16)
/* input:
* %rdi: ctx
Expand Down Expand Up @@ -282,7 +281,6 @@ SYM_FUNC_START_LOCAL(__cast5_enc_blk16)
RET;
SYM_FUNC_END(__cast5_enc_blk16)

.align 16
SYM_FUNC_START_LOCAL(__cast5_dec_blk16)
/* input:
* %rdi: ctx
Expand Down
1 change: 0 additions & 1 deletion arch/x86/crypto/crct10dif-pcl-asm_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
#
# Assumes len >= 16.
#
.align 16
SYM_FUNC_START(crc_t10dif_pcl)

movdqa .Lbswap_mask(%rip), BSWAP_MASK
Expand Down
2 changes: 0 additions & 2 deletions arch/x86/crypto/serpent-avx-x86_64-asm_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,6 @@
#define write_blocks(x0, x1, x2, x3, t0, t1, t2) \
transpose_4x4(x0, x1, x2, x3, t0, t1, t2)

.align 8
SYM_FUNC_START_LOCAL(__serpent_enc_blk8_avx)
/* input:
* %rdi: ctx, CTX
Expand Down Expand Up @@ -604,7 +603,6 @@ SYM_FUNC_START_LOCAL(__serpent_enc_blk8_avx)
RET;
SYM_FUNC_END(__serpent_enc_blk8_avx)

.align 8
SYM_FUNC_START_LOCAL(__serpent_dec_blk8_avx)
/* input:
* %rdi: ctx, CTX
Expand Down
2 changes: 0 additions & 2 deletions arch/x86/crypto/serpent-avx2-asm_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,6 @@
#define write_blocks(x0, x1, x2, x3, t0, t1, t2) \
transpose_4x4(x0, x1, x2, x3, t0, t1, t2)

.align 8
SYM_FUNC_START_LOCAL(__serpent_enc_blk16)
/* input:
* %rdi: ctx, CTX
Expand Down Expand Up @@ -604,7 +603,6 @@ SYM_FUNC_START_LOCAL(__serpent_enc_blk16)
RET;
SYM_FUNC_END(__serpent_enc_blk16)

.align 8
SYM_FUNC_START_LOCAL(__serpent_dec_blk16)
/* input:
* %rdi: ctx, CTX
Expand Down
1 change: 0 additions & 1 deletion arch/x86/crypto/sha1_ni_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
* numBlocks: Number of blocks to process
*/
.text
.align 32
SYM_FUNC_START(sha1_ni_transform)
push %rbp
mov %rsp, %rbp
Expand Down
1 change: 0 additions & 1 deletion arch/x86/crypto/sha256-avx-asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ a = TMP_
########################################################################
.text
SYM_FUNC_START(sha256_transform_avx)
.align 32
pushq %rbx
pushq %r12
pushq %r13
Expand Down
1 change: 0 additions & 1 deletion arch/x86/crypto/sha256-avx2-asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ STACK_SIZE = _CTX + _CTX_SIZE
########################################################################
.text
SYM_FUNC_START(sha256_transform_rorx)
.align 32
pushq %rbx
pushq %r12
pushq %r13
Expand Down
1 change: 0 additions & 1 deletion arch/x86/crypto/sha256-ssse3-asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ a = TMP_
########################################################################
.text
SYM_FUNC_START(sha256_transform_ssse3)
.align 32
pushq %rbx
pushq %r12
pushq %r13
Expand Down
1 change: 0 additions & 1 deletion arch/x86/crypto/sha256_ni_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
*/

.text
.align 32
SYM_FUNC_START(sha256_ni_transform)

shl $6, NUM_BLKS /* convert to bytes */
Expand Down
1 change: 0 additions & 1 deletion arch/x86/crypto/sm3-avx-asm_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@
* void sm3_transform_avx(struct sm3_state *state,
* const u8 *data, int nblocks);
*/
.align 16
SYM_FUNC_START(sm3_transform_avx)
/* input:
* %rdi: ctx, CTX
Expand Down
7 changes: 0 additions & 7 deletions arch/x86/crypto/sm4-aesni-avx-asm_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,11 @@


.text
.align 16

/*
* void sm4_aesni_avx_crypt4(const u32 *rk, u8 *dst,
* const u8 *src, int nblocks)
*/
.align 8
SYM_FUNC_START(sm4_aesni_avx_crypt4)
/* input:
* %rdi: round key array, CTX
Expand Down Expand Up @@ -249,7 +247,6 @@ SYM_FUNC_START(sm4_aesni_avx_crypt4)
RET;
SYM_FUNC_END(sm4_aesni_avx_crypt4)

.align 8
SYM_FUNC_START_LOCAL(__sm4_crypt_blk8)
/* input:
* %rdi: round key array, CTX
Expand Down Expand Up @@ -363,7 +360,6 @@ SYM_FUNC_END(__sm4_crypt_blk8)
* void sm4_aesni_avx_crypt8(const u32 *rk, u8 *dst,
* const u8 *src, int nblocks)
*/
.align 8
SYM_FUNC_START(sm4_aesni_avx_crypt8)
/* input:
* %rdi: round key array, CTX
Expand Down Expand Up @@ -419,7 +415,6 @@ SYM_FUNC_END(sm4_aesni_avx_crypt8)
* void sm4_aesni_avx_ctr_enc_blk8(const u32 *rk, u8 *dst,
* const u8 *src, u8 *iv)
*/
.align 8
SYM_FUNC_START(sm4_aesni_avx_ctr_enc_blk8)
/* input:
* %rdi: round key array, CTX
Expand Down Expand Up @@ -494,7 +489,6 @@ SYM_FUNC_END(sm4_aesni_avx_ctr_enc_blk8)
* void sm4_aesni_avx_cbc_dec_blk8(const u32 *rk, u8 *dst,
* const u8 *src, u8 *iv)
*/
.align 8
SYM_FUNC_START(sm4_aesni_avx_cbc_dec_blk8)
/* input:
* %rdi: round key array, CTX
Expand Down Expand Up @@ -544,7 +538,6 @@ SYM_FUNC_END(sm4_aesni_avx_cbc_dec_blk8)
* void sm4_aesni_avx_cfb_dec_blk8(const u32 *rk, u8 *dst,
* const u8 *src, u8 *iv)
*/
.align 8
SYM_FUNC_START(sm4_aesni_avx_cfb_dec_blk8)
/* input:
* %rdi: round key array, CTX
Expand Down
6 changes: 0 additions & 6 deletions arch/x86/crypto/sm4-aesni-avx2-asm_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@
.long 0xdeadbeef, 0xdeadbeef, 0xdeadbeef

.text
.align 16

.align 8
SYM_FUNC_START_LOCAL(__sm4_crypt_blk16)
/* input:
* %rdi: round key array, CTX
Expand Down Expand Up @@ -281,7 +278,6 @@ SYM_FUNC_END(__sm4_crypt_blk16)
* void sm4_aesni_avx2_ctr_enc_blk16(const u32 *rk, u8 *dst,
* const u8 *src, u8 *iv)
*/
.align 8
SYM_FUNC_START(sm4_aesni_avx2_ctr_enc_blk16)
/* input:
* %rdi: round key array, CTX
Expand Down Expand Up @@ -394,7 +390,6 @@ SYM_FUNC_END(sm4_aesni_avx2_ctr_enc_blk16)
* void sm4_aesni_avx2_cbc_dec_blk16(const u32 *rk, u8 *dst,
* const u8 *src, u8 *iv)
*/
.align 8
SYM_FUNC_START(sm4_aesni_avx2_cbc_dec_blk16)
/* input:
* %rdi: round key array, CTX
Expand Down Expand Up @@ -448,7 +443,6 @@ SYM_FUNC_END(sm4_aesni_avx2_cbc_dec_blk16)
* void sm4_aesni_avx2_cfb_dec_blk16(const u32 *rk, u8 *dst,
* const u8 *src, u8 *iv)
*/
.align 8
SYM_FUNC_START(sm4_aesni_avx2_cfb_dec_blk16)
/* input:
* %rdi: round key array, CTX
Expand Down
2 changes: 0 additions & 2 deletions arch/x86/crypto/twofish-avx-x86_64-asm_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@
vpxor x2, wkey, x2; \
vpxor x3, wkey, x3;

.align 8
SYM_FUNC_START_LOCAL(__twofish_enc_blk8)
/* input:
* %rdi: ctx, CTX
Expand Down Expand Up @@ -270,7 +269,6 @@ SYM_FUNC_START_LOCAL(__twofish_enc_blk8)
RET;
SYM_FUNC_END(__twofish_enc_blk8)

.align 8
SYM_FUNC_START_LOCAL(__twofish_dec_blk8)
/* input:
* %rdi: ctx, CTX
Expand Down
4 changes: 4 additions & 0 deletions arch/x86/entry/entry_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ SYM_FUNC_END(__switch_to_asm)
* r12: kernel thread arg
*/
.pushsection .text, "ax"
__FUNC_ALIGN
SYM_CODE_START(ret_from_fork)
UNWIND_HINT_EMPTY
ANNOTATE_NOENDBR // copy_thread
Expand Down Expand Up @@ -828,6 +829,7 @@ EXPORT_SYMBOL(asm_load_gs_index)
*
* C calling convention: exc_xen_hypervisor_callback(struct *pt_regs)
*/
__FUNC_ALIGN
SYM_CODE_START_LOCAL(exc_xen_hypervisor_callback)

/*
Expand Down Expand Up @@ -856,6 +858,7 @@ SYM_CODE_END(exc_xen_hypervisor_callback)
* We distinguish between categories by comparing each saved segment register
* with its current contents: any discrepancy means we in category 1.
*/
__FUNC_ALIGN
SYM_CODE_START(xen_failsafe_callback)
UNWIND_HINT_EMPTY
ENDBR
Expand Down Expand Up @@ -1516,6 +1519,7 @@ SYM_CODE_END(ignore_sysret)
#endif

.pushsection .text, "ax"
__FUNC_ALIGN
SYM_CODE_START(rewind_stack_and_make_dead)
UNWIND_HINT_FUNC
/* Prevent any naive code from trying to unwind to our caller. */
Expand Down
15 changes: 12 additions & 3 deletions arch/x86/include/asm/linkage.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,18 @@

#endif /* __ASSEMBLY__ */

#if CONFIG_FUNCTION_ALIGNMENT == 16
# define __FUNC_ALIGN .p2align 4, 0x90;
# define ASM_FUNC_ALIGN ".p2align 4, 0x90;"
# define SYM_F_ALIGN __FUNC_ALIGN
#else
# define ASM_FUNC_ALIGN ""
# define SYM_F_ALIGN SYM_A_ALIGN
#endif

/* SYM_FUNC_START -- use for global functions */
#define SYM_FUNC_START(name) \
SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN) \
SYM_START(name, SYM_L_GLOBAL, SYM_F_ALIGN) \
ENDBR

/* SYM_FUNC_START_NOALIGN -- use for global functions, w/o alignment */
Expand All @@ -56,7 +65,7 @@

/* SYM_FUNC_START_LOCAL -- use for local functions */
#define SYM_FUNC_START_LOCAL(name) \
SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN) \
SYM_START(name, SYM_L_LOCAL, SYM_F_ALIGN) \
ENDBR

/* SYM_FUNC_START_LOCAL_NOALIGN -- use for local functions, w/o alignment */
Expand All @@ -66,7 +75,7 @@

/* SYM_FUNC_START_WEAK -- use for weak functions */
#define SYM_FUNC_START_WEAK(name) \
SYM_START(name, SYM_L_WEAK, SYM_A_ALIGN) \
SYM_START(name, SYM_L_WEAK, SYM_F_ALIGN) \
ENDBR

/* SYM_FUNC_START_WEAK_NOALIGN -- use for weak functions, w/o alignment */
Expand Down
1 change: 1 addition & 0 deletions arch/x86/include/asm/paravirt.h
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
extern typeof(func) __raw_callee_save_##func; \
\
asm(".pushsection " section ", \"ax\";" \
ASM_FUNC_ALIGN \
".globl " PV_THUNK_NAME(func) ";" \
".type " PV_THUNK_NAME(func) ", @function;" \
PV_THUNK_NAME(func) ":" \
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/include/asm/qspinlock_paravirt.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath);
* rdx = internal variable (set to 0)
*/
asm (".pushsection .text;"
ASM_FUNC_ALIGN
".globl " PV_UNLOCK ";"
".type " PV_UNLOCK ", @function;"
".align 4,0x90;"
PV_UNLOCK ": "
ASM_ENDBR
FRAME_BEGIN
Expand Down

0 comments on commit 0f16b39

Please sign in to comment.