Lines Matching +full:1 +full:- +full:9 +full:a +full:- +full:e
1 #!/bin/sh -e
3 # Update Linux kernel headers QEMU requires from a specified kernel tree.
11 # See the COPYING file in the top-level directory.
15 # - linux-headers/ for files that are required for compiling for a
21 # - include/standard-headers/ for files that are used for guest
26 # sanitize the headers to remove any use of Linux-specifics such as
29 tmpdir=$(mktemp -d)
32 linux="$1"
35 if [ -z "$linux" ] || ! [ -d "$linux" ]; then
37 usage: update-kernel-headers.sh LINUX_PATH [OUTPUT_PATH]
42 exit 1
45 if [ -z "$output" ]; then
50 f=$1
53 grep '#include' "$f" | grep -v -e 'linux/virtio' \
54 -e 'linux/types' \
55 -e 'linux/ioctl' \
56 -e 'stdint' \
57 -e 'linux/if_ether' \
58 -e 'input-event-codes' \
59 -e 'sys/' \
60 -e 'drm.h' \
61 -e 'limits' \
62 -e 'linux/const' \
63 -e 'linux/kernel' \
64 -e 'linux/sysinfo' \
65 -e 'asm/setup_data.h' \
66 -e 'asm/kvm_para.h' \
75 if test -z "$arch"; then
76 # Let users of include/standard-headers/linux/ headers pick the
77 # asm-* header that they care about
80 arch_cmd='s/<asm\/\([^>]*\)>/"standard-headers\/asm-'$arch'\/\1"/'
83 sed -e 's/__aligned_u64/__u64 __attribute__((aligned(8)))/g' \
84 -e 's/__u\([0-9][0-9]*\)/uint\1_t/g' \
85 -e 's/u\([0-9][0-9]*\)/uint\1_t/g' \
86 -e 's/__s\([0-9][0-9]*\)/int\1_t/g' \
87 -e 's/__le\([0-9][0-9]*\)/uint\1_t/g' \
88 -e 's/__be\([0-9][0-9]*\)/uint\1_t/g' \
89 -e 's/"\(input-event-codes\.h\)"/"standard-headers\/linux\/\1"/' \
90 -e 's/<linux\/\([^>]*\)>/"standard-headers\/linux\/\1"/' \
91 -e "$arch_cmd" \
92 -e 's/__bitwise//' \
93 -e 's/__attribute__((packed))/QEMU_PACKED/' \
94 -e 's/__inline__/inline/' \
95 -e 's/__BITS_PER_LONG/HOST_LONG_BITS/' \
96 -e '/\"drm.h\"/d' \
97 -e '/sys\/ioctl.h/d' \
98 -e '/linux\/ioctl.h/d' \
99 -e 's/SW_MAX/SW_MAX_/' \
100 -e 's/atomic_t/int/' \
101 -e 's/__kernel_long_t/long/' \
102 -e 's/__kernel_ulong_t/unsigned long/' \
103 -e 's/struct ethhdr/struct eth_header/' \
104 -e '/\#define _LINUX_ETHTOOL_H/a \\n\#include "net/eth.h"' \
108 # This will pick up non-directories too (eg "Kconfig") but we will
113 # Discard anything which isn't a KVM-supporting architecture
114 if ! [ -e "$linux/arch/$arch/include/asm/kvm.h" ] &&
115 ! [ -e "$linux/arch/$arch/include/uapi/asm/kvm.h" ] ; then
125 rm -rf "$hdrdir"
126 make -C "$linux" O="$blddir" INSTALL_HDR_PATH="$hdrdir" $arch_var=$arch headers_install
128 rm -rf "$output/linux-headers/asm-$arch"
129 mkdir -p "$output/linux-headers/asm-$arch"
131 if test -f "$hdrdir/include/asm/$header"; then
132 cp "$hdrdir/include/asm/$header" "$output/linux-headers/asm-$arch"
133 elif test -f "$hdrdir/include/asm-generic/$header"; then
135 cat <<EOF >$output/linux-headers/asm-$arch/$header
136 #include <asm-generic/$header>
142 cp "$hdrdir/include/asm/sgidefs.h" "$output/linux-headers/asm-mips/"
143 cp "$hdrdir/include/asm/unistd_o32.h" "$output/linux-headers/asm-mips/"
144 cp "$hdrdir/include/asm/unistd_n32.h" "$output/linux-headers/asm-mips/"
145 cp "$hdrdir/include/asm/unistd_n64.h" "$output/linux-headers/asm-mips/"
148 cp "$hdrdir/include/asm/unistd_32.h" "$output/linux-headers/asm-powerpc/"
149 cp "$hdrdir/include/asm/unistd_64.h" "$output/linux-headers/asm-powerpc/"
152 rm -rf "$output/include/standard-headers/asm-$arch"
153 mkdir -p "$output/include/standard-headers/asm-$arch"
155 cp_portable "$hdrdir/include/asm/virtio-ccw.h" "$output/include/standard-headers/asm-s390/"
156 cp "$hdrdir/include/asm/unistd_32.h" "$output/linux-headers/asm-s390/"
157 cp "$hdrdir/include/asm/unistd_64.h" "$output/linux-headers/asm-s390/"
160 cp "$hdrdir/include/asm/unistd-eabi.h" "$output/linux-headers/asm-arm/"
161 cp "$hdrdir/include/asm/unistd-oabi.h" "$output/linux-headers/asm-arm/"
162 cp "$hdrdir/include/asm/unistd-common.h" "$output/linux-headers/asm-arm/"
165 cp "$hdrdir/include/asm/sve_context.h" "$output/linux-headers/asm-arm64/"
166 cp "$hdrdir/include/asm/unistd_64.h" "$output/linux-headers/asm-arm64/"
169 cp "$hdrdir/include/asm/unistd_32.h" "$output/linux-headers/asm-x86/"
170 cp "$hdrdir/include/asm/unistd_x32.h" "$output/linux-headers/asm-x86/"
171 cp "$hdrdir/include/asm/unistd_64.h" "$output/linux-headers/asm-x86/"
173 cp_portable "$hdrdir/include/asm/kvm_para.h" "$output/include/standard-headers/asm-$arch"
174 cat <<EOF >$output/linux-headers/asm-$arch/kvm_para.h
175 #include "standard-headers/asm-$arch/kvm_para.h"
180 sed -e '/__ASSEMBLY__/,/__ASSEMBLY__/d' \
183 "$output/include/standard-headers/asm-$arch"
185 "$output/include/standard-headers/asm-x86"
188 cp "$hdrdir/include/asm/ptrace.h" "$output/linux-headers/asm-riscv/"
189 cp "$hdrdir/include/asm/unistd_32.h" "$output/linux-headers/asm-riscv/"
190 cp "$hdrdir/include/asm/unistd_64.h" "$output/linux-headers/asm-riscv/"
193 cp "$hdrdir/include/asm/kvm_para.h" "$output/linux-headers/asm-loongarch/"
194 cp "$hdrdir/include/asm/unistd_64.h" "$output/linux-headers/asm-loongarch/"
199 rm -rf "$output/linux-headers/linux"
200 mkdir -p "$output/linux-headers/linux"
202 psci.h psp-sev.h userfaultfd.h memfd.h mman.h nvme_ioctl.h \
204 cp "$hdrdir/include/linux/$header" "$output/linux-headers/linux"
207 rm -rf "$output/linux-headers/asm-generic"
208 mkdir -p "$output/linux-headers/asm-generic"
209 for header in unistd.h bitsperlong.h mman-common.h mman.h hugetlb_encode.h; do
210 cp "$hdrdir/include/asm-generic/$header" "$output/linux-headers/asm-generic"
213 if [ -L "$linux/source" ]; then
214 cp "$linux/source/COPYING" "$output/linux-headers"
216 cp "$linux/COPYING" "$output/linux-headers"
222 # We don't copy the Documentation/process/license-rules.rst which
224 if [ -d "$linux/LICENSES" ]; then
225 mkdir -p "$output/linux-headers/LICENSES/preferred" \
226 "$output/linux-headers/LICENSES/exceptions"
227 for l in preferred/GPL-2.0 preferred/BSD-2-Clause preferred/BSD-3-Clause \
228 exceptions/Linux-syscall-note; do
229 cp "$linux/LICENSES/$l" "$output/linux-headers/LICENSES/$l"
233 cat <<EOF >$output/linux-headers/linux/kvm_para.h
234 #include "standard-headers/linux/kvm_para.h"
237 cat <<EOF >$output/linux-headers/linux/virtio_config.h
238 #include "standard-headers/linux/virtio_config.h"
240 cat <<EOF >$output/linux-headers/linux/virtio_ring.h
241 #include "standard-headers/linux/virtio_ring.h"
243 cat <<EOF >$output/linux-headers/linux/vhost_types.h
244 #include "standard-headers/linux/vhost_types.h"
247 rm -rf "$output/include/standard-headers/linux"
248 mkdir -p "$output/include/standard-headers/linux"
253 "$hdrdir/include/linux/input-event-codes.h" \
262 cp_portable "$i" "$output/include/standard-headers/linux"
264 mkdir -p "$output/include/standard-headers/misc"
266 "$output/include/standard-headers/misc"
267 mkdir -p "$output/include/standard-headers/drm"
269 "$output/include/standard-headers/drm"
271 cat <<EOF >$output/include/standard-headers/linux/types.h
276 cat <<EOF >$output/include/standard-headers/linux/if_ether.h
280 rm -rf "$tmpdir"