1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2022, Intel Corp. All rights reserved.
detect()
{
dev="$($NDCTL list -b "$NFIT_TEST_BUS0" -D | jq -r .[0].dev)"
[ -n "$dev" ] || err "$LINENO"
id="$($NDCTL list -b "$NFIT_TEST_BUS0" -D | jq -r .[0].id)"
[ -n "$id" ] || err "$LINENO"
}
lock_dimm()
{
$NDCTL disable-dimm "$dev"
# convert nmemX --> test_dimmY
# For now this is the only user of such a conversion so we can leave it
# inline. Once a subsequent user arrives we can refactor this to a
# helper in test/common:
# get_test_dimm_path "nfit_test.0" "nmem3"
handle="$($NDCTL list -b "$NFIT_TEST_BUS0" -d "$dev" -i | jq -r .[].dimms[0].handle)"
test_dimm_path=""
for test_dimm in /sys/devices/platform/"$NFIT_TEST_BUS0"/nfit_test_dimm/test_dimm*; do
td_handle_file="$test_dimm/handle"
test -e "$td_handle_file" || continue
td_handle="$(cat "$td_handle_file")"
if [[ "$td_handle" -eq "$handle" ]]; then
test_dimm_path="$test_dimm"
break
fi
done
test -d "$test_dimm_path"
# now lock the dimm
echo 1 > "${test_dimm_path}/lock_dimm"
sstate="$(get_security_state)"
if [ "$sstate" != "locked" ]; then
echo "Incorrect security state: $sstate expected: locked"
err "$LINENO"
fi
}
|