History log of /kvmtool/virtio/pci.c (Results 1 – 25 of 90)
Revision Date Author Comments
# d560235f 12-Sep-2023 Keir Fraser <keirf@google.com>

virtio/pci: Use consistent naming for the PCI ISR bit flags

Avoid using VIRTIO_IRQ_{HIGH,LOW} which belong to a different
namespace. Instead define VIRTIO_PCI_ISR_QUEUE as a logical extension
of th

virtio/pci: Use consistent naming for the PCI ISR bit flags

Avoid using VIRTIO_IRQ_{HIGH,LOW} which belong to a different
namespace. Instead define VIRTIO_PCI_ISR_QUEUE as a logical extension
of the VIRTIO_PCI_ISR_* namespace. Since this bit flag is missing from
a header imported verbatim from Linux, define it directly in pci.c.

Signed-off-by: Keir Fraser <keirf@google.com>
Link: https://lore.kernel.org/r/20230912151623.2558794-4-keirf@google.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# 29214484 12-Sep-2023 Keir Fraser <keirf@google.com>

virtio/pci: Treat PCI ISR as a set of bit flags

The PCI ISR is defined in the virtio spec as a set of flags which can
be bitwise ORed together. Therefore we should avoid clearing
previously-set flag

virtio/pci: Treat PCI ISR as a set of bit flags

The PCI ISR is defined in the virtio spec as a set of flags which can
be bitwise ORed together. Therefore we should avoid clearing
previously-set flags.

Signed-off-by: Keir Fraser <keirf@google.com>
Link: https://lore.kernel.org/r/20230912151623.2558794-3-keirf@google.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# 353fa0d8 12-Sep-2023 Keir Fraser <keirf@google.com>

virtio/pci: Level-trigger the legacy IRQ line in all cases

The PCI legacy IRQ line is level triggered, but is treated as
edge triggered via kvm__irq_trigger() for signalling of config
changes.

Fix

virtio/pci: Level-trigger the legacy IRQ line in all cases

The PCI legacy IRQ line is level triggered, but is treated as
edge triggered via kvm__irq_trigger() for signalling of config
changes.

Fix this by using kvm__irq_level(), as for queue signalling.

Signed-off-by: Keir Fraser <keirf@google.com>
Link: https://lore.kernel.org/r/20230912151623.2558794-2-keirf@google.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# c86ef0b8 01-Jul-2022 Jean-Philippe Brucker <jean-philippe.brucker@arm.com>

virtio/pci: Remove VIRTIO_PCI_F_SIGNAL_MSI

VIRTIO_PCI_F_SIGNAL_MSI is not a virtio feature but an internal flag.
Change it to bool to avoid confusion.

Signed-off-by: Jean-Philippe Brucker <jean-phi

virtio/pci: Remove VIRTIO_PCI_F_SIGNAL_MSI

VIRTIO_PCI_F_SIGNAL_MSI is not a virtio feature but an internal flag.
Change it to bool to avoid confusion.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Link: https://lore.kernel.org/r/20220701142434.75170-13-jean-philippe.brucker@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# 3d5cefc2 01-Jul-2022 Jean-Philippe Brucker <jean-philippe.brucker@arm.com>

virtio/pci: Initialize all vectors to VIRTIO_MSI_NO_VECTOR

According to the virtio spec, all vectors must be initialized to
VIRTIO_MSI_NO_VECTOR (0xffff). In 4.1.5.1.2.1 "Device Requirements:
MSI-X

virtio/pci: Initialize all vectors to VIRTIO_MSI_NO_VECTOR

According to the virtio spec, all vectors must be initialized to
VIRTIO_MSI_NO_VECTOR (0xffff). In 4.1.5.1.2.1 "Device Requirements:
MSI-X Vector Configuration":

The device MUST return vector mapped to a given event, (NO_VECTOR if
unmapped) on read of config_msix_vector/queue_msix_vector.

Currently we return 0, which is a valid MSI vector. Return NO_VECTOR
instead.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Link: https://lore.kernel.org/r/20220701142434.75170-12-jean-philippe.brucker@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# b0d56e3c 01-Jul-2022 Jean-Philippe Brucker <jean-philippe.brucker@arm.com>

virtio: Add support for modern virtio-pci

Add support for modern virtio-pci implementation (based on the 1.0 virtio
spec). We add a new transport, alongside MMIO and PCI-legacy. This is now
the defa

virtio: Add support for modern virtio-pci

Add support for modern virtio-pci implementation (based on the 1.0 virtio
spec). We add a new transport, alongside MMIO and PCI-legacy. This is now
the default when selecting PCI, but users can still select the legacy
transport for all virtio devices by passing "--virtio-legacy" on the
command-line.

The main change in modern PCI is the way we address virtqueues, using
64-bit values instead of PFNs. To keep the queue configuration atomic the
device also gets a "queue enable" register. Configuration is also made
extensible by more feature bits and PCI capabilities. Scalability is
improved as well, as devices can have notification registers for each
virtqueue on separate pages. However this implementation keeps a single
notification register.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Link: https://lore.kernel.org/r/20220701142434.75170-9-jean-philippe.brucker@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# 930876d5 01-Jul-2022 Jean-Philippe Brucker <jean-philippe.brucker@arm.com>

virtio: Move PCI transport to pci-legacy

To make space for the more recent virtio version, move the legacy bits of
virtio-pci to a different file.

Signed-off-by: Jean-Philippe Brucker <jean-philipp

virtio: Move PCI transport to pci-legacy

To make space for the more recent virtio version, move the legacy bits of
virtio-pci to a different file.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Link: https://lore.kernel.org/r/20220701142434.75170-8-jean-philippe.brucker@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# 73fd1368 01-Jul-2022 Jean-Philippe Brucker <jean-philippe.brucker@arm.com>

virtio/pci: Use the correct eventfd for vhost notification

Legacy virtio drivers write to the I/O port BAR, and the modern virtio
device uses the MMIO BAR. Since vhost can only listen on one ioevent

virtio/pci: Use the correct eventfd for vhost notification

Legacy virtio drivers write to the I/O port BAR, and the modern virtio
device uses the MMIO BAR. Since vhost can only listen on one ioeventfd,
select the one that the guest will use.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Link: https://lore.kernel.org/r/20220701142434.75170-5-jean-philippe.brucker@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# 21c9bc74 01-Jul-2022 Jean-Philippe Brucker <jean-philippe.brucker@arm.com>

virtio/pci: Make doorbell offset dynamic

The doorbell offset depends on the transport - virtio-legacy uses a
fixed offset, but modern virtio can have per-vq offsets. Add an offset
field to the virti

virtio/pci: Make doorbell offset dynamic

The doorbell offset depends on the transport - virtio-legacy uses a
fixed offset, but modern virtio can have per-vq offsets. Add an offset
field to the virtio_pci structure.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Link: https://lore.kernel.org/r/20220701142434.75170-4-jean-philippe.brucker@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# d0607293 01-Jul-2022 Jean-Philippe Brucker <jean-philippe.brucker@arm.com>

virtio: Extract init_vq() for PCI and MMIO

Modern virtio will need to reuse this code when initializing a
virtqueue. It's not much, but still nicer to have next to exit_vq().

Signed-off-by: Jean-Ph

virtio: Extract init_vq() for PCI and MMIO

Modern virtio will need to reuse this code when initializing a
virtqueue. It's not much, but still nicer to have next to exit_vq().

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Link: https://lore.kernel.org/r/20220701142434.75170-3-jean-philippe.brucker@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# c6590f78 01-Jul-2022 Jean-Philippe Brucker <jean-philippe.brucker@arm.com>

virtio/pci: Delete MSI routes

On exit_vq() and device reset, remove the MSI routes that were set up at
runtime.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Link: https://lo

virtio/pci: Delete MSI routes

On exit_vq() and device reset, remove the MSI routes that were set up at
runtime.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Link: https://lore.kernel.org/r/20220701142434.75170-2-jean-philippe.brucker@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# f44af23e 07-Jun-2022 Jean-Philippe Brucker <jean-philippe.brucker@arm.com>

virtio/pci: Factor MSI route creation

The code for creating an MSI route is already duplicated between config
and virtqueue MSI. Modern virtio will need it as well, so move it to a
separate function

virtio/pci: Factor MSI route creation

The code for creating an MSI route is already duplicated between config
and virtqueue MSI. Modern virtio will need it as well, so move it to a
separate function.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Link: https://lore.kernel.org/r/20220607170239.120084-17-jean-philippe.brucker@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# 15e6c4e7 07-Jun-2022 Jean-Philippe Brucker <jean-philippe.brucker@arm.com>

virtio: Add config access helpers

At the moment device-specific config access is tailored for a Linux
guest, that performs any access in 8 bits. But config access can have
any size, and modern virti

virtio: Add config access helpers

At the moment device-specific config access is tailored for a Linux
guest, that performs any access in 8 bits. But config access can have
any size, and modern virtio drivers must use the size of the accessed
field. Add helpers that generalize config accesses.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Link: https://lore.kernel.org/r/20220607170239.120084-7-jean-philippe.brucker@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# 609ee906 07-Jun-2022 Jean-Philippe Brucker <jean-philippe.brucker@arm.com>

virtio: Support modern virtqueue addresses

Modern virtio devices can use separate buffer for descriptors, available
and used rings. They can also use 64-bit addresses instead of 44-bit.
Rework the v

virtio: Support modern virtqueue addresses

Modern virtio devices can use separate buffer for descriptors, available
and used rings. They can also use 64-bit addresses instead of 44-bit.
Rework the virtqueue initialization function to support modern virtio.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Link: https://lore.kernel.org/r/20220607170239.120084-6-jean-philippe.brucker@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# 31e0eacc 09-May-2022 Martin Radev <martin.b.radev@gmail.com>

virtio: Check for overflows in QUEUE_NOTIFY and QUEUE_SEL

This patch checks for overflows in QUEUE_NOTIFY and QUEUE_SEL in
the PCI and MMIO operation handling paths. Further, the return
value type o

virtio: Check for overflows in QUEUE_NOTIFY and QUEUE_SEL

This patch checks for overflows in QUEUE_NOTIFY and QUEUE_SEL in
the PCI and MMIO operation handling paths. Further, the return
value type of get_vq_count is changed from int to uint since negative
doesn't carry any semantic meaning.

Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: Martin Radev <martin.b.radev@gmail.com>
Link: https://lore.kernel.org/r/20220509203940.754644-6-martin.b.radev@gmail.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# e4730284 09-May-2022 Martin Radev <martin.b.radev@gmail.com>

virtio: Sanitize config accesses

The handling of VIRTIO_PCI_O_CONFIG is prone to buffer access overflows.
This patch sanitizes this operation by using the newly added virtio op
get_config_size. Any

virtio: Sanitize config accesses

The handling of VIRTIO_PCI_O_CONFIG is prone to buffer access overflows.
This patch sanitizes this operation by using the newly added virtio op
get_config_size. Any access which goes beyond the config structure's
size is prevented and a failure is returned.

Additionally, PCI accesses which span more than a single byte are prevented
and a warning is printed because the implementation does not currently
support the behavior correctly.

Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: Martin Radev <martin.b.radev@gmail.com>
Link: https://lore.kernel.org/r/20220509203940.754644-5-martin.b.radev@gmail.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# 06e1e6fe 09-May-2022 Martin Radev <martin.b.radev@gmail.com>

virtio: Use u32 instead of int in pci_data_in/out

The PCI access size type is changed from a signed type
to an unsigned type since the size is never expected to
be negative, and the type also matche

virtio: Use u32 instead of int in pci_data_in/out

The PCI access size type is changed from a signed type
to an unsigned type since the size is never expected to
be negative, and the type also matches the type in the
signature of virtio_pci__io_mmio_callback.
This change simplifies size checking in the next patch.

Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: Martin Radev <martin.b.radev@gmail.com>
Link: https://lore.kernel.org/r/20220509203940.754644-4-martin.b.radev@gmail.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# 2108c86d 31-Jan-2022 Marc Zyngier <maz@kernel.org>

virtio/pci: Signal INTx interrupts as level instead of edge

It appears that the way INTx is emulated is "slightly" out of spec
in kvmtool. We happily inject an edge interrupt, even if the spec
manda

virtio/pci: Signal INTx interrupts as level instead of edge

It appears that the way INTx is emulated is "slightly" out of spec
in kvmtool. We happily inject an edge interrupt, even if the spec
mandates a level.

This doesn't change much for either the guest or userspace (only
KVM will have a bit more work tracking the EOI), but at least
this is correct.

Reported-by: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Will Deacon <will@kernel.org>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20220131160242.2665191-1-maz@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# 2e7380db 27-Aug-2021 Marc Zyngier <maz@kernel.org>

virtio/pci: Size the MSI-X bar according to the number of MSI-X

Since 45d3b59e8c45 ("kvm tools: Increase amount of possible interrupts
per PCI device"), the number of MSI-S has gone from 4 to 33.

H

virtio/pci: Size the MSI-X bar according to the number of MSI-X

Since 45d3b59e8c45 ("kvm tools: Increase amount of possible interrupts
per PCI device"), the number of MSI-S has gone from 4 to 33.

However, the corresponding storage hasn't been upgraded, and writing
to the MSI-X table is a pretty risky business. Now that the Linux
kernel writes to *all* MSI-X entries before doing anything else
with the device, kvmtool dies a horrible death.

Fix it by properly defining the size of the MSI-X bar, and make
Linux great again.

This includes some fixes the PBA region decoding, as well as minor
cleanups to make this code a bit more maintainable.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Link: https://lore.kernel.org/r/20210827115405.1981529-1-maz@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# 205eaa79 15-Mar-2021 Andre Przywara <andre.przywara@arm.com>

virtio: Switch trap handling to use MMIO handler

With the planned retirement of the special ioport emulation code, we
need to provide an emulation function compatible with the MMIO prototype.

Adjus

virtio: Switch trap handling to use MMIO handler

With the planned retirement of the special ioport emulation code, we
need to provide an emulation function compatible with the MMIO prototype.

Adjust the existing MMIO callback routine to automatically determine
the region this trap came through, and call the existing I/O handlers.
Register the ioport region using the new registration function.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
Link: https://lore.kernel.org/r/20210315153350.19988-18-andre.przywara@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# 5a8e4f25 14-May-2020 Alexandru Elisei <alexandru.elisei@arm.com>

pci: Implement callbacks for toggling BAR emulation

Implement callbacks for activating and deactivating emulation for a BAR
region. This is in preparation for allowing a guest operating system to
en

pci: Implement callbacks for toggling BAR emulation

Implement callbacks for activating and deactivating emulation for a BAR
region. This is in preparation for allowing a guest operating system to
enable and disable access to I/O or memory space, or to reassign the
BARs.

The emulated vesa device framebuffer isn't designed to allow stopping and
restarting at arbitrary points in the guest execution. Furthermore, on x86,
the kernel will not change the BAR addresses, which on bare metal are
programmed by the firmware, so take the easy way out and refuse to
activate/deactivate emulation for the BAR regions. We also take this
opportunity to make the vesa emulation code more consistent by moving all
static variable definitions in one place, at the top of the file.

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Link: https://lore.kernel.org/r/1589470709-4104-9-git-send-email-alexandru.elisei@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# e539f3e4 14-May-2020 Alexandru Elisei <alexandru.elisei@arm.com>

virtio/pci: Get emulated region address from BARs

The struct virtio_pci fields port_addr, mmio_addr and msix_io_block
represent the same addresses that are written in the corresponding BARs.
Remove

virtio/pci: Get emulated region address from BARs

The struct virtio_pci fields port_addr, mmio_addr and msix_io_block
represent the same addresses that are written in the corresponding BARs.
Remove this duplication of information and always use the address from the
BAR. This will make our life a lot easier when we add support for
reassignable BARs, because we won't have to update the fields on each BAR
change.

No functional changes.

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Link: https://lore.kernel.org/r/1589470709-4104-4-git-send-email-alexandru.elisei@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# c0c45eed 24-Apr-2020 Andre Przywara <andre.przywara@arm.com>

pci: Move legacy IRQ assignment into devices

So far the (legacy) IRQ line for a PCI device is allocated in devices.c,
which should actually not take care of that. Since we allocate all other
device

pci: Move legacy IRQ assignment into devices

So far the (legacy) IRQ line for a PCI device is allocated in devices.c,
which should actually not take care of that. Since we allocate all other
device specific resources in the actual device emulation code, the IRQ
should not be something special.

Remove the PCI specific code from devices.c, and move the IRQ line
allocation to the PCI code.
This drops the IRQ line from the VESA device, since it does not use one.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# e09b599a 14-Apr-2020 Julien Thierry <julien.thierry@arm.com>

virtio/pci: Make memory and IO BARs independent

Currently, callbacks for memory BAR 1 call the IO port emulation. This
means that the memory BAR needs I/O Space to be enabled whenever Memory
Space

virtio/pci: Make memory and IO BARs independent

Currently, callbacks for memory BAR 1 call the IO port emulation. This
means that the memory BAR needs I/O Space to be enabled whenever Memory
Space is enabled.

Refactor the code so the two type of BARs are independent. Also, unify
ioport/mmio callback arguments so that they all receive a virtio_device.

Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Julien Thierry <julien.thierry@arm.com>
[Cosmetic changes wrt to where local variables are initialized]
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


# 48843d10 14-Apr-2020 Julien Thierry <julien.thierry@arm.com>

pci: Fix ioport allocation size

The PCI Local Bus Specification, Rev. 3.0,
Section 6.2.5.1. "Address Maps" states:
"Devices that map control functions into I/O Space must not consume more
than 256 b

pci: Fix ioport allocation size

The PCI Local Bus Specification, Rev. 3.0,
Section 6.2.5.1. "Address Maps" states:
"Devices that map control functions into I/O Space must not consume more
than 256 bytes per I/O Base Address register."

Yet all the PCI devices allocate IO ports of IOPORT_SIZE (= 1024 bytes).

Fix this by having PCI devices use 256 bytes ports for IO BARs.

There is no hard requirement on the size of the memory region described
by memory BARs. Since BAR 1 is supposed to offer the same functionality as
IO ports, let's make its size match BAR 0.

Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Julien Thierry <julien.thierry@arm.com>
[Added rationale for changing BAR1 size to PCI_IO_SIZE]
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>

show more ...


1234