Skip to content

Commit 4fe3599

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 2a0389b commit 4fe3599

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
@@ -79,6 +79,14 @@ define pkg-cflags
7979
$(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" $(PKG_CONFIG) --cflags $(1))
8080
endef
8181

82+
ifeq ($(GCS_ENABLE),1)
83+
CFLAGS += -mbranch-protection=standard
84+
LDFLAGS += -z experimental-gcs=check
85+
TEST_ENV = GLIBC_TUNABLES=glibc.cpu.aarch64_gcs=1:glibc.cpu.aarch64_gcs_policy=2
86+
else
87+
TEST_ENV =
88+
endif
89+
8290
%.d: %.c
8391
$(E) " DEP " $@
8492
$(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
@@ -520,30 +520,30 @@ install: all
520520
.PHONY: all install
521521

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

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

528528
$(TST_DIR:%=%.pid): %.pid: %
529-
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --dirname=$<.test
529+
$(TEST_ENV) (<D)/$(<F) --pidfile=$@ --outfile=$<.out --dirname=$<.test
530530

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

534534
cmdlinenv00.pid: cmdlinenv00
535-
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --arg1=arg1 --arg2=arg2 --arg3=arg3
535+
$(TEST_ENV) $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --arg1=arg1 --arg2=arg2 --arg3=arg3
536536

537537
shm-unaligned.pid: shm-unaligned
538-
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --shmem_size=5000
538+
$(TEST_ENV) $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --shmem_size=5000
539539

540540
shm-hugetlb.pid: shm-hugetlb
541-
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --shmem_size=4194304
541+
$(TEST_ENV) $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --shmem_size=4194304
542542

543543
env00.pid: env00
544-
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --envname=ENV_00_TEST
544+
$(TEST_ENV) $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --envname=ENV_00_TEST
545545
umask00.pid: umask00
546-
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --mask=0345
546+
$(TEST_ENV) $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --mask=0345
547547

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

0 commit comments

Comments
 (0)