tools/testing/selftests/powerpc/security/mitigation-patching.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/security/mitigation-patching.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/security/mitigation-patching.sh- Extension
.sh- Size
- 1457 bytes
- Lines
- 79
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/usr/bin/env bash
set -euo pipefail
TIMEOUT=10
function do_one
{
local mitigation="$1"
local orig
local start
local now
orig=$(cat "$mitigation")
start=$(date +%s)
now=$start
while [[ $((now-start)) -lt "$TIMEOUT" ]]
do
echo 0 > "$mitigation"
echo 1 > "$mitigation"
now=$(date +%s)
done
echo "$orig" > "$mitigation"
}
rc=0
cd /sys/kernel/debug/powerpc || rc=1
if [[ "$rc" -ne 0 ]]; then
echo "Error: couldn't cd to /sys/kernel/debug/powerpc" >&2
exit 1
fi
tainted=$(cat /proc/sys/kernel/tainted)
if [[ "$tainted" -ne 0 ]]; then
echo "Warning: kernel already tainted! ($tainted)" >&2
fi
mitigations="barrier_nospec stf_barrier count_cache_flush rfi_flush entry_flush uaccess_flush"
for m in $mitigations
do
if [[ -f /sys/kernel/debug/powerpc/$m ]]
then
do_one "$m" &
fi
done
echo "Spawned threads enabling/disabling mitigations ..."
if stress-ng > /dev/null 2>&1; then
stress="stress-ng"
elif stress > /dev/null 2>&1; then
stress="stress"
else
stress=""
fi
if [[ -n "$stress" ]]; then
"$stress" -m "$(nproc)" -t "$TIMEOUT" &
echo "Spawned VM stressors ..."
fi
echo "Waiting for timeout ..."
wait
orig_tainted=$tainted
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.