From 81e6512014619d1fe35c4a86bb7d4d952a9dcd0c Mon Sep 17 00:00:00 2001 From: Jing Chen Date: Thu, 21 Mar 2024 23:41:05 -0700 Subject: [PATCH] Implmenet ioctl command VFIO_DEVICE_RESET. PiperOrigin-RevId: 618077589 --- pkg/abi/linux/vfio.go | 1 + pkg/sentry/devices/tpuproxy/tpu.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/pkg/abi/linux/vfio.go b/pkg/abi/linux/vfio.go index b8c2b7a66..44f458899 100644 --- a/pkg/abi/linux/vfio.go +++ b/pkg/abi/linux/vfio.go @@ -106,6 +106,7 @@ var ( VFIO_DEVICE_GET_REGION_INFO = IO(VFIO_TYPE, VFIO_BASE+8) VFIO_DEVICE_GET_IRQ_INFO = IO(VFIO_TYPE, VFIO_BASE+9) VFIO_DEVICE_SET_IRQS = IO(VFIO_TYPE, VFIO_BASE+10) + VFIO_DEVICE_RESET = IO(VFIO_TYPE, VFIO_BASE+11) ) // VFIODeviceInfo is analogous to vfio_device_info diff --git a/pkg/sentry/devices/tpuproxy/tpu.go b/pkg/sentry/devices/tpuproxy/tpu.go index 477906ccd..8cd612ab8 100644 --- a/pkg/sentry/devices/tpuproxy/tpu.go +++ b/pkg/sentry/devices/tpuproxy/tpu.go @@ -242,6 +242,9 @@ func (fd *pciDeviceFD) Ioctl(ctx context.Context, uio usermem.IO, sysno uintptr, return fd.vfioIrqInfo(ctx, t, args[2].Pointer()) case linux.VFIO_DEVICE_SET_IRQS: return fd.vfioSetIrqs(ctx, t, args[2].Pointer()) + case linux.VFIO_DEVICE_RESET: + // VFIO_DEVICE_RESET is just a simple IOCTL command that carries no data. + return IOCTLInvoke[uint32, uintptr](fd.hostFD, linux.VFIO_DEVICE_RESET, 0) } return 0, linuxerr.ENOSYS }