Files
xen/automation/eclair_analysis/prepare.sh
T
Nicola Vetrini 33888e7aaa automation/eclair_analysis: deviate linker symbols for Rule 18.2
MISRA C Rule 18.2 states: "Subtraction between pointers shall
only be applied to pointers that address elements of the same array".

Subtractions between pointer where at least one symbol is a
symbol defined by the linker are safe and thus deviated, because
the compiler cannot exploit the undefined behaviour that would
arise from violating the rules in this case.

To create an ECLAIR configuration that contains the list of
linker-defined symbols, the script "linker-symbols.sh" is used
after a build of xen (without static analysis) is performed.
The generated file "linker_symbols.ecl" is then used as part of the
static analysis configuration.

Additional changes to the ECLAIR integration are:
- perform a build of xen without static analysis during prepare.sh
- run the scripts to generated ECL configuration during the prepare.sh,
  rather than analysis.sh
- export ECLAIR_PROJECT_ROOT earlier, to allow such generation

Additionally, the macro page_to_mfn performs a subtraction that is safe,
so its uses are deviated.

No functional changes.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
2024-09-11 17:11:09 -07:00

53 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# Stop immediately if any executed command has exit status different from 0.
set -e
script_name="$(basename "$0")"
script_dir="$(
cd "$(dirname "$0")"
echo "${PWD}"
)"
fatal() {
echo "${script_name}: $*" >&2
exit 1
}
usage() {
fatal "Usage: ${script_name}"
}
if [ $# -ne 1 ]; then
usage
exit 1
fi
export XEN_TARGET_ARCH
if [ "$1" = "X86_64" ]; then
CONFIG_FILE="${script_dir}/xen_x86_config"
XEN_TARGET_ARCH=x86_64
elif [ "$1" = "ARM64" ]; then
CONFIG_FILE="${script_dir}/xen_arm_config"
XEN_TARGET_ARCH=arm64
else
fatal "Unknown configuration: $1"
fi
(
./configure
cp "${CONFIG_FILE}" xen/.config
make clean
find . -type f -name "*.safparse" -print -delete
"${script_dir}/build.sh" "$1"
# Generate additional configuration files
"${script_dir}/ECLAIR/generate_ecl.sh"
make clean
cd xen
make -f "${script_dir}/Makefile.prepare" prepare
# Translate the /* SAF-n-safe */ comments into ECLAIR CBTs
scripts/xen-analysis.py --run-eclair --no-build --no-clean
# Translate function-properties.json into ECLAIR properties
python3 "${script_dir}/propertyparser.py"
)