pvIOMMU is moving from experimental UAPI to Android16-6.12 Bug: 357781595 Bug: 348382247 Bug: 236685427 Change-Id: I35899049569286e8f047cba9a996d3797212ae95 Signed-off-by: Mostafa Saleh <smostafa@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/6680690 Reviewed-by: Frederick Mayle <fmayle@google.com> Commit-Queue: Frederick Mayle <fmayle@google.com>
120 lines
5.5 KiB
Bash
Executable file
120 lines
5.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Copyright 2022 The ChromiumOS Authors
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
# Regenerate kvm_sys bindgen bindings.
|
|
|
|
set -euo pipefail
|
|
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
|
|
|
source tools/impl/bindgen-common.sh
|
|
|
|
KVM_EXTRAS="// Added by kvm_sys/bindgen.sh
|
|
use zerocopy::FromBytes;
|
|
use zerocopy::Immutable;
|
|
use zerocopy::IntoBytes;
|
|
use zerocopy::KnownLayout;
|
|
|
|
// TODO(b/388092267): Replace this with an upstream equivalent when available.
|
|
// The original index (236) used in the ChromeOS v6.6 kernel was reused upstream for another
|
|
// capability, so this may return incorrect information on some kernels.
|
|
pub const KVM_CAP_USER_CONFIGURE_NONCOHERENT_DMA_CROS: u32 = 236;
|
|
pub const KVM_CAP_USER_CONFIGURE_NONCOHERENT_DMA: u32 = 239;
|
|
pub const KVM_MEM_NON_COHERENT_DMA: u32 = 8;
|
|
|
|
// TODO(qwandor): Update this once the pKVM patches are merged upstream with a stable capability ID.
|
|
pub const KVM_CAP_ARM_PROTECTED_VM: u32 = 0xffbadab1;
|
|
pub const KVM_CAP_ARM_PROTECTED_VM_FLAGS_SET_FW_IPA: u32 = 0;
|
|
pub const KVM_CAP_ARM_PROTECTED_VM_FLAGS_INFO: u32 = 1;
|
|
pub const KVM_CAP_ARM_PROTECTED_VM_FLAGS_SET_FFA: u32 = 2;
|
|
pub const KVM_VM_TYPE_ARM_PROTECTED: u32 = 0x80000000;
|
|
pub const KVM_X86_PKVM_PROTECTED_VM: u32 = 28;
|
|
pub const KVM_CAP_X86_PROTECTED_VM: u32 = 0xffbadab2;
|
|
pub const KVM_CAP_X86_PROTECTED_VM_FLAGS_SET_FW_GPA: u32 = 0;
|
|
pub const KVM_CAP_X86_PROTECTED_VM_FLAGS_INFO: u32 = 1;
|
|
pub const KVM_DEV_VFIO_PVIOMMU: u32 = 5;
|
|
pub const KVM_DEV_VFIO_PVIOMMU_ATTACH: u32 = 1;
|
|
#[repr(C)]
|
|
#[derive(Debug, Default, Copy, Clone)]
|
|
pub struct kvm_vfio_iommu_info {
|
|
pub size: u32,
|
|
pub device_fd: i32,
|
|
pub nr_sids: u32,
|
|
pub __reserved: u32,
|
|
}
|
|
pub const KVM_DEV_VFIO_PVIOMMU_GET_INFO: u32 = 2;
|
|
#[repr(C)]
|
|
#[derive(Debug, Default, Copy, Clone)]
|
|
pub struct kvm_vfio_iommu_config {
|
|
pub size: u32,
|
|
pub device_fd: i32,
|
|
pub sid_idx: u32,
|
|
pub vsid: u32,
|
|
pub __reserved: u32,
|
|
}"
|
|
|
|
bindgen_generate \
|
|
--raw-line "${KVM_EXTRAS}" \
|
|
--blocklist-item='__kernel.*' \
|
|
--blocklist-item='__BITS_PER_.*' \
|
|
--blocklist-item='__FD_SETSIZE' \
|
|
--blocklist-item='_?IOC.*' \
|
|
--with-derive-custom "kvm_regs=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_sregs=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_fpu=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_debugregs=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_xcr=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_xcrs=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_lapic_state=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_mp_state=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_vcpu_events=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_vcpu_events__bindgen_ty_1=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_vcpu_events__bindgen_ty_2=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_vcpu_events__bindgen_ty_3=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_vcpu_events__bindgen_ty_4=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_vcpu_events__bindgen_ty_5=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_dtable=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_segment=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_pic_state=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_pit_state2=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_clock_data=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_pit_channel_state=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
"${BINDGEN_LINUX_X86_HEADERS}/include/linux/kvm.h" \
|
|
-- \
|
|
-isystem "${BINDGEN_LINUX_X86_HEADERS}/include" \
|
|
| replace_linux_int_types \
|
|
> kvm_sys/src/x86/bindings.rs
|
|
|
|
bindgen_generate \
|
|
--raw-line "${KVM_EXTRAS}" \
|
|
--blocklist-item='__kernel.*' \
|
|
--blocklist-item='__BITS_PER_.*' \
|
|
--blocklist-item='__FD_SETSIZE' \
|
|
--blocklist-item='_?IOC.*' \
|
|
--with-derive-custom "kvm_regs=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_sregs=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_fpu=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_vcpu_events=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_vcpu_events__bindgen_ty_1=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "kvm_mp_state=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "user_fpsimd_state=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
--with-derive-custom "user_pt_regs=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
"${BINDGEN_LINUX_ARM64_HEADERS}/include/linux/kvm.h" \
|
|
-- \
|
|
-isystem "${BINDGEN_LINUX_ARM64_HEADERS}/include" \
|
|
| replace_linux_int_types \
|
|
> kvm_sys/src/aarch64/bindings.rs
|
|
|
|
bindgen_generate \
|
|
--raw-line "${KVM_EXTRAS}" \
|
|
--blocklist-item='__kernel.*' \
|
|
--blocklist-item='__BITS_PER_.*' \
|
|
--blocklist-item='__FD_SETSIZE' \
|
|
--blocklist-item='_?IOC.*' \
|
|
--with-derive-custom "kvm_regs=FromBytes,Immutable,IntoBytes,KnownLayout" \
|
|
"${BINDGEN_LINUX_RISCV_HEADERS}/include/linux/kvm.h" \
|
|
-- \
|
|
-isystem "${BINDGEN_LINUX_RISCV_HEADERS}/include" \
|
|
| replace_linux_int_types \
|
|
> kvm_sys/src/riscv64/bindings.rs
|