crosvm/vfio_sys/bindgen.sh
Woody Chow 91296bdee0 devices: vvu: virtio-iommu support in virtio-vhost-user
Make vvu use devices use VFIO to manage their virt queues. This
alleviates the need to use noiommu mode. However, it is still necessary
to use `vfio_iommu_type1.allow_unsafe_interrupts=1`.

BUG=b:202151642,b:215310597
TEST=launch sibling with vvu + virtio-iommu

Cq-Depend: chromium:3565728, chromium:3565260
Change-Id: If418524598c40a37d41c0ffaa1dcc0f8ee11fcb3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3501052
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-04-08 01:39:22 +00:00

57 lines
1.7 KiB
Bash
Executable file

#!/usr/bin/env bash
# Copyright 2022 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Regenerate vfio_sys bindgen bindings.
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
source tools/impl/bindgen-common.sh
# VFIO_TYPE is translated as a u8 since it is a char constant, but it needs to be u32 for use in
# ioctl macros.
fix_vfio_type() {
sed -E -e 's/^pub const VFIO_TYPE: u8 = (.*)u8;/pub const VFIO_TYPE: u32 = \1;/'
}
VFIO_EXTRA="// Added by vfio_sys/bindgen.sh
use data_model::DataInit;
#[repr(C)]
#[derive(Debug, Default)]
pub struct vfio_region_info_with_cap {
pub region_info: vfio_region_info,
pub cap_info: __IncompleteArrayField<u8>,
}
// vfio_iommu_type1_info_cap_iova_range minus the incomplete iova_ranges
// array, so that Copy/DataInit can be implemented.
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct vfio_iommu_type1_info_cap_iova_range_header {
pub header: vfio_info_cap_header,
pub nr_iovas: u32,
pub reserved: u32,
}
// Safe because it only has data and no implicit padding.
unsafe impl DataInit for vfio_info_cap_header {}
// Safe because it only has data and no implicit padding.
unsafe impl DataInit for vfio_iommu_type1_info_cap_iova_range_header {}
// Safe because it only has data and no implicit padding.
unsafe impl DataInit for vfio_iova_range {}"
bindgen_generate \
--raw-line "${VFIO_EXTRA}" \
--allowlist-var='VFIO_.*' \
--blocklist-item='VFIO_DEVICE_API_.*_STRING' \
--allowlist-type='vfio_.*' \
"${BINDGEN_LINUX}/include/uapi/linux/vfio.h" \
-- \
-D__user= \
| replace_linux_int_types | fix_vfio_type \
> vfio_sys/src/vfio.rs