Skip to content

Commit dd8018f

Browse files
committed
zdtm: gcs: add opt-in GCS test support for AArch64
Introduce an opt-in mode for building and running ZDTM static tests with Guarded Control Stack (GCS) enabled on AArch64. Changes: - Support `GCS_ENABLE=1` builds, adding `-mbranch-protection=standard` and `-z experimental-gcs=check` to CFLAGS/LDFLAGS. - Export required GLIBC_TUNABLES at runtime via `TEST_ENV`. - %.pid rules to prefix test binaries with `$(TEST_ENV)` so the tunables are set when running tests. - Makefile rules for selectively enabling GCS in tests Usage: # Build and run with GCS enabled make -C zdtm/static GCS_ENABLE=1 posix_timers GCS_ENABLE=1 ./zdtm.py run --keep-img=always \ -t zdtm/static/posix_timers By default (`GCS_ENABLE` unset or 0), test builds and runs are unchanged. NOTE: This assumes that the test victim was compiled also using GCS_ENABLE=1 so that the proper GCS AArch64 ELF headers are present Signed-off-by: Igor Svilenkov Bozic <svilenkov@gmail.com> Reviewed-by: Alexander Mikhalitsyn aleksandr.mikhalitsyn@canonical.com
1 parent 3f0aee4 commit dd8018f

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

test/zdtm/Makefile.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ define pkg-cflags
7474
$(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" $(PKG_CONFIG) --cflags $(1))
7575
endef
7676

77+
ifeq ($(GCS_ENABLE),1)
78+
CFLAGS += -mbranch-protection=standard
79+
LDFLAGS += -z experimental-gcs=check
80+
TEST_ENV = GLIBC_TUNABLES=glibc.cpu.aarch64_gcs=1:glibc.cpu.aarch64_gcs_policy=2
81+
else
82+
TEST_ENV =
83+
endif
84+
7785
%.d: %.c
7886
$(E) " DEP " $@
7987
$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -MM -MP $< -o $@

test/zdtm/static/Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -514,30 +514,30 @@ install: all
514514
.PHONY: all install
515515

516516
$(TST_NOFILE:%=%.pid): %.pid: %
517-
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out
517+
$(TEST_ENV) $(<D)/$(<F) --pidfile=$@ --outfile=$<.out
518518

519519
$(TST_FILE:%=%.pid): %.pid: %
520-
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --filename=$<.test
520+
$(TEST_ENV) $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --filename=$<.test
521521

522522
$(TST_DIR:%=%.pid): %.pid: %
523-
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --dirname=$<.test
523+
$(TEST_ENV) (<D)/$(<F) --pidfile=$@ --outfile=$<.out --dirname=$<.test
524524

525525
$(TST_DIR_FILE:%=%.pid): %.pid: %
526-
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --dirname=$<.dir.test --filename=$<.test
526+
$(TEST_ENV) $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --dirname=$<.dir.test --filename=$<.test
527527

528528
cmdlinenv00.pid: cmdlinenv00
529-
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --arg1=arg1 --arg2=arg2 --arg3=arg3
529+
$(TEST_ENV) $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --arg1=arg1 --arg2=arg2 --arg3=arg3
530530

531531
shm-unaligned.pid: shm-unaligned
532-
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --shmem_size=5000
532+
$(TEST_ENV) $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --shmem_size=5000
533533

534534
shm-hugetlb.pid: shm-hugetlb
535-
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --shmem_size=4194304
535+
$(TEST_ENV) $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --shmem_size=4194304
536536

537537
env00.pid: env00
538-
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --envname=ENV_00_TEST
538+
$(TEST_ENV) $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --envname=ENV_00_TEST
539539
umask00.pid: umask00
540-
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --mask=0345
540+
$(TEST_ENV) $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --mask=0345
541541

542542
fifo-rowo-pair.pid: fifo-rowo-pair
543543
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --name_master=$<.master.test --name_slave=$<.slave.test

0 commit comments

Comments
 (0)