mirror of
https://github.com/lemonade-sdk/mac_linuxgpu.git
synced 2026-11-23 08:59:28 -10:00
Prototypes for letting HRX write kernel arguments into CPU-visible VRAM and publish them with the HDP flush register on this platform, where a CPU store to a GPU that left the Thunderbolt link panics the Mac. doorbell_gate.h: mlg_bar_write_begin and mlg_bar_write_end bracket a submission's several stores into the BARs (a memcpy into the VRAM kernarg ring, the HDP store and its read back, the doorbell) under the client's existing gate, with the same Dekker protocol as mlg_doorbell_ring. Brackets nest, so a doorbell rung inside one is a nested bracket. End completes the stores (DSB ST) before counting out, since the driver may power the device down the moment busy reads zero. mlg_doorbell_ring is unchanged. hsa/src/bar_mapping_retire.h: DriverKit cannot revoke a mapping it gave a client, so the client maps zero-filled anonymous memory over its BAR range in one step (mmap MAP_FIXED) once it learns the device is going: every later store from any thread lands in host memory and every load reads zero, as Linux's dummy page after drm_dev_unplug. Tests (make test-bar-write-safety): submitters copying kernargs, storing and reading back the HDP register and ringing the doorbell race power and reset holds, client closes and session closes under ThreadSanitizer and AddressSanitizer, and no store lands after a close returns; writers with no gate store into a shared mapping while it is retired, and none reaches the underlying pages afterwards, none faults, and the range reads zero.
21 lines
1.1 KiB
Bash
Executable File
21 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Client stores into the GPU's BARs kept off a device that is going: a
|
|
# submission's stores (kernargs into VRAM, the HDP flush, the doorbell) as
|
|
# one gate bracket, under ThreadSanitizer and AddressSanitizer
|
|
# (linuxu/tests/test_bar_write_gate.c), and a client's revocation of its
|
|
# BAR mapping under writers that use no gate
|
|
# (linuxu/tests/test_bar_mapping_retire.c).
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
test_dir=$(mktemp -d)
|
|
trap 'rm -rf "$test_dir"' EXIT
|
|
for sanitizer in thread address,undefined; do
|
|
clang -std=gnu11 -Wall -Wextra -Werror -g -O1 -fsanitize=$sanitizer -fno-sanitize-recover=all \
|
|
-Idext/sources linuxu/tests/test_bar_write_gate.c -lpthread -o "$test_dir/test_bar_write_gate"
|
|
echo "($sanitizer)"
|
|
ASAN_OPTIONS=detect_leaks=0 "$test_dir/test_bar_write_gate"
|
|
done
|
|
clang -std=gnu11 -Wall -Wextra -Werror -g -O1 -fsanitize=address,undefined -fno-sanitize-recover=all \
|
|
-Ihsa/src linuxu/tests/test_bar_mapping_retire.c -lpthread -o "$test_dir/test_bar_mapping_retire"
|
|
ASAN_OPTIONS=detect_leaks=0 "$test_dir/test_bar_mapping_retire"
|