VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   33 Branches   57 Tags
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100   1) #!/bin/sh
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100   2) # SPDX-License-Identifier: GPL-2.0
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100   3) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100   4) ATOMICDIR=$(dirname $0)
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100   5) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100   6) . ${ATOMICDIR}/atomic-tbl.sh
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100   7) 
3570a1bcf45e9 (Marco Elver    2020-07-24 09:00:08 +0200   8) #gen_param_check(meta, arg)
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100   9) gen_param_check()
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  10) {
3570a1bcf45e9 (Marco Elver    2020-07-24 09:00:08 +0200  11) 	local meta="$1"; shift
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  12) 	local arg="$1"; shift
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  13) 	local type="${arg%%:*}"
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  14) 	local name="$(gen_param_name "${arg}")"
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  15) 	local rw="write"
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  16) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  17) 	case "${type#c}" in
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  18) 	i) return;;
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  19) 	esac
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  20) 
3570a1bcf45e9 (Marco Elver    2020-07-24 09:00:08 +0200  21) 	if [ ${type#c} != ${type} ]; then
3570a1bcf45e9 (Marco Elver    2020-07-24 09:00:08 +0200  22) 		# We don't write to constant parameters.
3570a1bcf45e9 (Marco Elver    2020-07-24 09:00:08 +0200  23) 		rw="read"
3570a1bcf45e9 (Marco Elver    2020-07-24 09:00:08 +0200  24) 	elif [ "${meta}" != "s" ]; then
3570a1bcf45e9 (Marco Elver    2020-07-24 09:00:08 +0200  25) 		# An atomic RMW: if this parameter is not a constant, and this atomic is
3570a1bcf45e9 (Marco Elver    2020-07-24 09:00:08 +0200  26) 		# not just a 's'tore, this parameter is both read from and written to.
3570a1bcf45e9 (Marco Elver    2020-07-24 09:00:08 +0200  27) 		rw="read_write"
3570a1bcf45e9 (Marco Elver    2020-07-24 09:00:08 +0200  28) 	fi
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  29) 
ed8af2e4d2a71 (Marco Elver    2020-01-21 17:05:09 +0100  30) 	printf "\tinstrument_atomic_${rw}(${name}, sizeof(*${name}));\n"
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  31) }
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  32) 
3570a1bcf45e9 (Marco Elver    2020-07-24 09:00:08 +0200  33) #gen_params_checks(meta, arg...)
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  34) gen_params_checks()
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  35) {
3570a1bcf45e9 (Marco Elver    2020-07-24 09:00:08 +0200  36) 	local meta="$1"; shift
3570a1bcf45e9 (Marco Elver    2020-07-24 09:00:08 +0200  37) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  38) 	while [ "$#" -gt 0 ]; do
3570a1bcf45e9 (Marco Elver    2020-07-24 09:00:08 +0200  39) 		gen_param_check "$meta" "$1"
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  40) 		shift;
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  41) 	done
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  42) }
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  43) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  44) #gen_proto_order_variant(meta, pfx, name, sfx, order, atomic, int, arg...)
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  45) gen_proto_order_variant()
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  46) {
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  47) 	local meta="$1"; shift
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  48) 	local pfx="$1"; shift
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  49) 	local name="$1"; shift
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  50) 	local sfx="$1"; shift
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  51) 	local order="$1"; shift
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  52) 	local atomic="$1"; shift
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  53) 	local int="$1"; shift
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  54) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  55) 	local atomicname="${atomic}_${pfx}${name}${sfx}${order}"
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  56) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  57) 	local ret="$(gen_ret_type "${meta}" "${int}")"
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  58) 	local params="$(gen_params "${int}" "${atomic}" "$@")"
3570a1bcf45e9 (Marco Elver    2020-07-24 09:00:08 +0200  59) 	local checks="$(gen_params_checks "${meta}" "$@")"
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  60) 	local args="$(gen_args "$@")"
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  61) 	local retstmt="$(gen_ret_stmt "${meta}")"
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  62) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  63) cat <<EOF
c020395b6634b (Marco Elver    2019-11-26 15:04:04 +0100  64) static __always_inline ${ret}
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  65) ${atomicname}(${params})
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  66) {
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  67) ${checks}
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  68) 	${retstmt}arch_${atomicname}(${args});
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  69) }
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  70) EOF
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  71) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  72) 	printf "\n"
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  73) }
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  74) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  75) gen_xchg()
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  76) {
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  77) 	local xchg="$1"; shift
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  78) 	local mult="$1"; shift
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  79) 
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  80) 	if [ "${xchg%${xchg#try_cmpxchg}}" = "try_cmpxchg" ] ; then
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  81) 
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  82) cat <<EOF
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  83) #define ${xchg}(ptr, oldp, ...) \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  84) ({ \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  85) 	typeof(ptr) __ai_ptr = (ptr); \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  86) 	typeof(oldp) __ai_oldp = (oldp); \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  87) 	instrument_atomic_write(__ai_ptr, ${mult}sizeof(*__ai_ptr)); \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  88) 	instrument_atomic_write(__ai_oldp, ${mult}sizeof(*__ai_oldp)); \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  89) 	arch_${xchg}(__ai_ptr, __ai_oldp, __VA_ARGS__); \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  90) })
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  91) EOF
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  92) 
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  93) 	else
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  94) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100  95) cat <<EOF
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  96) #define ${xchg}(ptr, ...) \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  97) ({ \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  98) 	typeof(ptr) __ai_ptr = (ptr); \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900  99) 	instrument_atomic_write(__ai_ptr, ${mult}sizeof(*__ai_ptr)); \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 100) 	arch_${xchg}(__ai_ptr, __VA_ARGS__); \\
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 101) })
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 102) EOF
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 103) 
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 104) 	fi
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 105) }
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 106) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 107) cat << EOF
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 108) // SPDX-License-Identifier: GPL-2.0
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 109) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 110) // Generated by $0
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 111) // DO NOT MODIFY THIS FILE DIRECTLY
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 112) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 113) /*
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 114)  * This file provides wrappers with KASAN instrumentation for atomic operations.
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 115)  * To use this functionality an arch's atomic.h file needs to define all
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 116)  * atomic operations with arch_ prefix (e.g. arch_atomic_read()) and include
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 117)  * this file at the end. This file provides atomic_read() that forwards to
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 118)  * arch_atomic_read() for actual atomic operation.
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 119)  * Note: if an arch atomic operation is implemented by means of other atomic
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 120)  * operations (e.g. atomic_read()/atomic_cmpxchg() loop), then it needs to use
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 121)  * arch_ variants (i.e. arch_atomic_read()/arch_atomic_cmpxchg()) to avoid
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 122)  * double instrumentation.
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 123)  */
e3d18cee258b8 (Mark Rutland   2021-07-13 11:52:51 +0100 124) #ifndef _LINUX_ATOMIC_INSTRUMENTED_H
e3d18cee258b8 (Mark Rutland   2021-07-13 11:52:51 +0100 125) #define _LINUX_ATOMIC_INSTRUMENTED_H
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 126) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 127) #include <linux/build_bug.h>
c020395b6634b (Marco Elver    2019-11-26 15:04:04 +0100 128) #include <linux/compiler.h>
ed8af2e4d2a71 (Marco Elver    2020-01-21 17:05:09 +0100 129) #include <linux/instrumented.h>
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 130) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 131) EOF
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 132) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 133) grep '^[a-z]' "$1" | while read name meta args; do
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 134) 	gen_proto "${meta}" "${name}" "atomic" "int" ${args}
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 135) done
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 136) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 137) grep '^[a-z]' "$1" | while read name meta args; do
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 138) 	gen_proto "${meta}" "${name}" "atomic64" "s64" ${args}
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 139) done
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 140) 
67d1b0de258ad (Mark Rutland   2021-07-13 11:52:52 +0100 141) grep '^[a-z]' "$1" | while read name meta args; do
67d1b0de258ad (Mark Rutland   2021-07-13 11:52:52 +0100 142) 	gen_proto "${meta}" "${name}" "atomic_long" "long" ${args}
67d1b0de258ad (Mark Rutland   2021-07-13 11:52:52 +0100 143) done
67d1b0de258ad (Mark Rutland   2021-07-13 11:52:52 +0100 144) 
67d1b0de258ad (Mark Rutland   2021-07-13 11:52:52 +0100 145) 
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 146) for xchg in "xchg" "cmpxchg" "cmpxchg64" "try_cmpxchg"; do
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 147) 	for order in "" "_acquire" "_release" "_relaxed"; do
bccf1ec369ac1 (Mark Rutland   2021-05-25 15:02:32 +0100 148) 		gen_xchg "${xchg}${order}" ""
bccf1ec369ac1 (Mark Rutland   2021-05-25 15:02:32 +0100 149) 		printf "\n"
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 150) 	done
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 151) done
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 152) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 153) for xchg in "cmpxchg_local" "cmpxchg64_local" "sync_cmpxchg"; do
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 154) 	gen_xchg "${xchg}" ""
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 155) 	printf "\n"
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 156) done
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 157) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 158) gen_xchg "cmpxchg_double" "2 * "
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 159) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 160) printf "\n\n"
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 161) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 162) gen_xchg "cmpxchg_double_local" "2 * "
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 163) 
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 164) cat <<EOF
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 165) 
e3d18cee258b8 (Mark Rutland   2021-07-13 11:52:51 +0100 166) #endif /* _LINUX_ATOMIC_INSTRUMENTED_H */
ace9bad4df268 (Mark Rutland   2018-09-04 11:48:25 +0100 167) EOF