• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2# Copyright 2022 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5#
6# Regenerate kvm_sys bindgen bindings.
7
8set -euo pipefail
9cd "$(dirname "${BASH_SOURCE[0]}")/.."
10
11source tools/impl/bindgen-common.sh
12
13KVM_EXTRAS="// Added by kvm_sys/bindgen.sh
14pub const KVM_SYSTEM_EVENT_S2IDLE: u32 = 4;
15pub const KVM_SYSTEM_EVENT_RESET_FLAG_PSCI_RESET2: u64 = 0x1;
16// TODO(tjeznach): Remove this when reporting KVM_IOAPIC_NUM_PINS is no longer required.
17pub const KVM_CAP_IOAPIC_NUM_PINS: u32 = 8191;
18// TODO(qwandor): Update this once the pKVM patches are merged upstream with a stable capability ID.
19pub const KVM_CAP_ARM_PROTECTED_VM: u32 = 0xffbadab1;
20pub const KVM_CAP_ARM_PROTECTED_VM_FLAGS_SET_FW_IPA: u32 = 0;
21pub const KVM_CAP_ARM_PROTECTED_VM_FLAGS_INFO: u32 = 1;
22pub const KVM_VM_TYPE_ARM_PROTECTED: u32 = 0x80000000;"
23
24bindgen_generate \
25    --raw-line "${KVM_EXTRAS}" \
26    --blocklist-item='__kernel.*' \
27    --blocklist-item='__BITS_PER_LONG' \
28    --blocklist-item='__FD_SETSIZE' \
29    --blocklist-item='_?IOC.*' \
30    "${BINDGEN_LINUX_X86_HEADERS}/include/linux/kvm.h" \
31    -- \
32    -isystem "${BINDGEN_LINUX_X86_HEADERS}/include" \
33    | replace_linux_int_types \
34    > kvm_sys/src/x86/bindings.rs
35
36bindgen_generate \
37    --raw-line "${KVM_EXTRAS}" \
38    --blocklist-item='__kernel.*' \
39    --blocklist-item='__BITS_PER_LONG' \
40    --blocklist-item='__FD_SETSIZE' \
41    --blocklist-item='_?IOC.*' \
42    "${BINDGEN_LINUX_ARM64_HEADERS}/include/linux/kvm.h" \
43    -- \
44    -isystem "${BINDGEN_LINUX_ARM64_HEADERS}/include" \
45    | replace_linux_int_types \
46    > kvm_sys/src/aarch64/bindings.rs
47