VMCI: Add support for ARM64
authorVishnu Dasa <vdasa@vmware.com>
Thu, 14 Apr 2022 19:33:16 +0000 (12:33 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 24 Apr 2022 15:32:14 +0000 (17:32 +0200)
Add support for ARM64 architecture so that the driver can now be built
and VMCI device can be used.

Update Kconfig file to allow the driver to be built on ARM64 as well.
Fail vmci_guest_probe_device() on ARM64 if the device does not support
MMIO register access.  Lastly, add virtualization specific barriers
which map to actual memory barrier instructions on ARM64, because it
is required in case of ARM64 for queuepair (de)queuing.

Reviewed-by: Bryan Tan <bryantan@vmware.com>
Reviewed-by: Cyprien Laplace <claplace@vmware.com>
Signed-off-by: Vishnu Dasa <vdasa@vmware.com>
Link: https://lore.kernel.org/r/20220414193316.14356-1-vdasa@vmware.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/vmw_vmci/Kconfig
drivers/misc/vmw_vmci/vmci_guest.c
drivers/misc/vmw_vmci/vmci_queue_pair.c

index 605794aadf11809bebdceffc84434addce65db85..b6d4d7fd686a5275aa4bb86c6b04c1f0e240849c 100644 (file)
@@ -5,7 +5,7 @@
 
 config VMWARE_VMCI
        tristate "VMware VMCI Driver"
-       depends on X86 && PCI
+       depends on (X86 || ARM64) && !CPU_BIG_ENDIAN && PCI
        help
          This is VMware's Virtual Machine Communication Interface.  It enables
          high-speed communication between host and guest in a virtual
index 57a6157209a19f039cc87bbd6a0870ea92b24b46..aa7b05de97dd52d84fa04615912af9df46f7fb5f 100644 (file)
@@ -614,6 +614,10 @@ static int vmci_guest_probe_device(struct pci_dev *pdev,
        }
 
        if (!mmio_base) {
+               if (IS_ENABLED(CONFIG_ARM64)) {
+                       dev_err(&pdev->dev, "MMIO base is invalid\n");
+                       return -ENXIO;
+               }
                error = pcim_iomap_regions(pdev, BIT(0), KBUILD_MODNAME);
                if (error) {
                        dev_err(&pdev->dev, "Failed to reserve/map IO regions\n");
index 94ebf7f3fd58a6e4829925b2f2d85a1000f06c22..8f2de1893245ae91140629e3923b5bd26d09ae8d 100644 (file)
@@ -2577,6 +2577,12 @@ static ssize_t qp_enqueue_locked(struct vmci_queue *produce_q,
        if (result < VMCI_SUCCESS)
                return result;
 
+       /*
+        * This virt_wmb() ensures that data written to the queue
+        * is observable before the new producer_tail is.
+        */
+       virt_wmb();
+
        vmci_q_header_add_producer_tail(produce_q->q_header, written,
                                        produce_q_size);
        return written;
@@ -2620,6 +2626,12 @@ static ssize_t qp_dequeue_locked(struct vmci_queue *produce_q,
        if (buf_ready < VMCI_SUCCESS)
                return (ssize_t) buf_ready;
 
+       /*
+        * This virt_rmb() ensures that data from the queue will be read
+        * after we have determined how much is ready to be consumed.
+        */
+       virt_rmb();
+
        read = (size_t) (buf_ready > buf_size ? buf_size : buf_ready);
        head = vmci_q_header_consumer_head(produce_q->q_header);
        if (likely(head + read < consume_q_size)) {