// SPDX-License-Identifier: GPL-2.0-only /* * VFIO PCI Intel Graphics support * * Copyright (C) 2016 Red Hat, Inc. All rights reserved. * Author: Alex Williamson <alex.williamson@redhat.com> * * Register a device specific region through which to provide read-only * access to the Intel IGD opregion. The register defining the opregion * address is also virtualized to prevent user modification.
*/
/** * igd_opregion_shift_copy() - Copy OpRegion to user buffer and shift position. * @dst: User buffer ptr to copy to. * @off: Offset to user buffer ptr. Increased by bytes on return. * @src: Source buffer to copy from. * @pos: Increased by bytes on return. * @remaining: Decreased by bytes on return. * @bytes: Bytes to copy and adjust off, pos and remaining. * * Copy OpRegion to offset from specific source ptr and shift the offset. * * Return: 0 on success, -EFAULT otherwise. *
*/ staticinlineunsignedlong igd_opregion_shift_copy(char __user *dst,
loff_t *off, void *src,
loff_t *pos,
size_t *remaining,
size_t bytes)
{ if (copy_to_user(dst + (*off), src, bytes)) return -EFAULT;
/* * OpRegion and VBT: * When VBT data doesn't exceed 6KB, it's stored in Mailbox #4. * When VBT data exceeds 6KB size, Mailbox #4 is no longer large enough * to hold the VBT data, the Extended VBT region is introduced since * OpRegion 2.0 to hold the VBT data. Since OpRegion 2.0, RVDA/RVDS are * introduced to define the extended VBT data location and size. * OpRegion 2.0: RVDA defines the absolute physical address of the * extended VBT data, RVDS defines the VBT data size. * OpRegion 2.1 and above: RVDA defines the relative address of the * extended VBT data to OpRegion base, RVDS defines the VBT data size. * * Due to the RVDA definition diff in OpRegion VBT (also the only diff * between 2.0 and 2.1), exposing OpRegion and VBT as a contiguous range * for OpRegion 2.0 and above makes it possible to support the * non-contiguous VBT through a single vfio region. From r/w ops view, * only contiguous VBT after OpRegion with version 2.1+ is exposed, * regardless the host OpRegion is 2.0 or non-contiguous 2.1+. The r/w * ops will on-the-fly shift the actural offset into VBT so that data at * correct position can be returned to the requester.
*/
version = le16_to_cpu(*(__le16 *)(opregionvbt->opregion +
OPREGION_VERSION)); if (version >= 0x0200) {
u64 rvda = le64_to_cpu(*(__le64 *)(opregionvbt->opregion +
OPREGION_RVDA));
u32 rvds = le32_to_cpu(*(__le32 *)(opregionvbt->opregion +
OPREGION_RVDS));
/* The extended VBT is valid only when RVDA/RVDS are non-zero */ if (rvda && rvds) {
size += rvds;
/* * Extended VBT location by RVDA: * Absolute physical addr for 2.0. * Relative addr to OpRegion header for 2.1+.
*/ if (version == 0x0200)
addr = rvda; else
addr += rvda;
/* Fill vconfig with the hw value and virtualize register */
*dwordp = cpu_to_le32(addr);
memset(vdev->pci_config_map + OPREGION_PCI_ADDR,
PCI_CAP_ID_INVALID_VIRT, 4);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.