@@ -41,118 +41,127 @@ EOF
4141 bindgen --no-doc-comments --disable-header-comment --constified-enum ' *' --with-derive-default --with-derive-partialeq $@
4242}
4343
44- KERNEL_HEADERS_HOME=" /usr"
45-
46- info " BINDGEN sockios.h"
47- fc-bindgen " $KERNEL_HEADERS_HOME /include/linux/sockios.h" | replace_linux_int_types > src/vmm/src/devices/virtio/net/gen/sockios.rs
48-
49- info " BINDGEN if.h"
50- fc-bindgen " $KERNEL_HEADERS_HOME /include/linux/if.h" \
51- --allowlist-var=' IF.*' \
52- --allowlist-type=' if.*' \
53- --allowlist-type=" net_device.*" \
54- -- -D __UAPI_DEF_IF_IFNAMSIZ -D __UAPI_DEF_IF_NET_DEVICE_FLAGS -D __UAPI_DEF_IF_IFREQ -D __UAPI_DEF_IF_IFMAP > src/vmm/src/devices/virtio/net/gen/iff.rs
55-
56- info " BINDGEN if_tun.h"
57- fc-bindgen \
58- --allowlist-type=' sock_fprog' \
59- --allowlist-var=' TUN_.*' \
60- --allowlist-var=' IFF_NO_PI' \
61- --allowlist-var=' IFF_MULTI_QUEUE' \
62- --allowlist-var=' IFF_TAP' \
63- --allowlist-var=' IFF_VNET_HDR' \
64- --allowlist-var=' ETH_.*' \
65- --allowlist-type=' ifreq' \
66- " $KERNEL_HEADERS_HOME /include/linux/if_tun.h" > src/vmm/src/devices/virtio/net/gen/if_tun.rs
67-
68- info " BINDGEN virtio_ring.h"
69- fc-bindgen \
70- --allowlist-var " VIRTIO_RING_F_EVENT_IDX" \
71- " $KERNEL_HEADERS_HOME /include/linux/virtio_ring.h" > src/vmm/src/devices/virtio/gen/virtio_ring.rs
72-
73- info " BINDGEN virtio_blk.h"
74- fc-bindgen \
75- --allowlist-var " VIRTIO_BLK_.*" \
76- --allowlist-var " VIRTIO_F_.*" \
77- " $KERNEL_HEADERS_HOME /include/linux/virtio_blk.h" > src/vmm/src/devices/virtio/gen/virtio_blk.rs
78-
79- info " BINDGEN virtio_net.h"
80- fc-bindgen \
81- --allowlist-var " VIRTIO_NET_F_.*" \
82- --allowlist-var " VIRTIO_F_.*" \
83- --allowlist-type " virtio_net_hdr_v1" \
84- " $KERNEL_HEADERS_HOME /include/linux/virtio_net.h" > src/vmm/src/devices/virtio/gen/virtio_net.rs
85-
86- info " BINDGEN virtio_rng.h"
87- fc-bindgen \
88- --allowlist-var " VIRTIO_RNG_.*" \
89- --allowlist-var " VIRTIO_F_.*" \
90- " $KERNEL_HEADERS_HOME /include/linux/virtio_rng.h" > src/vmm/src/devices/virtio/gen/virtio_rng.rs
91-
92- info " BINDGEN prctl.h"
93- fc-bindgen \
94- --allowlist-var " PR_.*" \
95- " $KERNEL_HEADERS_HOME /include/linux/prctl.h" > src/firecracker/src/gen/prctl.rs
96- sed -i ' /PR_SET_SPECULATION_CTRL/s/u32/i32/g' src/firecracker/src/gen/prctl.rs
97-
98- # https://www.kernel.org/doc/Documentation/kbuild/headers_install.txt
99- # The Linux repo is huge. Just copy what we need.
100- # git clone --branch v5.10 --depth 1 https://github.com/torvalds/linux.git linux
101- git clone --branch linux-5.10.y --depth 1 https://github.com/amazonlinux/linux amazonlinux-v5.10.y
102-
103- info " BINDGEN mpspec_def.h"
104- fc-bindgen amazonlinux-v5.10.y/arch/x86/include/asm/mpspec_def.h \
105- > src/vmm/src/arch/x86_64/gen/mpspec.rs
106- # https://github.com/rust-lang/rust-bindgen/issues/1274
107-
108- info " BINDGEN msr-index.h"
109- cp -r amazonlinux-v5.10.y/include/asm-generic amazonlinux-v5.10.y/include/asm
110- sed -i -E ' s/__no_(sanitize|kasan)_or_inline//g' amazonlinux-v5.10.y/include/asm/rwonce.h
111- fc-bindgen amazonlinux-v5.10.y/arch/x86/include/asm/msr-index.h \
112- --allowlist-var " ^MSR_.*$" \
113- -- \
114- -Iamazonlinux-v5.10.y/include/ \
115- -Iamazonlinux-v5.10.y/arch/x86/include/ \
116- -Wno-macro-redefined \
117- > src/vmm/src/arch/x86_64/gen/msr_index.rs
118- perl -i -pe ' s/= (\d+);/sprintf("= 0x%x;",$1)/eg' src/vmm/src/arch/x86_64/gen/msr_index.rs
119-
120- info " BINDGEN perf_event.h"
121- grep " MSR_ARCH_PERFMON_" amazonlinux-v5.10.y/arch/x86/include/asm/perf_event.h \
122- > amazonlinux-v5.10.y/arch/x86/include/asm/perf_event_msr.h
123- fc-bindgen amazonlinux-v5.10.y/arch/x86/include/asm/perf_event_msr.h \
124- --allowlist-var " ^MSR_ARCH_PERFMON_.*$" \
125- -- \
126- > src/vmm/src/arch/x86_64/gen/perf_event.rs
127- perl -i -pe ' s/= (\d+);/sprintf("= 0x%x;",$1)/eg' src/vmm/src/arch/x86_64/gen/perf_event.rs
128-
129- info " BINDGEN hyperv.h"
130- grep " HV_X64_MSR_" amazonlinux-v5.10.y/arch/x86/kvm/hyperv.h \
131- > amazonlinux-v5.10.y/arch/x86/kvm/hyperv_msr.h
132- fc-bindgen amazonlinux-v5.10.y/arch/x86/kvm/hyperv_msr.h \
133- --allowlist-var " ^HV_X64_MSR_.*$" \
134- -- \
135- > src/vmm/src/arch/x86_64/gen/hyperv.rs
136- perl -i -pe ' s/= (\d+);/sprintf("= 0x%x;",$1)/eg' src/vmm/src/arch/x86_64/gen/hyperv.rs
137-
138- info " BINDGEN hyperv-tlfs.h"
139- grep " HV_X64_MSR_" amazonlinux-v5.10.y/arch/x86/include/asm/hyperv-tlfs.h \
140- > amazonlinux-v5.10.y/arch/x86/include/asm/hyperv-tlfs_msr.h
141- fc-bindgen amazonlinux-v5.10.y/arch/x86/include/asm/hyperv-tlfs_msr.h \
142- --allowlist-var " ^HV_X64_MSR_.*$" \
143- -- \
144- > src/vmm/src/arch/x86_64/gen/hyperv_tlfs.rs
145- perl -i -pe ' s/= (\d+);/sprintf("= 0x%x;",$1)/eg' src/vmm/src/arch/x86_64/gen/hyperv_tlfs.rs
146-
147- info " BINDGEN io_uring.h"
44+ # KERNEL_HEADERS_HOME="/usr"
45+
46+ # info "BINDGEN sockios.h"
47+ # fc-bindgen "$KERNEL_HEADERS_HOME/include/linux/sockios.h" |replace_linux_int_types >src/vmm/src/devices/virtio/net/gen/sockios.rs
48+
49+ # info "BINDGEN if.h"
50+ # fc-bindgen "$KERNEL_HEADERS_HOME/include/linux/if.h" \
51+ # --allowlist-var='IF.*' \
52+ # --allowlist-type='if.*' \
53+ # --allowlist-type="net_device.*" \
54+ # -- -D __UAPI_DEF_IF_IFNAMSIZ -D __UAPI_DEF_IF_NET_DEVICE_FLAGS -D __UAPI_DEF_IF_IFREQ -D __UAPI_DEF_IF_IFMAP >src/vmm/src/devices/virtio/net/gen/iff.rs
55+
56+ # info "BINDGEN if_tun.h"
57+ # fc-bindgen \
58+ # --allowlist-type='sock_fprog' \
59+ # --allowlist-var='TUN_.*' \
60+ # --allowlist-var='IFF_NO_PI' \
61+ # --allowlist-var='IFF_MULTI_QUEUE' \
62+ # --allowlist-var='IFF_TAP' \
63+ # --allowlist-var='IFF_VNET_HDR' \
64+ # --allowlist-var='ETH_.*' \
65+ # --allowlist-type='ifreq' \
66+ # "$KERNEL_HEADERS_HOME/include/linux/if_tun.h" >src/vmm/src/devices/virtio/net/gen/if_tun.rs
67+
68+ # info "BINDGEN virtio_ring.h"
69+ # fc-bindgen \
70+ # --allowlist-var "VIRTIO_RING_F_EVENT_IDX" \
71+ # "$KERNEL_HEADERS_HOME/include/linux/virtio_ring.h" >src/vmm/src/devices/virtio/gen/virtio_ring.rs
72+
73+ # info "BINDGEN virtio_blk.h"
74+ # fc-bindgen \
75+ # --allowlist-var "VIRTIO_BLK_.*" \
76+ # --allowlist-var "VIRTIO_F_.*" \
77+ # "$KERNEL_HEADERS_HOME/include/linux/virtio_blk.h" >src/vmm/src/devices/virtio/gen/virtio_blk.rs
78+
79+ # info "BINDGEN virtio_net.h"
80+ # fc-bindgen \
81+ # --allowlist-var "VIRTIO_NET_F_.*" \
82+ # --allowlist-var "VIRTIO_F_.*" \
83+ # --allowlist-type "virtio_net_hdr_v1" \
84+ # "$KERNEL_HEADERS_HOME/include/linux/virtio_net.h" >src/vmm/src/devices/virtio/gen/virtio_net.rs
85+
86+ # info "BINDGEN virtio_rng.h"
87+ # fc-bindgen \
88+ # --allowlist-var "VIRTIO_RNG_.*" \
89+ # --allowlist-var "VIRTIO_F_.*" \
90+ # "$KERNEL_HEADERS_HOME/include/linux/virtio_rng.h" >src/vmm/src/devices/virtio/gen/virtio_rng.rs
91+
92+ # info "BINDGEN prctl.h"
93+ # fc-bindgen \
94+ # --allowlist-var "PR_.*" \
95+ # "$KERNEL_HEADERS_HOME/include/linux/prctl.h" >src/firecracker/src/gen/prctl.rs
96+ # sed -i '/PR_SET_SPECULATION_CTRL/s/u32/i32/g' src/firecracker/src/gen/prctl.rs
97+
98+ # # https://www.kernel.org/doc/Documentation/kbuild/headers_install.txt
99+ # # The Linux repo is huge. Just copy what we need.
100+ # # git clone --branch v5.10 --depth 1 https://github.com/torvalds/linux.git linux
101+ # git clone --branch linux-5.10.y --depth 1 https://github.com/amazonlinux/linux amazonlinux-v5.10.y
102+
103+ # info "BINDGEN mpspec_def.h"
104+ # fc-bindgen amazonlinux-v5.10.y/arch/x86/include/asm/mpspec_def.h \
105+ # >src/vmm/src/arch/x86_64/gen/mpspec.rs
106+ # # https://github.com/rust-lang/rust-bindgen/issues/1274
107+
108+ # info "BINDGEN msr-index.h"
109+ # cp -r amazonlinux-v5.10.y/include/asm-generic amazonlinux-v5.10.y/include/asm
110+ # sed -i -E 's/__no_(sanitize|kasan)_or_inline//g' amazonlinux-v5.10.y/include/asm/rwonce.h
111+ # fc-bindgen amazonlinux-v5.10.y/arch/x86/include/asm/msr-index.h \
112+ # --allowlist-var "^MSR_.*$" \
113+ # -- \
114+ # -Iamazonlinux-v5.10.y/include/ \
115+ # -Iamazonlinux-v5.10.y/arch/x86/include/ \
116+ # -Wno-macro-redefined \
117+ # >src/vmm/src/arch/x86_64/gen/msr_index.rs
118+ # perl -i -pe 's/= (\d+);/sprintf("= 0x%x;",$1)/eg' src/vmm/src/arch/x86_64/gen/msr_index.rs
119+
120+ # info "BINDGEN perf_event.h"
121+ # grep "MSR_ARCH_PERFMON_" amazonlinux-v5.10.y/arch/x86/include/asm/perf_event.h \
122+ # >amazonlinux-v5.10.y/arch/x86/include/asm/perf_event_msr.h
123+ # fc-bindgen amazonlinux-v5.10.y/arch/x86/include/asm/perf_event_msr.h \
124+ # --allowlist-var "^MSR_ARCH_PERFMON_.*$" \
125+ # -- \
126+ # >src/vmm/src/arch/x86_64/gen/perf_event.rs
127+ # perl -i -pe 's/= (\d+);/sprintf("= 0x%x;",$1)/eg' src/vmm/src/arch/x86_64/gen/perf_event.rs
128+
129+ # info "BINDGEN hyperv.h"
130+ # grep "HV_X64_MSR_" amazonlinux-v5.10.y/arch/x86/kvm/hyperv.h \
131+ # >amazonlinux-v5.10.y/arch/x86/kvm/hyperv_msr.h
132+ # fc-bindgen amazonlinux-v5.10.y/arch/x86/kvm/hyperv_msr.h \
133+ # --allowlist-var "^HV_X64_MSR_.*$" \
134+ # -- \
135+ # >src/vmm/src/arch/x86_64/gen/hyperv.rs
136+ # perl -i -pe 's/= (\d+);/sprintf("= 0x%x;",$1)/eg' src/vmm/src/arch/x86_64/gen/hyperv.rs
137+
138+ # info "BINDGEN hyperv-tlfs.h"
139+ # grep "HV_X64_MSR_" amazonlinux-v5.10.y/arch/x86/include/asm/hyperv-tlfs.h \
140+ # >amazonlinux-v5.10.y/arch/x86/include/asm/hyperv-tlfs_msr.h
141+ # fc-bindgen amazonlinux-v5.10.y/arch/x86/include/asm/hyperv-tlfs_msr.h \
142+ # --allowlist-var "^HV_X64_MSR_.*$" \
143+ # -- \
144+ # >src/vmm/src/arch/x86_64/gen/hyperv_tlfs.rs
145+ # perl -i -pe 's/= (\d+);/sprintf("= 0x%x;",$1)/eg' src/vmm/src/arch/x86_64/gen/hyperv_tlfs.rs
146+
147+ # info "BINDGEN io_uring.h"
148+ # fc-bindgen \
149+ # --allowlist-var "IORING_.+" \
150+ # --allowlist-var "IO_URING_.+" \
151+ # --allowlist-var "IOSQE_.+" \
152+ # --allowlist-type "io_uring_.+" \
153+ # --allowlist-type "io_.qring_offsets" \
154+ # "amazonlinux-v5.10.y/include/uapi/linux/io_uring.h" \
155+ # >src/vmm/src/io_uring/gen.rs
156+
157+ # Latest upstream kernel
158+ KERNEL_SRC_DIR=" linux"
159+ [ -d ${KERNEL_SRC_DIR} ] || git clone --depth 1 https://github.com/amazonlinux/linux ${KERNEL_SRC_DIR}
160+
161+ info " BINDGEN asm/prctl.h"
148162fc-bindgen \
149- --allowlist-var " IORING_.+" \
150- --allowlist-var " IO_URING_.+" \
151- --allowlist-var " IOSQE_.+" \
152- --allowlist-type " io_uring_.+" \
153- --allowlist-type " io_.qring_offsets" \
154- " amazonlinux-v5.10.y/include/uapi/linux/io_uring.h" \
155- > src/vmm/src/io_uring/gen.rs
163+ --allowlist-var " ARCH_.*" \
164+ " ${KERNEL_SRC_DIR} /arch/x86/include/uapi/asm/prctl.h" > src/vmm/src/arch/x86_64/gen/arch_prctl.rs
156165
157166# Apply any patches
158167info " Apply patches"
0 commit comments