Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ ifeq ($(QUIC_AARCH64_NOFP),yes)
ALL_OBJS := $(subst obj/src/math/aarch64/,obj/src/math/, $(ALL_OBJS))
endif

ifeq ($(QUIC_AARCH64_MARK_BTI),yes)
ASM_SRCS = src/string/aarch64/memcpy.S src/string/aarch64/memset.S
$(ASM_SRCS:%.S=obj/%.o) $(ASM_SRCS:%.S=obj/%.lo): CFLAGS_ALL += -mmark-bti-property
endif

ifneq ($(QUIC_AARCH64_OPTMEM),yes)
# Use the generic implementation of memset/memcpy instead.
ALL_OBJS := $(subst obj/src/string/aarch64/,obj/src/string/, $(ALL_OBJS))
endif
include build_variants.mk
# Qualcomm-specific code - end

Expand Down
14 changes: 14 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Qualcomm-specific options:
--quic-arm-armv6m-armv5 build for ARMV6M or ARMV5 architectures [disabled]
--quic-arm-nofp use optimized no floating point memset [disabled]
--quic-aarch64-nofp build for aarch64 with no floating point [disabled]
--quic-aarch64-mark-bti mark bti property for assembly source files [disabled]
--quic-aarch64-optmem use optimized memset/memcpy for aarch64 [disabled]
--quic-libc-standalone build standalone libc [disabled]
--quic-baremetal-uselock build for baremetal with locking/unlocking [disabled]

Expand Down Expand Up @@ -191,6 +193,8 @@ case "$arg" in
--quic-arm-armv6m-armv5|--quic-arm-armv6m-armv5=yes) quic_arm_armv6m_armv5=yes ;;
--quic-arm-nofp|--quic-arm-nofp=yes) quic_arm_nofp=yes ;;
--quic-aarch64-nofp|--quic-aarch64-nofp=yes) quic_aarch64_nofp=yes ;;
--quic-aarch64-mark-bti|--quic-aarch64-mark-bti=yes) quic_aarch64_mark_bti=yes ;;
--quic-aarch64-optmem|--quic-aarch64-optmem=yes) quic_aarch64_optmem=yes ;;
--quic-libc-standalone|--quic-libc-standalone=yes) quic_libc_standalone=yes ;;
--quic-baremetal-uselock|--quic-baremetal-uselock=yes) quic_baremetal_uselock=yes ;;
--enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;;
Expand Down Expand Up @@ -707,6 +711,14 @@ fi
if test "x$quic_aarch64_nofp" = xyes ; then
QUIC_AARCH64_NOFP=yes
fi
if test "x$quic_aarch64_mark_bti" = xyes ; then
CFLAGS_AUTO="$CFLAGS_AUTO -D__QUIC_BTI"
CFLAGS_AUTO="${CFLAGS_AUTO# }"
QUIC_AARCH64_MARK_BTI=yes
fi
if test "x$quic_aarch64_optmem" = xyes ; then
QUIC_AARCH64_OPTMEM=yes
fi
if test "x$quic_baremetal_uselock" = xyes ; then
CFLAGS_AUTO="$CFLAGS_AUTO -D__QUIC_BAREMETAL_USELOCK"
CFLAGS_AUTO="${CFLAGS_AUTO# }"
Expand Down Expand Up @@ -849,6 +861,8 @@ QUIC_ARM_BAREMETAL = $QUIC_ARM_BAREMETAL
QUIC_ARM_ARMV6M_ARMV5 = $QUIC_ARM_ARMV6M_ARMV5
QUIC_ARM_NOFP = $QUIC_ARM_NOFP
QUIC_AARCH64_NOFP = $QUIC_AARCH64_NOFP
QUIC_AARCH64_MARK_BTI = $QUIC_AARCH64_MARK_BTI
QUIC_AARCH64_OPTMEM = $QUIC_AARCH64_OPTMEM
QUIC_BAREMETAL_USELOCK = $QUIC_BAREMETAL_USELOCK
QUIC_LIBC_STANDALONE = $QUIC_LIBC_STANDALONE
QUIC_VARIANTS = $QUIC_VARIANTS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ RESOURCE_DIR=$(clang -print-resource-dir)
PATH_TO_BUILTIN=$RESOURCE_DIR/lib/baremetal
BUILTIN=clang_rt.builtins-pacret-bti-aarch64-nofp

./configure --disable-wrapper --quic-arm-baremetal --quic-aarch64-nofp --disable-visibility CROSS_COMPILE="llvm-" CC="clang --target=aarch64-none-elf -fuse-ld=eld" CFLAGS="-mabi=aapcs-soft -march=armv8.5-a -mbranch-protection=pac-ret+leaf+b-key+bti -Os -mstrict-align -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden -DVISIBILITY_HIDDEN -mgeneral-regs-only -mllvm -aarch64-enable-simd-scalar=false -fno-rounding-math" LDFLAGS="-Wl,-L${PATH_TO_BUILTIN}" LIBCC="-l${BUILTIN}" "$@"
./configure --disable-wrapper --quic-arm-baremetal --quic-aarch64-nofp --quic-aarch64-mark-bti --disable-visibility CROSS_COMPILE="llvm-" CC="clang --target=aarch64-none-elf -fuse-ld=eld" CFLAGS="-mabi=aapcs-soft -march=armv8.5-a -mbranch-protection=pac-ret+leaf+b-key+bti -Os -mstrict-align -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden -DVISIBILITY_HIDDEN -mgeneral-regs-only -mllvm -aarch64-enable-simd-scalar=false -fno-rounding-math" LDFLAGS="-Wl,-L${PATH_TO_BUILTIN}" LIBCC="-l${BUILTIN}" "$@"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed with @pzhengqc that if quic_aarch64_optmem is not specified, quic-aarch64-mark-bti is not needed. So we should clean this up. We can also enable the quic_aarch64_optmem for all linux configs.

Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ RESOURCE_DIR=$(clang -print-resource-dir)
PATH_TO_BUILTIN=$RESOURCE_DIR/lib/baremetal
BUILTIN=clang_rt.builtins-pacret-bti-aarch64-nofp

./configure --disable-wrapper --quic-arm-baremetal --quic-aarch64-nofp --disable-visibility CROSS_COMPILE="llvm-" CC="clang --target=aarch64-none-elf -fuse-ld=eld" CFLAGS="-mabi=aapcs-soft -march=armv8.3a -mbranch-protection=pac-ret+leaf+bti -Os -mstrict-align -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden -DVISIBILITY_HIDDEN -mgeneral-regs-only -mllvm -aarch64-enable-simd-scalar=false -fno-rounding-math" LDFLAGS="-Wl,-L${PATH_TO_BUILTIN}" LIBCC="-l${BUILTIN}" "$@"
./configure --disable-wrapper --quic-arm-baremetal --quic-aarch64-nofp --quic-aarch64-mark-bti --disable-visibility CROSS_COMPILE="llvm-" CC="clang --target=aarch64-none-elf -fuse-ld=eld" CFLAGS="-mabi=aapcs-soft -march=armv8.3a -mbranch-protection=pac-ret+leaf+bti -Os -mstrict-align -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden -DVISIBILITY_HIDDEN -mgeneral-regs-only -mllvm -aarch64-enable-simd-scalar=false -fno-rounding-math" LDFLAGS="-Wl,-L${PATH_TO_BUILTIN}" LIBCC="-l${BUILTIN}" "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ echo $INSTALL_DIR
mkdir -p $INSTALL_DIR/lib
# configure for libc standalone

./configure --disable-wrapper --quic-arm-baremetal --quic-libc-standalone --disable-visibility CROSS_COMPILE="llvm-" CC="clang --target=aarch64-none-elf -fuse-ld=eld" CFLAGS="-march=armv8.5-a -mbranch-protection=pac-ret+leaf+b-key+bti -Os -mstrict-align -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden -DVISIBILITY_HIDDEN -D__QUIC_ENABLE_FLT_FOR_PRINT -fno-rounding-math" "$@" --prefix=tmp_install_dir/libc
./configure --disable-wrapper --quic-arm-baremetal --quic-aarch64-mark-bti --quic-libc-standalone --disable-visibility CROSS_COMPILE="llvm-" CC="clang --target=aarch64-none-elf -fuse-ld=eld" CFLAGS="-march=armv8.5-a -mbranch-protection=pac-ret+leaf+b-key+bti -Os -mstrict-align -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden -DVISIBILITY_HIDDEN -D__QUIC_ENABLE_FLT_FOR_PRINT -fno-rounding-math" "$@" --prefix=tmp_install_dir/libc

make -j8 && make install
cp tmp_install_dir/libc/lib/libc.a $INSTALL_DIR/lib/libc-standalone.a
rm -rf tmp_install_dir
make distclean

./configure --disable-wrapper --quic-arm-baremetal --disable-visibility CROSS_COMPILE="llvm-" CC="clang --target=aarch64-none-elf -fuse-ld=eld" CFLAGS="-march=armv8.5-a -mbranch-protection=pac-ret+leaf+b-key+bti -Os -mstrict-align -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden -DVISIBILITY_HIDDEN -fno-rounding-math" "$@"
./configure --disable-wrapper --quic-arm-baremetal --quic-aarch64-mark-bti --disable-visibility CROSS_COMPILE="llvm-" CC="clang --target=aarch64-none-elf -fuse-ld=eld" CFLAGS="-march=armv8.5-a -mbranch-protection=pac-ret+leaf+b-key+bti -Os -mstrict-align -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden -DVISIBILITY_HIDDEN -fno-rounding-math" "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ echo $INSTALL_DIR
mkdir -p $INSTALL_DIR/lib
# configure for libc standalone

./configure --disable-wrapper --quic-arm-baremetal --quic-libc-standalone --disable-visibility CROSS_COMPILE="llvm-" CC="clang --target=aarch64-none-elf -fuse-ld=eld" CFLAGS="-march=armv8.3a -mbranch-protection=pac-ret+leaf+bti -Os -mstrict-align -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden -DVISIBILITY_HIDDEN -D__QUIC_ENABLE_FLT_FOR_PRINT -fno-rounding-math" "$@" --prefix=tmp_install_dir/libc
./configure --disable-wrapper --quic-arm-baremetal --quic-aarch64-mark-bti --quic-libc-standalone --disable-visibility CROSS_COMPILE="llvm-" CC="clang --target=aarch64-none-elf -fuse-ld=eld" CFLAGS="-march=armv8.3a -mbranch-protection=pac-ret+leaf+bti -Os -mstrict-align -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden -DVISIBILITY_HIDDEN -D__QUIC_ENABLE_FLT_FOR_PRINT -fno-rounding-math" "$@" --prefix=tmp_install_dir/libc

make -j8 && make install
cp tmp_install_dir/libc/lib/libc.a $INSTALL_DIR/lib/libc-standalone.a
rm -rf tmp_install_dir
make distclean

./configure --disable-wrapper --quic-arm-baremetal --disable-visibility CROSS_COMPILE="llvm-" CC="clang --target=aarch64-none-elf -fuse-ld=eld" CFLAGS="-march=armv8.3a -mbranch-protection=pac-ret+leaf+bti -Os -mstrict-align -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden -DVISIBILITY_HIDDEN -fno-rounding-math" "$@"
./configure --disable-wrapper --quic-arm-baremetal --quic-aarch64-mark-bti --disable-visibility CROSS_COMPILE="llvm-" CC="clang --target=aarch64-none-elf -fuse-ld=eld" CFLAGS="-march=armv8.3a -mbranch-protection=pac-ret+leaf+bti -Os -mstrict-align -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden -DVISIBILITY_HIDDEN -fno-rounding-math" "$@"
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# should be run from MUSL source top directory
# ./configure --disable-wrapper CROSS_COMPILE="llvm-" CC="clang --target=aarch64-linux-gnu -fuse-ld=eld" CFLAGS="-march=armv8.3a -mbranch-protection=pac-ret+leaf+bti -O3 -mstrict-align -fno-vectorize-loops -fPIC -fno-rounding-math" LIBCC="$(clang -print-resource-dir)/lib/generic/libclang_rt.builtins-pacret-bti-aarch64.a" "$@"
./configure --disable-wrapper CROSS_COMPILE="llvm-" CC="clang --target=aarch64-linux-gnu -fuse-ld=eld" CFLAGS="-march=armv8.3a -mbranch-protection=pac-ret+leaf+bti -O3 -mstrict-align -fPIC -fno-rounding-math" LIBCC="$(clang -print-resource-dir)/lib/linux/libclang_rt.builtins-pacret-bti-aarch64.a" "$@"
./configure --disable-wrapper --quic-aarch64-mark-bti CROSS_COMPILE="llvm-" CC="clang --target=aarch64-linux-gnu -fuse-ld=eld" CFLAGS="-march=armv8.3a -mbranch-protection=pac-ret+leaf+bti -O3 -mstrict-align -fPIC -fno-rounding-math" LIBCC="$(clang -print-resource-dir)/lib/linux/libclang_rt.builtins-pacret-bti-aarch64.a" "$@"
2 changes: 1 addition & 1 deletion qualcomm-software/config/linux/arm/aarch64_linux.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# should be run from MUSL source top directory
# ./configure --disable-wrapper CROSS_COMPILE="llvm-" CC="clang --target=aarch64-linux-gnu -fuse-ld=eld" CFLAGS="-O3 -mstrict-align -fno-vectorize-loops -fPIC -fno-rounding-math" LIBCC="$(clang -print-resource-dir)/lib/generic/libclang_rt.builtins-aarch64.a" "$@"
./configure --disable-wrapper CROSS_COMPILE="llvm-" CC="clang --target=aarch64-linux-gnu -fuse-ld=eld" CFLAGS="-O3 -mstrict-align -fPIC -fno-rounding-math" LIBCC="$(clang -print-resource-dir)/lib/linux/libclang_rt.builtins-aarch64.a" "$@"
./configure --disable-wrapper --quic-aarch64-optmem CROSS_COMPILE="llvm-" CC="clang --target=aarch64-linux-gnu -fuse-ld=eld" CFLAGS="-O3 -mstrict-align -fPIC -fno-rounding-math" LIBCC="$(clang -print-resource-dir)/lib/linux/libclang_rt.builtins-aarch64.a" "$@"
3 changes: 3 additions & 0 deletions src/string/aarch64/memcpy.S
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
.type memcpy,%function
memcpy:
.cfi_startproc
#ifdef __QUIC_BTI
bti c
#endif
add srcend, src, count
add dstend, dstin, count
cmp count, 128
Expand Down
3 changes: 3 additions & 0 deletions src/string/aarch64/memset.S
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
.type memset,%function
memset:
.cfi_startproc
#ifdef __QUIC_BTI
bti c
#endif
mov dst, dstin /* Preserve return value. */
ands A_lw, val, #255
b.eq .Lzero_mem /* Use DC ZVA instruction if the val = 0 */
Expand Down
Loading